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

mcElementHelpers Class Reference

#include <Element.h>

Inheritance diagram for mcElementHelpers:

Inheritance graph
[legend]
Collaboration diagram for mcElementHelpers:

Collaboration graph
[legend]
List of all members.

Detailed Description

A little class which contains all the data referenced by a mcElement.

This is the base class for the specialized classes containing the instances of their helper mcElementData-, mcElementGUI-, mcElementMath- mcElementIO-derived classes. mcElement-derived do not contain pointers to allocated classes: in this way we would have an enormous number of allocations: 1 due to mcElement + 4 due to helper classes (data, gui, math, io).

Definition at line 116 of file Element.h.

Math engine handy functions.

Virtual functions implemented using the abstract mcElementMath functions.

virtual mcExpSimRes math_MaxSimplify (long flags)
 Completely simplifies this element.
virtual bool math_isMaxSimplified (long flags) const
 Returns TRUE if the element is completely simplified; FALSE if calls to math_Simplify(long flags) will make changes to the element.
virtual int math_GetSymbolList (mcSymbol **, int size, const mcSymbol &tofind) const
 Returns the number of symbols identic to the one given (uses #math_CompareWith to perform comparison) and place a pointer to each symbol in the given array of pointers of size 'size'.
virtual int math_GetSymbolList (mcSymbol **, int size, mcSymbolProperties &tofind) const
virtual bool math_isConstant () const
 Returns TRUE if this element contains mcSymbol registered as constants and/or mcNumbers only.
virtual bool math_EvaluatesTo (const mcRealValue &val) const
 Returns TRUE if this element can be evaluated (see math_Evaluate()) and its value matches the given one.
virtual mcRealValue math_EvaluateAt (const mcSymbolProperties *sym, const mcRealValue &symval) const
 Returns the result of the math_Evaluate function called on a copy of this element with the given symbol substituted by the given value.
virtual bool math_isFinite () const
 Returns TRUE if this element evaluates to a finite value; returns FALSE if this element could not be evaluated (result is NAN) or this element evaluates to a infinite value.
virtual mcRealValue math_GetTotalLenght () const
 Returns the lenght of this element, taking in count also the children.
virtual void math_SimpleAdd (const mcElement &p, bool add=TRUE)
 Adds the given element to this element using the math_Add() function and then checking that the return value is mcBOR_REMOVE_OPERAND: that is, the operation was completed successfully and *this now contains the result of the operation.
virtual void math_SimpleSubtract (const mcElement &p)
virtual void math_SimpleMultiplyBy (const mcElement &p)
virtual void math_SimpleDivideBy (const mcElement &p)
void math_SimpleRaiseTo (const mcPolynomial &)
 Raises this element to the given mcPolynomial, checking that the return value is mcBOR_REMOVE_OPERAND.
bool math_isValidMath () const
 Returns TRUE if *this element is math consistent, that is, it is not a mcParenthesis or a mcEmptyBox and it does not contain invalid math elements (this function is recursive).
virtual bool math_isListedBeforeOf (const mcElement &p) const
 Returns TRUE if *this should be put before the given element in an ordered math list: this function is used by mcElementArray-derived classes to reorder their elements.
static bool math_isExpAllowed (mcElement p)
 Use the following function to check if the given element can allocate an exponent.
static bool math_isSubAllowed (mcElement p)

Public Member Functions

 mcElementHelpers ()
 Default constructor.
virtual ~mcElementHelpers ()
virtual bool io_Init (const wxString &str)
 Inits this element with the given INLINED expression; for more info about inlined expressions, see the mcElement::io_ImportInlinedExpr function.
Properties control functions
See the previous section for more info about properties.

virtual void data_AddProperty (int p, void *val1=NULL, void *val2=NULL)
 Adds the given property to this element.
virtual void data_RemoveProperty (int p)
 Removes the given property to this element.
virtual bool data_hasProperty (int p) const
 Returns TRUE if this element has the given property set.
Recursive properties control functions
See the previous section for more info about properties.

virtual void data_AddRecursiveProperty (mcElementType t, int p, void *val1=NULL, void *val2=NULL)
 math_Adds the given property to this element.
virtual void data_RemoveRecursiveProperty (mcElementType t, int p)
 Removes the given property to this element.
virtual bool data_hasRecursiveProperty (mcElementType t, int p) const
 Returns TRUE if this element has the given property set.
Abstract general functions
Functions which must be implemented in derived classes.

virtual mcElementHelpersdata_Clone () const =0
 Returns a pointer to a new object identical to the current element.
virtual int data_GetMemoryInfo () const =0
 Returns the size of this class and all its helper classes calculated using the sizeof() operator.
virtual mcElementType data_GetType () const =0
 Returns the identifier code for this class.
Standard methods (overridables)
Override only if necessary.

virtual void data_DeepCopy (const mcElementHelpers *p)
 Deep copies all the info contained in this class.
virtual bool data_isSameAs (const mcElementHelpers *) const
 Performs a deep comparison of the data hold by this class and the data hold by the given mcElementHelpers object.
virtual bool data_isAllowedBefore (mcElementType type) const
 Returns TRUE if this element is allowed to be directly on the left of the given element type.
virtual bool data_isAllowedAfter (mcElementType type) const
 Returns TRUE if this element is allows to be placed directly on the right of the given element type.
virtual mcElementdata_GetElemFromID (int id) const
 Returns the element with the given ID.
virtual void data_OnNeighborChange ()
 Called by parent when neighbors change.
virtual void data_Update ()
 Updates this element and all its children (recursive function).
wxString data_Debug (long) const
 Returns simple info about this element.
wxString data_GetDebugName () const
Functions which MUST be overridden by container classes
Functions which _MUST_ be overridden by container classes to ensure a correct behaviour of the element.

wxString data_Check () const
 Does some standard checks on the element integrity.
virtual int data_GetChildrenCount () const
 Returns the number of children attached to this tree node.
virtual const mcElementdata_GetConstChild (int n) const
 Returns the n-th tree node attached to this element.
virtual mcElementdata_GetChild (int n)
 Like data_GetConstChild, but this function returns a non-const pointer.
virtual void data_SetChild (int idx, const mcElement &newchild)
 math_Replaces the idx-th child of this element with a copy of the given one.
virtual int data_GetChildIdx (const mcElement &p) const
 Returns the index of the children which is allocated in the given memory address.
virtual bool data_AddChildrenTo (mcElement p)
 Tries to attach the children of *this to the given element, respecting the math meaning of each one.
Standard methods (not overridables)
You just cannot override these functions...

int data_GetID () const
 Returns the ID for this element.
void data_Init ()
 Inits this class calling the gui_Init, math_Init and io_Init functions, if required.
wxString data_GetDebug (int, long) const
 Returns more complete debug information about this element (using the data_Debug function).
mcElement univocal begin and end characters
The characters that univocally defines the beginning and the ending of this element.

virtual bool gui_isBeginKey (const mcKey &ev) const =0
 Returns a positive value if the given character marks the begin of this element; FALSE otherwise.
virtual bool gui_isEndKey (const mcKey &ev) const =0
 Returns TRUE if the given character marks the end of this element; this function is always called before calling ::gui_Input function.
Pure virtual functions
Functions which must be implemented in the derived classes.

virtual int gui_Draw (wxDC &dc, int x, int y, long flags, const wxPoint &pt) const =0
 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.
virtual void gui_DoRecalcSize ()=0
 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.
virtual int gui_GetRelCursorPos (wxDC &dc, wxPoint *pt) const =0
 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.
virtual mcMoveCursorRes gui_MoveCursor (mcMoveCursorFlag flag, long modifiers)=0
 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).
virtual int gui_MoveCursorUsingPoint (wxDC &dc, const wxPoint &p)=0
 Moves the cursor inside this element in the closest available position to the given point.
virtual void gui_GetCursorPos (mcCursorPos &) const =0
 Returns the cursor position as Cursor Position flag.
virtual mcCursorPos gui_GetCursorPos () const
 Returns the cursor position after creating mcCursorPos.
virtual void gui_SetCursorPos (const mcCursorPos &code)=0
 Sets the cursor position inside the element using Cursor Position flags.
virtual mcInputRes gui_Input (const mcKey &ev, mcElement *newelem)=0
 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).
virtual mcInsertRes gui_Insert (const mcElement &toinsert, mcElement *newelem)=0
 Inserts the given element at the right of the cursor position.
Functions which MUST be overridden by container classes
Functions which _MUST_ be overridden by container classes to ensure a correct behaviour of the element.

Non-container classes should avoid to overload these functions.

virtual void gui_OnSelect (wxDC &, wxRect &rc)
 This function is called when the bounding box of this element intersects with the selection rectangle created by the user with the mouse cursor.
virtual mcElement gui_GetSelection () const
 Returns the selected portion of this element.
virtual void gui_DeleteSelection ()
 Deletes the selected children of this element, without breaking the integrity of this element: a data_Check() constcall after this function should throw no errors.
virtual mcElementgui_GetActiveElem (int x, int y, const wxPoint &pt) const
 Returns the currently active element; that is, the element currently under the mouse cursor (whose position is given) or NULL if there is no active element inside this one (for container elements).
Overrideables functions
Functions which can be overridden but that should work without changes.

virtual void gui_SetStyleArray (const mcStyleArray *p)
 Changes recursively the styles of this element and the styles of all its children.
virtual void gui_OnRecalcSize (wxSize old)
 Called by the mcElementHelpers::sgui_RecalcSize.
virtual void gui_OnParentSizeChange ()
 Called by parent when parent's size changes.
virtual void gui_DeepRecalcSize ()
 Recalculates the size of the elements and all the subelements contained into this one (this is not done normally by gui_RecalcSize).
virtual bool gui_isAllSelected () const
 Returns TRUE only if the element and all its children are completely selected.
virtual void gui_SelectAll ()
 gui_Selects the entire element and all its children.
virtual void gui_DeSelect ()
 If this element is selected, this function deselects it.
virtual bool gui_Split (mcElement *p)
 gui_Splits this element in two parts.
virtual bool gui_MergeWith (const mcElement &)
 Merges the given element with this object.
virtual bool gui_isSplittable () const
 Returns TRUE if this element supports splitting and, thus, also merging.
virtual void gui_Select ()
 Sets this element as selected.
virtual bool gui_isSelected () const
 Returns TRUE if this element is selected (totally or partially).
virtual 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).
virtual void gui_RecalcSize ()
 Recalculates the size of the element, calling in any case the mcElement::gui_OnRecalcSize function.
int gui_GetExpDepth () const
 Returns the exponent depth of this element.
virtual wxSize gui_GetSize () const
 Returns the size; the returned size can be not up-to-date (this function cannot update size if it is invalid, because this is a CONST function; use gui_RecalcSize() before calling this function to be sure to get updated results).
virtual int gui_GetWidth () const
 Returns the width of the element.
virtual int gui_GetHeight () const
 Returns the width of the element.
virtual wxSize gui_GetSize ()
 Returns the updated size (in pixels) of the element.
virtual int gui_GetWidth ()
 Returns the updated width, in pixels, of this element.
virtual int gui_GetHeight ()
 Returns the updated height, in pixels, of this element.
virtual int gui_GetYAnchor () const
 Returns the y amount of this mcElement to subtract from the center line to draw this element.
Styles non-STATIC functions.
Functions which makes style-access easier but requires a THIS pointer.

virtual void gui_UpdateExpDepth ()
 Called by mcElement's standard functions to update the exponent depth of member classes.
void gui_SetAsExpOf (const mcElement &p)
 Sets this element as exponent of the given pointer.
void gui_SetAtSameLevelOf (const mcElement &p)
 Sets this element at the same level of the given element.
void gui_SetExpDepth (int n)
 Sets the exponent depth of this element.
const mcStylegui_GetStyle (int n) const
 Returns the style associated with the n-th exponent depth using the style array owned by this element.
const mcStyleArraygui_GetStyleArray () const
 Returns the style array associated with this element.
wxSize gui_GetSizeOfChar (wxDC *dc=NULL, const mcElement &p=mcEmptyElement) const
 Returns the size of a character (assume that fonts used are fixed pitch fonts and thus all characters have the same size) in the style used by the given pointer;.
int gui_GetHeightOfChar (wxDC *, const mcElement &) const
 Returns only the height of gui_GetSizeOfChar.
int gui_GetWidthOfChar (wxDC *, const mcElement &) const
 Returns only the width of gui_GetSizeOfChar.
const mcStylegui_GetStyleForThis () const
 The style used to draw each element is chosen using the element's exponent level; use this function to retrieve the style which should be used for the currentelement.
void gui_SelectStyle (wxDC &dc) const
 Automatically selects the style for the given element in the given DC, recognizing its mcElementType.
int gui_GetThickness (wxDC *dc) const
 Returns the thickness (in pixels) the caller should use to draw decoration elements (for example, the fraction line).
int gui_GetBaseOffsety (int h) const
 Use the following function to get the num of pixels between the exponent miny and the base miny; that is, the empty space between the exponent and the base on y axis.
int gui_GetSubscriptOffsety (int h) const
 Returns the num of pixels between the base's bottom border and the subscript's (of the base) bottom border.
Search & replace
Various versions of math_Find() and math_Replace() functions.

