LineAttrItem Class Reference

This DisplayTree node is used by the Line SuperGallery It is responsible for providing the ability to handle/redraw one LineAttrItem displayed in said gallery. More...

#include <sgline.h>

Inheritance diagram for LineAttrItem:

SGDisplayItem SGDisplayNode CCObject SimpleCCObject BrushAttrItem LineArrowItem LineCapItem LineDashItem LineJoinTypeItem LineWidthItem StrokeTypeItem VarWidthItem List of all members.

Public Types

enum  TextPosition { NO_LABEL, LEFT, BELOW }

Public Member Functions

const StringGetDescription () const
 Describes this item, basically.
void SetDescription (StringBase *pNewDescription)
 Changes the item's text in the gallery.
void GetSize (TextPosition eTextPos, MILLIPOINT *pxSize, MILLIPOINT *pySize) const
void Render (RenderRegion *pRegion, const DocRect &drBounds, TextPosition eTextPos) const
virtual void DragWasReallyAClick (SGMouseInfo *pMouse, SGMiscInfo *pMiscInfo)
 Handles a mouse click event. This is a callback function - drags of items from galleries will call this function back if the drag turns out to just be a click.
virtual NodeAttributeCreateNewAttribute (BOOL fIsAdjust) const =0
virtual BOOL GetStatusLineHelp (DocCoord *pMousePos, String_256 *pResult)
 Sets the given string to the text description of this line item.
virtual void GetNameText (String_256 *pResult)
 To determine a name string for this node. Generally, this is used for a simple mechanism which searches for display items whose names match given search parameters in some way. It is also used in libraries to provide default redraw methods.
virtual BOOL ItemSelected (NodeAttribute *pAttr)
 utility fn called when the item is selected. If your item needs to do anything just prior to it becoming selected then override this function.

Static Public Member Functions

static BOOL UpdateCurrentAttribStatus ()
 Updates the "current attribute" status flag of every LineAttrItem within the line gallery, setting it to whether each item represents an attribute value applying to the current selection.

Protected Member Functions

 LineAttrItem (const String &strDescription, TextPosition eTextPos)
virtual MILLIPOINT GetWidth () const
 Called by the formatting code.
virtual MILLIPOINT GetHeight () const
 Called by the formatting code.
virtual MILLIPOINT GetHorzGap () const
 Called by the formatting code. This base-class version returns a default value, derived classes may override it to make items closer or further apart.
virtual MILLIPOINT GetVertGap () const
 Called by the formatting code. This base-class version returns a default value, derived classes may override it to make items closer or further apart.
virtual void SetAttributes (RenderRegion *pRegion) const =0
virtual void DrawItem (RenderRegion *pRegion, const DocRect &drBounds) const
 Draws this item within the bouding box. This default implementation draws a single line through the centre of the box, fine for almost all derived classes. You can override this to do something else (cf. the join-types attribute item, that must draw two lines that meet).
void SetTextPosition (TextPosition eNewTextPos)
 Tells SGDisplayLineAttrItems whether to display themselves with a label describing themselves, or not.
virtual CCRuntimeClass ** GetAttribRuntimeClasses () const =0
virtual BOOL IsEqualValueToAny (NodeAttribute **pOtherAttribs) const =0
virtual BOOL ShouldCloseOnDoubleClick (void)
 When an item is ctrl-double-clicked, the default action is to apply the item and close the gallery (for convenience). However, arrowheads do a special action for ctrl-double-click (they apply to the other end of the line) so they do not want auto-close to occur.

Private Member Functions

virtual BOOL HandleEvent (SGEventType EventType, void *EventInfo, SGMiscInfo *MiscInfo)
 Handles a SuperGallery DisplayTree event Notes: This overrides the pure virtual SGDisplayNode::HandleEvent method. A node need not handle a specific event - if it does not handle it, it should return FALSE. Redraw and Formatting handlers should never return TRUE, as this will prevent the event from continuing through the tree. Non-leaf-nodes must call SGDisplayNode::GiveEventToMyChildren in order to pass the event dow the tree. THIS node is a leaf-node, so it doesn't.
virtual void HandleRedraw (SGRedrawInfo *RedrawInfo, SGMiscInfo *MiscInfo)
 LineAttrItem item redraw method - removed from the main HandleEvent method merely to make the code tidier.
virtual void CalculateMyRect (SGFormatInfo *FormatInfo, SGMiscInfo *MiscInfo)
virtual BOOL DefaultClickHandler (SGMouseInfo *pMouse, SGMiscInfo *pMiscInfo)
 CC_DECLARE_DYNAMIC (LineAttrItem)

Private Attributes

String m_strDescription
TextPosition m_eDefaultTextPosition
BOOL m_fIsCurrentAttrib

