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 MATHORSYSTEM_H 00034 #define MATHORSYSTEM_H 00035 00036 // optimization for GCC compiler 00037 #ifdef __GNUG__ 00038 #pragma interface "MathOrSystem.h" 00039 #endif 00040 00041 // required includes 00042 #include "mc/MathSystem.h" 00043 #include "mc/MathAndSystem.h" 00044 00045 00046 // defined later 00047 class mcMathOrSystem; 00048 class mcMathAndSystem; 00049 class mcMathLine; 00050 00051 00053 class mcEXPORT mcMathOrSystemHelpers : public mcMathSystemHelpers 00054 { 00055 mcDEFINE_REFERENCE_DATA(mcMathOrSystem, mcET_MATHORSYSTEM); 00056 00057 public: 00058 mcMathOrSystemHelpers() { data_Init(); } 00059 virtual ~mcMathOrSystemHelpers() { data_Clear(); } 00060 00061 00062 00063 #ifdef mcENABLE_DATA 00064 protected: // mcAbstractArray functions 00065 00067 void data_Delete(int n); 00068 00070 mcAbstractItem *data_GetCopyOf(int n) const; 00071 00072 public: 00073 00074 #ifdef __MCDEBUG__ 00075 00076 wxString data_Debug(long flags) const; 00077 00079 wxString data_GetMemoryInfoStr() const; 00080 00081 #endif 00082 00083 mcMathAndSystem &data_GetSys(int n) 00084 { return (mcMathAndSystem &)data_GetChild(n); } 00085 const mcMathAndSystem &data_GetSys(int n) const 00086 { return (const mcMathAndSystem &)data_GetConstChild(n); } 00087 mcMathAndSystem &data_GetLastSys() 00088 { return (mcMathAndSystem &)data_GetLast(); } 00089 const mcMathAndSystem &data_GetLastSys() const 00090 { return (const mcMathAndSystem &)data_GetLast(); } 00091 00092 void data_AddSys(mcMathAndSystem *toadd) 00093 { data_Add(toadd); } 00094 00095 void data_AddLineToNewAndSystem(mcMathLine *toadd); 00096 void data_AddLineToLastAndSystem(mcMathLine *toadd); 00097 00099 int data_GetLineCount() const; 00100 00103 wxString data_GetDescString() const; 00104 00110 void data_SetFilter(const mcFilter *p, int n = -1); 00111 00112 #endif // mcENABLE_DATA 00113 00114 00115 00116 #ifdef mcENABLE_GUI 00117 public: // customizable variables 00118 00119 static bool sgui_bHorizOrientation; 00120 static bool sgui_bDrawOrLabels; 00121 static int sgui_nSpaceAboveBelow; 00122 static int sgui_nSpaceLeftRight; 00123 static int sgui_nSpaceBetween; 00124 00125 protected: 00126 00127 virtual bool gui_DrawHorizontally() const { return sgui_bHorizOrientation; } 00128 virtual bool gui_DrawVertically() const { return !sgui_bHorizOrientation; } 00129 00130 virtual int gui_GetSpaceAboveBelow() const { return sgui_nSpaceAboveBelow; } 00131 virtual int gui_GetSpaceLeftRight() const { return sgui_nSpaceLeftRight; } 00132 virtual int gui_GetSpaceBetween() const { return sgui_nSpaceBetween; } 00133 00134 public: 00135 00136 mcMathAndSystem &gui_GetFocusSys() 00137 { return (mcMathAndSystem &)gui_GetFocus(); } 00138 const mcMathAndSystem &gui_GetFocusSys() const 00139 { return (const mcMathAndSystem &)gui_GetFocus(); } 00140 00141 mcMathLine &gui_GetFocusLine(); 00142 const mcMathLine &gui_GetFocusLine() const; 00143 00144 void gui_AddEmptyLineToNewAndSystem(); 00145 void gui_AddEmptyLineToLastAndSystem(); 00146 00147 void gui_DrawSystemSymbols(wxDC &dc, int x, int y, long flags) const; 00148 void gui_RecalcSymbolSize(); 00149 00152 mcElement gui_GetSelection() const; 00153 00161 virtual int gui_GetActiveElemID() const; 00162 00166 bool gui_isIDChanged() const; 00167 00168 #endif // mcENABLE_GUI 00169 00170 00171 00172 #ifdef mcENABLE_MATH 00173 public: 00174 00176 void math_AndMerge(const mcMathOrSystem &, const mcMathOrSystem &); 00177 00178 void math_OrMerge(const mcMathOrSystem &, const mcMathOrSystem &); 00179 00180 mcMathSystemType math_GetMathSystemType() const; 00181 00182 #endif // mcENABLE_MATH 00183 00184 00185 00186 #ifdef mcENABLE_IO 00187 public: 00188 00189 wxString io_GetInlinedExprOfLogicalOperator() const 00190 { return wxT("OR"); } 00191 00192 bool io_ImportToken(const wxString &str, wxString *perr); 00193 00194 #endif // mcENABLE_IO 00195 }; 00196 00197 00201 class mcMathOrSystem : public mcMathSystem 00202 { 00203 mcDEFINE_MAIN_CLASS(MathOrSystem, mcMathSystem); 00204 00205 public: 00206 00207 mcMathOrSystem(const mcMathAndSystem &towrap) 00208 { data_SetRefData(new mcMathOrSystemHelpers()); data_AddSys(new mcMathAndSystem(towrap)); } 00209 00210 mcMathOrSystem(const mcMathLine &l1, const mcMathLine &l2) 00211 { data_SetRefData(new mcMathOrSystemHelpers()); 00212 data_AddLineToNewAndSystem(new mcMathLine(l1)); 00213 data_AddLineToNewAndSystem(new mcMathLine(l2)); } 00214 00215 bool data_isValidContainerFor(mcElementType t) const 00216 { return t == mcET_MATHORSYSTEM; } 00217 00218 00219 #ifdef mcENABLE_DATA 00220 public: 00221 00222 mcWRAPPER void data_AddSys(mcMathAndSystem *p) 00223 { hlp()->data_AddSys(p); } 00224 mcWRAPPER void data_AddLineToNewAndSystem(mcMathLine *p) 00225 { hlp()->data_AddLineToNewAndSystem(p); } 00226 mcWRAPPER void data_AddLineToLastAndSystem(mcMathLine *p) 00227 { hlp()->data_AddLineToLastAndSystem(p); } 00228 mcWRAPPER mcMathAndSystem &data_GetSys(int n) 00229 { return hlp()->data_GetSys(n); } 00230 mcWRAPPER const mcMathAndSystem &data_GetSys(int n) const 00231 { return hlp()->data_GetSys(n); } 00232 mcWRAPPER void data_SetFilter(const mcFilter *p, int n = -1) 00233 { hlp()->data_SetFilter(p, n); } 00234 mcWRAPPER wxString data_GetDescString() const 00235 { return hlp()->data_GetDescString(); } 00236 00237 mcWRAPPER int gui_GetActiveElemID() const 00238 { return hlp()->gui_GetActiveElemID(); } 00239 00240 #ifdef __MCDEBUG__ 00241 00242 mcWRAPPER wxString data_GetMemoryInfoStr() const 00243 { return hlp()->data_GetMemoryInfoStr(); } 00244 00245 #endif 00246 #endif // mcENABLE_DATA 00247 00248 00249 #ifdef mcENABLE_GUI 00250 public: 00251 00252 mcWRAPPER bool gui_isIDChanged() const 00253 { return hlp()->gui_isIDChanged(); } 00254 00255 mcWRAPPER mcMathLine &gui_GetFocusLine() 00256 { return hlp()->gui_GetFocusLine(); } 00257 mcWRAPPER const mcMathLine &gui_GetFocusLine() const 00258 { return hlp()->gui_GetFocusLine(); } 00259 00260 mcWRAPPER void gui_AddEmptyLineToLastAndSystem() 00261 { hlp()->gui_AddEmptyLineToLastAndSystem(); } 00262 mcWRAPPER void gui_AddEmptyLineToNewAndSystem() 00263 { hlp()->gui_AddEmptyLineToNewAndSystem(); } 00264 00265 #endif 00266 00267 00268 #ifdef mcENABLE_MATH 00269 public: 00270 00271 mcWRAPPER void math_AndMerge(const mcMathOrSystem &arr1, const mcMathOrSystem &arr2) 00272 { hlp()->math_AndMerge(arr1, arr2); } 00273 mcWRAPPER void math_OrMerge(const mcMathOrSystem &arr1, const mcMathOrSystem &arr2) 00274 { hlp()->math_OrMerge(arr1, arr2); } 00275 00276 #endif // mcENABLE_MATH 00277 }; 00278 00279 00280 #endif // mcMATHORSYSTEM 00281
[ Top ] |