GridAccount code moved
This commit is contained in:
parent
6ca15e23b0
commit
2c1c8b7b76
|
@ -19,7 +19,6 @@ along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "AccountPanel.h"
|
#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 {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 {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};
|
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);
|
wxBoxSizer *vbox2 = new wxBoxSizer(wxVERTICAL);
|
||||||
wxChartPanel* chart ;
|
wxChartPanel* chart ;
|
||||||
int i ;
|
int i ;
|
||||||
DEFAULT_FONT(font);
|
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
std::vector<Account>::iterator accountIt;
|
std::vector<Account>::iterator accountIt;
|
||||||
std::vector<Category>::iterator categoryIt;
|
std::vector<Category>::iterator categoryIt;
|
||||||
|
@ -60,8 +58,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*
|
||||||
wxColour(0xFF, 0x93, 0x0E),
|
wxColour(0xFF, 0x93, 0x0E),
|
||||||
wxColour(0xC5, 0x00, 0x0D),
|
wxColour(0xC5, 0x00, 0x0D),
|
||||||
wxColour(0x00, 0x84, 0xD1)};
|
wxColour(0x00, 0x84, 0xD1)};
|
||||||
wxBitmap deleteBitmap(wxT(DELETE_ICON));
|
DEFAULT_FONT(font);
|
||||||
wxBitmap checkedBitmap(wxT(CHECKED_ICON));
|
|
||||||
|
|
||||||
SetSizer(hbox);
|
SetSizer(hbox);
|
||||||
|
|
||||||
|
@ -104,28 +101,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*
|
||||||
|
|
||||||
_pie->SetLegend(new Legend(wxBOTTOM, wxCENTER));
|
_pie->SetLegend(new Legend(wxBOTTOM, wxCENTER));
|
||||||
|
|
||||||
_grid = new GridAccount(this, OPS_GRID_ID);
|
_grid = new GridAccount(_kiss, 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; i<NUMBER_COLS_OPS; i++)
|
|
||||||
{
|
|
||||||
_grid->SetCellValue(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);
|
|
||||||
|
|
||||||
_accountsGrid = new wxGrid(this, ACCOUNTS_GRID_ID);
|
_accountsGrid = new wxGrid(this, ACCOUNTS_GRID_ID);
|
||||||
_accountsGrid->CreateGrid(0, NUMBER_COLS_ACCOUNTS);
|
_accountsGrid->CreateGrid(0, NUMBER_COLS_ACCOUNTS);
|
||||||
|
@ -403,72 +379,11 @@ void AccountPanel::InsertOperation(User* user, Operation* op, int line, bool fix
|
||||||
{
|
{
|
||||||
std::vector<Operation>::iterator it;
|
std::vector<Operation>::iterator it;
|
||||||
int curLine, curWeek, week, i;
|
int curLine, curWeek, week, i;
|
||||||
int r, g, b;
|
|
||||||
wxColour color;
|
|
||||||
|
|
||||||
if (!op && !user->_accounts.size()) return;
|
_grid->InsertOperation(user, op, line, fix, _curMonth, _curYear);
|
||||||
|
|
||||||
_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);
|
|
||||||
|
|
||||||
if (fix)
|
if (fix)
|
||||||
{
|
|
||||||
_fixCosts++;
|
_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);
|
|
||||||
|
|
||||||
if (op)
|
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();
|
_wxUI->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,38 +24,29 @@ along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <wx/grid.h>
|
#include <wx/grid.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "AccountPanel.h"
|
#include "AccountPanel.h"
|
||||||
|
#include <model/model.h>
|
||||||
|
#include <controller/KissCount.h>
|
||||||
|
|
||||||
|
class KissCount;
|
||||||
|
|
||||||
|
enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, DELETE, CHECKED, NUMBER_COLS_OPS};
|
||||||
|
|
||||||
class GridAccount : public wxGrid
|
class GridAccount : public wxGrid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GridAccount(wxWindow *parent, wxWindowID id) : wxGrid(parent, id),
|
GridAccount(KissCount* kiss, wxWindow *parent, wxWindowID id);
|
||||||
_fixCosts(0), _week1(0), _week2(0), _week3(0), _week4(0)
|
~GridAccount();
|
||||||
{}
|
|
||||||
|
|
||||||
wxPen GetColGridLinePen (int col) {return wxPen(*wxBLACK, 1, wxSOLID);}
|
wxPen GetColGridLinePen (int col);
|
||||||
wxPen GetRowGridLinePen (int row) {
|
wxPen GetRowGridLinePen (int row);
|
||||||
if (row == 0 || row == _fixCosts ||
|
void SetWeek(int week, int line);
|
||||||
row == _week1 ||
|
void InsertOperation(User* user, Operation* op, int line, bool fix, int curMonth, int curYear);
|
||||||
row == _week2 ||
|
|
||||||
row == _week3 ||
|
|
||||||
row == _week4)
|
|
||||||
return wxPen(*wxBLACK, 1, wxSOLID);
|
|
||||||
|
|
||||||
return GetCellBackgroundColour(row, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 _fixCosts;
|
||||||
int _week1, _week2, _week3, _week4;
|
int _week1, _week2, _week3, _week4;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<int> _col;
|
KissCount* _kiss;
|
||||||
|
wxString* _categories, *_accounts;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user