mcElement math_Find (int n, const mcElement &p, long flags=mcFIND_NOFLAGS) const
 Returns the n-th occurrence of an element with the same contents (this function uses #math_CompareWith, not #hasSameContentOf to perform the comparison !) or NULL if there is no an n-th occurrence of such an element.
mcElement math_FindInChildrenOnly (int n, const mcElement &p, long flags=mcFIND_NOFLAGS) const
 Works like math_Find() but its action is limited to the children (recursively) of *this only and not also *this.
int math_NonRecursiveFindInChildren (int n, const mcElement &p, long flags=mcFIND_NOFLAGS) const
 Works like math_FindInChildrenOnly() but this function does not search recursively; that is, this function won't search in the children of the children of *this.
virtual int math_GetCountOf (const mcElement &p, long flags=mcFIND_NOFLAGS) const
 Returns the number of elements with the same contents of the given one contained into this one.
virtual int math_GetCountOfChildrenOnly (const mcElement &p, long flags=mcFIND_NOFLAGS) const
 Works like math_GetCountOf() but does not compare the given element with *this, just with the children of *this.
virtual int math_GetCountOf (const mcSymbolProperties *sym, long flags=mcFIND_NOFLAGS) const
 Returns the number of symbols of the given type contained in *this element and its children (recursive search).
virtual int math_GetCountOf (const mcSymbolArray *arr, long flags=mcFIND_NOFLAGS) const
 Returns the number of symbols belonging to the given mcSymbolArray are contained in *this element and its children (recursive search).
virtual int math_GetCountOfSymbolsType (const mcSymbolArray *arr, long flags=mcFIND_NOFLAGS) const
 Unlike #math_GetCountOf(const mcSymbolArray *, long) this function does not return the total number of symbols contained: it returns how many *types* of symbols of the given array are contained into *this and its children (recursive search).
virtual int math_Replace (const mcElement &tofind, int n, long flags, const mcElement &replacement, bool bAttachChildren)
 Replaces the n-th occurrence of the element 'tofind' with a copy of the element 'replacement'.
virtual bool math_Contains (const mcElement &p, long flags=mcFIND_NOFLAGS) const
 Returns TRUE if the given element is contained inside this one.
bool math_ContainsOneOf (const mcSymbolArray *) const
 Returns TRUE if one of the symbols registered in the given array is contained inside this element.
virtual bool math_ContainsSymbol (const mcSymbolProperties *s, const mcPolynomial &exp=mcEmptyPolynomial) const
 Returns TRUE if this element contains the given type of.
virtual bool math_ContainsNumber (const mcRealValue &n, const mcPolynomial &exp=mcEmptyPolynomial) const
virtual bool math_ContainsUnknowns () const
 Returns TRUE if this element contains one or more unknowns.
virtual bool math_ContainsConstants () const
 Like math_ContainsUnknowns() but the array checked is mcSymbol::arrConstants.
virtual bool math_ContainsParameters () const
 Like math_ContainsUnknowns() but the array checked is mcSymbol::arrParameters.
virtual bool math_ContainsSymbols () const
 Returns TRUE if this element contains at least one unknown/constant/parameter.
virtual bool math_ContainsInvalidSymbols () const
 Returns TRUE if this element contains unregistered symbols.
Math engine ABSTRACT functions.
Abstract functions to implement in mcElementMath-derived classes.

virtual mcMathType math_GetMathType () const =0
 A powerful recognizer function which automatically classifies the type of the math data contained in this class and returns the respective identifier.
virtual mcRealValue math_GetLenght () const =0
 Returns the 'lenght' of this element without taking in count its children.
virtual mcExpSimRes math_Simplify (long flags, mcElement *newelem)=0
 Simplifies this element one "step"; that is, after one call to this function the element must be slightly changed.
virtual mcExpSimRes math_Expand (long flags, mcElement *newelem)=0
 Expands this element one "step".
virtual bool math_Compare (const mcElement &p, long flags) const =0
 Compares *this element with the given one and then compare the children of *this and the children of the given element, too.
virtual bool math_CompareThisOnly (const mcElement &p, long flags) const
 Compares this element and the given one and then stops, unlike math_Compare() that compares children too.
virtual mcRealValue math_Evaluate () const =0
 Evaluates the numeric value of this element and then returns it.
virtual int math_GetOrderPos () const =0
 Returns the order position for this element.
virtual mcMonomial math_GetFactors () const
 Factores-out everything which can be factored out from this element.
BASIC operations
Abstract functions defining basic add/sub/mult/div operations.

virtual bool math_CanBeAddedWith (const mcElement &p) const =0
 Returns TRUE if this element can be added with the given element.
virtual bool math_CanBeMultWith (const mcElement &p) const =0
 Works like #math_CanBemath_AddeWith(), just for multiplication.
virtual bool math_CanBeDivBy (const mcElement &p) const =0
 Works like #math_CanBemath_AddeWith(), just for divisions.
virtual mcBasicOpRes math_Add (const mcElement &e, mcElement *pp, bool add=TRUE)=0
 Sums or subtracts this element with the given e element.
mcBasicOpRes math_Subtract (const mcElement &e, mcElement *pp)
 math_s two mcElements of the same type and stores the result in this object.
virtual mcBasicOpRes math_MultiplyBy (const mcElement &e, mcElement *pp)=0
 Multiplies two mcElements of the same type and stores the result in this object.
virtual mcBasicOpRes math_DivideBy (const mcElement &e, mcElement *pp)=0
 Divides two mcElements of the same type and stores the result in this object.
virtual mcMonomial math_GetLCM (const mcElement &) const =0
 Returns the LCM between *this and the given element.
virtual mcMonomial math_GetGCD (const mcElement &) const =0
BASIC operations regarding EXPONENTS
Abstract functions defining basic raise/set op on the exp.

virtual mcBasicOpRes math_RaiseTo (const mcPolynomial &)=0
 Raises *this element to the given polynomial.
virtual mcBasicOpRes math_MakeReciprocal (mcElement *replacement)
 Calculates the reciprocal of this element; tipically, this function creates a mcFraction whose numerator is 1 and the denominator contains *this.
virtual void math_SetExp (const mcPolynomial &)
 Sets the exponent of this element to match the given polynomial.
Input & output functions (abstract functions)
These functions import or export the element's data.

virtual bool io_isBeginTag (const wxXml2Node &tag) const =0
 Returns a positive value if the given MathML content tag marks the begin of this element; FALSE otherwise.
virtual bool io_isBeginChar (const wxString &str) const =0
 Returns a positive value if the given inlined expression marks the begin of this element; FALSE otherwise.
virtual wxXml2Node io_GetMathML (bool bGetPresentation) const =0
 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).
virtual wxString io_GetInlinedExpr () const =0
 Returns the inlined expression for this element as a wxString.
virtual bool io_ImportPresentationMathML (wxXml2Node tag, wxString &pErr)=0
 Imports presentation MathML reading the contents of the given XML node (without modifying it).
virtual bool io_ImportInlinedExpr (const wxString &str, int *count, wxString &pErr)=0
 Imports an inlined expression.

Static Public Member Functions

BASIC CLASS SECTION
The class identifiers of MathCore classes (the possible values of mcElement::m_nType), and the functions which handle them.

static mcElementType gui_isKeyBeginKey (const mcKey &ev)
 Returns the identifier code (mcET_****) of the class that uses the given char as begin char; mcET_INVALID if the function can't find any result.
static mcElementType io_isCharBeginChar (const wxString &str)
static mcElementType io_isTagBeginTag (const wxXml2Node &tag)
static mcElement data_NewElem (mcElementType type, const mcElementHelpers *towrap=NULL)
 Allocates a new element of given type and set his parent to the given pointer (which must be NULL only for the root of the tree structure); then, eventually initializes it with the given inlined expression (if IO section is enabled !).
static mcElementdata_GetInstanceOf (mcElementType type)
 Returns a pointer to an instance of the given element type.
static wxString data_GetGlobalMemoryInfo ()
 Returns a string containing the sizes of the various mcElement classes.
static void data_UpdateElemArray ()
 data_Updates the internal array of elements used by #GetInstanceOf and the isChar/Key/Tag/BeginXXXX() functions.
static int data_GenID (bool bFirstMember=TRUE)
 Generates a unique number in the entire MathCore session, applying a fixed formula based on the current time and the random generator provided by standard libraries.
static void Init ()
 Inits all the static data of mcElement.
static void Cleanup ()
 Destroys all the static data of mcElement.
Styles STATIC functions
Defines a lot of attributes which are used to create the graphical output for all MathCore classes.

static void gui_InitDefaultStyles ()
 Resets the style array to the defaults, eventually deleting previous styles.
static void gui_DeleteDefaultStyles ()
 Removes the allocated styles from the default style array of mcElementGUI.
static double gui_GetPointSize ()
 Returns the style for the n-th exponent level.
static double gui_PointSize2Pixels (double pointsize)
 Utility function: use it to convert point size units to pixels units.
static double gui_Pixels2PointSize (double pointsize)
 Utility function: use it to convert pixels to point size units.
static wxSize gui_GetSizeOf (wxDC *dc, const wxString &str)
 Returns the string height and width (using the selected font to determine them).
static int gui_GetHeightOf (wxDC *, const wxString &)
 Returns only the height of ::gui_GetSizeOf.
static int gui_GetWidthOf (wxDC *, const wxString &)
 Returns only the width of ::gui_GetSizeOf.

Static Public Attributes

static mcElementsdata_pElem [mcNUM_ELEMENT_TYPES]
 An array containing one instance of each class type; used by isCharBeginChar(char) function; it uses this array to call the io_isBeginChar() function of each element type to do its work (the pElem array is initialized at the moment of the allocation of the namespace; see MathCore.cpp).
static wxBrush * sgui_pSelectionBrush = NULL
 The brush used to draw the selected portions of the math data.
static wxBrush * sgui_pActivationBrush = NULL
 The brush used to draw active elements (elements which are located under the cursor).
static mcStyleArraysgui_pDefaultStyles = NULL
 The array of styles used by default by all mcElements.
static int sgui_nAdditionalActivationSpaceLeftRight = 2
 The additional number of pixels on the left & right of the active element to fill with sgui_pActivationBrush.

Protected Member Functions

virtual void gui_Init ()
 Inits this section of the element.
virtual void math_Init ()
 Initializes the MATH section of this element.
virtual mcElement math_RecursiveFind (int &n, const mcElement &p, long flags) const
 Recursively search the n-th occurrence of the given element both in *this and both in *this' children using math_RecursiveFindInChildrenOnly().
virtual mcElement math_RecursiveFindInChildrenOnly (int &n, const mcElement &p, long flags) const
 Works exactly like math_RecursiveFind() except that this function does not perform comparison between p and *this.
virtual void io_Init ()
 Initializes the IO section of this element.
virtual void io_PostProcess ()
 Post-processes this element after the import-process.
virtual void io_PostProcessChildren ()
 Calls the io_PostProcess functions of all the children of this element; call this one just before exiting #io_ImportInlinedExpr and #io_ImportPresentationMathML.

Protected Attributes

int mdata_nID
 The ID of this element.
int mdata_nProperties
 The properties of this element, stored as bit array (use values defined in Element.h to check and set flags).
const mcStyleArraymgui_pStyleArray
 Array of MathCore styles; access this array indirectly using the gui_GetStyle() function.
bool mgui_bSelected
 TRUE if the element is selected (totally or partially).
wxSize mgui_sz
 Size of the element (in pixels).
int mgui_nExpDepth
 The exponent level of this element.

Friends

class mcElement


Constructor & Destructor Documentation

mcElementHelpers::mcElementHelpers  ) 
 

Default constructor.

Definition at line 166 of file Element.cpp.

References data_GenID(), and mcEP_NOPROPERTIES.

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

Definition at line 354 of file Element.h.


Member Function Documentation

void mcElementHelpers::Cleanup  )  [static]
 

Destroys all the static data of mcElement.

Definition at line 362 of file Element.cpp.

References mcNUM_ELEMENT_TYPES, mcSAFE_DELETE, and sdata_pElem.

Referenced by mcMathCore::CleanupMath().

bool mcElementHelpers::data_AddChildrenTo mcElement  p  )  [virtual]
 

Tries to attach the children of *this to the given element, respecting the math meaning of each one.

If the function does not manage to perform its task, it returns FALSE (for example, when the given element's type and this.data_GetType() do not match).

Definition at line 281 of file Element.cpp.

References data_GetChild(), data_GetChildrenCount(), data_GetType(), mcElement::data_GetType(), and mcElement::data_SetChild().

virtual void mcElementHelpers::data_AddProperty int  p,
void *  val1 = NULL,
void *  val2 = NULL
[inline, virtual]
 

Adds the given property to this element.

Reimplemented in mcElementArrayHelpers.

Definition at line 367 of file Element.h.

References mdata_nProperties.

Referenced by data_AddRecursiveProperty(), mcExpElementHelpers::data_CreateExpSub(), mcSymbolHelpers::gui_BaseInput(), mcExpContainerHelpers::gui_BaseInput(), mcExpElementHelpers::gui_EditExpSub(), mcParenthesisHelpers::gui_Input(), mcFractionHelpers::gui_Input(), mcEmptyBoxHelpers::gui_Input(), mcDecorationHelpers::gui_Input(), mcFunctionHelpers::gui_Setup(), mcSymbolHelpers::io_ImportBaseInlinedExpr(), mcNumberHelpers::io_ImportBaseInlinedExpr(), mcSymbolHelpers::io_ImportPresentationMathML(), and mcNumberHelpers::io_ImportPresentationMathML().

void mcElementHelpers::data_AddRecursiveProperty mcElementType  t,
int  p,
void *  val1 = NULL,
void *  val2 = NULL
[virtual]
 

math_Adds the given property to this element.

Definition at line 240 of file Element.cpp.

References data_AddProperty(), mcElement::data_AddRecursiveProperty(), data_GetChild(), data_GetChildrenCount(), and data_GetType().

wxString mcElementHelpers::data_Check  )  const [inline]
 

Does some standard checks on the element integrity.

If something is wrong an mcASSERT fails. Except for some short moments (the element creation/deallocation...) none of the checks done by the function should never fail. This is a recursive function.

Reimplemented in mcMathSystemHelpers.

Definition at line 530 of file Element.h.

Referenced by mcPolynomialHelpers::data_AddNewEmptyMonomial(), mcMonomialHelpers::data_Repair(), mcPolynomialHelpers::data_ReplaceParentheses(), mcMonomialHelpers::gui_AddNewElement(), mcPolynomialHelpers::gui_BackInput(), mcElementArrayHelpers::gui_Input(), mcPolynomialHelpers::gui_ReplaceBracket(), mcPolynomialHelpers::math_Add(), mcPolynomialHelpers::math_DeleteSelection(), mcPolynomialHelpers::math_DistributeBracket(), mcElementArrayHelpers::math_EmbedInFraction(), mcPolynomialHelpers::math_FactoreOut(), mcElementArrayHelpers::math_HandleBasicOpRes(), mcPolynomialHelpers::math_MultiplyBy(), mcPolynomialHelpers::math_Reorder(), mcElementArrayHelpers::math_Simplify(), and mcPolynomialHelpers::math_WrapMonomial().

virtual mcElementHelpers* mcElementHelpers::data_Clone  )  const [pure virtual]
 

Returns a pointer to a new object identical to the current element.

Derived classes must implement this function creating a new identical mcElement and returning it. See also mcIMPLEMENT_CLONE_FNC macro for a quick way to create this function.

Returns:
A pointer to a new element which must be deleted by the caller

Referenced by mcElement::data_MakePrivateCopy(), and math_isMaxSimplified().

wxString mcElementHelpers::data_Debug long   )  const [inline]
 

Returns simple info about this element.

It should return something in this form:

[class name: 14 char, pad with spaces the end of the name if less than 14 characters][info specific for this element][with final '\n']

For example, for the mcSymbol class defining 'a', default debug output is:

"mcSymbol a\n"

Definition at line 505 of file Element.h.

void mcElementHelpers::data_DeepCopy const mcElementHelpers p  )  [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 in mcDecorationHelpers, mcElementArrayHelpers, mcExpContainerHelpers, mcExpElementHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathLineHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcNumberHelpers, mcOperatorHelpers, mcParenthesisHelpers, mcPolynomialHelpers, mcSymbolHelpers, and mcTextHelpers.

Definition at line 584 of file Element.cpp.

References data_GetType(), mcASSERT, mdata_nProperties, mgui_bSelected, mgui_nExpDepth, mgui_pStyleArray, and mgui_sz.

Referenced by mcFractionHelpers::data_DeepCopy(), mcElementArrayHelpers::data_DeepCopy(), and mcDecorationHelpers::data_DeepCopy().

int mcElementHelpers::data_GenID bool  bFirstMember = TRUE  )  [static]
 

Generates a unique number in the entire MathCore session, applying a fixed formula based on the current time and the random generator provided by standard libraries.

Exists a litte possibility that this function produces two identical values in the same MathCore session, but it's almost impossible.

Parameters:
bFirstMember If TRUE ID generation starts from zero, if FALSE from 0xFFFF
Returns:
a 32-bit unique code.

Definition at line 482 of file Element.cpp.

Referenced by mcElementHelpers().

mcElement & mcElementHelpers::data_GetChild int  n  )  [virtual]
 

Like data_GetConstChild, but this function returns a non-const pointer.

Note:
This function *must* have a different name from data_GetConstChild otherwise, stack overflows would occur since this function calls data_GetConstChild.

