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

mcNumberHelpers Class Reference

#include <Number.h>

Inheritance diagram for mcNumberHelpers:

Inheritance graph
[legend]
Collaboration diagram for mcNumberHelpers:

Collaboration graph
[legend]
List of all members.

Detailed Description

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

This is entirely defined & implemented through macros.

Definition at line 63 of file Number.h.

Public Member Functions

 mcNumberHelpers ()
virtual ~mcNumberHelpers ()
void data_DeepCopy (const mcElementHelpers *p)
 Deep copies the given mcExpElementHelpers, removing the exponent from this if it is not present in p or deep-copying it otherwise.
bool data_isSameAs (const mcElementHelpers *p) const
 Performs a deep comparison of the data hold by this class and the data hold by the given mcElementHelpers object.
bool data_isAllowedBefore (mcElementType type) const
 Returns TRUE if this element is allowed to be directly on the left of the given element type.
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.
void data_Set (const mcRealValue &d)
mcRealValue data_Get () const
void gui_Set (const wxString &toset)
wxString gui_GetStr () const
void math_Abs ()
bool math_isValid () const
bool math_GetNumDen (mcIntegerValue &num, mcIntegerValue &den)
mcFraction math_TransformInFraction ()
void math_RaiseBaseTo (mcRealValue n)
virtual void math_RaiseTo (const mcIntegerValue &n)
bool io_isBeginTag (const wxXml2Node &tag) const
 Returns a positive value if the given MathML content tag marks the begin of this element; FALSE otherwise.
bool io_isBeginChar (const wxString &str) const
 Returns a positive value if the given inlined expression marks the begin of this element; FALSE otherwise.
wxXml2Node io_GetBaseMathML (bool bGetPresentation) const
 Returns a MathML tree with the presentation math markup language regarding the base.
wxString io_GetBaseInlinedExpr () const
bool io_ImportPresentationMathML (wxXml2Node tag, wxString &pErr)
 Imports presentation MathML reading the contents of the given XML node (without modifying it).
bool io_ImportBaseInlinedExpr (const wxString &, int *count, wxString &pErr)
mcExpElement overloaded BASE functions
These functions handle the base of the symbol; the exponent is handled by mcExpElement functions.

bool gui_isBeginKey (const mcKey &ev) const
 Returns a positive value if the given character marks the begin of this element; FALSE otherwise.
bool gui_isBaseEndKey (const mcKey &ev) const
 This function should work as mcElement::isEndChar function, but it should care only for the base; this means that the element should not handle the mcEXPELEM_**** cursor positions, but it will probably still need to check for exp/sub presence to choose if the given keyevent is the end key.
bool gui_DrawAsActiveOverBase () const
 mcNumber is not a container element, thus when mouse cursor is placed over the base, all the element should be drawn as active.
mcInsertRes gui_BaseInsert (const mcElement &, mcElement *)
mcInputRes gui_BaseInput (const mcKey &key, mcElement *pnew)
 Handles the input when the cursor is editing the base; an useful function, to avoid repetitions inside gui_BaseInput(), could be the gui_HandleSubExpEditKeys() function...
mcMoveCursorRes gui_BaseMoveCursor (mcMoveCursorFlag flag, long modifiers)
 Handles cursor movements when the cursor is editing the base.
int gui_DrawBase (wxDC &dc, int x, int y, long flags, const wxPoint &pt) const
 Identical to mcElement::gui_Draw, but just for the base.
int gui_BaseMoveCursorUsingPoint (wxDC &, const wxPoint &)
 Moves the cursor inside the base using the given point and, eventually the given DC for calculations.
int gui_GetBaseRelCursorPos (wxDC &dc, wxPoint *pt) const
 Returns the height of the cursor and it's position (in the given pointer and in coordinates relatives to the top-left point of the base), when the cursor is editing the base.
void gui_GetBaseCursorPos (mcCursorPos &) const
 Returns one of the cursor position flags (called only when cursor is inside the base).
void gui_SetBaseCursorPos (const mcCursorPos &)
 Sets the cursor position of the element.
void gui_DoRecalcBaseSize ()
 Calculates (in the m_szBase variable) the size of the base only.
void gui_EditBase ()
 Called when the cursor is switching from the exp/sub to the base; it should set the cursor inside the base: the correct position will be set using the gui_SetBaseCursorPos.