Detailed Description

This DisplayTree node is used by the Line SuperGallery It is responsible for providing the ability to handle/redraw one LineAttrItem displayed in said gallery.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (Based on template code by Jason)
Date:
15/2/95
See also:
LineGallery; SuperGallery; SGDisplayItem

Definition at line 159 of file sgline.h.


Member Enumeration Documentation

enum LineAttrItem::TextPosition
 

Enumerator:
NO_LABEL 
LEFT 
BELOW 

Definition at line 163 of file sgline.h.

00164     {
00165         NO_LABEL,           // don't display a text description
00166         LEFT,               // display a description to the left of the item
00167         BELOW               // display a description below the item
00168     };


Constructor & Destructor Documentation

LineAttrItem::LineAttrItem const String strDescription,
TextPosition  eTextPos
[protected]
 

Definition at line 197 of file sgline.cpp.

00198   : m_strDescription(strDescription),
00199     m_eDefaultTextPosition(eTextPos),
00200     m_fIsCurrentAttrib(FALSE)
00201 {
00202     // Empty.
00203 }


Member Function Documentation

void LineAttrItem::CalculateMyRect SGFormatInfo FormatInfo,
SGMiscInfo MiscInfo
[private, virtual]
 

Definition at line 322 of file sgline.cpp.

00323 {
00324     // Find out the extent of this item, including a gap for formatting.
00325     MILLIPOINT xSize, ySize;
00326     GetSize(m_eDefaultTextPosition, &xSize, &ySize);
00327     if (xSize != SG_InfiniteWidth)
00328         xSize += GetHorzGap();
00329 
00330     ySize += GetVertGap();
00331 
00332     // Let the base class do what it needs to do with this.
00333     CalculateFormatRect(pFormatInfo, pMiscInfo, xSize, ySize);
00334 }

LineAttrItem::CC_DECLARE_DYNAMIC LineAttrItem   )  [private]
 

virtual NodeAttribute* LineAttrItem::CreateNewAttribute BOOL  fIsAdjust  )  const [pure virtual]
 

Implemented in BrushAttrItem, LineWidthItem, LineDashItem, LineArrowItem, LineCapItem, LineJoinTypeItem, StrokeTypeItem, and VarWidthItem.

BOOL LineAttrItem::DefaultClickHandler SGMouseInfo pMouse,
SGMiscInfo pMiscInfo
[private, virtual]
 

Definition at line 835 of file sgline.cpp.

00836 {
00837     // Get some objects.
00838     SuperGallery* pParent = GetParentGallery();
00839     SGDisplayGroup* pGroup = (SGDisplayGroup*) GetParent();
00840     ERROR3IF(pGroup == NULL, "No parent group in LineAttrItem::DefaultClickHandler?");
00841     
00842     // If there is any other item within the group already selected then
00843     // deselect it.  We start searching from the first child of this group.
00844     for (LineAttrItem* pItem = (LineAttrItem*) pGroup->GetChild();
00845          pItem != NULL;
00846          pItem = (LineAttrItem*) pItem->GetNext())
00847     {
00848          if (pItem != this) pItem->SetSelected(FALSE);
00849     }
00850 
00851     // If Adjust, toggle my selection state
00852     // If Select, set myself selected, and ensure all other items deselected
00853     // NB. NOTE THAT "ADJUST" IS REALLY WHAT EVERY ONE ELSE CALLS "CONSTRAIN"!!
00854     // (Well, actually, it's what Windows uses for altering a selection... it's not my
00855     // fault that the rest of Camelot flies in the face of windows conventions... and
00856     // as galleries are really "super" windows list boxes, they have to use windows
00857     // conventions. Note also that pMouse->Adjust is not necessarily fixed to any key
00858     // but happens under Windows to be attached to ctrl or the right button)
00859     SetSelected((pMouse->Adjust && !pMouse->DoubleClick) ? !Flags.Selected : TRUE);
00860 
00861     // OK, now we have guaranteed that an item is selected on a double click we can run
00862     // an Apply action.
00863     if (pMouse->DoubleClick)
00864     {
00865         // Apply the attributes.     
00866         if (pParent->ApplyAction(pMouse->Adjust ? SGACTION_APPLYADJUST : SGACTION_APPLY) &&
00867             pMouse->Adjust)
00868         {
00869             // Adjust/Ctrl double click of an item. This applies the item and then
00870             // auto closes the gallery (just like RISC OS and Win95)
00871             // Auto-close only occurs, however, if the item says it's OK, as arrowheads
00872             // use the ctrl-double click to apply in a special way, so shouldn't autoclose.
00873 
00874             if (ShouldCloseOnDoubleClick())
00875             {
00876                 pParent->SetVisibility(FALSE);
00877 
00878                 DialogBarOp::SetSystemStateChanged();   // Ensure toolbar button pops out again
00879             }
00880         }
00881 
00882         return TRUE;
00883     }
00884 
00885     // Update the pParent to know that we are the new multi-selection anchor
00886     // (The anchor only changes when single items are (de)selected)
00887     pParent->SetLastSelectedNode((Flags.Selected) ? this : NULL);
00888 
00889     // Finally, inform the parent gallery that the selection has changed, so it can
00890     // shade/unshade buttons as appropriate, etc
00891     pParent->SelectionHasChanged();
00892     return TRUE;
00893 }