Definition at line 300 of file Element.cpp.

References data_GetConstChild().

Referenced by data_AddChildrenTo(), data_AddRecursiveProperty(), mcMathSystemHelpers::data_Get(), mcMathAndSystemHelpers::data_GetLine(), mcMathOrSystemHelpers::data_GetSys(), data_RemoveRecursiveProperty(), data_Update(), gui_DeepRecalcSize(), gui_DeleteSelection(), gui_DeSelect(), gui_SelectAll(), gui_SetStyleArray(), io_PostProcessChildren(), and math_SetExp().

int mcElementHelpers::data_GetChildIdx const mcElement p  )  const [virtual]
 

Returns the index of the children which is allocated in the given memory address.

If the given pointer does not identify a children of this element, the returned value is -1.

Definition at line 291 of file Element.cpp.

References data_GetChildrenCount(), and data_GetConstChild().

virtual int mcElementHelpers::data_GetChildrenCount  )  const [inline, virtual]
 

Returns the number of children attached to this tree node.

This function can be used on *any* mcElement node because this is a virtual function which is overridden by container classes which thus return the correct number of children.

This function is used by various mcElement functions like data_Check() const data_GetElemFromID(), ... which must call some standard mcElement functions on all nodes attached to this element.

Reimplemented in mcElementArrayHelpers, mcExpContainerHelpers, mcExpElementHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, and mcTextHelpers.

Definition at line 542 of file Element.h.

Referenced by data_AddChildrenTo(), data_AddRecursiveProperty(), data_GetChildIdx(), mcTextHelpers::data_GetChildrenCount(), mcMathMngHelpers::data_GetChildrenCount(), mcFractionHelpers::data_GetChildrenCount(), mcExpElementHelpers::data_GetChildrenCount(), mcElementArrayHelpers::data_GetChildrenCount(), data_GetElemFromID(), data_hasRecursiveProperty(), data_isSameAs(), data_RemoveRecursiveProperty(), data_Update(), gui_DeepRecalcSize(), gui_DeleteSelection(), gui_DeSelect(), gui_isAllSelected(), gui_SelectAll(), gui_SetStyleArray(), io_PostProcessChildren(), math_GetCountOf(), math_GetCountOfChildrenOnly(), math_GetTotalLenght(), math_isValidMath(), math_NonRecursiveFindInChildren(), math_RecursiveFind(), math_RecursiveFindInChildrenOnly(), and math_SetExp().

const mcElement & mcElementHelpers::data_GetConstChild int  n  )  const [virtual]
 

Returns the n-th tree node attached to this element.

You can use this function to traverse the entire tree:

     mcElement rootnode = [...];
     MyWalkerFnc(rootnode);
    
     void MyWalkerFnc(mcElement p) {
    
         // do what you want on the "p" node...
    
         for (int i=0; i < p.data_GetChildrenCount(); i++)
             MyWalkerFnc(p.data_GetChild(i));
     }

Parameters:
n The n-th child of this object.

Reimplemented in mcDecorationHelpers, mcElementArrayHelpers, mcExpContainerHelpers, mcExpElementHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, and mcTextHelpers.

Definition at line 303 of file Element.cpp.

References mcEmptyElement.

Referenced by data_GetChild(), data_GetChildIdx(), data_GetElemFromID(), data_hasRecursiveProperty(), data_isSameAs(), gui_isAllSelected(), math_GetCountOf(), math_GetCountOfChildrenOnly(), math_GetTotalLenght(), math_isValidMath(), math_NonRecursiveFindInChildren(), math_RecursiveFind(), and math_RecursiveFindInChildrenOnly().

wxString mcElementHelpers::data_GetDebug int  ,
long 
const [inline]
 

Returns more complete debug information about this element (using the data_Debug function).

Parameters:
indent The indentation to leave at the beginning of the string.
flags Allows to specify additional info to get through the mcELEMENT_DBG_ID, mcELEMENT_DBG_EXPDEPTH flags...

Definition at line 624 of file Element.h.

wxString mcElementHelpers::data_GetDebugName  )  const [inline]
 

Reimplemented in mcExpContainerHelpers.

Definition at line 507 of file Element.h.

mcElement & mcElementHelpers::data_GetElemFromID int  id  )  const [virtual]
 

Returns the element with the given ID.

Non-container classes should just return their ID (which is the default implementation behaviour). Container classes, instead, should search recursively among their children and then return the one which matches with the given ID. If the element with the given ID cannot be found, this function returns NULL.

Definition at line 225 of file Element.cpp.

References data_GetChildrenCount(), data_GetConstChild(), mcElement::data_GetElemFromID(), and mcEmptyElement.

Referenced by gui_GetActiveElem().

wxString mcElementHelpers::data_GetGlobalMemoryInfo  )  [static]
 

Returns a string containing the sizes of the various mcElement classes.

Definition at line 468 of file Element.cpp.

References data_GetMemoryInfo(), mcNUM_ELEMENT_TYPES, and sdata_pElem.

int mcElementHelpers::data_GetID  )  const [inline]
 

Returns the ID for this element.

Definition at line 606 of file Element.h.

References mdata_nID.

Referenced by mcTextHelpers::gui_Draw(), mcParenthesisHelpers::gui_Draw(), mcOperatorHelpers::gui_Draw(), mcMultDivOpHelpers::gui_Draw(), mcFractionHelpers::gui_Draw(), mcExpElementHelpers::gui_Draw(), mcEmptyBoxHelpers::gui_Draw(), mcSymbolHelpers::gui_DrawBase(), mcNumberHelpers::gui_DrawBase(), mcFunctionHelpers::gui_DrawBase(), and mcExpContainerHelpers::gui_DrawBase().

static mcElement* mcElementHelpers::data_GetInstanceOf mcElementType  type  )  [inline, static]
 

Returns a pointer to an instance of the given element type.

The given pointer must not be modified and it is completely unlinked from any tree (no parents, no children).

Definition at line 159 of file Element.h.

References sdata_pElem.

Referenced by mcElementArrayHelpers::math_GetOpBetween(), mcElementArrayHelpers::math_GetOpPreceding(), and mcPolynomialHelpers::math_SimplifySolveOp().

virtual int mcElementHelpers::data_GetMemoryInfo  )  const [pure virtual]
 

Returns the size of this class and all its helper classes calculated using the sizeof() operator.

See the mcDEFINE_GETMEMORYINFO_FNC macro for a quick way to implement this function.

Referenced by data_GetGlobalMemoryInfo().

virtual mcElementType mcElementHelpers::data_GetType  )  const [pure virtual]
 

Returns the identifier code for this class.

The identifier code is one of the mcElementType enumeration values and it should uniquely identify this mcElmentHelpers-derived class.

Referenced by data_AddChildrenTo(), mcElementArrayHelpers::data_AddElements(), data_AddRecursiveProperty(), data_DeepCopy(), mcPolynomialHelpers::data_DetachAndShiftMonomial(), mcPolynomialHelpers::data_FindMonomialContaining(), mcElementArrayHelpers::data_GetElemIndexOfType(), mcElementArrayHelpers::data_GetNumOfElemType(), mcPolynomialHelpers::data_GetWrapped(), data_hasRecursiveProperty(), mcElementArrayHelpers::data_isOp(), data_isSameAs(), mcPolynomialHelpers::data_isWrappingOnly(), mcElementArrayHelpers::data_isWrappingOnly(), mcElementArrayHelpers::data_QueueElemType(), data_RemoveRecursiveProperty(), mcMonomialHelpers::data_Repair(), mcPolynomialHelpers::data_ReplaceParentheses(), mcMonomialHelpers::data_TransformDivOp(), mcMonomialHelpers::gui_BackInput(), mcExpElementHelpers::gui_CreateExpSub(), mcElementArrayHelpers::gui_GetSelection(), mcPolynomialHelpers::gui_ReplaceBracket(), mcMonomialHelpers::gui_ScanArrayForFunctions(), mcExpElementHelpers::io_GetInlinedExpr(), mcMonomialHelpers::io_ImportPresentationMathML(), mcExpContainerHelpers::math_Add(), mcExpContainerHelpers::math_CanBeAddedWith(), mcElementArrayHelpers::math_CanBeAddedWith(), mcExpContainerHelpers::math_CanBeDivBy(), mcExpContainerHelpers::math_CanBeMultWith(), mcExpElementHelpers::math_Compare(), mcElementArrayHelpers::math_Compare(), mcExpContainerHelpers::math_CompareThisOnly(), math_CompareThisOnly(), mcElementArrayHelpers::math_CreateWrapperFor(), mcPolynomialHelpers::math_DeleteFirstOp(), mcPolynomialHelpers::math_DistributeBracket(), mcExpContainerHelpers::math_DivideBaseOnlyBy(), mcNumberHelpers::math_GetGCD(), mcExpElementHelpers::math_GetGCD(), mcPolynomialHelpers::math_GetSign(), mcPolynomialHelpers::math_GetWrapped(), mcElementArrayHelpers::math_HandleExpSimFlag(), math_isValidMath(), mcPolynomialHelpers::math_isWrappingOnly(), mcElementArrayHelpers::math_isWrappingOnly(), mcExpContainerHelpers::math_MultiplyBaseOnlyBy(), mcElementArrayHelpers::math_Remove(), mcMonomialHelpers::math_RemoveCoeff(), mcElementArrayHelpers::math_ReorderElements(), mcMonomialHelpers::math_SetCoeff(), and mcMonomialHelpers::math_TransformDivOp().

virtual bool mcElementHelpers::data_hasProperty int  p  )  const [inline, virtual]
 

Returns TRUE if this element has the given property set.

Definition at line 380 of file Element.h.

References mdata_nProperties.

Referenced by mcElementArrayHelpers::data_UpdateNeighbor(), mcSymbolHelpers::gui_BaseInput(), mcFunctionHelpers::gui_BaseInput(), mcExpContainerHelpers::gui_BaseInput(), mcFunctionHelpers::gui_BaseMoveCursor(), mcExpElementHelpers::gui_Draw(), mcExpElementHelpers::gui_EditExpSub(), mcExpElementHelpers::gui_ExpSubDraw(), mcExpElementHelpers::gui_GetBaseAndSubSize(), mcExpElementHelpers::gui_GetExpSubCursorPos(), mcExpElementHelpers::gui_GetExpSubSize(), mcExpElementHelpers::gui_GetSelection(), mcExpElementHelpers::gui_hasBaseSthOnLeftSide(), mcExpElementHelpers::gui_hasBaseSthOnRightSide(), mcParenthesisHelpers::gui_Input(), mcFractionHelpers::gui_Input(), mcEmptyBoxHelpers::gui_Input(), mcDecorationHelpers::gui_Input(), mcExpElementHelpers::gui_isCursorInExpSub(), mcRadicalHelpers::gui_isLeftPosEnabled(), mcFunctionHelpers::gui_MoveCursor(), mcExpElementHelpers::gui_MoveCursor(), mcExpElementHelpers::gui_MoveCursorUsingPoint(), mcExpElementHelpers::gui_OnSelect(), mcExpElementHelpers::gui_SetCursorPos(), mcExpElementHelpers::gui_SetExpSubCursorPos(), mcFunctionHelpers::io_GetBaseInlinedExpr(), mcRadicalHelpers::io_GetInlinedExpr(), mcExpElementHelpers::io_GetInlinedExpr(), mcRadicalHelpers::io_GetMathML(), mcExpElementHelpers::io_GetMathML(), mcRadicalHelpers::io_ImportBaseInlinedExpr(), mcExpElementHelpers::math_hasExp(), and mcExpElementHelpers::math_hasSub().

bool mcElementHelpers::data_hasRecursiveProperty mcElementType  t,
int  p
const [virtual]
 

Returns TRUE if this element has the given property set.

Definition at line 250 of file Element.cpp.

References data_GetChildrenCount(), data_GetConstChild(), data_GetType(), and mdata_nProperties.

void mcElementHelpers::data_Init  ) 
 

Inits this class calling the gui_Init, math_Init and io_Init functions, if required.

This function should called by the last overload of the constructor of the mcElementHelpers-derived class, that is, when the build process is completed and the xxx_Init() functions called are the functions of the derived class.

Reimplemented in mcMathMngHelpers.

Definition at line 179 of file Element.cpp.

References gui_Init(), io_Init(), and math_Init().

Referenced by mcMathMngHelpers::data_Init(), mcBracketHelpers::mcBracketHelpers(), mcFunctionHelpers::mcFunctionHelpers(), mcMathAndSystemHelpers::mcMathAndSystemHelpers(), and mcMathOrSystemHelpers::mcMathOrSystemHelpers().

virtual bool mcElementHelpers::data_isAllowedAfter mcElementType  type  )  const [inline, virtual]
 

Returns TRUE if this element is allows to be placed directly on the right of the given element type.

See #isAllowedBefore for more info.

Reimplemented in mcNumberHelpers.

Definition at line 458 of file Element.h.

Referenced by mcMonomialHelpers::data_Repair().

virtual bool mcElementHelpers::data_isAllowedBefore mcElementType  type  )  const [inline, virtual]
 

Returns TRUE if this element is allowed to be directly on the left of the given element type.

If this function returns FALSE (default implementation returns TRUE), the container element will interpose a mcMultOp between this element and the following.

Note:
This is not a GUI-specific function because it is used also by non-GUI functions, like mcMonomial::data_Repair().

Reimplemented in mcNumberHelpers, and mcOperatorHelpers.

Definition at line 453 of file Element.h.

Referenced by mcMonomialHelpers::data_Repair(), and mcMonomialHelpers::gui_BackInput().

bool mcElementHelpers::data_isSameAs const mcElementHelpers  )  const [virtual]
 

Performs a deep comparison of the data hold by this class and the data hold by the given mcElementHelpers object.

Reimplemented in mcElementArrayHelpers, mcExpContainerHelpers, mcFractionHelpers, mcFunctionHelpers, mcNumberHelpers, and mcSymbolHelpers.

Definition at line 562 of file Element.cpp.

References data_GetChildrenCount(), data_GetConstChild(), data_GetType(), and mdata_nProperties.

mcElement mcElementHelpers::data_NewElem mcElementType  type,
const mcElementHelpers towrap = NULL
[static]
 

Allocates a new element of given type and set his parent to the given pointer (which must be NULL only for the root of the tree structure); then, eventually initializes it with the given inlined expression (if IO section is enabled !).

This function can allocate any type of mcElement-derived class.

See also:
mcElement::Newhlp()

Definition at line 395 of file Element.cpp.

References mcASSERT, mcDEFINE_ALLOCATOR, mcDEFINE_SPECIAL_ALLOCATOR, mcET_ADDOP, mcET_BRACKET, mcET_DIVOP, mcET_EMPTYBOX, mcET_FRACTION, mcET_FUNCTION, mcET_MONOMIAL, mcET_MULTOP, mcET_NUMBER, mcET_PARENTHESIS, mcET_POLYNOMIAL, mcET_RADICAL, mcET_SUBOP, mcET_SYMBOL, and mcET_TEXT.

