diff --git a/src/view/AccountPanel.cpp b/src/view/AccountPanel.cpp
index 818acbd..bffa20f 100644
--- a/src/view/AccountPanel.cpp
+++ b/src/view/AccountPanel.cpp
@@ -19,7 +19,6 @@ along with KissCount. If not, see .
#include "AccountPanel.h"
-enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, DELETE, CHECKED, NUMBER_COLS_OPS};
enum {ACCOUNT_NUMBER, ACCOUNT_NAME, ACCOUNT_INIT, ACCOUNT_CUR, ACCOUNT_FINAL, NUMBER_COLS_ACCOUNTS};
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};
@@ -44,7 +43,6 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*
wxBoxSizer *vbox2 = new wxBoxSizer(wxVERTICAL);
wxChartPanel* chart ;
int i ;
- DEFAULT_FONT(font);
User* user = _kiss->GetUser();
std::vector::iterator accountIt;
std::vector::iterator categoryIt;
@@ -60,8 +58,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*
wxColour(0xFF, 0x93, 0x0E),
wxColour(0xC5, 0x00, 0x0D),
wxColour(0x00, 0x84, 0xD1)};
- wxBitmap deleteBitmap(wxT(DELETE_ICON));
- wxBitmap checkedBitmap(wxT(CHECKED_ICON));
+ DEFAULT_FONT(font);
SetSizer(hbox);
@@ -104,28 +101,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*
_pie->SetLegend(new Legend(wxBOTTOM, wxCENTER));
- _grid = new GridAccount(this, OPS_GRID_ID);
- _grid->CreateGrid(1, NUMBER_COLS_OPS);
- _grid->SetColLabelSize(0);
- _grid->SetRowLabelSize(0);
-
- _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]);
- _grid->SetCellBackgroundColour(0, i, OWN_CYAN);
- _grid->SetCellFont(0, i, font);
- _grid->SetReadOnly(0, i, true);
- _grid->SetCellAlignment(0, i, wxALIGN_CENTRE, wxALIGN_CENTRE);
- }
- _grid->SetCellRenderer(0, DELETE, new wxGridCellBitmapRenderer(deleteBitmap));
- _grid->SetCellRenderer(0, CHECKED, new wxGridCellBitmapRenderer(checkedBitmap));
-
- font.SetWeight(wxFONTWEIGHT_NORMAL);
+ _grid = new GridAccount(_kiss, this, OPS_GRID_ID);
_accountsGrid = new wxGrid(this, ACCOUNTS_GRID_ID);
_accountsGrid->CreateGrid(0, NUMBER_COLS_ACCOUNTS);
@@ -403,72 +379,11 @@ void AccountPanel::InsertOperation(User* user, Operation* op, int line, bool fix
{
std::vector::iterator it;
int curLine, curWeek, week, i;
- int r, g, b;
- wxColour color;
- if (!op && !user->_accounts.size()) return;
-
- _grid->InsertRows(line, 1);
-
- _grid->SetCellEditor(line, DEBIT, new wxGridCellFloatEditor(-1, 2));
- _grid->SetCellEditor(line, CREDIT, new wxGridCellFloatEditor(-1, 2));
- wxGridCellChoiceEditor* accountEditor = new wxGridCellChoiceEditor(user->GetAccountsNumber(), _accounts, false);
- _grid->SetCellEditor(line, ACCOUNT, accountEditor);
- wxGridCellChoiceEditor* categoryEditor = new wxGridCellChoiceEditor(user->GetCategoriesNumber()-1, _categories+1, false);
- _grid->SetCellEditor(line, CATEGORY, categoryEditor);
+ _grid->InsertOperation(user, op, line, fix, _curMonth, _curYear);
if (fix)
- {
- _fixCosts++;
- _grid->SetCellValue(line, CATEGORY, _("Fix"));
- _grid->SetReadOnly(line, CATEGORY);
- }
-
- if (op)
- {
- _grid->SetCellEditor(line, DATE, new CalendarEditor(op->day, op->month, op->year));
- _grid->SetCellValue(line, DESCRIPTION, op->description);
- _grid->SetCellValue(line, DATE, wxString::Format(wxT("%02d/%02d/%d"), op->day+1, op->month+1, op->year));
- if (op->amount < 0)
- _grid->SetCellValue(line, DEBIT, wxString::Format(wxT("%.2lf"), -op->amount));
- else
- _grid->SetCellValue(line, CREDIT, wxString::Format(wxT("%.2lf"), op->amount));
- _grid->SetCellValue(line, ACCOUNT, user->GetAccountName(op->account));
- if (!fix)
- _grid->SetCellValue(line, CATEGORY, user->GetCategoryName(op->category));
- _grid->SetCellRenderer(line, DELETE, new wxGridCellBoolRenderer ());
- _grid->SetCellEditor(line, DELETE, new wxGridCellBoolEditor ());
- _grid->SetCellRenderer(line, CHECKED, new wxGridCellBoolRenderer ());
- _grid->SetCellEditor(line, CHECKED, new wxGridCellBoolEditor ());
-
- color = user->GetCategory(op->category).color;
-
- if (op->checked)
- {
- r = ((color.Red()*1.5) >= 0xFF) ? 0xFF : color.Red()*1.5 ;
- g = ((color.Green()*1.5) >= 0xFF) ? 0xFF : color.Green()*1.5 ;
- b = ((color.Blue()*1.5) >= 0xFF) ? 0xFF : color.Blue()*1.5 ;
- color.Set(r, g, b, color.Alpha());
- _grid->SetCellValue(line, CHECKED, wxT("1"));
- }
-
- SET_ROW_COLOR(line, color);
- }
- else
- {
- _grid->SetCellEditor(line, DATE, new CalendarEditor(0, _curMonth, _curYear));
- if (fix)
- SET_ROW_COLOR(line, OWN_YELLOW)
- else
- SET_ROW_COLOR(line, OWN_GREEN);
- _grid->SetReadOnly(line, CHECKED, true);
- _grid->SetReadOnly(line, DELETE, true);
- }
-
- _grid->SetCellAlignment(line, DEBIT, wxALIGN_RIGHT, wxALIGN_CENTRE);
- _grid->SetCellAlignment(line, CREDIT, wxALIGN_RIGHT, wxALIGN_CENTRE);
- _grid->SetCellAlignment(line, DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
- _grid->SetCellAlignment(line, CHECKED, wxALIGN_CENTRE, wxALIGN_CENTRE);
+ _fixCosts++;
if (op)
{
@@ -491,8 +406,6 @@ void AccountPanel::InsertOperation(User* user, Operation* op, int line, bool fix
}
}
- _grid->Layout();
- _grid->SetMinSize(_grid->GetMinSize());
_wxUI->Layout();
}
diff --git a/src/view/GridAccount.h b/src/view/GridAccount.h
index 6b4d85a..61671b3 100644
--- a/src/view/GridAccount.h
+++ b/src/view/GridAccount.h
@@ -24,38 +24,29 @@ along with KissCount. If not, see .
#include
#include
#include "AccountPanel.h"
+#include
+#include
+
+class KissCount;
+
+enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, DELETE, CHECKED, NUMBER_COLS_OPS};
class GridAccount : public wxGrid
{
public:
- GridAccount(wxWindow *parent, wxWindowID id) : wxGrid(parent, id),
- _fixCosts(0), _week1(0), _week2(0), _week3(0), _week4(0)
- {}
+ GridAccount(KissCount* kiss, wxWindow *parent, wxWindowID id);
+ ~GridAccount();
- wxPen GetColGridLinePen (int col) {return wxPen(*wxBLACK, 1, wxSOLID);}
- wxPen GetRowGridLinePen (int row) {
- if (row == 0 || row == _fixCosts ||
- row == _week1 ||
- row == _week2 ||
- row == _week3 ||
- row == _week4)
- return wxPen(*wxBLACK, 1, wxSOLID);
-
- return GetCellBackgroundColour(row, 0);
- }
+ wxPen GetColGridLinePen (int col);
+ wxPen GetRowGridLinePen (int row);
+ void SetWeek(int week, int line);
+ void InsertOperation(User* user, Operation* op, int line, bool fix, int curMonth, int curYear);
- void SetWeek(int week, int line) {
- switch (week) {
- case 1: _week1 = line; break;
- case 2: _week2 = line; break;
- case 3: _week3 = line; break;
- case 4: _week4 = line; break;
- }
- }
int _fixCosts;
int _week1, _week2, _week3, _week4;
-
private:
- std::list _col;
+ KissCount* _kiss;
+ wxString* _categories, *_accounts;
+
};
#endif