From 9101da3e2b056aa2871ae00ec854d290b6feccea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 15 Dec 2010 19:13:16 +0100 Subject: [PATCH] First work for KissPanel --- src/view/AccountPanel.cpp | 20 +++++++++++++- src/view/AccountPanel.h | 16 +++++------ src/view/ButtonPanel.h | 1 - src/view/KissPanel.h | 51 +++++++++++++++++++++++++++++++++++ src/view/PreferencesPanel.cpp | 20 ++++++++++++-- src/view/PreferencesPanel.h | 17 ++++++------ src/view/SearchPanel.cpp | 22 ++++++++++++--- src/view/SearchPanel.h | 18 ++++++------- src/view/StatsPanel.cpp | 20 ++++++++++++-- src/view/StatsPanel.h | 14 ++++------ src/view/view.h | 2 ++ 11 files changed, 155 insertions(+), 46 deletions(-) create mode 100644 src/view/KissPanel.h diff --git a/src/view/AccountPanel.cpp b/src/view/AccountPanel.cpp index 5bf71e4..5ba728d 100644 --- a/src/view/AccountPanel.cpp +++ b/src/view/AccountPanel.cpp @@ -38,7 +38,7 @@ EVT_BUTTON(GROUP_ID, AccountPanel::OnGroup) EVT_BUTTON(UNGROUP_ID, AccountPanel::OnUnGroup) END_EVENT_TABLE() -AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*parent)), _curMonth(-1), _curYear(-1), _kiss(kiss), _wxUI(parent), _tree(this, CALENDAR_TREE_ID, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT) +AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _curMonth(-1), _curYear(-1), _tree(this, CALENDAR_TREE_ID, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT) { wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *hbox2 = new wxBoxSizer(wxHORIZONTAL); @@ -156,6 +156,24 @@ AccountPanel::~AccountPanel() delete[] _accounts; } +KissPanel* AccountPanel::CreatePanel() +{ + return new AccountPanel(_kiss, _wxUI); +} + +wxBitmapButton* AccountPanel::GetButton(int id) +{ + if (!_KissButton) + _KissButton = new wxBitmapButton(_wxUI, id, wxBitmap(wxT(ACCOUNT_ICON)), wxDefaultPosition, wxSize(128, 128)); + + return _KissButton; +} + +wxString AccountPanel::GetToolTip() +{ + return _("Operations"); +} + void AccountPanel::InitStatsGrid(User* user) { int i; diff --git a/src/view/AccountPanel.h b/src/view/AccountPanel.h index 09d0928..4be0bca 100644 --- a/src/view/AccountPanel.h +++ b/src/view/AccountPanel.h @@ -25,26 +25,27 @@ #include #include #include -#include #include "grid/CalendarEditor.h" #include "grid/wxGridCellBitmapRenderer.h" #include "view.h" #include -#include "wxUI.h" #include #include "grid/GridAccount.h" #include -class wxUI; -class KissCount; - -class AccountPanel: public wxScrolledWindow +class AccountPanel: public KissPanel { public: AccountPanel(KissCount* kiss, wxUI *parent); ~AccountPanel(); + + KissPanel* CreatePanel(); + wxBitmapButton* GetButton(int id); + wxString GetToolTip(); + void OnShow(wxShowEvent& event); + void ChangeUser(); void LoadYear(int year, bool showMonth=true); void ShowMonth(int month, int year); @@ -56,7 +57,6 @@ public: void OnTreeChange(wxTreeEvent& event); void OnMenuGenerate(wxCommandEvent& event); void OnMenuDelete(wxCommandEvent& event); - void OnShow(wxShowEvent& event); void OnCalendarChange(wxCalendarEvent& event); void OnCheckMode(wxCommandEvent& event); void OnGroup(wxCommandEvent& event); @@ -65,8 +65,6 @@ public: int _curMonth, _curYear; private: - KissCount* _kiss; - wxUI* _wxUI; wxTreeCtrl _tree; wxCalendarCtrl* _calendar; GridAccount* _grid; diff --git a/src/view/ButtonPanel.h b/src/view/ButtonPanel.h index 6e6e171..6b93c2b 100644 --- a/src/view/ButtonPanel.h +++ b/src/view/ButtonPanel.h @@ -21,7 +21,6 @@ #define BUTTONPANEL_H #include -#include #include #include "wxUI.h" diff --git a/src/view/KissPanel.h b/src/view/KissPanel.h new file mode 100644 index 0000000..ed139a1 --- /dev/null +++ b/src/view/KissPanel.h @@ -0,0 +1,51 @@ +/* + Copyright 2010 Grégory Soutadé + + This file is part of KissCount. + + 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. + + 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. + + You should have received a copy of the GNU General Public License + along with KissCount. If not, see . +*/ + +#ifndef KISSPANEL_H +#define KISSPANEL_H + +#include +#include +#include + +class wxUI; +class KissCount; + +class KissPanel: public wxScrolledWindow +{ +public: + KissPanel(KissCount* kiss, wxUI* parent) : + wxScrolledWindow((wxFrame*)parent), + _kiss(kiss), + _wxUI(parent), + _KissButton(NULL) + {Hide();} + + virtual void OnShow(wxShowEvent& event)=0; + virtual KissPanel* CreatePanel()=0; + virtual wxBitmapButton* GetButton(int id) {return NULL;} + virtual wxString GetToolTip() {return wxT("");} + +protected: + KissCount* _kiss; + wxUI* _wxUI; + wxBitmapButton* _KissButton; +}; + +#endif diff --git a/src/view/PreferencesPanel.cpp b/src/view/PreferencesPanel.cpp index 4bc9bc3..92447b7 100644 --- a/src/view/PreferencesPanel.cpp +++ b/src/view/PreferencesPanel.cpp @@ -38,7 +38,7 @@ EVT_CHECKLISTBOX(SHARED_WITH_ID, PreferencesPanel::OnSharedChange) EVT_SHOW(PreferencesPanel::OnShow) END_EVENT_TABLE() -PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent), _sharedWith(NULL), _curAccountRow(-1) +PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _sharedWith(NULL), _curAccountRow(-1) { wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL); @@ -160,8 +160,24 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p Fit(); SetMinSize(GetSize()); +} - Hide(); +KissPanel* PreferencesPanel::CreatePanel() +{ + return new PreferencesPanel(_kiss, _wxUI); +} + +wxBitmapButton* PreferencesPanel::GetButton(int id) +{ + if (!_KissButton) + _KissButton = new wxBitmapButton(_wxUI, id, wxBitmap(wxT(PREFS_ICON)), wxDefaultPosition, wxSize(128, 128)); + + return _KissButton; +} + +wxString PreferencesPanel::GetToolTip() +{ + return _("Preferences"); } void PreferencesPanel::InitAccounts(User* user) diff --git a/src/view/PreferencesPanel.h b/src/view/PreferencesPanel.h index e45437c..1731e2a 100644 --- a/src/view/PreferencesPanel.h +++ b/src/view/PreferencesPanel.h @@ -31,20 +31,22 @@ #include #include -#include -#include "wxUI.h" +#include "view.h" #include #include "PasswordDialog.h" #include "SupportedLanguages.h" #include "wxGridCellStarEditor.h" -class wxUI; -class KissCount; - -class PreferencesPanel: public wxPanel +class PreferencesPanel: public KissPanel { public: PreferencesPanel(KissCount* kiss, wxUI *parent); + + KissPanel* CreatePanel(); + wxBitmapButton* GetButton(int id); + wxString GetToolTip(); + void OnShow(wxShowEvent& event); + void ChangeUser(); void OnAccountModified(wxGridEvent& event); @@ -55,12 +57,9 @@ public: void OnChangePassword(wxCommandEvent& event); void OnOperationOrderChange(wxCommandEvent& event); void OnLanguageChange(wxCommandEvent& event); - void OnShow(wxShowEvent& event); void OnKillMe(wxCommandEvent& event); private: - KissCount* _kiss; - wxUI* _wxUI; wxGrid* _accountsGrid; wxGrid* _categoriesGrid; wxTextCtrl* _name; diff --git a/src/view/SearchPanel.cpp b/src/view/SearchPanel.cpp index bd71c76..8156832 100644 --- a/src/view/SearchPanel.cpp +++ b/src/view/SearchPanel.cpp @@ -34,7 +34,7 @@ END_EVENT_TABLE() s.Replace(wxT("\\\'"), wxT("\'"), true); \ } -SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*parent)), _kiss(kiss), _wxUI(parent), _operations(NULL) +SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _operations(NULL) { DEFAULT_FONT(font); User* user = _kiss->GetUser(); @@ -117,8 +117,6 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*pa SetMinSize(wxSize(rect.width-rect.x-15, rect.height-rect.y-128-25)); SetScrollbars(10, 10, 100/10, 100/10); - - Hide(); } SearchPanel::~SearchPanel() @@ -126,6 +124,24 @@ SearchPanel::~SearchPanel() if (_operations) delete _operations; } +KissPanel* SearchPanel::CreatePanel() +{ + return new SearchPanel(_kiss, _wxUI); +} + +wxBitmapButton* SearchPanel::GetButton(int id) +{ + if (!_KissButton) + _KissButton = new wxBitmapButton(_wxUI, id, wxBitmap(wxT(SEARCH_ICON)), wxDefaultPosition, wxSize(128, 128)); + + return _KissButton; +} + +wxString SearchPanel::GetToolTip() +{ + return _("Search"); +} + void SearchPanel::OnButtonSearch(wxCommandEvent& event) { wxString *description=NULL, *amountFrom=NULL, *amountTo=NULL; diff --git a/src/view/SearchPanel.h b/src/view/SearchPanel.h index d6476a4..2872d4a 100644 --- a/src/view/SearchPanel.h +++ b/src/view/SearchPanel.h @@ -24,35 +24,33 @@ #include #include #include +#include "view.h" #include "grid/CalendarEditor.h" #include "grid/wxGridCellBitmapRenderer.h" -#include "AccountPanel.h" #include "grid/GridAccount.h" -#include "view.h" +#include "AccountPanel.h" -#include -#include "wxUI.h" #include -class wxUI; -class KissCount; class GridAccount; -class SearchPanel: public wxScrolledWindow +class SearchPanel: public KissPanel { public: SearchPanel(KissCount* kiss, wxUI *parent); ~SearchPanel(); + KissPanel* CreatePanel(); + wxBitmapButton* GetButton(int id); + wxString GetToolTip(); + void OnShow(wxShowEvent& event); + void OnButtonSearch(wxCommandEvent& event); void OnOperationModified(wxGridEvent& event); - void OnShow(wxShowEvent& event); void OnCalendarFromChange(wxCalendarEvent& event); void OnCalendarToChange(wxCalendarEvent& event); private: - KissCount* _kiss; - wxUI* _wxUI; std::vector *_operations; wxCalendarCtrl* _calendarFrom, *_calendarTo; GridAccount *_grid; diff --git a/src/view/StatsPanel.cpp b/src/view/StatsPanel.cpp index 0f2e6da..8468a4a 100644 --- a/src/view/StatsPanel.cpp +++ b/src/view/StatsPanel.cpp @@ -26,7 +26,7 @@ EVT_CHOICE(RANGE_ID, StatsPanel::OnRangeChange) EVT_CHECKLISTBOX(ACCOUNTS_ID, StatsPanel::OnAccountsChange) END_EVENT_TABLE() -StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent), _plot(NULL), _chart(NULL) +StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _plot(NULL), _chart(NULL) { wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL); _hbox2 = new wxBoxSizer(wxHORIZONTAL); @@ -138,8 +138,24 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _ki OnRangeChange(event); Fit(); +} - Hide(); +KissPanel* StatsPanel::CreatePanel() +{ + return new StatsPanel(_kiss, _wxUI); +} + +wxBitmapButton* StatsPanel::GetButton(int id) +{ + if (!_KissButton) + _KissButton = new wxBitmapButton(_wxUI, id, wxBitmap(wxT(STATS_ICON)), wxDefaultPosition, wxSize(128, 128)); + + return _KissButton; +} + +wxString StatsPanel::GetToolTip() +{ + return _("Statistics"); } void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearTo) diff --git a/src/view/StatsPanel.h b/src/view/StatsPanel.h index b4fd2af..702212b 100644 --- a/src/view/StatsPanel.h +++ b/src/view/StatsPanel.h @@ -34,24 +34,20 @@ #include #include -#include "wxUI.h" -#include #include "view.h" +#include -class wxUI; -class KissCount; - -class StatsPanel: public wxPanel //public wxScrolledWindow +class StatsPanel: public KissPanel { public: StatsPanel(KissCount* kiss, wxUI *parent); - //~StatsPanel(); + KissPanel* CreatePanel(); + wxBitmapButton* GetButton(int id); + wxString GetToolTip(); void OnShow(wxShowEvent& event); private: - KissCount* _kiss; - wxUI* _wxUI; wxCalendarCtrl* _calendarFrom, *_calendarTo; wxChoice* _monthFrom, *_yearFrom, *_monthTo, *_yearTo; wxGrid *_statsGrid; diff --git a/src/view/view.h b/src/view/view.h index f475a42..f935997 100644 --- a/src/view/view.h +++ b/src/view/view.h @@ -38,4 +38,6 @@ #define ABOUT_ICON "ressources/icons/windows-users-icon.png" #define QUIT_ICON "ressources/icons/system-log-out.png" +#include "KissPanel.h" + #endif