This commit is contained in:
2010-05-24 20:14:15 +02:00
parent 22cef5fe16
commit f73c80fc6a
12 changed files with 129 additions and 84 deletions

View File

@@ -6,17 +6,42 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
{
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
wxChartPanel* chart ;
double data[] = {1.0, 2.0, 3.0} ;
wxString cats[] = {_("cat1"), _("cat2"), _("cat3")};
wxColour colours[] = {OWN_CYAN, OWN_YELLOW, OWN_GREEN} ;
double value;
SetSizer(hbox);
_pie = new PiePlot();
CategorySimpleDataset* set = new CategorySimpleDataset(cats, 3);
value = 1.0;
//set->AddSerie(new CategorySerie(_("cat1"), &value, 1)) ;
set->AddSerie(_("série 1"), data, 3);
// value = 2.0;
// set->AddSerie(new CategorySerie(_("cat2"), &value, 1)) ;
// value = 3.0;
// set->AddSerie(new CategorySerie(_("cat3"), &value, 1)) ;
// set->SetRenderer(new XYLineRenderer());
// set serie names to be displayed on legend
//dataset->SetSerieName(0, wxT("Serie 0"));
//dataset->SetSerieName(1, wxT("Serie 1"));
_pie->SetDataset(set);
_pie->SetColorScheme(new ColorScheme(colours, 3));
// set legend
_pie->SetLegend(new Legend(wxCENTER, wxTOP));
_grid = new GridAccount(this, -1);
_grid->CreateGrid(1, NUMBER_COLS);
_grid->SetColLabelSize(0);
_grid->SetRowLabelSize(0);
chart = new wxChartPanel(this);
chart->SetChart(new Chart(_pie, _("Cost repartition")));
chart->Fit();
chart->Layout();
chart->SetMinSize(// chart->GetSize()
wxSize(200,200));
hbox->Add(&_tree, 0);
hbox->Add(_grid, 0);
hbox->Add(chart, 0);
@@ -30,7 +55,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
void AccountPanel::ChangeUser()
{
User* user = _kiss->GetUser();
int curYear;
int curYear = -1;
std::map<unsigned int, std::map<unsigned int, std::list<operation> >* >::iterator it;
wxDateTime curDate;
@@ -42,7 +67,8 @@ void AccountPanel::ChangeUser()
_tree.AddRoot(wxString::Format(wxT("%d"), it->first));
}
LoadYear(curYear);
if (curYear != -1)
LoadYear(curYear);
}
void AccountPanel::LoadYear(int year)
@@ -99,9 +125,10 @@ void AccountPanel::ShowMonth(int year, int month)
int curLine = 0;
User* user = _kiss->GetUser();
wxFont font(DEFAULT_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, DEFAULT_FONT);
std::list<wxString>::iterator categoryIt;
wxGridCellChoiceEditor* categoryEditor;
wxString* categories;
std::map<wxString, wxString>::iterator categoryIt;
std::map<wxString, Account>::iterator accountIt;
wxGridCellChoiceEditor* categoryEditor, *accountEditor;
wxString* categories, *accounts;
int i;
_wxUI->SetTitle(user->_name + _(" - ") + months[month]);
@@ -132,15 +159,21 @@ void AccountPanel::ShowMonth(int year, int month)
// SetReadOnly(row, col, bool)
categories = new wxString[user->_preferences._categories.size()+1];
categories[0] = _("unknown");
categories[0] = _("Unknown");
for (i=1,
categoryIt = user->_preferences._categories.begin();
categoryIt != user->_preferences._categories.end();
categoryIt++,
i++)
categories[i] = *categoryIt;
categoryEditor = new wxGridCellChoiceEditor(user->_preferences._categories.size()+1, categories, false);
categoryIt++, i++)
categories[i] = user->_preferences._categories[categoryIt->first];
accounts = new wxString[user->_accounts.size()+1];
accounts[0] = _("Unknown");
for (i=1,
accountIt = user->_accounts.begin();
accountIt != user->_accounts.end();
accountIt++, i++)
accounts[i] = user->_accounts[accountIt->first].name;
it = operations.begin();
@@ -174,7 +207,10 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellNumberEditor());
categoryEditor = new wxGridCellChoiceEditor(user->_preferences._categories.size()+1, categories, false);
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
_grid->SetCellValue(curLine, ACCOUNT, it->account);
_grid->SetCellValue(curLine, CATEGORY, user->GetCategoryName(it->category));
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, accounts, false);
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
_grid->SetCellValue(curLine, ACCOUNT, user->GetAccountName(it->account));
it++;
}
@@ -185,6 +221,8 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
_grid->SetCellEditor(curLine, DEBIT, new wxGridCellNumberEditor());
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellNumberEditor());
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, accounts, false);
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
_grid->_fixCosts = ++fixCosts;
@@ -204,7 +242,10 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
_grid->SetCellValue(curLine, CATEGORY, it->category);
categoryEditor = new wxGridCellChoiceEditor(user->_preferences._categories.size()+1, categories, false);
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
_grid->SetCellValue(curLine, ACCOUNT, it->account);
_grid->SetCellValue(curLine, CATEGORY, user->GetCategoryName(it->category));
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, accounts, false);
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
_grid->SetCellValue(curLine, ACCOUNT, user->GetAccountName(it->account));
it++;
}
@@ -215,8 +256,14 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
_grid->SetCellEditor(curLine, DEBIT, new wxGridCellNumberEditor());
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellNumberEditor());
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, accounts, false);
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
delete[] categories;
delete[] accounts;
_grid->AutoSizeColumn(CATEGORY, false);
_grid->AutoSizeColumn(ACCOUNT, false);
Fit();
SetMinSize(GetSize());

View File

@@ -20,6 +20,7 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
#include "wxUI.h"
#include <model/model.h>
#include "GridAccount.h"
#include <wx/category/categorysimpledataset.h>
class wxUI;
class KissCount;