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

mcEmptyBoxHelpers Class Reference

#include <EmptyBox.h>

Inheritance diagram for mcEmptyBoxHelpers:

Inheritance graph
[legend]
Collaboration diagram for mcEmptyBoxHelpers:

Collaboration graph
[legend]
List of all members.

Detailed Description

A little class containing the DATA, MATH, GUI and IO sections of this element (as instances and not pointers).

This is entirely defined & implemented through macros.

Definition at line 53 of file EmptyBox.h.

Public Member Functions

 mcDEFINE_REFERENCE_DATA (mcEmptyBox, mcET_EMPTYBOX)
 mcEmptyBoxHelpers ()
virtual ~mcEmptyBoxHelpers ()
bool io_isBeginTag (const wxXml2Node &tag) const
 Returns a positive value if the given MathML content tag marks the begin of this element; FALSE otherwise.
wxXml2Node io_GetMathML (bool bGetPresentation) const
 Returns the MathML code for this element as presentation markup (http://www.w3.org/TR/MathML2/chapter3.html) or as content markup (http://www.w3.org/TR/MathML2/chapter4.html).
wxString io_GetInlinedExpr () const
 Returns the inlined expression for this element as a wxString.
bool io_ImportPresentationMathML (wxXml2Node tag, wxString &pErr)
 Imports presentation MathML reading the contents of the given XML node (without modifying it).
mcDecoration overloaded functions
Implements the empty boxes' behaviours.

Even if the mcDecorationGUI class implements almost all mcElementGUI abstract functions, here we need to override some of them because they suppose two cursor positions for a decoration, while mcEmptyBox has one cursor position only...

bool gui_isBeginKey (const mcKey &key) const
 Always returns FALSE: empty boxes should be created by mcPolynomials only.
bool gui_isEndKey (const mcKey &key) const
 Always returns FALSE: mcEmptyBox::gui_Input function handles all the keypresses returning mcIR_DELETE_this-> Empty boxes infact, should always be replaced by a new class.
int gui_Draw (wxDC &dc, int x, int y, long flags, const wxPoint &pt) const
 element must be drawn with mcElementHelpers::sgui_m_pActivationBrush background brush; if this pointer is equal to mcDRW_NONACTIVE, the function must simply draw everything with default transparent mode; if the pointer is not one of the previous values, the function must use the pointer to find the subelement where it lies.
mcInputRes gui_Input (const mcKey &key, mcElement *pnew)
 This function is called when the cursor is inside the element and the user presses a key (which is not the element's end tag).
mcInsertRes gui_Insert (const mcElement &, mcElement *)
 Inserts the given element at the right of the cursor position.
mcMoveCursorRes gui_MoveCursor (mcMoveCursorFlag flag, long modifiers)
 This function is called to move the cursor which is inside the element, one 'step' left, right, up or down (when flag=mcMCF_LEFT/mcMCF_RIGHT/mcMCF_UP/mcMCF_DOWN).
int gui_MoveCursorUsingPoint (wxDC &dc, const wxPoint &p)
 Moves the cursor inside this element in the closest available position to the given point.
int gui_GetRelCursorPos (wxDC &dc, wxPoint *pt) 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.
void gui_DoRecalcSize ()
 This function is called by mcElement and non-mcElement functions when the internal size variable must be updated due to a change in the structure of the element.
void gui_SetCursorPos (const mcCursorPos &code)
 Sets the cursor position inside the element using Cursor Position flags.
void gui_GetCursorPos (mcCursorPos &p) const
 Returns the cursor position as Cursor Position flag.

Static Public Member Functions

static wxString io_GetInlinedExprTag ()
 Returns the string used to export mcEmptyBoxes in inlined expressions.

Static Public Attributes

static float sgui_fEmptyBoxCharWidth
 The width of an empty box in "character units".
static float sgui_fEmptyBoxCharHeight = 0.8f
 See mcEmptyBox::gui_m_fEmptyBoxCharWidth.
static wxBrush * sgui_pEmptyBoxBrush = NULL
 The brush used to draw the empty boxes.
static mcKeysgui_pNewEmptyBox = NULL
 The key to use to create this element.


Constructor & Destructor Documentation

mcEmptyBoxHelpers::mcEmptyBoxHelpers  )  [inline]
 

Definition at line 59 of file EmptyBox.h.

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

Definition at line 60 of file EmptyBox.h.


Member Function Documentation

void mcEmptyBoxHelpers::gui_DoRecalcSize  )  [virtual]
 

