KissCount/src/view/ButtonPanel.cpp

116 lines
3.8 KiB
C++
Raw Normal View History

2010-07-10 16:34:30 +02:00
/*
Copyright 2010 Grégory Soutadé
2010-07-10 16:34:30 +02:00
This file is part of KissCount.
2010-07-10 16:34:30 +02:00
KissCount is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
2010-07-10 16:34:30 +02:00
KissCount is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2010-07-10 16:34:30 +02:00
You should have received a copy of the GNU General Public License
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
2010-07-10 16:34:30 +02:00
*/
#include "ButtonPanel.h"
2010-07-04 16:33:25 +02:00
enum {BUTTON_ACCOUNT_ID=1, BUTTON_STATS_ID, BUTTON_SEARCH_ID, BUTTON_PREFS_ID, BUTTON_CHANGE_USER_ID, BUTTON_ABOUT_ID, BUTTON_QUIT_ID};
BEGIN_EVENT_TABLE(ButtonPanel, wxPanel)
2010-07-04 16:33:25 +02:00
EVT_BUTTON(BUTTON_ACCOUNT_ID, ButtonPanel::OnButtonAccount)
EVT_BUTTON(BUTTON_STATS_ID, ButtonPanel::OnButtonStats)
2010-07-14 11:15:48 +02:00
EVT_BUTTON(BUTTON_SEARCH_ID, ButtonPanel::OnButtonSearch)
2010-07-04 16:33:25 +02:00
EVT_BUTTON(BUTTON_PREFS_ID, ButtonPanel::OnButtonPreferences)
EVT_BUTTON(BUTTON_CHANGE_USER_ID, ButtonPanel::OnButtonChangeUser)
EVT_BUTTON(BUTTON_ABOUT_ID, ButtonPanel::OnButtonAbout)
EVT_BUTTON(BUTTON_QUIT_ID, ButtonPanel::OnButtonQuit)
END_EVENT_TABLE()
ButtonPanel::ButtonPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent)
{
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
_account = new wxBitmapButton(this, BUTTON_ACCOUNT_ID, wxBitmap(wxT(ACCOUNT_ICON)), wxDefaultPosition, wxSize(128, 128));
_stats = new wxBitmapButton(this, BUTTON_STATS_ID, wxBitmap(wxT(STATS_ICON)), wxDefaultPosition, wxSize(128, 128));
_search = new wxBitmapButton(this, BUTTON_SEARCH_ID, wxBitmap(wxT(SEARCH_ICON)), wxDefaultPosition, wxSize(128, 128));
_prefs = new wxBitmapButton(this, BUTTON_PREFS_ID, wxBitmap(wxT(PREFS_ICON)), wxDefaultPosition, wxSize(128, 128));
_changeUser = new wxBitmapButton(this, BUTTON_CHANGE_USER_ID, wxBitmap(wxT(CHANGE_USER_ICON)), wxDefaultPosition, wxSize(128, 128));
_about = new wxBitmapButton(this, BUTTON_ABOUT_ID, wxBitmap(wxT(ABOUT_ICON)), wxDefaultPosition, wxSize(128, 128));
_quit = new wxBitmapButton(this, BUTTON_QUIT_ID, wxBitmap(wxT(QUIT_ICON)), wxDefaultPosition, wxSize(128, 128));
SetSizer(hbox);
_account->SetToolTip(_("Operations"));
_stats->SetToolTip(_("Statistics"));
_search->SetToolTip(_("Search"));
_prefs->SetToolTip(_("Preferences"));
_changeUser->SetToolTip(_("Change user"));
_about->SetToolTip(_("About"));
_quit->SetToolTip(_("Quit"));
hbox->Add(_account);
hbox->Add(_stats);
hbox->Add(_search);
hbox->Add(_prefs);
hbox->Add(_changeUser);
hbox->Add(_about);
hbox->Add(_quit);
Fit();
SetMinSize(GetSize());
}
ButtonPanel::~ButtonPanel()
{
delete _account;
delete _stats;
delete _prefs;
delete _changeUser;
}
2010-05-17 18:03:21 +02:00
void ButtonPanel::OnButtonAccount(wxCommandEvent& event)
{
_wxUI->ShowAccount();
2010-05-17 18:03:21 +02:00
}
void ButtonPanel::OnButtonStats(wxCommandEvent& event)
{
_wxUI->ShowStats();
}
2010-07-14 11:15:48 +02:00
void ButtonPanel::OnButtonSearch(wxCommandEvent& event)
{
_wxUI->ShowSearch();
2010-07-14 11:15:48 +02:00
}
2010-05-17 18:03:21 +02:00
void ButtonPanel::OnButtonPreferences(wxCommandEvent& event)
{
_wxUI->ShowPreferences();
2010-05-17 18:03:21 +02:00
}
void ButtonPanel::OnButtonChangeUser(wxCommandEvent& event)
{
_wxUI->ChangeUser();
}
void ButtonPanel::OnButtonAbout(wxCommandEvent& event)
{
wxMessageBox( _("Personal accounting software\n\nCopyright (C) 2010 Grégory Soutadé"),
wxT("KissCount " APP_VERSION "\n\n"),
wxOK | wxICON_INFORMATION, _wxUI );
}
void ButtonPanel::OnButtonQuit(wxCommandEvent& event)
{
wxMessageDialog dialog(_wxUI, _("Quit KissCount ?"), wxT("KissCount"), wxYES_NO);
if (dialog.ShowModal() == wxID_NO)
{
return;
}
_wxUI->Close(true);
}