## wxShape

The wxShape is the top-level, abstract object that all other objects are derived from. All common functionality is represented by wxShape's members, and overriden members that appear in derived classes and have behaviour as documented for wxShape, are not documented separately.

Derived from

wxShapeEvtHandler

Members

wxShape::wxShape
wxShape::~wxShape
wxShape::AddLine
wxShape::AddRegion
wxShape::AddText
wxShape::AddToCanvas
wxShape::AncestorSelected
wxShape::ApplyAttachmentOrdering
wxShape::AssignNewIds
wxShape::Attach
wxShape::AttachmentIsValid
wxShape::AttachmentSortTest
wxShape::CalcSimpleAttachment
wxShape::CalculateSize
wxShape::ClearAttachments
wxShape::ClearRegions
wxShape::ClearText
wxShape::Constrain
wxShape::Copy
wxShape::CreateNewCopy
wxShape::DeleteControlPoints
wxShape::Detach
wxShape::Draggable
wxShape::Draw
wxShape::DrawContents
wxShape::DrawLinks
wxShape::Erase
wxShape::EraseContents
wxShape::EraseLinks
wxShape::FindRegion
wxShape::FindRegionNames
wxShape::Flash
wxShape::FormatText
wxShape::GetAttachmentMode
wxShape::GetAttachmentPosition
wxShape::GetBoundingBoxMax
wxShape::GetBoundingBoxMin
wxShape::GetBrush
wxShape::GetCanvas
wxShape::GetCentreResize
wxShape::GetChildren
wxShape::GetClientData
wxShape::GetDisableLabel
wxShape::GetEventHandler
wxShape::GetFixedHeight
wxShape::GetFixedSize
wxShape::GetFixedWidth
wxShape::GetFont
wxShape::GetFunctor
wxShape::GetId
wxShape::GetLinePosition
wxShape::GetLines
wxShape::GetMaintainAspectRatio
wxShape::GetNumberOfAttachments
wxShape::GetNumberOfTextRegions
wxShape::GetParent
wxShape::GetPen
wxShape::GetPerimeterPoint
wxShape::GetRegionId
wxShape::GetRegionName
wxShape::GetRegions
wxShape::GetRotation
wxShape::GetSensitivityFilter
wxShape::GetShadowMode
wxShape::GetSpaceAttachments
wxShape::GetTextColour
wxShape::GetTopAncestor
wxShape::GetX
wxShape::GetY
wxShape::HitTest
wxShape::Insert
wxShape::IsHighlighted
wxShape::IsShown
wxShape::MakeControlPoints
wxShape::MakeMandatoryControlPoints
wxShape::Move
wxShape::MoveLineToNewAttachment
wxShape::MoveLinks
wxShape::NameRegions
wxShape::Rotate
wxShape::ReadConstraints
wxShape::ReadAttributes
wxShape::ReadRegions
wxShape::Recentre
wxShape::RemoveFromCanvas
wxShape::ResetControlPoints
wxShape::ResetMandatoryControlPoints
wxShape::Recompute
wxShape::RemoveLine
wxShape::Select
wxShape::Selected
wxShape::SetAttachmentMode
wxShape::SetBrush
wxShape::SetCanvas
wxShape::SetCentreResize
wxShape::SetClientData
wxShape::SetDefaultRegionSize
wxShape::SetDisableLabel
wxShape::SetDraggable
wxShape::SetDrawHandles
wxShape::SetEventHandler
wxShape::SetFixedSize
wxShape::SetFont
wxShape::SetFormatMode
wxShape::SetHighlight
wxShape::SetId
wxShape::SetMaintainAspectRatio
wxShape::SetPen
wxShape::SetRegionName
wxShape::SetSensitivityFilter
wxShape::SetShadowMode
wxShape::SetSize
wxShape::SetSpaceAttachments
wxShape::SetTextColour
wxShape::SetX
wxShape::SetX
wxShape::SpaceAttachments
wxShape::Show
wxShape::Unlink
wxShape::WriteAttributes
wxShape::WriteRegions

