Don't return a dummy icon when no icon is found for a command

The hotkey editor initially required this, but now that we've using
fully custom renderers they're no longer needed, and the blank icons
didn't work correctly on wxGTK.

Originally committed to SVN as r6490.
This commit is contained in:
Thomas Goyne 2012-02-20 05:41:54 +00:00
parent 113c85bda0
commit ad7d7c2be3
2 changed files with 8 additions and 27 deletions

View file

@ -53,19 +53,8 @@ wxBitmap const& get(std::string const& name, const int size) {
LOG_W("icon/get") << "Icon not found: " << name << " " << size; LOG_W("icon/get") << "Icon not found: " << name << " " << size;
static wxBitmap empty16(16, 16, 1); static wxBitmap bad;
static wxBitmap empty24(24, 24, 1); return bad;
static bool initialized = false;
if (!initialized) {
empty16.SetMask(new wxMask(empty16));
empty24.SetMask(new wxMask(empty24));
initialized = true;
}
if (size != 24)
return empty16;
return empty24;
} }

View file

@ -271,6 +271,7 @@ Interface_Colours::Interface_Colours(wxTreebook *book, Preferences *parent): Opt
class CommandRenderer : public wxDataViewCustomRenderer { class CommandRenderer : public wxDataViewCustomRenderer {
wxArrayString autocomplete; wxArrayString autocomplete;
wxDataViewIconText value; wxDataViewIconText value;
static const int icon_width = 20;
public: public:
CommandRenderer() CommandRenderer()
@ -288,11 +289,8 @@ public:
wxString text = iconText.GetText(); wxString text = iconText.GetText();
// adjust the label rect to take the width of the icon into account // adjust the label rect to take the width of the icon into account
if (iconText.GetIcon().IsOk()) { label_rect.x += icon_width;
int w = iconText.GetIcon().GetWidth() + 4; label_rect.width -= icon_width;
label_rect.x += w;
label_rect.width -= w;
}
wxTextCtrl* ctrl = new wxTextCtrl(parent, -1, text, label_rect.GetPosition(), label_rect.GetSize(), wxTE_PROCESS_ENTER); wxTextCtrl* ctrl = new wxTextCtrl(parent, -1, text, label_rect.GetPosition(), label_rect.GetSize(), wxTE_PROCESS_ENTER);
ctrl->SetInsertionPointEnd(); ctrl->SetInsertionPointEnd();
@ -307,15 +305,11 @@ public:
} }
bool Render(wxRect rect, wxDC *dc, int state) { bool Render(wxRect rect, wxDC *dc, int state) {
int xoffset = 0;
wxIcon const& icon = value.GetIcon(); wxIcon const& icon = value.GetIcon();
if (icon.IsOk()) { if (icon.IsOk())
dc->DrawIcon(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2); dc->DrawIcon(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
xoffset = icon.GetWidth() + 4;
}
RenderText(value.GetText(), xoffset, rect, dc, state); RenderText(value.GetText(), icon_width, rect, dc, state);
return true; return true;
} }
@ -323,9 +317,7 @@ public:
wxSize GetSize() const { wxSize GetSize() const {
if (!value.GetText().empty()) { if (!value.GetText().empty()) {
wxSize size = GetTextExtent(value.GetText()); wxSize size = GetTextExtent(value.GetText());
size.x += icon_width;
if (value.GetIcon().IsOk())
size.x += value.GetIcon().GetWidth() + 4;
return size; return size;
} }
return wxSize(80,20); return wxSize(80,20);