Referenced by mcElementArrayHelpers::data_AddNewElement(), mcElementArrayHelpers::data_AddNewOp(), mcPolynomialHelpers::data_AddNewWrappedElement(), mcElement::data_GetNewElemLikeThis(), data_UpdateElemArray(), mcElementArrayHelpers::gui_AddNewElement(), mcEmptyBoxHelpers::gui_Input(), mcMonomialHelpers::io_ImportInlinedExpr(), mcMonomialHelpers::io_ImportPresentationMathML(), mcElementArrayHelpers::math_ApplyOp(), mcElementArrayHelpers::math_ApplyOpSimple(), mcElementArrayHelpers::math_CreateWrapperFor(), and mcElementArrayHelpers::math_HandleBasicOpRes().

virtual void mcElementHelpers::data_OnNeighborChange  )  [inline, 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 in mcParenthesisHelpers.

Definition at line 473 of file Element.h.

virtual void mcElementHelpers::data_RemoveProperty int  p  )  [inline, virtual]
 

Removes the given property to this element.

Definition at line 375 of file Element.h.

References mdata_nProperties.

Referenced by mcExpElementHelpers::data_DestroyExpSub(), and mcExpElementHelpers::gui_DeleteExpSub().

void mcElementHelpers::data_RemoveRecursiveProperty mcElementType  t,
int  p
[virtual]
 

Removes the given property to this element.

Definition at line 262 of file Element.cpp.

References data_GetChild(), data_GetChildrenCount(), data_GetType(), mcElement::data_RemoveRecursiveProperty(), and mdata_nProperties.

virtual void mcElementHelpers::data_SetChild int  idx,
const mcElement newchild
[inline, virtual]
 

math_Replaces the idx-th child of this element with a copy of the given one.

Reimplemented in mcElementArrayHelpers, mcExpContainerHelpers, mcExpElementHelpers, mcFractionHelpers, mcFunctionHelpers, and mcTextHelpers.

Definition at line 570 of file Element.h.

void mcElementHelpers::data_Update  )  [virtual]
 

Updates this element and all its children (recursive function).

Default implementation of data_Update() does nothing: override it if you need to do something else...

Reimplemented in mcSymbolHelpers.

Definition at line 272 of file Element.cpp.

References data_GetChild(), data_GetChildrenCount(), and mcElement::data_Update().

void mcElementHelpers::data_UpdateElemArray  )  [static]
 

data_Updates the internal array of elements used by #GetInstanceOf and the isChar/Key/Tag/BeginXXXX() functions.

This function is typically used by mcMathCore functions only; however it is public to allow special uses.

Definition at line 368 of file Element.cpp.

References data_NewElem(), mcElement, mcNUM_ELEMENT_TYPES, mcSAFE_DELETE, and sdata_pElem.

Referenced by Init().

void mcElementHelpers::gui_DeepRecalcSize  )  [virtual]
 

Recalculates the size of the elements and all the subelements contained into this one (this is not done normally by gui_RecalcSize).

This function must be obviously overridden by container classes. The standard implementation recalculates the size of this element and the sizes of the children.

Definition at line 703 of file Element.cpp.

References data_GetChild(), data_GetChildrenCount(), mcElement::gui_DeepRecalcSize(), gui_RecalcSize(), mcGUILOG, and mcTXTTHIS.

Referenced by mcPolynomialHelpers::gui_Input().

void mcElementHelpers::gui_DeleteDefaultStyles  )  [static]
 

Removes the allocated styles from the default style array of mcElementGUI.

This function must be called only when styles will no longer be used (like in program shutdown).

See also:
mcMathCore::Cleanup()

Definition at line 895 of file Element.cpp.

References mcSAFE_DELETE, and sgui_pDefaultStyles.

Referenced by mcMathCore::CleanupGUI(), and gui_InitDefaultStyles().

void mcElementHelpers::gui_DeleteSelection  )  [virtual]
 

Deletes the selected children of this element, without breaking the integrity of this element: a data_Check() constcall after this function should throw no errors.

The caller should first check if the element is entirely selected; if it is, the element should be deleted (by the caller) and this function should not be called. This is a recursive function.

Reimplemented in mcElementArrayHelpers, mcFractionHelpers, and mcMathMngHelpers.

Definition at line 746 of file Element.cpp.

References data_GetChild(), data_GetChildrenCount(), mcElement::gui_DeleteSelection(), gui_isAllSelected(), gui_RecalcSize(), and mcASSERT.

Referenced by mcFractionHelpers::gui_DeleteSelection().

void mcElementHelpers::gui_DeSelect  )  [virtual]
 

If this element is selected, this function deselects it.

Use this function to turn off selection; you can't directly access mcElement::mgui_bSelected variable because when selection state change, also derived classes' selection states must change. This function ensures this is done, calling the #data_Updategui_SelectionState() function. To select the element, see gui_OnSelect function().

Definition at line 725 of file Element.cpp.

References data_GetChild(), data_GetChildrenCount(), mcElement::gui_DeSelect(), and mgui_bSelected.

Referenced by mcElementArrayHelpers::gui_ExOnSelect(), mcMathSystemHelpers::gui_OnSelect(), mcMathMngHelpers::gui_OnSelect(), mcFractionHelpers::gui_OnSelect(), and mcExpElementHelpers::gui_OnSelect().

virtual void mcElementHelpers::gui_DoRecalcSize  )  [pure 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...).

Implemented in mcElementArrayHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathLineHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMultDivOpHelpers, mcOperatorHelpers, mcParenthesisHelpers, and mcTextHelpers.

Referenced by gui_RecalcSize().

virtual int mcElementHelpers::gui_Draw wxDC &  dc,
int  x,
int  y,
long  flags,
const wxPoint &  pt
const [pure 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.

Implemented in mcElementArrayHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, mcMultDivOpHelpers, mcOperatorHelpers, mcParenthesisHelpers, mcPolynomialHelpers, and mcTextHelpers.

Referenced by gui_GetActiveElem().

mcElement & mcElementHelpers::gui_GetActiveElem int  x,
int  y,
const wxPoint &  pt
const [virtual]
 

Returns the currently active element; that is, the element currently under the mouse cursor (whose position is given) or NULL if there is no active element inside this one (for container elements).

The default implementation of this function returns the element itself but container classes should return the active subelement.

Definition at line 680 of file Element.cpp.

References data_GetElemFromID(), gui_Draw(), mcDRW_NOACTIVEELEM, mcDRW_ONSELECTION, mcDRW_USEPOINT, and mcEmptyElement.

int mcElementHelpers::gui_GetBaseOffsety int  h  )  const
 

Use the following function to get the num of pixels between the exponent miny and the base miny; that is, the empty space between the exponent and the base on y axis.

This function should be used every time an exp must be drawn; in this way, we ensure that all the exponents appear always at the same level over the base.

Parameters:
h The height (in pixels) of the exponent.

Definition at line 917 of file Element.cpp.

Referenced by mcExpElementHelpers::gui_GetBaseOffsety().

virtual mcCursorPos mcElementHelpers::gui_GetCursorPos  )  const [inline, virtual]
 

Returns the cursor position after creating mcCursorPos.

This function uses the gui_GetCursorPos but it is a little slower since it allocates a mcCursorPos oject while the other overload uses an already existing object given by the caller.

Reimplemented in mcDecorationHelpers, and mcElementArrayHelpers.

Definition at line 797 of file Element.h.

Referenced by mcFunctionHelpers::gui_BaseMoveCursor(), mcFunctionHelpers::gui_GetBaseCursorPos(), mcMathSystemHelpers::gui_GetCursorPos(), mcMathMngHelpers::gui_GetCursorPos(), mcElementArrayHelpers::gui_GetCursorPos(), and mcDecorationHelpers::gui_GetCursorPos().

virtual void mcElementHelpers::gui_GetCursorPos mcCursorPos  )  const [pure 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.

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcOperatorHelpers, and mcTextHelpers.

int mcElementHelpers::gui_GetExpDepth  )  const [inline]
 

Returns the exponent depth of this element.

This is a positive value; for more info see mgui_nExpDepth.

Definition at line 1003 of file Element.h.

References mgui_nExpDepth.

Referenced by mcOperatorHelpers::gui_DoRecalcSize(), and mcElementArrayHelpers::gui_GetSpaceBetween().

virtual int mcElementHelpers::gui_GetHeight  )  [inline, virtual]
 

Returns the updated height, in pixels, of this element.

Note:
This function cannot be CONST because it could be forced to call the gui_RecalcSize() function.

Definition at line 1043 of file Element.h.

References gui_RecalcSize(), and mgui_sz.

virtual int mcElementHelpers::gui_GetHeight  )  const [inline, virtual]
 

Returns the width of the element.

See #GetConstSize() for some important info about the usage of this function.

Definition at line 1017 of file Element.h.

References mgui_sz.

Referenced by mcMathMngHelpers::gui_DoRecalcSize(), mcFractionHelpers::gui_DoRecalcSize(), mcParenthesisHelpers::gui_Draw(), mcMathSystemHelpers::gui_Draw(), mcEmptyBoxHelpers::gui_Draw(), mcMathSystemHelpers::gui_DrawBmp(), mcMathLineHelpers::gui_DrawBmp(), mcMathLineHelpers::gui_ExpandBmp(), mcSymbolHelpers::gui_GetBaseRelCursorPos(), mcMathSystemHelpers::gui_GetBmp(), mcRadicalHelpers::gui_GetContentOffsetY(), mcFractionHelpers::gui_GetDenPos(), mcExpElementHelpers::gui_GetExpSubRelCursorPos(), mcMathSystemHelpers::gui_GetRectOf(), mcMathMngHelpers::gui_GetRectOfLeftMem(), mcMathMngHelpers::gui_GetRectOfRightMem(), mcOperatorHelpers::gui_GetRelCursorPos(), mcMathLineHelpers::gui_GetRelCursorPos(), mcEmptyBoxHelpers::gui_GetRelCursorPos(), mcDecorationHelpers::gui_GetRelCursorPos(), mcMathSystemHelpers::gui_GetYOf(), and mcMathSystemHelpers::gui_GetYOfSymbol().

int mcElementHelpers::gui_GetHeightOf wxDC *  ,
const wxString & 
[static]
 

Returns only the height of ::gui_GetSizeOf.

Definition at line 1020 of file Element.cpp.

References gui_GetSizeOf().

Referenced by mcOperatorHelpers::gui_DoRecalcSize(), and mcNumberHelpers::gui_GetBaseRelCursorPos().

int mcElementHelpers::gui_GetHeightOfChar wxDC *  ,
const mcElement
const
 

Returns only the height of gui_GetSizeOfChar.

Definition at line 1057 of file Element.cpp.

References mcASSERT, and mcGUILOG.

Referenced by mcNumberHelpers::gui_BaseMoveCursorUsingPoint(), mcEmptyBoxHelpers::gui_DoRecalcSize(), mcNumberHelpers::gui_GetBaseRelCursorPos(), gui_GetSizeOfChar(), and mcParenthesisHelpers::gui_RebuildFont().

double mcElementHelpers::gui_GetPointSize  )  [static]
 

Returns the style for the n-th exponent level.

This function is static, so it can be used in this way:

 */
 //| [...]   mcElementHelpers::sgui_GetStyle(0).[...]
 //! 
static const mcStyle *gui_GetDefaultStyle(int n);