### wxShape::wxShape

wxShape(wxShapeCanvas* canvas = NULL)

Constructs a new wxShape.

### wxShape::~wxShape

~wxShape()

Destructor.

### wxShape::AddLine

void AddLine(wxLineShape* line, wxShape* other, int attachFrom = 0, int attachTo = 0, int positionFrom = -1, int positionTo = -1)

Adds a line between the specified canvas shapes, at the specified attachment points.

The position in the list of lines at each end can also be specified, so that the line will be drawn at a particular point on its attachment point.

### wxShape::AddRegion

void AddRegion(wxShapeRegion* region)

Adds a region to the shape.

### wxShape::AddText

void AddText(const wxString& string)

Adds a line of text to the shape's default text region.

### wxShape::AddToCanvas

void AddToCanvas(wxShapeCanvas* theCanvas, wxShape* addAfter=NULL)

Adds the shape to the canvas's shape list. If addAfter is non-NULL, will add the shape after this one.

### wxShape::AncestorSelected

bool AncestorSelected() const

TRUE if the shape's ancestor is currently selected.

### wxShape::ApplyAttachmentOrdering

void ApplyAttachmentOrdering(wxList& linesToSort)

Applies the line ordering in linesToSort to the shape, to reorder the way lines are attached.

### wxShape::AssignNewIds

void AssignNewIds()

Assigns new ids to this image and its children.

### wxShape::Attach

void Attach(wxShapeCanvas* can)

Sets the shape's internal canvas pointer to point to the given canvas.

### wxShape::AttachmentIsValid

bool AttachmentIsValid(int attachment) const

Returns TRUE if attachment is a valid attachment point.

### wxShape::AttachmentSortTest

bool AttachmentSortTest(int attachment, const wxRealPoint& pt1, const wxRealPoint& pt2) const

Returns TRUE if pt1 is less than or equal to pt2, in the sense that one point comes before another on an edge of the shape. attachment is the attachment point (side) in question.

This function is used in wxShape::MoveLineToNewAttachment to determine the new line ordering.

### wxShape::CalcSimpleAttachment

wxRealPoint CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPoint& pt2, int nth, int noArcs, wxLineShape* line)

Assuming the attachment lies along a vertical or horizontal line, calculates the position on that point.

Parameters

pt1

The first point of the line repesenting the edge of the shape.

pt2

The second point of the line representing the edge of the shape.

nth

