Move directories, fix a bug into month generation (tree), add tooltips
This commit is contained in:
126
src/view/wxUI.cpp
Normal file
126
src/view/wxUI.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
#include "wxUI.h"
|
||||
|
||||
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)
|
||||
: wxFrame(NULL, -1, title, pos, size), _kiss(kiss), _accountPanel(NULL), _preferencesPanel(NULL), _curPanel(NULL),
|
||||
_needReload(false)
|
||||
{
|
||||
_hbox = new wxBoxSizer(wxVERTICAL);
|
||||
ButtonPanel* buttons = new ButtonPanel(_kiss, this);
|
||||
// wxMenu *menuFile = new wxMenu;
|
||||
|
||||
// menuFile->Append( ID_About, wxT("&About...") );
|
||||
// menuFile->AppendSeparator();
|
||||
// menuFile->Append( ID_Quit, wxT("E&xit") );
|
||||
|
||||
// wxMenuBar *menuBar = new wxMenuBar;
|
||||
// menuBar->Append( menuFile, wxT("&File") );
|
||||
|
||||
// SetMenuBar( menuBar );
|
||||
|
||||
// CreateStatusBar();
|
||||
// SetStatusText( wxT("Welcome to wxWidgets!") );
|
||||
|
||||
SetSizer(_hbox);
|
||||
|
||||
_hbox->Add(buttons);
|
||||
}
|
||||
|
||||
wxUI::~wxUI()
|
||||
{
|
||||
if (_accountPanel) delete _accountPanel;
|
||||
if (_preferencesPanel) delete _preferencesPanel;
|
||||
}
|
||||
|
||||
void wxUI::ShowAccount()
|
||||
{
|
||||
ShowPanel(_accountPanel);
|
||||
}
|
||||
|
||||
void wxUI::ShowPreferences()
|
||||
{
|
||||
ShowPanel(_preferencesPanel);
|
||||
}
|
||||
|
||||
void wxUI::ChangeUser()
|
||||
{
|
||||
UsersDialog u(_kiss, this);
|
||||
u.ShowModal();
|
||||
}
|
||||
|
||||
void wxUI::LoadUser()
|
||||
{
|
||||
if (_curPanel)
|
||||
{
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel = NULL;
|
||||
}
|
||||
|
||||
if (_accountPanel)
|
||||
delete _accountPanel;
|
||||
|
||||
if (_preferencesPanel)
|
||||
delete _preferencesPanel;
|
||||
|
||||
_preferencesPanel = new PreferencesPanel(_kiss, this);
|
||||
_accountPanel = new AccountPanel(_kiss, this);
|
||||
|
||||
ShowPanel(_accountPanel);
|
||||
}
|
||||
|
||||
void wxUI::ShowPanel(wxPanel* panel)
|
||||
{
|
||||
int month, year;
|
||||
|
||||
if (!panel) return;
|
||||
|
||||
if (_curPanel)
|
||||
{
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel->Hide();
|
||||
}
|
||||
|
||||
if (panel == _accountPanel && _needReload)
|
||||
{
|
||||
month = _accountPanel->_curMonth;
|
||||
year = _accountPanel->_curYear;
|
||||
delete _accountPanel;
|
||||
panel = _accountPanel = new AccountPanel(_kiss, this);
|
||||
_accountPanel->ShowMonth(month, year);
|
||||
_needReload = false;
|
||||
}
|
||||
|
||||
_curPanel = panel;
|
||||
_hbox->Add(panel);
|
||||
_curPanel->Show();
|
||||
Layout();
|
||||
}
|
||||
|
||||
void wxUI::GenerateMonth(int month, int year)
|
||||
{
|
||||
_accountPanel->GenerateMonth(month, year);
|
||||
}
|
||||
|
||||
void wxUI::KillMe()
|
||||
{
|
||||
if (_curPanel)
|
||||
{
|
||||
_hbox->Detach(_curPanel);
|
||||
_curPanel = NULL;
|
||||
}
|
||||
|
||||
if (_accountPanel)
|
||||
delete _accountPanel;
|
||||
|
||||
if (_preferencesPanel)
|
||||
delete _preferencesPanel;
|
||||
|
||||
_accountPanel = NULL;
|
||||
_preferencesPanel = NULL;
|
||||
}
|
||||
|
||||
void wxUI::NeedReload()
|
||||
{
|
||||
_needReload = true;
|
||||
}
|
||||
Reference in New Issue
Block a user