/** Returns the number of pixels per point size using the current screen settings to compute them. This is an utility function used by gui_PointSize2Pixels & gui_Pixels2PointSize.

Definition at line 876 of file Element.cpp.

Referenced by gui_Pixels2PointSize(), and gui_PointSize2Pixels().

virtual int mcElementHelpers::gui_GetRelCursorPos wxDC &  dc,
wxPoint *  pt
const [pure 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.

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathLineHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcOperatorHelpers, and mcTextHelpers.

mcElement mcElementHelpers::gui_GetSelection  )  const [virtual]
 

Returns the selected portion of this element.

If this element is entirely selected (this is the default for non-container elements), the entire element should be returned (this is what the default implementation does). Container elements should override this function returning only the selected elements (in mcMonomials, mcBrackets, mcPolynomials...) or the entire element itself if it is entirely selected. This functions returns an object and not a reference to an object (as for example does gui_GetActiveElem) because the selection cannot be modified through this function.

Reimplemented in mcElementArrayHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathAndSystemHelpers, mcMathLineHelpers, mcMathMngHelpers, and mcMathOrSystemHelpers.

Definition at line 673 of file Element.cpp.

References mcElement.

Referenced by mcMathSystemHelpers::gui_GetSelInlinedExpr().

virtual wxSize mcElementHelpers::gui_GetSize  )  [inline, virtual]
 

Returns the updated size (in pixels) of the element.

Note:
This function cannot be CONST because it could be forced to call the gui_RecalcSize() function; use the #GetConstSize() function instead.

Definition at line 1023 of file Element.h.

References gui_RecalcSize(), and mgui_sz.

virtual wxSize mcElementHelpers::gui_GetSize  )  const [inline, virtual]
 

Returns the size; the returned size can be not up-to-date (this function cannot update size if it is invalid, because this is a CONST function; use gui_RecalcSize() before calling this function to be sure to get updated results).

Definition at line 1009 of file Element.h.

References mgui_sz.

Referenced by mcExpContainerHelpers::gui_BaseMoveCursorUsingPoint(), mcFractionHelpers::gui_Draw(), mcExpElementHelpers::gui_Draw(), mcExpElementHelpers::gui_DrawActivationRect(), mcExpContainerHelpers::gui_DrawBase(), mcFractionHelpers::gui_GetRelCursorPos(), gui_GetYAnchor(), mcFractionHelpers::gui_MoveCursorUsingPoint(), mcExpContainerHelpers::gui_OnBaseSelect(), mcFractionHelpers::gui_OnSelect(), and mcExpElementHelpers::gui_OnSelect().

wxSize mcElementHelpers::gui_GetSizeOf wxDC *  dc,
const wxString &  str
[static]
 

Returns the string height and width (using the selected font to determine them).

Parameters:
dc A valid pointer to the DC whose selected font will be used to calculate string size, or a NULL value to use a temporary DC.
str The string whose size will be calculated.

Definition at line 985 of file Element.cpp.

References mcASSERT, and mcGUILOG.

Referenced by mcSymbolHelpers::gui_DoRecalcBaseSize(), mcNumberHelpers::gui_DoRecalcBaseSize(), mcBracketHelpers::gui_DoRecalcBaseSize(), mcParenthesisHelpers::gui_DoRecalcSize(), gui_GetHeightOf(), gui_GetWidthOf(), mcMathMngHelpers::gui_RecalcSeparatorSize(), mcMathOrSystemHelpers::gui_RecalcSymbolSize(), and mcMathAndSystemHelpers::gui_RecalcSymbolSize().

wxSize mcElementHelpers::gui_GetSizeOfChar wxDC *  dc = NULL,
const mcElement p = mcEmptyElement
const
 

Returns the size of a character (assume that fonts used are fixed pitch fonts and thus all characters have the same size) in the style used by the given pointer;.

Parameters:
dc A valid pointer to the DC which will be used to select the style of the element and to calculate the character size, or a NULL value to use a temporary DC.
p The element whose style will be used to calculate the char size; if you use a NULL pointer, currently selected style will be used

Definition at line 1024 of file Element.cpp.

References gui_GetHeightOfChar(), and gui_GetWidthOfChar().

const mcStyle * mcElementHelpers::gui_GetStyle int  n  )  const
 

Returns the style associated with the n-th exponent depth using the style array owned by this element.

If you want to get the default style for the n-th exponent depth, you can use the #gui_GetDefaultStyle() function.

Definition at line 940 of file Element.cpp.

References mcStyleArray::Get(), and mgui_pStyleArray.

Referenced by mcMathMngHelpers::gui_SelectSeparatorStyle().

const mcStyleArray* mcElementHelpers::gui_GetStyleArray  )  const [inline]
 

Returns the style array associated with this element.

Definition at line 1168 of file Element.h.

References mgui_pStyleArray.

Referenced by mcOperatorHelpers::gui_DoRecalcSize().

const mcStyle * mcElementHelpers::gui_GetStyleForThis  )  const
 

The style used to draw each element is chosen using the element's exponent level; use this function to retrieve the style which should be used for the currentelement.

VERY IMPORTANT: the style shouldn't be stored in any variable; it should be chosen on the fly during draw functions (style could change between two 'steps').

Returns:
A pointer to the style for the given element

Definition at line 931 of file Element.cpp.

References mcStyleArray::gui_GetStyleFor(), and mgui_pStyleArray.

Referenced by gui_SelectStyle().

int mcElementHelpers::gui_GetSubscriptOffsety int  h  )  const
 

Returns the num of pixels between the base's bottom border and the subscript's (of the base) bottom border.

Parameters:
h The height (in pixels) of the subscript.

Definition at line 924 of file Element.cpp.

Referenced by mcExpElementHelpers::gui_GetExpSubOffsety().

int mcElementHelpers::gui_GetThickness wxDC *  dc  )  const
 

Returns the thickness (in pixels) the caller should use to draw decoration elements (for example, the fraction line).

Parameters:
dc A valid pointer to the DC which will be used to select the style of the element and to calculate the default thickness, or a NULL value to use a temporary DC.

Definition at line 962 of file Element.cpp.

References gui_SelectStyle(), and mcGUILOG.

Referenced by mcRadicalHelpers::gui_DoRecalcBaseSize(), mcFractionHelpers::gui_Draw(), mcRadicalHelpers::gui_DrawContainer(), mcRadicalHelpers::gui_GetContentOffsetY(), and mcFractionHelpers::gui_GetYAnchor().

virtual int mcElementHelpers::gui_GetWidth  )  [inline, virtual]
 

Returns the updated width, in pixels, of this element.

Note:
This function cannot be CONST because it could be forced to call the gui_RecalcSize() function; use the #GetConstSize() function instead.

Definition at line 1034 of file Element.h.

References gui_RecalcSize(), and mgui_sz.

virtual int mcElementHelpers::gui_GetWidth  )  const [inline, virtual]
 

Returns the width of the element.

See #GetConstSize() for some important info about the usage of this function.

Definition at line 1013 of file Element.h.

References mgui_sz.

Referenced by mcMathMngHelpers::gui_DoRecalcSize(), mcFractionHelpers::gui_DoRecalcSize(), mcParenthesisHelpers::gui_Draw(), mcMathSystemHelpers::gui_Draw(), mcFractionHelpers::gui_Draw(), mcEmptyBoxHelpers::gui_Draw(), mcMathSystemHelpers::gui_DrawBmp(), mcMathLineHelpers::gui_DrawBmp(), mcRadicalHelpers::gui_DrawContainer(), mcElementArrayHelpers::gui_ExDraw(), mcMathLineHelpers::gui_ExpandBmp(), mcMathSystemHelpers::gui_GetBmp(), mcFractionHelpers::gui_GetDenPos(), mcExpElementHelpers::gui_GetExpSubRelCursorPos(), mcFractionHelpers::gui_GetNumPos(), mcMathSystemHelpers::gui_GetRectOf(), mcMathMngHelpers::gui_GetRectOfLeftMem(), mcMathMngHelpers::gui_GetRectOfRightMem(), mcEmptyBoxHelpers::gui_GetRelCursorPos(), mcDecorationHelpers::gui_GetRelCursorPos(), mcMathSystemHelpers::gui_GetXOf(), and mcMathSystemHelpers::gui_GetXOfSymbol().

int mcElementHelpers::gui_GetWidthOf wxDC *  ,
const wxString & 
[static]
 

Returns only the width of ::gui_GetSizeOf.

Definition at line 1016 of file Element.cpp.

References gui_GetSizeOf().

Referenced by mcTextHelpers::gui_DoRecalcSize(), mcOperatorHelpers::gui_DoRecalcSize(), mcNumberHelpers::gui_GetBaseRelCursorPos(), and mcTextHelpers::gui_GetRelCursorPos().

int mcElementHelpers::gui_GetWidthOfChar wxDC *  ,
const mcElement
const
 

Returns only the width of gui_GetSizeOfChar.

Definition at line 1029 of file Element.cpp.

References mcASSERT, and mcGUILOG.

Referenced by mcNumberHelpers::gui_BaseMoveCursorUsingPoint(), mcEmptyBoxHelpers::gui_DoRecalcSize(), and gui_GetSizeOfChar().

virtual int mcElementHelpers::gui_GetYAnchor  )  const [inline, virtual]
 

Returns the y amount of this mcElement to subtract from the center line to draw this element.

Reimplemented in mcElementArrayHelpers, mcExpContainerHelpers, mcExpElementHelpers, mcFractionHelpers, and mcMathMngHelpers.

Definition at line 1051 of file Element.h.

References gui_GetSize().

void mcElementHelpers::gui_Init  )  [protected, virtual]
 

Inits this section of the element.

Acts like a constructor (it's called by mcElementHelpers).

Reimplemented in mcDecorationHelpers, mcElementArrayHelpers, mcExpContainerHelpers, mcExpElementHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathLineHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcNumberHelpers, mcPolynomialHelpers, mcSymbolHelpers, and mcTextHelpers.

Definition at line 608 of file Element.cpp.

References gui_RecalcSize(), mcASSERT, mgui_bSelected, mgui_pStyleArray, mgui_sz, mcStyleArray::Set(), and sgui_pDefaultStyles.

Referenced by data_Init(), mcMathSystemHelpers::gui_Init(), mcMathMngHelpers::gui_Init(), mcFractionHelpers::gui_Init(), mcExpElementHelpers::gui_Init(), mcElementArrayHelpers::gui_Init(), and mcDecorationHelpers::gui_Init().

void mcElementHelpers::gui_InitDefaultStyles  )  [static]
 

Resets the style array to the defaults, eventually deleting previous styles.

This function should be called at the beginning of the program, before styles are used.

See also:
mcMathCore::Setup()

Definition at line 785 of file Element.cpp.

References gui_DeleteDefaultStyles(), mcASSERT, mcET_ADDOP, mcET_FUNCTION, mcET_NUMBER, mcET_SYMBOL, mcET_TEXT, mcGUILOG, mcINITWX, mcStyle::Ok(), mcStyleArray::Set(), mcStyle::SetSpecialTextSettings(), mcStyle::SetTextSettingsFor(), and sgui_pDefaultStyles.

Referenced by mcMathCore::SetupGUI().

virtual mcInputRes mcElementHelpers::gui_Input const mcKey ev,
mcElement newelem
[pure 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).

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, mcOperatorHelpers, mcParenthesisHelpers, mcPolynomialHelpers, and mcTextHelpers.

virtual mcInsertRes mcElementHelpers::gui_Insert const mcElement toinsert,
mcElement newelem
[pure virtual]
 

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

Implemented in mcDecorationHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, and mcPolynomialHelpers.

bool mcElementHelpers::gui_isAllSelected  )  const [virtual]
 

Returns TRUE only if the element and all its children are completely selected.

This is a recursive function.

Definition at line 735 of file Element.cpp.

References data_GetChildrenCount(), data_GetConstChild(), and gui_isSelected().

Referenced by mcElementArrayHelpers::gui_DeleteSelection(), gui_DeleteSelection(), mcExpContainerHelpers::gui_DrawBase(), mcElementArrayHelpers::gui_DrawSelection(), mcPolynomialHelpers::gui_ExOnSelect(), mcFractionHelpers::gui_GetSelection(), and mcExpElementHelpers::gui_GetSelection().

virtual bool mcElementHelpers::gui_isBeginKey const mcKey ev  )  const [pure virtual]
 

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

The begin character cannot be dependent from any variable; it must be always the same. The character is given both as ASCII code and as virtual key code.

Parameters:
ev The wxWidgets key event for the keypress. It contains the untraslated code for the input key; see wxWidgets KeyCodes for more info.
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.

Implemented in mcBracketHelpers, mcDecorationHelpers, mcEmptyBoxHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, mcMultDivOpHelpers, mcNumberHelpers, mcOperatorHelpers, mcParenthesisHelpers, mcPolynomialHelpers, mcRadicalHelpers, mcSymbolHelpers, and mcTextHelpers.

Referenced by mcExpContainerHelpers::gui_BaseInput(), and gui_isKeyBeginKey().

virtual bool mcElementHelpers::gui_isEndKey const mcKey ev  )  const [pure virtual]
 

Returns TRUE if the given character marks the end of this element; this function is always called before calling ::gui_Input function.

isEndChar can return values dependent from the cursor position. The character is given both as ASCII code and as virtual key code

Parameters:
ev The wxWidgets key event for the keypress. It contains the untraslated code for the input key; see wxWidgets KeyCodes for more info.

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcOperatorHelpers, and mcTextHelpers.

mcElementType mcElementHelpers::gui_isKeyBeginKey const mcKey ev  )  [static]
 

Returns the identifier code (mcET_****) of the class that uses the given char as begin char; mcET_INVALID if the function can't find any result.

If you specify a pointer for the last argument, and the class found has derived classes, subtype will be set to the subtype identifier code for that class.

Definition at line 456 of file Element.cpp.

References gui_isBeginKey(), and SCAN_REGISTERED_CLASSES.

Referenced by mcPolynomialHelpers::gui_Input(), mcElementArrayHelpers::gui_Input(), mcMonomialHelpers::gui_isArrEndKey(), and mcEmptyBoxHelpers::gui_isEndKey().

virtual bool mcElementHelpers::gui_isSelected  )  const [inline, virtual]
 

Returns TRUE if this element is selected (totally or partially).

This is a very quick function because all the elements owns a specific flag for selection state.

Definition at line 978 of file Element.h.

References mgui_bSelected.

Referenced by mcElementArrayHelpers::gui_ExDraw(), mcElementArrayHelpers::gui_GetActiveElemIndex(), mcMathOrSystemHelpers::gui_GetSelection(), mcMathMngHelpers::gui_GetSelection(), mcMathAndSystemHelpers::gui_GetSelection(), mcExpElementHelpers::gui_GetSelection(), gui_isAllSelected(), mcElementArrayHelpers::gui_MoveCursor(), mcExpContainerHelpers::gui_OnBaseSelect(), mcMathSystemHelpers::gui_OnSelect(), mcMathMngHelpers::gui_OnSelect(), mcFractionHelpers::gui_OnSelect(), and mcExpElementHelpers::gui_OnSelect().

virtual bool mcElementHelpers::gui_isSplittable  )  const [inline, virtual]
 

Returns TRUE if this element supports splitting and, thus, also merging.

The default implementation returns FALSE because this is a quite unused feature. Elements which override this function and return TRUE, must override also the gui_Split() and gui_MergeWith() functions to actually do the work...

Reimplemented in mcNumberHelpers.

Definition at line 961 of file Element.h.

Referenced by mcMonomialHelpers::gui_MergeWith().

virtual bool mcElementHelpers::gui_LetInCursor mcCursorPos  code  )  [inline, virtual]
 

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().

Parameters:
code The position where the cursor must be placed in this element: if mcCP_END, then the cursor is assumed to be entering from right; if mcCP_BEGIN, the cursor is assumed to be entering from left.

Reimplemented in mcOperatorHelpers.

Definition at line 991 of file Element.h.

References gui_SetCursorPos().

Referenced by mcElementArrayHelpers::gui_MoveCursorLeft(), and mcElementArrayHelpers::gui_MoveCursorRight().

virtual bool mcElementHelpers::gui_MergeWith const mcElement  )  [inline, virtual]
 

Merges the given element with this object.

Like splitting, very few elements support merging, but those elements which handles splitting, should also handle merging... see gui_Split(). The function should merge the given element in *this and return TRUE if everything was okay; FALSE if the merging could not be done (because, for example, the given element is not of the right type...).

Reimplemented in mcMonomialHelpers, and mcNumberHelpers.

Definition at line 952 of file Element.h.

virtual mcMoveCursorRes mcElementHelpers::gui_MoveCursor mcMoveCursorFlag  flag,
long  modifiers
[pure 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)

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcOperatorHelpers, and mcTextHelpers.

virtual int mcElementHelpers::gui_MoveCursorUsingPoint wxDC &  dc,
const wxPoint &  p
[pure 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

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathLineHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcOperatorHelpers, and mcTextHelpers.

virtual void mcElementHelpers::gui_OnParentSizeChange  )  [inline, virtual]
 

Called by parent when parent's size changes.

Override this function if you need to do something when parent's size changes (remember to set up the flag mcEP_NOTIFY_PARENTSIZE_CHANGE in the constructor).

Definition at line 903 of file Element.h.

void mcElementHelpers::gui_OnRecalcSize wxSize  old  )  [virtual]
 

Called by the mcElementHelpers::sgui_RecalcSize.

Definition at line 200 of file Element.cpp.

References mgui_sz.

Referenced by gui_RecalcSize().

virtual void mcElementHelpers::gui_OnSelect wxDC &  ,
wxRect &  rc
[inline, 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 in mcElementArrayHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathLineHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcPolynomialHelpers, and mcTextHelpers.

Definition at line 852 of file Element.h.

References gui_Select().

double mcElementHelpers::gui_Pixels2PointSize double  pointsize  )  [static]
 

Utility function: use it to convert pixels to point size units.

Point size units is the type of unit used by wxWidgets font functions. See also the gui_PointSize2Pixels function.

Definition at line 911 of file Element.cpp.

References gui_GetPointSize().

double mcElementHelpers::gui_PointSize2Pixels double  pointsize  )  [static]
 

Utility function: use it to convert point size units to pixels units.

Point size units is the type of unit used by wxWidgets font functions.

Definition at line 901 of file Element.cpp.

References gui_GetPointSize().

void mcElementHelpers::gui_RecalcSize  )  [virtual]
 

Recalculates the size of the element, calling in any case the mcElement::gui_OnRecalcSize function.

See gui_DoRecalcSize() for more info.

Definition at line 694 of file Element.cpp.

References gui_DoRecalcSize(), gui_OnRecalcSize(), and mgui_sz.

Referenced by mcPolynomialHelpers::gui_AddNewElement(), mcMonomialHelpers::gui_AddNewElement(), mcSymbolHelpers::gui_BaseInput(), mcNumberHelpers::gui_BaseInput(), mcFunctionHelpers::gui_BaseInput(), mcExpContainerHelpers::gui_BaseInput(), mcExpElementHelpers::gui_CheckExpSub(), gui_DeepRecalcSize(), mcMathMngHelpers::gui_DeleteSelection(), mcFractionHelpers::gui_DeleteSelection(), mcElementArrayHelpers::gui_DeleteSelection(), gui_DeleteSelection(), mcExpElementHelpers::gui_EditExpSub(), mcExpElementHelpers::gui_ExpSubInput(), gui_GetHeight(), gui_GetSize(), gui_GetWidth(), mcExpContainerHelpers::gui_HandleContentInput(), gui_Init(), mcPolynomialHelpers::gui_Input(), mcParenthesisHelpers::gui_Input(), mcOperatorHelpers::gui_Input(), mcMathSystemHelpers::gui_Input(), mcMathMngHelpers::gui_Input(), mcFractionHelpers::gui_Input(), mcEmptyBoxHelpers::gui_Input(), mcElementArrayHelpers::gui_Input(), mcDecorationHelpers::gui_Input(), mcMathSystemHelpers::gui_Insert(), mcNumberHelpers::gui_MergeWith(), mcMonomialHelpers::gui_MergeWith(), mcParenthesisHelpers::gui_RebuildFont(), mcMonomialHelpers::gui_ReplaceSymbolsWithFunction(), mcFunctionHelpers::gui_Setup(), mcNumberHelpers::gui_Split(), mcMonomialHelpers::gui_Split(), and gui_UpdateExpDepth().

virtual void mcElementHelpers::gui_Select  )  [inline, virtual]
 

Sets this element as selected.

This function doesn't call the #data_Updategui_SelectionState() function because the gui_OnSelect() function should care about setting up the selection states for the member classes. Use this function with attention.

Definition at line 969 of file Element.h.

References mgui_bSelected.

Referenced by mcSymbolHelpers::gui_BaseMoveCursor(), mcElementArrayHelpers::gui_ExOnSelect(), mcElementArrayHelpers::gui_MoveCursor(), mcExpContainerHelpers::gui_OnBaseSelect(), mcMathSystemHelpers::gui_OnSelect(), mcMathMngHelpers::gui_OnSelect(), mcFractionHelpers::gui_OnSelect(), mcExpElementHelpers::gui_OnSelect(), gui_OnSelect(), and gui_SelectAll().

void mcElementHelpers::gui_SelectAll  )  [virtual]
 

gui_Selects the entire element and all its children.

This is a recursive function.

Definition at line 715 of file Element.cpp.

References data_GetChild(), data_GetChildrenCount(), gui_Select(), and mcElement::gui_SelectAll().

Referenced by mcExpElementHelpers::gui_OnBaseSelect(), mcFractionHelpers::gui_OnSelect(), and mcExpElementHelpers::gui_OnSelect().

void mcElementHelpers::gui_SelectStyle wxDC &  dc  )  const
 

Automatically selects the style for the given element in the given DC, recognizing its mcElementType.

Parameters:
dc The device context where the style will be selected

Definition at line 950 of file Element.cpp.

References gui_GetStyleForThis(), mcStyle::gui_Select(), and mcASSERT.

Referenced by mcSymbolHelpers::gui_DoRecalcBaseSize(), mcNumberHelpers::gui_DoRecalcBaseSize(), mcTextHelpers::gui_DoRecalcSize(), mcTextHelpers::gui_Draw(), mcParenthesisHelpers::gui_Draw(), mcOperatorHelpers::gui_Draw(), mcMultDivOpHelpers::gui_Draw(), mcSymbolHelpers::gui_DrawBase(), mcNumberHelpers::gui_DrawBase(), mcBracketHelpers::gui_DrawContainer(), mcMathOrSystemHelpers::gui_DrawSystemSymbols(), mcMathAndSystemHelpers::gui_DrawSystemSymbols(), mcNumberHelpers::gui_GetBaseRelCursorPos(), mcTextHelpers::gui_GetRelCursorPos(), gui_GetThickness(), mcTextHelpers::gui_MoveCursorUsingPoint(), mcMathOrSystemHelpers::gui_RecalcSymbolSize(), and mcMathAndSystemHelpers::gui_RecalcSymbolSize().

void mcElementHelpers::gui_SetAsExpOf const mcElement p  ) 
 

Sets this element as exponent of the given pointer.

This function automatically calls the gui_UpdateExpDepth() function.

Parameters:
p The element which will be the base of the current element.

Definition at line 767 of file Element.cpp.

References mcElement::gui_GetExpDepth(), gui_UpdateExpDepth(), mcEmptyElement, and mgui_nExpDepth.

void mcElementHelpers::gui_SetAtSameLevelOf const mcElement p  ) 
 

Sets this element at the same level of the given element.

For 'level', I mean exponent depth. This function is called at least once just after the creation of the element. This function automatically calls the gui_UpdateExpDepth() function.

Parameters:
p The element from which exponent depth will be copied.

Definition at line 776 of file Element.cpp.

References mcElement::gui_GetExpDepth(), gui_UpdateExpDepth(), mcEmptyElement, and mgui_nExpDepth.

virtual void mcElementHelpers::gui_SetCursorPos const mcCursorPos code  )  [pure 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.

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcOperatorHelpers, mcPolynomialHelpers, and mcTextHelpers.

Referenced by gui_LetInCursor().

void mcElementHelpers::gui_SetExpDepth int  n  )  [inline]
 

Sets the exponent depth of this element.

This function automatically calls the gui_UpdateExpDepth() function.

Definition at line 1158 of file Element.h.

References gui_UpdateExpDepth(), and mgui_nExpDepth.

void mcElementHelpers::gui_SetStyleArray const mcStyleArray p  )  [virtual]
 

Changes recursively the styles of this element and the styles of all its children.

Definition at line 212 of file Element.cpp.

References data_GetChild(), data_GetChildrenCount(), mcElement::gui_SetStyleArray(), and mgui_pStyleArray.

virtual bool mcElementHelpers::gui_Split mcElement p  )  [inline, virtual]
 

gui_Splits this element in two parts.

The first is stored in this element, the second is returned as a pointer (the caller must then delete it when it's no longer necessary). The split point must be determined using the current cursor position. This function has a sense only for few elements, see as an example mcNumber::gui_Split: when the user tries to insert a new operator like '/' and the cursor is inside a number, the number is split in two parts and this function is used to get the second half. If the cursor is placed in at the leftmost/rightmost point of the element and, thus, the first/second half of the element would be empty, then the function should return NULL. The classes that cannot be splitted should return NULL. This is what the standard implementation does.

Returns:
TRUE if *this must be deleted; FALSE if it must be kept.

Reimplemented in mcMonomialHelpers, and mcNumberHelpers.

Definition at line 944 of file Element.h.

void mcElementHelpers::gui_UpdateExpDepth  )  [virtual]
 

Called by mcElement's standard functions to update the exponent depth of member classes.

Override this function if you need to update member variables when the exponent level of this element changes (this happens each time gui_SetExpDepth() function is called; thus this happens each time gui_SetAsExpOf or gui_SetAtSameLevelOf functions are called).

Note:
This function DOES NOT call the gui_RecalcSize() function, even if probably it is required after such function.

Reimplemented in mcElementArrayHelpers, mcExpContainerHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, and mcTextHelpers.

Definition at line 513 of file Element.cpp.

References gui_RecalcSize().

Referenced by gui_SetAsExpOf(), gui_SetAtSameLevelOf(), gui_SetExpDepth(), mcTextHelpers::gui_UpdateExpDepth(), mcMathSystemHelpers::gui_UpdateExpDepth(), mcMathMngHelpers::gui_UpdateExpDepth(), mcFractionHelpers::gui_UpdateExpDepth(), mcExpElementHelpers::gui_UpdateExpDepth(), and mcElementArrayHelpers::gui_UpdateExpDepth().

void mcElementHelpers::Init  )  [static]
 

Inits all the static data of mcElement.

Definition at line 353 of file Element.cpp.

References data_UpdateElemArray(), mcNUM_ELEMENT_TYPES, and sdata_pElem.

Referenced by mcFunctionHelpers::gui_BaseInput(), and mcMathCore::Init().

virtual wxString mcElementHelpers::io_GetInlinedExpr  )  const [pure 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", ....

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcOperatorHelpers, mcPolynomialHelpers, mcRadicalHelpers, and mcTextHelpers.

virtual wxXml2Node mcElementHelpers::io_GetMathML bool  bGetPresentation  )  const [pure 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.

Implemented in mcDecorationHelpers, mcEmptyBoxHelpers, mcExpElementHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, mcMultDivOpHelpers, mcOperatorHelpers, mcPolynomialHelpers, mcRadicalHelpers, and mcTextHelpers.

virtual bool mcElementHelpers::io_ImportInlinedExpr const wxString &  str,
int *  count,
wxString &  pErr
[pure 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.

Implemented in mcDecorationHelpers, mcExpElementHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, mcOperatorHelpers, mcParenthesisHelpers, mcPolynomialHelpers, and mcTextHelpers.

Referenced by io_Init().

virtual bool mcElementHelpers::io_ImportPresentationMathML wxXml2Node  tag,
wxString &  pErr
[pure 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).

Implemented in mcDecorationHelpers, mcEmptyBoxHelpers, mcExpContainerHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, mcMultDivOpHelpers, mcNumberHelpers, mcOperatorHelpers, mcParenthesisHelpers, mcPolynomialHelpers, mcRadicalHelpers, mcSymbolHelpers, and mcTextHelpers.

bool mcElementHelpers::io_Init const wxString &  str  )  [virtual]
 

Inits this element with the given INLINED expression; for more info about inlined expressions, see the mcElement::io_ImportInlinedExpr function.

If the given string is not valid for this element as init string, then this function returns FALSE.

Definition at line 187 of file Element.cpp.

References io_ImportInlinedExpr(), and io_isBeginChar().

virtual void mcElementHelpers::io_Init  )  [inline, protected, virtual]
 

Initializes the IO section of this element.

Definition at line 1672 of file Element.h.

Referenced by data_Init().

virtual bool mcElementHelpers::io_isBeginChar const wxString &  str  )  const [pure 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.

Implemented in mcBracketHelpers, mcDecorationHelpers, mcElementArrayHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcNumberHelpers, mcOperatorHelpers, mcParenthesisHelpers, mcRadicalHelpers, mcSymbolHelpers, and mcTextHelpers.

Referenced by io_Init(), and io_isCharBeginChar().

virtual bool mcElementHelpers::io_isBeginTag const wxXml2Node &  tag  )  const [pure 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

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcEmptyBoxHelpers, mcExpContainerHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcNumberHelpers, mcOperatorHelpers, mcParenthesisHelpers, mcRadicalHelpers, mcSymbolHelpers, and mcTextHelpers.

Referenced by io_isTagBeginTag().

mcElementType mcElementHelpers::io_isCharBeginChar const wxString &  str  )  [static]
 

Definition at line 460 of file Element.cpp.

References io_isBeginChar(), and SCAN_REGISTERED_CLASSES.

Referenced by mcPolynomialHelpers::io_ImportInlinedExpr(), and mcMonomialHelpers::io_ImportInlinedExpr().

mcElementType mcElementHelpers::io_isTagBeginTag const wxXml2Node &  tag  )  [static]
 

Definition at line 464 of file Element.cpp.

References io_isBeginTag(), and SCAN_REGISTERED_CLASSES.

Referenced by mcMonomialHelpers::io_ImportPresentationMathML().

virtual void mcElementHelpers::io_PostProcess  )  [inline, protected, virtual]
 

Post-processes this element after the import-process.

This function will be called after the entire process performed by io_ImportInlinedExpr and io_ImportPresentationMathML and thus when all the data tree has already been built (from this function you can access neighbor elements, for example).

Reimplemented in mcMonomialHelpers.

Definition at line 1679 of file Element.h.

void mcElementHelpers::io_PostProcessChildren  )  [protected, virtual]
 

Calls the io_PostProcess functions of all the children of this element; call this one just before exiting #io_ImportInlinedExpr and #io_ImportPresentationMathML.

Definition at line 1093 of file Element.cpp.

References data_GetChild(), and data_GetChildrenCount().

Referenced by mcPolynomialHelpers::io_ImportInlinedExpr(), mcMonomialHelpers::io_ImportInlinedExpr(), mcFunctionHelpers::io_ImportInlinedExpr(), and mcMonomialHelpers::io_ImportPresentationMathML().

virtual mcBasicOpRes mcElementHelpers::math_Add const mcElement e,
mcElement pp,
bool  add = TRUE
[pure virtual]
 

Sums or subtracts this element with the given e element.

A unique function for add/subtract operations is used because the algorithms used to handle this two operations are usually almost identic and thus this avoids a lot of repetitions.

If the two elements cannot be summed, then an ASSERT should fail since before using this function, the caller should always use the math_CanBeAddedWith() function.

The function returns one of mcBasicOpRes values, eventually using the pp pointer to store the replacement element which will be used by the caller in case this function returns mcBOR_REPLACE_OPERAND or mcBOR_REPLACE_BOTH.

Implemented in mcDecorationHelpers, mcExpContainerHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, mcNumberHelpers, mcPolynomialHelpers, and mcSymbolHelpers.

Referenced by math_SimpleAdd(), and math_Subtract().

virtual bool mcElementHelpers::math_CanBeAddedWith const mcElement p  )  const [pure virtual]
 

Returns TRUE if this element can be added with the given element.

If the function returns TRUE, then the math_Add() function should return one of mcBOR_REMOVE_OPERAND, mcBOR_REPLACE_BOTH or mcBOR_REPLACE_OPERAND.

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcExpContainerHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, mcNumberHelpers, and mcSymbolHelpers.

virtual bool mcElementHelpers::math_CanBeDivBy const mcElement p  )  const [pure virtual]
 

Works like #math_CanBemath_AddeWith(), just for divisions.

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcExpContainerHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcNumberHelpers, and mcSymbolHelpers.

Referenced by mcExpElementHelpers::math_DivideBy().

virtual bool mcElementHelpers::math_CanBeMultWith const mcElement p  )  const [pure virtual]
 

Works like #math_CanBemath_AddeWith(), just for multiplication.

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcExpContainerHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcNumberHelpers, and mcSymbolHelpers.

Referenced by mcExpElementHelpers::math_MultiplyBy().

virtual bool mcElementHelpers::math_Compare const mcElement p,
long  flags
const [pure virtual]
 

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.

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, and mcOperatorHelpers.

Referenced by math_GetCountOf(), math_NonRecursiveFindInChildren(), and math_RecursiveFind().

bool mcElementHelpers::math_CompareThisOnly const mcElement p,
long  flags
const [virtual]
 

Compares this element and the given one and then stops, unlike math_Compare() that compares children too.

Reimplemented in mcElementArrayHelpers, mcExpContainerHelpers, mcMathMngHelpers, mcNumberHelpers, mcSymbolHelpers, and mcTextHelpers.

Definition at line 1414 of file Element.cpp.

References data_GetType().

Referenced by mcMathSystemHelpers::math_Compare(), mcExpElementHelpers::math_Compare(), math_GetCountOf(), mcExpElementHelpers::math_GetGCD(), mcExpElementHelpers::math_GetLCM(), mcExpElementHelpers::math_MultOrDiv(), and math_RecursiveFind().

bool mcElementHelpers::math_Contains const mcElement p,
long  flags = mcFIND_NOFLAGS
const [virtual]
 

Returns TRUE if the given element is contained inside this one.

While #hasSameContentOf returns TRUE if the two elements involved have exactly the same contents (nothing more, nothing less), this function returns TRUE even if the given element is only a subset of those contained. This function does *not* work with math_MaxSimplify()ed copies of the two elements involved.

Some examples:

  • the polynomial wxT("2x+5^2") contains "x"
  • the monomial wxT("(8^3)*(1/y)") contains wxT("3") but it doesn't contain "y^(-1)"
  • the polynomial wxT("x^7+x^x") contains 3 times "x"

Definition at line 1299 of file Element.cpp.

References math_Find(), and mcEmptyElement.

Referenced by math_ContainsNumber(), math_ContainsOneOf(), math_ContainsSymbol(), and mcPolynomialHelpers::math_GetCoeffOf().

bool mcElementHelpers::math_ContainsConstants  )  const [virtual]
 

Like math_ContainsUnknowns() but the array checked is mcSymbol::arrConstants.

Definition at line 1356 of file Element.cpp.

References math_ContainsOneOf().

Referenced by math_ContainsSymbols().

bool mcElementHelpers::math_ContainsInvalidSymbols  )  const [virtual]
 

Returns TRUE if this element contains unregistered symbols.

Reimplemented in mcMathMngHelpers.

Definition at line 1370 of file Element.cpp.

References math_ContainsOneOf().

bool mcElementHelpers::math_ContainsNumber const mcRealValue n,
const mcPolynomial exp = mcEmptyPolynomial
const [virtual]
 

Definition at line 1302 of file Element.cpp.

References mcExpElement::data_SetExpSub(), math_Contains(), and mcEmptyPolynomial.

bool mcElementHelpers::math_ContainsOneOf const mcSymbolArray  )  const
 

Returns TRUE if one of the symbols registered in the given array is contained inside this element.

Definition at line 1327 of file Element.cpp.

References mcSymbolProperties::data_GetSafeLinkedSym(), and math_Contains().

Referenced by math_ContainsConstants(), math_ContainsInvalidSymbols(), math_ContainsParameters(), and math_ContainsUnknowns().

bool mcElementHelpers::math_ContainsParameters  )  const [virtual]
 

Like math_ContainsUnknowns() but the array checked is mcSymbol::arrParameters.

Definition at line 1359 of file Element.cpp.

References math_ContainsOneOf().

Referenced by math_ContainsSymbols(), and math_isConstant().

bool mcElementHelpers::math_ContainsSymbol const mcSymbolProperties s,
const mcPolynomial exp = mcEmptyPolynomial
const [virtual]
 

Returns TRUE if this element contains the given type of.

Definition at line 1314 of file Element.cpp.

References mcExpElement::data_SetExpSub(), math_Contains(), mcASSERT, and mcEmptyPolynomial.

Referenced by mcPolynomialHelpers::math_FactoreOut(), mcPolynomialHelpers::math_FactoreOutFreeOf(), and math_GetCountOfSymbolsType().

bool mcElementHelpers::math_ContainsSymbols  )  const [virtual]
 

Returns TRUE if this element contains at least one unknown/constant/parameter.

This function does not check for unregistered symbols...

Definition at line 1362 of file Element.cpp.

References math_ContainsConstants(), math_ContainsParameters(), and math_ContainsUnknowns().

bool mcElementHelpers::math_ContainsUnknowns  )  const [virtual]
 

Returns TRUE if this element contains one or more unknowns.

The unknowns which are checked are those registered in mcSymbol::arrUnknowns. This function performs a recursive search in this element.

Definition at line 1353 of file Element.cpp.

References math_ContainsOneOf().

Referenced by math_ContainsSymbols(), mcRadicalHelpers::math_GetBaseMathType(), mcFractionHelpers::math_GetMathType(), math_isConstant(), and mcMonomialHelpers::math_RemoveCoeff().

virtual mcBasicOpRes mcElementHelpers::math_DivideBy const mcElement e,
mcElement pp
[pure virtual]
 

Divides two mcElements of the same type and stores the result in this object.

Parameters:
p A pointer to a mcElement of the same type of this mcElement, which will be used to divide this mcElement.

Implemented in mcDecorationHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, and mcPolynomialHelpers.

Referenced by math_SimpleDivideBy().

virtual mcRealValue mcElementHelpers::math_Evaluate  )  const [pure virtual]
 

Evaluates the numeric value of this element and then returns it.

The evaluation can proceed *only* if this element does _not_ contain any parameter or unknown; in case it contains one of these, then the returned value is *mcRealValue::pNAN.

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, and mcRadicalHelpers.

Referenced by math_EvaluateAt(), math_EvaluatesTo(), and math_isFinite().

mcRealValue mcElementHelpers::math_EvaluateAt const mcSymbolProperties sym,
const mcRealValue symval
const [virtual]
 

Returns the result of the math_Evaluate function called on a copy of this element with the given symbol substituted by the given value.

Definition at line 1718 of file Element.cpp.

References mcSymbol::data_LinkWith(), mcSymbolProperties::m_bEvaluating, mcSymbolProperties::m_fValue, math_Evaluate(), mcElement::math_Evaluate(), mcElement::math_Replace(), mcMATHLOG, mcTXTP, mcTXTTHIS, and mcTXTV.

virtual bool mcElementHelpers::math_EvaluatesTo const mcRealValue val  )  const [inline, virtual]
 

Returns TRUE if this element can be evaluated (see math_Evaluate()) and its value matches the given one.

Definition at line 1413 of file Element.h.

References math_Evaluate().

Referenced by mcElementArrayHelpers::math_SimplifyRemoveNeutrals().

virtual mcExpSimRes mcElementHelpers::math_Expand long  flags,
mcElement newelem
[pure virtual]
 

Expands this element one "step".

expanding means that the aim of this function is exactly the opposite of math_Simplify: instead making the function body shorter, it tries to make it as long as possible:

(x - 2)^3 . first call to math_Expand x^3 - 6x^2 + 12x -8

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, and mcMathSystemHelpers.

mcElement mcElementHelpers::math_Find int  n,
const mcElement p,
long  flags = mcFIND_NOFLAGS
const
 

Returns the n-th occurrence of an element with the same contents (this function uses #math_CompareWith, not #hasSameContentOf to perform the comparison !) or NULL if there is no an n-th occurrence of such an element.

The element to search is not required to be of the same type of *this, since this function recursively calls itself on the children of *this.

Definition at line 1422 of file Element.cpp.

References math_RecursiveFind(), and mcASSERT.

Referenced by math_Contains(), mcMonomialHelpers::math_GetMaxDegreeFor(), math_GetSymbolList(), and math_Replace().

mcElement mcElementHelpers::math_FindInChildrenOnly int  n,
const mcElement p,
long  flags = mcFIND_NOFLAGS
const
 

Works like math_Find() but its action is limited to the children (recursively) of *this only and not also *this.

Definition at line 1431 of file Element.cpp.

References math_RecursiveFindInChildrenOnly(), and mcASSERT.

int mcElementHelpers::math_GetCountOf const mcSymbolArray arr,
long  flags = mcFIND_NOFLAGS
const [virtual]
 

Returns the number of symbols belonging to the given mcSymbolArray are contained in *this element and its children (recursive search).

Definition at line 1582 of file Element.cpp.

References math_GetCountOf().

int mcElementHelpers::math_GetCountOf const mcSymbolProperties sym,
long  flags = mcFIND_NOFLAGS
const [virtual]
 

Returns the number of symbols of the given type contained in *this element and its children (recursive search).

Definition at line 1574 of file Element.cpp.

References math_GetCountOf(), and mcASSERT.

int mcElementHelpers::math_GetCountOf const mcElement p,
long  flags = mcFIND_NOFLAGS
const [virtual]
 

Returns the number of elements with the same contents of the given one contained into this one.

Reimplemented in mcMathMngHelpers.

Definition at line 1557 of file Element.cpp.

References data_GetChildrenCount(), data_GetConstChild(), math_Compare(), math_CompareThisOnly(), and math_GetCountOfChildrenOnly().

Referenced by math_GetCountOf(), and mcMonomialHelpers::math_GetMaxDegreeFor().

int mcElementHelpers::math_GetCountOfChildrenOnly const mcElement p,
long  flags = mcFIND_NOFLAGS
const [virtual]
 

Works like math_GetCountOf() but does not compare the given element with *this, just with the children of *this.

Definition at line 1547 of file Element.cpp.

References data_GetChildrenCount(), data_GetConstChild(), and mcElement::math_GetCountOf().

Referenced by math_GetCountOf().

int mcElementHelpers::math_GetCountOfSymbolsType const mcSymbolArray arr,
long  flags = mcFIND_NOFLAGS
const [virtual]
 

Unlike #math_GetCountOf(const mcSymbolArray *, long) this function does not return the total number of symbols contained: it returns how many *types* of symbols of the given array are contained into *this and its children (recursive search).

Eg: 4ax^2+bx+x -> math_GetCountOf(mcSymbol::arrUnknowns) = 3 (because "x" is repeated three times) -> math_GetCountOfSymbolsType(mcSymbol::arrUnknowns) = 1 (because only one type of unknown is used, "x") where wxT("x") is registered as unknown and wxT("a") and "b" are not.

Definition at line 1593 of file Element.cpp.

References math_ContainsSymbol().

mcMonomial mcElementHelpers::math_GetFactors  )  const [virtual]
 

Factores-out everything which can be factored out from this element.

Returns a mcPolynomial containing a copy of those elements factored-out. This function is CONST since many times not all the factores which can be taken out will be used and thus is caller's duty the modification of this element, eventually calling the math_DivideBy function.

Reimplemented in mcElementArrayHelpers, and mcExpContainerHelpers.

Definition at line 1284 of file Element.cpp.

References mcElementArray::math_WrapSimple().

virtual mcMonomial mcElementHelpers::math_GetGCD const mcElement  )  const [pure virtual]
 

Implemented in mcDecorationHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, mcNumberHelpers, and mcPolynomialHelpers.

virtual mcMonomial mcElementHelpers::math_GetLCM const mcElement  )  const [pure virtual]
 

Returns the LCM between *this and the given element.

Implemented in mcDecorationHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, and mcPolynomialHelpers.

virtual mcRealValue mcElementHelpers::math_GetLenght  )  const [pure virtual]
 

Returns the 'lenght' of this element without taking in count its children.

The wxT('lenght') of this element is the 'complexity' represented by the data placed in the mcElementData of this element. This is a key function for the simplify and expand routines of MathCore because through the use of this value, the system is able to decide if an operation determines a simplification or a complication. The simple example below shows how this can be done:

          mcPolynomial mypol(NULL);
          mypol.Init("2^16");
          mcRealValue n1 = mypol.math_GetTotalLenght(); */

