Fix a bug with
This commit is contained in:
@@ -201,12 +201,17 @@ void PreferencesPanel::InitAccounts(User* user)
|
||||
_categoriesGrid->SetCellBackgroundColour(row, i, color); \
|
||||
}
|
||||
|
||||
#define SET_ROW_FONT(row, font) for(int i=0; i<NUMBER_COLS_CATEGORY; i++) \
|
||||
{ \
|
||||
_categoriesGrid->SetCellFont(row, i, font); \
|
||||
}
|
||||
|
||||
void PreferencesPanel::InitCategories(User* user)
|
||||
{
|
||||
std::vector<Category>::iterator it;
|
||||
int curLine = 0;
|
||||
DEFAULT_FONT(font);
|
||||
|
||||
|
||||
_categoriesGrid->CreateGrid(0, NUMBER_COLS_CATEGORY);
|
||||
_categoriesGrid->SetRowLabelSize(0);
|
||||
_categoriesGrid->SetDefaultCellFont(font);
|
||||
@@ -228,9 +233,20 @@ void PreferencesPanel::InitCategories(User* user)
|
||||
_categoriesGrid->SetCellEditor(curLine, CATEGORY_DELETE, new wxGridCellBoolEditor ());
|
||||
}
|
||||
|
||||
_categoriesGrid->SetCellRenderer(curLine, CATEGORY_COLOR, new wxGridCellButtonRenderer (wxT("...")));
|
||||
_categoriesGrid->SetCellRenderer(curLine, CATEGORY_FONT, new wxGridCellButtonRenderer (wxT("...")));
|
||||
_categoriesGrid->SetCellEditor(curLine, CATEGORY_COLOR, new wxGridCellButtonEditor (wxT("...")));
|
||||
_categoriesGrid->SetCellEditor(curLine, CATEGORY_FONT, new wxGridCellButtonEditor (wxT("...")));
|
||||
|
||||
_categoriesGrid->SetCellAlignment(curLine, CATEGORY_COLOR, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
||||
_categoriesGrid->SetCellAlignment(curLine, CATEGORY_FONT, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
||||
_categoriesGrid->SetCellAlignment(curLine, CATEGORY_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
||||
|
||||
if (it->font.Length())
|
||||
{
|
||||
wxFont font = user->GetCategoryFont(it->id);
|
||||
SET_ROW_FONT(curLine, font);
|
||||
}
|
||||
}
|
||||
|
||||
_categoriesGrid->SetReadOnly(0, CATEGORY_NAME, true);
|
||||
@@ -437,6 +453,46 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
|
||||
|
||||
inModification = true;
|
||||
|
||||
if (event.GetCol() == CATEGORY_COLOR)
|
||||
{
|
||||
wxColourData color;
|
||||
color.SetColour(wxColor(user->_categories[row].color));
|
||||
wxColourDialog dial(this, &color);
|
||||
|
||||
if (dial.ShowModal() == wxID_OK)
|
||||
{
|
||||
user->_categories[row].color = dial.GetColourData().GetColour();
|
||||
_kiss->UpdateCategory(user->_categories[row]);
|
||||
|
||||
SET_ROW_COLOR(row, user->_categories[row].color);
|
||||
_wxUI->NeedReload();
|
||||
}
|
||||
|
||||
inModification = false ;
|
||||
return ;
|
||||
}
|
||||
|
||||
if (event.GetCol() == CATEGORY_FONT)
|
||||
{
|
||||
wxFontData font;
|
||||
font.SetInitialFont(_kiss->ExtractFont(user->_categories[row].font));
|
||||
wxFontDialog dial(this, font);
|
||||
|
||||
if (dial.ShowModal() == wxID_OK)
|
||||
{
|
||||
font = dial.GetFontData();
|
||||
|
||||
user->_categories[row].font = _kiss->CompactFont(font.GetChosenFont());
|
||||
_kiss->UpdateCategory(user->_categories[row]);
|
||||
|
||||
SET_ROW_FONT(row, font.GetChosenFont());
|
||||
_wxUI->NeedReload();
|
||||
}
|
||||
|
||||
inModification = false ;
|
||||
return ;
|
||||
}
|
||||
|
||||
value = _categoriesGrid->GetCellValue(row, CATEGORY_NAME);
|
||||
if (value.Length())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user