bool gui_Split (mcElement *)
 mcNumber is one of the few elements which supports splitting.
bool gui_MergeWith (const mcElement &)
 Merges the given element with this object.
bool gui_isSplittable () const
 Returns TRUE if this element supports splitting and, thus, also merging.
mcExpElementMath and mcElementMath abstract functions
Implementation of pure virtual common math functions.

bool math_CanBeAddedWith (const mcElement &p) const
 Returns TRUE if this element can be added with the given element.
bool math_CanBeMultWith (const mcElement &p) const
 Works like #math_CanBemath_AddeWith(), just for multiplication.
bool math_CanBeDivBy (const mcElement &p) const
 Works like #math_CanBemath_AddeWith(), just for divisions.
mcBasicOpRes math_Add (const mcElement &, mcElement *, bool add)
 Sums or subtracts this element with the given e element.
mcBasicOpRes math_MultiplyBaseOnlyBy (const mcElement &, mcElement *)
mcBasicOpRes math_DivideBaseOnlyBy (const mcElement &, mcElement *)
mcBasicOpRes math_MultiplyBaseBy (const mcElement &, mcElement *)
mcBasicOpRes math_DivideBaseBy (const mcElement &, mcElement *)
mcRealValue math_GetBaseLenght () const
mcRealValue math_EvaluateBase () const
int math_GetOrderPos () const
 Returns the order position for this element.
mcMathType math_GetBaseMathType () const
mcBasicOpRes math_MakeReciprocal (mcElement *)
 Calculates the reciprocal of this element; tipically, this function creates a mcFraction whose numerator is 1 and the denominator contains *this.
mcExpSimRes math_ExpandBase (long flags, mcElement *newelem)
mcExpSimRes math_SimplifyBase (long flags, mcElement *newelem)
mcExpSimRes math_SimplifyBaseExp (long flags, mcElement *pnew)
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.
mcMonomial math_GetBaseLCM (const mcElement &p) const
mcMonomial math_GetGCD (const mcElement &p) const

Static Public Member Functions

static bool gui_isDigit (int vk)
 Returns TRUE if the given keycode is a digit (0, 1, 2, 3, 4, 5, 6, 7, 8 or 9).
static bool gui_isDecimalPoint (wxChar totest)
 Returns TRUE if the given character is considered as a decimal point.
static bool math_isZero (const mcElement &)

Static Public Attributes

static int sgui_nDigitToShow = -1
 The number of digits of #m_n which will be shown when exporting through the mcNumberIO functions or when viewing the graphical representation through the mcNumberGUI functions.
static wxString sgui_strFloatingPoint = wxT(".,")
 Contains the characters recognized as floating point.
static bool smath_bUseIntegersWhenPossible = TRUE
 If TRUE, then fractions with integer coefficients will be used when possible, instead of decimal numbers:.
static mcNumbersmath_pOne = NULL
 A mcNumber with "1.0" as content...
static mcNumbersmath_pTwo = NULL
static mcNumbersmath_pFour = NULL
static mcNumbersmath_pMinusOne = NULL
static mcNumbersmath_pZero = NULL

Protected Member Functions

void gui_Init ()
 Inits this section of the element.

Protected Attributes

mcRealValue mdata_n
 The number represented by this class.
wxString mgui_strTrailer
 mcNumberGUI allows the user to input decimal numbers (of any lenght) so it cannot just read the input through gui_BaseInput() and add the typed digits to mcNumber::data_m_n because if the user wants to add a zero when the cursor is placed in the rightmost digit after the comma, in this way it wouldn't work:
int mgui_nCursorPos
 The cursor position.

Private Member Functions

 mcDEFINE_REFERENCE_DATA (mcNumber, mcET_NUMBER)


Constructor & Destructor Documentation

mcNumberHelpers::mcNumberHelpers  )  [inline]
 

Definition at line 166 of file Number.h.

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

Definition at line 176 of file Number.h.


Member Function Documentation

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

Deep copies the given mcExpElementHelpers, removing the exponent from this if it is not present in p or deep-copying it otherwise.

The same checks are performed on the subscript.

Reimplemented from mcExpElementHelpers.

Definition at line 205 of file Number.h.

References mcExpElementHelpers::data_DeepCopy(), mdata_n, and mgui_strTrailer.

mcRealValue mcNumberHelpers::data_Get  )  const [inline]
 

Definition at line 239 of file Number.h.

