GRAPHICLAYOUT Class Reference

#include <mi32/grlayout.h>

Inheritance diagram for GRAPHICLAYOUT:

Inheritance graph
[legend]
List of all members.

Public Types

typedef ITEMLIST::CONST_ITERATOR CONST_ITERATOR
typedef MILIST< ITEM * > ITEMLIST
typedef ITEMLIST::ITERATOR ITERATOR

Public Member Functions

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 TRANSPARM *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 COLORGetBackgroundColor () const
const LINESTYLEGetBorderStyle () const
bool GetDrawBackground () const
bool GetDrawBorder () const
bool GetDrawDropShadow () const
const COLORGetDropShadowColor () 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 ITEMGetItemFromLocation (const DPOINT2D &point) const
ITEMGetItemFromLocation (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 NAMEDTEXTSTYLEGetTextStyle (int num) const
const UNICODEGetTextStyleName (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
 GRAPHICLAYOUT (const GRAPHICLAYOUT &rhs)
 GRAPHICLAYOUT ()
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 SERIALIZER::ITEMDEFSerialGetItemDef (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 UNICODE *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
virtual ~GRAPHICLAYOUT ()

Static Public Member Functions

const SERIALIZER::ITEMDEFGetSerialItemDef ()
void InstallItemType (const char *name, int(*Construct)(GRAPHICLAYOUT &, ITEM **))

Private Member Functions

void DrawHandle (MGD::CONTEXT *gc, const DPOINT2D &GuideEnd, const DPOINT2D &ItemEnd, TRANSPARM *trans=0, double scale=1.0) const
void Free ()
GRAPHICLAYOUToperator= (const GRAPHICLAYOUT &rhs)
void Redraw ()
void SortHGuides ()
void SortVGuides ()

Static Private Member Functions

ERRVALUE SerializerCB_Item (SERIALIZER &serializer, const SERIALIZER::ITEMDEF *itemdef, void *cbdata, SERIALIZER::ITEMDEF::ACTION action)
ERRVALUE SerializerCB_NamedTextStyle (SERIALIZER &serializer, const SERIALIZER::ITEMDEF *itemdef, void *cbdata, SERIALIZER::ITEMDEF::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
DOUBLEm_HGuides
ITEMLIST m_ItemList
INT32 m_MaxGroup
UINT32 m_NumHGuides
UINT32 m_NumVGuides
OBSERVERMANAGER m_Observers
UINT32 m_RedrawSuspended
std::vector< NAMEDTEXTSTYLEm_TextStyle
DOUBLEm_VGuides

Static Private Attributes

SIMPLE_ARRAY< ITEMTYPEs_ItemTypes

Member Typedef Documentation

typedef ITEMLIST::CONST_ITERATOR GRAPHICLAYOUT::CONST_ITERATOR
 

Definition at line 188 of file grlayout.h.

typedef MILIST<ITEM*> GRAPHICLAYOUT::ITEMLIST
 

Definition at line 186 of file grlayout.h.

typedef ITEMLIST::ITERATOR GRAPHICLAYOUT::ITERATOR
 

Definition at line 187 of file grlayout.h.


Constructor & Destructor Documentation

GRAPHICLAYOUT::GRAPHICLAYOUT  ) 
 

#include <mi32/MILIST.h> Constructor.

GRAPHICLAYOUT::GRAPHICLAYOUT const GRAPHICLAYOUT rhs  ) 
 

Copy constructor.

virtual GRAPHICLAYOUT::~GRAPHICLAYOUT  )  [virtual]
 

Assignment operator private and unimplemented to prevent use Destructor.


Member Function Documentation

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.

Definition at line 993 of file grlayout.h.

ITERATOR GRAPHICLAYOUT::Begin  )  [inline]
 

Return iterator to first item in layout.

Definition at line 987 of file grlayout.h.

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

Parameters:
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 TRANSPARM 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,
TRANSPARM trans = 0,
double  scale = 1.0
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).

Definition at line 1070 of file grlayout.h.

ITERATOR GRAPHICLAYOUT::End  )  [inline]
 

Return iterator to compare to end of layout (0).

Definition at line 1064 of file grlayout.h.

void GRAPHICLAYOUT::Free  )  [private]
 