void LineAttrItem::DragWasReallyAClick SGMouseInfo pMouse,
SGMiscInfo pMiscInfo
[virtual]
 

Handles a mouse click event. This is a callback function - drags of items from galleries will call this function back if the drag turns out to just be a click.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/3/95
Parameters:
MouseInfo - The mouse info passed to the original click handler [INPUTS] MiscInfo - The misc info passed to the original click handler
Notes: The base class method takes no action whatsoever. Derived classes should override this method to do something useful.

For a description of how to use this, see the documentation, or take a look at other galleries for example code.

Documentation: docs.doc

See also:
SGDisplayNode::HandleEvent; SGDisplayNode::DefaultDragHandler

Reimplemented from SGDisplayNode.

Definition at line 812 of file sgline.cpp.

00813 {
00814     // Just get default selection action to be applied for this click.
00815     DefaultClickHandler(pMouse, pMiscInfo);
00816 }

void LineAttrItem::DrawItem RenderRegion pRegion,
const DocRect drBounds
const [protected, virtual]
 

Draws this item within the bouding box. This default implementation draws a single line through the centre of the box, fine for almost all derived classes. You can override this to do something else (cf. the join-types attribute item, that must draw two lines that meet).

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/3/95
Parameters:
pRegion pointer to the RenderRegion to draw into [INPUTS] drBounds reference to the bounding box rectangle to draw within
- [OUTPUTS]
Returns:
-

Errors: -

See also:
LineAttrItem::Render

Reimplemented in BrushAttrItem, LineArrowItem, LineNoArrowItem, and LineJoinTypeItem.

Definition at line 581 of file sgline.cpp.

00582 {
00583     // Calculate the mid-point of the vertical sides of the bounding box.
00584     INT32 yMid = (drBounds.lo.y + drBounds.hi.y) / 2;
00585 
00586     // Draw a line at this height from the left to the right edge.
00587     Path pthLinePath;
00588     if (pthLinePath.Initialise())
00589     {
00590         pthLinePath.InsertMoveTo(DocCoord(drBounds.lo.x, yMid));
00591         pthLinePath.InsertLineTo(DocCoord(drBounds.hi.x, yMid));
00592         pthLinePath.IsFilled  = FALSE;
00593         pthLinePath.IsStroked = TRUE;
00594         pRegion->DrawPath(&pthLinePath);
00595     }
00596 }

virtual CCRuntimeClass** LineAttrItem::GetAttribRuntimeClasses  )  const [protected, pure virtual]
 

Implemented in BrushAttrItem, LineWidthItem, LineDashItem, LineArrowItem, LineCapItem, LineJoinTypeItem, StrokeTypeItem, and VarWidthItem.

const String & LineAttrItem::GetDescription  )  const
 

Describes this item, basically.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/3/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A reference to a string that describes what this item represents.

Errors: -

See also:
LineAttrItem::LineAttrItem

Definition at line 910 of file sgline.cpp.

00911 {
00912     return m_strDescription;
00913 }

MILLIPOINT LineAttrItem::GetHeight void   )  const [protected, virtual]
 

Called by the formatting code.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/4/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The height of this item, in millipoints.

Errors: -

See also:
LineAttrItem::GetSize; LineAttrItem::CalculateMyRect

Reimplemented in LineDashItem, LineArrowItem, and LineNoArrowItem.

Definition at line 633 of file sgline.cpp.

00634 {
00635     return c_nVertSizeOfItem;
00636 }

MILLIPOINT LineAttrItem::GetHorzGap  )  const [protected, virtual]
 

Called by the formatting code. This base-class version returns a default value, derived classes may override it to make items closer or further apart.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/4/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The horizontal gap between this item and another item of the same type, in millipoints.

Errors: -

See also:
-

Reimplemented in LineArrowItem, StrokeTypeItem, and VarWidthItem.

Definition at line 656 of file sgline.cpp.

00657 {
00658     return c_nHorzGapBetweenItems;
00659 }

virtual void LineAttrItem::GetNameText String_256 pResult  )  [inline, virtual]
 

