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

mcParenthesisHelpers Class Reference

#include <Parenthesis.h>

Inheritance diagram for mcParenthesisHelpers:

Inheritance graph
[legend]
Collaboration diagram for mcParenthesisHelpers:

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 59 of file Parenthesis.h.

Public Member Functions

 mcParenthesisHelpers ()
virtual ~mcParenthesisHelpers ()
void data_DeepCopy (const mcElementHelpers *p)
 Deep copies all the info contained in this class.
bool data_isLeftBracket () const
 Returns the #m_bLeftBracket value.
wxString data_GetSymbol () const
 Returns the wxT("(") symbol if m_bLeftBracket == TRUE, ")" otherwise.
void data_SetAsLeftBracket ()
void data_SetAsRightBracket ()
void data_OnNeighborChange ()
 Called by parent when neighbors change.
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.
bool io_isBeginChar (const wxString &str) const
 Returns a positive value if the given inlined expression marks the begin of this element; FALSE otherwise.
bool io_ImportPresentationMathML (wxXml2Node tag, wxString &pErr)
 Imports presentation MathML reading the contents of the given XML node (without modifying it).
bool io_ImportInlinedExpr (const wxString &str, int *count, wxString &pErr)
 Imports an inlined expression.
wxString io_GetInlinedExpr ()
mcElementGUI abstract functions.
Some of the functions which are provided by mcDecorationGUI must be overloaded...

bool gui_isBeginKey (const mcKey &ev) const
 Always returns FALSE: decorations generally are created by the program itself...
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).
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.

Public Attributes

mcPolynomial mdata_pTmpExp
 The exponent is temporary stored in a mcParenthesis if it is required to keep it somewhere before creating a mcBracket.

Protected Member Functions

bool gui_SearchInMonomial (mcMonomial &m, int *h, bool left, int idx)
int gui_GetMaxHeightToNextBracket (bool left)
void gui_RebuildFont ()

Protected Attributes

bool mdata_bLeftBracket
 If TRUE, this class represents a left parenthesis; otherwise it is a right one.
wxFont mgui_fLastFont
 Font used to draw the parentheses (it's updated each time the content changes its height).

Private Member Functions

 mcDEFINE_REFERENCE_DATA (mcParenthesis, mcET_PARENTHESIS)


Constructor & Destructor Documentation

mcParenthesisHelpers::mcParenthesisHelpers  )  [inline]
 

Definition at line 83 of file Parenthesis.h.

References mcEP_NOTIFY_NEIGHBOR_CHANGE.

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

Definition at line 89 of file Parenthesis.h.


Member Function Documentation

void mcParenthesisHelpers::data_DeepCopy const mcElementHelpers p  )  [inline, virtual]
 

Deep copies all the info contained in this class.

The mcElement implementation should be enough because all the element's data should be contained inside the associated mcElementData derived class. In fact, mcElementData does not provide a standard implementation of the DeepCopy() function. mcElement-derived classes, instead, should not contain any other variable, so this function should be enough....

Reimplemented from mcDecorationHelpers.

Definition at line 105 of file Parenthesis.h.

References mcDecorationHelpers::data_DeepCopy(), mcElement::data_DeepCopy(), mdata_bLeftBracket, and mdata_pTmpExp.

wxString mcParenthesisHelpers::data_GetSymbol  )  const [inline]
 

Returns the wxT("(") symbol if m_bLeftBracket == TRUE, ")" otherwise.

This function differs from mcParenthesis::gui_GetSymbol() because the latter can return also wxT("["), wxT("{") or wxT("]"), "}"....

Definition at line 120 of file Parenthesis.h.

Referenced by gui_DoRecalcSize(), and gui_Draw().

bool mcParenthesisHelpers::data_isLeftBracket  )  const [inline]
 

Returns the #m_bLeftBracket value.

Definition at line 113 of file Parenthesis.h.

Referenced by gui_RebuildFont(), and gui_SearchInMonomial().

void mcParenthesisHelpers::data_OnNeighborChange  )  [virtual]
 

Called by parent when neighbors change.

Override this function if you need to do something when neighbor elements change (remember to set up the flag mcEP_NOTIFY_NEIGHBOR_CHANGE in the constructor).

Reimplemented from mcElementHelpers.

Definition at line 65 of file Parenthesis.cpp.

References gui_RebuildFont().

void mcParenthesisHelpers::data_SetAsLeftBracket  )  [inline]
 

Definition at line 124 of file Parenthesis.h.

void mcParenthesisHelpers::data_SetAsRightBracket  )  [inline]
 

Definition at line 125 of file Parenthesis.h.

void mcParenthesisHelpers::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 76 of file Parenthesis.cpp.

References data_GetSymbol(), mcElementHelpers::gui_GetSizeOf(), and mgui_fLastFont.

int mcParenthesisHelpers::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 113 of file Parenthesis.cpp.