Free the contents of the layout. Used by Copy and desturctor.

const COLOR& GRAPHICLAYOUT::GetBackgroundColor  )  const [inline]
 

Definition at line 1080 of file grlayout.h.

const LINESTYLE& GRAPHICLAYOUT::GetBorderStyle  )  const [inline]
 

Definition at line 1075 of file grlayout.h.

bool GRAPHICLAYOUT::GetDrawBackground  )  const [inline]
 

Control wether or not the legend background is filled.

Definition at line 1086 of file grlayout.h.

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.

Definition at line 1093 of file grlayout.h.

bool GRAPHICLAYOUT::GetDrawDropShadow  )  const [inline]
 

Determine if DropShadow is on or off.

Definition at line 1099 of file grlayout.h.

const COLOR& GRAPHICLAYOUT::GetDropShadowColor  )  const [inline]
 

Get the color for the drop shadow.

Definition at line 1105 of file grlayout.h.

double GRAPHICLAYOUT::GetDropShadowDirection  )  const [inline]
 

Get the angle for the drop shadow (in radians).

Definition at line 1111 of file grlayout.h.

double GRAPHICLAYOUT::GetDropShadowDistance  )  const [inline]
 

Get distance for the drop shadow (in points).

Definition at line 1117 of file grlayout.h.

DOUBLE GRAPHICLAYOUT::GetHeight  )  const [inline]
 

Get the height of the content.

Definition at line 1131 of file grlayout.h.

DOUBLE GRAPHICLAYOUT::GetHGuide int  GuideNum  )  const [inline]
 

Return the value of a Horizontal Guide.

Definition at line 1123 of file grlayout.h.

INT32 GRAPHICLAYOUT::GetHGuideFromLocation const DPOINT2D point,
int  tolerance = 2
const
 

Given an X/Y position, return the horizontal Guide number.

Returns -1 if no guide at given location.

Parameters:
tolerance  How close do we have to be (in pixels)

const ITEM* GRAPHICLAYOUT::GetItemFromLocation const DPOINT2D point  )  const
 

Const version of GetItemFromLocation().

ITEM* GRAPHICLAYOUT::GetItemFromLocation const DPOINT2D point  ) 
 

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.

Definition at line 1161 of file grlayout.h.

int GRAPHICLAYOUT::GetNumTextStyles  )  const [inline]
 

Get the number of text styles.

Definition at line 1167 of file grlayout.h.

int GRAPHICLAYOUT::GetNumVGuides  )  const [inline]
 

Get the number of Vertical Guides.

Definition at line 1173 of file grlayout.h.

const SERIALIZER::ITEMDEF* GRAPHICLAYOUT::GetSerialItemDef  )  [static]
 

Method for implementing SERIALIZABLE behaviour.

void GRAPHICLAYOUT::GetTextStyle int  num,
NAMEDTEXTSTYLE style
const [inline]
 

Get a copy of a text style.

Definition at line 1196 of file grlayout.h.

void GRAPHICLAYOUT::GetTextStyle int  num,
TEXTSTYLE style
const [inline]
 

Get a copy of a text style.

Definition at line 1187 of file grlayout.h.

const NAMEDTEXTSTYLE* GRAPHICLAYOUT::GetTextStyle int  num  )  const [inline]
 

Get a text style (const*).

Definition at line 1179 of file grlayout.h.

const UNICODE* GRAPHICLAYOUT::GetTextStyleName int  num  )  const [inline]
 

Get the name of a text style.

Definition at line 1206 of file grlayout.h.

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.

Definition at line 1216 of file grlayout.h.

DOUBLE GRAPHICLAYOUT::GetVGuide int  GuideNum  )  const [inline]
 

Return the value of a Vertical Guide.

Definition at line 1224 of file grlayout.h.

INT32 GRAPHICLAYOUT::GetVGuideFromLocation const DPOINT2D point,
int  tolerance = 2
const
 

Parameters:
tolerance  How close do we have to be (in pixels)

DOUBLE GRAPHICLAYOUT::GetWidth  )  const [inline]
 

Get the width of the content.

Definition at line 1232 of file grlayout.h.

void GRAPHICLAYOUT::InstallItemType const char *  name,
int(*  Construct)(GRAPHICLAYOUT &, ITEM **)
[static]
 

