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 // // 00030 00031 00032 00033 #ifndef MATHANDSYSTEM_H 00034 #define MATHANDSYSTEM_H 00035 00036 // optimization for GCC compiler 00037 #ifdef __GNUG__ 00038 #pragma interface "MathAndSystem.h" 00039 #endif 00040 00041 // required includes 00042 #include "mc/MathSystem.h" 00043 00044 00045 // defined later 00046 class mcMathAndSystem; 00047 00048 00051 enum mcMathAndSystemRenderMode { 00052 00055 mcMASRM_DRAW_CURLY_BRACKET, 00056 00058 mcMASRM_DRAW_AND_SYMBOLS, 00059 00061 mcMASRM_DRAW_AND_TEXT, 00062 }; 00063 00064 00065 00070 class mcEXPORT mcMathAndSystemHelpers : public mcMathSystemHelpers 00071 { 00072 mcDEFINE_REFERENCE_DATA(mcMathAndSystem, mcET_MATHANDSYSTEM); 00073 00074 protected: // functions 00075 00083 int gui_UpdateActiveLine(int n, wxMemoryDC &hDC, int x, int y, 00084 long flags, const wxPoint &p); 00085 00087 int gui_GetLineContainingPt(int x, int y, const wxPoint &pt); 00088 00090 void gui_UpdateSystemSym(); 00091 00093 //void data_OnArrayChange(); 00094 00095 00096 protected: // mcAbstractArray functions 00097 00099 void data_Delete(int n) 00100 { delete ((mcMathLine*)data_GetItem(n)); } 00101 00103 mcAbstractItem *data_GetCopyOf(int n) const 00104 { return new mcMathLine(data_GetLine(n)); } 00105 00106 00107 public: 00108 00109 mcMathAndSystemHelpers() { data_Init(); } 00110 virtual ~mcMathAndSystemHelpers() { data_Clear(); } 00111 00112 00113 00114 #ifdef mcENABLE_DATA 00115 public: 00116 00117 #ifdef __MCDEBUG__ 00118 00119 wxString data_Debug(long flags) const; 00120 00121 #endif 00122 00127 00129 void data_AddLine(mcMathLine *ptoadd) 00130 { mcAbstractArray::data_Add(ptoadd); } 00131 00133 void data_AddEmptyLine() 00134 { data_AddLine(new mcMathLine()); } 00135 00136 mcMathLine &data_GetLine(int n) 00137 { return (mcMathLine &)data_GetChild(n); } 00138 const mcMathLine &data_GetLine(int n) const 00139 { return (const mcMathLine &)data_GetConstChild(n); } 00140 mcMathLine &data_GetLastLine() 00141 { return (mcMathLine &)data_GetLast(); } 00142 const mcMathLine &data_GetLastLine() const 00143 { return (const mcMathLine &)data_GetLast(); } 00144 00146 00152 void data_SetFilter(const mcFilter *p, int n = -1); 00153 00154 #endif // mcENABLE_DATA 00155 00156 00157 00158 #ifdef mcENABLE_GUI 00159 public: // customizable variables 00160 00162 static int sgui_nSpaceLeftRight; 00163 00165 static int sgui_nSpaceAboveBelow; 00166 00169 static int sgui_nSpaceBetween; 00170 00171 00174 static bool sgui_bHorizOrientation; 00175 00179 static mcMathAndSystemRenderMode sgui_nRenderMode; 00180 00181 protected: 00182 00183 virtual bool gui_DrawHorizontally() const { return sgui_bHorizOrientation; } 00184 virtual bool gui_DrawVertically() const { return !sgui_bHorizOrientation; } 00185 00186 virtual int gui_GetSpaceAboveBelow() const { return sgui_nSpaceAboveBelow; } 00187 virtual int gui_GetSpaceLeftRight() const { return sgui_nSpaceLeftRight; } 00188 virtual int gui_GetSpaceBetween() const { return sgui_nSpaceBetween; } 00189 00190 public: 00191 00192 mcMathLine &gui_GetFocusLine() 00193 { return (mcMathLine &)gui_GetFocus(); } 00194 const mcMathLine &gui_GetFocusLine() const 00195 { return (const mcMathLine &)gui_GetFocus(); } 00196 00197 void gui_DrawSystemSymbols(wxDC &dc, int x, int y, long flags) const; 00198 void gui_RecalcSymbolSize(); 00199 00202 mcElement gui_GetSelection() const; 00203 00207 bool gui_isIDChanged() const; 00208 00216 virtual int gui_GetActiveElemID() const; 00217 00218 #endif // mcENABLE_GUI 00219 00220 00221 00222 #ifdef mcENABLE_MATH 00223 public: 00224 00225 //mcMathAndSystem *math_Merge(const mcMathAndSystem *) const; 00226 void math_Merge(const mcMathAndSystem &arr1, 00227 const mcMathAndSystem &arr2); 00228 00229 mcMathSystemType math_GetMathSystemType() const; 00230 00231 #endif // mcENABLE_MATH 00232 00233 00234 00235 #ifdef mcENABLE_IO 00236 public: 00237 00239 //wxString io_GetInlinedExpr() const; 00240 00241 wxString io_GetInlinedExprOfLogicalOperator() const 00242 { return wxT("AND"); } 00243 00244 bool io_ImportToken(const wxString &str, wxString *perr); 00245 00246 #endif // mcENABLE_IO 00247 }; 00248 00249 00253 class mcMathAndSystem : public mcMathSystem 00254 { 00255 mcDEFINE_MAIN_CLASS(MathAndSystem, mcMathSystem); 00256 00257 public: 00258 00259 mcMathAndSystem(const mcMathLine &l1, const mcMathLine &l2) 00260 { data_SetRefData(new mcMathAndSystemHelpers()); 00261 data_AddLine(new mcMathLine(l1)); data_AddLine(new mcMathLine(l2)); } 00262 00263 bool data_isValidContainerFor(mcElementType t) const 00264 { return t == mcET_MATHANDSYSTEM; } 00265 00266 00267 #ifdef mcENABLE_DATA 00268 public: 00269 00270 mcWRAPPER void data_AddLine(mcMathLine *ptoadd) 00271 { hlp()->data_AddLine(ptoadd); } 00272 mcWRAPPER mcMathLine &data_GetLine(int n) 00273 { return hlp()->data_GetLine(n); } 00274 mcWRAPPER const mcMathLine &data_GetLine(int n) const 00275 { return hlp()->data_GetLine(n); } 00276 mcWRAPPER void data_SetFilter(const mcFilter *p, int n = -1) 00277 { hlp()->data_SetFilter(p, n); } 00278 00279 #endif // mcENABLE_DATA 00280 00281 00282 #ifdef mcENABLE_GUI 00283 public: 00284 00285 mcWRAPPER int gui_GetActiveElemID() const 00286 { return hlp()->gui_GetActiveElemID(); } 00287 mcWRAPPER bool gui_isIDChanged() const 00288 { return hlp()->gui_isIDChanged(); } 00289 00290 mcWRAPPER mcMathLine &gui_GetFocusLine() 00291 { return hlp()->gui_GetFocusLine(); } 00292 mcWRAPPER const mcMathLine &gui_GetFocusLine() const 00293 { return hlp()->gui_GetFocusLine(); } 00294 00295 #endif // mcENABLE_GUI 00296 00297 00298 #ifdef mcENABLE_MATH 00299 public: 00300 00301 mcWRAPPER void math_Merge(const mcMathAndSystem &arr1, 00302 const mcMathAndSystem &arr2) 00303 { hlp()->math_Merge(arr1, arr2); } 00304 00305 #endif // mcENABLE_MATH 00306 }; 00307 00308 #endif // mcMATHANDSYSTEM
[ Top ] |