To determine a name string for this node. Generally, this is used for a simple mechanism which searches for display items whose names match given search parameters in some way. It is also used in libraries to provide default redraw methods.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/3/95
Parameters:
On exit, the string pointed at by Result will contain either a blank [OUTPUTS] string, or the name text associated with this item (if any)
Notes: The base class returns a blank string. If you can provide a better name string, then override the base class method to do so.

See also:
SGDisplayNode::GetFullInfoText

Reimplemented from SGDisplayNode.

Definition at line 197 of file sgline.h.

00197 {if(pResult != NULL) *pResult = m_strDescription;};

void LineAttrItem::GetSize TextPosition  eTextPos,
MILLIPOINT pxSize,
MILLIPOINT pySize
const
 

Definition at line 353 of file sgline.cpp.

00356 {
00357     // Make sure we can put the results somewhere.
00358     ERROR3IF(pxSize == NULL || pySize == NULL, "Null* passed in LineAttrItem::GetSize");
00359 
00360     // Get the basic size and add in a possible text size as well.
00361     *pxSize = GetWidth();
00362     *pySize = GetHeight();
00363     switch (eTextPos)
00364     {
00365         case LEFT:
00366             if (*pxSize != SG_InfiniteWidth)
00367             {
00368                 *pxSize += (c_nHorzSizeOfText + c_nHorzGapAfterText);
00369             }
00370             break;
00371 
00372         case BELOW:
00373             *pySize += (c_nVertSizeOfText + c_nVertGapAboveText);
00374             break;
00375 
00376         case NO_LABEL:
00377             break;
00378 
00379         default:
00380             ERROR3("Unexpected case in LineAttrItem::GetSize");
00381             break;
00382     }
00383 }

BOOL LineAttrItem::GetStatusLineHelp DocCoord pMousePos,
String_256 pResult
[virtual]
 

Sets the given string to the text description of this line item.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/6/95
Parameters:
dcMousePos (not used) [INPUTS]
pResult where to put the text [OUTPUTS]
Returns:
TRUE

Reimplemented from SGDisplayNode.

Definition at line 966 of file sgline.cpp.

00967 {
00968     // Check for rubbish.
00969     ERROR3IF(pResult == NULL, "Null String_256* passed to LineAttrItem::GetStatusLineHelp");
00970     
00971     // Build up the status-line text.  This is composed of the item's text description,
00972     // followed by the text of the item's group title, without the last pluralising 's'.
00973     String_256 str;
00974     if (IsSelected())
00975         str = String_256(_R(IDS_LINEGAL_SEL_CTRLCLICK));
00976     else
00977         str = String_256(_R(IDS_LINEGAL_SEL_CLICK));
00978 
00979     str += GetDescription();
00980     str += String_8(_R(IDS_SGLINE_STAT_SPACE_SEP)); // " "
00981     str += ((LineAttrGroup*) GetParent())->GetTitle();
00982     str.Left(pResult, str.Length() - 1);
00983 
00984     String_256 strAttr(_R(IDS_LINEGAL_ATTR));
00985     *pResult += strAttr;
00986 
00987 //  if (IsSelected())           // removing this test fixes bug #4684 (hee hee!!)
00988     {
00989         String_256 strDbl(_R(IDS_LINEGAL_SEL_DBLCLK));
00990         *pResult += strDbl;
00991     }
00992     
00993     // Success!
00994     return TRUE;
00995 }

MILLIPOINT LineAttrItem::GetVertGap  )  const [protected, virtual]
 

Called by the formatting code. This base-class version returns a default value, derived classes may override it to make items closer or further apart.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/4/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The vertical gap between this item and another item of the same type, in millipoints.

Errors: -

See also:
-

Reimplemented in LineArrowItem, and LineNoArrowItem.

Definition at line 679 of file sgline.cpp.

00680 {
00681     return c_nVertGapBetweenItems;
00682 }

MILLIPOINT LineAttrItem::GetWidth void   )  const [protected, virtual]
 

Called by the formatting code.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/4/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The width of this item, in millipoints.

Errors: -

See also:
LineAttrItem::GetSize; LineAttrItem::CalculateMyRect

Reimplemented in LineWidthItem, LineArrowItem, LineNoArrowItem, StrokeTypeItem, and VarWidthItem.

Definition at line 613 of file sgline.cpp.

00614 {
00615     return c_nHorzSizeOfItem;
00616 }

BOOL LineAttrItem::HandleEvent SGEventType  EventType,
void *  EventInfo,
SGMiscInfo MiscInfo
[private, virtual]
 