(The math_GetTotalLenght() function works using this function !) The default implementation returns zero. This is a valid behaviour only for container elements, that is, for those elements where only the children carry information. For simple elements and for those containers which stand for an operation (like mcFraction which implies a division), the default implementation must be overridden.

A lenght/complexity of 1 means that this element would require only a single byte of memory if stored in an ASCII string. An element long 2 units (like mcBracket) would require 2 bytes (one for the left parenthesis and one for the right one)...

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcExpElementHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, and mcOperatorHelpers.

Referenced by math_GetTotalLenght().

virtual mcMathType mcElementHelpers::math_GetMathType  )  const [pure virtual]
 

A powerful recognizer function which automatically classifies the type of the math data contained in this class and returns the respective identifier.

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, and mcMathSystemHelpers.

virtual int mcElementHelpers::math_GetOrderPos  )  const [pure virtual]
 

Returns the order position for this element.

Implemented in mcBracketHelpers, mcDecorationHelpers, mcFractionHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, mcNumberHelpers, mcPolynomialHelpers, mcRadicalHelpers, and mcSymbolHelpers.

Referenced by math_isListedBeforeOf().

int mcElementHelpers::math_GetSymbolList mcSymbol **  ,
int  size,
mcSymbolProperties tofind
const [virtual]
 

