This commit is contained in:
2010-06-16 19:15:49 +02:00
parent 721a0afc29
commit 936d7a95eb
5 changed files with 51 additions and 24 deletions

View File

@@ -293,7 +293,7 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, DELETE, NUMBER_COLS_O
_grid->AutoSizeColumn(DATE, false);
_grid->AutoSizeColumn(ACCOUNT, false);
_grid->AutoSizeColumn(DELETE, false);
_grid->AutoSizeColumn(VIEW, false);
_grid->AutoSizeColumn(CHECKED, false);
InitAccountsGrid(user, month, year);
@@ -307,6 +307,8 @@ void AccountPanel::InsertOperation(User* user, operation* op, int line, bool fix
{
std::vector<operation>::iterator it;
int curLine, curWeek, week, i;
int r, g, b;
wxColour color;
_grid->InsertRows(line, 1);
@@ -339,10 +341,21 @@ void AccountPanel::InsertOperation(User* user, operation* op, int line, bool fix
_grid->SetCellValue(line, CATEGORY, user->GetCategoryName(op->category));
_grid->SetCellRenderer(line, DELETE, new wxGridCellBoolRenderer ());
_grid->SetCellEditor(line, DELETE, new wxGridCellBoolEditor ());
_grid->SetCellRenderer(line, VIEW, new wxGridCellBoolRenderer ());
_grid->SetCellEditor(line, VIEW, new wxGridCellBoolEditor ());
_grid->SetCellRenderer(line, CHECKED, new wxGridCellBoolRenderer ());
_grid->SetCellEditor(line, CHECKED, new wxGridCellBoolEditor ());
SET_ROW_COLOR(line, user->_preferences._colors[user->GetCategoryName(op->category)]);
color = user->_preferences._colors[user->GetCategoryName(op->category)];
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, _("1"));
}
SET_ROW_COLOR(line, color);
}
else
{
@@ -356,7 +369,7 @@ void AccountPanel::InsertOperation(User* user, operation* op, int line, bool fix
_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, VIEW, wxALIGN_CENTRE, wxALIGN_CENTRE);
_grid->SetCellAlignment(line, CHECKED, wxALIGN_CENTRE, wxALIGN_CENTRE);
if (op)
{
@@ -496,7 +509,7 @@ void AccountPanel::OnOperationModified(wxGridEvent& event)
int row = event.GetRow()-1;
int col = event.GetCol();
struct operation new_op, cur_op;
int op_complete = 5, i;
int op_complete = 6, i;
wxString value ;
wxDateTime date;
bool need_insertion = false, fix_op=false;
@@ -560,28 +573,36 @@ void AccountPanel::OnOperationModified(wxGridEvent& event)
op_complete--;
}
if (col == VIEW || col == CATEGORY)
value = _grid->GetCellValue(event.GetRow(), CHECKED);
if (value != _(""))
{
color = _grid->GetCellBackgroundColour(event.GetRow(), col);
new_op.checked = (value == _("1"));
op_complete--;
}
if (_grid->GetCellValue(event.GetRow(), col) == _("1"))
if (col == CHECKED || col == CATEGORY)
{
color = user->_preferences._colors[user->GetCategoryName(new_op.category)];
if (new_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());
}
else
{
color = user->_preferences._colors[user->GetCategoryName(new_op.category)];
}
SET_ROW_COLOR(event.GetRow(), color);
}
inModification = false;
if (col == VIEW)
return ;
if (col == DELETE)
{
wxMessageDialog dialog(_wxUI, _("Are you sure want to delete : \n")+new_op.description, _("KissCount"), wxYES_NO);
if (dialog.ShowModal() == wxID_NO)
{
_grid->SetCellValue(event.GetRow(), event.GetCol(), _("0"));
return;
}
}
// Penser au fix implosif

View File

@@ -17,7 +17,7 @@
#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);
enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, DELETE, VIEW, NUMBER_COLS_OPS};
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};