Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

mcMathLineHelpers Class Reference

#include <MathLine.h>

Inheritance diagram for mcMathLineHelpers:

Inheritance graph
[legend]
Collaboration diagram for mcMathLineHelpers:

Collaboration graph
[legend]
List of all members.

Detailed Description

This class is basically a wrapper for a mcMathMng and a bitmap object; it adds to mcMathMng a new feature: the ability to store in a bitmap the most updated output of the math object for fast redraws (and this is very important because a lot of redraws are necessary: for cursor flashing, selection\activation state changes and so on....).

Todo:
Besides, the ability to use a bitmap for the output, also gives mcMathLineHelpers the new feature of "equation wrap": when an equation is too long, mcMathLineHelpers can break it up in various pieces...

Definition at line 148 of file MathLine.h.

Public Member Functions

 mcMathLineHelpers ()
 Constructor of the structure.
virtual ~mcMathLineHelpers ()
void gui_Init ()
 Inits the GUI variables of this class.
void data_DeepCopy (const mcElementHelpers *mbl)
 Deep copy this object in the given pointer.
Double buffering functions
The functions which handle double buffering system for better GUI performances.

int gui_UpdateBmp (int x, int y, long flags, const wxPoint &p)
 Updates the bitmap in the mcMathLineHelpers structure, calling the mcMathMng::gui_Draw function.
int gui_DrawBmp (wxDC &dc, int x, int y) const
 Draws this line on the given DC using the bitmap.
void gui_SetMask (const wxColour &)
 Sets the given colour as the mask which will be used when blitting the bitmap in the given DC in a gui_DrawBmp call.
int gui_ForceBmpUpdate (int x, int y, long flags, const wxPoint &p)
 Forces the update of the internal bitmap used for double buffering.
bool gui_NeedsRefresh () const
 Returns TRUE if with the last call to gui_UpdateBmp or gui_ForceBmpUpdate, a redraw is required to keep the output up to date.
void gui_SetBmpBackgroundBrush (const wxBrush &br)
 Changes the brush used to clear the bitmap.
void gui_ExpandBmp ()
 Expands line's bitmap if it's too small.
bool gui_isIDChanged () const
 Returns TRUE if the ID of the active element has changed between the last two calls to the gui_Draw() function of the math object.
int gui_GetActiveElemID () const
 Returns the ID of the currently active element.
mcElement GUI overloaded functions
mcMathLine needs to modify some mcMathMng GUI behaviour to adjust coordinates and to keep bitmap's size right for this element.

mcElement gui_GetSelection () const
 Returns the selected portion of this math data.
int gui_GetRelCursorPos (wxDC &dc, wxPoint *) const
 Returns the height of the cursor and the (x;y) position of the cursor (in the given pointer) relative to the top-left point of this element.
int gui_MoveCursorUsingPoint (wxDC &, const wxPoint &)
 Moves the cursor inside this element in the closest available position to the given point.
void gui_OnSelect (wxDC &dc, wxRect &)
 This function is called when the bounding box of this element intersects with the selection rectangle created by the user with the mouse cursor.
void gui_DoRecalcSize ()
 This is the most important overload of mcMathLine.

Static Public Attributes

static int sgui_nCursorWidth = 2
 The width of the cursor.

Protected Attributes

wxBitmap mgui_bmpMath
 Last rendering of this line (without cursor, activation state, selection state).
wxBrush mgui_brushBmpBg
 The brush used to clear the bitmap before each update.
bool mgui_bUsingMask
 TRUE if we are using a mask when blitting the bitmap.
int mgui_nLastID
 The ID of the active element before last redraw.
int mgui_nCurrentID
 The ID of the current active element.


Constructor & Destructor Documentation

mcMathLineHelpers::mcMathLineHelpers  )  [inline]
 

Constructor of the structure.

Automatically calls the mcMathMng::Init() function and automatically creates the bitmap used to hold the last rendering of the math obj.

Definition at line 188 of file MathLine.h.

References mcMathMngHelpers::data_Init().

virtual mcMathLineHelpers::~mcMathLineHelpers  )  [inline, virtual]
 

Definition at line 189 of file MathLine.h.


Member Function Documentation

void mcMathLineHelpers::data_DeepCopy const mcElementHelpers mbl  )  [virtual]
 

Deep copy this object in the given pointer.

Reimplemented from mcMathMngHelpers.

Definition at line 101 of file MathLine.cpp.

References mcMathMngHelpers::data_DeepCopy(), gui_ExpandBmp(), mgui_brushBmpBg, mgui_bUsingMask, mgui_nCurrentID, and mgui_nLastID.

void mcMathLineHelpers::gui_DoRecalcSize  )  [virtual]
 

This is the most important overload of mcMathLine.

This is the function infact, which calls gui_ExpandBmp() which is a very important thing to do to keep the double buffering system active.

Reimplemented from mcMathMngHelpers.

Definition at line 278 of file MathLine.cpp.