Handles a SuperGallery DisplayTree event Notes: This overrides the pure virtual SGDisplayNode::HandleEvent method. A node need not handle a specific event - if it does not handle it, it should return FALSE. Redraw and Formatting handlers should never return TRUE, as this will prevent the event from continuing through the tree. Non-leaf-nodes must call SGDisplayNode::GiveEventToMyChildren in order to pass the event dow the tree. THIS node is a leaf-node, so it doesn't.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/2/95 (base generated in sgbase.cpp)
Parameters:
EventType - An enumerated value describing what type of event is to be processed [INPUTS] EventInfo - A structure describing the event (may be NULL). The exact thing pointed at by this pointer depends upon the event type: MonoOn Event Thing EventInfo points at SGEVENT_FORMAT (SGFormatInfo *) SGEVENT_REDRAW (SGRedrawInfo *) SGEVENT_MOUSECLICK (SGMouseInfo *) MonoOff Use the provided SGDisplayNode::Get[Format]Info() inlines to retrieve this information - they provide useful error/type checking, and hide the cast
MiscInfo - always provided. Contains a few useful bits of info that may be needed for all event types.
Parameters:
FormatInfo is updated as appropriate [OUTPUTS]
Returns:
TRUE if the event was handled successfully FALSE if it was not
See also:
SGDisplayNode::HandleEvent

Reimplemented from SGDisplayItem.

Definition at line 721 of file sgline.cpp.

00722 {
00723     switch (EventType)
00724     {
00725     case SGEVENT_FORMAT:
00726         {
00727             SGFormatInfo* FormatInfo = GetFormatInfo(EventType, EventInfo);
00728             CalculateMyRect(FormatInfo, MiscInfo);      // Cache our FormatRect for later use
00729         }
00730         break;
00731 
00732 
00733     case SGEVENT_REDRAW:
00734         {
00735             // Rely on FormatRect being cached from above
00736             SGRedrawInfo* RedrawInfo = GetRedrawInfo(EventType, EventInfo);
00737 
00738             // only redraw if we intersect the clip rect
00739             if (IMustRedraw(RedrawInfo))
00740             {
00741                 // Now render the item.
00742                 StartRendering(RedrawInfo, MiscInfo);
00743                 RedrawInfo->Renderer->SaveContext();
00744                 HandleRedraw(RedrawInfo, MiscInfo);
00745                 RedrawInfo->Renderer->RestoreContext();
00746                 StopRendering(RedrawInfo, MiscInfo);
00747             }
00748         }
00749         break;      // exit and return FALSE to pass the redraw event on
00750 
00751 
00752     case SGEVENT_MOUSECLICK:
00753         {
00754             SGMouseInfo *Mouse = GetMouseInfo(EventType, EventInfo);
00755 
00756             if (FormatRect.ContainsCoord(Mouse->Position))
00757             {
00758                 //OK temporary dodge (see, not a bodge) to stop people doing things with brushes in the
00759                 //line gallery before we get them working!
00760                 // LineAttrItem* pItem = this;
00761     
00762                 {
00763                     // If the colour is in the selected document, then it is safe to
00764                     // do a colour drag - for now, it will only allow drags for the
00765                     // selected doc.
00766                     // Otherwise, the normal click action takes place.
00767                     // If the drag fails (turns into a click) then the normal click action
00768                     // takes place, passed on by the GalleryColourDragInfo::OnClick handler
00769                     // SGDisplayGroup *Parent = (SGDisplayGroup *) GetParent();
00770 
00771                     if (Mouse->DoubleClick) // || Parent->GetParentDocument() != Document::GetSelected())
00772                         DefaultClickHandler(Mouse, MiscInfo);
00773                     else
00774                     {
00775                         DefaultPreDragHandler(Mouse, MiscInfo); 
00776     
00777                         GalleryLineDragInfo* pInfo;
00778                         pInfo = new GalleryLineDragInfo(this, Mouse, MiscInfo, Mouse->MenuClick);
00779                         if (pInfo != NULL) DragManagerOp::StartDrag(pInfo, GetListWindow());
00780                     }
00781                 }
00782 
00783                 return(TRUE);       // Claim this event - nobody else can own this click
00784             }
00785         }
00786         break;
00787 
00788     default:
00789         // Pass unknown events on to the base class
00790         return(SGDisplayItem::HandleEvent(EventType, EventInfo, MiscInfo));
00791     }
00792 
00793     // Default return value: We do not claim this event, so it will be passed on to others
00794     return FALSE;
00795 }

void LineAttrItem::HandleRedraw SGRedrawInfo pRedrawInfo,
SGMiscInfo pMiscInfo
[private, virtual]
 

LineAttrItem item redraw method - removed from the main HandleEvent method merely to make the code tidier.

Member variable FormatRect should be set up (before calling this method) to be the rectangle in which to draw this item