References mcElementHelpers::data_GetID(), data_GetSymbol(), mcElement::data_GetType(), mcElementHelpers::gui_GetHeight(), mcElementHelpers::gui_GetWidth(), mcElementHelpers::gui_SelectStyle(), mcET_MONOMIAL, and mgui_fLastFont.

int mcParenthesisHelpers::gui_GetMaxHeightToNextBracket bool  left  )  [protected]
 

Definition at line 209 of file Parenthesis.cpp.

Referenced by gui_RebuildFont().

mcInputRes mcParenthesisHelpers::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 140 of file Parenthesis.cpp.

References mcElementHelpers::data_AddProperty(), mcElementHelpers::data_hasProperty(), mcDecorationHelpers::gui_Input(), mcElementHelpers::gui_RecalcSize(), mcASSERT, mcEP_INITIALIZED, and mdata_bLeftBracket.

bool mcParenthesisHelpers::gui_isBeginKey const mcKey ev  )  const [inline, virtual]
 

Always returns FALSE: decorations generally are created by the program itself...

Reimplemented from mcDecorationHelpers.

Definition at line 155 of file Parenthesis.h.

void mcParenthesisHelpers::gui_RebuildFont  )  [protected]
 

Definition at line 89 of file Parenthesis.cpp.

References data_isLeftBracket(), mcElementHelpers::gui_GetHeightOfChar(), gui_GetMaxHeightToNextBracket(), mcBracketHelpers::gui_RebuildFont(), mcElementHelpers::gui_RecalcSize(), mcMAX, and mgui_fLastFont.

Referenced by data_OnNeighborChange().

bool mcParenthesisHelpers::gui_SearchInMonomial mcMonomial m,
int *  h,
bool  left,
int  idx
[protected]
 

Definition at line 256 of file Parenthesis.cpp.

References data_isLeftBracket(), END_ARRAY_SCAN, mcET_PARENTHESIS, mcMAX, and START_ARRAY_SCAN.

wxString mcParenthesisHelpers::io_GetInlinedExpr  )  [inline]
 

Definition at line 185 of file Parenthesis.h.

bool mcParenthesisHelpers::io_ImportInlinedExpr const wxString &  str,
int *  count,
wxString &  pErr
[virtual]
 

Imports an inlined expression.

"Inlined expression" means a string containing an encoded representation of math data: 234^2*ax+6y/2=0 is an inlined expression. This is the form which is used to input and output math data by a lot of math programs. Compability with these programs is crucial. However, because of the nature of this representation, the algorithm which recognizes (through io_isBeginChar functions) the elements to create, needs to know the lenght of the token which encodes this element; this is accomplished with the count parameter which must *absolutely* be set by this function.

Parameters:
str The string containing the inlined expression to import.
count A pointer where is stored the number of characters of str imported by this function.
pErr The string where the error description is placed, if the function returns FALSE.
Returns:
TRUE on success: the first (and eventually the following) characters of the given string represent an encoded inline expression of this element and they were successfully recognized and imported.

Reimplemented from mcDecorationHelpers.

Definition at line 305 of file Parenthesis.cpp.

References mcElementArray::data_DeleteAll(), mcExpElementHelpers::io_GetExpSubInlinedToken(), mcElement::io_ImportInlinedExpr(), mcASSERT, mdata_bLeftBracket, and mdata_pTmpExp.

bool mcParenthesisHelpers::io_ImportPresentationMathML wxXml2Node  tag,
wxString &  pErr
[inline, 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 182 of file Parenthesis.h.

bool mcParenthesisHelpers::io_isBeginChar const wxString &  str  )  const [virtual]
 

Returns a positive value if the given inlined expression marks the begin of this element; FALSE otherwise.

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

Reimplemented from mcDecorationHelpers.

Definition at line 291 of file Parenthesis.cpp.

bool mcParenthesisHelpers::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 179 of file Parenthesis.h.

mcParenthesisHelpers::mcDEFINE_REFERENCE_DATA mcParenthesis  ,
mcET_PARENTHESIS 
[private]
 


Member Data Documentation

bool mcParenthesisHelpers::mdata_bLeftBracket [protected]
 

If TRUE, this class represents a left parenthesis; otherwise it is a right one.

Definition at line 68 of file Parenthesis.h.

Referenced by data_DeepCopy(), gui_Input(), and io_ImportInlinedExpr().

mcPolynomial mcParenthesisHelpers::mdata_pTmpExp
 

The exponent is temporary stored in a mcParenthesis if it is required to keep it somewhere before creating a mcBracket.

Definition at line 75 of file Parenthesis.h.

Referenced by data_DeepCopy(), and io_ImportInlinedExpr().

wxFont mcParenthesisHelpers::mgui_fLastFont [protected]
 

Font used to draw the parentheses (it's updated each time the content changes its height).

Definition at line 140 of file Parenthesis.h.

Referenced by gui_DoRecalcSize(), gui_Draw(), and gui_RebuildFont().


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

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

[ Top ]