Definition at line 1406 of file Element.cpp.

References mcSymbol::data_LinkWith(), and math_GetSymbolList().

int mcElementHelpers::math_GetSymbolList mcSymbol **  ,
int  size,
const mcSymbol tofind
const [virtual]
 

Returns the number of symbols identic to the one given (uses #math_CompareWith to perform comparison) and place a pointer to each symbol in the given array of pointers of size 'size'.

If the array is too small, then the function returns the number of symbols of the given type which have been found but with a negative sign. If no symbols of the given type are found, then the function returns 0.

Definition at line 1384 of file Element.cpp.

References math_Find().

Referenced by math_GetSymbolList().

mcRealValue mcElementHelpers::math_GetTotalLenght  )  const [virtual]
 

Returns the lenght of this element, taking in count also the children.

Uses the math_GetLenght() function to do the job.

Reimplemented in mcMathMngHelpers.

Definition at line 1229 of file Element.cpp.

References data_GetChildrenCount(), data_GetConstChild(), math_GetLenght(), and mcElement::math_GetTotalLenght().

Referenced by mcNumberHelpers::math_SimplifyBaseExp().

virtual void mcElementHelpers::math_Init  )  [inline, protected, virtual]
 

Initializes the MATH section of this element.

Definition at line 1234 of file Element.h.

Referenced by data_Init().

bool mcElementHelpers::math_isConstant  )  const [virtual]
 

Returns TRUE if this element contains mcSymbol registered as constants and/or mcNumbers only.

Reimplemented in mcMathMngHelpers.

Definition at line 1376 of file Element.cpp.

References math_ContainsParameters(), and math_ContainsUnknowns().

Referenced by mcSymbolHelpers::math_GetBaseMathType(), and mcFunctionHelpers::math_SimplifyBase().

bool mcElementHelpers::math_isExpAllowed mcElement  p  )  [static]
 

Use the following function to check if the given element can allocate an exponent.

Parameters:
p The element to be tested.

Definition at line 1154 of file Element.cpp.

Referenced by mcExpElementHelpers::gui_EditExpSub().

bool mcElementHelpers::math_isFinite  )  const [virtual]
 

Returns TRUE if this element evaluates to a finite value; returns FALSE if this element could not be evaluated (result is NAN) or this element evaluates to a infinite value.

Definition at line 1243 of file Element.cpp.

References math_Evaluate(), and mcValue::math_isFinite().

bool mcElementHelpers::math_isListedBeforeOf const mcElement p  )  const [virtual]
 

Returns TRUE if *this should be put before the given element in an ordered math list: this function is used by mcElementArray-derived classes to reorder their elements.

The default implementation of this function just compares the order position (retrieved through the math_GetOrderPos function) of this with the order position of the given element.

Reimplemented in mcSymbolHelpers.

Definition at line 1277 of file Element.cpp.

References math_GetOrderPos().

Referenced by mcSymbolHelpers::math_isListedBeforeOf().

bool mcElementHelpers::math_isMaxSimplified long  flags  )  const [virtual]
 

Returns TRUE if the element is completely simplified; FALSE if calls to math_Simplify(long flags) will make changes to the element.

Definition at line 1206 of file Element.cpp.

References data_Clone(), math_Simplify(), mcELEMENTMATH_MAX_PROCESS_CYCLES, mcESR_DONE, and mcESR_NOTFINISHED.

bool mcElementHelpers::math_isSubAllowed mcElement  p  )  [static]
 

Definition at line 1162 of file Element.cpp.

Referenced by mcExpElementHelpers::gui_EditExpSub().

bool mcElementHelpers::math_isValidMath  )  const
 

Returns TRUE if *this element is math consistent, that is, it is not a mcParenthesis or a mcEmptyBox and it does not contain invalid math elements (this function is recursive).

Definition at line 1251 of file Element.cpp.

References data_GetChildrenCount(), data_GetConstChild(), data_GetType(), mcET_EMPTYBOX, mcET_INVALID, mcET_PARENTHESIS, and mcET_TEXT.

