00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00030
00031
00032
00033 #ifndef MATHLINE_H
00034 #define MATHLINE_H
00035
00036
00037 #ifdef __GNUG__
00038 #pragma interface "MathLine.h"
00039 #endif
00040
00041
00042 #include <wx/dcmemory.h>
00043 #include "mc/MathMng.h"
00044
00045
00046
00049
00050 #define mcBMP_STDWIDTH 60
00051 #define mcBMP_STDHEIGHT 60
00052
00057 #define mcBMP_ADDEDWIDTH 30
00058 #define mcBMP_ADDEDHEIGHT 20
00059
00064 #define mcBMP_SPACELEFT 5
00065 #define mcBMP_SPACERIGHT 5
00066
00068
00069
00070
00073 #define mcMATHLINE_DBG_BITMAP 256
00074
00075
00076
00077 class mcMathLine;
00078 extern mcMathLine mcEmptyLine;
00079
00080
00081
00085 class mcDoubleBufferedElement
00086 {
00087 public:
00088 mcDoubleBufferedElement() {}
00089 virtual ~mcDoubleBufferedElement() {}
00090
00091
00092
00097
00107 virtual int gui_UpdateBmp(int x, int y, long flags, const wxPoint &p) = 0;
00108
00115 virtual int gui_DrawBmp(wxDC &dc, int x, int y) const = 0;
00116
00119 virtual int gui_ForceBmpUpdate(int x, int y, long flags, const wxPoint &p) = 0;
00120
00123 virtual bool gui_NeedsRefresh() const = 0;
00124
00127 virtual void gui_SetMask(const wxColour &) = 0;
00128
00131 virtual void gui_SetBmpBackgroundBrush(const wxBrush &) = 0;
00132
00134 };
00135
00136
00137
00138
00148 class mcMathLineHelpers : public mcMathMngHelpers, public mcDoubleBufferedElement
00149 {
00150 #ifdef mcENABLE_GUI
00151 public:
00152
00156 static int sgui_nCursorWidth;
00157
00158 protected:
00159
00163 wxBitmap mgui_bmpMath;
00164
00166 wxBrush mgui_brushBmpBg;
00167
00169 bool mgui_bUsingMask;
00170
00172 int mgui_nLastID;
00173
00175 int mgui_nCurrentID;
00176
00178
00179
00180 #endif
00181
00182
00183 public:
00184
00188 mcMathLineHelpers() { data_Init(); }
00189 virtual ~mcMathLineHelpers() {}
00190
00191
00193 void gui_Init();
00194
00195
00196
00197 #ifdef mcENABLE_DATA
00198 public:
00199
00201 void data_DeepCopy(const mcElementHelpers *mbl);
00202
00203 #ifdef __MCDEBUG__
00204
00206 wxString data_Debug(long flags) const;
00207
00208 #endif
00209 #endif // mcENABLE_DATA
00210
00211
00212
00213 #ifdef mcENABLE_GUI
00214 public:
00215
00220
00221 int gui_UpdateBmp(int x, int y, long flags, const wxPoint &p);
00222 int gui_DrawBmp(wxDC &dc, int x, int y) const;
00223
00224 void gui_SetMask(const wxColour &);
00225
00226 int gui_ForceBmpUpdate(int x, int y, long flags, const wxPoint &p)
00227 { return gui_UpdateBmp(x, y, flags, p); }
00228
00229 bool gui_NeedsRefresh() const
00230 { return gui_isIDChanged(); }
00231
00236 void gui_SetBmpBackgroundBrush(const wxBrush &br)
00237 { mgui_brushBmpBg = br; }
00238
00244 void gui_ExpandBmp();
00245
00248 bool gui_isIDChanged() const {
00249 return (mgui_nLastID != mgui_nCurrentID);
00250 }
00251
00253 int gui_GetActiveElemID() const {
00254 return mgui_nCurrentID;
00255 }
00256
00258
00259
00260
00265
00266 mcElement gui_GetSelection() const;
00267 int gui_GetRelCursorPos(wxDC &dc, wxPoint *) const;
00268 int gui_MoveCursorUsingPoint(wxDC &, const wxPoint &);
00269 void gui_OnSelect(wxDC &dc, wxRect &);
00270
00275 void gui_DoRecalcSize();
00276
00278
00279 #endif // mcENABLE_GUI
00280 };
00281
00282
00287 class mcMathLine : public mcMathMng
00288 {
00289
00290
00291
00292 mcDEFINE_CLASS(MathLine);
00293
00294 public:
00295
00296
00297
00298
00299
00300
00301 mcMathLine(const mcElementHelpers *p) : mcMathMng(p) { data_CheckContainer(); }
00302 mcMathLine(const mcElement &v) : mcMathMng(v.hlp()) { data_CheckContainer(); }
00303 mcMathLine(const mcMathLine &toref) : mcMathMng(NULL) { data_Ref(toref); }
00304 mcMathLine() : mcMathMng(NULL) { data_SetRefData(new mcMathLineHelpers); }
00305
00306
00307 mcMathLine(const mcPolynomial &left, const mcPolynomial &right) : mcMathMng(NULL)
00308 { data_SetRefData(new mcMathLineHelpers); data_Init(left, right); }
00309 mcMathLine(const mcMathMng &p) : mcMathMng(NULL) {
00310 mcMathLineHelpers *h = new mcMathLineHelpers();
00311 h->mcMathMngHelpers::data_DeepCopy(p.chlp());
00312 data_SetRefData(h);
00313 }
00314
00315 virtual ~mcMathLine() {}
00316
00317
00318
00319 bool data_isValidContainerFor(mcElementType t) const
00320 { return t == mcET_MATHMNG; }
00321
00322 mcWRAPPER int gui_GetActiveElemID() const
00323 { return hlp()->gui_GetActiveElemID(); }
00324 mcWRAPPER int gui_isIDChanged() const
00325 { return hlp()->gui_isIDChanged(); }
00326
00327 mcWRAPPER int gui_UpdateBmp(int x, int y, long flags, const wxPoint &p)
00328 { return hlp()->gui_UpdateBmp(x, y, flags, p); }
00329 mcWRAPPER int gui_ForceBmpUpdate(int x, int y, long flags, const wxPoint &p)
00330 { return hlp()->gui_ForceBmpUpdate(x, y, flags, p); }
00331 mcWRAPPER int gui_DrawBmp(wxDC &dc, int x, int y) const
00332 { return hlp()->gui_DrawBmp(dc, x, y); }
00333 };
00334
00335
00336 #endif // MATHLINE_H
00337
00338