Referenced by gui_BaseInput(), gui_BaseMoveCursor(), gui_BaseMoveCursorUsingPoint(), gui_EditBase(), gui_MergeWith(), gui_Split(), io_GetBaseInlinedExpr(), io_GetBaseMathML(), math_Add(), math_CanBeDivBy(), math_CanBeMultWith(), math_CompareThisOnly(), math_DivideBaseOnlyBy(), math_GetBaseLCM(), math_GetGCD(), math_GetNumDen(), math_MakeReciprocal(), math_MultiplyBaseBy(), math_MultiplyBaseOnlyBy(), math_RaiseBaseTo(), math_RaiseTo(), math_SimplifyBase(), and math_SimplifyBaseExp().

bool mcNumberHelpers::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 from mcElementHelpers.

Definition at line 227 of file Number.h.

References mcET_BRACKET, mcET_FRACTION, mcET_FUNCTION, mcET_NUMBER, mcET_RADICAL, and mcET_SYMBOL.

bool mcNumberHelpers::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 from mcElementHelpers.

Definition at line 221 of file Number.h.

References mcET_NUMBER.

bool mcNumberHelpers::data_isSameAs const mcElementHelpers p  )  const [inline, virtual]
 

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

Reimplemented from mcElementHelpers.

Definition at line 212 of file Number.h.

References mdata_n.

void mcNumberHelpers::data_Set const mcRealValue d  )  [inline]
 

Definition at line 238 of file Number.h.

Referenced by gui_MergeWith(), gui_Set(), gui_Split(), io_ImportBaseInlinedExpr(), io_ImportPresentationMathML(), math_Add(), math_DivideBaseOnlyBy(), math_MultiplyBaseBy(), math_MultiplyBaseOnlyBy(), math_RaiseBaseTo(), math_RaiseTo(), and math_SimplifyBaseExp().

mcInputRes mcNumberHelpers::gui_BaseInput const mcKey key,
mcElement pnew
[virtual]
 

Handles the input when the cursor is editing the base; an useful function, to avoid repetitions inside gui_BaseInput(), could be the gui_HandleSubExpEditKeys() function...

Implements mcExpElementHelpers.

Definition at line 222 of file Number.cpp.

References data_Get(), mcMathCore::Get(), gui_GetStr(), mcExpElementHelpers::gui_HandleSubExpEditKeys(), gui_isDecimalPoint(), gui_isDigit(), mcElementHelpers::gui_RecalcSize(), gui_Set(), mcIR_DELETE_NEXT, mcIR_DELETE_PREVIOUS, mcIR_DELETE_THIS, mcIR_OKAY, mcNUMBER_DECIMAL_POINT, mgui_nCursorPos, mgui_strTrailer, and mcMathCore::SyntaxError().

mcInsertRes mcNumberHelpers::gui_BaseInsert const mcElement ,
mcElement
[virtual]
 

Implements mcExpElementHelpers.

Definition at line 306 of file Number.cpp.

References mcINSR_OKAY.

mcMoveCursorRes mcNumberHelpers::gui_BaseMoveCursor mcMoveCursorFlag  flag,
long  modifiers
[virtual]
 

Handles cursor movements when the cursor is editing the base.

This function should work ABSOLUTELY without care about the exponent or subscript presence or absence: if the cursor is placed on the rightmost point of the base, and the function is called with the mcMCF_RIGHT flag, then the function should return mcMCR_SETFOCUS_NEXT without any check: the mcExpElement::gui_MoveCursor function will check the return value of this function and will corerctly handle it !!!

Implements mcExpElementHelpers.

Definition at line 363 of file Number.cpp.

References data_Get(), mcRealValue::GetNumOfDigits(), mcMCF_DOWN, mcMCF_LEFT, mcMCF_RIGHT, mcMCF_UP, mcMCR_OKAY, mcMCR_SETFOCUS_ABOVE, mcMCR_SETFOCUS_BELOW, mcMCR_SETFOCUS_NEXT, mcMCR_SETFOCUS_PREVIOUS, and mgui_nCursorPos.

int mcNumberHelpers::gui_BaseMoveCursorUsingPoint wxDC &  ,
const wxPoint & 
[virtual]
 

Moves the cursor inside the base using the given point and, eventually the given DC for calculations.

Implements mcExpElementHelpers.

Definition at line 415 of file Number.cpp.

