X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be5a51fb592f3fa2ba38ac6cd1e488d6d806058c..b271d60d6a009930d80092a8cb534a5df19fc99b:/utils/configtool/src/mainframe.cpp?ds=sidebyside diff --git a/utils/configtool/src/mainframe.cpp b/utils/configtool/src/mainframe.cpp index b91d75eb53..31965e2164 100644 --- a/utils/configtool/src/mainframe.cpp +++ b/utils/configtool/src/mainframe.cpp @@ -9,23 +9,25 @@ // Licence: ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "mainframe.h" -#endif - -#include "wx/wx.h" +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif +#ifndef WX_PRECOMP + +#include "wx/splitter.h" + +#endif + +#include "wx/cshelp.h" #include "wx/html/htmlwin.h" #include "wx/notebook.h" -#include "wx/splitter.h" -#include "wx/clipbrd.h" #include "wx/dataobj.h" -#include "wx/cshelp.h" - +#include "wx/clipbrd.h" +#include "wx/stockitem.h" #include "wxconfigtool.h" #include "mainframe.h" #include "appsettings.h" @@ -90,8 +92,7 @@ BEGIN_EVENT_TABLE(ctMainFrame, wxDocParentFrame) END_EVENT_TABLE() // Define my frame constructor -ctMainFrame::ctMainFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, - long style): +ctMainFrame::ctMainFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style): wxDocParentFrame(manager, parent, id, title, pos, size, style) { m_document = NULL; @@ -104,24 +105,24 @@ ctMainFrame::ctMainFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id, m_mainNotebook = NULL; m_findDialog = NULL; - m_treeSplitterWindow = new wxSplitterWindow(this, -1, wxDefaultPosition, wxSize(400, 300), - wxSP_3DSASH|wxSP_3DBORDER|wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN); + m_treeSplitterWindow = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, wxSize(400, 300), + wxSP_3DSASH|wxSP_3DBORDER|wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN|wxSP_NO_XP_THEME); - m_configTreeCtrl = new ctConfigTreeCtrl(m_treeSplitterWindow, -1, wxDefaultPosition, wxDefaultSize, + m_configTreeCtrl = new ctConfigTreeCtrl(m_treeSplitterWindow, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS|wxNO_BORDER|wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN); - m_mainNotebook = new wxNotebook(m_treeSplitterWindow, -1, wxDefaultPosition, wxSize(300, 300), + m_mainNotebook = new wxNotebook(m_treeSplitterWindow, wxID_ANY, wxDefaultPosition, wxSize(300, 300), wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN); - m_propertyEditor = new ctPropertyEditor(m_mainNotebook, -1, wxDefaultPosition, wxSize(300, 200), + m_propertyEditor = new ctPropertyEditor(m_mainNotebook, wxID_ANY, wxDefaultPosition, wxSize(300, 200), wxNO_BORDER|wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN); - m_setupPage = new ctOutputWindow(m_mainNotebook, -1, wxDefaultPosition, wxSize(300, 200), + m_setupPage = new ctOutputWindow(m_mainNotebook, wxID_ANY, wxDefaultPosition, wxSize(300, 200), wxNO_BORDER|wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN); - m_configurePage = new ctOutputWindow(m_mainNotebook, -1, wxDefaultPosition, wxSize(300, 200), + m_configurePage = new ctOutputWindow(m_mainNotebook, wxID_ANY, wxDefaultPosition, wxSize(300, 200), wxNO_BORDER|wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN); #ifdef USE_CONFIG_BROWSER_PAGE - m_configBrowserPage = new ctConfigurationBrowserWindow(m_mainNotebook, -1, wxDefaultPosition, wxSize(300, 200), + m_configBrowserPage = new ctConfigurationBrowserWindow(m_mainNotebook, wxID_ANY, wxDefaultPosition, wxSize(300, 200), wxNO_BORDER|wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN); #endif @@ -141,7 +142,9 @@ ctMainFrame::ctMainFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id, SetIcon(wxIcon(wxconfigtool_xpm)); +#if wxUSE_STATUSBAR CreateStatusBar(2); +#endif // wxUSE_STATUSBAR wxMenuBar* menuBar = CreateMenuBar(); SetMenuBar(menuBar); @@ -151,12 +154,12 @@ ctMainFrame::ctMainFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id, if (wxGetApp().GetSettings().m_showToolBar) { - menuBar->Check(ctID_SHOW_TOOLBAR, TRUE); + menuBar->Check(ctID_SHOW_TOOLBAR, true); } else { - menuBar->Check(ctID_SHOW_TOOLBAR, FALSE); - GetToolBar()->Show(FALSE); + menuBar->Check(ctID_SHOW_TOOLBAR, false); + GetToolBar()->Show(false); ResizeFrame(); } } @@ -178,7 +181,7 @@ void ctMainFrame::OnCloseWindow(wxCloseEvent& event) m_findDialog = NULL; } - Show(FALSE); + Show(false); if (IsMaximized()) wxGetApp().GetSettings().m_frameStatus = ctSHOW_STATUS_MAXIMIZED ; @@ -186,11 +189,11 @@ void ctMainFrame::OnCloseWindow(wxCloseEvent& event) wxGetApp().GetSettings().m_frameStatus = ctSHOW_STATUS_MINIMIZED ; else wxGetApp().GetSettings().m_frameStatus = ctSHOW_STATUS_NORMAL ; - + // Must delete this now since the DLL loading library will be // uninitialised by the time the app object is deleted wxGetApp().ClearHelpControllers(); - + if (!IsMaximized() && !IsIconized()) { wxGetApp().GetSettings().m_frameSize = GetRect(); @@ -247,22 +250,22 @@ void ctMainFrame::InitToolBar(wxToolBar* toolBar) toolBarBitmaps[12] = wxBitmap(help_xpm); toolBarBitmaps[13] = wxBitmap(helpcs_xpm); - toolBar->AddTool(wxID_NEW, toolBarBitmaps[0], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("New project")); - toolBar->AddTool(wxID_OPEN, toolBarBitmaps[1], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Open project")); - toolBar->AddTool(wxID_SAVE, toolBarBitmaps[2], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Save project")); + toolBar->AddTool(wxID_NEW, toolBarBitmaps[0], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, (wxObject *) NULL, wxT("New project")); + toolBar->AddTool(wxID_OPEN, toolBarBitmaps[1], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, (wxObject *) NULL, wxT("Open project")); + toolBar->AddTool(wxID_SAVE, toolBarBitmaps[2], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, (wxObject *) NULL, wxT("Save project")); toolBar->AddSeparator(); - toolBar->AddTool(wxID_CUT, toolBarBitmaps[4], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Cut")); - toolBar->AddTool(wxID_COPY, toolBarBitmaps[3], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Copy")); - toolBar->AddTool(wxID_PASTE, toolBarBitmaps[5], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Paste")); + toolBar->AddTool(wxID_CUT, toolBarBitmaps[4], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, (wxObject *) NULL, wxGetStockLabel(wxID_CUT, false)); + toolBar->AddTool(wxID_COPY, toolBarBitmaps[3], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, (wxObject *) NULL, wxGetStockLabel(wxID_COPY, false)); + toolBar->AddTool(wxID_PASTE, toolBarBitmaps[5], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, (wxObject *) NULL, wxGetStockLabel(wxID_PASTE, false)); toolBar->AddSeparator(); - toolBar->AddTool(wxID_UNDO, toolBarBitmaps[10], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Undo")); - toolBar->AddTool(wxID_REDO, toolBarBitmaps[11], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Redo")); + toolBar->AddTool(wxID_UNDO, toolBarBitmaps[10], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, (wxObject *) NULL, wxGetStockLabel(wxID_UNDO, false)); + toolBar->AddTool(wxID_REDO, toolBarBitmaps[11], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, (wxObject *) NULL, wxGetStockLabel(wxID_REDO, false)); toolBar->AddSeparator(); - toolBar->AddTool(ctID_GO, toolBarBitmaps[6], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Save setup.h or configurewx.sh")); + toolBar->AddTool(ctID_GO, toolBarBitmaps[6], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, (wxObject *) NULL, wxT("Save setup.h or configurewx.sh")); toolBar->AddSeparator(); - toolBar->AddTool(ctID_ITEM_HELP, toolBarBitmaps[12], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Show help for this option")); - toolBar->AddTool(wxID_HELP_CONTEXT, toolBarBitmaps[13], wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, wxT("Show help on the clicked item")); + toolBar->AddTool(ctID_ITEM_HELP, toolBarBitmaps[12], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, (wxObject *) NULL, wxT("Show help for this option")); + toolBar->AddTool(wxID_HELP_CONTEXT, toolBarBitmaps[13], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, (wxObject *) NULL, wxT("Show help on the clicked item")); // after adding the buttons to the toolbar, must call Realize() to reflect // the changes @@ -273,33 +276,33 @@ wxMenuBar* ctMainFrame::CreateMenuBar() { // Make a menubar wxMenu *fileMenu = new wxMenu; - + wxGetApp().GetFileHistory().UseMenu(fileMenu); - - fileMenu->Append(wxID_NEW, wxT("&New...\tCtrl+N"), wxT("Create a new settings document")); - fileMenu->Append(wxID_OPEN, wxT("&Open...\tCtrl+O"), wxT("Open a settings document")); - fileMenu->Append(wxID_CLOSE, wxT("&Close\tCtrl+W"), wxT("Close the current settings document")); + + fileMenu->Append(wxID_NEW, wxGetStockLabel(wxID_NEW, true, wxT("Ctrl+N")), wxT("Create a new settings document")); + fileMenu->Append(wxID_OPEN, wxGetStockLabel(wxID_OPEN, true, wxT("Ctrl+O")), wxT("Open a settings document")); + fileMenu->Append(wxID_CLOSE, wxGetStockLabel(wxID_CLOSE, true, wxT("Ctrl+W")), wxT("Close the current settings document")); fileMenu->AppendSeparator(); - fileMenu->Append(wxID_SAVE, wxT("&Save\tCtrl+S"), wxT("Save the settings document")); - fileMenu->Append(wxID_SAVEAS, wxT("&Save As..."), wxT("Save the settings document under a new filename")); + fileMenu->Append(wxID_SAVE, wxGetStockLabel(wxID_SAVE, true, wxT("Ctrl+S")), wxT("Save the settings document")); + fileMenu->Append(wxID_SAVEAS, wxGetStockLabel(wxID_SAVEAS), wxT("Save the settings document under a new filename")); fileMenu->AppendSeparator(); fileMenu->Append(ctID_SAVE_SETUP_FILE, wxT("Save Setup.&h...\tCtrl+H"), wxT("Save the setup.h file")); fileMenu->Append(ctID_SAVE_CONFIGURE_COMMAND, wxT("Save Configure Script...\tCtrl+G"), wxT("Save the configure script file")); fileMenu->AppendSeparator(); fileMenu->Append(ctID_GO, wxT("&Go\tF5"), wxT("Quick-save the setup.h or configure.sh file")); fileMenu->AppendSeparator(); - fileMenu->Append(wxID_EXIT, wxT("E&xit\tAlt+F4"), wxT("Exit the application")); + fileMenu->Append(wxID_EXIT, wxGetStockLabel(wxID_EXIT, true, wxT("Alt+F4")), wxT("Exit the application")); wxGetApp().GetDocManager()->FileHistoryUseMenu(fileMenu); - + wxMenu *editMenu = new wxMenu; - editMenu->Append(wxID_UNDO, _("&Undo\tCtrl+Z")); - editMenu->Append(wxID_REDO, _("&Redo\tCtrl+Y")); + editMenu->Append(wxID_UNDO, wxGetStockLabel(wxID_UNDO, true, wxT("Ctrl+Z"))); + editMenu->Append(wxID_REDO, wxGetStockLabel(wxID_REDO, true, wxT("Ctrl+Y"))); editMenu->AppendSeparator(); - editMenu->Append(wxID_COPY, _("&Copy\tCtrl+C")); - editMenu->Append(wxID_CUT, _("Cu&t\tCtrl+X")); - editMenu->Append(wxID_PASTE, _("&Paste\tCtrl+V")); + editMenu->Append(wxID_COPY, wxGetStockLabel(wxID_CLOSE, true, wxT("Ctrl+C"))); + editMenu->Append(wxID_CUT, wxGetStockLabel(wxID_CUT, true, wxT("Ctrl+X"))); + editMenu->Append(wxID_PASTE, wxGetStockLabel(wxID_PASTE, true, wxT("Ctrl+V"))); editMenu->AppendSeparator(); wxMenu* itemMenu = new wxMenu; @@ -325,7 +328,7 @@ wxMenuBar* ctMainFrame::CreateMenuBar() editMenu->Append(ctID_DELETE_ITEM, _("&Delete Option"), _("Delete a configuration option")); editMenu->Append(ctID_RENAME_ITEM, _("&Rename Option"), _("Rename a configuration option")); editMenu->AppendSeparator(); - editMenu->Append(wxID_FIND, _("&Find...\tCtrl+F"), _("Search for a string in the settings document")); + editMenu->Append(wxID_FIND, wxGetStockLabel(wxID_FIND, true, wxT("Ctrl+F")), _("Search for a string in the settings document")); // Save for the command processor. m_editMenu = editMenu; @@ -343,9 +346,9 @@ wxMenuBar* ctMainFrame::CreateMenuBar() helpMenu->Append(wxID_HELP_CONTEXT, wxT("&What's this?"), wxT("Show help on the clicked item")); helpMenu->AppendSeparator(); helpMenu->Append(wxID_ABOUT, wxT("&About..."), wxT("Show details about this application")); - + wxMenuBar *menuBar = new wxMenuBar; - + menuBar->Append(fileMenu, wxT("&File")); menuBar->Append(editMenu, wxT("&Edit")); menuBar->Append(viewMenu, wxT("&View")); @@ -355,7 +358,7 @@ wxMenuBar* ctMainFrame::CreateMenuBar() wxConfig config(wxGetApp().GetSettings().GetAppName(), wxT("wxWidgets")); config.SetPath(wxT("FileHistory/")); wxGetApp().GetDocManager()->FileHistoryLoad(config); - } + } return menuBar; } @@ -404,7 +407,7 @@ void ctMainFrame::UpdateFrameTitle() // General disabler void ctMainFrame::OnUpdateDisable(wxUpdateUIEvent& event) { - event.Enable( FALSE ); + event.Enable( false ); } /*! @@ -414,7 +417,9 @@ void ctMainFrame::OnUpdateDisable(wxUpdateUIEvent& event) IMPLEMENT_CLASS(ctOutputWindow, wxPanel) BEGIN_EVENT_TABLE(ctOutputWindow, wxPanel) +#if wxUSE_CLIPBOARD EVT_BUTTON(wxID_COPY, ctOutputWindow::OnCopyToClipboard) +#endif // wxUSE_CLIPBOARD EVT_BUTTON(wxID_SAVE, ctOutputWindow::OnSaveText) EVT_BUTTON(ctID_REGENERATE, ctOutputWindow::OnRegenerate) EVT_UPDATE_UI(wxID_SAVE, ctOutputWindow::OnUpdateSaveText) @@ -432,10 +437,6 @@ ctOutputWindow::ctOutputWindow(wxWindow* parent, wxWindowID id, CreateWindows(); } -ctOutputWindow::~ctOutputWindow() -{ -} - /// Initialise the windows. void ctOutputWindow::CreateWindows() { @@ -453,7 +454,7 @@ void ctOutputWindow::CreateWindows() item5->SetHelpText(_("Regenerates the code.")); #if 0 - m_filenameCtrl = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTE_READONLY); + m_filenameCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTE_READONLY); item2->Add( m_filenameCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); m_filenameCtrl->SetHelpText(_("Shows the filename where the code is being saved.")); #else @@ -461,13 +462,14 @@ void ctOutputWindow::CreateWindows() #endif // The code editor - m_codeCtrl = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxSize(100, 100), wxTE_RICH|wxTE_MULTILINE|wxSUNKEN_BORDER); + m_codeCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(100, 100), wxTE_RICH|wxTE_MULTILINE|wxSUNKEN_BORDER); item0->Add( m_codeCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 ); - SetAutoLayout( TRUE ); + SetAutoLayout( true ); SetSizer( item0 ); } +#if wxUSE_CLIPBOARD /// Copies the text to the clipboard. void ctOutputWindow::OnCopyToClipboard(wxCommandEvent& WXUNUSED(event)) { @@ -486,13 +488,13 @@ void ctOutputWindow::OnCopyToClipboard(wxCommandEvent& WXUNUSED(event)) wxMessageBox(_("Sorry, could not open the clipboard."), _("Clipboard problem"), wxICON_EXCLAMATION|wxOK); return; } - + wxString value(m_codeCtrl->GetValue()); #ifdef __WXMSW__ value.Replace(_T("\n"), _T("\r\n")); #endif wxTextDataObject *data = new wxTextDataObject( value ); - + if (!wxTheClipboard->SetData( data )) { wxTheClipboard->Close(); @@ -503,6 +505,7 @@ void ctOutputWindow::OnCopyToClipboard(wxCommandEvent& WXUNUSED(event)) wxTheClipboard->Close(); } } +#endif // wxUSE_CLIPBOARD /// Sets the code in the text control. void ctOutputWindow::SetText(const wxString& text) @@ -524,7 +527,7 @@ void ctOutputWindow::OnSaveText(wxCommandEvent& WXUNUSED(event)) if (m_codeCtrl->IsModified()) { wxString filename(m_filenameCtrl->GetValue()); - if (!filename.IsEmpty()) + if (!filename.empty()) { m_codeCtrl->SaveFile(filename); m_codeCtrl->DiscardEdits();