From 59d770c9280343d3b2d241742396ad2dcc31a8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 11 Dec 2010 09:51:44 +0100 Subject: [PATCH 01/15] Add lib directory check in Makefile --- INSTALL | 1 + Makefile | 5 ++++- src/view/AccountPanel.cpp | 32 ++++++++++++----------------- src/view/PreferencesPanel.cpp | 38 ++++++++++++++--------------------- src/view/SearchPanel.cpp | 7 +++---- src/view/StatsPanel.cpp | 29 +++++++++++--------------- src/view/UsersDialog.cpp | 6 ++++-- src/view/wxUI.cpp | 2 +- 8 files changed, 53 insertions(+), 67 deletions(-) diff --git a/INSTALL b/INSTALL index a1fdb2d..794d553 100644 --- a/INSTALL +++ b/INSTALL @@ -14,6 +14,7 @@ php5 ** Compilation of extra libraries ** lib is not included by default and must be downloaded http://indefero.soutade.fr/p/kisscount/downloads/ +It must be decompressed beside "src" directory. cd lib/wxsqlite3-1.9.9 ./configure diff --git a/Makefile b/Makefile index cd69603..d753805 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ HEADERS+=$(wildcard src/controller/*.h) HEADERS+=src/main.h src/sha1.h OBJS=$(SOURCES:.cpp=.o) -all: kc +all: check kc clean: rm -f *~ src/*~ src/*.o src/model/*.o src/model/*~ src/view/*.o src/view/grid/*.o src/view/grid/*~ src/view/*~ src/controller/*.o src/controller/*~ kc @@ -28,6 +28,9 @@ clean: %.o : src/model/%.cpp src/view/%.cpp src/view/grid/%.cpp src/controller/%.cpp src/%.cpp $(CXX) $(CXXFLAGS) $< -c +check: + if ! test -d lib ; then echo lib directory not found, please see INSTALL ; return 1 ; fi + kc: $(OBJS) $(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS) diff --git a/src/view/AccountPanel.cpp b/src/view/AccountPanel.cpp index f90a83c..5bf71e4 100644 --- a/src/view/AccountPanel.cpp +++ b/src/view/AccountPanel.cpp @@ -126,32 +126,26 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(* wxButton* buttonGroup = new wxButton(this, GROUP_ID, _("Group")); wxButton* buttonUnGroup = new wxButton(this, UNGROUP_ID, _("UnGroup")); - vbox3->Add(&_tree, 0); - vbox3->Add(-1, 30); - vbox3->Add(buttonGroup, 0); - vbox3->Add(-1, 10); - vbox3->Add(buttonUnGroup, 0); + vbox3->Add(&_tree, 0, wxGROW|wxALL, 2); + vbox3->Add(buttonGroup, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10); + vbox3->Add(buttonUnGroup, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10); - hbox->Add(vbox3, 0); - hbox2->Add(_accountsGrid, 0); - hbox2->Add(_calendar, 0); + hbox->Add(vbox3, 0, wxGROW|wxALL, 2); + hbox2->Add(_accountsGrid, 0, wxGROW|wxALL, 2); + hbox2->Add(_calendar, 0, wxALL, 2); vbox2->Add(hbox2, 0); - vbox2->Add(-1, 10); - vbox2->Add(_grid, 0); - hbox->Add(vbox2, 0); - vbox->Add(_statsGrid, 0); - vbox->Add(-1, 10); - vbox->Add(chart, 0); - hbox->Add(-1, 10); - vbox->Add(_checkCheckMode, 0); - hbox->Add(-1, 10); - hbox->Add(vbox, 0); + vbox2->Add(_grid, 0, wxGROW|wxALL, 2); + hbox->Add(vbox2, 0, wxGROW|wxALL, 2); + vbox->Add(_statsGrid, 0, wxGROW); + vbox->Add(chart, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 10); + vbox->Add(_checkCheckMode, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 10); + hbox->Add(vbox, 0, wxGROW|wxALL, 2); ChangeUser(); Fit(); - SetMinSize(wxSize(rect.width-rect.x, rect.height-rect.y-128)); + SetMinSize(wxSize(rect.width-rect.x-15, rect.height-rect.y-128-25)); SetScrollbars(10, 10, 100/10, 100/10); } diff --git a/src/view/PreferencesPanel.cpp b/src/view/PreferencesPanel.cpp index 7e73bf6..4bc9bc3 100644 --- a/src/view/PreferencesPanel.cpp +++ b/src/view/PreferencesPanel.cpp @@ -65,8 +65,8 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p // User staticBoxSizer = new wxStaticBoxSizer (staticUser, wxVERTICAL); - gridBagSizer = new wxGridBagSizer(10, 10); - staticBoxSizer->Add(gridBagSizer); + gridBagSizer = new wxGridBagSizer(2, 3); + staticBoxSizer->Add(gridBagSizer, 0, wxGROW|wxALL, 2); label = new wxStaticText(this, wxID_ANY, _("Name")); gridBagSizer->Add(label, wxGBPosition(0, 0)); @@ -82,8 +82,7 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p gridBagSizer->Add(buttonChangePassword, wxGBPosition(1, 1)); gridBagSizer->Add(killMe, wxGBPosition(1, 2)); - vbox->Add(staticBoxSizer); - vbox->Add(-1, 20); + vbox->Add(staticBoxSizer, 0, wxALL, 10); // Account staticBoxSizer = new wxStaticBoxSizer (staticAccount, wxVERTICAL); @@ -96,15 +95,14 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p InitAccounts(user); - staticBoxSizer->Add(_accountsGrid); + staticBoxSizer->Add(_accountsGrid, 0, wxGROW|wxALL, 2); - hbox1->Add(staticBoxSizer); - hbox1->Add(-1, 20); + hbox1->Add(staticBoxSizer, 0, wxALL); staticBoxSizer = new wxStaticBoxSizer (staticSharedWith, wxVERTICAL); _sharedWith = new wxCheckListBox(this, SHARED_WITH_ID); - staticBoxSizer->Add(_sharedWith); + staticBoxSizer->Add(_sharedWith, 0, wxGROW); users = _kiss->GetUsers(); @@ -114,8 +112,8 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p _sharedWith->Enable(false); - hbox1->Add(staticBoxSizer); - hbox1->Add(-1, 20); + hbox1->Add(staticBoxSizer, 0, wxLEFT, 5); + vbox->Add(hbox1, 0, wxGROW|wxALL, 10); // Categories staticBoxSizer = new wxStaticBoxSizer (staticCategories, wxVERTICAL); @@ -126,15 +124,11 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p _categoriesGrid = new wxMyGrid(this, CATEGORIES_GRID_ID, clicks, 4); } - staticBoxSizer->Add(_categoriesGrid); + staticBoxSizer->Add(_categoriesGrid, 0, wxGROW|wxALL, 2); InitCategories(user); - vbox->Add(hbox1); - vbox->Add(-1, 20); - - vbox->Add(staticBoxSizer); - vbox->Add(-1, 20); + vbox->Add(staticBoxSizer, 0, wxALL, 10); // Operation Order staticBoxSizer = new wxStaticBoxSizer (staticOperationOrder, wxVERTICAL); @@ -142,10 +136,9 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p _operationOrder = new wxComboBox(this, OPERATION_ORDER_ID); _operationOrder->SetWindowStyle(wxCB_READONLY); - staticBoxSizer->Add(_operationOrder); + staticBoxSizer->Add(_operationOrder, 0, wxGROW|wxALL, 2); - hbox2->Add(staticBoxSizer); - hbox2->Add(-1, 20); + hbox2->Add(staticBoxSizer, 0); InitOperationOrder(user); @@ -155,16 +148,15 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p _language = new wxBitmapComboBox(this, LANGUAGE_ID); _language->SetWindowStyle(wxCB_READONLY); - staticBoxSizer->Add(_language); + staticBoxSizer->Add(_language, 0, wxGROW|wxALL, 2); - hbox2->Add(staticBoxSizer); - hbox2->Add(-1, 20); + hbox2->Add(staticBoxSizer, 0, wxLEFT, 10); InitLanguage(user); _language->Fit(); - vbox->Add(hbox2); + vbox->Add(hbox2, 0, wxALL, 10); Fit(); SetMinSize(GetSize()); diff --git a/src/view/SearchPanel.cpp b/src/view/SearchPanel.cpp index 1318a0c..bd71c76 100644 --- a/src/view/SearchPanel.cpp +++ b/src/view/SearchPanel.cpp @@ -107,16 +107,15 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*pa gridBagSizer->Add(_account, wxGBPosition(1, 7)); gridBagSizer->Add(_searchButton, wxGBPosition(2, 0)); - vbox->Add(gridBagSizer); - vbox->Add(-1, 20); + vbox->Add(gridBagSizer, 0, wxGROW|wxALL, 5); _grid = new GridAccount(_kiss, this, GRID_ID); - vbox->Add(_grid); + vbox->Add(_grid, 0, wxGROW|wxALL, 5); Fit(); - SetMinSize(wxSize(rect.width-rect.x, rect.height-rect.y-128)); + SetMinSize(wxSize(rect.width-rect.x-15, rect.height-rect.y-128-25)); SetScrollbars(10, 10, 100/10, 100/10); Hide(); diff --git a/src/view/StatsPanel.cpp b/src/view/StatsPanel.cpp index 62ca913..0f2e6da 100644 --- a/src/view/StatsPanel.cpp +++ b/src/view/StatsPanel.cpp @@ -60,16 +60,13 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _ki _yearTo->Select(i); wxStaticText* label = new wxStaticText(this, wxID_ANY, _("From")); - hbox->Add(label); - hbox->Add(-1, 10); - hbox->Add(_monthFrom); - hbox->Add(_yearFrom); + hbox->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5); + hbox->Add(_monthFrom, 0, wxRIGHT, 5); + hbox->Add(_yearFrom, 0, wxRIGHT, 20); - hbox->Add(-1, 30); label = new wxStaticText(this, wxID_ANY, _("To")); - hbox->Add(label); - hbox->Add(-1, 10); - hbox->Add(_monthTo); + hbox->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5); + hbox->Add(_monthTo, 0, wxRIGHT, 5); hbox->Add(_yearTo); _account = new wxCheckListBox(this, ACCOUNTS_ID); @@ -106,9 +103,8 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _ki _statsGrid->SetCellAlignment(i, 1, wxALIGN_RIGHT, wxALIGN_CENTRE); } - _vbox2->Add(_account); - _vbox2->Add(-1, 10); - _vbox2->Add(_statsGrid); + _vbox2->Add(_account, 0, wxGROW|wxALL, 5); + _vbox2->Add(_statsGrid, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW|wxALL, 5); _pie = new PiePlot(); @@ -133,11 +129,10 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _ki chart->SetMinSize(// chart->GetSize() wxSize(200,250)); - _vbox2->Add(-1, 10); - _vbox2->Add(chart); + _vbox2->Add(chart, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW|wxALL, 10); - vbox->Add(hbox); - vbox->Add(_hbox2); + vbox->Add(hbox, 0, wxALIGN_CENTER_VERTICAL|wxGROW|wxALL, 5); + vbox->Add(_hbox2, 0, wxGROW|wxALL, 5); wxCommandEvent event ; OnRangeChange(event); @@ -295,7 +290,7 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT _chart->SetMinSize(// chart->GetSize() wxSize(750,550)); - _hbox2->Add(_chart); + _hbox2->Add(_chart, 0, wxGROW|wxALL, 5); total = 0.0; for(categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++) @@ -317,7 +312,7 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT _pie->DatasetChanged(_dataset); - _hbox2->Add(_vbox2); + _hbox2->Add(_vbox2, 0, wxGROW|wxALL, 5); Layout(); } diff --git a/src/view/UsersDialog.cpp b/src/view/UsersDialog.cpp index ce60891..c53d52e 100644 --- a/src/view/UsersDialog.cpp +++ b/src/view/UsersDialog.cpp @@ -33,6 +33,7 @@ UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : wxDialog(&(*parent), - wxStaticText* label; wxCommandEvent event; + wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL); gridBagSizer = new wxGridBagSizer(4, 4); label = new wxStaticText(this, -1, _("User ")); @@ -63,10 +64,11 @@ UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : wxDialog(&(*parent), - _users->Select(0); - SetSizer(gridBagSizer); + hbox->Add(gridBagSizer, 0, wxGROW|wxALL, 10); + SetSizer(hbox); _users->SetFocus(); - Layout(); + Fit(); Center(); if (users_list.size() == 0) diff --git a/src/view/wxUI.cpp b/src/view/wxUI.cpp index 0d267fb..d5e17a4 100644 --- a/src/view/wxUI.cpp +++ b/src/view/wxUI.cpp @@ -250,7 +250,7 @@ void wxUI::ShowPanel(wxPanel* panel) } _curPanel = panel; - _hbox->Add(panel); + _hbox->Add(panel, 1, wxGROW|wxALL, 0); _curPanel->Show(); Layout(); } From a43dd6bd95b9280a635f0c5775d521e9be4d7f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sun, 12 Dec 2010 20:30:52 +0100 Subject: [PATCH 02/15] Add ChangeLog --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ChangeLog diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..2b00522 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,3 @@ + +v0.2_dev (12/12/10) + Better use of sizers (so better interface!) 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 03/15] 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 From 7c85467a5a744a10bb6fac92695acce6c4ac87f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Mon, 20 Dec 2010 19:28:24 +0100 Subject: [PATCH 04/15] Use a factory to create panels instead of hard coded panels --- src/view/ButtonPanel.cpp | 118 -------------- src/view/ButtonPanel.h | 64 -------- src/view/wxUI.cpp | 336 +++++++++++++++++++-------------------- src/view/wxUI.h | 27 ++-- 4 files changed, 183 insertions(+), 362 deletions(-) delete mode 100644 src/view/ButtonPanel.cpp delete mode 100644 src/view/ButtonPanel.h diff --git a/src/view/ButtonPanel.cpp b/src/view/ButtonPanel.cpp deleted file mode 100644 index e145ea5..0000000 --- a/src/view/ButtonPanel.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - 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 . -*/ - -#include "ButtonPanel.h" - -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) -EVT_BUTTON(BUTTON_ACCOUNT_ID, ButtonPanel::OnButtonAccount) -EVT_BUTTON(BUTTON_STATS_ID, ButtonPanel::OnButtonStats) -EVT_BUTTON(BUTTON_SEARCH_ID, ButtonPanel::OnButtonSearch) -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); - - 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; -} - -void ButtonPanel::SetToolTips() -{ - _account->SetToolTip(_("Operations")); - _stats->SetToolTip(_("Statistics")); - _search->SetToolTip(_("Search")); - _prefs->SetToolTip(_("Preferences")); - _changeUser->SetToolTip(_("Change user")); - _about->SetToolTip(_("About")); - _quit->SetToolTip(_("Quit")); -} - -void ButtonPanel::OnButtonAccount(wxCommandEvent& event) -{ - _wxUI->ShowAccount(); -} - -void ButtonPanel::OnButtonStats(wxCommandEvent& event) -{ - _wxUI->ShowStats(); -} - -void ButtonPanel::OnButtonSearch(wxCommandEvent& event) -{ - _wxUI->ShowSearch(); -} - -void ButtonPanel::OnButtonPreferences(wxCommandEvent& event) -{ - _wxUI->ShowPreferences(); -} - -void ButtonPanel::OnButtonChangeUser(wxCommandEvent& event) -{ - _wxUI->ChangeUser(); -} - -void ButtonPanel::OnButtonAbout(wxCommandEvent& event) -{ - wxMessageBox( _("Personal accounting software\n\nhttp://indefero.soutade.fr/p/kisscount/\n\nLicenced under GNU GPL v3\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); -} diff --git a/src/view/ButtonPanel.h b/src/view/ButtonPanel.h deleted file mode 100644 index 6b93c2b..0000000 --- a/src/view/ButtonPanel.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - 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 BUTTONPANEL_H -#define BUTTONPANEL_H - -#include - -#include -#include "wxUI.h" - -#include "view.h" - -class KissCount; -class wxUI; - -class ButtonPanel: public wxPanel -{ -public: - - ButtonPanel(KissCount* kiss, wxUI *parent); - ~ButtonPanel(); - - void SetToolTips(); - - void OnButtonAccount(wxCommandEvent& event); - void OnButtonStats(wxCommandEvent& event); - void OnButtonSearch(wxCommandEvent& event); - void OnButtonPreferences(wxCommandEvent& event); - void OnButtonChangeUser(wxCommandEvent& event); - void OnButtonAbout(wxCommandEvent& event); - void OnButtonQuit(wxCommandEvent& event); - -private: - KissCount* _kiss; - wxUI* _wxUI; - wxBitmapButton* _account; - wxBitmapButton* _stats; - wxBitmapButton* _search; - wxBitmapButton* _prefs; - wxBitmapButton* _changeUser; - wxBitmapButton* _about; - wxBitmapButton* _quit; - - DECLARE_EVENT_TABLE(); -}; - -#endif diff --git a/src/view/wxUI.cpp b/src/view/wxUI.cpp index d5e17a4..c2a5f76 100644 --- a/src/view/wxUI.cpp +++ b/src/view/wxUI.cpp @@ -19,38 +19,64 @@ #include "wxUI.h" +enum {BUTTON_CHANGE_USER_ID=-4, BUTTON_ABOUT_ID=-5, BUTTON_QUIT_ID=-6}; + +BEGIN_EVENT_TABLE(wxUI, wxFrame) +EVT_BUTTON(BUTTON_CHANGE_USER_ID, wxUI::OnButtonChangeUser) +EVT_BUTTON(BUTTON_ABOUT_ID, wxUI::OnButtonAbout) +EVT_BUTTON(BUTTON_QUIT_ID, wxUI::OnButtonQuit) +END_EVENT_TABLE() + wxString months[12] ; wxColour categoryColors[12] = {wxColour(0x00, 0x45, 0x86), - wxColour(0xFF, 0x3E, 0x0E), - wxColour(0xFF, 0xD3, 0x20), - wxColour(0x58, 0x9D, 0x1B), - wxColour(0x7E, 0x00, 0x21), - wxColour(0x83, 0xCC, 0xFF), - wxColour(0x31, 0x40, 0x04), - wxColour(0xB0, 0xCF, 0x00), - wxColour(0x4B, 0x1F, 0x6F), - wxColour(0xFF, 0x93, 0x0E), - wxColour(0xC5, 0x00, 0x0D), - wxColour(0x00, 0x84, 0xD1)}; + wxColour(0xFF, 0x3E, 0x0E), + wxColour(0xFF, 0xD3, 0x20), + wxColour(0x58, 0x9D, 0x1B), + wxColour(0x7E, 0x00, 0x21), + wxColour(0x83, 0xCC, 0xFF), + wxColour(0x31, 0x40, 0x04), + wxColour(0xB0, 0xCF, 0x00), + wxColour(0x4B, 0x1F, 0x6F), + wxColour(0xFF, 0x93, 0x0E), + wxColour(0xC5, 0x00, 0x0D), + wxColour(0x00, 0x84, 0xD1)}; wxUI::wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxSize& size) - : wxFrame(NULL, wxID_ANY, title, pos, size), _kiss(kiss), _buttonPanel(NULL), _accountPanel(NULL), _statsPanel(NULL), - _searchPanel(NULL), _preferencesPanel(NULL), _curPanel(NULL), _locale(NULL), _needReload(false) + : wxFrame(NULL, -1, title, pos, size), _kiss(kiss), + _curPanel(NULL), _locale(NULL), _needReload(false) { - _hbox = new wxBoxSizer(wxVERTICAL); - _buttonPanel = new ButtonPanel(_kiss, this); + _vbox = new wxBoxSizer(wxVERTICAL); + _buttonsBox = new wxBoxSizer(wxHORIZONTAL); + // ButtonPanel* buttons = new ButtonPanel(_kiss, this); + // wxMenu *menuFile = new wxMenu; - SetSizer(_hbox); + // menuFile->Append( ID_About, wxT("&About...") ); + // menuFile->AppendSeparator(); + // menuFile->Append( ID_Quit, wxT("E&xit") ); - _hbox->Add(_buttonPanel); + // wxMenuBar *menuBar = new wxMenuBar; + // menuBar->Append( menuFile, wxT("&File") ); + + // SetMenuBar( menuBar ); + + // CreateStatusBar(); + // SetStatusText( wxT("Welcome to wxWidgets!") ); + _buttonsBox->Add(new wxBitmapButton(this, BUTTON_CHANGE_USER_ID, wxBitmap(wxT(CHANGE_USER_ICON)), wxDefaultPosition, wxSize(128, 128))); + _buttonsBox->Add(new wxBitmapButton(this, BUTTON_ABOUT_ID, wxBitmap(wxT(ABOUT_ICON)), wxDefaultPosition, wxSize(128, 128))); + _buttonsBox->Add(new wxBitmapButton(this, BUTTON_QUIT_ID, wxBitmap(wxT(QUIT_ICON)), wxDefaultPosition, wxSize(128, 128))); + + SetSizer(_vbox); + + _vbox->Add(_buttonsBox, 0, wxGROW); } wxUI::~wxUI() { - if (_accountPanel) delete _accountPanel; - if (_preferencesPanel) delete _preferencesPanel; - if (_searchPanel) delete _searchPanel; - if (_statsPanel) delete _statsPanel; + int i; + + for (i=0; i<(int)_panels.size(); i++) + Disconnect(i, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), _panels[i], this); + if (_locale) delete _locale; } @@ -64,31 +90,31 @@ bool wxUI::SetLanguage(long language) // load language if possible, fall back to english otherwise if(wxLocale::IsAvailable(language)) { - _locale = new wxLocale( language, wxLOCALE_CONV_ENCODING ); + _locale = new wxLocale( language, wxLOCALE_CONV_ENCODING ); #ifdef __WXGTK__ - _locale->AddCatalogLookupPathPrefix(wxT("./ressources/po")); + _locale->AddCatalogLookupPathPrefix(wxT("./ressources/po")); #endif - _locale->AddCatalog(wxT("french")); - _locale->AddCatalog(wxT("kisscount")); + _locale->AddCatalog(wxT("french")); + _locale->AddCatalog(wxT("kisscount")); - _language = (wxLanguage) language; + _language = (wxLanguage) language; } if (_locale == NULL || !_locale->IsOk()) { - if (_locale) delete _locale; - _locale = new wxLocale(); + if (_locale) delete _locale; + _locale = new wxLocale(); #ifdef __WXGTK__ - _locale->AddCatalogLookupPathPrefix(wxT("./ressources/po")); + _locale->AddCatalogLookupPathPrefix(wxT("./ressources/po")); #endif - _locale->AddCatalog(wxT("kisscount")); + _locale->AddCatalog(wxT("kisscount")); - _language = wxLANGUAGE_ENGLISH; - res = false; + _language = wxLANGUAGE_ENGLISH; + res = false; } months[0] = _("january"); @@ -104,30 +130,108 @@ bool wxUI::SetLanguage(long language) months[10] = _("november"); months[11] = _("december") ; - if (_buttonPanel) - _buttonPanel->SetToolTips(); - return res; } -void wxUI::ShowAccount() +#define ADD_PANEL(panelName, id) \ + panel = new panelName(_kiss, this); \ + button = panel->GetButton(id); \ + button->SetToolTip(panel->GetToolTip()); \ + _buttonsBox->Insert(id, button); \ + _buttons.insert(_buttons.begin()+id, button); \ + _panels.push_back(panel); \ + Connect(id, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), panel, this); + +void wxUI::InitPanels() { - ShowPanel(_accountPanel); + KissPanel* panel; + wxBitmapButton* button; + _panels.clear(); + + ADD_PANEL(AccountPanel, 0); + ADD_PANEL(StatsPanel, 1); + ADD_PANEL(SearchPanel, 2); + ADD_PANEL(PreferencesPanel, 3); } -void wxUI::ShowSearch() +void wxUI::LoadPanels() { - ShowPanel(_searchPanel); + std::vector::iterator it; + KissPanel* temp; + int i; + + if (_curPanel) + { + _vbox->Detach(_curPanel); + _curPanel = NULL; + } + + if (_panels.size()) + { + for (i=0; i<(int)_panels.size(); i++) + { + temp = _panels[i]->CreatePanel(); + Disconnect(i, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), _panels[i], this); + _panels[i] = temp; + Connect(i, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), temp, this); + std::cout << temp->GetToolTip().mb_str() << "\n"; + _buttons[i]->SetToolTip(temp->GetToolTip()); + } + } + else + InitPanels(); } -void wxUI::ShowStats() +void wxUI::LoadUser() { - ShowPanel(_statsPanel); + User* user = _kiss->GetUser(); + LoadPanels(); + + if (user->_preferences[wxT("language")] != wxT("")) + SetLanguage(user->GetLanguage()); + + if (_panels.size()) + ShowPanel(_panels[0]); } -void wxUI::ShowPreferences() +void wxUI::ShowPanel(KissPanel* panel) { - ShowPanel(_preferencesPanel); + wxShowEvent event; + int i; + + if (!panel) return; + + if (_curPanel) + { + _vbox->Detach(_curPanel); + _curPanel->Hide(); + } + + if (_needReload) + { + for(i=0; i<(int)_panels.size(); i++) + if (_panels[i] == panel) break; + LoadPanels(); + _needReload = false; + _curPanel = _panels[i]; + } + else + _curPanel = panel; + + _curPanel->OnShow(event); + _vbox->Add(_curPanel); + _curPanel->Show(); + Layout(); +} + +void wxUI::OnButtonClicked(wxCommandEvent& event) +{ + ShowPanel(_panels[event.GetId()]); +} + +void wxUI::OnButtonChangeUser(wxCommandEvent& event) +{ + ChangeUser(); } void wxUI::ChangeUser() @@ -135,151 +239,47 @@ void wxUI::ChangeUser() UsersDialog u(_kiss, this); } -void wxUI::LoadUser() +void wxUI::OnButtonAbout(wxCommandEvent& event) { - User* user = _kiss->GetUser(); - wxShowEvent event; - - if (_curPanel) - { - _hbox->Detach(_curPanel); - _curPanel = NULL; - } - - if (_accountPanel) - delete _accountPanel; - - if (_preferencesPanel) - delete _preferencesPanel; - - if (_searchPanel) - delete _searchPanel; - - if (_statsPanel) - delete _statsPanel; - - if (user->_preferences[wxT("language")].Length()) - SetLanguage(user->GetLanguage()); - - _accountPanel = new AccountPanel(_kiss, this); - _statsPanel = new StatsPanel(_kiss, this); - _searchPanel = new SearchPanel(_kiss, this); - _preferencesPanel = new PreferencesPanel(_kiss, this); - - ShowPanel(_accountPanel); - _accountPanel->OnShow(event); + wxMessageBox( _("Personal accounting software\n\nhttp://indefero.soutade.fr/p/kisscount/\n\nLicenced under GNU GPL v3\n\nCopyright (C) 2010 Grégory Soutadé"), + wxT("KissCount " APP_VERSION "\n\n"), + wxOK | wxICON_INFORMATION, this ); } -void wxUI::ShowPanel(wxPanel* panel) +void wxUI::OnButtonQuit(wxCommandEvent& event) { - int month, year=-1, account=0, preferences=0, search=0, stats=0; - wxShowEvent event; - - if (!panel || (panel == _curPanel && !_needReload)) return; - - if (_curPanel) + wxMessageDialog dialog(this, _("Quit KissCount ?"), wxT("KissCount"), wxYES_NO); + if (dialog.ShowModal() == wxID_NO) { - _hbox->Detach(_curPanel); - _curPanel->Hide(); + return; } - if (_needReload) - { - if (panel == _accountPanel) - { - account = 1; - month = _accountPanel->_curMonth; - year = _accountPanel->_curYear; - } - - if (panel == _preferencesPanel) - { - preferences = 1; - } - - if (panel == _searchPanel) - { - search = 1; - } - - if (panel == _statsPanel) - { - stats = 1; - } - - delete _accountPanel; - delete _preferencesPanel; - delete _searchPanel; - delete _statsPanel; - - _accountPanel = new AccountPanel(_kiss, this); - if (year != -1) - { - _kiss->LoadYear(year, true); - _accountPanel->ShowMonth(month, year); - } - _preferencesPanel = new PreferencesPanel(_kiss, this); - _searchPanel = new SearchPanel(_kiss, this); - _statsPanel = new StatsPanel(_kiss, this); - - if (account) - { - _accountPanel->OnShow(event); - panel = _accountPanel; - } - else if (preferences) - { - _preferencesPanel->OnShow(event); - panel = _preferencesPanel; - } - else if (search) - { - _searchPanel->OnShow(event); - panel = _searchPanel; - } - else if (stats) - { - _statsPanel->OnShow(event); - panel = _statsPanel; - } - - _hbox->Detach(_accountPanel); - _accountPanel->Hide(); - - _needReload = false; - } - - _curPanel = panel; - _hbox->Add(panel, 1, wxGROW|wxALL, 0); - _curPanel->Show(); - Layout(); + Close(true); } void wxUI::GenerateMonth(int month, int year) { - _accountPanel->GenerateMonth(month, year); + ((AccountPanel*)_panels[0])->GenerateMonth(month, year); } void wxUI::KillMe() { + std::vector::iterator it; + if (_curPanel) { - _hbox->Detach(_curPanel); - _curPanel = NULL; + _vbox->Detach(_curPanel); + _curPanel = NULL; } - if (_accountPanel) - delete _accountPanel; + for (it=_panels.begin(); it!= _panels.end(); it++) + { + if (*it) delete *it; + _buttonsBox->Remove(0); + _buttons.erase(_buttons.begin()); + } - if (_preferencesPanel) - delete _preferencesPanel; - - if (_searchPanel) - delete _searchPanel; - - _accountPanel = NULL; - _preferencesPanel = NULL; - _searchPanel = NULL; + _panels.clear(); } void wxUI::NeedReload() diff --git a/src/view/wxUI.h b/src/view/wxUI.h index b42684f..9522c70 100644 --- a/src/view/wxUI.h +++ b/src/view/wxUI.h @@ -22,7 +22,6 @@ #include #include "AccountPanel.h" -#include "ButtonPanel.h" #include "PreferencesPanel.h" #include "UsersDialog.h" #include "GenerateDialog.h" @@ -35,10 +34,8 @@ #include "grid/wxGridCellButtonEditor.h" class KissCount; -class ButtonPanel; class AccountPanel; class PreferencesPanel; -class StatsPanel; extern wxString months[12]; extern wxColour categoryColors[12]; @@ -56,29 +53,35 @@ public: void LoadUser(); void ShowAccount(); - void ShowStats(); void ShowSearch(); void ShowPreferences(); void GenerateMonth(int month, int year); void KillMe(); - void ShowPanel(wxPanel* panel); + void ShowPanel(KissPanel* panel); void NeedReload(); wxLanguage _language; + void OnButtonClicked(wxCommandEvent& event); + void OnButtonChangeUser(wxCommandEvent& event); + void OnButtonAbout(wxCommandEvent& event); + void OnButtonQuit(wxCommandEvent& event); + private: KissCount *_kiss; - wxBoxSizer *_hbox; - ButtonPanel *_buttonPanel; - AccountPanel *_accountPanel; - StatsPanel *_statsPanel; - SearchPanel *_searchPanel; - PreferencesPanel *_preferencesPanel; - wxPanel *_curPanel; + wxBoxSizer *_vbox, *_buttonsBox; + KissPanel *_curPanel; + std::vector _panels; + std::vector _buttons; wxLocale *_locale; bool _needReload; + + void InitPanels(); + void LoadPanels(); + + DECLARE_EVENT_TABLE(); }; #endif From 6317511fd8abeeb3e1a6e961a319b9b5087bc1b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Mon, 20 Dec 2010 20:17:46 +0100 Subject: [PATCH 05/15] Forgot to remove debugging disply --- ChangeLog | 7 ++++++- TODO | 1 - src/view/wxUI.cpp | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b00522..5879e5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ -v0.2_dev (12/12/10) +v0.2_dev (20/12/10) + +** User ** Better use of sizers (so better interface!) + +** Dev ** + Use a factory to create panels (prepare for plug-in) diff --git a/TODO b/TODO index eb78945..25bf88d 100644 --- a/TODO +++ b/TODO @@ -3,7 +3,6 @@ Version 0.2 Statistics (need to add months/years label on graph) Auto completion (already up into wxwidgets 2.9) Using tabulation to navigate throw interface (Search Panel) -Improve Scrolled Windows and widgets placement Can type a letter with a comboboxes Windows version Need packaging (.deb) diff --git a/src/view/wxUI.cpp b/src/view/wxUI.cpp index c2a5f76..142827e 100644 --- a/src/view/wxUI.cpp +++ b/src/view/wxUI.cpp @@ -174,7 +174,6 @@ void wxUI::LoadPanels() Disconnect(i, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), _panels[i], this); _panels[i] = temp; Connect(i, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxUI::OnButtonClicked), temp, this); - std::cout << temp->GetToolTip().mb_str() << "\n"; _buttons[i]->SetToolTip(temp->GetToolTip()); } } From c527fad7563b3bb6cd234c214c04420f88d1d219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Thu, 6 Jan 2011 18:18:31 +0100 Subject: [PATCH 06/15] Bug of new year --- src/model/Database.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/model/Database.cpp b/src/model/Database.cpp index 0b83830..53278ce 100644 --- a/src/model/Database.cpp +++ b/src/model/Database.cpp @@ -661,6 +661,10 @@ bool Database::LoadOperation(User* user, const wxString& id) op.transfert = set.GetAsString(wxT("transfert")); op.formula = set.GetAsString(wxT("formula")); op.meta = set.GetBool(wxT("meta")); + + if (!user->_operations[op.year]) + user->_operations[op.year] = new std::map >(); + for (it = (*user->_operations[op.year])[op.month].begin(); it != (*user->_operations[op.year])[op.month].end(); it++) From 5bf9e2f871812d29e29e69bf4f35f99045784e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Thu, 6 Jan 2011 18:27:58 +0100 Subject: [PATCH 07/15] Bad version number --- src/controller/KissCount.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/KissCount.h b/src/controller/KissCount.h index 7eb3a0a..0da2a31 100644 --- a/src/controller/KissCount.h +++ b/src/controller/KissCount.h @@ -29,7 +29,7 @@ #include -#define APP_VERSION "v0.1" +#define APP_VERSION "v0.2 dev" class wxUI; class Database; From c0c5a090f675967ebf2db9102864780a2e2abcae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Thu, 6 Jan 2011 18:32:45 +0100 Subject: [PATCH 08/15] Update package.sh to take care of spaces in version number --- tools/package.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/package.sh b/tools/package.sh index fba1944..f4ec3bc 100755 --- a/tools/package.sh +++ b/tools/package.sh @@ -6,16 +6,16 @@ VERSION=`cat src/controller/KissCount.h | grep APP_VERSION | cut -d\" -f2` DIR="KissCount_build_${VERSION}_${DATE}_${ARCH}" FILE="$DIR.tar.bz2" -rm -f $FILE -rm -rf $DIR +rm -f "$FILE" +rm -rf "$DIR" if [ "$1" == "clean" ] ; then make clean fi make || (echo "Compilation failed" ; exit 1) -mkdir -p $DIR/lib -cp -r lib/freechart/lib/*.so* lib/wxsqlite3-1.9.9/lib/*.so* $DIR/lib -cp -r kc init.sql ressources tools/launch_kc.sh TODO CONTRIBUTORS COPYING README README.fr www $DIR -find $DIR -type f -executable -exec strip \{\} \; -tar -jcf $FILE $DIR -rm -rf $DIR +mkdir -p "$DIR"/lib +cp -r lib/freechart/lib/*.so* lib/wxsqlite3-1.9.9/lib/*.so* "$DIR"/lib +cp -r kc init.sql ressources tools/launch_kc.sh TODO CONTRIBUTORS COPYING README README.fr www "$DIR" +find "$DIR" -type f -executable -exec strip \{\} \; +tar -jcf "$FILE" "$DIR" +rm -rf "$DIR" echo "Packaged !" \ No newline at end of file From e6ca15f5f3aff993e9b6788cc65a367d82feec18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Thu, 6 Jan 2011 18:59:23 +0100 Subject: [PATCH 09/15] Better fix for previous bug --- src/model/Database.cpp | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/model/Database.cpp b/src/model/Database.cpp index 53278ce..3b6b754 100644 --- a/src/model/Database.cpp +++ b/src/model/Database.cpp @@ -662,33 +662,33 @@ bool Database::LoadOperation(User* user, const wxString& id) op.formula = set.GetAsString(wxT("formula")); op.meta = set.GetBool(wxT("meta")); - if (!user->_operations[op.year]) - user->_operations[op.year] = new std::map >(); - - for (it = (*user->_operations[op.year])[op.month].begin(); - it != (*user->_operations[op.year])[op.month].end(); - it++) + if (user->_operations[op.year]) { - if (!op.fix_cost && it->fix_cost) continue; - if (op.fix_cost && !it->fix_cost) + for (it = (*user->_operations[op.year])[op.month].begin(); + it != (*user->_operations[op.year])[op.month].end(); + it++) { - it--; - break; - } - if (it->day > op.day) - { - it--; - break; + if (!op.fix_cost && it->fix_cost) continue; + if (op.fix_cost && !it->fix_cost) + { + it--; + break; + } + if (it->day > op.day) + { + it--; + break; + } } + if (it == (*user->_operations[op.year])[op.month].end()) + (*user->_operations[op.year])[op.month].push_back(op); + else + (*user->_operations[op.year])[op.month].insert(it, op); + // if (op.fix_cost) + // else + // (*user->_operations[op.year])[op.month].push_back(op); + ret = true; } - if (it == (*user->_operations[op.year])[op.month].end()) - (*user->_operations[op.year])[op.month].push_back(op); - else - (*user->_operations[op.year])[op.month].insert(it, op); - // if (op.fix_cost) - // else - // (*user->_operations[op.year])[op.month].push_back(op); - ret = true; } set.Finalize(); From d2d8e47dbcd1bce8e43a919022195251b9bcf928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Thu, 6 Jan 2011 20:19:03 +0100 Subject: [PATCH 10/15] Bug on GenerateMonth with different years --- src/controller/KissCount.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controller/KissCount.cpp b/src/controller/KissCount.cpp index 18203a5..4113bc4 100644 --- a/src/controller/KissCount.cpp +++ b/src/controller/KissCount.cpp @@ -296,8 +296,8 @@ void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int year } // Re Generate parents - for(it = (*_user->_operations[yearFrom])[monthTo].begin(); - it != (*_user->_operations[yearFrom])[monthTo].end(); + for(it = (*_user->_operations[yearTo])[monthTo].begin(); + it != (*_user->_operations[yearTo])[monthTo].end(); it++) { if (it->parent.Length()) @@ -305,8 +305,8 @@ void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int year it->parent = meta[it->parent]; UpdateOperation(*it); - for(it2 = (*_user->_operations[yearFrom])[monthTo].begin(); - it2 != (*_user->_operations[yearFrom])[monthTo].end(); + for(it2 = (*_user->_operations[yearTo])[monthTo].begin(); + it2 != (*_user->_operations[yearTo])[monthTo].end(); it2++) if (it2->id == it->parent) { From d71f055dfc1f9b9d8f3ad8bbb8048f2d2bab9522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 8 Jan 2011 12:17:54 +0100 Subject: [PATCH 11/15] Fix several bugs in StatsPanel : Bad selection of year with multiple years Bad year range check Unordered accounts (makes account selection points to bad indexes on account graph) --- ChangeLog | 5 ++++- src/model/User.h | 5 +++++ src/view/StatsPanel.cpp | 41 +++++++++++++++++++++-------------------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5879e5a..4c97cec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,11 @@ -v0.2_dev (20/12/10) +v0.2_dev (06/01/2011) ** User ** Better use of sizers (so better interface!) ** Dev ** Use a factory to create panels (prepare for plug-in) + +** Bugs ** + Bug on GenerateMonth with different years diff --git a/src/model/User.h b/src/model/User.h index 3e9b689..509186d 100644 --- a/src/model/User.h +++ b/src/model/User.h @@ -51,14 +51,19 @@ public: wxString GetCategoryName(wxString& catId); wxString GetCategoryId(wxString& catName); const wxFont GetCategoryFont(wxString& catId); + Account GetAccount(const wxString& accountId); wxString GetAccountName(const wxString& accountId); wxString GetAccountId(wxString& accountName); + int GetCategoriesNumber(); int GetAccountsNumber(); int GetOperationsNumber(int month, int year); + wxLanguage GetLanguage(); + void LinkOrUnlinkOperation(Operation& op); + void Group(const Operation& op); bool Group(std::vector* ops, const Operation& op); void UnGroup(const Operation& op); diff --git a/src/view/StatsPanel.cpp b/src/view/StatsPanel.cpp index 8468a4a..0a5a650 100644 --- a/src/view/StatsPanel.cpp +++ b/src/view/StatsPanel.cpp @@ -54,10 +54,12 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _yearTo->Append(wxString::Format(wxT("%d"), it->first)); } - _monthFrom->Select(0); - _monthTo->Select(11); + if (i) i--; + _yearFrom->Select(i); _yearTo->Select(i); + _monthFrom->Select(0); + _monthTo->Select(11); wxStaticText* label = new wxStaticText(this, wxID_ANY, _("From")); hbox->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5); @@ -163,12 +165,11 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT std::map > > accountAmounts; std::map categories; std::map > operations; - std::map >::iterator accountIdIt2; + std::vector::iterator accountIt; std::map::iterator categoriesIt; - std::map > >::iterator accountIdIt; std::map >::iterator accountYearIt; double total; - int size, i, a, b, percents, account, nbDays; + int account, size, i, a, b, percents, nbDays; double *amounts; wxString value; User* user = _kiss->GetUser(); @@ -204,10 +205,10 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT dataset->AddSerie((double *) amounts, nbDays); delete[] amounts; - for (account = 0, i = 0, accountIdIt2 = operations.begin(); accountIdIt2 != operations.end(); - accountIdIt2++, i++, account++) + for (account = 0, i = 0, accountIt = user->_accounts.begin(); accountIt != user->_accounts.end(); + account++, accountIt++, i++) { - if (!((wxCheckListBox*)_account)->IsChecked(account)) + if (!_account->IsChecked(account)) { i-- ; continue; @@ -218,11 +219,11 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT for (a=0; afirst][a]; + amounts[a*2+1] = operations[accountIt->id][a]; } dataset->AddSerie((double *) amounts, nbDays); // set serie names to be displayed on legend - dataset->SetSerieName(i+1, user->GetAccountName(accountIdIt2->first)); + dataset->SetSerieName(i+1, user->GetAccountName(accountIt->id)); delete[] amounts; } } @@ -245,34 +246,34 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT dataset->AddSerie((double *) amounts, size); delete[] amounts; - for (account = 0, i = 0, accountIdIt = accountAmounts.begin(); accountIdIt != accountAmounts.end(); - accountIdIt++, i++, account++) + for (account = 0, i = 0, accountIt = user->_accounts.begin(); accountIt != user->_accounts.end(); + account++, accountIt++, i++) { - if (!((wxCheckListBox*)_account)->IsChecked(account)) + if (!_account->IsChecked(account)) { i-- ; continue; } - size = accountAmounts[accountIdIt->first].size(); + size = accountAmounts[accountIt->id].size(); amounts = new double[size*12*2]; size = 0; - for(a = 0, accountYearIt = accountAmounts[accountIdIt->first].begin(); - accountYearIt != accountAmounts[accountIdIt->first].end(); + for(a = 0, accountYearIt = accountAmounts[accountIt->id].begin(); + accountYearIt != accountAmounts[accountIt->id].end(); accountYearIt++, a++) { for(b = 0; b<12; b++) { - if (!accountAmounts[accountIdIt->first][accountYearIt->first].count(b)) + if (!accountAmounts[accountIt->id][accountYearIt->first].count(b)) continue; amounts[size*2+0] = a*12+b; - amounts[size*2+1] = accountAmounts[accountIdIt->first][accountYearIt->first][b]; + amounts[size*2+1] = accountAmounts[accountIt->id][accountYearIt->first][b]; size++; } } dataset->AddSerie((double *) amounts, size); // set serie names to be displayed on legend - dataset->SetSerieName(i+1, user->GetAccountName(accountIdIt->first)); + dataset->SetSerieName(i+1, user->GetAccountName(accountIt->id)); delete[] amounts; } } @@ -351,7 +352,7 @@ void StatsPanel::OnRangeChange(wxCommandEvent& event) monthTo = _monthTo->GetCurrentSelection(); _yearTo->GetStringSelection().ToLong(&yearTo); - if (yearTo > yearFrom || + if (yearTo < yearFrom || (yearFrom == yearTo && monthFrom > monthTo)) { wxMessageBox(_("Invalide date range"), _("KissCount"), wxICON_ERROR | wxOK); From 0975d12c86e54a9bc6221954e7026d40651e31da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 8 Jan 2011 12:20:22 +0100 Subject: [PATCH 12/15] Update ChangeLog --- ChangeLog | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4c97cec..7c220c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ -v0.2_dev (06/01/2011) +v0.2_dev (08/01/2011) ** User ** Better use of sizers (so better interface!) @@ -9,3 +9,7 @@ v0.2_dev (06/01/2011) ** Bugs ** Bug on GenerateMonth with different years + In StatsPanel : + Bad selection of year with multiple years + Bad year range check + Unordered accounts (makes account selection points to bad indexes on account graph) From a4b01362de1dda1653759545b1049bbdebe8d663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sun, 16 Jan 2011 20:50:48 +0100 Subject: [PATCH 13/15] Fix a bug in account creation --- src/view/PreferencesPanel.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/view/PreferencesPanel.cpp b/src/view/PreferencesPanel.cpp index 92447b7..508076f 100644 --- a/src/view/PreferencesPanel.cpp +++ b/src/view/PreferencesPanel.cpp @@ -238,6 +238,12 @@ void PreferencesPanel::AddAccount(int line, Account ac) _accountsGrid->SetReadOnly(line, ACCOUNT_DEFAULT, true); _accountsGrid->SetReadOnly(line, ACCOUNT_BLOCKED, true); } + else + { + _accountsGrid->SetReadOnly(line, ACCOUNT_DEFAULT, false); + _accountsGrid->SetReadOnly(line, ACCOUNT_BLOCKED, false); + _accountsGrid->SetReadOnly(line, ACCOUNT_DELETE, false); + } } else { @@ -488,6 +494,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event) new_account.shared = false; new_account.blocked = false; + new_account.is_owner = true; AddAccount(row, new_account); _kiss->AddAccount(new_account); @@ -495,7 +502,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event) _accountsGrid->AppendRows(); new_account.id = wxT("0"); - AddAccount(row, new_account); + AddAccount(row+1, new_account); } _wxUI->Layout(); From 87b68db3190aa6fce33956bd258afef6d1ad2618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sun, 16 Jan 2011 20:51:15 +0100 Subject: [PATCH 14/15] Update Changelog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 7c220c0..9a0b39d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,3 +13,4 @@ v0.2_dev (08/01/2011) Bad selection of year with multiple years Bad year range check Unordered accounts (makes account selection points to bad indexes on account graph) + Bug in account creation (read only fields) From 81884250bcbf17ca44c6eb19ec60ea2869c39731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sun, 23 Jan 2011 09:51:08 +0100 Subject: [PATCH 15/15] Solve bug of scrollbar and window when there is a lot of operations in AccountPanel --- ChangeLog | 5 +++-- src/view/AccountPanel.cpp | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a0b39d..422cb9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -v0.2_dev (08/01/2011) +v0.2_dev (23/01/2011) ** User ** Better use of sizers (so better interface!) + No further problems with scrollbar in AccountPanel when there is a lot of operations ** Dev ** Use a factory to create panels (prepare for plug-in) @@ -13,4 +14,4 @@ v0.2_dev (08/01/2011) Bad selection of year with multiple years Bad year range check Unordered accounts (makes account selection points to bad indexes on account graph) - Bug in account creation (read only fields) + Bug in account creation (readonly fields) diff --git a/src/view/AccountPanel.cpp b/src/view/AccountPanel.cpp index 5ba728d..5963e7f 100644 --- a/src/view/AccountPanel.cpp +++ b/src/view/AccountPanel.cpp @@ -146,6 +146,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare Fit(); SetMinSize(wxSize(rect.width-rect.x-15, rect.height-rect.y-128-25)); + SetMaxSize(wxSize(rect.width-rect.x-15, rect.height-rect.y-128-25)); SetScrollbars(10, 10, 100/10, 100/10); } @@ -573,6 +574,8 @@ void AccountPanel::UpdateStats() void AccountPanel::OnOperationModified(wxGridEvent& event) { UpdateStats(); + + Fit(); } void AccountPanel::OnAccountModified(wxGridEvent& event)