References data_Get(), mcRealValue::GetNumOfDigits(), mcElementHelpers::gui_GetHeightOfChar(), mcElementHelpers::gui_GetWidthOfChar(), mcASSERT, mcMCR_OKAY, and mgui_nCursorPos.

void mcNumberHelpers::gui_DoRecalcBaseSize  )  [virtual]
 

Calculates (in the m_szBase variable) the size of the base only.

It's very important not to modify the m_sz variable: m_sz is handled by mcExpElement functions: the base must modify ONLY *m_szBase*.

Implements mcExpElementHelpers.

Definition at line 154 of file Number.cpp.

References mcElementHelpers::gui_GetSizeOf(), gui_GetStr(), and mcElementHelpers::gui_SelectStyle().

bool mcNumberHelpers::gui_DrawAsActiveOverBase  )  const [inline, virtual]
 

mcNumber is not a container element, thus when mouse cursor is placed over the base, all the element should be drawn as active.

Implements mcExpElementHelpers.

Definition at line 265 of file Number.h.

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

Identical to mcElement::gui_Draw, but just for the base.

You have to draw it at the given point (x,y) without take care of the exp/sub, just do everything as they wouldn't exist. The given pointer to a wxPoint class can be mcDRW_NONACTIVE or a valid pointer value (in this case, the cursor is always inside the base). You can be sure that it will never be mcDRW_ALLACTIVE: this flag is completely handled by mcExpElement. If all the base must be drawn as active, the subscript should be too... you can use the #GetBaseAndSubSize function to make the task easier.

Parameters:
dc The DC where the base must be drawn
x,y The position on the DC where the base must be drawn
pt mcDRW_NONACTIVE or a valid pointer to the mouse position;
Returns:
The ID of the element which is placed under the given cursor position (this is typically hlp()->data_GetID(), but in some cases, like for mcBracket, it can be different) or mcDRW_NOACTIVELEM, if the mouse cursor is placed over empty space.

Implements mcExpElementHelpers.

Definition at line 164 of file Number.cpp.

References mcElementHelpers::data_GetID(), mcExpElementHelpers::gui_GetBaseSize(), gui_GetStr(), mcElementHelpers::gui_SelectStyle(), mcDRW_NONACTIVE, and mcGUILOG.

void mcNumberHelpers::gui_EditBase  )  [virtual]
 

Called when the cursor is switching from the exp/sub to the base; it should set the cursor inside the base: the correct position will be set using the gui_SetBaseCursorPos.

Implements mcExpElementHelpers.

Definition at line 189 of file Number.cpp.

References data_Get(), mcRealValue::GetNumOfDigits(), mcECL_INSIDEBASE, and mgui_nCursorPos.

void mcNumberHelpers::gui_GetBaseCursorPos mcCursorPos  )  const [virtual]
 

Returns one of the cursor position flags (called only when cursor is inside the base).

Implements mcExpElementHelpers.

Definition at line 475 of file Number.cpp.

References gui_GetStr(), mcCursorPos::gui_Push(), mcCP_BEGIN, mcCP_END, and mgui_nCursorPos.

int mcNumberHelpers::gui_GetBaseRelCursorPos wxDC &  dc,
wxPoint *  pt
const [virtual]
 

Returns the height of the cursor and it's position (in the given pointer and in coordinates relatives to the top-left point of the base), when the cursor is editing the base.

Implements mcExpElementHelpers.

Definition at line 450 of file Number.cpp.

References mcElementHelpers::gui_GetHeightOf(), mcElementHelpers::gui_GetHeightOfChar(), gui_GetStr(), mcElementHelpers::gui_GetWidthOf(), mcElementHelpers::gui_SelectStyle(), and mgui_nCursorPos.

wxString mcNumberHelpers::gui_GetStr  )  const [inline]
 

Definition at line 251 of file Number.h.

References mcRealValue::GetSmartStr().

Referenced by gui_BaseInput(), gui_DoRecalcBaseSize(), gui_DrawBase(), gui_GetBaseCursorPos(), gui_GetBaseRelCursorPos(), gui_Set(), and gui_SetBaseCursorPos().

void mcNumberHelpers::gui_Init  )  [inline, protected, virtual]
 

Inits this section of the element.

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

Reimplemented from mcExpElementHelpers.

Definition at line 180 of file Number.h.

References mcExpElementHelpers::gui_Init().