Install handler for an ITEMTYPE.

Parameters:
name  Item type name for serialization
Construct  Function to construct an item of this type

bool GRAPHICLAYOUT::IsLayoutNeeded  )  const [inline]
 

Definition at line 1237 of file grlayout.h.

void GRAPHICLAYOUT::MoveItem ITEM item,
const DRECT2D location,
bool  bSnap
 

Move an item to an absolute location.

Parameters:
item  Item to move
location  Where to move it to (XXX May make this a point)
bSnap  Snap to guide if close

void GRAPHICLAYOUT::MoveItem ITEM item,
DOUBLE  dx,
DOUBLE  dy,
bool  bSnap
 

Move an item relative to its current position.

Parameters:
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

Definition at line 1272 of file grlayout.h.

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.

Definition at line 1263 of file grlayout.h.

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 SERIALIZER::ITEMDEF* GRAPHICLAYOUT::SerialGetItemDef SERIALIZER serializer  )  const [virtual]
 

Method for implementing SERIALIZABLE behaviour.

virtual const char* GRAPHICLAYOUT::SerialGetTagName  )  const [inline, virtual]
 

Method for implementing SERIALIZABLE behaviour.

Definition at line 1311 of file grlayout.h.

ERRVALUE GRAPHICLAYOUT::SerializerCB_Item SERIALIZER serializer,
const SERIALIZER::ITEMDEF itemdef,
void *  cbdata,
SERIALIZER::ITEMDEF::ACTION  action
[static, private]
 

ERRVALUE GRAPHICLAYOUT::SerializerCB_NamedTextStyle SERIALIZER serializer,
const SERIALIZER::ITEMDEF itemdef,
void *  cbdata,
SERIALIZER::ITEMDEF::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]
 

Definition at line 1327 of file grlayout.h.

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.

Definition at line 1336 of file grlayout.h.

void GRAPHICLAYOUT::SetDrawBackground bool  DrawBackground  )  [inline]
 

Control wether or not the background is filled.

Definition at line 1344 of file grlayout.h.

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.

Definition at line 1353 of file grlayout.h.

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.

Definition at line 1362 of file grlayout.h.

void GRAPHICLAYOUT::SetDropShadowColor const COLOR color  )  [inline]
 

Set the color for the drop shadow.

Definition at line 1370 of file grlayout.h.

void GRAPHICLAYOUT::SetDropShadowDirection double  angle  )  [inline]
 

Set the angle for the drop shadow (in radians).

GUI should provide intuitive way to set this.

Definition at line 1379 of file grlayout.h.

void GRAPHICLAYOUT::SetDropShadowDistance double  distance  )  [inline]
 

Set the distance for the drop shadow (in points).

GUI should provide intuitive way to set this.

Definition at line 1388 of file grlayout.h.

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

Definition at line 1403 of file grlayout.h.

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

Definition at line 1412 of file grlayout.h.

void GRAPHICLAYOUT::SetTextStyle int  num,
const NAMEDTEXTSTYLE style
 

Set a text style.

void GRAPHICLAYOUT::SetTextStyleName int  num,
const UNICODE name
[inline]
 

Set the name of a text style.

Definition at line 1433 of file grlayout.h.

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
 


Member Data Documentation

bool GRAPHICLAYOUT::m_bDrawBackground [private]
 

Definition at line 1505 of file grlayout.h.

bool GRAPHICLAYOUT::m_bDrawBorder [private]
 

Definition at line 1506 of file grlayout.h.

bool GRAPHICLAYOUT::m_bDrawDropShadow [private]
 

Definition at line 1507 of file grlayout.h.

COLOR GRAPHICLAYOUT::m_BGColor [private]
 

Definition at line 1509 of file grlayout.h.

bool GRAPHICLAYOUT::m_bLayoutNeeded [private]
 

Definition at line 1494 of file grlayout.h.

LINESTYLE GRAPHICLAYOUT::m_BorderStyle [private]
 

Definition at line 1504 of file grlayout.h.

bool GRAPHICLAYOUT::m_bRedrawNeeded [private]
 

Definition at line 1495 of file grlayout.h.

COLOR GRAPHICLAYOUT::m_DropShadowColor [private]
 

Definition at line 1508 of file grlayout.h.