mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Multiple choice choices can be drawn as radio buttons instead of check boxes
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@463 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -214,3 +214,24 @@ void draw_checkbox(Window* win, DC& dc, const wxRect& rect, bool checked, bool e
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
|
||||
void draw_radiobox(Window* win, DC& dc, const wxRect& rect, bool checked, bool enabled) {
|
||||
#if wxUSE_UXTHEME && defined(__WXMSW__)
|
||||
// TODO: Windows version?
|
||||
#endif
|
||||
// portable version
|
||||
#if 1
|
||||
// circle drawing on windows looks absolutely horrible
|
||||
// so use rounded rectangles instead
|
||||
dc.SetPen(wxSystemSettings::GetColour(enabled ? wxSYS_COLOUR_WINDOWTEXT: wxSYS_COLOUR_GRAYTEXT));
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
//dc.DrawEllipse(rect.x, rect.y, rect.width, rect.height);
|
||||
dc.DrawRoundedRectangle(rect.x, rect.y, rect.width, rect.height, rect.width*0.5-1);
|
||||
if (checked) {
|
||||
dc.SetBrush(wxSystemSettings::GetColour(enabled ? wxSYS_COLOUR_WINDOWTEXT: wxSYS_COLOUR_GRAYTEXT));
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
//dc.DrawEllipse(rect.x+2,rect.y+2,rect.width-4,rect.height-4);
|
||||
dc.DrawRoundedRectangle(rect.x+3, rect.y+3, rect.width-6, rect.height-6, rect.width*0.5-4);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -63,5 +63,8 @@ void draw_drop_down_arrow(Window* win, DC& dc, const wxRect& rect, bool active);
|
||||
/// Draws a check box
|
||||
void draw_checkbox(Window* win, DC& dc, const wxRect& rect, bool checked, bool enabled = true);
|
||||
|
||||
/// Draws a radio button
|
||||
void draw_radiobox(Window* win, DC& dc, const wxRect& rect, bool checked, bool enabled = true);
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
|
||||
@@ -45,9 +45,11 @@ void DropDownMultipleChoiceList::select(size_t item) {
|
||||
void DropDownMultipleChoiceList::drawIcon(DC& dc, int x, int y, size_t item, bool selected) const {
|
||||
// is this item active/checked?
|
||||
bool active = false;
|
||||
bool radio = false;
|
||||
if (!isFieldDefault(item)) {
|
||||
ChoiceField::ChoiceP choice = getChoice(item);
|
||||
active = dynamic_cast<MultipleChoiceValueEditor&>(cve).active[choice->first_id];
|
||||
radio = choice->type == CHOICE_TYPE_RADIO;
|
||||
} else {
|
||||
active = dynamic_cast<MultipleChoiceValueEditor&>(cve).value().value.isDefault();
|
||||
}
|
||||
@@ -56,7 +58,11 @@ void DropDownMultipleChoiceList::drawIcon(DC& dc, int x, int y, size_t item, boo
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.DrawRectangle(x,y,16,16);
|
||||
wxRect rect = RealRect(x+2,y+2,12,12);
|
||||
draw_checkbox(nullptr, dc, rect, active, itemEnabled(item));
|
||||
if (radio) {
|
||||
draw_radiobox(nullptr, dc, rect, active, itemEnabled(item));
|
||||
} else {
|
||||
draw_checkbox(nullptr, dc, rect, active, itemEnabled(item));
|
||||
}
|
||||
// draw icon
|
||||
DropDownChoiceListBase::drawIcon(dc, x + 16, y, item, selected);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user