bool mcNumberHelpers::gui_isBaseEndKey const mcKey ev  )  const [virtual]
 

This function should work as mcElement::isEndChar function, but it should care only for the base; this means that the element should not handle the mcEXPELEM_**** cursor positions, but it will probably still need to check for exp/sub presence to choose if the given keyevent is the end key.

When the cursor is inside the exp/sub, this function is never called. Derived classes must also implement the mcElementHelpers::gui_isBeginChar function.

Implements mcExpElementHelpers.

Definition at line 143 of file Number.cpp.

References mcMathCore::Get(), gui_isDecimalPoint(), gui_isDigit(), and mcMathCore::MatchEditKeys().

bool mcNumberHelpers::gui_isBeginKey const mcKey ev  )  const [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.

Implements mcElementHelpers.

Definition at line 136 of file Number.cpp.

References gui_isDigit().

static bool mcNumberHelpers::gui_isDecimalPoint wxChar  totest  )  [inline, static]
 

Returns TRUE if the given character is considered as a decimal point.

Definition at line 132 of file Number.h.

Referenced by gui_BaseInput(), and gui_isBaseEndKey().

bool mcNumberHelpers::gui_isDigit int  vk  )  [static]
 

Returns TRUE if the given keycode is a digit (0, 1, 2, 3, 4, 5, 6, 7, 8 or 9).

This utility does not belong to any specific subsection of the program because it is used almost in each of them.

Definition at line 89 of file Number.cpp.

Referenced by gui_BaseInput(), gui_isBaseEndKey(), gui_isBeginKey(), io_ImportBaseInlinedExpr(), and io_isBeginChar().

bool mcNumberHelpers::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 from mcElementHelpers.

Definition at line 285 of file Number.h.

bool mcNumberHelpers::gui_MergeWith const mcElement p  )  [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 from mcElementHelpers.

Definition at line 344 of file Number.cpp.

References data_Get(), mcNumber::data_Get(), data_Set(), mcRealValue::GetNumOfDigits(), mcElementHelpers::gui_RecalcSize(), mcET_NUMBER, and mcRealValue::pow().

void mcNumberHelpers::gui_Set const wxString &  toset  ) 
 

Definition at line 196 of file Number.cpp.

References data_Set(), gui_GetStr(), mgui_nCursorPos, and mgui_strTrailer.

Referenced by gui_BaseInput().

void mcNumberHelpers::gui_SetBaseCursorPos const mcCursorPos  )  [virtual]
 

Sets the cursor position of the element.

When this function is called with the mcCP_BEGIN flag, it must set the cursor at the leftmost point of the base; when this function is called with mcCP_END flag, the function must set the cursor at the rightmost point of the base. It should never check exponent/subscript presence: everything is handled by mcExpElement.

Implements mcExpElementHelpers.

Definition at line 495 of file Number.cpp.

References gui_GetStr(), and mgui_nCursorPos.

bool mcNumberHelpers::gui_Split mcElement  )  [virtual]
 

mcNumber is one of the few elements which supports splitting.

In fact, if the user types something which is not a digit inside the number, the mcNumber is splitted in two parts.

Reimplemented from mcElementHelpers.

Definition at line 313 of file Number.cpp.

References mcNumber::data_Get(), data_Get(), data_Set(), mcNumber::data_Set(), mcElementHelpers::gui_RecalcSize(), mcElement::gui_RecalcSize(), and mgui_nCursorPos.

wxString mcNumberHelpers::io_GetBaseInlinedExpr  )  const [virtual]
 

Implements mcExpElementHelpers.

Definition at line 540 of file Number.cpp.

References data_Get(), and mcRealValue::GetSmartStr().

wxXml2Node mcNumberHelpers::io_GetBaseMathML bool  bGetPresentation  )  const [virtual]
 

Returns a MathML tree with the presentation math markup language regarding the base.

This function should work exactly as the hononymous mcElement function.

Parameters:
bGetPresentation If TRUE, this function returns the presentation MathML, otherwise it returns the content markup.

Implements mcExpElementHelpers.

Definition at line 524 of file Number.cpp.

References data_Get().

bool mcNumberHelpers::io_ImportBaseInlinedExpr const wxString &  ,
int *  count,
wxString &  pErr
[virtual]
 

Implements mcExpElementHelpers.

Definition at line 566 of file Number.cpp.

