Design goal. More...
#include <mi32/grlayout.h>

Classes | |
| class | ITEM |
| class | ITEMPOSITION |
| class | ITEMPROPERTYSHEET |
| This class is used to create "property sheets" for various element types. More... | |
| struct | ITEMTYPE |
| class | NAMEDTEXTSTYLE |
| class | OBSERVER |
| This is a base class that any class wishing to be notified of changes to a GRAPHICLAYOUT may derive itself from. More... | |
| class | OBSERVERMANAGER |
| class | SUSPEND_REDRAW |
| Creating an instance of this class suspends redrawing on the layout. More... | |
| class | TEXTBLOCK |
Public Types | |
| typedef ITEMLIST::CONST_ITERATOR | CONST_ITERATOR |
| typedef MILIST< ITEM * > | ITEMLIST |
| typedef ITEMLIST::ITERATOR | ITERATOR |
Public Member Functions | |
| GRAPHICLAYOUT (const GRAPHICLAYOUT &rhs) | |
| GRAPHICLAYOUT () | |
| virtual | ~GRAPHICLAYOUT () |
| int | AddHGuide (DOUBLE value) |
| void | AddItem (ITEM *item) |
| int | AddTextStyle (const NAMEDTEXTSTYLE &style) |
| int | AddVGuide (DOUBLE value) |
| CONST_ITERATOR | Begin () const |
| ITERATOR | Begin () |
| void | ComputeItemAttachments (const ITEM *item, DRECT2D &rect, ITEMPOSITION &newpos, const ITEM *&ItemAbove, bool bSnap=true) const |
| ERRVALUE | Copy (const GRAPHICLAYOUT &rhs) |
| int | DoLayout () |
| int | Draw (MGD::CONTEXT *gc, const DRECT2D *rect=0, const TRANS2D_MAPGEN *trans=0, double scale=1.0) |
| void | DrawItemHandles (MGD::CONTEXT *gc, const ITEMPOSITION &position, const DRECT2D &rect, const GRAPHICLAYOUT::ITEM *ItemAbove, const DPOINT2D &SelectedDelta, double scale=1.0) const |
| CONST_ITERATOR | End () const |
| ITERATOR | End () |
| const COLOR & | GetBackgroundColor () const |
| const LINESTYLE & | GetBorderStyle () const |
| bool | GetDrawBackground () const |
| bool | GetDrawBorder () const |
| bool | GetDrawDropShadow () const |
| const COLOR & | GetDropShadowColor () const |
| double | GetDropShadowDirection () const |
| double | GetDropShadowDistance () const |
| DOUBLE | GetHeight () const |
| DOUBLE | GetHGuide (int GuideNum) const |
| INT32 | GetHGuideFromLocation (const DPOINT2D &point, int tolerance=2) const |
| const ITEM * | GetItemFromLocation (const DPOINT2D &point) const |
| ITEM * | GetItemFromLocation (const DPOINT2D &point) |
| int | GetNumHGuides () const |
| int | GetNumTextStyles () const |
| int | GetNumVGuides () const |
| void | GetTextStyle (int num, NAMEDTEXTSTYLE &style) const |
| void | GetTextStyle (int num, TEXTSTYLE &style) const |
| const NAMEDTEXTSTYLE * | GetTextStyle (int num) const |
| const MIUNICODE * | GetTextStyleName (int num) const |
| void | GetTextStyles (std::vector< NAMEDTEXTSTYLE > &styles) |
| DOUBLE | GetVGuide (int GuideNum) const |
| INT32 | GetVGuideFromLocation (const DPOINT2D &point, int tolerance=2) const |
| DOUBLE | GetWidth () const |
| bool | IsLayoutNeeded () const |
| void | MoveItem (ITEM *item, const DRECT2D &location, bool bSnap) |
| void | MoveItem (ITEM *item, DOUBLE dx, DOUBLE dy, bool bSnap) |
| void | RedrawResume () |
| void | RedrawSuspend () |
| bool | RemoveHGuide (int GuideNum) |
| void | RemoveItem (ITEM *item) |
| bool | RemoveVGuide (int GuideNum) |
| virtual const SERIALIZERITEM * | SerialGetItemDef (SERIALIZER &serializer) const |
| virtual const char * | SerialGetTagName () const |
| virtual ERRVALUE | SerialRead (SERIALIZER &serializer) |
| virtual ERRVALUE | SerialWrite (SERIALIZER &serializer, const char *itemname) const |
| void | SetBackgroundColor (const COLOR &color) |
| void | SetBorderStyle (const LINESTYLE &style) |
| void | SetDrawBackground (bool DrawBackground) |
| void | SetDrawBorder (bool DrawBorder) |
| void | SetDrawDropShadow (bool DrawDropShadow) |
| void | SetDropShadowColor (const COLOR &color) |
| void | SetDropShadowDirection (double angle) |
| void | SetDropShadowDistance (double distance) |
| void | SetHGuide (int GuideNum, DOUBLE value) |
| void | SetLayoutNeeded () |
| void | SetRedrawNeeded () |
| void | SetTextStyle (int num, const NAMEDTEXTSTYLE &style) |
| void | SetTextStyleName (int num, const MIUNICODE *name) |
| ERRVALUE | SetTextStyles (const std::vector< NAMEDTEXTSTYLE > &styles, const SIMPLE_ARRAY< INT32 > &trans) |
| ERRVALUE | SetTextStyles (const std::vector< NAMEDTEXTSTYLE > &styles) |
| void | SetVGuide (int GuideNum, DOUBLE value) |
| bool | UsesTransparency (const MGD::CONTEXT *gc=0) const |
Static Public Member Functions | |
| static const SERIALIZERITEM * | GetSerialItemDef () |
| static void | InstallItemType (const char *name, int(*Construct)(GRAPHICLAYOUT &, ITEM **)) |
Private Member Functions | |
| void | DrawHandle (MGD::CONTEXT *gc, const DPOINT2D &GuideEnd, const DPOINT2D &ItemEnd) const |
| void | Free () |
| GRAPHICLAYOUT & | operator= (const GRAPHICLAYOUT &rhs) |
| void | Redraw () |
| void | SortHGuides () |
| void | SortVGuides () |
Static Private Member Functions | |
| static ERRVALUE | SerializerCB_Item (SERIALIZER &serializer, const SERIALIZERITEM *itemdef, void *cbdata, SERIALIZERITEM::ACTION action) |
| static ERRVALUE | SerializerCB_NamedTextStyle (SERIALIZER &serializer, const SERIALIZERITEM *itemdef, void *cbdata, SERIALIZERITEM::ACTION action) |
Private Attributes | |
| bool | m_bDrawBackground |
| bool | m_bDrawBorder |
| bool | m_bDrawDropShadow |
| COLOR | m_BGColor |
| bool | m_bLayoutNeeded |
| LINESTYLE | m_BorderStyle |
| bool | m_bRedrawNeeded |
| COLOR | m_DropShadowColor |
| double | m_DropShadowDirection |
| double | m_DropShadowDistance |
| DRECT2D | m_Extents |
| DOUBLE * | m_HGuides |
| ITEMLIST | m_ItemList |
| INT32 | m_MaxGroup |
| UINT32 | m_NumHGuides |
| UINT32 | m_NumVGuides |
| OBSERVERMANAGER | m_Observers |
| UINT32 | m_RedrawSuspended |
| std::vector< NAMEDTEXTSTYLE > | m_TextStyle |
| DOUBLE * | m_VGuides |
Static Private Attributes | |
| static SIMPLE_ARRAY< ITEMTYPE > | s_ItemTypes |
Design goal.
..
Need two classes. the GRAPHICLAYOUT class keeps track of positions of things and calls generic drawing methods but know nothing about X
Need another class which takes a pointer or reference to a GRAPHICLAYOUT and handles all the user input associated with editing one. GRAPHICLAYOUT should be SERIALIZABLE For simplicity, everything's vertical position is recorded as an offset from either... a) the item above it b) a guide All horizontal positions are recorded as an offset from a guide If I end up using this for the rewrite of forms later, this may have to be extended to allow things to be tacked onto the end of other things at the same "Y" position. Shouldn't be too hard.
Sizes and distances are defined as "points at layout map scale" If drawing to something where "layout scale" is meaningless, treat them as pixels.
| typedef ITEMLIST::CONST_ITERATOR GRAPHICLAYOUT::CONST_ITERATOR |
| typedef MILIST<ITEM*> GRAPHICLAYOUT::ITEMLIST |
| typedef ITEMLIST::ITERATOR GRAPHICLAYOUT::ITERATOR |
| GRAPHICLAYOUT::GRAPHICLAYOUT | ( | ) |
Constructor.
| GRAPHICLAYOUT::GRAPHICLAYOUT | ( | const GRAPHICLAYOUT & | rhs | ) |
Copy constructor.
| virtual GRAPHICLAYOUT::~GRAPHICLAYOUT | ( | ) | [virtual] |
Destructor.
| int GRAPHICLAYOUT::AddHGuide | ( | DOUBLE | value | ) |
Add a Horizontal Guide.
Returns the new guide number or err < 0
| void GRAPHICLAYOUT::AddItem | ( | ITEM * | item | ) |
Add an item to the layout.
Once added, the item is "owned" by the layout and will be destroied by the layout's destructor. If the position of the item hasn't been set yet, a default postion will be computed.
| int GRAPHICLAYOUT::AddTextStyle | ( | const NAMEDTEXTSTYLE & | style | ) |
Add a named text style.
| int GRAPHICLAYOUT::AddVGuide | ( | DOUBLE | value | ) |
Add a Vertical Guide.
Returns the new guide number or err < 0
| CONST_ITERATOR GRAPHICLAYOUT::Begin | ( | ) | const [inline] |
Return const iterator to first item in layout.
| ITERATOR GRAPHICLAYOUT::Begin | ( | ) | [inline] |
Return iterator to first item in layout.
| void GRAPHICLAYOUT::ComputeItemAttachments | ( | const ITEM * | item, | |
| DRECT2D & | rect, | |||
| ITEMPOSITION & | newpos, | |||
| const ITEM *& | ItemAbove, | |||
| bool | bSnap = true | |||
| ) | const |
Compute item attachments given a rectangle of where the item will go.
If bSnap is true, then anything within 3 pixels of a guide will snap to the guide and the rectangle will be adjusted accordingly
| newpos | Computed and returned (Initial values unused) |
| ERRVALUE GRAPHICLAYOUT::Copy | ( | const GRAPHICLAYOUT & | rhs | ) |
| int GRAPHICLAYOUT::DoLayout | ( | ) |
Compute all item positions.
If nothing has changed since the last layout, nothing is done.
| int GRAPHICLAYOUT::Draw | ( | MGD::CONTEXT * | gc, | |
| const DRECT2D * | rect = 0, |
|||
| const TRANS2D_MAPGEN * | trans = 0, |
|||
| double | scale = 1.0 | |||
| ) |
Draw.
If Rect is not 0, only draw things intersecting the rect
| void GRAPHICLAYOUT::DrawHandle | ( | MGD::CONTEXT * | gc, | |
| const DPOINT2D & | GuideEnd, | |||
| const DPOINT2D & | ItemEnd | |||
| ) | const [private] |
| void GRAPHICLAYOUT::DrawItemHandles | ( | MGD::CONTEXT * | gc, | |
| const ITEMPOSITION & | position, | |||
| const DRECT2D & | rect, | |||
| const GRAPHICLAYOUT::ITEM * | ItemAbove, | |||
| const DPOINT2D & | SelectedDelta, | |||
| double | scale = 1.0 | |||
| ) | const |
Draw "handles" showing item attachemts.
(normally done while moving an item) SelectedDelta is the offset in output cordinates that selected items have been shifted.
| CONST_ITERATOR GRAPHICLAYOUT::End | ( | ) | const [inline] |
Return const iterator to compare to end of layout (0).
| ITERATOR GRAPHICLAYOUT::End | ( | ) | [inline] |
Return iterator to compare to end of layout (0).
| void GRAPHICLAYOUT::Free | ( | ) | [private] |
Free the contents of the layout. Used by Copy and desturctor.
| const COLOR& GRAPHICLAYOUT::GetBackgroundColor | ( | ) | const [inline] |
| const LINESTYLE& GRAPHICLAYOUT::GetBorderStyle | ( | ) | const [inline] |
| bool GRAPHICLAYOUT::GetDrawBackground | ( | ) | const [inline] |
Control wether or not the legend background is filled.
| bool GRAPHICLAYOUT::GetDrawBorder | ( | ) | const [inline] |
Control wether or not a border is drawn around the legend Use SetBorderStyle() to set the style of the border.
| bool GRAPHICLAYOUT::GetDrawDropShadow | ( | ) | const [inline] |
Determine if DropShadow is on or off.
| const COLOR& GRAPHICLAYOUT::GetDropShadowColor | ( | ) | const [inline] |
Get the color for the drop shadow.
| double GRAPHICLAYOUT::GetDropShadowDirection | ( | ) | const [inline] |
Get the angle for the drop shadow (in radians).
| double GRAPHICLAYOUT::GetDropShadowDistance | ( | ) | const [inline] |
Get distance for the drop shadow (in points).
| DOUBLE GRAPHICLAYOUT::GetHeight | ( | ) | const [inline] |
Get the height of the content.
| DOUBLE GRAPHICLAYOUT::GetHGuide | ( | int | GuideNum | ) | const [inline] |
Return the value of a Horizontal Guide.
Given an X/Y position, return the horizontal Guide number.
Returns -1 if no guide at given location.
| tolerance | How close do we have to be (in pixels) |
Const version of GetItemFromLocation().
Given an x/y position return the item at that location.
Returns NULL if no item at that location.
| int GRAPHICLAYOUT::GetNumHGuides | ( | ) | const [inline] |
Get the number of Horizontal Guides.
| int GRAPHICLAYOUT::GetNumTextStyles | ( | ) | const [inline] |
Get the number of text styles.
| int GRAPHICLAYOUT::GetNumVGuides | ( | ) | const [inline] |
Get the number of Vertical Guides.
| static const SERIALIZERITEM* GRAPHICLAYOUT::GetSerialItemDef | ( | ) | [static] |
Method for implementing SERIALIZABLE behaviour.
| void GRAPHICLAYOUT::GetTextStyle | ( | int | num, | |
| NAMEDTEXTSTYLE & | style | |||
| ) | const [inline] |
Get a copy of a text style.
| void GRAPHICLAYOUT::GetTextStyle | ( | int | num, | |
| TEXTSTYLE & | style | |||
| ) | const [inline] |
Get a copy of a text style.
| const NAMEDTEXTSTYLE* GRAPHICLAYOUT::GetTextStyle | ( | int | num | ) | const [inline] |
Get a text style (const*).
| const MIUNICODE* GRAPHICLAYOUT::GetTextStyleName | ( | int | num | ) | const [inline] |
Get the name of a text style.
| void GRAPHICLAYOUT::GetTextStyles | ( | std::vector< NAMEDTEXTSTYLE > & | styles | ) | [inline] |
Get the list of text styles.
Can't return a const SIMPLE_ARRAY<>& because they're not stored that way internally for serialization reasons.
| DOUBLE GRAPHICLAYOUT::GetVGuide | ( | int | GuideNum | ) | const [inline] |
Return the value of a Vertical Guide.
| tolerance | How close do we have to be (in pixels) |
| DOUBLE GRAPHICLAYOUT::GetWidth | ( | ) | const [inline] |
Get the width of the content.
| static void GRAPHICLAYOUT::InstallItemType | ( | const char * | name, | |
| int(*)(GRAPHICLAYOUT &, ITEM **) | Construct | |||
| ) | [static] |
Install handler for an ITEMTYPE.
| name | Item type name for serialization | |
| Construct | Function to construct an item of this type |
| bool GRAPHICLAYOUT::IsLayoutNeeded | ( | ) | const [inline] |
Move an item to an absolute location.
| item | Item to move | |
| location | Where to move it to (XXX May make this a point) | |
| bSnap | Snap to guide if close |
Move an item relative to its current position.
| item | Item to move | |
| dx | Distance to move (x) | |
| dy | Distance to move (y, positive == down) | |
| bSnap | Snap to guide if close |
| GRAPHICLAYOUT& GRAPHICLAYOUT::operator= | ( | const GRAPHICLAYOUT & | rhs | ) | [private] |
Assignment operator (private and inimplemented to prevent use) (Use Copy(), which can return an error if it needs to).
| void GRAPHICLAYOUT::Redraw | ( | ) | [private] |
Inform all observers that they need to redraw.
| void GRAPHICLAYOUT::RedrawResume | ( | ) | [inline] |
Resume redraws.
If anything has changd while redraws were suspended, it will redraw. See comments on RedrawSuspend() for more information.
Notifies all observers
| void GRAPHICLAYOUT::RedrawSuspend | ( | ) | [inline] |
Suspend redraws.
RedrawSuspend()/RedrawResume() calls can be nested. If you plan to Suspend/Resume in the same function, you're better off creating an instance of a GRAPHICLAYOUT::SUSPENDREDRAW, which will automatically resume when it goes out of scope.
| bool GRAPHICLAYOUT::RemoveHGuide | ( | int | GuideNum | ) |
Remove a Horizontal Guide.
Will not allow the removal of a guide which is in use. Will return true if the guide was removed, false if it was in use or an invalid guide number.
| void GRAPHICLAYOUT::RemoveItem | ( | ITEM * | item | ) |
Removes an item from the layout.
Does not free the item. Once removed from the layout, it is your responsibility to destroy the item. Any items which are in the layout at the time the layout is destroied will get destroied by the layout's destructor.
| bool GRAPHICLAYOUT::RemoveVGuide | ( | int | GuideNum | ) |
Remove a Vertical Guide.
Will not allow the removal of a guide which is in use. Will return true if the guide was removed, false if it was in use or an invalid guide number.
| virtual const SERIALIZERITEM* GRAPHICLAYOUT::SerialGetItemDef | ( | SERIALIZER & | serializer | ) | const [virtual] |
Method for implementing SERIALIZABLE behaviour.
| virtual const char* GRAPHICLAYOUT::SerialGetTagName | ( | ) | const [inline, virtual] |
Method for implementing SERIALIZABLE behaviour.
| static ERRVALUE GRAPHICLAYOUT::SerializerCB_Item | ( | SERIALIZER & | serializer, | |
| const SERIALIZERITEM * | itemdef, | |||
| void * | cbdata, | |||
| SERIALIZERITEM::ACTION | action | |||
| ) | [static, private] |
| static ERRVALUE GRAPHICLAYOUT::SerializerCB_NamedTextStyle | ( | SERIALIZER & | serializer, | |
| const SERIALIZERITEM * | itemdef, | |||
| void * | cbdata, | |||
| SERIALIZERITEM::ACTION | action | |||
| ) | [static, private] |
| virtual ERRVALUE GRAPHICLAYOUT::SerialRead | ( | SERIALIZER & | serializer | ) | [virtual] |
Method for implementing SERIALIZABLE behaviour.
Implements SERIALIZABLE.
| virtual ERRVALUE GRAPHICLAYOUT::SerialWrite | ( | SERIALIZER & | serializer, | |
| const char * | itemname | |||
| ) | const [virtual] |
Method for implementing SERIALIZABLE behaviour.
Implements SERIALIZABLE.
| void GRAPHICLAYOUT::SetBackgroundColor | ( | const COLOR & | color | ) | [inline] |
| void GRAPHICLAYOUT::SetBorderStyle | ( | const LINESTYLE & | style | ) | [inline] |
Set the style of the border to draw around the legend.
Use SetDrawBorder() to control wether or not this is used.
| void GRAPHICLAYOUT::SetDrawBackground | ( | bool | DrawBackground | ) | [inline] |
Control wether or not the background is filled.
| void GRAPHICLAYOUT::SetDrawBorder | ( | bool | DrawBorder | ) | [inline] |
Control wether or not a border is drawn around the legend Use SetBorderStyle() to set the style of the border.
| void GRAPHICLAYOUT::SetDrawDropShadow | ( | bool | DrawDropShadow | ) | [inline] |
Control wether or not a drop shadow is drawn around the legend Use SetDropShadowXxxx() to set the shadow parameters.
| void GRAPHICLAYOUT::SetDropShadowColor | ( | const COLOR & | color | ) | [inline] |
Set the color for the drop shadow.
| void GRAPHICLAYOUT::SetDropShadowDirection | ( | double | angle | ) | [inline] |
Set the angle for the drop shadow (in radians).
GUI should provide intuitive way to set this.
| void GRAPHICLAYOUT::SetDropShadowDistance | ( | double | distance | ) | [inline] |
Set the distance for the drop shadow (in points).
GUI should provide intuitive way to set this.
| void GRAPHICLAYOUT::SetHGuide | ( | int | GuideNum, | |
| DOUBLE | value | |||
| ) |
Set the value of a horizontal guide.
| void GRAPHICLAYOUT::SetLayoutNeeded | ( | ) | [inline] |
Sets the flag indicating that layout needs to be recomputed.
XXX This could be made private.
Inform observers if not suspended
| void GRAPHICLAYOUT::SetRedrawNeeded | ( | ) | [inline] |
Sets the flag indicating that layout needs to be redrawn but not necessarly layout recomputed.
Used when all was changed was color and things that don't effect size.
Inform observers if not suspended
| void GRAPHICLAYOUT::SetTextStyle | ( | int | num, | |
| const NAMEDTEXTSTYLE & | style | |||
| ) |
Set a text style.
| void GRAPHICLAYOUT::SetTextStyleName | ( | int | num, | |
| const MIUNICODE * | name | |||
| ) | [inline] |
Set the name of a text style.
| ERRVALUE GRAPHICLAYOUT::SetTextStyles | ( | const std::vector< NAMEDTEXTSTYLE > & | styles, | |
| const SIMPLE_ARRAY< INT32 > & | trans | |||
| ) |
Set the text styles, but allow for possibility of style reordering.
The trans parameter is an array of INT32's that map old style number to new style number. The size of this array should match the number of styles that are in the layout before the call. If a style has been deleted, it's entry in the array should be -1.
| ERRVALUE GRAPHICLAYOUT::SetTextStyles | ( | const std::vector< NAMEDTEXTSTYLE > & | styles | ) |
Set the text styles.
| void GRAPHICLAYOUT::SetVGuide | ( | int | GuideNum, | |
| DOUBLE | value | |||
| ) |
Set the value of a vertical guide.
| void GRAPHICLAYOUT::SortHGuides | ( | ) | [private] |
| void GRAPHICLAYOUT::SortVGuides | ( | ) | [private] |
| bool GRAPHICLAYOUT::UsesTransparency | ( | const MGD::CONTEXT * | gc = 0 |
) | const |
bool GRAPHICLAYOUT::m_bDrawBackground [private] |
bool GRAPHICLAYOUT::m_bDrawBorder [private] |
bool GRAPHICLAYOUT::m_bDrawDropShadow [private] |
COLOR GRAPHICLAYOUT::m_BGColor [private] |
bool GRAPHICLAYOUT::m_bLayoutNeeded [private] |
LINESTYLE GRAPHICLAYOUT::m_BorderStyle [private] |
bool GRAPHICLAYOUT::m_bRedrawNeeded [private] |
COLOR GRAPHICLAYOUT::m_DropShadowColor [private] |
double GRAPHICLAYOUT::m_DropShadowDirection [private] |
double GRAPHICLAYOUT::m_DropShadowDistance [private] |
DRECT2D GRAPHICLAYOUT::m_Extents [private] |
DOUBLE* GRAPHICLAYOUT::m_HGuides [private] |
ITEMLIST GRAPHICLAYOUT::m_ItemList [private] |
INT32 GRAPHICLAYOUT::m_MaxGroup [private] |
UINT32 GRAPHICLAYOUT::m_NumHGuides [private] |
UINT32 GRAPHICLAYOUT::m_NumVGuides [private] |
OBSERVERMANAGER GRAPHICLAYOUT::m_Observers [private] |
UINT32 GRAPHICLAYOUT::m_RedrawSuspended [private] |
std::vector<NAMEDTEXTSTYLE> GRAPHICLAYOUT::m_TextStyle [private] |
DOUBLE* GRAPHICLAYOUT::m_VGuides [private] |
SIMPLE_ARRAY<ITEMTYPE> GRAPHICLAYOUT::s_ItemTypes [static, private] |
1.6.1