1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "mainframe.h"
22 #include "wx/html/htmlwin.h"
23 #include "wx/notebook.h"
24 #include "wx/splitter.h"
25 #include "wx/clipbrd.h"
26 #include "wx/cshelp.h"
28 #include "wxconfigtool.h"
29 #include "mainframe.h"
30 #include "appsettings.h"
32 #include "configtree.h"
33 #include "propeditor.h"
34 #include "configtooldoc.h"
35 #include "configtoolview.h"
36 #include "configbrowser.h"
38 #include "bitmaps/wxconfigtool.xpm"
40 #include "bitmaps/copy.xpm"
41 #include "bitmaps/cut.xpm"
42 #include "bitmaps/paste.xpm"
43 #include "bitmaps/open.xpm"
44 #include "bitmaps/save.xpm"
45 #include "bitmaps/new.xpm"
46 #include "bitmaps/help.xpm"
47 #include "bitmaps/undo.xpm"
48 #include "bitmaps/redo.xpm"
49 #include "bitmaps/helpcs.xpm"
50 #include "bitmaps/go.xpm"
52 IMPLEMENT_CLASS(ctMainFrame
, wxDocParentFrame
)
54 BEGIN_EVENT_TABLE(ctMainFrame
, wxDocParentFrame
)
55 EVT_CLOSE(ctMainFrame::OnCloseWindow
)
56 EVT_MENU(wxID_ABOUT
, ctMainFrame::OnAbout
)
57 EVT_MENU(wxID_OPEN
, ctMainFrame::OnOpen
)
58 EVT_MENU(wxID_NEW
, ctMainFrame::OnNew
)
59 EVT_MENU(wxID_EXIT
, ctMainFrame::OnExit
)
60 EVT_MENU(ctID_SETTINGS
, ctMainFrame::OnSettings
)
61 EVT_MENU(ctID_SHOW_TOOLBAR
, ctMainFrame::OnShowToolbar
)
62 EVT_MENU(wxID_HELP
, ctMainFrame::OnHelp
)
63 EVT_MENU(ctID_REFERENCE_CONTENTS
, ctMainFrame::OnReferenceHelp
)
64 EVT_MENU(wxID_HELP_CONTEXT
, ctMainFrame::OnContextHelp
)
66 EVT_UPDATE_UI(ctID_ADD_ITEM_CHECKBOX
, ctMainFrame::OnUpdateDisable
)
67 EVT_UPDATE_UI(ctID_ADD_ITEM_RADIOBUTTON
, ctMainFrame::OnUpdateDisable
)
68 EVT_UPDATE_UI(ctID_ADD_ITEM_GROUP
, ctMainFrame::OnUpdateDisable
)
69 EVT_UPDATE_UI(ctID_ADD_ITEM_CHECK_GROUP
, ctMainFrame::OnUpdateDisable
)
70 EVT_UPDATE_UI(ctID_ADD_ITEM_RADIO_GROUP
, ctMainFrame::OnUpdateDisable
)
71 EVT_UPDATE_UI(ctID_ADD_ITEM_STRING
, ctMainFrame::OnUpdateDisable
)
72 EVT_UPDATE_UI(ctID_DELETE_ITEM
, ctMainFrame::OnUpdateDisable
)
73 EVT_UPDATE_UI(ctID_RENAME_ITEM
, ctMainFrame::OnUpdateDisable
)
74 EVT_UPDATE_UI(wxID_COPY
, ctMainFrame::OnUpdateDisable
)
75 EVT_UPDATE_UI(wxID_CUT
, ctMainFrame::OnUpdateDisable
)
76 EVT_UPDATE_UI(wxID_PASTE
, ctMainFrame::OnUpdateDisable
)
77 EVT_UPDATE_UI(ctID_ITEM_HELP
, ctMainFrame::OnUpdateDisable
)
79 EVT_UPDATE_UI(ctID_ADD_CUSTOM_PROPERTY
, ctMainFrame::OnUpdateDisable
)
80 EVT_UPDATE_UI(ctID_EDIT_CUSTOM_PROPERTY
, ctMainFrame::OnUpdateDisable
)
81 EVT_UPDATE_UI(ctID_DELETE_CUSTOM_PROPERTY
, ctMainFrame::OnUpdateDisable
)
83 EVT_UPDATE_UI(ctID_SAVE_SETUP_FILE
, ctMainFrame::OnUpdateDisable
)
84 EVT_UPDATE_UI(ctID_SAVE_CONFIGURE_COMMAND
, ctMainFrame::OnUpdateDisable
)
86 EVT_UPDATE_UI(wxID_FIND
, ctMainFrame::OnUpdateDisable
)
88 EVT_UPDATE_UI(ctID_GO
, ctMainFrame::OnUpdateDisable
)
91 // Define my frame constructor
92 ctMainFrame::ctMainFrame(wxDocManager
*manager
, wxFrame
*parent
, wxWindowID id
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
,
94 wxDocParentFrame(manager
, parent
, id
, title
, pos
, size
, style
)
98 m_configurePage
= NULL
;
100 m_configBrowserPage
= NULL
;
101 m_mainNotebook
= NULL
;
104 m_treeSplitterWindow
= new wxSplitterWindow(this, -1, wxDefaultPosition
, wxSize(400, 300),
105 wxSP_3DSASH
|wxSP_3DBORDER
|wxNO_FULL_REPAINT_ON_RESIZE
|wxCLIP_CHILDREN
);
107 m_configTreeCtrl
= new ctConfigTreeCtrl(m_treeSplitterWindow
, -1, wxDefaultPosition
, wxDefaultSize
,
108 wxTR_HAS_BUTTONS
|wxNO_BORDER
|wxNO_FULL_REPAINT_ON_RESIZE
|wxCLIP_CHILDREN
);
110 m_mainNotebook
= new wxNotebook(m_treeSplitterWindow
, -1, wxDefaultPosition
, wxSize(300, 300),
111 wxNO_FULL_REPAINT_ON_RESIZE
|wxCLIP_CHILDREN
);
113 m_propertyEditor
= new ctPropertyEditor(m_mainNotebook
, -1, wxDefaultPosition
, wxSize(300, 200),
114 wxNO_BORDER
|wxNO_FULL_REPAINT_ON_RESIZE
|wxCLIP_CHILDREN
);
115 m_setupPage
= new ctOutputWindow(m_mainNotebook
, -1, wxDefaultPosition
, wxSize(300, 200),
116 wxNO_BORDER
|wxNO_FULL_REPAINT_ON_RESIZE
|wxCLIP_CHILDREN
);
117 m_configurePage
= new ctOutputWindow(m_mainNotebook
, -1, wxDefaultPosition
, wxSize(300, 200),
118 wxNO_BORDER
|wxNO_FULL_REPAINT_ON_RESIZE
|wxCLIP_CHILDREN
);
121 m_configBrowserPage
= new ctConfigurationBrowserWindow(m_mainNotebook
, -1, wxDefaultPosition
, wxSize(300, 200),
122 wxNO_BORDER
|wxNO_FULL_REPAINT_ON_RESIZE
|wxCLIP_CHILDREN
);
125 m_mainNotebook
->AddPage(m_propertyEditor
, _T("Properties"));
127 m_mainNotebook
->AddPage(m_configBrowserPage
, _T("Configuration Browser"));
129 m_mainNotebook
->AddPage(m_setupPage
, _T("setup.h"));
130 m_mainNotebook
->AddPage(m_configurePage
, _T("configure"));
132 // Need to do this afterwards since wxWin sets the XP background
134 m_propertyEditor
->GetDescriptionWindow()->SetBackgroundColour(ctDESCRIPTION_BACKGROUND_COLOUR
);
136 int sashPos
= wxGetApp().GetSettings().m_mainSashSize
;
137 m_treeSplitterWindow
->SplitVertically(m_configTreeCtrl
, m_mainNotebook
, sashPos
);
139 SetIcon(wxIcon(wxconfigtool_xpm
));
143 wxMenuBar
* menuBar
= CreateMenuBar();
146 CreateToolBar(wxNO_BORDER
|wxTB_FLAT
|wxTB_HORIZONTAL
|wxNO_FULL_REPAINT_ON_RESIZE
|wxCLIP_CHILDREN
);
147 InitToolBar(GetToolBar());
149 if (wxGetApp().GetSettings().m_showToolBar
)
151 menuBar
->Check(ctID_SHOW_TOOLBAR
, TRUE
);
155 menuBar
->Check(ctID_SHOW_TOOLBAR
, FALSE
);
156 GetToolBar()->Show(FALSE
);
161 void ctMainFrame::OnCloseWindow(wxCloseEvent
& event
)
165 if (!GetDocument()->DeleteAllViews() && event
.CanVeto())
174 m_findDialog
->Destroy();
181 wxGetApp().GetSettings().m_frameStatus
= ctSHOW_STATUS_MAXIMIZED
;
182 else if (IsIconized())
183 wxGetApp().GetSettings().m_frameStatus
= ctSHOW_STATUS_MINIMIZED
;
185 wxGetApp().GetSettings().m_frameStatus
= ctSHOW_STATUS_NORMAL
;
187 // Must delete this now since the DLL loading library will be
188 // uninitialised by the time the app object is deleted
189 wxGetApp().ClearHelpControllers();
191 if (!IsMaximized() && !IsIconized())
193 wxGetApp().GetSettings().m_frameSize
= GetRect();
194 wxGetApp().GetSettings().m_mainSashSize
= m_treeSplitterWindow
->GetSashPosition();
200 void ctMainFrame::OnAbout(wxCommandEvent
& event
)
202 wxString msg
= wxGetApp().GetSettings().GetAppName() + wxT(" (c) Julian Smart");
203 wxString caption
= wxT("About ") + wxGetApp().GetSettings().GetAppName();
204 wxMessageBox(msg
, caption
, wxOK
|wxICON_INFORMATION
);
207 void ctMainFrame::OnOpen(wxCommandEvent
& event
)
209 wxGetApp().GetDocManager()->OnFileOpen(event
);
212 void ctMainFrame::OnNew(wxCommandEvent
& event
)
214 wxGetApp().GetDocManager()->OnFileNew(event
);
217 void ctMainFrame::OnExit(wxCommandEvent
& event
)
222 void ctMainFrame::OnSettings(wxCommandEvent
& event
)
224 wxGetApp().GetSettings().ShowSettingsDialog();
227 void ctMainFrame::InitToolBar(wxToolBar
* toolBar
)
229 toolBar
->SetHelpText(wxT("The toolbar gives you easy access to commonly used commands."));
232 wxBitmap toolBarBitmaps
[20];
234 toolBarBitmaps
[0] = wxBitmap(new_xpm
);
235 toolBarBitmaps
[1] = wxBitmap(open_xpm
);
236 toolBarBitmaps
[2] = wxBitmap(save_xpm
);
237 toolBarBitmaps
[3] = wxBitmap(copy_xpm
);
238 toolBarBitmaps
[4] = wxBitmap(cut_xpm
);
239 toolBarBitmaps
[5] = wxBitmap(paste_xpm
);
240 toolBarBitmaps
[6] = wxBitmap(go_xpm
);
241 toolBarBitmaps
[7] = wxBitmap(help_xpm
);
242 toolBarBitmaps
[10] = wxBitmap(undo_xpm
);
243 toolBarBitmaps
[11] = wxBitmap(redo_xpm
);
244 toolBarBitmaps
[12] = wxBitmap(help_xpm
);
245 toolBarBitmaps
[13] = wxBitmap(helpcs_xpm
);
247 toolBar
->AddTool(wxID_NEW
, toolBarBitmaps
[0], wxNullBitmap
, FALSE
, -1, -1, (wxObject
*) NULL
, wxT("New project"));
248 toolBar
->AddTool(wxID_OPEN
, toolBarBitmaps
[1], wxNullBitmap
, FALSE
, -1, -1, (wxObject
*) NULL
, wxT("Open project"));
249 toolBar
->AddTool(wxID_SAVE
, toolBarBitmaps
[2], wxNullBitmap
, FALSE
, -1, -1, (wxObject
*) NULL
, wxT("Save project"));
251 toolBar
->AddSeparator();
252 toolBar
->AddTool(wxID_CUT
, toolBarBitmaps
[4], wxNullBitmap
, FALSE
, -1, -1, (wxObject
*) NULL
, wxT("Cut"));
253 toolBar
->AddTool(wxID_COPY
, toolBarBitmaps
[3], wxNullBitmap
, FALSE
, -1, -1, (wxObject
*) NULL
, wxT("Copy"));
254 toolBar
->AddTool(wxID_PASTE
, toolBarBitmaps
[5], wxNullBitmap
, FALSE
, -1, -1, (wxObject
*) NULL
, wxT("Paste"));
255 toolBar
->AddSeparator();
256 toolBar
->AddTool(wxID_UNDO
, toolBarBitmaps
[10], wxNullBitmap
, FALSE
, -1, -1, (wxObject
*) NULL
, wxT("Undo"));
257 toolBar
->AddTool(wxID_REDO
, toolBarBitmaps
[11], wxNullBitmap
, FALSE
, -1, -1, (wxObject
*) NULL
, wxT("Redo"));
258 toolBar
->AddSeparator();
259 toolBar
->AddTool(ctID_GO
, toolBarBitmaps
[6], wxNullBitmap
, FALSE
, -1, -1, (wxObject
*) NULL
, wxT("Save setup.h or configurewx.sh"));
260 toolBar
->AddSeparator();
261 toolBar
->AddTool(ctID_ITEM_HELP
, toolBarBitmaps
[12], wxNullBitmap
, FALSE
, -1, -1, (wxObject
*) NULL
, wxT("Show help for this option"));
262 toolBar
->AddTool(wxID_HELP_CONTEXT
, toolBarBitmaps
[13], wxNullBitmap
, FALSE
, -1, -1, (wxObject
*) NULL
, wxT("Show help on the clicked item"));
264 // after adding the buttons to the toolbar, must call Realize() to reflect
269 wxMenuBar
* ctMainFrame::CreateMenuBar()
272 wxMenu
*fileMenu
= new wxMenu
;
274 wxGetApp().GetFileHistory().UseMenu(fileMenu
);
276 fileMenu
->Append(wxID_NEW
, wxT("&New...\tCtrl+N"), wxT("Create a new settings document"));
277 fileMenu
->Append(wxID_OPEN
, wxT("&Open...\tCtrl+O"), wxT("Open a settings document"));
278 fileMenu
->Append(wxID_CLOSE
, wxT("&Close\tCtrl+W"), wxT("Close the current settings document"));
279 fileMenu
->AppendSeparator();
280 fileMenu
->Append(wxID_SAVE
, wxT("&Save\tCtrl+S"), wxT("Save the settings document"));
281 fileMenu
->Append(wxID_SAVEAS
, wxT("&Save As..."), wxT("Save the settings document under a new filename"));
282 fileMenu
->AppendSeparator();
283 fileMenu
->Append(ctID_SAVE_SETUP_FILE
, wxT("Save Setup.&h...\tCtrl+H"), wxT("Save the setup.h file"));
284 fileMenu
->Append(ctID_SAVE_CONFIGURE_COMMAND
, wxT("Save Configure Script...\tCtrl+G"), wxT("Save the configure script file"));
285 fileMenu
->AppendSeparator();
286 fileMenu
->Append(ctID_GO
, wxT("&Go\tF5"), wxT("Quick-save the setup.h or configure.sh file"));
287 fileMenu
->AppendSeparator();
288 fileMenu
->Append(wxID_EXIT
, wxT("E&xit\tAlt+F4"), wxT("Exit the application"));
290 wxGetApp().GetDocManager()->FileHistoryUseMenu(fileMenu
);
292 wxMenu
*editMenu
= new wxMenu
;
294 editMenu
->Append(wxID_UNDO
, _("&Undo\tCtrl+Z"));
295 editMenu
->Append(wxID_REDO
, _("&Redo\tCtrl+Y"));
296 editMenu
->AppendSeparator();
297 editMenu
->Append(wxID_COPY
, _("&Copy\tCtrl+C"));
298 editMenu
->Append(wxID_CUT
, _("Cu&t\tCtrl+X"));
299 editMenu
->Append(wxID_PASTE
, _("&Paste\tCtrl+V"));
300 editMenu
->AppendSeparator();
302 wxMenu
* itemMenu
= new wxMenu
;
303 itemMenu
->Append(ctID_ADD_ITEM_CHECKBOX
, _("Add &Checkbox Option"), _("Add a checkbox configuration option"));
304 itemMenu
->Append(ctID_ADD_ITEM_RADIOBUTTON
, _("Add &Radio Button Option"), _("Add a radio button configuration option"));
305 // TODO. However we can also simply use custom properties;
306 // but then the C++ code has to be special-cased.
307 // itemMenu->Append(ctID_ADD_ITEM_STRING, _("Add &String Option"), _("Add a string configuration option"));
308 itemMenu
->Append(ctID_ADD_ITEM_GROUP
, _("Add &Group Option"), _("Add a group configuration option"));
309 itemMenu
->Append(ctID_ADD_ITEM_CHECK_GROUP
, _("Add Chec&k Group Option"), _("Add a check group configuration option"));
310 itemMenu
->Append(ctID_ADD_ITEM_RADIO_GROUP
, _("Add Rad&io Group Option"), _("Add a radio group configuration option"));
312 editMenu
->Append(ctID_ADD_ITEM
, wxT("Add &Option"), itemMenu
, _("Add a configuration option"));
313 editMenu
->AppendSeparator();
315 wxMenu
* propertyMenu
= new wxMenu
;
316 propertyMenu
->Append(ctID_ADD_CUSTOM_PROPERTY
, _("&Add Custom Property"), _("Adds a custom property to the current option"));
317 propertyMenu
->Append(ctID_EDIT_CUSTOM_PROPERTY
, _("&Edit Custom Property"), _("Edits the currently selected custom property"));
318 propertyMenu
->Append(ctID_DELETE_CUSTOM_PROPERTY
, _("&Delete Custom Property"), _("Deletes the currently selected custom property"));
319 editMenu
->Append(ctID_CUSTOM_PROPERTY
, _("Custom P&roperty"), propertyMenu
, _("Custom property commands"));
321 editMenu
->AppendSeparator();
322 editMenu
->Append(ctID_DELETE_ITEM
, _("&Delete Option"), _("Delete a configuration option"));
323 editMenu
->Append(ctID_RENAME_ITEM
, _("&Rename Option"), _("Rename a configuration option"));
324 editMenu
->AppendSeparator();
325 editMenu
->Append(wxID_FIND
, _("&Find...\tCtrl+F"), _("Search for a string in the settings document"));
327 // Save for the command processor.
328 m_editMenu
= editMenu
;
330 wxMenu
*viewMenu
= new wxMenu
;
331 viewMenu
->Append(ctID_SHOW_TOOLBAR
, wxT("Show &Toolbar"), wxT("Toggle the toolbar on and off"),
333 viewMenu
->Append(ctID_SETTINGS
, wxT("&Settings...\tCtrl+T"), wxT("Show application settings"));
335 wxMenu
*helpMenu
= new wxMenu
;
336 helpMenu
->Append(wxID_HELP
, wxT("&Help Contents"), wxT("Show Configuration Tool help"));
337 helpMenu
->Append(ctID_REFERENCE_CONTENTS
, wxT("&wxWindows Help Contents"), wxT("Show wxWindows reference"));
338 helpMenu
->AppendSeparator();
339 helpMenu
->Append(ctID_ITEM_HELP
, wxT("&Configuration Option Help\tF1"), wxT("Show help for the selected option"));
340 helpMenu
->Append(wxID_HELP_CONTEXT
, wxT("&What's this?"), wxT("Show help on the clicked item"));
341 helpMenu
->AppendSeparator();
342 helpMenu
->Append(wxID_ABOUT
, wxT("&About..."), wxT("Show details about this application"));
344 wxMenuBar
*menuBar
= new wxMenuBar
;
346 menuBar
->Append(fileMenu
, wxT("&File"));
347 menuBar
->Append(editMenu
, wxT("&Edit"));
348 menuBar
->Append(viewMenu
, wxT("&View"));
349 menuBar
->Append(helpMenu
, wxT("&Help"));
352 wxConfig
config(wxGetApp().GetSettings().GetAppName(), wxT("wxWindows"));
353 config
.SetPath(wxT("FileHistory/"));
354 wxGetApp().GetDocManager()->FileHistoryLoad(config
);
360 /// Handles the Show Toolbar menu event.
361 void ctMainFrame::OnShowToolbar(wxCommandEvent
& event
)
363 wxGetApp().GetSettings().m_showToolBar
= !wxGetApp().GetSettings().m_showToolBar
;
364 GetToolBar()->Show(wxGetApp().GetSettings().m_showToolBar
);
368 /// Handles the Help Contents menu event.
369 void ctMainFrame::OnHelp(wxCommandEvent
& event
)
371 wxGetApp().GetHelpController().DisplayContents();
374 /// Handles context help
375 void ctMainFrame::OnContextHelp(wxCommandEvent
& event
)
377 wxContextHelp contextHelp
;
380 /// Handles the Help Contents menu event for the reference manual.
381 void ctMainFrame::OnReferenceHelp(wxCommandEvent
& event
)
383 wxGetApp().GetReferenceHelpController().DisplayContents();
386 /// Resizes the main frame according to the
387 /// state of the toolbar
388 void ctMainFrame::ResizeFrame()
391 wxSizeEvent
event(GetSize(), GetId());
392 this->ProcessEvent(event
);
395 /// Update the frame title.
396 void ctMainFrame::UpdateFrameTitle()
402 void ctMainFrame::OnUpdateDisable(wxUpdateUIEvent
& event
)
404 event
.Enable( FALSE
);
408 * ctOutputWindow represents a page showing a setup.h file or config command.
411 IMPLEMENT_CLASS(ctOutputWindow
, wxPanel
)
413 BEGIN_EVENT_TABLE(ctOutputWindow
, wxPanel
)
414 EVT_BUTTON(wxID_COPY
, ctOutputWindow::OnCopyToClipboard
)
415 EVT_BUTTON(wxID_SAVE
, ctOutputWindow::OnSaveText
)
416 EVT_BUTTON(ctID_REGENERATE
, ctOutputWindow::OnRegenerate
)
417 EVT_UPDATE_UI(wxID_SAVE
, ctOutputWindow::OnUpdateSaveText
)
418 EVT_UPDATE_UI(ctID_REGENERATE
, ctOutputWindow::OnUpdateRegenerate
)
419 EVT_UPDATE_UI(wxID_COPY
, ctOutputWindow::OnUpdateCopy
)
422 ctOutputWindow::ctOutputWindow(wxWindow
* parent
, wxWindowID id
,
423 const wxPoint
& pos
, const wxSize
& size
, long style
):
424 wxPanel(parent
, id
, pos
, size
, style
)
427 m_filenameCtrl
= NULL
;
432 ctOutputWindow::~ctOutputWindow()
436 /// Initialise the windows.
437 void ctOutputWindow::CreateWindows()
439 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
441 wxBoxSizer
*item2
= new wxBoxSizer( wxHORIZONTAL
);
442 item0
->Add( item2
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5 );
444 wxButton
*item4
= new wxButton( this, wxID_COPY
, _("&Copy"), wxDefaultPosition
, wxDefaultSize
, 0 );
445 item2
->Add( item4
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxBOTTOM
|wxRIGHT
, 5 );
446 item4
->SetHelpText(_("Copies the selection or whole file to the clipboard."));
448 wxButton
*item5
= new wxButton( this, ctID_REGENERATE
, _("Re&generate"), wxDefaultPosition
, wxDefaultSize
, 0 );
449 item2
->Add( item5
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
|wxRIGHT
, 5 );
450 item5
->SetHelpText(_("Regenerates the code."));
453 m_filenameCtrl
= new wxTextCtrl(this, -1, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxSUNKEN_BORDER
|wxTE_READONLY
);
454 item2
->Add( m_filenameCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
|wxRIGHT
, 5 );
455 m_filenameCtrl
->SetHelpText(_("Shows the filename where the code is being saved."));
457 m_filenameCtrl
= NULL
;
461 m_codeCtrl
= new wxTextCtrl(this, -1, wxEmptyString
, wxDefaultPosition
, wxSize(100, 100), wxTE_RICH
|wxTE_MULTILINE
|wxSUNKEN_BORDER
);
462 item0
->Add( m_codeCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
|wxBOTTOM
, 5 );
464 SetAutoLayout( TRUE
);
468 /// Copies the text to the clipboard.
469 void ctOutputWindow::OnCopyToClipboard(wxCommandEvent
& event
)
471 // Try to copy the selection first
472 long int selFrom
, selTo
;
473 m_codeCtrl
->GetSelection(& selFrom
, & selTo
);
474 if (selFrom
!= selTo
)
480 // Copy the whole amount
481 if (!wxTheClipboard
->Open())
483 wxMessageBox(_("Sorry, could not open the clipboard."), _("Clipboard problem"), wxICON_EXCLAMATION
|wxOK
);
487 wxString
value(m_codeCtrl
->GetValue());
489 value
.Replace(_T("\n"), _T("\r\n"));
491 wxTextDataObject
*data
= new wxTextDataObject( value
);
493 if (!wxTheClipboard
->SetData( data
))
495 wxTheClipboard
->Close();
496 wxMessageBox(_("Sorry, could not copy to the clipboard."), _("Clipboard problem"), wxICON_EXCLAMATION
|wxOK
);
500 wxTheClipboard
->Close();
504 /// Sets the code in the text control.
505 void ctOutputWindow::SetText(const wxString
& text
)
508 m_codeCtrl
->SetValue(text
);
511 /// Sets the filename.
512 void ctOutputWindow::SetFilename(const wxString
& filename
)
515 m_filenameCtrl
->SetValue(filename
);
519 void ctOutputWindow::OnSaveText(wxCommandEvent
& event
)
521 if (m_codeCtrl
->IsModified())
523 wxString
filename(m_filenameCtrl
->GetValue());
524 if (!filename
.IsEmpty())
526 m_codeCtrl
->SaveFile(filename
);
527 m_codeCtrl
->DiscardEdits();
532 void ctOutputWindow::OnUpdateSaveText(wxUpdateUIEvent
& event
)
534 event
.Enable(m_doc
&& m_codeCtrl
&& m_codeCtrl
->IsModified());
537 void ctOutputWindow::OnRegenerate(wxCommandEvent
& event
)
541 ctConfigToolView
* view
= (ctConfigToolView
*) m_doc
->GetFirstView();
542 view
->RegenerateSetup();
546 void ctOutputWindow::OnUpdateRegenerate(wxUpdateUIEvent
& event
)
548 event
.Enable( m_doc
!= NULL
);
551 void ctOutputWindow::OnUpdateCopy(wxUpdateUIEvent
& event
)
553 event
.Enable( m_doc
!= NULL
);