References mcMathMngHelpers::gui_DoRecalcSize(), gui_ExpandBmp(), mcBMP_SPACELEFT, and mcBMP_SPACERIGHT.

int mcMathLineHelpers::gui_DrawBmp wxDC &  dc,
int  x,
int  y
const [virtual]
 

Draws this line on the given DC using the bitmap.

Parameters:
dc The DC where the line will be drawn
memDC The memory DC to use to blit the bitmap
x The x-coord. where the line will be drawn
y The y-coord. where the line will be drawn
Returns:
The ID of the element currently under mouse cursor.

Implements mcDoubleBufferedElement.

Definition at line 176 of file MathLine.cpp.

References mcMathMngHelpers::gui_Draw(), mcElementHelpers::gui_GetHeight(), mcElementHelpers::gui_GetWidth(), mgui_bmpMath, mgui_bUsingMask, and mgui_nCurrentID.

Referenced by mcMathLine::gui_DrawBmp().

void mcMathLineHelpers::gui_ExpandBmp  ) 
 

Expands line's bitmap if it's too small.

Use this function to expand the bitmap size at least to the math object size; if the given size is smaller than bmp size, nothing is done; if the bitmap size is updated, previous contents of the bitmap are lost. This function is automatically called when size changes.

Definition at line 224 of file MathLine.cpp.

References mcElementHelpers::gui_GetHeight(), mcElementHelpers::gui_GetWidth(), mcASSERT, mcBMP_ADDEDHEIGHT, mcBMP_ADDEDWIDTH, and mgui_bmpMath.

Referenced by data_DeepCopy(), gui_DoRecalcSize(), and gui_Init().

int mcMathLineHelpers::gui_ForceBmpUpdate int  x,
int  y,
long  flags,
const wxPoint &  p
[inline, virtual]
 

Forces the update of the internal bitmap used for double buffering.

All the parameters are the same of the gui_UpdateBmp function.

Implements mcDoubleBufferedElement.

Definition at line 226 of file MathLine.h.

References gui_UpdateBmp().

Referenced by mcMathLine::gui_ForceBmpUpdate().

int mcMathLineHelpers::gui_GetActiveElemID  )  const [inline]
 

Returns the ID of the currently active element.

Definition at line 253 of file MathLine.h.

References mgui_nCurrentID.

Referenced by mcMathLine::gui_GetActiveElemID().

int mcMathLineHelpers::gui_GetRelCursorPos wxDC &  dc,
wxPoint * 
const [virtual]
 

Returns the height of the cursor and the (x;y) position of the cursor (in the given pointer) relative to the top-left point of this element.

The function must fill the wxPoint pointer using coordinates relative to the top-left point of its bounding rectangle. When this function is called, the cursor is always inside the element.

Parameters:
dc The device context where the element was drawn last time.
pt The coordinates, relative to the element (assume the element placed at 0;0), indicating the top-left point of the cursor.

Reimplemented from mcMathMngHelpers.

Definition at line 212 of file MathLine.cpp.

References mcElementHelpers::gui_GetHeight(), mcMathMngHelpers::gui_GetRelCursorPos(), and mcBMP_SPACELEFT.

mcElement mcMathLineHelpers::gui_GetSelection  )  const [virtual]
 

Returns the selected portion of this math data.

The returned object maybe mcEmptyElement if nothing is selected in none of the two members.

Reimplemented from mcMathMngHelpers.

Definition at line 270 of file MathLine.cpp.

void mcMathLineHelpers::gui_Init  )  [virtual]
 

Inits the GUI variables of this class.

Reimplemented from mcMathMngHelpers.

Definition at line 124 of file MathLine.cpp.

References gui_ExpandBmp(), mcMathMngHelpers::gui_Init(), mcBMP_SPACELEFT, mcBMP_SPACERIGHT, mcBMP_STDHEIGHT, mcBMP_STDWIDTH, mgui_bmpMath, mgui_brushBmpBg, mgui_bUsingMask, mgui_nCurrentID, and mgui_nLastID.

bool mcMathLineHelpers::gui_isIDChanged  )  const [inline]
 

Returns TRUE if the ID of the active element has changed between the last two calls to the gui_Draw() function of the math object.

Definition at line 248 of file MathLine.h.

References mgui_nCurrentID, and mgui_nLastID.

Referenced by mcMathLine::gui_isIDChanged(), and gui_NeedsRefresh().

int mcMathLineHelpers::gui_MoveCursorUsingPoint wxDC &  ,
const wxPoint & 
[virtual]
 

Moves the cursor inside this element in the closest available position to the given point.

The function must use the given point to set its internal cursor-position variables (when this function is called, the given point is always inside the bounding rectangle of the element, but maybe the cursor is not).

Parameters:
dc The device context where the element was drawn last time
p a valid pointer to a wxPoint (containing coord. relative to the top-left point of the element) which must be used to find the selected subelement; otherwise this is a NULL value

Reimplemented from mcMathMngHelpers.

Definition at line 254 of file MathLine.cpp.

