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 // // 00025 // \file OptFontSettings.h 00026 // \brief Defines the mgOptFontSettingsPanel class. 00027 // 00028 // See OptFontSettings.cpp for more info. 00030 00031 00032 00033 00034 #ifndef OPTFONTSETTINGS_H 00035 #define OPTFONTSETTINGS_H 00036 00037 00038 #if defined(__GNUG__) && !defined(__APPLE__) 00039 #pragma interface "OptFontSettingsPanel.h" 00040 #endif 00041 00042 // For compilers that support precompilation, includes "wx/wx.h". 00043 /*#include "wx/wxprec.h" 00044 00045 #ifdef __BORLANDC__ 00046 #pragma hdrstop 00047 #endif 00048 00049 // for all others, include the necessary headers 00050 #ifndef WX_PRECOMP 00051 #include "wx/wx.h" 00052 #endif 00053 */ 00054 00055 // includes 00056 #include <wx/fontenum.h> // for wxFontEnumerator 00057 #include <mg/OptBasePanel.h> 00058 #include <mg/MathBox.h> // for mgMathBox 00059 #include <mc/MathUtils.h> // for mcTextSettings 00060 00061 00062 // ids 00063 #define OPTIONSDLG_FONTPANEL_EXPDEPTH OPTIONSDLG_FONTPANEL_BASEID+1 00064 #define OPTIONSDLG_FONTPANEL_PREVIEWBOX OPTIONSDLG_FONTPANEL_BASEID+2 00065 00066 // the base ids for the font-setting rows 00067 #define OPTIONSDLG_FONTPANEL_SETTINGBASEID OPTIONSDLG_FONTPANEL_BASEID+5 00068 #define OPTIONSDLG_FONTPANEL_NUMSETTINGS 6 // the number of font-settings rows 00069 00070 // the idoffsets for each font-setting row 00071 #define OPTIONSDLG_FONTPANEL_FONTFACE_IDOFFSET 1 00072 #define OPTIONSDLG_FONTPANEL_FONTSIZE_IDOFFSET 2 00073 #define OPTIONSDLG_FONTPANEL_FGCOL_IDOFFSET 3 00074 #define OPTIONSDLG_FONTPANEL_BKCOL_IDOFFSET 4 00075 00076 // the number of previous idoffsets defined... 00077 #define OPTIONSDLG_FONTPANEL_SETTING_IDOFFSET 5 00078 00079 00080 00081 00084 class mgOptFontEnumerator : public wxFontEnumerator 00085 { 00086 // The array where all font faces are stored. 00087 wxArrayString m_facenames; 00088 00089 public: 00090 int GetCount() const 00091 { return m_facenames.GetCount(); } 00092 00093 const wxArrayString &GetFacenames() const 00094 { return m_facenames; } 00095 00096 wxString *GetFacenamesArray() const { 00097 00098 // return a wxString[], useful for the controls which 00099 // take one in their ctor. You must delete[] it yourself 00100 // once you are done with it. Will return NULL if the 00101 // ArrayString was empty. 00102 return m_facenames.GetStringArray(); 00103 } 00104 00105 protected: 00106 00107 // The overridden wxFontEnumerator function 00108 virtual bool OnFacename(const wxString& facename) { 00109 m_facenames.Add(facename); 00110 return TRUE; 00111 } 00112 }; 00113 00114 00115 00122 class mgOptFontSettingsPanel : public mgOptBasePanel 00123 { 00124 protected: // member variables 00125 00134 int m_nBaseID[OPTIONSDLG_FONTPANEL_NUMSETTINGS]; 00135 00138 static wxString m_strSettingsLabel[OPTIONSDLG_FONTPANEL_NUMSETTINGS]; 00139 00143 mgMathBox *m_pPreviewBox; 00144 00146 wxChoice *m_pExpDepthChoice; 00147 00149 wxString *m_pFontFaces; 00150 00152 mgOptFontEnumerator m_fntEnumerator; 00153 00154 00155 protected: // functions 00156 00157 virtual void Setup( const wxString &itemLabel ); 00158 virtual mgOptDlg::mgOptChangedType CommitChanges( wxConfig* config ); 00159 00162 void BuildCtrls(); 00163 00168 void BuildFontSettings(wxFlexGridSizer *table, const wxString &label, int id); 00169 00172 void ReadSettings(int id, const mcTextSettings &p); 00173 00176 void SaveSettings(int id, mcTextSettings &p); 00177 00179 void OnExpDepthChange(wxCommandEvent &); 00180 00182 void OnActiveElemChange(wxCommandEvent &ev); 00183 00187 const mcTextSettings &GetSettingsFromBaseID(const mcStyle *p, int id); 00188 00193 const mcTextSettings &GetSettingsFromBaseID(int expdepth, int id); 00194 00195 public: 00196 00197 mgOptFontSettingsPanel(); 00198 virtual ~mgOptFontSettingsPanel(); 00199 00200 00201 private: 00202 DECLARE_DYNAMIC_CLASS( mgOptFontSettingsPanel ) 00203 DECLARE_EVENT_TABLE() 00204 }; 00205 00206 00207 #endif // not defined OPTFONTSETTINGS_H 00208
[ Top ] |