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 // // 00031 00032 00033 00034 #ifndef mcDECORATION_H 00035 #define mcDECORATION_H 00036 00037 00038 // optimization for GCC compiler 00039 #ifdef __GNUG__ 00040 #pragma interface "Decoration.h" 00041 #endif 00042 00043 00044 // required includes 00045 #include "mc/Element.h" 00046 00047 00048 mcDEFINE_HELPER_CLASSES(mcDecoration) 00049 00050 00051 00052 00053 00054 class mcDecorationHelpers : public mcElementHelpers 00055 { 00056 #ifdef mcENABLE_DATA 00057 public: // DATA variables 00058 00060 const mcElement &data_GetConstChild(int n) const 00061 { return mcEmptyElement; } 00062 #endif 00063 00064 00065 00066 #ifdef mcENABLE_GUI 00067 protected: // GUI variables 00068 00069 int mgui_nCursorPos; 00070 00071 #define mcDECORATION_LEFT 0 00072 #define mcDECORATION_RIGHT 1 00073 00074 #endif 00075 00076 00077 00078 00079 public: 00080 mcDecorationHelpers() { /* data_Init() must be called by derived class */ } 00081 virtual ~mcDecorationHelpers() {} 00082 00083 00084 protected: 00085 00086 void gui_Init() { 00087 mcElementHelpers::gui_Init(); 00088 mgui_nCursorPos = mcDECORATION_RIGHT; 00089 } 00090 00091 00092 00093 00094 #ifdef mcENABLE_DATA 00095 public: 00096 00097 void data_DeepCopy(const mcElementHelpers *p) { 00098 const mcDecorationHelpers *d = (const mcDecorationHelpers *)p; 00099 mgui_nCursorPos = d->mgui_nCursorPos; 00100 mcElementHelpers::data_DeepCopy(p); 00101 } 00102 00103 #ifdef __MCDEBUG__ 00104 00105 wxString data_Debug(long flags) const 00106 { return wxT("mcDecoration\n"); } 00107 00108 #endif 00109 #endif // mcENABLE_DATA 00110 00111 00112 00113 #ifdef mcENABLE_GUI 00114 public: 00115 00119 00122 bool gui_isBeginKey(const mcKey &key) const { 00123 return FALSE; 00124 } 00125 00129 bool gui_isEndKey(const mcKey &key) const; 00130 00131 mcInputRes gui_Input(const mcKey &key, mcElement *pnew); 00132 mcMoveCursorRes gui_MoveCursor(mcMoveCursorFlag flag, long modifiers); 00133 mcInsertRes gui_Insert(const mcElement &, mcElement *) { return mcINSR_OKAY; } 00134 00135 int gui_MoveCursorUsingPoint(wxDC &dc, const wxPoint &p); 00136 int gui_GetRelCursorPos(wxDC &dc, wxPoint *pt) const; 00137 void gui_SetCursorPos(const mcCursorPos &code); 00138 void gui_GetCursorPos(mcCursorPos &) const; 00139 mcCursorPos gui_GetCursorPos() const 00140 { return mcElementHelpers::gui_GetCursorPos(); } 00141 00143 #endif // mcENABLE_GUI 00144 00145 00146 00147 #ifdef mcENABLE_MATH 00148 public: 00149 00150 mcExpSimRes math_Simplify(long flags, mcElement *) { return mcESR_DONE; } 00151 mcExpSimRes math_Expand(long flags, mcElement *) { return mcESR_DONE; } 00152 00153 // these do not apply on this object 00154 bool math_CanBeAddedWith(const mcElement &p) const { return FALSE; } 00155 bool math_CanBeMultWith(const mcElement &p) const { return FALSE; } 00156 bool math_CanBeDivBy(const mcElement &p) const { return FALSE; } 00157 00158 virtual mcBasicOpRes math_Add(const mcElement &, mcElement *p, bool add) { return mcBOR_REMOVE_OPERAND; } 00159 virtual mcBasicOpRes math_Subtract(const mcElement &, mcElement *p) { return mcBOR_REMOVE_OPERAND; } 00160 virtual mcBasicOpRes math_MultiplyBy(const mcElement &, mcElement *p) { return mcBOR_REMOVE_OPERAND; } 00161 virtual mcBasicOpRes math_DivideBy(const mcElement &, mcElement *p) { return mcBOR_REMOVE_OPERAND; } 00162 00163 void math_SetExp(const mcPolynomial &p) { /* do nothing */ } 00164 mcBasicOpRes math_MakeReciprocal(mcElement *e) { return mcBOR_REMOVE_OPERAND; } 00165 mcBasicOpRes math_RaiseTo(const mcPolynomial &) { return mcBOR_REMOVE_OPERAND; } 00166 00167 mcMathType math_GetMathType() const 00168 { return mcMathType(mcMTL1_POLYNOMIAL, mcMTL2_ALGEBRAIC, mcMTL3_CONSTANT); } 00169 00170 bool math_Compare(const mcElement &p, long flags) const 00171 { return math_CompareThisOnly(p, flags); } 00172 00173 mcRealValue math_Evaluate() const { return *mcRealValue::pNAN; } 00174 mcRealValue math_GetLenght() const { return *mcRealValue::pNAN; } 00175 00176 00177 int math_GetOrderPos() const { return -1; } 00178 00179 mcMonomial math_GetLCM(const mcElement &) const;// { return mcEmptyElement; } 00180 mcMonomial math_GetGCD(const mcElement &) const;// { return mcEmptyElement; } 00181 //mcPolynomial &math_GetFactors() const { return mcEmptyElement; } 00182 #endif // mcENABLE_MATH 00183 00184 00185 00186 00187 #ifdef mcENABLE_IO 00188 public: 00189 00190 bool io_isBeginTag(const wxXml2Node &tag) const { 00191 if (tag.GetName() == wxT("mdecoration")) 00192 return TRUE; 00193 return FALSE; 00194 } 00195 00196 bool io_isBeginChar(const wxString &str) const { 00197 return FALSE; 00198 } 00199 00200 wxXml2Node io_GetMathML(bool bGetPresentation) const; 00201 wxString io_GetInlinedExpr() const; 00202 00203 bool io_ImportPresentationMathML(wxXml2Node tag, wxString &pErr); 00204 bool io_ImportInlinedExpr(const wxString &str, int *count, wxString &pErr); 00205 00206 #endif // mcENABLE_IO 00207 }; 00208 00209 00210 00211 00214 class mcDecoration : public mcElement 00215 { 00216 mcDEFINE_ABSTRACT_CLASS(Decoration, mcElement); 00217 00218 public: 00219 00220 bool data_isValidContainerFor(mcElementType t) const 00221 { return t == mcET_DIVOP || t == mcET_MULTOP || 00222 t == mcET_ADDOP || t == mcET_SUBOP || 00223 t == mcET_PARENTHESIS || t == mcET_TEXT || 00224 t == mcET_EMPTYBOX; } 00225 }; 00226 00227 #endif // mcDECORATION_H 00228
[ Top ] |