From 1b491b0a3513809e93c3bb3b65f6b9116da02b50 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Sun, 12 Jun 2022 19:42:01 -0500 Subject: [PATCH] Add DrawRadioButton() --- ImageControlLook.cpp | 22 ++++++++++++++++++++++ ImageControlLook.h | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/ImageControlLook.cpp b/ImageControlLook.cpp index 68b0776..e263484 100644 --- a/ImageControlLook.cpp +++ b/ImageControlLook.cpp @@ -16,8 +16,11 @@ ImageControlLook::ImageControlLook(image_id id) { for (int i = 0; i < 3; i++) fButton[i].fill(NULL); + fCheckBox_Checked.fill(NULL); fCheckBox_Unchecked.fill(NULL); + fRadioButton_Checked.fill(NULL); + fRadioButton_Unchecked.fill(NULL); fSliderThumb.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 ImageControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base, uint32 flags, orientation orientation) @@ -216,6 +234,10 @@ ImageControlLook::_Image(const char* type, uint32 state, uint32 side) nosideList = &fCheckBox_Unchecked; else if (strcmp(type, "CheckBox-Checked") == 0) 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) nosideList = &fSliderThumb; else if (strcmp(type, "SliderTriangle") == 0) diff --git a/ImageControlLook.h b/ImageControlLook.h index 28efe96..d5bbdaa 100644 --- a/ImageControlLook.h +++ b/ImageControlLook.h @@ -102,6 +102,11 @@ public: const rgb_color& base, 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, const BRect& updateRect, const rgb_color& base, uint32 flags, @@ -135,6 +140,8 @@ private: SidedImages fButton; UnsidedImages fCheckBox_Checked; UnsidedImages fCheckBox_Unchecked; + UnsidedImages fRadioButton_Checked; + UnsidedImages fRadioButton_Unchecked; UnsidedImages fSliderThumb; UnsidedImages fSliderTriangle; };