LineArrowItem Class Reference

Class to represent a arrowhead/tail user-interface item within the line gallery. More...

#include <sgline2.h>

Inheritance diagram for LineArrowItem:

LineAttrItem SGDisplayItem SGDisplayNode CCObject SimpleCCObject LineNoArrowItem LineNoEndArrowItem LineNoStartArrowItem List of all members.

Public Member Functions

 LineArrowItem (StockArrow nArrowType, double fpScale, const String &strDescription)

Protected Member Functions

virtual void SetAttributes (RenderRegion *pRegion) const
 Sets the arrowhead attributes in the given render-region to render this item.
virtual void DrawItem (RenderRegion *pRegion, const DocRect &drBounds) const
 Formats and draws an arrowhead/tail.
virtual NodeAttributeCreateNewAttribute (BOOL fIsAdjust) const
 A pointer to a NodeAttribute-derivative that this user-interface item represents, ie. an arrowhead attribute that can be passed to the attribute manager. This is either an AttrStartArrow or an AttrEndArrow, depending on the particular type of arrowhead and the state of the fIsAdjust parameter.
virtual MILLIPOINT GetWidth () const
 Overrides the default width of display items in the line gallery, making arrowhead items half the normal width.
virtual MILLIPOINT GetHeight () const
 Overrides the default width of display items in the line gallery, making arrowhead items one-and-a-half times the normal height.
virtual MILLIPOINT GetHorzGap () const
 Overrides the default gap of display items in the line gallery, making arrowhead items more closely spaced horizontally than normal.
virtual MILLIPOINT GetVertGap () const
 Halves the vertical gap between arrowhead items.
virtual CCRuntimeClass ** GetAttribRuntimeClasses () const
 Used when searching for display items representing the selection's current attributes.
virtual BOOL IsEqualValueToAny (NodeAttribute **pOtherAttribs) const
 Used when searching for display items representing the selection's current attributes.
virtual BOOL IsStartArrow () const
 Used to work out what kind of AttrXXXXArrow attribute type to create in LineArrowItem::CreateNewAttribute. Can be overridden. This version asks the item's arrowhead record what kind it is.
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.

Protected Attributes

ArrowRec m_arArrow
BOOL m_fCentred

Detailed Description

Class to represent a arrowhead/tail user-interface item within the line gallery.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/4/95
See also:
-

Definition at line 181 of file sgline2.h.


Constructor & Destructor Documentation

LineArrowItem::LineArrowItem StockArrow  nArrowType,
double  fpScale,
const String strDescription
 

Definition at line 418 of file sgline2.cpp.

00420   : LineAttrItem(strDescription, NO_LABEL),
00421     m_fCentred(nArrowType == SA_SPOT ||
00422                nArrowType == SA_DIAMOND ||
00423                nArrowType == SA_HOLLOWDIAMOND)
00424 {
00425     // Fill in the blank ArrowRec object and scale it, if we have a valid stock arrow type.
00426     if (nArrowType != (StockArrow) -1)
00427     {
00428         m_arArrow.CreateStockArrow(nArrowType);
00429         m_arArrow.SetArrowSize((FIXED16) fpScale);
00430     }
00431 }


Member Function Documentation

NodeAttribute * LineArrowItem::CreateNewAttribute BOOL  fIsAdjust  )  const [protected, virtual]
 

A pointer to a NodeAttribute-derivative that this user-interface item represents, ie. an arrowhead attribute that can be passed to the attribute manager. This is either an AttrStartArrow or an AttrEndArrow, depending on the particular type of arrowhead and the state of the fIsAdjust parameter.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/4/95
Parameters:
fIsAdjust whether this item is being "applied" by a click with [INPUTS] the Adjust modifier in force or not. This has the effect of applying the attribute to the "other" end of the line, eg. applying an "end-arrowhead" to the start of a line.
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Implements LineAttrItem.

Definition at line 599 of file sgline2.cpp.

00600 {
00601     // Work out whether to make a start- or end-arrow attribute
00602     BOOL fMakeStart = IsStartArrow();
00603     if (fIsAdjust) fMakeStart = !fMakeStart;
00604 
00605     // Make the appropriate attribute.
00606     NodeAttribute* pNewAttr;
00607     if (fMakeStart)
00608     {
00609         // Make a start-arrow attribute.
00610         AttrStartArrow* pNewStartAttr = new AttrStartArrow;
00611         if (pNewStartAttr != NULL) pNewStartAttr->Value.StartArrow = m_arArrow;
00612         pNewAttr = pNewStartAttr;
00613     }
00614     else
00615     {
00616         // Make an end-arrow attribute.
00617         AttrEndArrow* pNewEndAttr = new AttrEndArrow;
00618         if (pNewEndAttr != NULL) pNewEndAttr->Value.EndArrow = m_arArrow;
00619         pNewAttr = pNewEndAttr;
00620     }
00621 
00622     // Return the new attribute.
00623     return pNewAttr;
00624 }

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

Formats and draws an arrowhead/tail.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/4/95
Parameters:
pRegion pointer to the RenderRegion to draw into [INPUTS] drBounds the bounds of the drawing area within the RenderRegion
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from LineAttrItem.

Reimplemented in LineNoArrowItem.

Definition at line 554 of file sgline2.cpp.