References mcMathMngHelpers::gui_MoveCursorUsingPoint(), and mcBMP_SPACELEFT.

bool mcMathLineHelpers::gui_NeedsRefresh  )  const [inline, virtual]
 

Returns TRUE if with the last call to gui_UpdateBmp or gui_ForceBmpUpdate, a redraw is required to keep the output up to date.

Implements mcDoubleBufferedElement.

Definition at line 229 of file MathLine.h.

References gui_isIDChanged().

void mcMathLineHelpers::gui_OnSelect wxDC &  dc,
wxRect &  rc
[virtual]
 

This function is called when the bounding box of this element intersects with the selection rectangle created by the user with the mouse cursor.

The standard implementation just selects this element. If you are implementing a container element, you must override this function and check contained elements' bounding boxes and then call the gui_OnSelect() function of the contained elements whose bounding boxes intersect the given selection rectangle.

Reimplemented from mcMathMngHelpers.

Definition at line 262 of file MathLine.cpp.

References mcMathMngHelpers::gui_OnSelect(), and mcBMP_SPACELEFT.

void mcMathLineHelpers::gui_SetBmpBackgroundBrush const wxBrush &  br  )  [inline, virtual]
 

Changes the brush used to clear the bitmap.

No updates are done after the change since this could clear out the current active element. It's caller's duty to call the gui_ForceBmpUpdate function with the right parameters.

Implements mcDoubleBufferedElement.

Definition at line 236 of file MathLine.h.

References mgui_brushBmpBg.

void mcMathLineHelpers::gui_SetMask const wxColour &   )  [virtual]
 

Sets the given colour as the mask which will be used when blitting the bitmap in the given DC in a gui_DrawBmp call.

Implements mcDoubleBufferedElement.

Definition at line 203 of file MathLine.cpp.

References mgui_bmpMath, and mgui_bUsingMask.

int mcMathLineHelpers::gui_UpdateBmp int  x,
int  y,
long  flags,
const wxPoint &  p
[virtual]
 

Updates the bitmap in the mcMathLineHelpers structure, calling the mcMathMng::gui_Draw function.

Parameters:
memDC The memory DC to use as temporary DC (performance optimization: instead creating each time a new memory DC, allocate one once and then reuse it on each call to data_UpdateLineBmp).
x,y The position where this line is drawn.
p The mouse cursor position (in line coord.) or mcDRW_NONACTIVE, mcDRW_ALLACTIVE flags.
Returns:
The ID of the active element

Implements mcDoubleBufferedElement.

Definition at line 142 of file MathLine.cpp.

References mcMathMngHelpers::gui_Draw(), mcBMP_SPACELEFT, mcDRW_ALLACTIVE, mcDRW_NONACTIVE, mcDRW_USEPOINT, mgui_bmpMath, mgui_brushBmpBg, mgui_nCurrentID, and mgui_nLastID.

Referenced by gui_ForceBmpUpdate(), and mcMathLine::gui_UpdateBmp().


Member Data Documentation

wxBitmap mcMathLineHelpers::mgui_bmpMath [protected]
 

Last rendering of this line (without cursor, activation state, selection state).

Cannot use wxImage because of the high number of conversions between wxImage and wxBitmap that would be necessary.

Definition at line 163 of file MathLine.h.

Referenced by gui_DrawBmp(), gui_ExpandBmp(), gui_Init(), gui_SetMask(), and gui_UpdateBmp().

wxBrush mcMathLineHelpers::mgui_brushBmpBg [protected]
 

The brush used to clear the bitmap before each update.

Definition at line 166 of file MathLine.h.

Referenced by data_DeepCopy(), gui_Init(), gui_SetBmpBackgroundBrush(), and gui_UpdateBmp().

bool mcMathLineHelpers::mgui_bUsingMask [protected]
 

TRUE if we are using a mask when blitting the bitmap.

Definition at line 169 of file MathLine.h.

Referenced by data_DeepCopy(), gui_DrawBmp(), gui_Init(), and gui_SetMask().

int mcMathLineHelpers::mgui_nCurrentID [protected]
 

The ID of the current active element.

Definition at line 175 of file MathLine.h.

Referenced by data_DeepCopy(), gui_DrawBmp(), gui_GetActiveElemID(), gui_Init(), gui_isIDChanged(), and gui_UpdateBmp().

int mcMathLineHelpers::mgui_nLastID [protected]
 

The ID of the active element before last redraw.

Definition at line 172 of file MathLine.h.

Referenced by data_DeepCopy(), gui_Init(), gui_isIDChanged(), and gui_UpdateBmp().

int mcMathLineHelpers::sgui_nCursorWidth = 2 [static]
 

The width of the cursor.

This variable is used only to set the width of the rectangle returned by the gui_GetCursorPos() function.

Definition at line 53 of file MathLine.cpp.


The documentation for this class was generated from the following files:

Documentation generated with Doxygen on Sun Feb 6 17:12:47 2005
Visit MathStudio home page for more info

[ Top ]