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

MathHelpers.h

Go to the documentation of this file.
00001 
00002 // MathCore = a WYSIWYG equation editor + a powerful math engine     //
00003 // Copyright (C) 2003 by Francesco Montorsi                          //
00004 //                                                                   //
00005 // This library is free software; you can redistribute it and/or     //
00006 // modify it under the terms of the GNU Lesser General Public        //
00007 // License as published by the Free Software Foundation; either      //
00008 // version 2.1 of the License, or (at your option) any later         //
00009 // version.                                                          //
00010 //                                                                   //
00011 // This library is distributed in the hope that it will be useful,   //
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of    //
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      //
00014 // GNU Lesser General Public License for more details.               //
00015 //                                                                   //
00016 // You should have received a copy of the GNU Lesser General Public  //
00017 // License along with this program; if not, write to the Free        //
00018 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,   //
00019 // MA 02111-1307, USA.                                               //
00020 //                                                                   //
00021 // For any comment, suggestion or feature request, please contact    //
00022 // the administrator of the project at frm@users.sourceforge.net     //
00023 //                                                                   //
00040 
00041 
00042 
00043 #ifndef MATHHELPERS_H
00044 #define MATHHELPERS_H
00045 
00046 // optimization for GCC compiler
00047 #ifdef __GNUG__
00048 #pragma interface "MathHelpers.h"
00049 #endif
00050 
00051 
00052 
00053 //  Includes
00054 // ----------
00055 
00056 #include <wx/dynarray.h> // for wxSymbolArray
00057 #include <wx/event.h>  // for wxKeyEvent
00058 #include <wx/font.h>
00059 #include <wx/colour.h>
00060 #include <wx/dc.h>
00061 
00062 #include "mc/MathUtils.h"
00063 #include "mc/MathTypes.h"
00064 #include "mc/Value.h"
00065 
00066 class mcElement;
00067 
00068 
00070 typedef void  mcAbstractItem;
00071 
00072 
00075 class mcAbstractArray
00076 {
00078  wxArrayPtrVoid m_arr;
00079 
00080 protected:
00081 
00083  virtual void data_Delete(int n) = 0;
00084 
00088  virtual mcAbstractItem *data_GetCopyOf(int) const { return NULL; }
00089 
00093  virtual void data_OnArrayChange() {}
00094 
00095 public:
00096 
00098  mcAbstractArray() {}
00099 
00104  virtual ~mcAbstractArray() {}
00105 
00107 #ifdef __MCDEBUG__
00108  virtual void data_Check() const;
00109 #else
00110  inline void data_Check() const {}
00111 #endif
00112 
00113 
00114 
00118 
00121  void data_Add(mcAbstractItem *pointer);
00122 
00124  void data_Insert(mcAbstractItem *pointer, int n);
00125 
00129  void data_SetItem(mcAbstractItem *pointer, int n);
00130 
00134  void data_RemoveAt(int idx, int count = 1);
00135 
00137  void data_Remove(const mcAbstractItem *p);
00138 
00141  mcAbstractItem *data_Detach(int idx);
00142 
00144  void data_Clear();
00145 
00148  void data_DeepCopy(const mcAbstractArray &arr);
00149 
00151  mcAbstractItem *data_GetItem(int idx)    { return m_arr.Item(idx); }
00152 
00154  const mcAbstractItem *data_GetItem(int idx) const { return m_arr.Item(idx); }
00155 
00157 
00158 
00159 
00163  
00165  bool data_isEmpty() const       { return m_arr.IsEmpty(); }
00166 
00168  int data_GetCount() const       { return m_arr.GetCount(); }
00169 
00172  int data_Find(const mcAbstractItem *pointer) const;
00173 
00175 };
00176 
00177 
00178 
00183 class mcGUIHelper
00184 {
00185 public:
00186  mcGUIHelper() {}
00187  virtual ~mcGUIHelper() {}
00188 };
00189 
00190 
00191 
00196 class mcMathHelper
00197 {
00198 public:
00199  mcMathHelper() {}
00200  virtual ~mcMathHelper() {}
00201 };
00202 
00203 
00204 
00209 class mcDataHelper
00210 {
00211 public:
00212  mcDataHelper() {}
00213  virtual ~mcDataHelper() {}
00214 };
00215 
00216 
00217 
00218 
00221 #define mcKEY_MAX_COMBINATIONS      2
00222 
00225 class mcKeyEntry : public mcGUIHelper
00226 {
00227 protected:
00228  
00232 #define SHIFT_KEY  1
00233 #define CTRL_KEY  2
00234 #define META_KEY  4
00235 #define ALT_KEY   8 
00236 
00237  
00238 
00239  int m_nFlags;
00240  
00243  int m_nKeyCode;
00244  
00249  bool m_bSpecial;
00250  
00251  
00252 protected:
00253  
00257  void InitFlags(const wxString &str) {
00258   wxString s = GetModifiersFrom(str);
00259   m_nFlags = 0;
00260   
00261   m_nFlags |= (s.Contains(wxT("c")) ? CTRL_KEY : 0);
00262   m_nFlags |= (s.Contains(wxT("m")) ? META_KEY : 0);
00263   m_nFlags |= (s.Contains(wxT("a")) ? ALT_KEY : 0);
00264   m_nFlags |= (s.Contains(wxT("s")) ? SHIFT_KEY : 0);
00265   m_bSpecial = s.Contains(wxT("x"));
00266  }
00267  
00270  void InitKeyCode(const wxString &str) {
00271   long m;
00272   wxString num = str.Right(str.Len()-GetModifiersFrom(str).Len());
00273   if (num.GetChar(0) == wxT('+') || num.GetChar(0) == wxT('-'))
00274    num.Remove(0, 1);  // remove first character
00275   num.ToLong(&m);
00276   m_nKeyCode = (int)m;
00277  }
00278  
00280  wxString GetModifiersFrom(const wxString &def) {
00281   
00282   // return everything before first '+'
00283   wxString modifiers = def.BeforeFirst(wxT('+'));
00284   modifiers.MakeLower();
00285   return modifiers;
00286  }
00287  
00288 public:
00289  
00299  mcKeyEntry() {
00300   Reset();
00301  }
00302  
00303  mcKeyEntry(const wxString &str, long keycode) {
00304   Reset();
00305   InitFlags(str);
00306   m_nKeyCode = keycode;
00307  }
00308  
00309  mcKeyEntry(const wxString &str) {
00310   Reset();
00311   InitFlags(str);
00312   InitKeyCode(str);
00313  }
00314  
00316  mcKeyEntry( const wxKeyEvent &keyEvent )
00317  {
00318   Reset();
00319   if ( keyEvent.m_altDown )
00320    m_nFlags += ALT_KEY;
00321   if ( keyEvent.m_shiftDown )
00322    m_nFlags += SHIFT_KEY;
00323   if ( keyEvent.m_controlDown )
00324    m_nFlags += CTRL_KEY;
00325   if ( keyEvent.m_metaDown )
00326    m_nFlags += META_KEY;
00327   m_nKeyCode = keyEvent.m_keyCode;
00328  }
00329 
00330  virtual ~mcKeyEntry() {}
00331  
00332  
00335  void Reset() {
00336   m_nKeyCode = m_nFlags = 0;
00337   m_bSpecial = FALSE;
00338  }
00339  
00343  wxString Encode() const {
00344   wxString str;
00345   
00346   // adds the (eventually) present modifiers
00347   if (m_nFlags & CTRL_KEY) str += wxT("c");
00348   if (m_nFlags & SHIFT_KEY) str += wxT("s");
00349   if (m_nFlags & META_KEY) str += wxT("m");
00350   if (m_nFlags & ALT_KEY) str += wxT("a");
00351   
00352   // save main keycode
00353   str.Printf(wxT("%s+%d"), (const wxChar *)str, m_nKeyCode);
00354   
00355   // finished...
00356   return str;
00357  }
00358  
00361  bool MatchKey(const mcKeyEntry &ke) const {
00362   bool bTheSame = TRUE;
00363   
00364   // if one of this pair of values are different,
00365   // the two key objects represents different key
00366   // combinations
00367   bTheSame &= (m_nFlags == ke.m_nFlags);
00368   bTheSame &= (m_nKeyCode == ke.m_nKeyCode);
00369   bTheSame &= (m_bSpecial == ke.m_bSpecial);
00370   
00371   return bTheSame;
00372  }
00373  
00376  bool MatchKey(const wxKeyEvent &ke) const {
00377   bool bTheSame = TRUE;
00378   
00379   // if one of this pair of values are different,
00380   // the two key objects represents different key
00381   // combinations
00382   bTheSame &= (ke.ControlDown() == ((m_nFlags & CTRL_KEY) != 0));
00383   bTheSame &= (ke.ShiftDown() == ((m_nFlags & SHIFT_KEY) != 0));
00384   bTheSame &= (ke.MetaDown() == ((m_nFlags & META_KEY) != 0));
00385   bTheSame &= (ke.AltDown() == ((m_nFlags & ALT_KEY) != 0));
00386   bTheSame &= (ke.GetKeyCode() == m_nKeyCode);
00387   
00388   return bTheSame;
00389  }
00390  
00392  wxKeyEvent GetEvent() {
00393   wxKeyEvent res;
00394   
00395   // copy attributes ( the '!= 0' at the end is required to avoid warnings)
00396   res.m_altDown = (m_nFlags & ALT_KEY) != 0;
00397   res.m_shiftDown = (m_nFlags & SHIFT_KEY) != 0;
00398   res.m_controlDown = (m_nFlags & CTRL_KEY) != 0;
00399   res.m_metaDown = (m_nFlags & META_KEY) != 0;
00400   res.m_keyCode = m_nKeyCode;
00401   
00402   // return result
00403   return res;
00404  }
00405  
00407  wxChar GetKeyCode() {
00408   if ((m_nKeyCode >= 0 && m_nKeyCode <= 255) || m_bSpecial)
00409    return (wxChar)m_nKeyCode;
00410   return 0;
00411  }
00412  
00414  int GetModifiers() {
00415   return m_nFlags;
00416  }
00417  
00422  void SetAsSpecialKey() {
00423   m_bSpecial = TRUE;
00424  }
00425  
00427  bool isSpecialKey() {
00428   return m_bSpecial;
00429  }
00430 };
00431 
00432 
00433 
00434 
00437 class mcKey : public mcGUIHelper
00438 {
00439 protected:
00440  
00447  void Reset() {
00448   for (int i=0; i < mcKEY_MAX_COMBINATIONS; i++)
00449    m_pMatch[i] = NULL;
00450   m_strDescription = wxT("");
00451  }
00452 
00453 public:  // these variables are public so we can avoid a lot of
00454    // getters/setters which would provide full access anyway
00455  
00457  mcKeyEntry *m_pMatch[mcKEY_MAX_COMBINATIONS];
00458  
00460  wxString m_strDescription;
00461  
00462 public:  // special routines
00463 
00465  void DeepCopy( const mcKey& other ) {
00466 
00467   // avoid to copy itself
00468   if ( &other == this )
00469    return;
00470 
00471   Cleanup();  // deallocates actual content
00472 
00473   for (int i=0; i < mcKEY_MAX_COMBINATIONS; i++)
00474    if (other.m_pMatch[i])
00475     m_pMatch[i] = new mcKeyEntry(*other.m_pMatch[i]);
00476  }
00477  
00479  void Cleanup() {
00480   for (int i=0; i < mcKEY_MAX_COMBINATIONS; i++)
00481    mcSAFE_DELETE(m_pMatch[i]);
00482  }
00483 
00484  
00485 public:
00486  
00491  mcKey(const wxString &def) {
00492   wxString str = def;
00493   
00494   // create the mcKeyEntries and init them
00495   for (int i=0; i < mcKEY_MAX_COMBINATIONS; i++) {
00496    m_pMatch[i] = new mcKeyEntry(str.BeforeFirst(wxT(';')));
00497    str = str.AfterFirst(wxT(';'));
00498   }
00499  }
00500  
00501  mcKey(const wxChar c, bool bSpecial = FALSE) {
00502   Reset();
00503   m_pMatch[0] = new mcKeyEntry(wxEmptyString, c);
00504   if (bSpecial) m_pMatch[0]->SetAsSpecialKey();
00505  }
00506  
00507  mcKey(const wxKeyEvent &key, bool bSpecial = FALSE) {
00508   Reset();
00509   m_pMatch[0] = new mcKeyEntry(key);
00510   if (bSpecial) m_pMatch[0]->SetAsSpecialKey();
00511  }
00512  
00513  mcKey(const mcKey &other) {
00514   Reset();
00515   DeepCopy( other );
00516  }
00517  
00518  mcKey() {
00519   Reset();
00520  }
00521  
00522  mcKey& operator = ( const mcKey& other )  {
00523   DeepCopy( other );
00524   return *this;
00525  }
00526  
00528  virtual ~mcKey() {
00529   Cleanup();
00530  }
00531 
00532  
00533  /* void Decode(const wxString &str) {
00534  wxString match;
00535  
00536   // load each key entry enconding string using semicolon as tokenizer
00537   for (int c=0; c < mcKEY_MAX_COMBINATIONS; c++) {
00538   match = str.Left(str.math_Find(wxT(";")));
00539   kMatch[c]->Decode(match);
00540   }
00541   }
00542   
00543    wxString Encode() const {
00544    wxString str;
00545    
00546     // divide each key entry enconding string with a semicolon
00547     for (int c=0; c < mcKEY_MAX_COMBINATIONS; c++)
00548     str += kMatch[c]->Encode() + wxT(";");
00549     
00550   return str;
00551         }
00552  */
00555  bool MatchKey(const wxKeyEvent &ke) const {
00556   bool bTheSame = FALSE;
00557   for (int c=0; c < mcKEY_MAX_COMBINATIONS; c++)
00558    if (m_pMatch[c])
00559     bTheSame |= m_pMatch[c]->MatchKey(ke);
00560    return bTheSame;
00561  }
00562  
00565  bool MatchKey(const mcKey &ke) const {
00566   bool bTheSame = FALSE;
00567   for (int c=0; c < mcKEY_MAX_COMBINATIONS; c++)
00568    for (int d=0; d < mcKEY_MAX_COMBINATIONS; d++)
00569     if (m_pMatch[c] && ke.m_pMatch[d])
00570      bTheSame |= m_pMatch[c]->MatchKey(*ke.m_pMatch[d]);
00571                 return bTheSame;
00572  }
00573  /*
00574  bool operator== (const mcKey &key) const {
00575  return MatchKey(key);
00576         }*/
00577  
00580  bool isSpecialKey(int n = 0) const {
00581   return m_pMatch[n]->isSpecialKey();
00582  }
00583  
00586  void SetAsSpecialKey(int n = 0) {
00587   m_pMatch[n]->SetAsSpecialKey();
00588  }
00589  
00592  wxKeyEvent GetEvent(int n = 0) const {
00593   return m_pMatch[n]->GetEvent();
00594  }
00595  
00598  wxChar GetKeyCode(int n = 0) const {
00599   return m_pMatch[n]->GetKeyCode();
00600  }
00601  
00604  int GetModifiers(int n = 0) const {
00605   return m_pMatch[n]->GetModifiers();
00606  }
00607 };
00608 
00609 
00610 
00611 
00612 
00614 class mcMathType : public mcMathHelper
00615 {
00616 public:  // public to avoid a lot of getters/setters
00617  
00618  mcMathTypeLevel1 m_tMath1;
00619  mcMathTypeLevel2 m_tMath2;
00620  mcMathTypeLevel3 m_tMath3;
00621 
00624  long m_tMath4;
00625 
00626 public:
00627 
00628  mcMathType(mcMathTypeLevel1 t1 = mcMTL1_NOT_RECOGNIZED, 
00629      mcMathTypeLevel2 t2 = mcMTL2_NOT_RECOGNIZED, 
00630      mcMathTypeLevel3 t3 = mcMTL3_NOT_RECOGNIZED, 
00631         long t4 = mcMTL4_NOT_RECOGNIZED) :
00632       m_tMath1(t1), m_tMath2(t2), m_tMath3(t3), m_tMath4(t4) {}
00633 
00634  virtual ~mcMathType() {}
00635 
00638  wxString io_GetDescString() const;
00639 
00646  mcMathType math_MultiplyBy(const mcMathType &);
00647  mcMathType math_Add(const mcMathType &);
00648  mcMathType math_DivideBy(const mcMathType &);
00649  
00650  mcMathType math_RaiseTo(const mcMathType &);
00651 
00654  mcMathType math_ApplyOp(mcElementType optype, const mcMathType &);
00655 };
00656 
00657 
00660 class mcMathSystemType : public mcMathHelper
00661 {
00662 public:
00663  mcMathSystemTypeLevel1 m_tMath1;
00664 
00665 public:
00666 
00667  mcMathSystemType(mcMathSystemTypeLevel1 t1 = mcMSTL1_NOT_RECOGNIZED) :
00668       m_tMath1(t1) {}
00669  virtual ~mcMathSystemType() {}
00670 
00674  wxString io_GetDescString(int neq) const;
00675 
00680  mcMathSystemType math_CombineWith(const mcMathSystemType &);
00681 };
00682 
00683 
00684 #define mcSYM_PARAMETER   0  
00685 #define mcSYM_CONSTANT   1  
00686 #define mcSYM_UNKNOWN    2  
00687 #define mcSYM_UNREGISTERED  3  
00688 
00689 #define mcSYM_NOTSET   -1  
00690 #define mcSYM_NOTFOUND   -1  
00691 
00692 // this will be defined later
00693 class mcSymbol;
00694 class mcSymbolHelpers;
00695 class mcSymbolArray;
00696 class mcExtRange;
00697 
00699 class mcSymbolProperties : public mcMathHelper
00700 {
00701  friend class mcSymbolArray;
00702 
00703 protected:
00704 
00709  wxString m_strInlinedSymbol;
00710  
00714  wxArrayLong m_arrLinkedSymbol;
00715 
00716 public:   // to avoid a LOT of getters/setters
00717     // (all members must be modifiable)
00718 
00721  int m_nSymbolType;
00722 
00726  wxFontEncoding m_fEncoding;
00727 
00733  wxString m_strSymbol;
00734 
00737  wxString m_strSubscript;
00738 
00739 public:   // math properties
00740 
00744  mcRealValue m_fValue;
00745  
00751  mcExtRange *m_pDomain;
00752 
00763  bool m_bEvaluating;
00764  
00765 
00766 public:
00767 
00769  mcSymbolProperties(int symtype = mcSYM_NOTSET, 
00770       const wxString &name = wxEmptyString,
00771       wxFontEncoding encoding = wxFONTENCODING_DEFAULT,
00772       const mcRealValue &value = 0.0, 
00773       const wxString &inlinedsym = wxEmptyString, 
00774       const wxString &subscript = wxEmptyString,
00775             mcExtRange *domain = NULL,
00776       bool evaluating = FALSE);
00777 
00778  virtual ~mcSymbolProperties();
00779 
00780 
00783  mcSymbolProperties *data_Clone() const {
00784   mcSymbolProperties *copy = new mcSymbolProperties(m_nSymbolType, m_strSymbol, 
00785    m_fEncoding, m_fValue, m_strInlinedSymbol, m_strSubscript, m_pDomain,
00786    m_bEvaluating);
00787 
00788   return copy;
00789  }
00790 
00793  wxString io_GetInlinedSym() const 
00794   { return m_strInlinedSymbol.IsEmpty() ? m_strSymbol : m_strInlinedSymbol; }
00795  wxString io_GetInlinedExpr() const
00796   { return io_GetInlinedSym(); }
00797 
00798 
00801  void data_Check() const {
00802   bool valid = TRUE;
00803   
00804   // check that data is correctly init
00805   valid &= !m_strSymbol.IsEmpty();
00806   valid &= (m_nSymbolType != mcSYM_NOTSET);
00807   if (data_isConstant()) valid &= (m_fValue != *mcRealValue::pNAN);
00808   
00809   mcASSERT(valid, wxT("This symbol is damaged !!!"));
00810   }
00811 
00817  int math_FindDuplicate(const mcSymbolArray *tosearch, int occ) const;
00818 
00819 
00820 
00821 
00825 
00827  void data_Link(const mcSymbolHelpers *p)  { m_arrLinkedSymbol.Add((long)p); }
00828  void data_Unlink(const mcSymbolHelpers *p)  { m_arrLinkedSymbol.Remove((long)p); }
00829 
00830  int data_GetLinkedSymCount() const    { return m_arrLinkedSymbol.GetCount(); }
00831  mcSymbolHelpers *data_GetLinkedSym(int n) const { return (mcSymbolHelpers*)m_arrLinkedSymbol.Item(n); } 
00832 
00836  const mcSymbolHelpers *data_GetSafeLinkedSym() const
00837  { mcASSERT(data_GetLinkedSym(0) != NULL, wxT("Invalid safe index ?"));
00838    return (const mcSymbolHelpers *)data_GetLinkedSym(0); }
00839 
00841 
00842 
00846 
00847  bool data_isRegistered() const { return m_nSymbolType != mcSYM_UNREGISTERED; }
00848  bool data_isParameter() const { return m_nSymbolType == mcSYM_PARAMETER; }
00849  bool data_isUnknown() const  { return m_nSymbolType == mcSYM_UNKNOWN; }
00850  bool data_isConstant() const { return m_nSymbolType == mcSYM_CONSTANT; }
00851  bool data_isUnlinked() const { return m_arrLinkedSymbol.IsEmpty(); }
00852  bool data_isSameAs(const mcSymbolProperties &s) const;
00853 
00854  bool math_isBeingEvaluated() const
00855   { return m_bEvaluating; }
00856 
00858 };
00859 
00860 
00861 
00862 
00869 #define mcMAX_SYMBOL_ARRAY_NUM     5
00870 
00871 // flags used by mcSymbolArray::math_Find function.
00872 #define mcSYMFIND_MATCH_NAME     1
00873 #define mcSYMFIND_MATCH_ENCODING    2
00874 #define mcSYMFIND_MATCH_INLINED     4
00875 #define mcSYMFIND_MATCH_SUBSCRIPT    8
00876 #define mcSYMFIND_MATCH_VALUE     16
00877 
00878 #define mcSYMFIND_MATCH_ALL  (mcSYMFIND_MATCH_NAME | mcSYMFIND_MATCH_ENCODING | \
00879         mcSYMFIND_MATCH_INLINED | mcSYMFIND_MATCH_SUBSCRIPT | \
00880         mcSYMFIND_MATCH_VALUE)
00881 
00882 
00885 class mcSymbolArray : public mcAbstractArray
00886 {
00887 protected:
00888 
00892  int m_nSymbolArray;
00893 
00895  mcSymbolArray *m_pArr[mcMAX_SYMBOL_ARRAY_NUM];
00896 
00897 protected:
00898 
00899  void data_Delete(int n)
00900   { delete data_GetSymbol(n); }
00901  mcAbstractItem *data_GetCopyOf(int n) const
00902   { return data_GetSymbol(n)->data_Clone(); }
00903 
00905  void data_ResetLinkedArr() {
00906   for (int i=0; i < mcMAX_SYMBOL_ARRAY_NUM; i++)
00907    m_pArr[i] = NULL;
00908  }
00909 
00910 public:
00911 
00914  void (*m_pAddSymbolCallback)(void);
00915 
00916 public:
00917 
00918  mcSymbolArray(int type = mcSYM_NOTSET,
00919      void (*fnc)(void) = NULL) { 
00920   data_ResetLinkedArr(); 
00921   m_nSymbolArray = type; 
00922   m_pAddSymbolCallback = fnc;
00923  }
00924 
00925  virtual ~mcSymbolArray() { data_Clear(); }
00926 
00927 
00931  mcSymbolProperties *data_AddSymbol(bool bRemovePrevious,
00932          const wxString &name,
00933          wxFontEncoding enc = wxFONTENCODING_DEFAULT, 
00934          const mcRealValue &value = 0.0, 
00935          const wxString &inlinedsym = wxEmptyString, 
00936          const wxString &subscript = wxEmptyString,
00937          mcExtRange *domain = NULL);
00938 
00948  bool data_AddSymbol(const mcSymbolProperties &newsym, bool bRemovePrevious = TRUE);
00949 
00953  mcSymbolProperties *data_MoveSymbols(int i, mcSymbolArray *parr);
00954 
00964  int data_FindSymbol(long flags,
00965      const wxString &name, 
00966      wxFontEncoding enc = wxFONTENCODING_DEFAULT,
00967      const mcRealValue &value = 0.0, 
00968      const wxString &subscript = wxEmptyString, 
00969      const wxString &inlined = wxEmptyString,
00970      int occurrence = 0) const;
00971 
00972  int data_FindSymbol(long flags, const mcSymbolProperties &symtofind, int occ = 0) const;
00973 
00974 
00981  void data_LinkWithArray(mcSymbolArray *p) {
00982   int entry = 0;
00983   while (m_pArr[entry] != NULL)
00984    entry++;
00985 
00986   m_pArr[entry] = p;
00987  }
00988 
00989 
00990 
00993 
00994  mcSymbolProperties *data_GetSymbol(int n)    { return (mcSymbolProperties *)data_GetItem(n); }
00995  const mcSymbolProperties *data_GetSymbol(int n) const { return (const mcSymbolProperties *)data_GetItem(n); }
00996 
00997  wxString data_GetSymbolName(int n) const  { return data_GetSymbol(n)->m_strSymbol;}
00998  wxString data_GetSubscript(int n) const   { return data_GetSymbol(n)->m_strSubscript; }
00999  wxString io_GetInlinedSymbol(int n) const  { return data_GetSymbol(n)->io_GetInlinedSym(); }
01000  mcRealValue math_GetValue(int n) const   { return data_GetSymbol(n)->m_fValue; }
01001  wxFontEncoding data_GetEncoding(int n) const { return data_GetSymbol(n)->m_fEncoding; }
01002  int data_GetArrayId() const      { return m_nSymbolArray; }
01003 
01005 };
01006 
01007 
01008 #define mcCP_MAX_DEPTH  64
01009 
01010 #define mcCP_UNDEFINED  -256
01011 #define mcCP_BEGIN   -257
01012 #define mcCP_END   -258
01013 #define mcCP_BEGINEND  -259
01014 
01015 
01035 class mcCursorPos : public mcGUIHelper
01036 {
01037 protected:
01038 
01039  int m_nPos[mcCP_MAX_DEPTH];
01040  int m_nUsed;
01041 
01042 public:
01043  
01044  // constructor
01045  mcCursorPos() 
01046   { m_nUsed=0; }
01047  mcCursorPos(int pos) 
01048   { m_nUsed=1; m_nPos[0] = pos; }
01049 
01050  virtual ~mcCursorPos() {}
01051 
01052 
01053 public:  // push, pop
01054 
01057  void gui_Push(int cp)
01058   { m_nPos[m_nUsed++] = cp; }
01059 
01060  void gui_Push(const mcCursorPos &c);
01061  void gui_Pop();
01062 
01064  int gui_Last() const
01065   { return m_nPos[0]; }
01066 
01067  int gui_GetLastAndPop()
01068   { int n=gui_Last(); gui_Pop(); return n; }
01069 
01070 
01071 public:  // checkers
01072 
01073  bool isEnd() const
01074   { return gui_Last() == mcCP_END; }
01075 
01076  bool isSpecial() const
01077   { return isSpecial(gui_Last()); }
01078 
01079  bool isSpecial(int cp) const
01080   { return cp <= mcCP_UNDEFINED && cp >= mcCP_BEGINEND; }
01081 
01082  bool isBegin() const
01083   { return gui_Last() == mcCP_BEGIN; }
01084 
01085  bool isBeginEnd() const
01086   { return gui_Last() == mcCP_BEGINEND; }
01087 
01088  bool isUndefined() const
01089   { return gui_Last() == mcCP_UNDEFINED; }
01090 
01091  bool isInside() const
01092   { return !isBegin() && !isEnd() && !isBeginEnd() && !isUndefined(); }
01093 };
01094 
01095 
01097 class mcMathMngCmd : public mcGUIHelper
01098 {
01099 public:
01100 
01101  mcMathMngCmdID m_nID;
01102  const wxChar *m_strDescription;
01103 
01104 public:
01105  mcMathMngCmd(mcMathMngCmdID id, const wxChar *desc) : m_nID(id), m_strDescription(desc) {}
01106  virtual ~mcMathMngCmd() {}
01107 };
01108 
01109 
01110 #endif    // MATHHELPERS_H


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

[ Top ]