mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:32:44 +00:00 
			
		
		
		
	 ca538b6cee
			
		
	
	
		ca538b6cee
		
	
	
	
	
		
			
			You can now register a GWidget subclass with REGISTER_GWIDGET(class) and it will be available for factory construction through the new GWidgetClassRegistration interface. To obtain a GWidgetClassRegistration for a given class name, you call GWidgetClassRegistration::find(class_name). You can also iterate over all the registered classes using GWCR::for_each(callback). This will be very useful for implementing a proper GUI designer, and also in the future for things like script bindings. NOTE: All of the registrations are done in GWidget.cpp at the moment since I ran into trouble with the fricken linker pruning the global constructors this mechanism relies on. :^)
		
			
				
	
	
		
			35 lines
		
	
	
	
		
			899 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			899 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #pragma once
 | |
| 
 | |
| #include <LibGUI/GAbstractButton.h>
 | |
| 
 | |
| class GRadioButton : public GAbstractButton {
 | |
|     C_OBJECT(GRadioButton)
 | |
| public:
 | |
|     virtual ~GRadioButton() override;
 | |
| 
 | |
|     virtual void click() override;
 | |
| 
 | |
| protected:
 | |
|     explicit GRadioButton(GWidget* parent);
 | |
|     explicit GRadioButton(const StringView& text, GWidget* parent);
 | |
|     virtual void paint_event(GPaintEvent&) override;
 | |
| 
 | |
| private:
 | |
|     // These don't make sense for a radio button, so hide them.
 | |
|     using GAbstractButton::auto_repeat_interval;
 | |
|     using GAbstractButton::set_auto_repeat_interval;
 | |
| 
 | |
|     virtual bool is_radio_button() const final { return true; }
 | |
| 
 | |
|     template<typename Callback>
 | |
|     void for_each_in_group(Callback);
 | |
|     static Size circle_size();
 | |
| };
 | |
| 
 | |
| template<>
 | |
| inline bool is<GRadioButton>(const CObject& object)
 | |
| {
 | |
|     if (!is<GWidget>(object))
 | |
|         return false;
 | |
|     return to<GWidget>(object).is_radio_button();
 | |
| }
 |