mcBasicOpRes mcElementHelpers::math_MakeReciprocal mcElement replacement  )  [virtual]
 

Calculates the reciprocal of this element; tipically, this function creates a mcFraction whose numerator is 1 and the denominator contains *this.

This should be the default behaviour. A simple multiplication of the current exponent by -1 should be avoided when possible.

Note:
The math_RaiseTo function could be used instead of this one but this function should be preferred over math_RaiseTo(mcPolynomial(-1)); because this function ?????????? FIXME

Reimplemented in mcBracketHelpers, mcDecorationHelpers, mcElementArrayHelpers, mcExpElementHelpers, mcFractionHelpers, and mcNumberHelpers.

Definition at line 1178 of file Element.cpp.

References mcFraction::data_GetDen(), mcFraction::data_GetNum(), mcElementArray::math_WrapNumber(), mcElementArray::math_WrapSimple(), mcBOR_REPLACE_BOTH, and mcElement.

mcExpSimRes mcElementHelpers::math_MaxSimplify long  flags  )  [virtual]
 

Completely simplifies this element.

This function typically works calling math_Simplify until it does not return mcESR_DONE. Anyway, it doesn't modify the operation counter.

Definition at line 1188 of file Element.cpp.

References math_Simplify(), mcELEMENTMATH_MAX_PROCESS_CYCLES, mcESR_DONE, and mcESR_NOTFINISHED.

virtual mcBasicOpRes mcElementHelpers::math_MultiplyBy const mcElement e,
mcElement pp
[pure virtual]
 

Multiplies two mcElements of the same type and stores the result in this object.

Parameters:
p A pointer to a mcElement of the same type of this mcElement, which will be multiplied with this mcElement.

Implemented in mcDecorationHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, and mcPolynomialHelpers.

Referenced by math_SimpleMultiplyBy().

int mcElementHelpers::math_NonRecursiveFindInChildren int  n,
const mcElement p,
long  flags = mcFIND_NOFLAGS
const
 

Works like math_FindInChildrenOnly() but this function does not search recursively; that is, this function won't search in the children of the children of *this.

Returns:
The index of the n-th children which match the given element (comparison is performed through math_Compare()).

Definition at line 1440 of file Element.cpp.

References data_GetChildrenCount(), data_GetConstChild(), math_Compare(), and mcASSERT.

Referenced by mcElementArrayHelpers::math_Delete(), mcElementArrayHelpers::math_GetIndexOf(), mcPolynomialHelpers::math_GetNumSign(), and math_RecursiveFindInChildrenOnly().

virtual mcBasicOpRes mcElementHelpers::math_RaiseTo const mcPolynomial  )  [pure virtual]
 

Raises *this element to the given polynomial.

Returns mcBOR_INVALID if the operation could not be performed (this is typically because the base is negative), or mcBOR_REMOVE_OPERAND if the operation was okay.

Note:
All MathCore elements must implement this function, not only mcExpElement-derived classes because this operation *must* be feasible on every element: those elements which do not hold an exponent, must raise their children directly. mcFraction, for example, must implement this operation directly raising the numerator & denominator.

Implemented in mcDecorationHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, mcMonomialHelpers, and mcPolynomialHelpers.

Referenced by math_SimpleRaiseTo().

mcElement mcElementHelpers::math_RecursiveFind int &  n,
const mcElement p,
long  flags
const [protected, virtual]
 

Recursively search the n-th occurrence of the given element both in *this and both in *this' children using math_RecursiveFindInChildrenOnly().

If this function cannot find in *this or *this' children the n-th occurrence of the given element, then it returns NULL and to n the number of elements found is subtracted.

Note:
This function is used by math_Find() to perform its work. You should use math_Find() wherever it's possible since it hides the reference need.

Definition at line 1505 of file Element.cpp.

References data_GetChildrenCount(), data_GetConstChild(), math_Compare(), math_CompareThisOnly(), math_RecursiveFindInChildrenOnly(), mcASSERT, mcElement, mcEmptyElement, and mcFIND_PARENT.

Referenced by math_Find(), and math_RecursiveFindInChildrenOnly().

mcElement mcElementHelpers::math_RecursiveFindInChildrenOnly int &  n,
const mcElement p,
long  flags
const [protected, virtual]
 

Works exactly like math_RecursiveFind() except that this function does not perform comparison between p and *this.

Definition at line 1462 of file Element.cpp.

References mcElement::chlp(), data_GetChildrenCount(), data_GetConstChild(), math_NonRecursiveFindInChildren(), math_RecursiveFind(), mcASSERT, mcElement, mcEmptyElement, and mcFIND_PARENT.

Referenced by math_FindInChildrenOnly(), and math_RecursiveFind().

int mcElementHelpers::math_Replace const mcElement tofind,
int  n,
long  flags,
const mcElement replacement,
bool  bAttachChildren
[virtual]
 

Replaces the n-th occurrence of the element 'tofind' with a copy of the element 'replacement'.

If n == -1, all the occurrences of the element to find are replaced. If bAttachChildren == TRUE, then this function will try to attach the children of the just replaced element to the copy of 'replacement' using the mcElement::AttachChildrenTo. In any case, this function won't replace *this if *this matches the 'tofind' element.

Returns:
The number of occurrences replaced.
VERY IMPORTANT: this function should never be used to replace operators or to replace elements with operators, since operators follow special rules in mcElementArrays and could broke data integrity.

Reimplemented in mcMathMngHelpers.

Definition at line 1607 of file Element.cpp.

References mcObjectRefData::data_GetRefCount(), mcObject::data_GetRefData(), math_Find(), mcEmptyElement, mcFIND_PARENT, mcMATHLOG, mcTXT, and mcTXTTHIS.

void mcElementHelpers::math_SetExp const mcPolynomial  )  [virtual]
 

Sets the exponent of this element to match the given polynomial.

As for math_RaiseTo, for elements which do not have an exponent by their own, this function should just call the children's math_SetExp functions.

Reimplemented in mcDecorationHelpers, mcExpElementHelpers, and mcFractionHelpers.

Definition at line 1168 of file Element.cpp.

References data_GetChild(), data_GetChildrenCount(), and mcElement::math_SetExp().

void mcElementHelpers::math_SimpleAdd const mcElement p,
bool  add = TRUE
[virtual]
 

Adds the given element to this element using the math_Add() function and then checking that the return value is mcBOR_REMOVE_OPERAND: that is, the operation was completed successfully and *this now contains the result of the operation.

If the math_Add() function does not return mcBOR_REMOVE_OPERAND then an ASSERT fails: use math_SimpleXXXX functions only when you are sure that the operation can be performed without special operations.

Reimplemented in mcElementArrayHelpers.

Definition at line 1110 of file Element.cpp.

References math_Add(), mcASSERT, mcBOR_REMOVE_OPERAND, mcMATHLOG, mcTXT, mcTXTTHIS, and mcUNUSED.

Referenced by mcMathSystemHelpers::math_Add(), mcElementArrayHelpers::math_SimpleAdd(), and math_SimpleSubtract().

void mcElementHelpers::math_SimpleDivideBy const mcElement p  )  [virtual]
 

Reimplemented in mcElementArrayHelpers.

Definition at line 1132 of file Element.cpp.

References math_DivideBy(), mcASSERT, mcBOR_REMOVE_OPERAND, mcMATHLOG, mcTXT, mcTXTTHIS, and mcUNUSED.

Referenced by mcMathSystemHelpers::math_DivideBy(), and mcElementArrayHelpers::math_SimpleDivideBy().

void mcElementHelpers::math_SimpleMultiplyBy const mcElement p  )  [virtual]
 

Reimplemented in mcElementArrayHelpers.

Definition at line 1121 of file Element.cpp.

References math_MultiplyBy(), mcASSERT, mcBOR_REMOVE_OPERAND, mcMATHLOG, mcTXT, mcTXTTHIS, and mcUNUSED.

Referenced by mcMathSystemHelpers::math_MultiplyBy(), and mcElementArrayHelpers::math_SimpleMultiplyBy().

void mcElementHelpers::math_SimpleRaiseTo const mcPolynomial  ) 
 

Raises this element to the given mcPolynomial, checking that the return value is mcBOR_REMOVE_OPERAND.

If it is not, then a mcASSERT will fail.

Definition at line 1143 of file Element.cpp.

References math_RaiseTo(), mcASSERT, mcBOR_REMOVE_OPERAND, mcMATHLOG, mcTXT, mcTXTTHIS, and mcUNUSED.

virtual void mcElementHelpers::math_SimpleSubtract const mcElement p  )  [inline, virtual]
 

Definition at line 1438 of file Element.h.

References math_SimpleAdd().

Referenced by mcMathMngHelpers::gui_AddSubSel(), and mcMathSystemHelpers::math_Subtract().

virtual mcExpSimRes mcElementHelpers::math_Simplify long  flags,
mcElement newelem
[pure virtual]
 

Simplifies this element one "step"; that is, after one call to this function the element must be slightly changed.

For example, this monomial requires three calls to math_Simplify to be completely reduced in a basic form:

12ax*3 + 4a/(x^-1) . first call to math_Simplify 36ax + 4a/(1/x) . second call 36ax + 4ax . third call 40ax

Returns:
Returns TRUE if the element is completely simplied and thus, the following calls to math_Simplify won't have effect.

Implemented in mcDecorationHelpers, mcElementArrayHelpers, mcExpElementHelpers, mcFractionHelpers, mcMathMngHelpers, mcMathSystemHelpers, and mcPolynomialHelpers.

Referenced by math_isMaxSimplified(), and math_MaxSimplify().

mcBasicOpRes mcElementHelpers::math_Subtract const mcElement e,
mcElement pp
[inline]
 

math_s two mcElements of the same type and stores the result in this object.

Reimplemented in mcDecorationHelpers, mcFunctionHelpers, mcMathMngHelpers, mcMathSystemHelpers, and mcPolynomialHelpers.

Definition at line 1599 of file Element.h.

References math_Add().


Friends And Related Function Documentation

friend class mcElement [friend]
 

Definition at line 118 of file Element.h.

Referenced by data_UpdateElemArray(), mcSymbolHelpers::gui_BaseInsert(), mcExpElementHelpers::gui_GetSelection(), gui_GetSelection(), mcBracketHelpers::gui_OnRemoveLeftBracket(), mcBracketHelpers::gui_OnRemoveRightBracket(), mcBracketHelpers::math_ExpandContents(), math_MakeReciprocal(), math_RecursiveFind(), math_RecursiveFindInChildrenOnly(), and mcBracketHelpers::math_SimplifyContents().


Member Data Documentation

int mcElementHelpers::mdata_nID [protected]
 

The ID of this element.

This should be a unique value in the entire MathCore session: see MathCore::GenID() for more info about its generation at run-time. This code is used to identify one specific element inside the input data.

Definition at line 198 of file Element.h.

Referenced by data_GetID().

int mcElementHelpers::mdata_nProperties [protected]
 

The properties of this element, stored as bit array (use values defined in Element.h to check and set flags).

Definition at line 202 of file Element.h.

Referenced by data_AddProperty(), data_DeepCopy(), data_hasProperty(), data_hasRecursiveProperty(), data_isSameAs(), data_RemoveProperty(), and data_RemoveRecursiveProperty().

bool mcElementHelpers::mgui_bSelected [protected]
 

TRUE if the element is selected (totally or partially).

This variable cannot be accessed by derived classes: forcing use of the functions gui_OnSelect() and gui_DeSelect() avoids errors and nasty bugs because when the selection states of member classes' must change...

Definition at line 228 of file Element.h.

Referenced by data_DeepCopy(), gui_DeSelect(), gui_Init(), gui_isSelected(), and gui_Select().

int mcElementHelpers::mgui_nExpDepth [protected]
 

The exponent level of this element.

A null value means that this element is not an exponent; 1 means this is an exponent; 2 means this is an exponent of an exponent and so on... This variable can't be accessed by derived classes: forcing use of the functions #SetExpDepth() and #GetExpDepth() avoid errors and nasty bugs because when this value changes also the values of derived classes' exponent depth must change...

Note:
Why do we have to sore the exponent depth besides the parent which owns this element ? The parent always has the exponent level of this element minus 1, isn't it ? Well, the problem is that it's not always true: consider a bracket and its contained polynomial. The polynomial has the bracket as parent, but its same exponent depth. Instead, the exponent of a mcNumber has the mcNumber as parent, but an higher exponent level. In conclusion, we do really need to keep two values (exponent depth and parent) in each element.

Definition at line 253 of file Element.h.

Referenced by data_DeepCopy(), gui_GetExpDepth(), gui_SetAsExpOf(), gui_SetAtSameLevelOf(), and gui_SetExpDepth().

const mcStyleArray* mcElementHelpers::mgui_pStyleArray [protected]
 

Array of MathCore styles; access this array indirectly using the gui_GetStyle() function.

example:

     [...]
     gui_SelectObject(hDC, gui_GetStyle(this).hFont);
     SetTextColor(hDC, gui_GetStyle(this).clrText);
     [...]

Definition at line 221 of file Element.h.

Referenced by mcMathMngHelpers::data_DeepCopy(), data_DeepCopy(), gui_GetStyle(), gui_GetStyleArray(), gui_GetStyleForThis(), gui_Init(), and gui_SetStyleArray().

wxSize mcElementHelpers::mgui_sz [protected]
 

Size of the element (in pixels).

It should be always up-to-date; so, if you modify size in some way, call the gui_RecalcSize() function.

Definition at line 233 of file Element.h.

Referenced by data_DeepCopy(), gui_GetHeight(), gui_GetSize(), gui_GetWidth(), gui_Init(), gui_OnRecalcSize(), and gui_RecalcSize().

mcElement * mcElementHelpers::sdata_pElem [static]
 

An array containing one instance of each class type; used by isCharBeginChar(char) function; it uses this array to call the io_isBeginChar() function of each element type to do its work (the pElem array is initialized at the moment of the allocation of the namespace; see MathCore.cpp).

Definition at line 69 of file Element.cpp.

Referenced by Cleanup(), data_GetGlobalMemoryInfo(), data_GetInstanceOf(), data_UpdateElemArray(), and Init().

int mcElementHelpers::sgui_nAdditionalActivationSpaceLeftRight = 2 [static]
 

The additional number of pixels on the left & right of the active element to fill with sgui_pActivationBrush.

This should be a small value which should be use to adjust the activation rectangle which is drawn too small on some platforms.

Definition at line 68 of file Element.cpp.

wxBrush * mcElementHelpers::sgui_pActivationBrush = NULL [static]
 

The brush used to draw active elements (elements which are located under the cursor).

All the elements are highlighted when the mouse is moved over them. This is the background colour of the highlight.

Definition at line 66 of file Element.cpp.

mcStyleArray * mcElementHelpers::sgui_pDefaultStyles = NULL [static]
 

The array of styles used by default by all mcElements.

To change the style of a particular element (and the style of all its children), use the mcElement::SetStyle() function. To change the default style used by all mcElements, change this pointer.

Definition at line 67 of file Element.cpp.

Referenced by gui_DeleteDefaultStyles(), gui_Init(), and gui_InitDefaultStyles().

wxBrush * mcElementHelpers::sgui_pSelectionBrush = NULL [static]
 

The brush used to draw the selected portions of the math data.

When user selects a piece of math data, its background is filled with this colour.

Definition at line 65 of file Element.cpp.


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

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

[ Top ]