bbtkWxGUITextEditor.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00048 #ifdef _USE_WXWIDGETS_
00049
00050
00051 #ifndef __bbtkWxGUITextEditor_h__
00052 #define __bbtkWxGUITextEditor_h__
00053
00054
00055 #include "bbtkWx.h"
00056
00057 #include "bbtkInterpreter.h"
00058 #include <wx/splitter.h>
00059 #include <wx/aui/aui.h>
00060
00061 #include "bbtkWxGUICommand.h"
00062
00063 namespace bbtk
00064 {
00065
00066 class WxTextCtrlGettingKeyEvents;
00067
00068 class WxGUITextEditor;
00069
00070
00072 class BBTK_EXPORT WxGUITextEditorUser
00073 {
00074 public:
00075 WxGUITextEditorUser() {}
00076 virtual ~WxGUITextEditorUser() {}
00078 virtual void WxGUITextEditorRun() {}
00079 virtual void WxGUITextEditorRunBBI() {}
00080 virtual void WxGUITextEditorGraphSimple() {}
00081 virtual void WxGUITextEditorGraphDetail() {}
00082
00083 };
00084
00085
00086 class WxGUITextEditorPage : public wxPanel
00087 {
00088 public:
00089 WxGUITextEditorPage(wxWindow* parent, WxGUITextEditor* editor);
00090 ~WxGUITextEditorPage();
00091
00092 void SetPageName(const std::string& name) { mName = name; }
00093 const std::string& GetPageName() const { return mName; }
00094
00095 bool AskFilename() const { return mAskFilename; }
00096 void SetAskFilename(bool a) { mAskFilename=a; }
00097
00098 WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
00099
00100 void Load(const std::string& filename);
00101 void Save(const std::string& filter);
00102 void SaveFile(const std::string& filename);
00103
00104
00105 bool IsModified();
00106
00107 std::string GetText();
00108
00109 private:
00110 WxGUITextEditor* mEditor;
00111 WxTextCtrlGettingKeyEvents* mwxInputText;
00112 wxTextAttr* mwxInputTextAttr;
00113 wxFont* mFixedFont;
00114 std::string mName;
00115 bool mAskFilename;
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 } ;
00126
00127
00128
00129
00131 class BBTK_EXPORT WxGUITextEditor : public wxPanel
00132 {
00133 public:
00134 WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
00135 ~WxGUITextEditor();
00136
00137 void OnKeyDown(wxKeyEvent& event);
00138 void OnKeyUp(wxKeyEvent& event);
00139
00140 void OnToolLeftClick(wxCommandEvent& event);
00141 void OnToolRightClick(wxCommandEvent& event);
00142
00143 void OnPageClose(wxAuiNotebookEvent& evt);
00144
00145 void New();
00146 void Open();
00147 void Open(const std::string& filename);
00148 void SaveCurrentPage();
00149 bool CloseCurrentPage();
00150 bool CloseAllPages();
00151
00152
00153
00154 void HighlightSyntax();
00155 void UpdateInfo();
00156
00157 void NewPage(const std::string& filename);
00158 WxGUITextEditorPage* GetCurrentPage();
00159 void FocusOnCurrentPage();
00160
00161 void SetFileNameFilter(const std::string& filter)
00162 { mFileNameFilter = filter; }
00163
00164 private:
00165 WxGUITextEditorUser* mUser;
00166
00167
00168
00169 wxNotebook* mwxNotebook;
00170
00171 wxToolBar* mwxToolBar;
00172
00173 wxStaticText* mwxPosition;
00174
00175 std::string mFileNameFilter;
00176
00177 public:
00178
00179 enum
00180 {
00181 ID_ButtonNew,
00182 ID_ButtonOpen,
00183 ID_ButtonClose,
00184 ID_ButtonSave,
00185 ID_ButtonSaveAs,
00186 ID_ButtonRun,
00187 ID_ButtonRunBBI,
00188 ID_ButtonGraphSimple,
00189 ID_ButtonGraphDetail
00190
00191 };
00192
00193 DECLARE_EVENT_TABLE()
00194
00195 };
00196
00197
00199 class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame
00200
00201 {
00202 public:
00203 WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size);
00204 ~WxGUITextEditorWindow();
00205 void Open(const std::string& filename) { mEditor->Open(filename); }
00206
00207
00208
00209 private :
00210
00211 WxGUITextEditor* mEditor;
00212 };
00213
00214
00215 }
00216
00217
00218 #endif // __bbtkWxGUITextEditor_h__
00219
00220 #endif //_USE_WXWIDGETS_