opensubscriber
   Find in this group all groups
 
Unknown more information…

m : macapp-dev@lists.apple.com 5 December 2005 • 11:52PM -0500

R16 - Cluster Printing (part 3)
by Steve Graesser

REPLY TO AUTHOR
 
REPLY TO GROUP




Hi All,

More workarounds for printing controls under Carbon.

The TCluster class has been re-written to use the standard toolbox
control; GROUP BOX (CDEF 10). This change was necessary to get the
control to draw to a gworld when printing. The TPrimaryCluster::Draw
method creates a gworld and then calls the DrawThemePrimaryGroup
function to draw the control to the gworld. The gworld is then copied to
the printing port.

The TSecondaryCluster::Draw method creates a gworld and then calls the
DrawThemeSecondaryGroup function to draw the control to the gworld.

The Change Log for all file changes are include below:

Steve

Index: macapp.16/MacApp/Libraries/Views/UCluster.cpp
===================================================================
RCS file: /home1/frmwrks/clubmacapp/cvs/macapp.16/MacApp/Libraries/Views/
UCluster.cpp,v
retrieving revision 1.2
diff -r1.2 UCluster.cpp
469,474c377,378
< SInt16 TCluster::GetGapLeftInset(const CRect_AC& boundsRect, SInt16 gapSize)
< {
< // Return the number of pixels from the left edge of the group box
< // to the start of the gap. This depends on the title justification,
< // because the gap is not necessarily a fixed number of pixels from
< // the left.
---
> CToolboxControl_AC* aToolboxControl = TH_new CToolboxControl_AC
(theControl);
> ::ThrowIfNULL_AC(aToolboxControl);
476c380,381
< SInt16 inset;
---
> aToolboxControl->SetVisibility(isVisible);
> aToolboxControl->SetActive(isEnabled);
478,491c383
< switch (CTextStyle_AC::RuntimeJustify(teFlushDefault))
< {
< case teCenter:
< inset = (boundsRect.right - boundsRect.left - gapSize - 12) / 2;
< break;
< case teFlushRight:
< inset = boundsRect.right - boundsRect.left - gapSize - 12;
< break;
< default: //case teFlushLeft:
< inset = 10;
< break;
< }
<
< return inset;
---
> return aToolboxControl;
500c392
< return fLabel.AsString();
---
> return GetTitle();
510,513c402,411
< // Convert to a Unicode string
< CUniString_AC uniStr(theLabel);
<
< SetUnicodeLabel(uniStr, redraw);
---
> SetTitle(theLabel, redraw);
> }
>
> //---------------------------------
-------------------------------------------------------
> // TCluster::GetUnicodeLabel:
> //---------------------------------
-------------------------------------------------------
>
> CUniString_AC TCluster::GetUnicodeLabel() const
> {
> return GetUnicodeTitle();
523,525c421
< fLabel = theLabel;
< if (redraw)
< ForceRedraw();
---
> SetUnicodeTitle(theLabel, redraw);
540,541d435
< SetUnicodeLabel(aString, kDontRedraw);
< }
543,544c437,438
< if (redraw)
< ForceRedraw();
---
> SetUnicodeTitle(aString, redraw);
> }
565,597d458
< //---------------------------------
-------------------------------------------------------
< // TCluster::Activate:
< //---------------------------------
-------------------------------------------------------
<
< void TCluster::Activate(bool entering)
< {
< if (fWasActive != entering && Focus() && IsVisible())
< {
< fWasActive = entering;
<
< // if (!HasPendingUpdate())
< // DrawContents();
< // else
< ForceRedraw(); //DrawCluster(); // Draws the label and edges of
cluster in the appropriate state.
< }
<
< // don't let inherited add a dim adorner.
< }
<
< //---------------------------------
-------------------------------------------------------
< // TCluster::DoMouseCommand:
< //---------------------------------
-------------------------------------------------------
<
< void TCluster::DoMouseCommand(CViewPoint& theMouse,
<   TToolboxEvent* event,
<   CPoint_AC hysteresis)
< {
< #pragma unused (theMouse, event, hysteresis)
<
< // Group box drawing can be based on enable state, but we don't
< // want clicking on the group box itself to cause highlighting.
< }
<
600a462,463
> #undef Inherited
> #define Inherited TCluster
638,646d500
< // TPrimaryCluster::IsDrawingBorder:
< //---------------------------------
-------------------------------------------------------
<
< bool TPrimaryCluster::IsDrawingBorder() const
< {
< return true;
< }
<
< //---------------------------------
-------------------------------------------------------
669c523
< // TPrimaryCluster::DoPostCreate:
---
> // TPrimaryCluster::Draw:
670a525,529
>
> void TPrimaryCluster::Draw(const CViewRect& area)
> {
> if (gPrinting) {
> CUniString_AC title = GetUnicodeTitle();
672c531,585
< void TPrimaryCluster::DoPostCreate(TDocument* itsDocument)
---
> fTextStyle.SetPortTextStyle(); // calculate gap for title's text style
>
> ThemeFontID fontID = kThemeCurrentPortFont;
> ThemeDrawState theState = fIsActive ? kThemeStateActive :
kThemeStateInactive;
> /*
> CPoint_AC bounds;
> SInt16 baseline;
> ::GetThemeTextDimensions_AC(title, fontID, theState, false, bounds,
&baseline);
> */
> // Get the proper control area
> CRect_AC theDestRect = ControlQDArea();
>
> // Get the cluster's title/label rect
> CRect_AC titleRect = GetLabelRect();
>
> // DrawThemePrimaryGroup doesn't work under Mac OS X when drawing to
a printer port.
> // But, you can draw to an offscreen gworld and copy the gworld to
the printing port.
>
> CRect_AC srcRect(area.AsRect());
>
> // Move the group frame rect down to make room for the title string
> CRect_AC contentRect(srcRect);
> if (!title.empty())
> contentRect.top += titleRect.Height();
>
> // Create an offscreen gworld to draw the separator
> CTempGWorld_AC tempGW(srcRect, 0);
> tempGW.ClearPixMap(); // erase any bits in the gworld
> {
> CLockPixMap_AC lockPixMap(tempGW);
>
> ThemeDrawState themeState = fIsActive ? kThemeStateActive :
kThemeStateInactive;
> OSStatus theErr = ::DrawThemePrimaryGroup(contentRect, themeState);
> ::ThrowIfOSErr_AC(theErr);
> }
>
> // Copy the offscreen gworld to the current/printing graf port
> CGrafPtr port = GetCGrafPtr_AC();
> tempGW.CopyTo(port, srcRect, theDestRect, srcCopy, NULL);
>
> // Draw the cluster title text
> if (!title.empty())
> DrawLabel(title, fontID, theState, titleRect);
> }
> else {
> Inherited::Draw(area);
> }
> }
>
> //---------------------------------
-------------------------------------------------------
> // TPrimaryCluster::DrawLabel:
> //---------------------------------
-------------------------------------------------------
>
> void TPrimaryCluster::DrawLabel(const CUniString_AC& theText,
ThemeFontID fontID,
> ThemeDrawState theState, const CRect_AC& aRect)


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macapp-dev mailing list      (Macapp-dev@list...)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/macapp-dev/subscriber%40opensubscriber.com

This email sent to subscriber@open...

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

opensubscriber is not affiliated with the authors of this message nor responsible for its content.