This function is called by mcElement and non-mcElement functions when the internal size variable must be updated due to a change in the structure of the element.

This function should be as fast and accurate as possible and it must store the new size in the mgui_sz variable.

Note:
It's very important, to maintain the size member updated, to call, in the other mcElement functions, gui_RecalcSize() every time size could have changed (for example, in gui_Input(), mcElementData setters...).

Implements mcElementHelpers.

Definition at line 103 of file EmptyBox.cpp.

References mcElementHelpers::gui_GetHeightOfChar(), mcElementHelpers::gui_GetWidthOfChar(), sgui_fEmptyBoxCharHeight, and sgui_fEmptyBoxCharWidth.

int mcEmptyBoxHelpers::gui_Draw wxDC &  dc,
int  x,
int  y,
long  flags,
const wxPoint &  pt
const [virtual]
 

element must be drawn with mcElementHelpers::sgui_m_pActivationBrush background brush; if this pointer is equal to mcDRW_NONACTIVE, the function must simply draw everything with default transparent mode; if the pointer is not one of the previous values, the function must use the pointer to find the subelement where it lies.

Then, only the subelement's gui_Draw() function must be called with the initial pointer. The subelements must be called with mcDRW_ALLACTIVE flag only for special reasons.

Returns:
The ID of the element marked as active (the element which is drawn with mcElementHelpers::sgui_m_pActivationBrush as background), or mcDRW_NOACTIVEELEM flag if this element does not contain the mouse cursor.

Implements mcElementHelpers.

Definition at line 194 of file EmptyBox.cpp.

References mcElementHelpers::data_GetID(), mcElementHelpers::gui_GetHeight(), mcElementHelpers::gui_GetWidth(), mcDRW_ALLACTIVE, mcDRW_NOACTIVEELEM, mcDRW_USEPOINT, and sgui_pEmptyBoxBrush.

void mcEmptyBoxHelpers::gui_GetCursorPos mcCursorPos p  )  const [inline, virtual]
 

Returns the cursor position as Cursor Position flag.

It must return mcCP_BEGIN if cursor is at the leftmost point of the element, mcCP_END if the cursor is at the rightmost point of the element, mcCP_INSIDE otherwise. When this function is called the cursor is always inside the element.

Reimplemented from mcDecorationHelpers.

Definition at line 127 of file EmptyBox.h.

References mcCP_BEGINEND.

int mcEmptyBoxHelpers::gui_GetRelCursorPos wxDC &  dc,
wxPoint *  pt
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 mcDecorationHelpers.

Definition at line 182 of file EmptyBox.cpp.

References mcElementHelpers::gui_GetHeight(), and mcElementHelpers::gui_GetWidth().

mcInputRes mcEmptyBoxHelpers::gui_Input const mcKey key,
mcElement pnew
[virtual]
 

