From 6a6814fb9f26bcf54a719450852efceaf0a2377b Mon Sep 17 00:00:00 2001 From: Aleksey Lobanov Date: Thu, 18 Jun 2015 21:10:19 +0300 Subject: [PATCH] Added "Settings" menu item and dialog --- wxCrossGen/FormBuilderGUI.fbp | 403 +++++++++++++++++++++++++++++++++- wxCrossGen/fbgui/fbgui.cpp | 70 +++++- wxCrossGen/fbgui/fbgui.h | 34 ++- wxCrossGen/main.cpp | 2 +- 4 files changed, 499 insertions(+), 10 deletions(-) diff --git a/wxCrossGen/FormBuilderGUI.fbp b/wxCrossGen/FormBuilderGUI.fbp index 417ffa4..8ebaf3c 100644 --- a/wxCrossGen/FormBuilderGUI.fbp +++ b/wxCrossGen/FormBuilderGUI.fbp @@ -179,12 +179,12 @@ wxID_PREFERENCES wxITEM_NORMAL - &Preferences - miPreferences + &Settings + miSettings none - onPreferencesClick + onSettingsClick @@ -557,5 +557,402 @@ + + + + + 1 + + + + 0 + wxID_ANY + + + VSettingsDialog + + 426,224 + wxDEFAULT_DIALOG_STYLE + + Settings + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer5 + wxVERTICAL + none + + 5 + wxEXPAND + 0 + + + bSizer6 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 0 + + + + 1 + + + 0 + wxID_ANY + Dict path: + + + m_staticText1 + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL + 2 + + + + 1 + + + 0 + wxID_ANY + + 0 + + tDictPath + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + + 0 + 1 + + + 0 + wxID_ANY + ... + + + bDictPath + protected + + + wxBU_EXACTFIT + + + + wxFILTER_NONE + wxDefaultValidator + + + + + onDictPathClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 0 + + + bSizer7 + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL + 0 + + + + 0 + 1 + + + 0 + wxID_CANCEL + Cancel + + + bCancel + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + onCancelClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_OK + OK + + + bOk + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + onOkClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wxCrossGen/fbgui/fbgui.cpp b/wxCrossGen/fbgui/fbgui.cpp index 143de9c..a00028b 100644 --- a/wxCrossGen/fbgui/fbgui.cpp +++ b/wxCrossGen/fbgui/fbgui.cpp @@ -27,9 +27,9 @@ VMainFrame::VMainFrame( wxWindow* parent, wxWindowID id, const wxString& title, miExport = new wxMenuItem( miFile, wxID_EXPORT, wxString( _("&Export") ) , wxEmptyString, wxITEM_NORMAL ); miFile->Append( miExport ); - wxMenuItem* miPreferences; - miPreferences = new wxMenuItem( miFile, wxID_PREFERENCES, wxString( _("&Preferences ") ) , wxEmptyString, wxITEM_NORMAL ); - miFile->Append( miPreferences ); + wxMenuItem* miSettings; + miSettings = new wxMenuItem( miFile, wxID_PREFERENCES, wxString( _("&Settings") ) , wxEmptyString, wxITEM_NORMAL ); + miFile->Append( miSettings ); wxMenuItem* miExit; miExit = new wxMenuItem( miFile, wxID_EXIT, wxString( _("E&xit") ) + wxT('\t') + wxT("Ctrl+Q"), wxEmptyString, wxITEM_NORMAL ); @@ -90,7 +90,7 @@ VMainFrame::VMainFrame( wxWindow* parent, wxWindowID id, const wxString& title, this->Connect( miOpenGrid->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onOpenGridClick ) ); this->Connect( miGenerate->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onGenerateClick ) ); this->Connect( miExport->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onExportClick ) ); - this->Connect( miPreferences->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onPreferencesClick ) ); + this->Connect( miSettings->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onSettingsClick ) ); this->Connect( miExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onExitClick ) ); this->Connect( miAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onAboutClick ) ); bPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VMainFrame::onOpenGridClick ), NULL, this ); @@ -104,9 +104,69 @@ VMainFrame::~VMainFrame() this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onOpenGridClick ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onGenerateClick ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onExportClick ) ); - this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onPreferencesClick ) ); + this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onSettingsClick ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onExitClick ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( VMainFrame::onAboutClick ) ); bPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VMainFrame::onOpenGridClick ), NULL, this ); bGenerate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VMainFrame::onGenerateClick ), NULL, this ); } + +VSettingsDialog::VSettingsDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizer5; + bSizer5 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer6; + bSizer6 = new wxBoxSizer( wxHORIZONTAL ); + + m_staticText1 = new wxStaticText( this, wxID_ANY, _("Dict path:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1->Wrap( -1 ); + bSizer6->Add( m_staticText1, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + + bSizer6->Add( 0, 0, 1, wxEXPAND, 5 ); + + tDictPath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer6->Add( tDictPath, 2, wxALIGN_CENTER_VERTICAL, 5 ); + + bDictPath = new wxButton( this, wxID_ANY, _("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); + bSizer6->Add( bDictPath, 0, wxALL, 5 ); + + bSizer5->Add( bSizer6, 0, wxEXPAND, 5 ); + + + bSizer5->Add( 0, 0, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer7; + bSizer7 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer7->Add( 0, 0, 1, wxEXPAND, 5 ); + + bCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer7->Add( bCancel, 0, wxALL, 5 ); + + bOk = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); + bOk->SetDefault(); + bSizer7->Add( bOk, 0, wxALL, 5 ); + + bSizer5->Add( bSizer7, 0, wxEXPAND, 5 ); + + this->SetSizer( bSizer5 ); + this->Layout(); + + // Connect Events + bDictPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VSettingsDialog::onDictPathClick ), NULL, this ); + bCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VSettingsDialog::onCancelClick ), NULL, this ); + bOk->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VSettingsDialog::onOkClick ), NULL, this ); +} + +VSettingsDialog::~VSettingsDialog() +{ + // Disconnect Events + bDictPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VSettingsDialog::onDictPathClick ), NULL, this ); + bCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VSettingsDialog::onCancelClick ), NULL, this ); + bOk->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VSettingsDialog::onOkClick ), NULL, this ); +} diff --git a/wxCrossGen/fbgui/fbgui.h b/wxCrossGen/fbgui/fbgui.h index f95d629..71e0857 100644 --- a/wxCrossGen/fbgui/fbgui.h +++ b/wxCrossGen/fbgui/fbgui.h @@ -24,6 +24,8 @@ #include #include #include +#include +#include /////////////////////////////////////////////////////////////////////////// @@ -53,7 +55,7 @@ class VMainFrame : public wxFrame virtual void onOpenGridClick( wxCommandEvent& event ) { event.Skip(); } virtual void onGenerateClick( wxCommandEvent& event ) { event.Skip(); } virtual void onExportClick( wxCommandEvent& event ) { event.Skip(); } - virtual void onPreferencesClick( wxCommandEvent& event ) { event.Skip(); } + virtual void onSettingsClick( wxCommandEvent& event ) { event.Skip(); } virtual void onExitClick( wxCommandEvent& event ) { event.Skip(); } virtual void onAboutClick( wxCommandEvent& event ) { event.Skip(); } @@ -65,4 +67,34 @@ class VMainFrame : public wxFrame }; +/////////////////////////////////////////////////////////////////////////////// +/// Class VSettingsDialog +/////////////////////////////////////////////////////////////////////////////// +class VSettingsDialog : public wxDialog +{ + private: + + protected: + wxStaticText* m_staticText1; + + wxTextCtrl* tDictPath; + wxButton* bDictPath; + + + wxButton* bCancel; + wxButton* bOk; + + // Virtual event handlers, overide them in your derived class + virtual void onDictPathClick( wxCommandEvent& event ) { event.Skip(); } + virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); } + virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); } + + + public: + + VSettingsDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 426,224 ), long style = wxDEFAULT_DIALOG_STYLE ); + ~VSettingsDialog(); + +}; + #endif //__fbgui__ diff --git a/wxCrossGen/main.cpp b/wxCrossGen/main.cpp index 077cc4c..6345cd8 100644 --- a/wxCrossGen/main.cpp +++ b/wxCrossGen/main.cpp @@ -177,7 +177,7 @@ void MainFrame::onExportClick(wxCommandEvent& event) { wxLogDebug(wxT("Exporting to ") + dlgSave.GetPath() + wxT(" is complete")); } -void MainFrame::onPreferencesClick( wxCommandEvent& event ){ +void MainFrame::onSettingsClick( wxCommandEvent& event ){ }