Some structure changes. Added saving of window size
This commit is contained in:
@@ -49,7 +49,7 @@
|
||||
<event name="OnActivate"></event>
|
||||
<event name="OnActivateApp"></event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnClose">onExitClick</event>
|
||||
<event name="OnClose">onWindowClose</event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnHibernate"></event>
|
||||
|
||||
@@ -88,7 +88,7 @@ VMainFrame::VMainFrame( wxWindow* parent, wxWindowID id, const wxString& title,
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( VMainFrame::onExitClick ) );
|
||||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( VMainFrame::onWindowClose ) );
|
||||
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 ) );
|
||||
@@ -102,7 +102,7 @@ VMainFrame::VMainFrame( wxWindow* parent, wxWindowID id, const wxString& title,
|
||||
VMainFrame::~VMainFrame()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( VMainFrame::onExitClick ) );
|
||||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( VMainFrame::onWindowClose ) );
|
||||
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 ) );
|
||||
|
||||
@@ -51,7 +51,7 @@ class VMainFrame : public wxFrame
|
||||
wxButton* bGenerate;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void onExitClick( wxCloseEvent& event ) { event.Skip(); }
|
||||
virtual void onWindowClose( wxCloseEvent& event ) { event.Skip(); }
|
||||
virtual void onOpenGridClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onGenerateClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onExportClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
#include "fmain.hpp"
|
||||
|
||||
|
||||
MainFrame::MainFrame( wxWindow* parent): VMainFrame(parent) {
|
||||
// Hack for better background
|
||||
#ifdef __WINDOWS__
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
||||
#endif
|
||||
_isDictLoaded = false;
|
||||
srand(time(NULL));
|
||||
auto *config = wxConfigBase::Get();
|
||||
wxSize sz;
|
||||
sz.SetHeight(config->Read(SETTINGS_KEY_FMAIN_HEIGHT, SETTINGS_DEFAULT_FMAIN_HEIGHT));
|
||||
sz.SetWidth(config->Read(SETTINGS_KEY_FMAIN_WIDTH, SETTINGS_DEFAULT_FMAIN_WIDTH));
|
||||
SetSize(sz);
|
||||
}
|
||||
|
||||
void MainFrame::procDict(wxString path){
|
||||
_dict.clear();
|
||||
_allWords.clear();
|
||||
@@ -183,3 +197,19 @@ void MainFrame::onSettingsClick( wxCommandEvent& event ){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainFrame::onWindowClose( wxCloseEvent& event ){
|
||||
saveConfig();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void MainFrame::onExitClick( wxCommandEvent& event ){
|
||||
this->Close();
|
||||
}
|
||||
|
||||
void MainFrame::saveConfig(){
|
||||
auto *config = wxConfigBase::Get();
|
||||
auto sz = GetSize();
|
||||
config->Write(SETTINGS_KEY_FMAIN_HEIGHT, sz.GetHeight());
|
||||
config->Write(SETTINGS_KEY_FMAIN_WIDTH, sz.GetWidth());
|
||||
}
|
||||
|
||||
@@ -35,23 +35,15 @@ protected:
|
||||
public:
|
||||
void SetGridImage(GridType &grid, size_t w=400);
|
||||
void procDict(wxString path);
|
||||
void saveConfig();
|
||||
|
||||
MainFrame( wxWindow* parent): VMainFrame(parent) {
|
||||
// Hack for better background
|
||||
#ifdef __WINDOWS__
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
||||
#endif
|
||||
_isDictLoaded = false;
|
||||
srand(time(NULL));
|
||||
}
|
||||
void onExitClick( wxCloseEvent& event ) { event.Skip(); }
|
||||
MainFrame( wxWindow* parent);
|
||||
void onWindowClose( wxCloseEvent& event );
|
||||
void onOpenGridClick( wxCommandEvent& event );
|
||||
void onGenerateClick( wxCommandEvent& event );
|
||||
void onSettingsClick( wxCommandEvent& event );
|
||||
void onExportClick( wxCommandEvent& event );
|
||||
void onExitClick( wxCommandEvent& event ) {
|
||||
Close();
|
||||
}
|
||||
void onExitClick( wxCommandEvent& event );
|
||||
void onAboutClick( wxCommandEvent& event ) {
|
||||
wxAboutDialogInfo info;
|
||||
info.AddDeveloper(_("Aleksey Lobanov"));
|
||||
|
||||
@@ -5,5 +5,9 @@
|
||||
|
||||
const wxString SETTINGS_KEY_DICT_PATH = wxT("/Dict/Path");
|
||||
const wxString SETTINGS_DEFAULT_DICTPATH = wxT("big_cross_ru.txt");
|
||||
const wxString SETTINGS_KEY_FMAIN_HEIGHT = wxT("fMain/Height");
|
||||
const wxString SETTINGS_KEY_FMAIN_WIDTH = wxT("fMain/Width");
|
||||
const int SETTINGS_DEFAULT_FMAIN_HEIGHT = 350;
|
||||
const int SETTINGS_DEFAULT_FMAIN_WIDTH = 600;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user