References mcElementHelpers::data_AddProperty(), data_Set(), gui_isDigit(), mcASSERT, and mcEP_INITIALIZED.

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

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

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

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

Implements mcElementHelpers.

Definition at line 546 of file Number.cpp.

References mcElementHelpers::data_AddProperty(), data_Set(), mcASSERT, and mcEP_INITIALIZED.

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

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

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

Implements mcElementHelpers.

Definition at line 517 of file Number.cpp.

References gui_isDigit().

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

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

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

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

Implements mcElementHelpers.

Definition at line 355 of file Number.h.

void mcNumberHelpers::math_Abs  )  [inline]
 

Definition at line 298 of file Number.h.

mcBasicOpRes mcNumberHelpers::math_Add const mcElement ,
mcElement ,
bool  add
[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.

Implements mcElementHelpers.

Definition at line 658 of file Number.cpp.

References mcNumber::data_Get(), data_Get(), data_Set(), mcASSERT, mcBOR_REMOVE_OPERAND, mcET_NUMBER, mcLOG, and mcTXTV.

bool mcNumberHelpers::math_CanBeAddedWith const mcElement p  )  const [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.

Implements mcElementHelpers.

Definition at line 595 of file Number.cpp.

References mcET_NUMBER.

Referenced by math_CanBeMultWith().

bool mcNumberHelpers::math_CanBeDivBy const mcElement p  )  const [virtual]
 

Works like #math_CanBemath_AddeWith(), just for divisions.

Implements mcElementHelpers.

Definition at line 615 of file Number.cpp.

References mcNumber::data_Get(), data_Get(), mcIntegerValue::GCD(), mcIntegerValue::GetStr(), mcRealValue::isInteger(), mcIntegerValue::isPrimeTo(), mcNumber::math_isValid(), math_isValid(), math_isZero(), mcET_NUMBER, mcMATHLOG, and smath_bUseIntegersWhenPossible.

bool mcNumberHelpers::math_CanBeMultWith const mcElement p  )  const [virtual]
 

Works like #math_CanBemath_AddeWith(), just for multiplication.

Implements mcElementHelpers.

Definition at line 606 of file Number.cpp.

References data_Get(), and math_CanBeAddedWith().

bool mcNumberHelpers::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 from mcElementHelpers.

Definition at line 832 of file Number.cpp.

References data_Get().

Referenced by math_GetGCD().

mcBasicOpRes mcNumberHelpers::math_DivideBaseBy const mcElement ,
mcElement
[inline, virtual]
 

Reimplemented from mcExpElementHelpers.

Definition at line 322 of file Number.h.

References mcBOR_REMOVE_OPERAND.

mcBasicOpRes mcNumberHelpers::math_DivideBaseOnlyBy const mcElement ,
mcElement
[virtual]
 

Implements mcExpElementHelpers.

Definition at line 705 of file Number.cpp.

References mcNumber::data_Get(), data_Get(), data_Set(), mcRealValue::GetStr(), mcRealValue::isInteger(), math_isZero(), mcASSERT, mcBOR_REMOVE_OPERAND, mcBOR_REPLACE_OPERAND, mcET_NUMBER, mcMATHLOG, mcTXT, mcTXTTHIS, and smath_bUseIntegersWhenPossible.

mcRealValue mcNumberHelpers::math_EvaluateBase  )  const [inline, virtual]
 

Implements mcExpElementHelpers.

Definition at line 326 of file Number.h.

mcExpSimRes mcNumberHelpers::math_ExpandBase long  flags,
mcElement newelem
[virtual]
 

Implements mcExpElementHelpers.

Definition at line 914 of file Number.cpp.

References mcESR_DONE.

mcMonomial mcNumberHelpers::math_GetBaseLCM const mcElement p  )  const [virtual]
 

Reimplemented from mcExpElementHelpers.

Definition at line 952 of file Number.cpp.

References data_Get(), and mcExpElementHelpers::math_GetBaseLCM().

mcRealValue mcNumberHelpers::math_GetBaseLenght  )  const [inline, virtual]
 

Reimplemented from mcExpElementHelpers.

Definition at line 325 of file Number.h.

References mcRealValue::GetNumOfDigits().

mcMathType mcNumberHelpers::math_GetBaseMathType  )  const [inline, virtual]
 

Implements mcExpElementHelpers.

Definition at line 330 of file Number.h.