The position on the edge (for example there may be 6 lines at this attachment point, and this may be the 2nd line.

noArcs

The number of lines at this edge.

line

The line shape.

Remarks

This function expects the line to be either vertical or horizontal, and determines which.

### wxShape::CalculateSize

void CalculateSize()

Called to calculate the shape's size if dependent on children sizes.

### wxShape::ClearAttachments

void ClearAttachments()

Clears internal custom attachment point shapes (of class wxAttachmentPoint).

### wxShape::ClearRegions

void ClearRegions()

Clears the wxShapeRegions from the shape.

### wxShape::ClearText

void ClearText(int regionId = 0)

Clears the text from the specified text region.

### wxShape::Constrain

bool Constrain()

Calculates the shape's constraints (if any). Applicable only to wxCompositeShape, does nothing if the shape is of a different class.

### wxShape::Copy

void Copy(wxShape& copy)

Copy this shape into copy. Every derived class must have one of these, and each Copy implementation must call the derived class's implementation to ensure everything is copied. See also wxShape::CreateNewCopy.

### wxShape::CreateNewCopy

wxShape* CreateNewCopy(bool resetMapping = TRUE, bool recompute = TRUE)

Creates and returns a new copy of this shape (calling wxShape::Copy). Do not override this function.

This function should always be used to create a new copy, since it must do special processing for copying constraints associated with constraints.

If resetMapping is TRUE, a mapping table used for complex shapes is reset; this may not be desirable if the shape being copied is a child of a composite (and so the mapping table is in use).

If recompute is TRUE, wxShape::Recompute is called for the new shape.

Remarks

This function uses the wxWindows dynamic object creation system to create a new shape of the same type as 'this', before calling Copy.

If the event handler for this shape is not the same as the shape itself, the event handler is also copied using wxShapeEvtHandler::CreateNewCopy.

### wxShape::DeleteControlPoints

void DeleteControlPoints()

Deletes the control points (or handles) for the shape. Does not redraw the shape.

### wxShape::Detach

void Detach()

Disassociates the shape from its canvas by setting the internal shape canvas pointer to NULL.

### wxShape::Draggable

bool Draggable()

TRUE if the shape may be dragged by the user.

### wxShape::Draw

void Draw(wxDC& dc)

Draws the whole shape and any lines attached to it.

Do not override this function: override OnDraw, which is called by this function.

### wxShape::DrawContents

void DrawContents(wxDC& dc)

Draws the internal graphic of the shape (such as text).

Do not override this function: override OnDrawContents, which is called by this function.

### wxShape::DrawLinks

void DrawLinks(wxDC& dc, int attachment = -1)

Draws any lines linked to this shape.

### wxShape::Erase

void Erase(wxDC& dc)

Erases the shape, but does not repair damage caused to other shapes.

### wxShape::EraseContents

void EraseContents(wxDC& dc)

Erases the shape contents, that is, the area within the shape's minimum bounding box.

### wxShape::EraseLinks

void EraseLinks(wxDC& dc, int attachment = -1)

Erases links attached to this shape, but does not repair damage caused to other shapes.

### wxShape::FindRegion

wxShape * FindRegion(const wxString& regionName, int *regionId)

Finds the actual image ('this' if non-composite) and region id for the given region name.

### wxShape::FindRegionNames

void FindRegionNames(wxStringList& list)

Finds all region names for this image (composite or simple). Supply an empty string list.

### wxShape::Flash

void Flash()

Flashes the shape.

### wxShape::FormatText

void FormatText(const wxString& s, int i = 0)

Reformats the given text region; defaults to formatting the default region.

### wxShape::GetAttachmentMode

bool GetAttachmentMode() const

Returns the attachment mode, which is TRUE if attachments are used, FALSE otherwise (in which case lines will be drawn as if to the centre of the shape). See wxShape::SetAttachmentMode.

### wxShape::GetAttachmentPosition

bool GetAttachmentPosition(int attachment, double* x, double* y, int nth = 0, int noArcs = 1, wxLineShape* line = NULL)

Gets the position at which the given attachment point should be drawn.

If attachment isn't found among the attachment points of the shape, returns FALSE.

### wxShape::GetBoundingBoxMax

void GetBoundingBoxMax(double *width, double *height)

Gets the maximum bounding box for the shape, taking into account external features such as shadows.

### wxShape::GetBoundingBoxMin

void GetBoundingBoxMin(double *width, double *height)

Gets the minimum bounding box for the shape, that defines the area available for drawing the contents (such as text).

### wxShape::GetBrush

wxBrush* GetBrush() const

Returns the brush used for filling the shape.

### wxShape::GetCanvas

wxShapeCanvas* GetCanvas() const

Gets the internal canvas pointer.

### wxShape::GetCentreResize

bool GetCentreResize() const

Returns TRUE if the shape is to be resized from the centre (the centre stands still), or FALSE if from the corner or side being dragged (the other corner or side stands still).

### wxShape::GetChildren

wxList& GetChildren() const

Returns a reference to the list of children for this shape.

### wxShape::GetClientData

wxObject* GetClientData()

Gets the client data associated with the shape (NULL if there is none).

### wxShape::GetDisableLabel

bool GetDisableLabel() const

Returns TRUE if the default region will not be shown, FALSE otherwise.

### wxShape::GetEventHandler

wxShapeEvtHandler* GetEventHandler() const

Returns the event handler for this shape.

### wxShape::GetFixedHeight

bool GetFixedHeight() const

Returns TRUE if the shape cannot be resized in the vertical plane.

### wxShape::GetFixedSize

void GetFixedSize(bool * x, bool * y)

Returns flags indicating whether the shape is of fixed size in either direction.

### wxShape::GetFixedWidth

bool GetFixedWidth() const

Returns TRUE if the shape cannot be resized in the horizontal plane.

### wxShape::GetFont

wxFont* GetFont(int regionId = 0) const

Gets the font for the specified text region.

### wxShape::GetFunctor

wxString GetFunctor() const

Gets a string representing the type of the shape, to be used when writing out shape descriptions to a file. This is overridden by each derived shape class to provide an appropriate type string. By default, "node_image" is used for non-line shapes, and "arc_image" for lines.

### wxShape::GetId

long GetId() const

Returns the integer identifier for this shape.

### wxShape::GetLinePosition

int GetLinePosition(wxLineShape* line)

Gets the zero-based position of line in the list of lines for this shape.

### wxShape::GetLines

wxList& GetLines() const

Returns a reference to the list of lines connected to this shape.

### wxShape::GetMaintainAspectRatio

bool GetMaintainAspectRatio() const

If returns TRUE, resizing the shape will not change the aspect ratio (width and height will be in the original proportion).

### wxShape::GetNumberOfAttachments

int GetNumberOfAttachments() const

Gets the number of attachment points for this shape.

### wxShape::GetNumberOfTextRegions

int GetNumberOfTextRegions() const

Gets the number of text regions for this shape.

### wxShape::GetParent

wxShape * GetParent() const

Returns the parent of this shape, if it is part of a composite.

### wxShape::GetPen

wxPen* GetPen() const

Returns the pen used for drawing the shape's outline.

### wxShape::GetPerimeterPoint

bool GetPerimeterPoint(double x1, double y1, double x2, double y2, double *x3, double *y3)

Gets the point at which the line from (x1, y1) to (x2, y2) hits the shape. Returns TRUE if the line hits the perimeter.

### wxShape::GetRegionId

int GetRegionId(const wxString& name)

Gets the region's identifier by name. This is not unique for within an entire composite, but is unique for the image.

### wxShape::GetRegionName

wxString GetRegionName(int regionId = 0)

Gets the region's name. A region's name can be used to uniquely determine a region within an entire composite image hierarchy. See also wxShape::SetRegionName.

### wxShape::GetRegions

wxList& GetRegions()

Returns the list of wxShapeRegions.

### wxShape::GetRotation

double GetRotatation() const

Returns the angle of rotation in radians.

### wxShape::GetSensitivityFilter

void GetSensitivityFilter() const

Returns the sensitivity filter, a bitlist of values. See wxShape::SetSensitivityFilter.

### wxShape::GetShadowMode

int SetShadowMode() const

Returns the shadow mode. See wxShape::SetShadowMode.

### wxShape::GetSpaceAttachments

bool GetSpaceAttachments() const

Indicates whether lines should be spaced out evenly at the point they touch the node (TRUE), or whether they should join at a single point (FALSE).

### wxShape::GetTextColour

wxString GetTextColour(int regionId = 0) const

Gets the colour for the specified text region.

### wxShape::GetTopAncestor

wxShape * GetTopAncestor() const

Returns the top-most ancestor of this shape (the root of the composite).

### wxShape::GetX

double GetX() const

Gets the x position of the centre of the shape.

### wxShape::GetY

double GetY() const

Gets the y position of the centre of the shape.

### wxShape::HitTest

bool HitTest(double x, double y, int* attachment, double* distance)

Given a point on a canvas, returns TRUE if the point was on the shape, and returns the nearest attachment point and distance from the given point and target.

### wxShape::Insert

void InsertInCanvas(wxShapeCanvas* canvas)

Inserts the shape at the front of the shape list of canvas.

### wxShape::IsHighlighted

bool IsHighlighted() const

Returns TRUE if the shape is highlighted. Shape highlighting is unimplemented.

### wxShape::IsShown

bool IsShown() const

Returns TRUE if the shape is in a visible state, FALSE otherwise. Note that this has nothing to do with whether the window is hidden or the shape has scrolled off the canvas; it refers to the internal visibility flag.

### wxShape::MakeControlPoints

void MakeControlPoints()

Make a list of control points (draggable handles) appropriate to the shape.

### wxShape::MakeMandatoryControlPoints

void MakeMandatoryControlPoints()

Make the mandatory control points. For example, the control point on a dividing line should appear even if the divided rectangle shape's handles should not appear (because it is the child of a composite, and children are not resizable).

### wxShape::Move

void Move(wxDC& dc, double x1, double y1, bool display = TRUE)

Move the shape to the given position, redrawing if display is TRUE.

### wxShape::MoveLineToNewAttachment

void MoveLineToNewAttachment(wxDC& dc, wxLineShape* toMove, double x, double y)

Move the given line (which must already be attached to the shape) to a different attachment point on the shape, or a different order on the same attachment.

Cals wxShape::AttachmentSortTest and then wxShapeEvtHandler::OnChangeAttachment.

### wxShape::MoveLinks

void MoveLinks(wxDC& dc)

Redraw all the lines attached to the shape.

### wxShape::NameRegions

void NameRegions(const wxString& parentName = "")

Make unique names for all the regions in a shape or composite shape.

### wxShape::Rotate

void Rotate(double x, double y, double theta)

Rotate about the given axis by the given amount in radians (does nothing for most shapes). But even non-rotating shapes should record their notional rotation in case it's important (e.g. in dog-leg code).

### wxShape::ReadConstraints

void ReadConstraints(wxExpr *clause, wxExprDatabase *database)

If the shape is a composite, it may have constraints that need to be read in in a separate pass.

### wxShape::ReadAttributes

void ReadAttributes(wxExpr* clause)

Reads the attributes (data member values) from the given expression.

### wxShape::ReadRegions

void ReadRegions(wxExpr *clause)

Reads in the regions.

### wxShape::Recentre

void Recentre()

Does recentring (or other formatting) for all the text regions for this shape.

### wxShape::RemoveFromCanvas

void RemoveFromCanvas(wxShapeCanvas* canvas)

Removes the shape from the canvas.

### wxShape::ResetControlPoints

void ResetControlPoints()

Resets the positions of the control points (for instance when the shape's shape has changed).

### wxShape::ResetMandatoryControlPoints

void ResetMandatoryControlPoints()

Reset the mandatory control points. For example, the control point on a dividing line should appear even if the divided rectangle shape's handles should not appear (because it is the child of a composite, and children are not resizable).

### wxShape::Recompute

bool Recompute()

Recomputes any constraints associated with the shape (normally applicable to wxCompositeShapes only, but harmless for other classes of shape).

### wxShape::RemoveLine

void RemoveLine(wxLineShape* line)

Removes the given line from the shape's list of attached lines.

### wxShape::Select

void Select(bool select = TRUE)

Selects or deselects the given shape, drawing or erasing control points (handles) as necessary.

### wxShape::Selected

bool Selected() const

TRUE if the shape is currently selected.

### wxShape::SetAttachmentMode

void SetAttachmentMode(bool flag)

Sets the attachment mode to TRUE or FALSE. If TRUE, attachment points will be significant when drawing lines to and from this shape. If FALSE, lines will be drawn as if to the centre of the shape.

### wxShape::SetBrush

void SetBrush(wxBrush *brush)

Sets the brush for filling the shape's shape.

### wxShape::SetCanvas

void SetCanvas(wxShapeCanvas* theCanvas)

Identical to wxShape::Attach.

### wxShape::SetCentreResize

void SetCentreResize(bool cr)

Specify whether the shape is to be resized from the centre (the centre stands still) or from the corner or side being dragged (the other corner or side stands still).

### wxShape::SetClientData

void SetClientData(wxObject *clientData)

Sets the client data.

### wxShape::SetDefaultRegionSize

void SetDefaultRegionSize()

Set the default region to be consistent with the shape size.

### wxShape::SetDisableLabel

void SetDisableLabel(bool flag)

Set flag to TRUE to stop the default region being shown, FALSE otherwise.

### wxShape::SetDraggable

void SetDraggable(bool drag, bool recursive = FALSE)

Sets the shape to be draggable or not draggable.

### wxShape::SetDrawHandles

void SetDrawHandles(bool drawH)

Sets the drawHandles flag for this shape and all descendants. If drawH is TRUE (the default), any handles (control points) will be drawn. Otherwise, the handles will not be drawn.

### wxShape::SetEventHandler

void GetEventHandler(wxShapeEvtHandler *handler)

Sets the event handler for this shape.

### wxShape::SetFixedSize

void SetFixedSize(bool x, bool y)

Sets the shape to be of the given, fixed size.

### wxShape::SetFont

void SetFont(wxFont *font, int regionId = 0)

Sets the font for the specified text region.

### wxShape::SetFormatMode

void SetFormatMode(int mode, int regionId = 0)

Sets the format mode of the default text region. The argument can be a bit list of the following:

FORMAT_NONE
  No formatting.
FORMAT_CENTRE_HORIZ
  Horizontal centring.
FORMAT_CENTRE_VERT
  Vertical centring.

### wxShape::SetHighlight

void SetHighlight(bool hi, bool recurse = FALSE)

Sets the highlight for a shape. Shape highlighting is unimplemented.

### wxShape::SetId

void SetId(long id)

Set the integer identifier for this shape.

### wxShape::SetMaintainAspectRatio

void SetMaintainAspectRatio(bool flag)

If the argument is TRUE, tells the shape that resizes should not change the aspect ratio (width and height should be in the original proportion).

### wxShape::SetPen

void SetPen(wxPen *pen)

Sets the pen for drawing the shape's outline.

### wxShape::SetRegionName

void SetRegionName(const wxString& name, int regionId = 0)

Sets the name for this region. The name for a region is unique within the scope of the whole composite, whereas a region id is unique only for a single image.

### wxShape::SetSensitivityFilter

void SetSensitivityFilter(int sens=OP_ALL, bool recursive = FALSE)

Sets the shape to be sensitive or insensitive to specific mouse operations.

sens is a bitlist of the following:

- OP_CLICK_LEFT
- OP_CLICK_RIGHT
- OP_DRAG_LEFT
- OP_DRAG_RIGHT
- OP_ALL (equivalent to a combination of all the above).

### wxShape::SetShadowMode

void SetShadowMode(int mode, bool redraw = FALSE)

Sets the shadow mode (whether a shadow is drawn or not). mode can be one of the following:

SHADOW_NONE
  No shadow (the default).
SHADOW_LEFT
  Shadow on the left side.
SHADOW_RIGHT
  Shadow on the right side.

### wxShape::SetSize

void SetSize(double x, double y, bool recursive = TRUE)

Sets the shape's size.

### wxShape::SetSpaceAttachments

void SetSpaceAttachments(bool sp)

Indicate whether lines should be spaced out evenly at the point they touch the node (TRUE), or whether they should join at a single point (FALSE).

### wxShape::SetTextColour

void SetTextColour(const wxString& colour, int regionId = 0)

Sets the colour for the specified text region.

### wxShape::SetX

void SetX(double x)

Sets the x position of the shape.

### wxShape::SetX

void SetY(double y)

Sets the y position of the shape.

### wxShape::SpaceAttachments

void SpaceAttachments(bool sp)

Sets the spacing mode: if TRUE, lines at the same attachment point will be spaced evenly across that side of the shape. If false, all lines at the same attachment point will emanate from the same point.

### wxShape::Show

void Show(bool show)

Sets a flag indicating whether the shape should be drawn.

### wxShape::Unlink

void Unlink()

If the shape is a line, unlinks the nodes attached to the shape, removing itself from the list of lines for each of the 'to' and 'from' nodes.

### wxShape::WriteAttributes

void WriteAttributes(wxExpr *clause)

Writes the shape's attributes (data member values) into the given expression.

### wxShape::WriteRegions

void WriteRegions(wxExpr *clause)

Writes the regions.