Justin here: this version sets default attributes within the render region, such as foreground & background colour, and then calls the Render() function to do the actual drawing. Notes: VERY IMPORTANT: The rendering must be enclosed by calls to StartRendering and StopRendering, to ensure that rendering works properly (in the future we may change the redraw system to use a GRenderRegion for each individual item, rather than one global one for the window, for which these calls will be essential) Scope: protected

Definition at line 411 of file sgline.cpp.

00412 {
00413     // Remove the gap between the items, shrink by one pixel to ensure clean clipping,
00414     // and fix the bounds coincide with the position of pixels.
00415     DocRect drBounds(FormatRect);
00416     drBounds.Inflate(-(pMiscInfo->PixelSize + GetHorzGap() / 2),
00417                      -(pMiscInfo->PixelSize + GetVertGap() / 2));
00418     GridLockRect(pMiscInfo, &drBounds);
00419 
00420     // Set the foreground and background colours according to whether this item is
00421     // selected or not.
00422     DocColour dcolForegnd, dcolBackgnd;
00423     if (Flags.Selected)
00424     {
00425         dcolForegnd = pRedrawInfo->SelForeground;
00426         dcolBackgnd = pRedrawInfo->SelBackground;
00427     }
00428     else
00429     {
00430         dcolForegnd = pRedrawInfo->Foreground;
00431         dcolBackgnd = pRedrawInfo->Background;
00432     }
00433 
00434     // Set the attributes for drawing the formatted rectangle.
00435     RenderRegion* pRegion = pRedrawInfo->Renderer;
00436     pRegion->SetLineWidth(pMiscInfo->PixelSize);        // line is one pixel wide
00437     pRegion->SetFillColour(dcolBackgnd);
00438 
00439     // If we are drawing an item that is a "current attribute" then we want to draw it
00440     // with a "selected" line around it.  Otherwise we draw it with effectively no line.
00441     if (m_fIsCurrentAttrib)
00442     {
00443         pRegion->SetLineColour(pRedrawInfo->SelBackground);
00444     }
00445     else
00446     {
00447         // Draw the line the same colour as the fill colour, so it's "invisible".
00448         pRegion->SetLineColour(dcolBackgnd);
00449     }
00450 
00451     // Create a closed path that is filled with the fill colour and if necessary has
00452     // a visible outline.
00453     Path pth;
00454     pth.Initialise();
00455     pth.IsFilled = TRUE;
00456     pth.IsStroked = m_fIsCurrentAttrib;     // draw outline if "current attribute"
00457 
00458     // "Draw" the bounding rectangle into the path.
00459     pth.InsertMoveTo(drBounds.lo);
00460     pth.InsertLineTo(DocCoord(drBounds.lo.x, drBounds.hi.y));
00461     pth.InsertLineTo(drBounds.hi);
00462     pth.InsertLineTo(DocCoord(drBounds.hi.x, drBounds.lo.y));
00463     pth.InsertLineTo(drBounds.lo);
00464     pth.CloseSubPath();
00465     
00466     // Draw the path.
00467     pRegion->DrawPath(&pth);
00468 
00469     // Reset the rendering attributes back to the normal: standard gallery foreground
00470     // and background colours.
00471     pRegion->SetLineColour(dcolForegnd);
00472     pRegion->SetFixedSystemTextColours(&dcolForegnd, &dcolBackgnd);
00473 
00474     // Shrink the rectangle by a pixel, to make sure it nicely fits within the bounds,
00475     // lock down, and let the derived class do the rest of the work as it pleases.
00476     drBounds.Inflate(-pMiscInfo->PixelSize, -pMiscInfo->PixelSize);
00477     GridLockRect(pMiscInfo, &drBounds);
00478     Render(pRegion, drBounds, m_eDefaultTextPosition);
00479 }

virtual BOOL LineAttrItem::IsEqualValueToAny NodeAttribute **  pOtherAttribs  )  const [protected, pure virtual]
 

Implemented in BrushAttrItem, LineWidthItem, LineDashItem, LineArrowItem, LineNoStartArrowItem, LineNoEndArrowItem, LineCapItem, LineJoinTypeItem, StrokeTypeItem, and VarWidthItem.

BOOL LineAttrItem::ItemSelected NodeAttribute pNewAttr  )  [virtual]
 

utility fn called when the item is selected. If your item needs to do anything just prior to it becoming selected then override this function.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/1/2000
Parameters:
pNewAttr - the attribute that we are about to apply [INPUTS]
- [OUTPUTS]
Returns:
TRUE if we want the line gallery to go ahead and apply the attribute, FALSE if we applied it ourselves.

Errors: -

See also:
BrushAttrItem::ItemSelected

Reimplemented in BrushAttrItem, and VarWidthItem.

Definition at line 1042 of file sgline.cpp.

01043 {
01044     return TRUE;
01045 }

