@@ -139,4 +139,93 @@ bool DarkBreezeButton::onMotion(const MotionEvent& ev)
139139
140140// --------------------------------------------------------------------------------------------------------------------
141141
142+ DarkBreezeCheckBox::DarkBreezeCheckBox (DarkBreeze* const parent)
143+ : NanoSubWidget(parent),
144+ ButtonEventHandler(this )
145+ {
146+ loadSharedResources ();
147+
148+ constexpr uint size = kSizeButton + kSizePadding * 2 ;
149+ setSize (size, size);
150+
151+ setCheckable (true );
152+ }
153+
154+ DarkBreezeCheckBox::~DarkBreezeCheckBox ()
155+ {
156+ std::free (label);
157+ }
158+
159+ void DarkBreezeCheckBox::setLabel (const char * const label2)
160+ {
161+ std::free (label);
162+ label = label2 != nullptr ? strdup (label2) : nullptr ;
163+
164+ if (label != nullptr && label[0 ] != ' \0 ' )
165+ {
166+ Rectangle<float > bounds;
167+ // fontSize(theme.fontSize);
168+ textBounds (0 , 0 , label, nullptr , bounds);
169+
170+ const uint width = std::max (getWidth (), d_roundToUnsignedInt (bounds.getWidth ()) + kSizePadding * 8 );
171+ const uint height = std::max (getHeight (), d_roundToUnsignedInt (bounds.getHeight ()) + kSizePadding * 2 );
172+ setSize (width, height);
173+ }
174+ }
175+
176+ void DarkBreezeCheckBox::onNanoDisplay ()
177+ {
178+ beginPath ();
179+ roundedRect (kSizePadding * 4 ,
180+ kSizePadding * 4 ,
181+ kSizeButton - kSizePadding * 8 ,
182+ kSizeButton - kSizePadding * 8 ,
183+ kSizeRadius );
184+
185+ d_stdout (" state %d" , getState ());
186+ switch (getState ())
187+ {
188+ case kButtonStateActive :
189+ fillColor (Color::fromHTML (kColorButtonFillActive ));
190+ strokeColor (Color::fromHTML (kColorButtonStrokeActive ));
191+ break ;
192+ case kButtonStateActiveHover :
193+ fillColor (Color::fromHTML (kColorButtonFillActiveHover ));
194+ strokeColor (Color::fromHTML (kColorButtonStrokeActiveHover ));
195+ break ;
196+ case kButtonStateHover :
197+ fillColor (Color::fromHTML (kColorButtonFillHover ));
198+ strokeColor (Color::fromHTML (kColorButtonStrokeHover ));
199+ break ;
200+ case kButtonStateDefault :
201+ fillColor (Color::fromHTML (kColorButtonFillDefault ));
202+ strokeColor (Color::fromHTML (kColorButtonStrokeDefault ));
203+ break ;
204+ }
205+
206+ fill ();
207+ strokeWidth (1 );
208+ stroke ();
209+
210+ if (label != nullptr && label[0 ] != ' \0 ' )
211+ {
212+ fillColor (Color::fromHTML (kColorText ));
213+ // fontSize(theme.fontSize);
214+ textAlign (ALIGN_LEFT|ALIGN_MIDDLE);
215+ text (kSizeButton + kSizePadding , getHeight () / 2 , label, nullptr );
216+ }
217+ }
218+
219+ bool DarkBreezeCheckBox::onMouse (const MouseEvent& ev)
220+ {
221+ return mouseEvent (ev);
222+ }
223+
224+ bool DarkBreezeCheckBox::onMotion (const MotionEvent& ev)
225+ {
226+ return motionEvent (ev);
227+ }
228+
229+ // --------------------------------------------------------------------------------------------------------------------
230+
142231END_NAMESPACE_DGL
0 commit comments