00555 {
00556     // Calculate the mid-point of the bounding box.
00557     MILLIPOINT xMid = (drBounds.lo.x + drBounds.hi.x) / 2;
00558     MILLIPOINT yMid = (drBounds.lo.y + drBounds.hi.y) / 2;
00559 
00560     // Work out where to draw the line to and from.  This is a bodge worked out empirically
00561     // to get around the unfortunate Corel-like feature that arrowheads make lines longer
00562     // in an unknown way.
00563     const MILLIPOINT nFudge1 = drBounds.Width() / 7;
00564     const MILLIPOINT nFudge2 = 13 * drBounds.Width() / 84;
00565     DocCoord dcStart(xMid - nFudge1 + ((m_fCentred) ? (nFudge2 / 2) : nFudge2), yMid),
00566              dcEnd(drBounds.hi.x - nFudge1, yMid);
00567 
00568     // Create and draw the path.
00569     Path pthLinePath;
00570     pthLinePath.Initialise();
00571     pthLinePath.InsertMoveTo(dcStart);
00572     pthLinePath.InsertLineTo(dcEnd);
00573     pRegion->DrawPath(&pthLinePath);
00574 }

CCRuntimeClass ** LineArrowItem::GetAttribRuntimeClasses  )  const [protected, virtual]
 

Used when searching for display items representing the selection's current attributes.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/4/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The run-time class of the line attribute this type of display item represents.

Errors: -

See also:
LineAttrItem::UpdateCurrentAttribStatus

Implements LineAttrItem.

Definition at line 643 of file sgline2.cpp.

00644 {
00645     static CCRuntimeClass* aprtc[] =
00646     {
00647         CC_RUNTIME_CLASS(AttrStartArrow),
00648         CC_RUNTIME_CLASS(AttrEndArrow),
00649         NULL
00650     };
00651     
00652     return aprtc;
00653 }

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

Overrides the default width of display items in the line gallery, making arrowhead items one-and-a-half times the normal height.

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

Errors: -

See also:
LineAttrItem::CalculateMyRect; LineAttrItem::GetHeight

Reimplemented from LineAttrItem.

Reimplemented in LineNoArrowItem.

Definition at line 470 of file sgline2.cpp.

00471 {
00472     return 3 * LineAttrItem::GetHeight() / 2;
00473 }

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

Overrides the default gap of display items in the line gallery, making arrowhead items more closely spaced horizontally than normal.

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

Errors: -

See also:
LineAttrItem::CalculateMyRect; LineAttrItem::GetHorzGap

Reimplemented from LineAttrItem.

Definition at line 491 of file sgline2.cpp.

00492 {
00493     return 0;
00494 }

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

Halves the vertical gap between arrowhead items.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/4/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The line-spacing gap between arrowhead items.

Errors: -

See also:
LineAttrItem::GetSize; LineAttrItem::GetVertGap

Reimplemented from LineAttrItem.

Reimplemented in LineNoArrowItem.

Definition at line 511 of file sgline2.cpp.

00512 {
00513     return LineAttrItem::GetVertGap() / 4;
00514 }

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

Overrides the default width of display items in the line gallery, making arrowhead items half the normal width.

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

Errors: -

See also:
LineAttrItem::CalculateMyRect; LineAttrItem::GetWidth

Reimplemented from LineAttrItem.

Reimplemented in LineNoArrowItem.

Definition at line 449 of file sgline2.cpp.

00450 {
00451     return 5 * LineAttrItem::GetWidth() / 8;
00452 }

BOOL LineArrowItem::IsEqualValueToAny NodeAttribute **  ppOtherAttribs  )  const [protected, virtual]
 

Used when searching for display items representing the selection's current attributes.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/4/95
Parameters:
pOtherAttrib the attribute values to compare this item to [INPUTS]
- [OUTPUTS]
Returns:
TRUE if this item represents the same attribute value as the given attribute.

Errors: -

See also:
LineAttrItem::UpdateCurrentAttribStatus

Implements LineAttrItem.

Reimplemented in LineNoStartArrowItem, and LineNoEndArrowItem.

Definition at line 672 of file sgline2.cpp.

00673 {
00674     AttrStartArrow* psattr = (AttrStartArrow*) *ppOtherAttribs;
00675     if (psattr != NULL && psattr->Value.StartArrow == m_arArrow) return TRUE;
00676     AttrEndArrow* peattr = (AttrEndArrow*) ppOtherAttribs[1];
00677     return peattr != NULL && peattr->Value.EndArrow == m_arArrow;
00678 }

BOOL LineArrowItem::IsStartArrow  )  const [protected, virtual]
 

Used to work out what kind of AttrXXXXArrow attribute type to create in LineArrowItem::CreateNewAttribute. Can be overridden. This version asks the item's arrowhead record what kind it is.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/4/95
Returns:
TRUE if this line gallery item represents a start arrow, FALSE if it represents an end arrow.

Reimplemented in LineNoStartArrowItem, and LineNoEndArrowItem.

Definition at line 694 of file sgline2.cpp.

00695 {
00696     return ((ArrowRec&) m_arArrow).IsStartArrow();
00697 }

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

Sets the arrowhead attributes in the given render-region to render this item.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/4/95
Parameters:
pRegion pointer to the render-region to draw into [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Implements LineAttrItem.

Reimplemented in LineNoArrowItem.

Definition at line 532 of file sgline2.cpp.

00533 {
00534     pRegion->SetLineWidth(c_nDefaultLineWidth / 3);
00535     pRegion->SetStartArrow((ArrowRec&) m_arArrow);
00536 }

BOOL LineArrowItem::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:
FALSE
This function returns TRUE (auto-close) by default, and is overridden to return FALSE by this class, to stop the auto-close action.

See also:
LineAttrItem::ShouldCloseOnDoubleClick

Reimplemented from LineAttrItem.

Definition at line 722 of file sgline2.cpp.

00723 {
00724     return(FALSE);
00725 }


Member Data Documentation

ArrowRec LineArrowItem::m_arArrow [protected]
 

Definition at line 204 of file sgline2.h.

BOOL LineArrowItem::m_fCentred [protected]
 

Definition at line 205 of file sgline2.h.


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