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 00033 // optimization for GCC compiler 00034 #ifdef __GNUG__ 00035 #pragma implementation "GreekDlg.h" 00036 #endif 00037 00038 // includes 00039 #include "mg/mgprec.h" 00040 #include <wx/statline.h> // not included in wxprec.h 00041 00042 #ifndef mgPRECOMP 00043 #include <wx/wxprec.h> 00044 //#include "wx/minibtn.h" 00045 #include "mg/GUIUtils.h" 00046 #include "mg/GreekDlg.h" 00047 #endif 00048 00049 00050 00051 00052 // event tables 00053 BEGIN_EVENT_TABLE(mgSmallGreekPanel, mgButtonListPanel) 00054 00055 // buttons 00056 EVT_COMMAND_RANGE(IDC_GREEKDLG_SMALLBUTTONS, 00057 (IDC_GREEKDLG_SMALLBUTTONS+GREEKDLG_ALPHABET_LENGHT), 00058 wxEVT_COMMAND_BUTTON_CLICKED, mgSmallGreekPanel::OnButtons) 00059 00060 END_EVENT_TABLE() 00061 00062 BEGIN_EVENT_TABLE(mgCapitalGreekPanel, mgButtonListPanel) 00063 00064 // buttons 00065 EVT_COMMAND_RANGE(IDC_GREEKDLG_CAPITALBUTTONS, 00066 (IDC_GREEKDLG_CAPITALBUTTONS+GREEKDLG_ALPHABET_LENGHT), 00067 wxEVT_COMMAND_BUTTON_CLICKED, mgCapitalGreekPanel::OnButtons) 00068 00069 END_EVENT_TABLE() 00070 00071 00072 00073 00074 // setup STATIC variables 00075 00076 // in Unicode we would have two ways to do this: 00077 // 1) we can use the standard greek characters (lowercase from 0x03B1 to 00078 // 0x03C9; uppercase from 0x0391 to 0x03A9) 00079 // 2) we can use the greek mathematical characters which range from 00080 // 0x1D6A8 to 0x1D6DA. As you can see, these solution requires the use 00081 // of the UTF32 standard. 00082 // since the 2nd solution is the harder way (because of UTF32 and the lack 00083 // fonts which implement all those gliphs) even if it would be the most 00084 // correct one, we'll use the first way. 00085 // 00086 // note: the final sigma characters (0x03C2 and 0x03A2) won't be used in the 00087 // following list... 00088 wxString mgSmallGreekPanel::strSmallAlphabet = 00089 wxT("\x03B1\x03B2\x03B3\x03B4\x03B5\x03B6\x03B7\x03B8\x03B9\x03BA\x03BB\x03BC\x03BD\x03BE\x03BF") 00090 wxT("\x03C0\x03C1\x03C3\x03C4\x03C5\x03C6\x03C7\x03C8\x03C9"); 00091 wxString mgCapitalGreekPanel::strCapitalAlphabet = 00092 wxT("\x0391\x0392\x0393\x0394\x0395\x0396\x0397\x0398\x0399\x039A\x039B\x039C\x039D\x039E\x039F") 00093 wxT("\x03A0\x03A1\x03A3\x03A4\x03A5\x03A6\x03A7\x03A8\x03A9"); 00094 00095 wxString mgSmallGreekPanel::strLetterNames[] = { wxT("Alfa"), wxT("Beta"), wxT("Gamma"), wxT("Delta"), 00096 wxT("Epsilon"), wxT("Zeta"), wxT("Eta"), wxT("Teta"), wxT("Iota"), wxT("Cappa"), wxT("Lambda"), wxT("Mi"), wxT("Ni"), 00097 wxT("Xi"), wxT("Omicron"), wxT("Pi"), wxT("Ro"), wxT("Sigma"), wxT("Tau"), wxT("Ipsilon"), wxT("Fi"), wxT("Chi"), 00098 wxT("Psi"), wxT("Omega") }; 00099 00100 00101 00102 00103 // ------------------- 00104 // mgSMALLGREEKPANEL 00105 // ------------------- 00106 00107 mgSmallGreekPanel::mgSmallGreekPanel(wxWindow *parent, wxWindow *client, mgMathWnd *mathwnd, mgMathBox *mathbox, 00108 wxWindowID id, const wxPoint &position, const wxSize& size, long style) : 00109 // init base class 00110 mgButtonListPanel(parent, client, mathwnd, mathbox, 00111 GREEKDLG_GRID_COLUMNS, GREEKDLG_GRID_ROWS, IDC_GREEKDLG_SMALLBUTTONS, 00112 id, position, size, style) 00113 { 00114 // set up the font containing the greek symbols 00115 m_fButtons = mcElementHelpers::gui_GetDefaultStyle(0)->GetSpecialTextSettings()->m_hFont; 00116 m_bEnableFontButtonUpdate = TRUE; 00117 SetFontButtonPointSize(GREEKDLG_FONT_POINTSIZE); 00118 00119 // build this panel 00120 BuildSizer(); 00121 AddButtonsToSizer(0, strSmallAlphabet.Len(), 00122 wxSize(GREEKDLG_BUTTON_MINWIDTH, GREEKDLG_BUTTON_MINHEIGHT)); 00123 //FindBiggestLetter(strSmallAlphabet)); 00124 BuildPanel(0, 50); 00125 } 00126 00127 00128 void mgSmallGreekPanel::OnButtons( wxCommandEvent &ev ) 00129 { 00130 // the ID of the button clicked contains the ASCII code of the greek 00131 // letter to send to the mathbox: extract it and then send it with 00132 // a negative sign to indicate that it must be interpreted as greek ! 00133 SendSpecialKeyEvent(this, strSmallAlphabet.GetChar(GetButtonID(ev))); 00134 } 00135 00136 00137 00138 00139 // --------------------- 00140 // mgCAPITALGREEKPANEL 00141 // --------------------- 00142 00143 mgCapitalGreekPanel::mgCapitalGreekPanel(wxWindow *parent, wxWindow *client, mgMathWnd *mathwnd, mgMathBox *mathbox, 00144 wxWindowID id, const wxPoint &position, const wxSize& size, long style) : 00145 // init base class 00146 mgButtonListPanel(parent, client, mathwnd, mathbox, 00147 GREEKDLG_GRID_COLUMNS, GREEKDLG_GRID_ROWS, IDC_GREEKDLG_CAPITALBUTTONS, 00148 id, position, size, style) 00149 { 00150 // set up the font containing the greek symbols 00151 m_fButtons = mcElementHelpers::gui_GetDefaultStyle(0)->GetSpecialTextSettings()->m_hFont; 00152 m_bEnableFontButtonUpdate = TRUE; 00153 SetFontButtonPointSize(GREEKDLG_FONT_POINTSIZE); 00154 00155 // build this panel 00156 BuildSizer(); 00157 AddButtonsToSizer(0, strCapitalAlphabet.Len(), 00158 wxSize(GREEKDLG_BUTTON_MINWIDTH, GREEKDLG_BUTTON_MINHEIGHT)); 00159 //FindBiggestLetter(strCapitalAlphabet)); 00160 BuildPanel(0, 50); 00161 } 00162 00163 00164 void mgCapitalGreekPanel::OnButtons( wxCommandEvent &ev ) 00165 { 00166 // the ID of the button clicked contains the ASCII code of the greek 00167 // letter to send to the mathbox: extract it and then send it with 00168 // a negative sign to indicate that it must be interpreted as greek ! 00169 SendSpecialKeyEvent(this, strCapitalAlphabet.GetChar(GetButtonID(ev))); 00170 } 00171 00172 00173 00174 00175 00176 // ----------------- 00177 // mgGREEKPALETTE 00178 // ----------------- 00179 00180 void mgGreekPalette::Build(wxWindow *client, mgMathWnd *mathwnd, mgMathBox *mathbox) 00181 { 00182 wxPanel *main = new wxPanel(this); 00183 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); 00184 00185 // create a sizer containing both the mgSmallGreekPanel & the 00186 // mgCapitalGreekPanel panels separed by an horizontal line 00187 sizer->Add(new mgSmallGreekPanel(main, client, mathwnd, mathbox), 00188 1, wxGROW | wxALL, 5); 00189 sizer->Add(new wxStaticLine(main, -1), 00190 0, wxGROW | wxLEFT | wxRIGHT, 5); 00191 sizer->Add(new mgCapitalGreekPanel(main, client, mathwnd, mathbox), 00192 1, wxGROW | wxALL, 5); 00193 00194 main->SetSizer(sizer); 00195 sizer->SetSizeHints(main); 00196 00197 #ifdef mgUSE_PALETTEFRM 00198 SetClient(main); 00199 AddMiniButton(new wxCollapseBox(this)); 00200 SetSizeHintsUsingClientHints(); 00201 #else 00202 //SendSizeEvent(); 00203 SetSize(300, 180); // an arbitrary size 00204 #endif 00205 } 00206 00207 00208 00209
[ Top ] |