From 6ca15e23b084e378835b0bb5dc1453effd9f90d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 14 Jul 2010 11:15:48 +0200 Subject: [PATCH] wip --- src/view/AccountPanel.cpp | 4 +--- src/view/AccountPanel.h | 11 +---------- src/view/ButtonPanel.cpp | 6 ++++++ src/view/ButtonPanel.h | 9 ++------- src/view/GridAccount.h | 5 ++++- src/view/wxUI.cpp | 36 +++++++++++++++++++++++++++++++----- src/view/wxUI.h | 3 +++ 7 files changed, 48 insertions(+), 26 deletions(-) diff --git a/src/view/AccountPanel.cpp b/src/view/AccountPanel.cpp index a394681..818acbd 100644 --- a/src/view/AccountPanel.cpp +++ b/src/view/AccountPanel.cpp @@ -24,8 +24,6 @@ enum {ACCOUNT_NUMBER, ACCOUNT_NAME, ACCOUNT_INIT, ACCOUNT_CUR, ACCOUNT_FINAL, NU enum {CUR_CREDIT, CUR_DEBIT, TOTAL_CREDIT, TOTAL_DEBIT, REMAINS, STATS_ROW, CATS_STATS}; enum {CALENDAR_TREE_ID=1, OPS_GRID_ID, CALENDAR_ID, ACCOUNTS_GRID_ID, MENU_GENERATE_ID, MENU_DELETE_ID}; -static wxString colsName[] = {_("Description"), _("Date"), _("Debit"), _("Credit"), _("Category"), _("Account"), wxT(""), wxT("")}; - BEGIN_EVENT_TABLE(AccountPanel, wxPanel) EVT_GRID_CMD_CELL_CHANGE(OPS_GRID_ID, AccountPanel::OnOperationModified) EVT_GRID_CMD_CELL_CHANGE(ACCOUNTS_GRID_ID, AccountPanel::OnAccountModified) @@ -111,11 +109,11 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(* _grid->SetColLabelSize(0); _grid->SetRowLabelSize(0); - _grid->CreateGrid(1, NUMBER_COLS_OPS); _grid->SetColSize (0, _grid->GetColSize(0)*3); _grid->SetDefaultCellFont(font); font.SetWeight(wxFONTWEIGHT_BOLD); + wxString colsName[] = {_("Description"), _("Date"), _("Debit"), _("Credit"), _("Category"), _("Account"), wxT(""), wxT("")}; for(i=0; iSetCellValue(0, i, colsName[i]); diff --git a/src/view/AccountPanel.h b/src/view/AccountPanel.h index 975eae8..e73e5b5 100644 --- a/src/view/AccountPanel.h +++ b/src/view/AccountPanel.h @@ -29,16 +29,7 @@ along with KissCount. If not, see . #include "CalendarEditor.h" #include "wxGridCellBitmapRenderer.h" -#define OWN_CYAN wxColour(0x99, 0xCC, 0xFF) -#define OWN_YELLOW wxColour(0xFF, 0xFF, 0x99) -#define OWN_GREEN wxColour(0x3D, 0xEB, 0x3D) - -#define DEFAULT_FONT_NAME wxT("Liberation Sans") -#define DEFAULT_FONT_SIZE 12 -#define DEFAULT_FONT(font_name) wxFont font_name(DEFAULT_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, DEFAULT_FONT_NAME); - -#define DELETE_ICON "ressources/icons/process-stop.png" -#define CHECKED_ICON "ressources/icons/tick-icon.png" +#include "view.h" #include #include "wxUI.h" diff --git a/src/view/ButtonPanel.cpp b/src/view/ButtonPanel.cpp index 766fad8..932470a 100644 --- a/src/view/ButtonPanel.cpp +++ b/src/view/ButtonPanel.cpp @@ -23,6 +23,7 @@ enum {BUTTON_ACCOUNT_ID=1, BUTTON_STATS_ID, BUTTON_SEARCH_ID, BUTTON_PREFS_ID, B BEGIN_EVENT_TABLE(ButtonPanel, wxPanel) EVT_BUTTON(BUTTON_ACCOUNT_ID, ButtonPanel::OnButtonAccount) +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) @@ -75,6 +76,11 @@ void ButtonPanel::OnButtonAccount(wxCommandEvent& event) _wxUI->ShowAccount(); } +void ButtonPanel::OnButtonSearch(wxCommandEvent& event) +{ + _wxUI->ShowSearch(); +} + void ButtonPanel::OnButtonPreferences(wxCommandEvent& event) { _wxUI->ShowPreferences(); diff --git a/src/view/ButtonPanel.h b/src/view/ButtonPanel.h index 4eb2748..3fed829 100644 --- a/src/view/ButtonPanel.h +++ b/src/view/ButtonPanel.h @@ -26,13 +26,7 @@ along with KissCount. If not, see . #include #include "wxUI.h" -#define ACCOUNT_ICON "ressources/icons/administrator-icon.png" -#define STATS_ICON "ressources/icons/chart-icon.png" -#define SEARCH_ICON "ressources/icons/Search-icon.png" -#define PREFS_ICON "ressources/icons/options-icon.png" -#define CHANGE_USER_ICON "ressources/icons/Clients-icon.png" -#define ABOUT_ICON "ressources/icons/windows-users-icon.png" -#define QUIT_ICON "ressources/icons/system-log-out.png" +#include "view.h" class KissCount; class wxUI; @@ -45,6 +39,7 @@ class ButtonPanel: public wxPanel ~ButtonPanel(); void OnButtonAccount(wxCommandEvent& event); + void OnButtonSearch(wxCommandEvent& event); void OnButtonPreferences(wxCommandEvent& event); void OnButtonChangeUser(wxCommandEvent& event); void OnButtonAbout(wxCommandEvent& event); diff --git a/src/view/GridAccount.h b/src/view/GridAccount.h index 1a4ed4a..6b4d85a 100644 --- a/src/view/GridAccount.h +++ b/src/view/GridAccount.h @@ -28,7 +28,10 @@ along with KissCount. If not, see . class GridAccount : public wxGrid { public: - GridAccount(wxWindow *parent, wxWindowID id) : wxGrid(parent, id) {} + GridAccount(wxWindow *parent, wxWindowID id) : wxGrid(parent, id), + _fixCosts(0), _week1(0), _week2(0), _week3(0), _week4(0) + {} + wxPen GetColGridLinePen (int col) {return wxPen(*wxBLACK, 1, wxSOLID);} wxPen GetRowGridLinePen (int row) { if (row == 0 || row == _fixCosts || diff --git a/src/view/wxUI.cpp b/src/view/wxUI.cpp index b072df1..5909caa 100644 --- a/src/view/wxUI.cpp +++ b/src/view/wxUI.cpp @@ -22,8 +22,8 @@ along with KissCount. If not, see . wxString months[12] ; 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), - _locale(NULL), _needReload(false) + : wxFrame(NULL, -1, title, pos, size), _kiss(kiss), _accountPanel(NULL), _searchPanel(NULL), _preferencesPanel(NULL), + _curPanel(NULL), _locale(NULL), _needReload(false) { _hbox = new wxBoxSizer(wxVERTICAL); ButtonPanel* buttons = new ButtonPanel(_kiss, this); @@ -50,6 +50,7 @@ wxUI::~wxUI() { if (_accountPanel) delete _accountPanel; if (_preferencesPanel) delete _preferencesPanel; + if (_searchPanel) delete _searchPanel; if (_locale) delete _locale; } @@ -111,6 +112,11 @@ void wxUI::ShowAccount() ShowPanel(_accountPanel); } +void wxUI::ShowSearch() +{ + ShowPanel(_searchPanel); +} + void wxUI::ShowPreferences() { ShowPanel(_preferencesPanel); @@ -138,18 +144,22 @@ void wxUI::LoadUser() if (_preferencesPanel) delete _preferencesPanel; + if (_searchPanel) + delete _searchPanel; + if (user->_preferences[wxT("language")] != wxT("")) SetLanguage(user->GetLanguage()); - _preferencesPanel = new PreferencesPanel(_kiss, this); _accountPanel = new AccountPanel(_kiss, this); + _searchPanel = new SearchPanel(_kiss, this); + _preferencesPanel = new PreferencesPanel(_kiss, this); ShowPanel(_accountPanel); } void wxUI::ShowPanel(wxPanel* panel) { - int month, year, account=0, preferences=0; + int month, year, account=0, preferences=0, search=0; wxShowEvent event; if (!panel) return; @@ -174,13 +184,20 @@ void wxUI::ShowPanel(wxPanel* panel) preferences = 1; } + if (panel == _searchPanel) + { + search = 1; + } + delete _accountPanel; delete _preferencesPanel; + delete _searchPanel; _accountPanel = new AccountPanel(_kiss, this); if (year != -1) _accountPanel->ShowMonth(month, year); _preferencesPanel = new PreferencesPanel(_kiss, this); + _searchPanel = new SearchPanel(_kiss, this); if (account) { @@ -192,7 +209,12 @@ void wxUI::ShowPanel(wxPanel* panel) _preferencesPanel->OnShow(event); panel = _preferencesPanel; } - + if (search) + { + _searchPanel->OnShow(event); + panel = _searchPanel; + } + _needReload = false; } @@ -221,8 +243,12 @@ void wxUI::KillMe() if (_preferencesPanel) delete _preferencesPanel; + if (_searchPanel) + delete _searchPanel; + _accountPanel = NULL; _preferencesPanel = NULL; + _searchPanel = NULL; } void wxUI::NeedReload() diff --git a/src/view/wxUI.h b/src/view/wxUI.h index e33ab4e..06ee60d 100644 --- a/src/view/wxUI.h +++ b/src/view/wxUI.h @@ -26,6 +26,7 @@ along with KissCount. If not, see . #include "PreferencesPanel.h" #include "UsersDialog.h" #include "GenerateDialog.h" +#include "SearchPanel.h" #include class KissCount; @@ -47,6 +48,7 @@ class wxUI: public wxFrame void LoadUser(); void ShowAccount(); + void ShowSearch(); void ShowPreferences(); void GenerateMonth(int month, int year); @@ -61,6 +63,7 @@ class wxUI: public wxFrame KissCount *_kiss; wxBoxSizer *_hbox; AccountPanel *_accountPanel; + SearchPanel *_searchPanel; PreferencesPanel *_preferencesPanel; wxPanel *_curPanel; wxLocale *_locale;