#include <Operator.h>
Inheritance diagram for mcOperatorHelpers:
This is entirely defined & implemented through macros.
Definition at line 52 of file Operator.h.
OPERATORS SECTION | |
Declares class IDs functions and values used by the subclasses of mcOperator. | |
mcElementType | mdata_nType |
Class identifier (to avoid RTTI use); every derived class should set this variable to its specific #define in his constructor. | |
mcKey | kOpBeginChar [mcNUM_OPERATORS] |
The keys used by mcOperator to recognize the subclass to allocate when the user types an operator symbol. | |
static wxString | strOpSymbol [mcNUM_OPERATORS] = { wxT("+"), wxT("-"), wxT("*"), wxT("/:") } |
This little array is not placed in mcOperatorGUI because it is not related to the GUI system only: the entire mcOperator creation and destruction system uses this array. | |
Public Member Functions | |
mcOperatorHelpers () | |
virtual | ~mcOperatorHelpers () |
bool | data_isAllowedBefore (mcElementType type) const |
Operators are generally allowed only in some specific cases. | |
int | data_GetOpIndex () const |
wxString | data_GetOpSymbol () const |
void | data_DeepCopy (const mcElementHelpers *p) |
Deep copies all the info contained in this class. | |
mcRealValue | math_GetLenght () const |
All operators have a lenght/complexity of 1.5. | |
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. | |
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). | |
bool | io_ImportInlinedExpr (const wxString &, int *count, wxString &pErr) |
Imports an inlined expression. | |
mcElement overloaded functions | |
bool | gui_isBeginKey (const mcKey &ev) const |
Always returns FALSE: decorations generally are created by the program itself... | |
bool | gui_isEndKey (const mcKey &ev) 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. | |
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). | |
mcInputRes | gui_Input (const mcKey &ev, mcElement *newelem) |
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). | |
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_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. | |
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_GetCursorPos (mcCursorPos &p) const |
Returns the cursor position as Cursor Position flag. | |
void | gui_SetCursorPos (const mcCursorPos &) |
Sets the cursor position inside the element using Cursor Position flags. | |
bool | gui_LetInCursor (mcCursorPos code) |
Returns TRUE if this element can accept cursor (and then calls the gui_SetCursorPos() function with the given code) or FALSE if the element, for some reason, cannot accept cursor (in this case this element should be skipped). | |
wxSize | gui_GetRealSize () const |
Returns the real size of this operator. | |
mcOperator specific functions | |
Functions defined for mcOperators only. | |
virtual bool | math_CanBeApplied (const mcElement &l, const mcElement &r) const =0 |
Returns TRUE if this operator can be applied on the two given elements. | |
virtual mcBasicOpRes | math_Apply (mcElement &, const mcElement &, mcElement *) const =0 |
Applies this operator on the left and right monomials. | |
virtual mcBasicOpRes | math_ApplySimple (mcElement &, const mcElement &) const =0 |
Works like #Apply but uses the mcElement::math_SimpleAdd/Mult/Div functions and thus does not take the pointer-to-pointer argument. | |
virtual mcRealValue | math_Evaluate (mcRealValue val, mcRealValue val2) const =0 |
Applies the operator on the two given values and then returns it. | |
bool | math_Compare (const mcElement &p, long flags) const |
Compares *this element with the given one and then compare the children of *this and the children of the given element, too. | |
Static Public Member Functions | |
static int | data_GetOpIndex (mcElementType t) |
Returns the index in mcOperator arrays for the given operator type. | |
static wxString | data_GetOpSymbol (mcElementType t) |
Returns the symbol to use for the given operator type. | |
static bool | data_isOp (mcElementType t) |
Returns TRUE if the specified entry is an operator. | |
Protected Attributes | |
int | m_nPriority |
Priority level of this operator. Not used. | |
Static Protected Attributes | |
static wxSize | sgui_szReal [mcNUM_OPERATORS][mcELEMENTMATH_MAX_EXPDEPTH] |
Real size of this operator (m_sz is set to the maximum width and height found among all the operators). | |
static wxSize | sgui_sz [mcELEMENTMATH_MAX_EXPDEPTH] |
The maximum size. | |
static const mcStyleArray * | sgui_pLastStyle = NULL |
The style array used for last recalculation of the sgui_sz and sgui_szReal arrays. |
|
Definition at line 124 of file Operator.h. References mcET_INVALID. |
|
Definition at line 128 of file Operator.h. |
|
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 144 of file Operator.h. References mcDecorationHelpers::data_DeepCopy(), and mdata_nType. |
|
Returns the index in mcOperator arrays for the given operator type.
Definition at line 152 of file Operator.h. References mcASSERT, mcET_ADDOP, and mcET_INVALID. |
|
Definition at line 140 of file Operator.h. |
|
Returns the symbol to use for the given operator type.
Definition at line 158 of file Operator.h. References mcASSERT, and mcET_INVALID. |
|
Definition at line 141 of file Operator.h. Referenced by mcOperator::data_GetOpSymbol(), gui_Draw(), mcMultDivOpHelpers::gui_Draw(), gui_Input(), gui_isBeginKey(), mcMultDivOpHelpers::gui_isBeginKey(), io_GetInlinedExpr(), io_GetMathML(), io_ImportInlinedExpr(), io_ImportPresentationMathML(), and io_isBeginChar(). |
|
Operators are generally allowed only in some specific cases.
Reimplemented from mcElementHelpers. Definition at line 69 of file Operator.cpp. References data_isOp(). |
|
Returns TRUE if the specified entry is an operator.
Definition at line 164 of file Operator.h. References mcET_ADDOP, mcET_DIVOP, mcET_MULTOP, and mcET_SUBOP. Referenced by data_isAllowedBefore(), and mcElementArrayHelpers::data_isOp(). |
|
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.
Implements mcElementHelpers. Reimplemented in mcMultDivOpHelpers. Definition at line 82 of file Operator.cpp. References mcStyleArray::Get(), mcElementHelpers::gui_GetExpDepth(), mcElementHelpers::gui_GetHeightOf(), mcElementHelpers::gui_GetStyleArray(), mcElementHelpers::gui_GetWidthOf(), mcStyle::gui_Select(), mcELEMENTMATH_MAX_EXPDEPTH, mcGUILOG, mcMAX, mcNUM_OPERATORS, mcStyle::Set(), sgui_pLastStyle, sgui_sz, sgui_szReal, and strOpSymbol. Referenced by mcMultDivOpHelpers::gui_DoRecalcSize(). |
|
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.
Implements mcElementHelpers. Reimplemented in mcMultDivOpHelpers. Definition at line 123 of file Operator.cpp. References mcElementHelpers::data_GetID(), data_GetOpSymbol(), gui_GetRealSize(), mcElementHelpers::gui_SelectStyle(), mcGUILOG, and mcTXTTHIS. |
|
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 195 of file Operator.h. References mcCP_BEGINEND. |
|
Returns the real size of this operator. See sgui_szReal for more info. Definition at line 201 of file Operator.h. References mcET_ADDOP. Referenced by gui_Draw(), and mcMultDivOpHelpers::gui_Draw(). |
|
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.
Reimplemented from mcDecorationHelpers. Definition at line 177 of file Operator.cpp. References mcElementHelpers::gui_GetHeight(), and mcASSERT. |
|
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.
Reimplemented from mcDecorationHelpers. Definition at line 140 of file Operator.cpp. References data_GetOpSymbol(), mcElementHelpers::gui_RecalcSize(), mcASSERT, and mcIR_OKAY. |
|
Always returns FALSE: decorations generally are created by the program itself...
Reimplemented from mcDecorationHelpers. Reimplemented in mcMultDivOpHelpers. Definition at line 189 of file Operator.cpp. References data_GetOpSymbol(). Referenced by mcMultDivOpHelpers::gui_isBeginKey(). |
|
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 185 of file Operator.h. |
|
Returns TRUE if this element can accept cursor (and then calls the gui_SetCursorPos() function with the given code) or FALSE if the element, for some reason, cannot accept cursor (in this case this element should be skipped). The standard implementation returns TRUE and calls gui_SetCursorPos().
Reimplemented from mcElementHelpers. Definition at line 197 of file Operator.h. |
|
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.
Reimplemented from mcDecorationHelpers. Definition at line 155 of file Operator.cpp. References mcASSERT, and mcMCR_OKAY. |
|
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).
Reimplemented from mcDecorationHelpers. Definition at line 169 of file Operator.cpp. References mcASSERT, and mcMCR_OKAY. |
|
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 196 of file Operator.h. |
|
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:
Reimplemented from mcDecorationHelpers. Definition at line 234 of file Operator.cpp. References data_GetOpSymbol(). |
|
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).
Reimplemented from mcDecorationHelpers. Reimplemented in mcMultDivOpHelpers. Definition at line 228 of file Operator.cpp. References data_GetOpSymbol(). |
|
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
Reimplemented from mcDecorationHelpers. Definition at line 260 of file Operator.cpp. References data_GetOpSymbol(), and mcASSERT. |
|
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
Reimplemented from mcDecorationHelpers. Reimplemented in mcMultDivOpHelpers. Definition at line 239 of file Operator.cpp. References data_GetOpSymbol(), and mcASSERT. |
|
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 221 of file Operator.cpp. References data_GetOpSymbol(). |
|
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.
Reimplemented from mcDecorationHelpers. Definition at line 206 of file Operator.cpp. References mcNUM_OPERATORS, and strOpSymbol. |
|
Applies this operator on the left and right monomials.
Implemented in mcAddSubOpHelpers, and mcMultDivOpHelpers. Referenced by mcOperator::math_Apply(). |
|
Works like #Apply but uses the mcElement::math_SimpleAdd/Mult/Div functions and thus does not take the pointer-to-pointer argument.
Implemented in mcAddSubOpHelpers, and mcMultDivOpHelpers. Referenced by mcOperator::math_ApplySimple(). |
|
Returns TRUE if this operator can be applied on the two given elements. For non-commutative operators, the order is important: the first given pointer is the left operand while the second is the right one. Implemented in mcAddSubOpHelpers, and mcMultDivOpHelpers. Referenced by mcOperator::math_CanBeApplied(). |
|
Compares *this element with the given one and then compare the children of *this and the children of the given element, too. If they are the same, then the function returns TRUE; FALSE otherwise. This function is different from #math_hasSameContentOf() because it doesn't work on MaxSimply()ed copies. This function tipically uses the math_CompareThisOnly() function. Reimplemented from mcDecorationHelpers. Definition at line 240 of file Operator.h. |
|
Applies the operator on the two given values and then returns it.
Implemented in mcAddSubOpHelpers, and mcMultDivOpHelpers. |
|
All operators have a lenght/complexity of 1.5.
Reimplemented from mcDecorationHelpers. Definition at line 215 of file Operator.h. |
|
The keys used by mcOperator to recognize the subclass to allocate when the user types an operator symbol. See #MatchOpSymbol Definition at line 71 of file Operator.h. |
|
Priority level of this operator. Not used.
Definition at line 116 of file Operator.h. |
|
Class identifier (to avoid RTTI use); every derived class should set this variable to its specific #define in his constructor.
Definition at line 64 of file Operator.h. Referenced by data_DeepCopy(). |
|
The style array used for last recalculation of the sgui_sz and sgui_szReal arrays.
Definition at line 60 of file Operator.cpp. Referenced by gui_DoRecalcSize(). |
|
The maximum size.
Definition at line 59 of file Operator.cpp. Referenced by gui_DoRecalcSize(). |
|
Real size of this operator (m_sz is set to the maximum width and height found among all the operators). This member is static since it can be safely shared among all the operators instances. It is updated in the gui_DoRecalcSize() calls only if the style used for drawing operators has changed since last recalculation (and sgui_pLastStyle is used for this). Definition at line 58 of file Operator.cpp. Referenced by gui_DoRecalcSize(). |
|
This little array is not placed in mcOperatorGUI because it is not related to the GUI system only: the entire mcOperator creation and destruction system uses this array.
Definition at line 57 of file Operator.cpp. Referenced by gui_DoRecalcSize(), and io_isBeginTag(). |
[ Top ] |