Save window position and theme on exit

This commit is contained in:
Charles J. Cliffe
2015-07-15 00:32:36 -04:00
parent 1d20fd16bb
commit 291ec7038a
4 changed files with 101 additions and 13 deletions
+27 -12
View File
@@ -31,7 +31,7 @@
wxBEGIN_EVENT_TABLE(AppFrame, wxFrame)
//EVT_MENU(wxID_NEW, AppFrame::OnNewWindow)
EVT_MENU(wxID_CLOSE, AppFrame::OnClose)
EVT_CLOSE(AppFrame::OnClose)
EVT_MENU(wxID_ANY, AppFrame::OnMenu)
EVT_COMMAND(wxID_ANY, wxEVT_THREAD, AppFrame::OnThread)
EVT_IDLE(AppFrame::OnIdle)
@@ -190,13 +190,15 @@ AppFrame::AppFrame() :
menu = new wxMenu;
menu->AppendRadioItem(wxID_THEME_DEFAULT, "Default")->Check(true);
menu->AppendRadioItem(wxID_THEME_RADAR, "RADAR");
menu->AppendRadioItem(wxID_THEME_BW, "Black & White");
menu->AppendRadioItem(wxID_THEME_SHARP, "Sharp");
menu->AppendRadioItem(wxID_THEME_RAD, "Rad");
menu->AppendRadioItem(wxID_THEME_TOUCH, "Touch");
menu->AppendRadioItem(wxID_THEME_HD, "HD");
int themeId = wxGetApp().getConfig()->getTheme();
menu->AppendRadioItem(wxID_THEME_DEFAULT, "Default")->Check(themeId==COLOR_THEME_DEFAULT);
menu->AppendRadioItem(wxID_THEME_RADAR, "RADAR")->Check(themeId==COLOR_THEME_RADAR);
menu->AppendRadioItem(wxID_THEME_BW, "Black & White")->Check(themeId==COLOR_THEME_BW);
menu->AppendRadioItem(wxID_THEME_SHARP, "Sharp")->Check(themeId==COLOR_THEME_SHARP);
menu->AppendRadioItem(wxID_THEME_RAD, "Rad")->Check(themeId==COLOR_THEME_RAD);
menu->AppendRadioItem(wxID_THEME_TOUCH, "Touch")->Check(themeId==COLOR_THEME_TOUCH);
menu->AppendRadioItem(wxID_THEME_HD, "HD")->Check(themeId==COLOR_THEME_HD);
menuBar->Append(menu, wxT("&Color Scheme"));
@@ -302,8 +304,18 @@ AppFrame::AppFrame() :
SetMenuBar(menuBar);
CreateStatusBar();
SetClientSize(1280, 600);
Centre();
wxRect *win = wxGetApp().getConfig()->getWindow();
if (win) {
this->SetPosition(win->GetPosition());
this->SetClientSize(win->GetSize());
} else {
SetClientSize(1280, 600);
Centre();
}
ThemeMgr::mgr.setTheme(wxGetApp().getConfig()->getTheme());
Show();
#ifdef _WIN32
@@ -506,8 +518,11 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
}
void AppFrame::OnClose(wxCommandEvent& WXUNUSED(event)) {
Close(false);
void AppFrame::OnClose(wxCloseEvent& event) {
wxGetApp().getConfig()->setWindow(this->GetPosition(), this->GetClientSize());
wxGetApp().getConfig()->setTheme(ThemeMgr::mgr.getTheme());
wxGetApp().getConfig()->save();
event.Skip();
}
void AppFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event)) {