summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-25 19:49:28 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-25 19:49:28 +0200
commita599317624fb8428eb64cf719affcdd075f5c9d5 (patch)
tree7669ffd4a1acab1b0caf003443ed470de6fe34ea /Libraries
parentd21a4f7518ced2b49e20b3b2521c80b0afec216d (diff)
downloadserenity-a599317624fb8428eb64cf719affcdd075f5c9d5.zip
LibCore: Introduce a C_OBJECT macro.
This macro goes at the top of every CObject-derived class like so: class SomeClass : public CObject { C_OBJECT(SomeClass) public: ... At the moment, all it does is create an override for the class_name() getter but in the future this will be used to automatically insert member functions into these classes.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibCore/CFile.h3
-rw-r--r--Libraries/LibCore/CHttpJob.h3
-rw-r--r--Libraries/LibCore/CIODevice.h3
-rw-r--r--Libraries/LibCore/CLocalSocket.h1
-rw-r--r--Libraries/LibCore/CNetworkJob.h3
-rw-r--r--Libraries/LibCore/CNotifier.h6
-rw-r--r--Libraries/LibCore/CObject.h11
-rw-r--r--Libraries/LibCore/CSocket.h3
-rw-r--r--Libraries/LibCore/CTCPSocket.h1
-rw-r--r--Libraries/LibCore/CTimer.h3
-rw-r--r--Libraries/LibCore/CoreIPCClient.h1
-rw-r--r--Libraries/LibCore/CoreIPCServer.h11
-rw-r--r--Libraries/LibGUI/GAbstractButton.h2
-rw-r--r--Libraries/LibGUI/GAbstractView.h4
-rw-r--r--Libraries/LibGUI/GButton.h2
-rw-r--r--Libraries/LibGUI/GCheckBox.h3
-rw-r--r--Libraries/LibGUI/GComboBox.h3
-rw-r--r--Libraries/LibGUI/GDialog.h3
-rw-r--r--Libraries/LibGUI/GFilePicker.h5
-rw-r--r--Libraries/LibGUI/GFrame.h3
-rw-r--r--Libraries/LibGUI/GGroupBox.h3
-rw-r--r--Libraries/LibGUI/GInputBox.h3
-rw-r--r--Libraries/LibGUI/GItemView.h3
-rw-r--r--Libraries/LibGUI/GLabel.h3
-rw-r--r--Libraries/LibGUI/GListView.h3
-rw-r--r--Libraries/LibGUI/GMessageBox.h3
-rw-r--r--Libraries/LibGUI/GRadioButton.h3
-rw-r--r--Libraries/LibGUI/GResizeCorner.h3
-rw-r--r--Libraries/LibGUI/GScrollBar.h3
-rw-r--r--Libraries/LibGUI/GScrollableWidget.h3
-rw-r--r--Libraries/LibGUI/GSpinBox.h3
-rw-r--r--Libraries/LibGUI/GStackWidget.h3
-rw-r--r--Libraries/LibGUI/GStatusBar.h3
-rw-r--r--Libraries/LibGUI/GTabWidget.h3
-rw-r--r--Libraries/LibGUI/GTableView.h3
-rw-r--r--Libraries/LibGUI/GTextBox.h3
-rw-r--r--Libraries/LibGUI/GTextEditor.h3
-rw-r--r--Libraries/LibGUI/GToolBar.cpp4
-rw-r--r--Libraries/LibGUI/GToolBar.h3
-rw-r--r--Libraries/LibGUI/GTreeView.h2
-rw-r--r--Libraries/LibGUI/GWidget.h3
-rw-r--r--Libraries/LibGUI/GWindow.h3
42 files changed, 55 insertions, 85 deletions
diff --git a/Libraries/LibCore/CFile.h b/Libraries/LibCore/CFile.h
index 976d5718d9..cabf7abb14 100644
--- a/Libraries/LibCore/CFile.h
+++ b/Libraries/LibCore/CFile.h
@@ -4,6 +4,7 @@
#include <LibCore/CIODevice.h>
class CFile final : public CIODevice {
+ C_OBJECT(CFile)
public:
CFile() {}
explicit CFile(const StringView&);
@@ -20,8 +21,6 @@ public:
};
bool open(int fd, CIODevice::OpenMode, ShouldCloseFileDescription);
- virtual const char* class_name() const override { return "CFile"; }
-
private:
String m_filename;
ShouldCloseFileDescription m_should_close_file_descriptor { ShouldCloseFileDescription::Yes };
diff --git a/Libraries/LibCore/CHttpJob.h b/Libraries/LibCore/CHttpJob.h
index 5b714a7f77..b171119779 100644
--- a/Libraries/LibCore/CHttpJob.h
+++ b/Libraries/LibCore/CHttpJob.h
@@ -7,14 +7,13 @@
class CTCPSocket;
class CHttpJob final : public CNetworkJob {
+ C_OBJECT(CHttpJob)
public:
explicit CHttpJob(const CHttpRequest&);
virtual ~CHttpJob() override;
virtual void start() override;
- virtual const char* class_name() const override { return "CHttpJob"; }
-
private:
void on_socket_connected();
diff --git a/Libraries/LibCore/CIODevice.h b/Libraries/LibCore/CIODevice.h
index 6019ec7d19..1c8dac5831 100644
--- a/Libraries/LibCore/CIODevice.h
+++ b/Libraries/LibCore/CIODevice.h
@@ -5,6 +5,7 @@
#include <LibCore/CObject.h>
class CIODevice : public CObject {
+ C_OBJECT(CIODevice)
public:
enum OpenMode {
NotOpen = 0,
@@ -52,8 +53,6 @@ public:
int printf(const char*, ...);
- virtual const char* class_name() const override { return "CIODevice"; }
-
protected:
explicit CIODevice(CObject* parent = nullptr);
diff --git a/Libraries/LibCore/CLocalSocket.h b/Libraries/LibCore/CLocalSocket.h
index 3845707c93..57078b7126 100644
--- a/Libraries/LibCore/CLocalSocket.h
+++ b/Libraries/LibCore/CLocalSocket.h
@@ -2,6 +2,7 @@
#include <LibCore/CSocket.h>
class CLocalSocket final : public CSocket {
+ C_OBJECT(CLocalSocket)
public:
explicit CLocalSocket(CObject* parent = nullptr);
virtual ~CLocalSocket() override;
diff --git a/Libraries/LibCore/CNetworkJob.h b/Libraries/LibCore/CNetworkJob.h
index b68dba5670..a0638dd46d 100644
--- a/Libraries/LibCore/CNetworkJob.h
+++ b/Libraries/LibCore/CNetworkJob.h
@@ -6,6 +6,7 @@
class CNetworkResponse;
class CNetworkJob : public CObject {
+ C_OBJECT(CNetworkJob)
public:
enum class Error {
None,
@@ -24,8 +25,6 @@ public:
virtual void start() = 0;
- virtual const char* class_name() const override { return "CNetworkJob"; }
-
protected:
CNetworkJob();
void did_finish(NonnullRefPtr<CNetworkResponse>&&);
diff --git a/Libraries/LibCore/CNotifier.h b/Libraries/LibCore/CNotifier.h
index 6464000037..5d9a185c5f 100644
--- a/Libraries/LibCore/CNotifier.h
+++ b/Libraries/LibCore/CNotifier.h
@@ -4,6 +4,7 @@
#include "CObject.h"
class CNotifier : public CObject {
+ C_OBJECT(CNotifier)
public:
enum Event {
None = 0,
@@ -12,7 +13,7 @@ public:
Exceptional = 4,
};
CNotifier(int fd, unsigned event_mask);
- ~CNotifier();
+ virtual ~CNotifier() override;
void set_enabled(bool);
@@ -23,8 +24,7 @@ public:
unsigned event_mask() const { return m_event_mask; }
void set_event_mask(unsigned event_mask) { m_event_mask = event_mask; }
- const char* class_name() const override { return "CNotifier"; }
- void event(CEvent& event) override;
+ void event(CEvent&) override;
private:
int m_fd { -1 };
diff --git a/Libraries/LibCore/CObject.h b/Libraries/LibCore/CObject.h
index d0df0530be..247198c904 100644
--- a/Libraries/LibCore/CObject.h
+++ b/Libraries/LibCore/CObject.h
@@ -11,13 +11,16 @@ class CChildEvent;
class CCustomEvent;
class CTimerEvent;
+#define C_OBJECT(klass) \
+public: \
+ virtual const char* class_name() const override { return #klass; }
+
class CObject : public Weakable<CObject> {
+ // NOTE: No C_OBJECT macro for CObject itself.
public:
- CObject(CObject* parent = nullptr, bool is_widget = false);
virtual ~CObject();
- virtual const char* class_name() const { return "CObject"; }
-
+ virtual const char* class_name() const = 0;
virtual void event(CEvent&);
const String& name() const { return m_name; }
@@ -58,6 +61,8 @@ public:
virtual bool is_window() const { return false; }
protected:
+ CObject(CObject* parent = nullptr, bool is_widget = false);
+
virtual void timer_event(CTimerEvent&);
virtual void child_event(CChildEvent&);
virtual void custom_event(CCustomEvent&);
diff --git a/Libraries/LibCore/CSocket.h b/Libraries/LibCore/CSocket.h
index 6b18894390..29659b458f 100644
--- a/Libraries/LibCore/CSocket.h
+++ b/Libraries/LibCore/CSocket.h
@@ -6,6 +6,7 @@
class CNotifier;
class CSocket : public CIODevice {
+ C_OBJECT(CSocket)
public:
enum class Type {
Invalid,
@@ -35,8 +36,6 @@ public:
Function<void()> on_connected;
- virtual const char* class_name() const override { return "CSocket"; }
-
protected:
CSocket(Type, CObject* parent);
diff --git a/Libraries/LibCore/CTCPSocket.h b/Libraries/LibCore/CTCPSocket.h
index fe4f3ffb3a..8eb330c492 100644
--- a/Libraries/LibCore/CTCPSocket.h
+++ b/Libraries/LibCore/CTCPSocket.h
@@ -1,6 +1,7 @@
#include <LibCore/CSocket.h>
class CTCPSocket final : public CSocket {
+ C_OBJECT(CTCPSocket)
public:
explicit CTCPSocket(CObject* parent = nullptr);
virtual ~CTCPSocket() override;
diff --git a/Libraries/LibCore/CTimer.h b/Libraries/LibCore/CTimer.h
index b6c1c2005f..3abb54d6f6 100644
--- a/Libraries/LibCore/CTimer.h
+++ b/Libraries/LibCore/CTimer.h
@@ -4,6 +4,7 @@
#include <LibCore/CObject.h>
class CTimer final : public CObject {
+ C_OBJECT(CTimer)
public:
explicit CTimer(CObject* parent = nullptr);
CTimer(int interval, Function<void()>&& timeout_handler, CObject* parent = nullptr);
@@ -29,8 +30,6 @@ public:
Function<void()> on_timeout;
- virtual const char* class_name() const override { return "CTimer"; }
-
private:
virtual void timer_event(CTimerEvent&) override;
diff --git a/Libraries/LibCore/CoreIPCClient.h b/Libraries/LibCore/CoreIPCClient.h
index 400da2bc0d..490cf48503 100644
--- a/Libraries/LibCore/CoreIPCClient.h
+++ b/Libraries/LibCore/CoreIPCClient.h
@@ -49,6 +49,7 @@ private:
template <typename ServerMessage, typename ClientMessage>
class Connection : public CObject {
+ C_OBJECT(Connection)
public:
Connection(const StringView& address)
: m_notifier(CNotifier(m_connection.fd(), CNotifier::Read))
diff --git a/Libraries/LibCore/CoreIPCServer.h b/Libraries/LibCore/CoreIPCServer.h
index c49ebcc25b..9849c80329 100644
--- a/Libraries/LibCore/CoreIPCServer.h
+++ b/Libraries/LibCore/CoreIPCServer.h
@@ -55,8 +55,8 @@ T* new_connection_for_client(Args&& ... args)
};
template <typename ServerMessage, typename ClientMessage>
-class Connection : public CObject
-{
+class Connection : public CObject {
+ C_OBJECT(Connection)
public:
Connection(int fd, int client_id)
: m_socket(fd)
@@ -168,8 +168,6 @@ public:
m_notifier.set_enabled(false);
}
- const char* class_name() const override { return "Connection"; }
-
int client_id() const { return m_client_id; }
pid_t client_pid() const { return m_pid; }
void set_client_pid(pid_t pid) { m_pid = pid; }
@@ -194,10 +192,9 @@ protected:
private:
// TODO: A way to create some kind of CIODevice with an open FD would be nice.
- class COpenedSocket : public CIODevice
- {
+ class COpenedSocket : public CIODevice {
+ C_OBJECT(COpenedSocket)
public:
- const char* class_name() const override { return "COpenedSocket"; }
COpenedSocket(int fd)
{
set_fd(fd);
diff --git a/Libraries/LibGUI/GAbstractButton.h b/Libraries/LibGUI/GAbstractButton.h
index 6e5f77e19a..b9ccfd044b 100644
--- a/Libraries/LibGUI/GAbstractButton.h
+++ b/Libraries/LibGUI/GAbstractButton.h
@@ -7,6 +7,7 @@
class GPainter;
class GAbstractButton : public GWidget {
+ C_OBJECT(GAbstractButton)
public:
virtual ~GAbstractButton() override;
@@ -28,7 +29,6 @@ public:
bool is_being_pressed() const { return m_being_pressed; }
virtual void click() = 0;
- virtual const char* class_name() const override { return "GAbstractButton"; }
virtual bool accepts_focus() const override { return true; }
virtual bool supports_keyboard_activation() const override { return true; }
virtual bool is_uncheckable() const { return true; }
diff --git a/Libraries/LibGUI/GAbstractView.h b/Libraries/LibGUI/GAbstractView.h
index 348cabfdc3..730d944b32 100644
--- a/Libraries/LibGUI/GAbstractView.h
+++ b/Libraries/LibGUI/GAbstractView.h
@@ -7,8 +7,8 @@
class GModelEditingDelegate;
class GAbstractView : public GScrollableWidget {
+ C_OBJECT(GAbstractView)
friend class GModel;
-
public:
explicit GAbstractView(GWidget* parent);
virtual ~GAbstractView() override;
@@ -38,8 +38,6 @@ public:
Function<OwnPtr<GModelEditingDelegate>(const GModelIndex&)> aid_create_editing_delegate;
- virtual const char* class_name() const override { return "GAbstractView"; }
-
protected:
virtual void model_notification(const GModelNotification&);
virtual void did_scroll() override;
diff --git a/Libraries/LibGUI/GButton.h b/Libraries/LibGUI/GButton.h
index c5724c0f01..5eed1b012a 100644
--- a/Libraries/LibGUI/GButton.h
+++ b/Libraries/LibGUI/GButton.h
@@ -10,6 +10,7 @@
class GAction;
class GButton : public GAbstractButton {
+ C_OBJECT(GButton)
public:
GButton(const StringView& text, GWidget* parent);
explicit GButton(GWidget* parent);
@@ -31,7 +32,6 @@ public:
void set_action(GAction&);
- virtual const char* class_name() const override { return "GButton"; }
virtual bool accepts_focus() const override { return m_focusable; }
virtual bool supports_keyboard_activation() const override;
virtual bool is_uncheckable() const override;
diff --git a/Libraries/LibGUI/GCheckBox.h b/Libraries/LibGUI/GCheckBox.h
index ec6864e4b1..5d94535a8e 100644
--- a/Libraries/LibGUI/GCheckBox.h
+++ b/Libraries/LibGUI/GCheckBox.h
@@ -5,6 +5,7 @@
#include <LibGUI/GAbstractButton.h>
class GCheckBox : public GAbstractButton {
+ C_OBJECT(GCheckBox)
public:
GCheckBox(const StringView&, GWidget* parent);
explicit GCheckBox(GWidget* parent);
@@ -12,8 +13,6 @@ public:
virtual void click() override;
- virtual const char* class_name() const override { return "GCheckBox"; }
-
private:
// These don't make sense for a check box, so hide them.
using GAbstractButton::auto_repeat_interval;
diff --git a/Libraries/LibGUI/GComboBox.h b/Libraries/LibGUI/GComboBox.h
index 8747c2ec1b..017e538107 100644
--- a/Libraries/LibGUI/GComboBox.h
+++ b/Libraries/LibGUI/GComboBox.h
@@ -7,6 +7,7 @@ class GButton;
class GTextEditor;
class GComboBox : public GWidget {
+ C_OBJECT(GComboBox)
public:
explicit GComboBox(GWidget* parent = nullptr);
virtual ~GComboBox() override;
@@ -28,8 +29,6 @@ public:
Function<void(const String&)> on_change;
Function<void()> on_return_pressed;
- virtual const char* class_name() const override { return "GComboBox"; }
-
protected:
virtual void resize_event(GResizeEvent&) override;
diff --git a/Libraries/LibGUI/GDialog.h b/Libraries/LibGUI/GDialog.h
index 7e57ef8fbd..a0e9a2cb46 100644
--- a/Libraries/LibGUI/GDialog.h
+++ b/Libraries/LibGUI/GDialog.h
@@ -4,6 +4,7 @@
#include <LibGUI/GWindow.h>
class GDialog : public GWindow {
+ C_OBJECT(GDialog)
public:
enum ExecResult {
ExecOK = 0,
@@ -18,8 +19,6 @@ public:
int result() const { return m_result; }
void done(int result);
- virtual const char* class_name() const override { return "GDialog"; }
-
protected:
explicit GDialog(CObject* parent);
diff --git a/Libraries/LibGUI/GFilePicker.h b/Libraries/LibGUI/GFilePicker.h
index ccb68134b0..97f80bf103 100644
--- a/Libraries/LibGUI/GFilePicker.h
+++ b/Libraries/LibGUI/GFilePicker.h
@@ -7,6 +7,7 @@ class GDirectoryModel;
class GLabel;
class GFilePicker final : public GDialog {
+ C_OBJECT(GFilePicker)
public:
enum class Mode {
Open,
@@ -22,8 +23,6 @@ public:
FileSystemPath selected_file() const { return m_selected_file; }
- virtual const char* class_name() const override { return "GFilePicker"; }
-
private:
void set_preview(const FileSystemPath&);
void clear_preview();
@@ -48,4 +47,4 @@ private:
GLabel* m_preview_name_label { nullptr };
GLabel* m_preview_geometry_label { nullptr };
Mode m_mode { Mode::Open };
-}; \ No newline at end of file
+};
diff --git a/Libraries/LibGUI/GFrame.h b/Libraries/LibGUI/GFrame.h
index 84b07413f6..7ce5c0ac1d 100644
--- a/Libraries/LibGUI/GFrame.h
+++ b/Libraries/LibGUI/GFrame.h
@@ -4,6 +4,7 @@
#include <LibDraw/StylePainter.h>
class GFrame : public GWidget {
+ C_OBJECT(GFrame)
public:
explicit GFrame(GWidget* parent = nullptr);
virtual ~GFrame() override;
@@ -20,8 +21,6 @@ public:
Rect frame_inner_rect_for_size(const Size& size) const { return { m_thickness, m_thickness, size.width() - m_thickness * 2, size.height() - m_thickness * 2 }; }
Rect frame_inner_rect() const { return frame_inner_rect_for_size(size()); }
- virtual const char* class_name() const override { return "GFrame"; }
-
protected:
void paint_event(GPaintEvent&) override;
diff --git a/Libraries/LibGUI/GGroupBox.h b/Libraries/LibGUI/GGroupBox.h
index 335c5c7f9d..04cfed5611 100644
--- a/Libraries/LibGUI/GGroupBox.h
+++ b/Libraries/LibGUI/GGroupBox.h
@@ -3,6 +3,7 @@
#include <LibGUI/GWidget.h>
class GGroupBox : public GWidget {
+ C_OBJECT(GGroupBox)
public:
explicit GGroupBox(GWidget* parent);
GGroupBox(const StringView& title, GWidget* parent);
@@ -11,8 +12,6 @@ public:
String title() const { return m_title; }
void set_title(const StringView&);
- virtual const char* class_name() const override { return "GGroupBox"; }
-
protected:
virtual void paint_event(GPaintEvent&) override;
diff --git a/Libraries/LibGUI/GInputBox.h b/Libraries/LibGUI/GInputBox.h
index 76672b9a80..f7a36bebf0 100644
--- a/Libraries/LibGUI/GInputBox.h
+++ b/Libraries/LibGUI/GInputBox.h
@@ -6,14 +6,13 @@ class GButton;
class GTextEditor;
class GInputBox : public GDialog {
+ C_OBJECT(GInputBox)
public:
explicit GInputBox(const StringView& prompt, const StringView& title, CObject* parent = nullptr);
virtual ~GInputBox() override;
String text_value() const { return m_text_value; }
- virtual const char* class_name() const override { return "GInputBox"; }
-
private:
void build();
String m_prompt;
diff --git a/Libraries/LibGUI/GItemView.h b/Libraries/LibGUI/GItemView.h
index ca50019ce4..0d0bacf492 100644
--- a/Libraries/LibGUI/GItemView.h
+++ b/Libraries/LibGUI/GItemView.h
@@ -9,6 +9,7 @@ class GScrollBar;
class Painter;
class GItemView : public GAbstractView {
+ C_OBJECT(GItemView)
public:
explicit GItemView(GWidget* parent);
virtual ~GItemView() override;
@@ -22,8 +23,6 @@ public:
int model_column() const { return m_model_column; }
void set_model_column(int column) { m_model_column = column; }
- virtual const char* class_name() const override { return "GItemView"; }
-
private:
virtual void did_update_model() override;
virtual void paint_event(GPaintEvent&) override;
diff --git a/Libraries/LibGUI/GLabel.h b/Libraries/LibGUI/GLabel.h
index 4ee427d2bd..d98acdfa86 100644
--- a/Libraries/LibGUI/GLabel.h
+++ b/Libraries/LibGUI/GLabel.h
@@ -6,6 +6,7 @@
class GraphicsBitmap;
class GLabel : public GFrame {
+ C_OBJECT(GLabel)
public:
explicit GLabel(GWidget* parent = nullptr);
GLabel(const StringView& text, GWidget* parent = nullptr);
@@ -26,8 +27,6 @@ public:
void size_to_fit();
- virtual const char* class_name() const override { return "GLabel"; }
-
private:
virtual void paint_event(GPaintEvent&) override;
diff --git a/Libraries/LibGUI/GListView.h b/Libraries/LibGUI/GListView.h
index d32f7b51f9..1298ad4ec5 100644
--- a/Libraries/LibGUI/GListView.h
+++ b/Libraries/LibGUI/GListView.h
@@ -9,6 +9,7 @@ class GScrollBar;
class Painter;
class GListView : public GAbstractView {
+ C_OBJECT(GListView)
public:
explicit GListView(GWidget* parent);
virtual ~GListView() override;
@@ -26,8 +27,6 @@ public:
virtual Rect content_rect(const GModelIndex&) const override;
- virtual const char* class_name() const override { return "GListView"; }
-
private:
virtual void did_update_model() override;
virtual void paint_event(GPaintEvent&) override;
diff --git a/Libraries/LibGUI/GMessageBox.h b/Libraries/LibGUI/GMessageBox.h
index 0c7938ef14..7c7a5b7ca5 100644
--- a/Libraries/LibGUI/GMessageBox.h
+++ b/Libraries/LibGUI/GMessageBox.h
@@ -3,6 +3,7 @@
#include <LibGUI/GDialog.h>
class GMessageBox : public GDialog {
+ C_OBJECT(GMessageBox)
public:
enum class Type {
None,
@@ -21,8 +22,6 @@ public:
static void show(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
- virtual const char* class_name() const override { return "GMessageBox"; }
-
private:
bool should_include_ok_button() const;
bool should_include_cancel_button() const;
diff --git a/Libraries/LibGUI/GRadioButton.h b/Libraries/LibGUI/GRadioButton.h
index 5378e66047..5a1711386e 100644
--- a/Libraries/LibGUI/GRadioButton.h
+++ b/Libraries/LibGUI/GRadioButton.h
@@ -3,12 +3,11 @@
#include <LibGUI/GAbstractButton.h>
class GRadioButton : public GAbstractButton {
+ C_OBJECT(GRadioButton)
public:
GRadioButton(const StringView& text, GWidget* parent);
virtual ~GRadioButton() override;
- virtual const char* class_name() const override { return "GRadioButton"; }
-
virtual void click() override;
protected:
diff --git a/Libraries/LibGUI/GResizeCorner.h b/Libraries/LibGUI/GResizeCorner.h
index ac73703879..2fd540363b 100644
--- a/Libraries/LibGUI/GResizeCorner.h
+++ b/Libraries/LibGUI/GResizeCorner.h
@@ -1,12 +1,11 @@
#include <LibGUI/GWidget.h>
class GResizeCorner : public GWidget {
+ C_OBJECT(GResizeCorner)
public:
explicit GResizeCorner(GWidget* parent);
virtual ~GResizeCorner() override;
- virtual const char* class_name() const override { return "GResizeCorner"; }
-
protected:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
diff --git a/Libraries/LibGUI/GScrollBar.h b/Libraries/LibGUI/GScrollBar.h
index ff906d2edc..2197e51bd2 100644
--- a/Libraries/LibGUI/GScrollBar.h
+++ b/Libraries/LibGUI/GScrollBar.h
@@ -5,6 +5,7 @@
#include <LibGUI/GWidget.h>
class GScrollBar final : public GWidget {
+ C_OBJECT(GScrollBar)
public:
explicit GScrollBar(Orientation, GWidget* parent);
virtual ~GScrollBar() override;
@@ -27,8 +28,6 @@ public:
Function<void(int)> on_change;
- virtual const char* class_name() const override { return "GScrollBar"; }
-
enum Component {
Invalid,
DecrementButton,
diff --git a/Libraries/LibGUI/GScrollableWidget.h b/Libraries/LibGUI/GScrollableWidget.h
index 47f4b089fc..1d0610b4e2 100644
--- a/Libraries/LibGUI/GScrollableWidget.h
+++ b/Libraries/LibGUI/GScrollableWidget.h
@@ -5,6 +5,7 @@
class GScrollBar;
class GScrollableWidget : public GFrame {
+ C_OBJECT(GScrollableWidget)
public:
virtual ~GScrollableWidget() override;
@@ -37,8 +38,6 @@ public:
int width_occupied_by_vertical_scrollbar() const;
int height_occupied_by_horizontal_scrollbar() const;
- virtual const char* class_name() const override { return "GScrollableWidget"; }
-
protected:
explicit GScrollableWidget(GWidget* parent);
virtual void resize_event(GResizeEvent&) override;
diff --git a/Libraries/LibGUI/GSpinBox.h b/Libraries/LibGUI/GSpinBox.h
index c32e1d697d..d849c3c472 100644
--- a/Libraries/LibGUI/GSpinBox.h
+++ b/Libraries/LibGUI/GSpinBox.h
@@ -6,6 +6,7 @@ class GButton;
class GTextEditor;
class GSpinBox : public GWidget {
+ C_OBJECT(GSpinBox)
public:
GSpinBox(GWidget* parent = nullptr);
virtual ~GSpinBox() override;
@@ -21,8 +22,6 @@ public:
Function<void(int value)> on_change;
- virtual const char* class_name() const override { return "GSpinBox"; }
-
protected:
virtual void resize_event(GResizeEvent&) override;
diff --git a/Libraries/LibGUI/GStackWidget.h b/Libraries/LibGUI/GStackWidget.h
index 276e9cd793..980d4ea382 100644
--- a/Libraries/LibGUI/GStackWidget.h
+++ b/Libraries/LibGUI/GStackWidget.h
@@ -3,6 +3,7 @@
#include <LibGUI/GWidget.h>
class GStackWidget : public GWidget {
+ C_OBJECT(GStackWidget)
public:
explicit GStackWidget(GWidget* parent);
virtual ~GStackWidget() override;
@@ -12,8 +13,6 @@ public:
Function<void(GWidget*)> on_active_widget_change;
- virtual const char* class_name() const override { return "GStackWidget"; }
-
protected:
virtual void child_event(CChildEvent&) override;
virtual void resize_event(GResizeEvent&) override;
diff --git a/Libraries/LibGUI/GStatusBar.h b/Libraries/LibGUI/GStatusBar.h
index ad1deebb61..36f83b8609 100644
--- a/Libraries/LibGUI/GStatusBar.h
+++ b/Libraries/LibGUI/GStatusBar.h
@@ -6,6 +6,7 @@ class GLabel;
class GResizeCorner;
class GStatusBar : public GWidget {
+ C_OBJECT(GStatusBar)
public:
explicit GStatusBar(GWidget* parent);
virtual ~GStatusBar() override;
@@ -13,8 +14,6 @@ public:
String text() const;
void set_text(const StringView&);
- virtual const char* class_name() const override { return "GStatusBar"; }
-
private:
virtual void paint_event(GPaintEvent&) override;
diff --git a/Libraries/LibGUI/GTabWidget.h b/Libraries/LibGUI/GTabWidget.h
index 0b2e41ad58..ac679f21c8 100644
--- a/Libraries/LibGUI/GTabWidget.h
+++ b/Libraries/LibGUI/GTabWidget.h
@@ -3,6 +3,7 @@
#include <LibGUI/GWidget.h>
class GTabWidget : public GWidget {
+ C_OBJECT(GTabWidget)
public:
explicit GTabWidget(GWidget* parent);
virtual ~GTabWidget() override;
@@ -15,8 +16,6 @@ public:
void add_widget(const StringView&, GWidget*);
- virtual const char* class_name() const override { return "GTabWidget"; }
-
protected:
virtual void paint_event(GPaintEvent&) override;
virtual void child_event(CChildEvent&) override;
diff --git a/Libraries/LibGUI/GTableView.h b/Libraries/LibGUI/GTableView.h
index 6c6b02fa99..a5e8851cd6 100644
--- a/Libraries/LibGUI/GTableView.h
+++ b/Libraries/LibGUI/GTableView.h
@@ -9,6 +9,7 @@ class GScrollBar;
class Painter;
class GTableView : public GAbstractView {
+ C_OBJECT(GTableView)
public:
explicit GTableView(GWidget* parent);
virtual ~GTableView() override;
@@ -34,8 +35,6 @@ public:
virtual Rect content_rect(const GModelIndex&) const override;
- virtual const char* class_name() const override { return "GTableView"; }
-
private:
virtual void did_update_model() override;
virtual void paint_event(GPaintEvent&) override;
diff --git a/Libraries/LibGUI/GTextBox.h b/Libraries/LibGUI/GTextBox.h
index 6673e09fef..e67f500421 100644
--- a/Libraries/LibGUI/GTextBox.h
+++ b/Libraries/LibGUI/GTextBox.h
@@ -4,9 +4,8 @@
#include <LibGUI/GTextEditor.h>
class GTextBox final : public GTextEditor {
+ C_OBJECT(GTextBox)
public:
explicit GTextBox(GWidget* parent);
virtual ~GTextBox() override;
-
- virtual const char* class_name() const override { return "GTextBox"; }
};
diff --git a/Libraries/LibGUI/GTextEditor.h b/Libraries/LibGUI/GTextEditor.h
index fcac07ab15..22364e69cd 100644
--- a/Libraries/LibGUI/GTextEditor.h
+++ b/Libraries/LibGUI/GTextEditor.h
@@ -78,6 +78,7 @@ private:
};
class GTextEditor : public GScrollableWidget {
+ C_OBJECT(GTextEditor)
public:
enum Type {
MultiLine,
@@ -134,8 +135,6 @@ public:
Function<void()> on_return_pressed;
Function<void()> on_escape_pressed;
- virtual const char* class_name() const override { return "GTextEditor"; }
-
GAction& undo_action() { return *m_undo_action; }
GAction& redo_action() { return *m_redo_action; }
GAction& cut_action() { return *m_cut_action; }
diff --git a/Libraries/LibGUI/GToolBar.cpp b/Libraries/LibGUI/GToolBar.cpp
index 417e935ca2..de1eedbf89 100644
--- a/Libraries/LibGUI/GToolBar.cpp
+++ b/Libraries/LibGUI/GToolBar.cpp
@@ -45,6 +45,7 @@ void GToolBar::add_action(GAction& action)
}
class SeparatorWidget final : public GWidget {
+ C_OBJECT(SeparatorWidget)
public:
SeparatorWidget(GWidget* parent)
: GWidget(parent)
@@ -63,9 +64,6 @@ public:
painter.draw_line({ 0, 0 }, { 0, rect().bottom() }, Color::MidGray);
painter.draw_line({ 1, 0 }, { 1, rect().bottom() }, Color::White);
}
-
-private:
- virtual const char* class_name() const override { return "SeparatorWidget"; }
};
void GToolBar::add_separator()
diff --git a/Libraries/LibGUI/GToolBar.h b/Libraries/LibGUI/GToolBar.h
index 8e324b22e8..f1cf007a9b 100644
--- a/Libraries/LibGUI/GToolBar.h
+++ b/Libraries/LibGUI/GToolBar.h
@@ -6,6 +6,7 @@
class GAction;
class GToolBar : public GWidget {
+ C_OBJECT(GToolBar)
public:
explicit GToolBar(GWidget* parent);
virtual ~GToolBar() override;
@@ -16,8 +17,6 @@ public:
bool has_frame() const { return m_has_frame; }
void set_has_frame(bool has_frame) { m_has_frame = has_frame; }
- virtual const char* class_name() const override { return "GToolBar"; }
-
private:
virtual void paint_event(GPaintEvent&) override;
diff --git a/Libraries/LibGUI/GTreeView.h b/Libraries/LibGUI/GTreeView.h
index 55241d2376..421c88dcea 100644
--- a/Libraries/LibGUI/GTreeView.h
+++ b/Libraries/LibGUI/GTreeView.h
@@ -3,12 +3,12 @@
#include <LibGUI/GAbstractView.h>
class GTreeView : public GAbstractView {
+ C_OBJECT(GTreeView)
public:
explicit GTreeView(GWidget*);
virtual ~GTreeView() override;
virtual void scroll_into_view(const GModelIndex&, Orientation);
- virtual const char* class_name() const override { return "GTreeView"; }
protected:
virtual void paint_event(GPaintEvent&) override;
diff --git a/Libraries/LibGUI/GWidget.h b/Libraries/LibGUI/GWidget.h
index cd4fa680d4..dac6a11ae7 100644
--- a/Libraries/LibGUI/GWidget.h
+++ b/Libraries/LibGUI/GWidget.h
@@ -32,6 +32,7 @@ enum class VerticalDirection {
};
class GWidget : public CObject {
+ C_OBJECT(GWidget)
public:
explicit GWidget(GWidget* parent = nullptr);
virtual ~GWidget() override;
@@ -113,8 +114,6 @@ public:
HitTestResult hit_test(const Point&);
GWidget* child_at(const Point&) const;
- virtual const char* class_name() const override { return "GWidget"; }
-
void set_relative_rect(const Rect&);
void set_relative_rect(int x, int y, int width, int height) { set_relative_rect({ x, y, width, height }); }
diff --git a/Libraries/LibGUI/GWindow.h b/Libraries/LibGUI/GWindow.h
index 0ea7a15ce3..e8b50ed13a 100644
--- a/Libraries/LibGUI/GWindow.h
+++ b/Libraries/LibGUI/GWindow.h
@@ -22,6 +22,7 @@ enum class GStandardCursor {
};
class GWindow : public CObject {
+ C_OBJECT(GWindow)
public:
GWindow(CObject* parent = nullptr);
virtual ~GWindow() override;
@@ -123,8 +124,6 @@ public:
Vector<GWidget*> focusable_widgets() const;
- virtual const char* class_name() const override { return "GWindow"; }
-
protected:
virtual void wm_event(GWMEvent&);