1
0
Disbranĉigi 0

Add DrawRadioButton()

This commit is contained in:
Jaidyn Ann 2022-06-12 19:42:01 -05:00
parent d0a47a5bec
commit 1b491b0a35
2 changed files with 29 additions and 0 deletions

View File

@ -16,8 +16,11 @@ ImageControlLook::ImageControlLook(image_id id)
{ {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
fButton[i].fill(NULL); fButton[i].fill(NULL);
fCheckBox_Checked.fill(NULL); fCheckBox_Checked.fill(NULL);
fCheckBox_Unchecked.fill(NULL); fCheckBox_Unchecked.fill(NULL);
fRadioButton_Checked.fill(NULL);
fRadioButton_Unchecked.fill(NULL);
fSliderThumb.fill(NULL); fSliderThumb.fill(NULL);
fSliderTriangle.fill(NULL); fSliderTriangle.fill(NULL);
@ -111,6 +114,21 @@ ImageControlLook::DrawCheckBox(BView* view, BRect& rect, const BRect& updateRect
} }
void
ImageControlLook::DrawRadioButton(BView* view, BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags)
{
bool drawn = false;
if (((BControl*)view)->Value() == B_CONTROL_ON)
drawn = _DrawImage("RadioButton-Checked", _FlagsToState(flags & ~B_ACTIVATED), view, rect);
else
drawn = _DrawImage("RadioButton-Unchecked", _FlagsToState(flags), view, rect);
if (!drawn)
HaikuControlLook::DrawRadioButton(view, rect, updateRect, base, flags);
}
void void
ImageControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect, ImageControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags, orientation orientation) const rgb_color& base, uint32 flags, orientation orientation)
@ -216,6 +234,10 @@ ImageControlLook::_Image(const char* type, uint32 state, uint32 side)
nosideList = &fCheckBox_Unchecked; nosideList = &fCheckBox_Unchecked;
else if (strcmp(type, "CheckBox-Checked") == 0) else if (strcmp(type, "CheckBox-Checked") == 0)
nosideList = &fCheckBox_Checked; nosideList = &fCheckBox_Checked;
else if (strcmp(type, "RadioButton-Unchecked") == 0)
nosideList = &fRadioButton_Unchecked;
else if (strcmp(type, "RadioButton-Checked") == 0)
nosideList = &fRadioButton_Checked;
else if (strcmp(type, "SliderThumb") == 0) else if (strcmp(type, "SliderThumb") == 0)
nosideList = &fSliderThumb; nosideList = &fSliderThumb;
else if (strcmp(type, "SliderTriangle") == 0) else if (strcmp(type, "SliderTriangle") == 0)

View File

@ -102,6 +102,11 @@ public:
const rgb_color& base, const rgb_color& base,
uint32 flags = 0); uint32 flags = 0);
virtual void DrawRadioButton(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 flags = 0);
virtual void DrawSliderThumb(BView* view, BRect& rect, virtual void DrawSliderThumb(BView* view, BRect& rect,
const BRect& updateRect, const BRect& updateRect,
const rgb_color& base, uint32 flags, const rgb_color& base, uint32 flags,
@ -135,6 +140,8 @@ private:
SidedImages fButton; SidedImages fButton;
UnsidedImages fCheckBox_Checked; UnsidedImages fCheckBox_Checked;
UnsidedImages fCheckBox_Unchecked; UnsidedImages fCheckBox_Unchecked;
UnsidedImages fRadioButton_Checked;
UnsidedImages fRadioButton_Unchecked;
UnsidedImages fSliderThumb; UnsidedImages fSliderThumb;
UnsidedImages fSliderTriangle; UnsidedImages fSliderTriangle;
}; };