00001 00002 // MathGUI = 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 #ifndef PALETTEDLG_H 00033 #define PALETTEDLG_H 00034 00035 // with this little class, we can create a mgButtonListPanel able 00036 // to send commands both to a single, fixed mgMathBox or the 00037 // mgMathBox which is the active one in a mgMathWnd... 00038 #include "mg/MathBoxWndUser.h" 00039 00040 // this allows us to enable/disable the use of wxPaletteFrame 00041 #ifdef mgUSE_PALETTEFRM 00042 #include <wx/palettefrm.h> 00043 #include <wx/minibtn.h> 00044 #else 00045 //#define wxMainFrame wxFrame 00046 #define wxPaletteFrame wxMiniFrame 00047 #define wxPALETTEFRM_DEFAULT_STYLE wxDEFAULT_FRAME_STYLE 00048 #include <wx/minifram.h> 00049 00050 class wxMainFrame : public wxFrame 00051 { 00052 public: 00053 wxMainFrame(wxWindow* parent, wxWindowID id, const wxString& title, 00054 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, 00055 long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxT("frame")) 00056 : wxFrame(parent, id, title, pos, size, style, name) {} 00057 00058 void InitPalContextMenu() {} 00059 }; 00060 00061 #endif 00062 00063 00064 // optimization for GCC compiler 00065 #ifdef __GNUG__ 00066 #pragma interface "PaletteDlg.h" 00067 #endif 00068 00069 00070 #define BUTTONLISTPANEL_MAX_HORIZONTAL_LINES 10 00071 00072 00081 00092 class mgButtonListPanel : public wxPanel, public mgMathBoxWndUser 00093 { 00094 protected: // member variables 00095 00098 //wxSizer *m_pSizerList[BUTTONLISTPANEL_MAX_HORIZONTAL_LINES]; 00099 //int m_nUsedSizers; 00100 int m_nColumns, m_nRows; 00101 int m_nBaseID; 00102 00106 wxWindow *m_pClientWnd; 00107 00110 bool m_bBuildComplete; 00111 00113 wxFont m_fButtons; 00114 float m_fButtonFontRatio; 00115 bool m_bEnableFontButtonUpdate; 00116 00117 00118 protected: // functions 00119 00123 00126 virtual void BuildPanel(int border = 5, int proportion = 30); 00127 00130 virtual void BuildSizer(); 00131 00133 void AddHorizontalSpacer(); 00134 00138 void AddButtonsToSizer(int idoffset, int num, wxSize sz); 00139 00142 wxSize FindBiggestLetter(const wxString &str); 00143 00146 int GetDefaultWidth(const wxString &str) { 00147 wxScreenDC dc; 00148 dc.SetFont(m_fButtons); 00149 return FindBiggestLetter(str).GetWidth()*GetColCount(); 00150 } 00151 00152 int GetDefaultHeight(const wxString &str) { 00153 wxScreenDC dc; 00154 dc.SetFont(m_fButtons); 00155 return FindBiggestLetter(str).GetHeight()*GetRowCount(); 00156 } 00157 00158 void SetFontButtonPointSize(int pointsize); 00159 void UpdateFontButton(); 00160 void OnSize(wxSizeEvent &); 00161 00164 void SetClientWindow(wxWindow *p) { m_pClientWnd = p; } 00165 00168 virtual int GetButtonID(wxCommandEvent &) const; 00169 00170 int GetColCount() const { return m_nColumns; } 00171 int GetRowCount() const { return m_nRows; } 00172 00176 int GetBaseID() const { return m_nBaseID; } 00177 00179 00180 00181 00185 00187 virtual wxString GetButtonLabel(int n) = 0; 00188 00190 virtual wxString GetButtonTooltip(int n) = 0; 00191 00193 00194 00195 public: 00196 00203 mgButtonListPanel( 00204 wxWindow *parent, 00205 wxWindow *client, 00206 mgMathWnd *mathwnd, 00207 mgMathBox *mathbox, 00208 int cols, int rows, 00209 int baseid, 00210 wxWindowID id = -1, 00211 const wxPoint &pos = wxDefaultPosition, 00212 const wxSize &size = wxDefaultSize, 00213 long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) : 00214 wxPanel(parent, id, pos, size, style), 00215 mgMathBoxWndUser(mathwnd, mathbox) { 00216 00217 m_nColumns = cols; 00218 m_nRows = rows; 00219 m_nBaseID = baseid; 00220 m_pClientWnd = client; 00221 m_bBuildComplete = FALSE; 00222 m_bEnableFontButtonUpdate = FALSE; 00223 m_fButtonFontRatio = 0.0; 00224 //m_nUsedSizers = 0; 00225 } 00226 00227 virtual ~mgButtonListPanel() { 00228 // the wxWidgets framework will delete the main sizer... 00229 } 00230 00231 00232 private: 00233 DECLARE_CLASS(mgButtonListPanel) 00234 DECLARE_EVENT_TABLE() 00235 }; 00236 00237 00238 #endif // PALETTE_H 00239
[ Top ] |