void LineAttrItem::Render RenderRegion pRegion,
const DocRect drBounds,
TextPosition  eTextPos
const
 

Definition at line 501 of file sgline.cpp.

00503 {
00504     // Make a copy of the given bounding box rectangle so that we can adjust it later
00505     // if we render some text within it.
00506     DocRect drLineBounds(drBounds);
00507     
00508     // Next, render the text description of this item, if necessary.
00509     if (eTextPos != NO_LABEL)
00510     {
00511         // We must adjust the bounding box of the line to account for the text rendered
00512         // into it.  Items display their text on the left of the rendered attribute.
00513         DocRect drTextBounds(drLineBounds);
00514         switch (eTextPos)
00515         {
00516             case BELOW:
00517             {
00518                 // Divide the bounds horizontally, text below.
00519                 drTextBounds.hi.y = drTextBounds.lo.y + c_nVertSizeOfText;
00520                 drLineBounds.lo.y = drTextBounds.hi.y + c_nVertGapAboveText;
00521 
00522                 // Centre the text bounds.  As there is no "GetTextExtent" function for
00523                 // "system text" we have the obligatory bodge . . .
00524 //              MILLIPOINT nTextLen = (GetDescription().Length() + 1) * c_nAveCharWidth;
00525                 DocRect TextBounds;
00526                 String_256 Desc = GetDescription();
00527                 pRegion->GetFixedSystemTextSize(&Desc, &TextBounds);
00528                 MILLIPOINT nTextLen = TextBounds.Width() / 2;
00529                 MILLIPOINT xMid = (drTextBounds.lo.x + drTextBounds.hi.x) / 2;
00530                 drTextBounds.lo.x = xMid - nTextLen;
00531                 drTextBounds.hi.x = xMid + nTextLen;
00532                 break;
00533             }
00534 
00535             case LEFT:
00536                 // Divide the bounds vertically, text to the left.
00537                 drTextBounds.hi.x = drTextBounds.lo.x + c_nHorzSizeOfText;
00538                 drLineBounds.lo.x = drTextBounds.hi.x + c_nHorzGapAfterText;
00539                 break;
00540 
00541             default:
00542                 ERROR3("Unexpected case in LineAttrItem::Render");
00543                 return;
00544         }
00545     
00546         // Draw the text description of this item.  Note that the foreground and
00547         // background colours have already been set by the caller.
00548         pRegion->DrawFixedSystemText((String*) &GetDescription(), drTextBounds);
00549     }
00550 
00551     // Set the default line width for lines rendered within the gallery and let a
00552     // derived class set some specialised rendering attributes for its item. Then draw
00553     // the line, by default through the centre of the given bounding box.  A derived
00554     // class may very occasionally need to override this as well (eg. to render join-types).
00555     pRegion->SaveContext();
00556         pRegion->SetLineWidth(c_nDefaultLineWidth);
00557         SetAttributes(pRegion);
00558         DrawItem(pRegion, drLineBounds);
00559     pRegion->RestoreContext();
00560 }

virtual void LineAttrItem::SetAttributes RenderRegion pRegion  )  const [protected, pure virtual]
 

Implemented in BrushAttrItem, LineWidthItem, LineDashItem, LineArrowItem, LineNoArrowItem, LineCapItem, LineJoinTypeItem, StrokeTypeItem, and VarWidthItem.

void LineAttrItem::SetDescription StringBase pNewDescription  ) 
 

Changes the item's text in the gallery.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
06/03/97
Parameters:
pNewDescription - New description of the item [INPUTS]

Definition at line 924 of file sgline.cpp.

00925 {
00926     if(pNewDescription != NULL)
00927     {
00928         m_strDescription = *pNewDescription;
00929     }
00930 }

void LineAttrItem::SetTextPosition LineAttrItem::TextPosition  eNewTextPos  )  [protected]
 

Tells SGDisplayLineAttrItems whether to display themselves with a label describing themselves, or not.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/3/95
Parameters:
eNewTextPos the new position of the text description [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 948 of file sgline.cpp.

00949 {
00950     m_eDefaultTextPosition = eNewTextPos;
00951 }

BOOL LineAttrItem::ShouldCloseOnDoubleClick void   )  [protected, virtual]
 

When an item is ctrl-double-clicked, the default action is to apply the item and close the gallery (for convenience). However, arrowheads do a special action for ctrl-double-click (they apply to the other end of the line) so they do not want auto-close to occur.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/95
Returns:
TRUE
This function returns TRUE (auto-close) by default, and is overridden to return FALSE by derived classes which wish to stop the auto-close action.

See also:
LineArrowItem::ShouldCloseOnDoubleClick

Reimplemented in LineArrowItem.

Definition at line 1020 of file sgline.cpp.

01021 {
01022     return(TRUE);
01023 }