This function is called when the cursor is inside the element and the user presses a key (which is not the element's end tag).

The way the element should process the given character is dependent to the element type: a mcNumber will insert vk next to the cursor position if vk is a digit. If vk is not acceptable, the function should call the MathCore error-handler function, mcMathCore::Get()->SyntaxError. This function should return one of the values defined for mcInputRes: mcIR_OKAY, mcIR_DELETE_THIS, mcIR_DIRECT_DELETE, mcIR_DELETE_NEXT.

Parameters:
ev The wxWidgets key event for the keypress. It contains the untraslated code for the input key; see wxWidgets KeyCodes for more info.
newelem If the function returns mcIR_REPLACE_THIS, the caller will use this pointer as a substitute for this element (which will be deleted).

Reimplemented from mcDecorationHelpers.

Definition at line 115 of file EmptyBox.cpp.

References mcElementHelpers::data_AddProperty(), mcElementHelpers::data_hasProperty(), mcElementHelpers::data_NewElem(), mcMathCore::Get(), mcElement::gui_Input(), mcElementHelpers::gui_RecalcSize(), mcMathCore::m_pCancelKey, mcKey::MatchKey(), mcEP_INITIALIZED, mcET_INVALID, mcIR_DIRECT_DELETE, mcIR_OKAY, mcIR_REPLACE_THIS, and mcMathCore::SyntaxError().

mcInsertRes mcEmptyBoxHelpers::gui_Insert const mcElement ,
mcElement
[virtual]
 

Inserts the given element at the right of the cursor position.

Reimplemented from mcDecorationHelpers.

Definition at line 155 of file EmptyBox.cpp.

References mcINSR_REPLACE_THIS.

bool mcEmptyBoxHelpers::gui_isBeginKey const mcKey key  )  const [inline, virtual]
 

Always returns FALSE: empty boxes should be created by mcPolynomials only.

Reimplemented from mcDecorationHelpers.

Definition at line 107 of file EmptyBox.h.

bool mcEmptyBoxHelpers::gui_isEndKey const mcKey key  )  const [virtual]
 

Always returns FALSE: mcEmptyBox::gui_Input function handles all the keypresses returning mcIR_DELETE_this-> Empty boxes infact, should always be replaced by a new class.

Reimplemented from mcDecorationHelpers.

Definition at line 83 of file EmptyBox.cpp.

References mcKey::GetKeyCode(), mcElementHelpers::gui_isKeyBeginKey(), mcET_ADDOP, mcET_PARENTHESIS, and mcET_SUBOP.

mcMoveCursorRes mcEmptyBoxHelpers::gui_MoveCursor mcMoveCursorFlag  flag,
long  modifiers
[virtual]
 

This function is called to move the cursor which is inside the element, one 'step' left, right, up or down (when flag=mcMCF_LEFT/mcMCF_RIGHT/mcMCF_UP/mcMCF_DOWN).

Elements which cannot move the cursor in the given direction, should call mcMathCore::Get()->SyntaxError() function. If the cursor must 'exit' the element (because its at the end, for example) the function must return mcMCR_SETFOCUS_PREVIOUS or mcMCR_SETFOCUS_NEXT. This function must always return the code mcMCR_SETFOCUS_* or mcMCR_OKAY. When this function is called, cursor is always inside the element.

Parameters:
flag One of the Move Cursor flags (see MathTypes.h)

Reimplemented from mcDecorationHelpers.

Definition at line 162 of file EmptyBox.cpp.

References mcMCF_DOWN, mcMCF_LEFT, mcMCF_RIGHT, mcMCF_UP, mcMCR_OKAY, mcMCR_SETFOCUS_ABOVE, mcMCR_SETFOCUS_BELOW, mcMCR_SETFOCUS_NEXT, and mcMCR_SETFOCUS_PREVIOUS.

int mcEmptyBoxHelpers::gui_MoveCursorUsingPoint wxDC &  dc,
const wxPoint &  p
[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 mcDecorationHelpers.

Definition at line 174 of file EmptyBox.cpp.

References mcMCR_OKAY.

void mcEmptyBoxHelpers::gui_SetCursorPos const mcCursorPos code  )  [inline, virtual]
 

Sets the cursor position inside the element using Cursor Position flags.

When it's called to set the cursor at the end of the base, code==mcCP_END and data_hasProperty(mcEP_HASEXPONENT) == FALSE, when it's called to set the cursor at the beginning of the base, code==mcCP_BEGIN. The function doesnt need to care for the third Cursor Position flag: mcCP_INSIDE, actually this function will never be called with this code.

Reimplemented from mcDecorationHelpers.

Definition at line 126 of file EmptyBox.h.

wxString mcEmptyBoxHelpers::io_GetInlinedExpr  )  const [virtual]
 

Returns the inlined expression for this element as a wxString.

