First work for KissPanel

This commit is contained in:
Grégory Soutadé 2010-12-15 19:13:16 +01:00
parent a43dd6bd95
commit 9101da3e2b
11 changed files with 155 additions and 46 deletions

View File

@ -38,7 +38,7 @@ EVT_BUTTON(GROUP_ID, AccountPanel::OnGroup)
EVT_BUTTON(UNGROUP_ID, AccountPanel::OnUnGroup) EVT_BUTTON(UNGROUP_ID, AccountPanel::OnUnGroup)
END_EVENT_TABLE() 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 *hbox = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *hbox2 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *hbox2 = new wxBoxSizer(wxHORIZONTAL);
@ -156,6 +156,24 @@ AccountPanel::~AccountPanel()
delete[] _accounts; 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) void AccountPanel::InitStatsGrid(User* user)
{ {
int i; int i;

View File

@ -25,26 +25,27 @@
#include <wx/treectrl.h> #include <wx/treectrl.h>
#include <wx/pie/pieplot.h> #include <wx/pie/pieplot.h>
#include <wx/chartpanel.h> #include <wx/chartpanel.h>
#include <wx/scrolwin.h>
#include "grid/CalendarEditor.h" #include "grid/CalendarEditor.h"
#include "grid/wxGridCellBitmapRenderer.h" #include "grid/wxGridCellBitmapRenderer.h"
#include "view.h" #include "view.h"
#include <controller/KissCount.h> #include <controller/KissCount.h>
#include "wxUI.h"
#include <model/model.h> #include <model/model.h>
#include "grid/GridAccount.h" #include "grid/GridAccount.h"
#include <wx/category/categorysimpledataset.h> #include <wx/category/categorysimpledataset.h>
class wxUI; class AccountPanel: public KissPanel
class KissCount;
class AccountPanel: public wxScrolledWindow
{ {
public: public:
AccountPanel(KissCount* kiss, wxUI *parent); AccountPanel(KissCount* kiss, wxUI *parent);
~AccountPanel(); ~AccountPanel();
KissPanel* CreatePanel();
wxBitmapButton* GetButton(int id);
wxString GetToolTip();
void OnShow(wxShowEvent& event);
void ChangeUser(); void ChangeUser();
void LoadYear(int year, bool showMonth=true); void LoadYear(int year, bool showMonth=true);
void ShowMonth(int month, int year); void ShowMonth(int month, int year);
@ -56,7 +57,6 @@ public:
void OnTreeChange(wxTreeEvent& event); void OnTreeChange(wxTreeEvent& event);
void OnMenuGenerate(wxCommandEvent& event); void OnMenuGenerate(wxCommandEvent& event);
void OnMenuDelete(wxCommandEvent& event); void OnMenuDelete(wxCommandEvent& event);
void OnShow(wxShowEvent& event);
void OnCalendarChange(wxCalendarEvent& event); void OnCalendarChange(wxCalendarEvent& event);
void OnCheckMode(wxCommandEvent& event); void OnCheckMode(wxCommandEvent& event);
void OnGroup(wxCommandEvent& event); void OnGroup(wxCommandEvent& event);
@ -65,8 +65,6 @@ public:
int _curMonth, _curYear; int _curMonth, _curYear;
private: private:
KissCount* _kiss;
wxUI* _wxUI;
wxTreeCtrl _tree; wxTreeCtrl _tree;
wxCalendarCtrl* _calendar; wxCalendarCtrl* _calendar;
GridAccount* _grid; GridAccount* _grid;

View File

@ -21,7 +21,6 @@
#define BUTTONPANEL_H #define BUTTONPANEL_H
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/bmpbuttn.h>
#include <controller/KissCount.h> #include <controller/KissCount.h>
#include "wxUI.h" #include "wxUI.h"

51
src/view/KissPanel.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef KISSPANEL_H
#define KISSPANEL_H
#include <wx/wx.h>
#include <wx/scrolwin.h>
#include <wx/bmpbuttn.h>
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

View File

@ -38,7 +38,7 @@ EVT_CHECKLISTBOX(SHARED_WITH_ID, PreferencesPanel::OnSharedChange)
EVT_SHOW(PreferencesPanel::OnShow) EVT_SHOW(PreferencesPanel::OnShow)
END_EVENT_TABLE() 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 *vbox = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL);
@ -160,8 +160,24 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
Fit(); Fit();
SetMinSize(GetSize()); 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) void PreferencesPanel::InitAccounts(User* user)

View File

@ -31,20 +31,22 @@
#include <wx/colordlg.h> #include <wx/colordlg.h>
#include <wx/fontdlg.h> #include <wx/fontdlg.h>
#include <controller/KissCount.h> #include "view.h"
#include "wxUI.h"
#include <model/model.h> #include <model/model.h>
#include "PasswordDialog.h" #include "PasswordDialog.h"
#include "SupportedLanguages.h" #include "SupportedLanguages.h"
#include "wxGridCellStarEditor.h" #include "wxGridCellStarEditor.h"
class wxUI; class PreferencesPanel: public KissPanel
class KissCount;
class PreferencesPanel: public wxPanel
{ {
public: public:
PreferencesPanel(KissCount* kiss, wxUI *parent); PreferencesPanel(KissCount* kiss, wxUI *parent);
KissPanel* CreatePanel();
wxBitmapButton* GetButton(int id);
wxString GetToolTip();
void OnShow(wxShowEvent& event);
void ChangeUser(); void ChangeUser();
void OnAccountModified(wxGridEvent& event); void OnAccountModified(wxGridEvent& event);
@ -55,12 +57,9 @@ public:
void OnChangePassword(wxCommandEvent& event); void OnChangePassword(wxCommandEvent& event);
void OnOperationOrderChange(wxCommandEvent& event); void OnOperationOrderChange(wxCommandEvent& event);
void OnLanguageChange(wxCommandEvent& event); void OnLanguageChange(wxCommandEvent& event);
void OnShow(wxShowEvent& event);
void OnKillMe(wxCommandEvent& event); void OnKillMe(wxCommandEvent& event);
private: private:
KissCount* _kiss;
wxUI* _wxUI;
wxGrid* _accountsGrid; wxGrid* _accountsGrid;
wxGrid* _categoriesGrid; wxGrid* _categoriesGrid;
wxTextCtrl* _name; wxTextCtrl* _name;

View File

@ -34,7 +34,7 @@ END_EVENT_TABLE()
s.Replace(wxT("\\\'"), wxT("\'"), true); \ 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); DEFAULT_FONT(font);
User* user = _kiss->GetUser(); 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)); SetMinSize(wxSize(rect.width-rect.x-15, rect.height-rect.y-128-25));
SetScrollbars(10, 10, 100/10, 100/10); SetScrollbars(10, 10, 100/10, 100/10);
Hide();
} }
SearchPanel::~SearchPanel() SearchPanel::~SearchPanel()
@ -126,6 +124,24 @@ SearchPanel::~SearchPanel()
if (_operations) delete _operations; 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) void SearchPanel::OnButtonSearch(wxCommandEvent& event)
{ {
wxString *description=NULL, *amountFrom=NULL, *amountTo=NULL; wxString *description=NULL, *amountFrom=NULL, *amountTo=NULL;

View File

@ -24,35 +24,33 @@
#include <wx/grid.h> #include <wx/grid.h>
#include <wx/treectrl.h> #include <wx/treectrl.h>
#include <wx/scrolwin.h> #include <wx/scrolwin.h>
#include "view.h"
#include "grid/CalendarEditor.h" #include "grid/CalendarEditor.h"
#include "grid/wxGridCellBitmapRenderer.h" #include "grid/wxGridCellBitmapRenderer.h"
#include "AccountPanel.h"
#include "grid/GridAccount.h" #include "grid/GridAccount.h"
#include "view.h" #include "AccountPanel.h"
#include <controller/KissCount.h>
#include "wxUI.h"
#include <model/model.h> #include <model/model.h>
class wxUI;
class KissCount;
class GridAccount; class GridAccount;
class SearchPanel: public wxScrolledWindow class SearchPanel: public KissPanel
{ {
public: public:
SearchPanel(KissCount* kiss, wxUI *parent); SearchPanel(KissCount* kiss, wxUI *parent);
~SearchPanel(); ~SearchPanel();
KissPanel* CreatePanel();
wxBitmapButton* GetButton(int id);
wxString GetToolTip();
void OnShow(wxShowEvent& event);
void OnButtonSearch(wxCommandEvent& event); void OnButtonSearch(wxCommandEvent& event);
void OnOperationModified(wxGridEvent& event); void OnOperationModified(wxGridEvent& event);
void OnShow(wxShowEvent& event);
void OnCalendarFromChange(wxCalendarEvent& event); void OnCalendarFromChange(wxCalendarEvent& event);
void OnCalendarToChange(wxCalendarEvent& event); void OnCalendarToChange(wxCalendarEvent& event);
private: private:
KissCount* _kiss;
wxUI* _wxUI;
std::vector<Operation> *_operations; std::vector<Operation> *_operations;
wxCalendarCtrl* _calendarFrom, *_calendarTo; wxCalendarCtrl* _calendarFrom, *_calendarTo;
GridAccount *_grid; GridAccount *_grid;

View File

@ -26,7 +26,7 @@ EVT_CHOICE(RANGE_ID, StatsPanel::OnRangeChange)
EVT_CHECKLISTBOX(ACCOUNTS_ID, StatsPanel::OnAccountsChange) EVT_CHECKLISTBOX(ACCOUNTS_ID, StatsPanel::OnAccountsChange)
END_EVENT_TABLE() 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); wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
_hbox2 = new wxBoxSizer(wxHORIZONTAL); _hbox2 = new wxBoxSizer(wxHORIZONTAL);
@ -138,8 +138,24 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _ki
OnRangeChange(event); OnRangeChange(event);
Fit(); 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) void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearTo)

View File

@ -34,24 +34,20 @@
#include <wx/category/categorysimpledataset.h> #include <wx/category/categorysimpledataset.h>
#include <controller/KissCount.h> #include <controller/KissCount.h>
#include "wxUI.h"
#include <model/model.h>
#include "view.h" #include "view.h"
#include <model/model.h>
class wxUI; class StatsPanel: public KissPanel
class KissCount;
class StatsPanel: public wxPanel //public wxScrolledWindow
{ {
public: public:
StatsPanel(KissCount* kiss, wxUI *parent); StatsPanel(KissCount* kiss, wxUI *parent);
//~StatsPanel();
KissPanel* CreatePanel();
wxBitmapButton* GetButton(int id);
wxString GetToolTip();
void OnShow(wxShowEvent& event); void OnShow(wxShowEvent& event);
private: private:
KissCount* _kiss;
wxUI* _wxUI;
wxCalendarCtrl* _calendarFrom, *_calendarTo; wxCalendarCtrl* _calendarFrom, *_calendarTo;
wxChoice* _monthFrom, *_yearFrom, *_monthTo, *_yearTo; wxChoice* _monthFrom, *_yearFrom, *_monthTo, *_yearTo;
wxGrid *_statsGrid; wxGrid *_statsGrid;

View File

@ -38,4 +38,6 @@
#define ABOUT_ICON "ressources/icons/windows-users-icon.png" #define ABOUT_ICON "ressources/icons/windows-users-icon.png"
#define QUIT_ICON "ressources/icons/system-log-out.png" #define QUIT_ICON "ressources/icons/system-log-out.png"
#include "KissPanel.h"
#endif #endif