KissCount/view/wxUI.cpp

104 lines
2.2 KiB
C++
Raw Normal View History

#include "wxUI.h"
BEGIN_EVENT_TABLE(wxUI, wxFrame)
EVT_MENU(ID_Quit, wxUI::OnQuit)
EVT_MENU(ID_About, wxUI::OnAbout)
END_EVENT_TABLE()
2010-05-16 10:35:34 +02:00
wxString months[12] = {_("january"), _("february"), _("march"), _("april"), _("may"), _("june"), _("july"), _("august"), _("september"), _("october"), _("november"), _("december")} ;
wxUI::wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxSize& size)
2010-05-17 18:03:21 +02:00
: wxFrame(NULL, -1, title, pos, size), _kiss(kiss), _accountPanel(NULL), _preferencesPanel(NULL), _curPanel(NULL)
{
_hbox = new wxBoxSizer(wxVERTICAL);
ButtonPanel* buttons = new ButtonPanel(_kiss, this);
wxMenu *menuFile = new wxMenu;
menuFile->Append( ID_About, _("&About...") );
menuFile->AppendSeparator();
menuFile->Append( ID_Quit, _("E&xit") );
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, _("&File") );
SetMenuBar( menuBar );
CreateStatusBar();
SetStatusText( _("Welcome to wxWidgets!") );
SetSizer(_hbox);
_hbox->Add(buttons);
}
wxUI::~wxUI()
{
if (_accountPanel) delete _accountPanel;
2010-05-17 18:03:21 +02:00
if (_preferencesPanel) delete _preferencesPanel;
}
void wxUI::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(true);
}
void wxUI::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox( _("This is a wxWidgets Hello world sample"),
_("About Hello World"),
wxOK | wxICON_INFORMATION, this );
}
2010-05-17 18:03:21 +02:00
void wxUI::ShowAccount()
{
ShowPanel(_accountPanel);
}
void wxUI::ShowPreferences()
{
ShowPanel(_preferencesPanel);
}
void wxUI::ChangeUser()
{
UsersDialog u(_kiss, this);
u.ShowModal();
}
void wxUI::LoadUser()
{
2010-05-17 18:03:21 +02:00
if (_curPanel)
{
2010-05-17 18:03:21 +02:00
_hbox->Detach(_curPanel);
_curPanel = NULL;
}
2010-05-17 18:03:21 +02:00
if (_accountPanel)
delete _accountPanel;
if (_preferencesPanel)
delete _preferencesPanel;
_accountPanel = new AccountPanel(_kiss, this);
2010-05-17 18:03:21 +02:00
_preferencesPanel = new PreferencesPanel(_kiss, this);
ShowPanel(_accountPanel);
}
void wxUI::ShowPanel(wxPanel* panel)
{
if (!panel) return;
if (_curPanel)
{
_hbox->Detach(_curPanel);
_curPanel->Hide();
}
_curPanel = panel;
_hbox->Add(panel);
_curPanel->Show();
Layout();
}