"Inlined expression" means a math representation of the data in a single line: to allow such a restriction (everything must be on one text line), some standard conventions (and many brackets !!!) are used:

  • "^" introduces an exponent
  • "_" introduces a subscript Some examples of inlined expressions are: "4x^2+5a*sin(x/4)", "cos^2(PI/2)+ (123ax+b)/c >= 0", ....

Reimplemented from mcDecorationHelpers.

Definition at line 224 of file EmptyBox.cpp.

References io_GetInlinedExprTag().

static wxString mcEmptyBoxHelpers::io_GetInlinedExprTag  )  [inline, static]
 

Returns the string used to export mcEmptyBoxes in inlined expressions.

The string is always the same because empty boxes do not store any info inside them... so this function can be static.

Definition at line 148 of file EmptyBox.h.

Referenced by io_GetInlinedExpr().

wxXml2Node mcEmptyBoxHelpers::io_GetMathML bool  bGetPresentation  )  const [virtual]
 

Returns the MathML code for this element as presentation markup (http://www.w3.org/TR/MathML2/chapter3.html) or as content markup (http://www.w3.org/TR/MathML2/chapter4.html).

Parameters:
bGetPresentation TRUE if you want to get the presentation markup, FALSE if you want the content MathML.
Returns:
The XML tree containing the MathML code for this element.

Reimplemented from mcDecorationHelpers.

Definition at line 215 of file EmptyBox.cpp.

References mcUNUSED.

bool mcEmptyBoxHelpers::io_ImportPresentationMathML wxXml2Node  tag,
wxString &  pErr
[virtual]
 

Imports presentation MathML reading the contents of the given XML node (without modifying it).

This function is called only if io_isBeginTag function returns a positive value for the name of parent tag of pTag.

Parameters:
pTag The wxXML_***_NODE class to parse.
pErr The string where the error description is placed, if the function returns FALSE.
Returns:
TRUE on success (no mismatched or invalid tags).

Reimplemented from mcDecorationHelpers.

Definition at line 230 of file EmptyBox.cpp.

References mcASSERT.

bool mcEmptyBoxHelpers::io_isBeginTag const wxXml2Node &  tag  )  const [inline, virtual]
 

Returns a positive value if the given MathML content tag marks the begin of this element; FALSE otherwise.

The begin tag cannot be dependent from any variable; it must be always the same.

Parameters:
tag The string containing the TAG to test.
Returns:
A value identifying the subclass of this element that matched the given character; if the element has no subclasses it should return a null value when the given character is the begin character of the element. See MathCore::NewElem for more info

Reimplemented from mcDecorationHelpers.

Definition at line 139 of file EmptyBox.h.

mcEmptyBoxHelpers::mcDEFINE_REFERENCE_DATA mcEmptyBox  ,
mcET_EMPTYBOX 
 


Member Data Documentation

float mcEmptyBoxHelpers::sgui_fEmptyBoxCharHeight = 0.8f [static]
 

See mcEmptyBox::gui_m_fEmptyBoxCharWidth.

Definition at line 64 of file EmptyBox.cpp.

Referenced by gui_DoRecalcSize().

float mcEmptyBoxHelpers::sgui_fEmptyBoxCharWidth [static]
 

Initial value:




 2.0f
The width of an empty box in "character units".

To make this value work for all the styles, mcEmptyBoxGUI uses this value which is multiplied by GetCharWidth() to get the pixel width of an empty box; in this way empty boxes have the right size in each style.

Definition at line 58 of file EmptyBox.cpp.

Referenced by gui_DoRecalcSize().

wxBrush * mcEmptyBoxHelpers::sgui_pEmptyBoxBrush = NULL [static]
 

The brush used to draw the empty boxes.

Definition at line 65 of file EmptyBox.cpp.

Referenced by gui_Draw().

mcKey * mcEmptyBoxHelpers::sgui_pNewEmptyBox = NULL [static]
 

The key to use to create this element.

Definition at line 73 of file EmptyBox.cpp.


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

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

[ Top ]