This commit is contained in:
Grégory Soutadé 2010-07-14 11:15:48 +02:00
parent e4a81539a1
commit 6ca15e23b0
7 changed files with 48 additions and 26 deletions

View File

@ -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; i<NUMBER_COLS_OPS; i++)
{
_grid->SetCellValue(0, i, colsName[i]);

View File

@ -29,16 +29,7 @@ along with KissCount. If not, see <http://www.gnu.org/licenses/>.
#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 <controller/KissCount.h>
#include "wxUI.h"

View File

@ -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();

View File

@ -26,13 +26,7 @@ along with KissCount. If not, see <http://www.gnu.org/licenses/>.
#include <controller/KissCount.h>
#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);

View File

@ -28,7 +28,10 @@ along with KissCount. If not, see <http://www.gnu.org/licenses/>.
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 ||

View File

@ -22,8 +22,8 @@ along with KissCount. If not, see <http://www.gnu.org/licenses/>.
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,6 +209,11 @@ 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()

View File

@ -26,6 +26,7 @@ along with KissCount. If not, see <http://www.gnu.org/licenses/>.
#include "PreferencesPanel.h"
#include "UsersDialog.h"
#include "GenerateDialog.h"
#include "SearchPanel.h"
#include <controller/KissCount.h>
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;