References mcMTL1_POLYNOMIAL, mcMTL2_ALGEBRAIC, and mcMTL3_CONSTANT.

mcMonomial mcNumberHelpers::math_GetGCD const mcElement p  )  const [virtual]
 

Reimplemented from mcExpElementHelpers.

Definition at line 965 of file Number.cpp.

References mcElementArray::data_AddElements(), data_Get(), mcElementHelpers::data_GetType(), mcRealValue::isInteger(), math_CompareThisOnly(), mcExpElementHelpers::math_Evaluate(), mcElement::math_Evaluate(), mcExpElementHelpers::math_GetGCD(), mcMATHLOG, mcTXT, and mcTXTTHIS.

bool mcNumberHelpers::math_GetNumDen mcIntegerValue num,
mcIntegerValue den
 

Definition at line 792 of file Number.cpp.

References mcRationalValue::Canonicalize(), data_Get(), mcRationalValue::GetDen(), and mcRationalValue::GetNum().

Referenced by math_MultiplyBaseBy(), math_MultiplyBaseOnlyBy(), and math_TransformInFraction().

int mcNumberHelpers::math_GetOrderPos  )  const [inline, virtual]
 

Returns the order position for this element.

Implements mcElementHelpers.

Definition at line 327 of file Number.h.

bool mcNumberHelpers::math_isValid  )  const [inline]
 

Definition at line 299 of file Number.h.

References mcValue::isValid().

Referenced by math_CanBeDivBy().

bool mcNumberHelpers::math_isZero const mcElement  )  [static]
 

Definition at line 824 of file Number.cpp.

References mcET_NUMBER.

Referenced by math_CanBeDivBy(), and math_DivideBaseOnlyBy().

mcBasicOpRes mcNumberHelpers::math_MakeReciprocal mcElement  )  [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 from mcExpElementHelpers.

Definition at line 925 of file Number.cpp.

References data_Get(), mcFraction::data_GetDen(), mcFraction::data_SetNum(), mcElementArray::math_WrapSimple(), and mcBOR_REMOVE_OPERAND.

mcBasicOpRes mcNumberHelpers::math_MultiplyBaseBy const mcElement ,
mcElement
[virtual]
 

Reimplemented from mcExpElementHelpers.

Definition at line 747 of file Number.cpp.

References data_Get(), data_Set(), mcValue::isValid(), mcElement::math_Evaluate(), mcExpElementHelpers::math_Evaluate(), math_GetNumDen(), mcASSERT, mcBOR_REMOVE_OPERAND, mcBOR_REPLACE_OPERAND, mcET_NUMBER, and smath_bUseIntegersWhenPossible.

mcBasicOpRes mcNumberHelpers::math_MultiplyBaseOnlyBy const mcElement ,
mcElement
[virtual]
 

Implements mcExpElementHelpers.

Definition at line 673 of file Number.cpp.

References mcNumber::data_Get(), data_Get(), data_Set(), math_GetNumDen(), mcASSERT, mcBOR_REMOVE_OPERAND, mcBOR_REPLACE_OPERAND, mcET_NUMBER, and smath_bUseIntegersWhenPossible.

void mcNumberHelpers::math_RaiseBaseTo mcRealValue  n  ) 
 

Definition at line 937 of file Number.cpp.

References data_Get(), and data_Set().

void mcNumberHelpers::math_RaiseTo const mcIntegerValue n  )  [virtual]
 

Definition at line 942 of file Number.cpp.

References data_Get(), data_Set(), mcRealValue::GetStr(), mcMATHLOG, and mcRealValue::pow().

mcExpSimRes mcNumberHelpers::math_SimplifyBase long  flags,
mcElement newelem
[virtual]
 

Implements mcExpElementHelpers.

Definition at line 843 of file Number.cpp.

References data_Get(), math_TransformInFraction(), mcASSERT, mcEmptyElement, mcESR_DONE, mcESR_REPLACE_THIS, and smath_bUseIntegersWhenPossible.

mcExpSimRes mcNumberHelpers::math_SimplifyBaseExp long  flags,
mcElement pnew
[virtual]
 

Todo:
Creation of a perfect-power finder algorithm...

Reimplemented from mcExpElementHelpers.

Definition at line 860 of file Number.cpp.

