LibGUI: Make class_name() public so you can always call it.

I found myself having to cast to GWidget* all the time when writing some
generic debugging code that just wanted to dump widget info.
This commit is contained in:
Andreas Kling 2019-03-16 12:57:04 +01:00
parent 955a0ff477
commit eb610b309e
Notes: sideshowbarker 2024-07-19 15:01:55 +09:00
11 changed files with 22 additions and 13 deletions

View file

@ -23,6 +23,8 @@ public:
void set_button_style(GButtonStyle style) { m_button_style = style; }
GButtonStyle button_style() const { return m_button_style; }
virtual const char* class_name() const override { return "GButton"; }
private:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
@ -31,8 +33,6 @@ private:
virtual void enter_event(GEvent&) override;
virtual void leave_event(GEvent&) override;
virtual const char* class_name() const override { return "GButton"; }
String m_caption;
RetainPtr<GraphicsBitmap> m_icon;
GButtonStyle m_button_style { GButtonStyle::Normal };

View file

@ -17,13 +17,14 @@ public:
Function<void(GCheckBox&, bool)> on_change;
virtual const char* class_name() const override { return "GCheckBox"; }
private:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual void keydown_event(GKeyEvent&) override;
virtual const char* class_name() const override { return "GCheckBox"; }
virtual bool accepts_focus() const override { return true; }
String m_caption;

View file

@ -5,6 +5,7 @@ public:
GFilePicker();
virtual ~GFilePicker() override;
private:
virtual const char* class_name() const override { return "GFilePicker"; }
private:
};

View file

@ -22,11 +22,11 @@ public:
TextAlignment text_alignment() const { return m_text_alignment; }
void set_text_alignment(TextAlignment text_alignment) { m_text_alignment = text_alignment; }
virtual const char* class_name() const override { return "GLabel"; }
private:
virtual void paint_event(GPaintEvent&) override;
virtual const char* class_name() const override { return "GLabel"; }
String m_text;
RetainPtr<GraphicsBitmap> m_icon;
TextAlignment m_text_alignment { TextAlignment::Center };

View file

@ -10,10 +10,11 @@ public:
void add_item(String&&);
int selected_index() const { return m_selected_index; }
virtual const char* class_name() const override { return "GListBox"; }
private:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual const char* class_name() const override { return "GListBox"; }
virtual bool accepts_focus() const override { return true; }
Rect item_rect(int index) const;

View file

@ -24,12 +24,13 @@ public:
Function<void(int)> on_change;
virtual const char* class_name() const override { return "GScrollBar"; }
private:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual const char* class_name() const override { return "GScrollBar"; }
int button_size() const { return orientation() == Orientation::Vertical ? width() : height(); }
Rect up_button_rect() const;

View file

@ -10,12 +10,12 @@ public:
GWidget* active_widget() const { return m_active_widget; }
void set_active_widget(GWidget*);
virtual const char* class_name() const override { return "GStackWidget"; }
protected:
virtual void child_event(GChildEvent&) override;
virtual void resize_event(GResizeEvent&) override;
private:
virtual const char* class_name() const override { return "GStackWidget"; }
GWidget* m_active_widget { nullptr };
};

View file

@ -12,8 +12,9 @@ public:
String text() const;
void set_text(String&&);
private:
virtual const char* class_name() const override { return "GStatusBar"; }
private:
virtual void paint_event(GPaintEvent&) override;
GLabel* m_label { nullptr };

View file

@ -14,8 +14,9 @@ public:
Function<void(GTextBox&)> on_return_pressed;
Function<void(GTextBox&)> on_change;
private:
virtual const char* class_name() const override { return "GTextBox"; }
private:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void keydown_event(GKeyEvent&) override;

View file

@ -100,6 +100,8 @@ public:
Function<void(GTextEditor&)> on_return_pressed;
virtual const char* class_name() const override { return "GTextEditor"; }
private:
virtual void paint_event(GPaintEvent&) override;
virtual void resize_event(GResizeEvent&) override;

View file

@ -12,8 +12,9 @@ public:
void add_action(Retained<GAction>&&);
void add_separator();
private:
virtual const char* class_name() const override { return "GToolBar"; }
private:
virtual void paint_event(GPaintEvent&) override;
struct Item {