mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Add help text to the card/keyword filter boxes
This commit is contained in:
@@ -32,14 +32,13 @@ protected:
|
||||
|
||||
// ----------------------------------------------------------------------------- : FilterControl
|
||||
|
||||
FilterCtrl::FilterCtrl(wxWindow* parent, int id, String const& placeholder)
|
||||
FilterCtrl::FilterCtrl(wxWindow* parent, int id, String const& placeholder, String const& help_text)
|
||||
: wxTextCtrl(parent, id, _(""), wxDefaultPosition, wxSize(160, -1), wxBORDER_THEME)
|
||||
, changing(false)
|
||||
, placeholder(placeholder)
|
||||
, help_text(help_text)
|
||||
{
|
||||
wxColour bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
SetBackgroundColour(bg);
|
||||
SetCursor(wxCURSOR_IBEAM);
|
||||
clear_button = new HoverButton(this, wxID_ANY, _("btn_clear_filter"), bg, false);
|
||||
clear_button->SetCursor(*wxSTANDARD_CURSOR);
|
||||
onSize();
|
||||
@@ -63,6 +62,7 @@ void FilterCtrl::focusAndSelect() {
|
||||
if (!value.empty()) {
|
||||
SetSelection(-1,-1);
|
||||
}
|
||||
showHelp();
|
||||
}
|
||||
|
||||
void FilterCtrl::update() {
|
||||
@@ -125,16 +125,32 @@ void FilterCtrl::onKillFocus(wxFocusEvent& ev) {
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
void FilterCtrl::onMouseEnter(wxMouseEvent& ev) {
|
||||
showHelp();
|
||||
}
|
||||
void FilterCtrl::onMouseLeave(wxMouseEvent& ev) {
|
||||
showHelp(false);
|
||||
}
|
||||
|
||||
bool FilterCtrl::hasFocus() {
|
||||
wxWindow* focus = wxWindow::FindFocus();
|
||||
return focus == this || focus == clear_button;
|
||||
}
|
||||
|
||||
void FilterCtrl::showHelp(bool show) {
|
||||
wxFrame* frame = dynamic_cast<wxFrame*>(wxGetTopLevelParent(this));
|
||||
if (frame) {
|
||||
frame->DoGiveHelp(help_text, show);
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(FilterCtrl, wxControl)
|
||||
EVT_BUTTON (wxID_ANY, FilterCtrl::onClear)
|
||||
EVT_TEXT (wxID_ANY, FilterCtrl::onChangeEvent)
|
||||
EVT_SIZE (FilterCtrl::onSizeEvent)
|
||||
EVT_SET_FOCUS (FilterCtrl::onSetFocus)
|
||||
EVT_KILL_FOCUS(FilterCtrl::onKillFocus)
|
||||
EVT_ENTER_WINDOW(FilterCtrl::onMouseEnter)
|
||||
EVT_LEAVE_WINDOW(FilterCtrl::onMouseLeave)
|
||||
EVT_CHAR (FilterCtrl::onChar)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
@@ -18,7 +18,7 @@ class HoverButton;
|
||||
/// A search/filter textbox
|
||||
class FilterCtrl : public wxTextCtrl {
|
||||
public:
|
||||
FilterCtrl(wxWindow* parent, int id, String const& placeholder);
|
||||
FilterCtrl(wxWindow* parent, int id, String const& placeholder, String const& help_text);
|
||||
|
||||
/// Set the filter text
|
||||
void setFilter(const String& filter, bool send_event = false);
|
||||
@@ -41,10 +41,12 @@ private:
|
||||
bool changing;
|
||||
String value;
|
||||
String placeholder;
|
||||
String help_text;
|
||||
HoverButton* clear_button;
|
||||
|
||||
void update();
|
||||
bool hasFocus();
|
||||
void showHelp(bool show = true);
|
||||
// wxWidgets appears to have developed an overload allergy
|
||||
void onChangeEvent(wxCommandEvent&);
|
||||
void onClear(wxCommandEvent&);
|
||||
@@ -53,6 +55,7 @@ private:
|
||||
void onSize();
|
||||
void onSetFocus(wxFocusEvent&);
|
||||
void onKillFocus(wxFocusEvent&);
|
||||
void onPaint(wxPaintEvent&);
|
||||
void onMouseEnter(wxMouseEvent&);
|
||||
void onMouseLeave(wxMouseEvent&);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user