References mcExpElementHelpers::data_DestroyExpSub(), mcExpElement::data_DestroyExpSub(), data_Get(), mcExpElementHelpers::data_GetExp(), mcExpElement::data_GetExp(), data_Set(), mcNumber::data_Set(), mcElement::math_Evaluate(), mcElementHelpers::math_GetTotalLenght(), mcElement::math_GetTotalLenght(), mcESR_DONE, and mcESR_NOTFINISHED.

mcFraction mcNumberHelpers::math_TransformInFraction  ) 
 

Definition at line 806 of file Number.cpp.

References mcFraction::data_GetDen(), mcFraction::data_GetNum(), math_GetNumDen(), and mcElementArray::math_WrapSimple().

Referenced by math_SimplifyBase().

mcNumberHelpers::mcDEFINE_REFERENCE_DATA mcNumber  ,
mcET_NUMBER 
[private]
 


Member Data Documentation

mcRealValue mcNumberHelpers::mdata_n [protected]
 

The number represented by this class.

Definition at line 71 of file Number.h.

Referenced by data_DeepCopy(), and data_isSameAs().

int mcNumberHelpers::mgui_nCursorPos [protected]
 

The cursor position.

Note on the cursor positions available for mcExpElement::mgui_nCursorPos in the mcNumber class.

Positive numbers of mgui_nCursorPos indicates the digit where the cursor is next to... example: mgui_nCursorPos=0, m_n=123 . |123 mgui_nCursorPos=3, m_n=335 . 335| mgui_nCursorPos=2, m_n=1024 . 10|24

example: mgui_nCursorPos=mcECL_INSIDEEXP, m_n=123 . 123^(...|...) mgui_nCursorPos=mcECL_ENDEXP, m_n=335 . 335^(...)|

Definition at line 107 of file Number.h.

Referenced by gui_BaseInput(), gui_BaseMoveCursor(), gui_BaseMoveCursorUsingPoint(), gui_EditBase(), gui_GetBaseCursorPos(), gui_GetBaseRelCursorPos(), gui_Set(), gui_SetBaseCursorPos(), and gui_Split().

wxString mcNumberHelpers::mgui_strTrailer [protected]
 

mcNumberGUI allows the user to input decimal numbers (of any lenght) so it cannot just read the input through gui_BaseInput() and add the typed digits to mcNumber::data_m_n because if the user wants to add a zero when the cursor is placed in the rightmost digit after the comma, in this way it wouldn't work:

1234.5678| the user types "0" 1234.56780 must be the result

Using a string (which is always kept sync with mcNumber::data_m_n), we can avoid such problems...

Definition at line 91 of file Number.h.

Referenced by data_DeepCopy(), gui_BaseInput(), and gui_Set().

int mcNumberHelpers::sgui_nDigitToShow = -1 [static]
 

The number of digits of #m_n which will be shown when exporting through the mcNumberIO functions or when viewing the graphical representation through the mcNumberGUI functions.

If this variable is set to -1, then all the significant digits will be shown; if set to n, then only the first n digits of the number will be shown (padding with zeroes if significant digits are missing).

Definition at line 66 of file Number.cpp.

wxString mcNumberHelpers::sgui_strFloatingPoint = wxT(".,") [static]
 

Contains the characters recognized as floating point.

Definition at line 65 of file Number.cpp.

bool mcNumberHelpers::smath_bUseIntegersWhenPossible = TRUE [static]
 

If TRUE, then fractions with integer coefficients will be used when possible, instead of decimal numbers:.

24/15 will be simplified to 8/5 instead of 1.6

Definition at line 67 of file Number.cpp.

Referenced by math_CanBeDivBy(), math_DivideBaseOnlyBy(), math_MultiplyBaseBy(), math_MultiplyBaseOnlyBy(), and math_SimplifyBase().

mcNumber * mcNumberHelpers::smath_pFour = NULL [static]
 

Definition at line 61 of file Number.cpp.

mcNumber * mcNumberHelpers::smath_pMinusOne = NULL [static]
 

Definition at line 62 of file Number.cpp.

mcNumber * mcNumberHelpers::smath_pOne = NULL [static]
 

A mcNumber with "1.0" as content...

Definition at line 59 of file Number.cpp.

mcNumber * mcNumberHelpers::smath_pTwo = NULL [static]
 

Definition at line 60 of file Number.cpp.

mcNumber * mcNumberHelpers::smath_pZero = NULL [static]
 

Definition at line 63 of file Number.cpp.


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

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

[ Top ]