wip
This commit is contained in:
@@ -5,10 +5,14 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
|
||||
{
|
||||
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxChartPanel* chart ;
|
||||
|
||||
SetSizer(hbox);
|
||||
|
||||
_pie = new PiePlot();
|
||||
_grid.CreateGrid(10, 7);
|
||||
_grid.SetColLabelSize(0);
|
||||
_grid.SetRowLabelSize(0);
|
||||
//_grid.EnableGridLines(false);
|
||||
|
||||
chart = new wxChartPanel(this);
|
||||
chart->SetChart(new Chart(_pie, _("Cost repartition")));
|
||||
@@ -16,6 +20,93 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
|
||||
hbox->Add(&_grid, 0);
|
||||
hbox->Add(chart, 0);
|
||||
|
||||
ChangeUser();
|
||||
|
||||
Fit();
|
||||
SetMinSize(GetSize());
|
||||
}
|
||||
|
||||
void AccountPanel::ChangeUser()
|
||||
{
|
||||
User* user = _kiss->GetUser();
|
||||
int curYear;
|
||||
std::map<unsigned int, std::map<unsigned int, std::list<operation> >* >::iterator it;
|
||||
wxDateTime curDate;
|
||||
|
||||
curDate.SetToCurrent();
|
||||
for(it = user->_operations.begin(); it != user->_operations.end(); it++)
|
||||
{
|
||||
if ((int)it->first <= curDate.GetYear())
|
||||
curYear = it->first;
|
||||
_tree.AddRoot(wxString::Format(wxT("%d"), it->first));
|
||||
}
|
||||
|
||||
LoadYear(curYear);
|
||||
}
|
||||
|
||||
void AccountPanel::LoadYear(int year)
|
||||
{
|
||||
User* user = _kiss->GetUser();
|
||||
int curMonth = -1;
|
||||
std::map<unsigned int, std::list<operation> >::iterator it;
|
||||
wxDateTime curDate;
|
||||
wxTreeItemId parentNode, curMonthNode;
|
||||
|
||||
if (user->_operations[year] != NULL)
|
||||
{
|
||||
ShowMonth(year, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
_kiss->LoadYear(year);
|
||||
|
||||
curDate.SetToCurrent();
|
||||
parentNode = _tree.GetSelection();
|
||||
|
||||
for (it = user->_operations[year]->begin(); it != user->_operations[year]->end(); it++)
|
||||
{
|
||||
if (year == curDate.GetYear() && (int)it->first <= curDate.GetMonth())
|
||||
{
|
||||
curMonth = it->first;
|
||||
curMonthNode = _tree.AppendItem(parentNode, months[it->first]);
|
||||
}
|
||||
else if(curMonth == -1)
|
||||
{
|
||||
curMonthNode = _tree.AppendItem(parentNode, months[it->first]);
|
||||
curMonth++;
|
||||
}
|
||||
else
|
||||
_tree.AppendItem(parentNode, months[it->first]);
|
||||
}
|
||||
|
||||
_tree.Expand(parentNode);
|
||||
_tree.SelectItem(curMonthNode, true);
|
||||
|
||||
ShowMonth(year, curMonth);
|
||||
}
|
||||
|
||||
void AccountPanel::ShowMonth(int year, int month)
|
||||
{
|
||||
std::list<operation> operations;
|
||||
User* user = _kiss->GetUser();
|
||||
|
||||
_wxUI->SetTitle(user->_name + _(" - ") + months[month]);
|
||||
|
||||
// Operations are ordered
|
||||
operations = (*user->_operations[year])[month];
|
||||
|
||||
_grid.CreateGrid(10, 7);
|
||||
// Creating headers
|
||||
_grid.SetColSize (0, _grid.GetColSize(0)*4);
|
||||
// SetCellBackgroundColour (int row, int col, const wxColour &colour);
|
||||
// SetCellFont (int row, int col, const wxFont &font);
|
||||
// SetCellValue (int row, int col, const wxString &s);
|
||||
// GetColSize (int col) const ;
|
||||
// SetColSize (int col, int width);
|
||||
// AppendRows (int numRows=1, bool updateLabels=true);
|
||||
// InsertRows (int pos=0, int numRows=1, bool updateLabels=true);
|
||||
// SetReadOnly(row, col, bool)
|
||||
Fit();
|
||||
SetMinSize(GetSize());
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <controller/KissCount.h>
|
||||
#include "wxUI.h"
|
||||
#include <model/model.h>
|
||||
#include "GridAccount.h"
|
||||
|
||||
class wxUI;
|
||||
class KissCount;
|
||||
@@ -16,14 +18,16 @@ class KissCount;
|
||||
class AccountPanel: public wxPanel
|
||||
{
|
||||
public:
|
||||
|
||||
AccountPanel(KissCount* kiss, wxUI *parent);
|
||||
void ChangeUser();
|
||||
void LoadYear(int year);
|
||||
void ShowMonth(int year, int month);
|
||||
|
||||
private:
|
||||
KissCount* _kiss;
|
||||
wxUI* _wxUI;
|
||||
wxTreeCtrl _tree;
|
||||
wxGrid _grid;
|
||||
GridAccount _grid;
|
||||
PiePlot* _pie;
|
||||
};
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : wxDialog(&(*parent), -
|
||||
Center();
|
||||
SetSizer(vbox);
|
||||
|
||||
_users->SetFocus();
|
||||
Layout();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ BEGIN_EVENT_TABLE(wxUI, wxFrame)
|
||||
EVT_MENU(ID_About, wxUI::OnAbout)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxString months[12] = {_("january"), _("february"), _("march"), _("april"), _("may"), _("june"), _("july"), _("august"), _("september"), _("october"), _("november"), _("december")} ;
|
||||
|
||||
wxUI::wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
: wxFrame(NULL, -1, title, pos, size), _kiss(kiss)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
class KissCount;
|
||||
class AccountPanel;
|
||||
|
||||
extern wxString months[12];
|
||||
|
||||
class wxUI: public wxFrame
|
||||
{
|
||||
public:
|
||||
@@ -22,6 +24,7 @@ public:
|
||||
|
||||
void ChangeUser();
|
||||
void LoadUser();
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user