BOOL LineAttrItem::UpdateCurrentAttribStatus  )  [static]
 

Updates the "current attribute" status flag of every LineAttrItem within the line gallery, setting it to whether each item represents an attribute value applying to the current selection.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/4/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if no problems encountered, eg. out of memory.

Errors: Out of memory.

See also:
LineAttrItem::GetRuntimeClass; LineAttrItem::IsEqualValue

Definition at line 222 of file sgline.cpp.

00223 {
00224     // If the line gallery isn't running then we don't bother.
00225     if (!LineGallery::IsActive()) return TRUE;
00226     
00227     // For each group in the line gallery, try to match the current attribute of the
00228     // selection with the group's items.
00229     SGDisplayRoot* pRoot = LineGallery::GetInstance()->GetDisplayTree();
00230     if (pRoot == NULL) return FALSE;
00231 
00232     for (LineAttrGroup* pGroup = (LineAttrGroup*) pRoot->GetChild();
00233          pGroup != NULL;
00234          pGroup = (LineAttrGroup*) pGroup->GetNext())
00235     {
00236         // Get a pointer to the first item within the group, if any.
00237         LineAttrItem* pItem = (LineAttrItem*) pGroup->GetChild();
00238         if (pItem == NULL) continue;
00239 
00240         // Get a pointer to the null-terminated array of pointers to run-time classes that
00241         // this type of item can represent.
00242         CCRuntimeClass** ppAttribClasses = pItem->GetAttribRuntimeClasses();
00243         ERROR3IF(ppAttribClasses == NULL,
00244                     "No attribute run-time classes in LineAttrItem::UpdateCurrentAttribStatus");
00245 
00246         // Count how many types of classes the item represents.  Note the null statement.
00247         CCRuntimeClass**  pprtc;
00248         for (pprtc = ppAttribClasses; *pprtc != NULL; pprtc++);
00249         INT32 nAttribClasses = pprtc - ppAttribClasses;
00250 
00251         // Allocate an array of NodeAttribute pointers for each run-time class.
00252         typedef NodeAttribute* PATTRIBUTE;
00253         NodeAttribute** ppCommonAttribs = new PATTRIBUTE[nAttribClasses];
00254         ERRORIF(ppCommonAttribs == NULL, _R(IDE_NOMORE_MEMORY), FALSE);
00255 
00256         // For each run-time class that appears in *ppAttribClasses, try to find an
00257         // attribute of the same class that currently applies to the selection.
00258         for (INT32 i = 0; i < nAttribClasses; i++)
00259         {
00260             NodeAttribute* pattr = NULL; // sjk
00261             SelRange::CommonAttribResult eResult;
00262             
00263             eResult = GetApplication()->
00264                         FindSelection()->
00265                             FindCommonAttribute(ppAttribClasses[i], &pattr);
00266 
00267             // See if we found either a common attribute or the "default attribute".
00268             if (pattr != NULL)
00269             {
00270                 // Check for nothing really brain-damaged happening.
00271                 ERROR3IF(pattr->GetRuntimeClass() != ppAttribClasses[i],
00272                             "Wrong kind of attribute in LineAttrItem::"
00273                             "UpdateCurrentAttribStatus");
00274 
00275                 // There is just one attribute applying, and we got it.
00276                 ppCommonAttribs[i] = pattr;
00277             }
00278             else
00279             {
00280                 // There are either many or none applying, so we aren't interested.
00281                 ppCommonAttribs[i] = NULL;
00282             }       
00283         }
00284 
00285         // OK, so now we have an array of all the attributes this type of item is
00286         // interested in.  Ask each item within the group to compare itself against
00287         // each attribute we have found, to see if it represents it or not.
00288         for (; pItem != NULL; pItem = (LineAttrItem*) pItem->GetNext())
00289         {
00290             BOOL fOldState = pItem->m_fIsCurrentAttrib;
00291             pItem->m_fIsCurrentAttrib = pItem->IsEqualValueToAny(ppCommonAttribs);
00292             if (pItem->m_fIsCurrentAttrib != fOldState) pItem->ForceRedrawOfMyself();
00293         }
00294 
00295         // All done, we are finished with these kinds of attributes.
00296         delete[] ppCommonAttribs;
00297     }
00298 
00299     // Everything went OK.
00300     return TRUE;
00301 }


Member Data Documentation

TextPosition LineAttrItem::m_eDefaultTextPosition [private]
 

Definition at line 243 of file sgline.h.

BOOL LineAttrItem::m_fIsCurrentAttrib [private]
 

Definition at line 244 of file sgline.h.

String LineAttrItem::m_strDescription [private]
 

Definition at line 242 of file sgline.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:55:56 2007 for Camelot by  doxygen 1.4.4