mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 15:45:07 +00:00
Rename all the LibGUI classes to GClassName.
This commit is contained in:
parent
a026da47e7
commit
b91479d9b9
33 changed files with 623 additions and 581 deletions
76
LibGUI/GObject.cpp
Normal file
76
LibGUI/GObject.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
#include "GObject.h"
|
||||
#include "GEvent.h"
|
||||
#include "GEventLoop.h"
|
||||
#include <AK/Assertions.h>
|
||||
|
||||
GObject::GObject(GObject* parent)
|
||||
: m_parent(parent)
|
||||
{
|
||||
if (m_parent)
|
||||
m_parent->addChild(*this);
|
||||
}
|
||||
|
||||
GObject::~GObject()
|
||||
{
|
||||
if (m_parent)
|
||||
m_parent->removeChild(*this);
|
||||
auto childrenToDelete = move(m_children);
|
||||
for (auto* child : childrenToDelete)
|
||||
delete child;
|
||||
}
|
||||
|
||||
void GObject::event(GEvent& event)
|
||||
{
|
||||
switch (event.type()) {
|
||||
case GEvent::Timer:
|
||||
return timerEvent(static_cast<GTimerEvent&>(event));
|
||||
case GEvent::DeferredDestroy:
|
||||
delete this;
|
||||
break;
|
||||
case GEvent::Invalid:
|
||||
ASSERT_NOT_REACHED();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GObject::addChild(GObject& object)
|
||||
{
|
||||
m_children.append(&object);
|
||||
}
|
||||
|
||||
void GObject::removeChild(GObject& object)
|
||||
{
|
||||
for (unsigned i = 0; i < m_children.size(); ++i) {
|
||||
if (m_children[i] == &object) {
|
||||
m_children.remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GObject::timerEvent(GTimerEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void GObject::startTimer(int ms)
|
||||
{
|
||||
if (m_timerID) {
|
||||
dbgprintf("GObject{%p} already has a timer!\n", this);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
void GObject::stopTimer()
|
||||
{
|
||||
if (!m_timerID)
|
||||
return;
|
||||
m_timerID = 0;
|
||||
}
|
||||
|
||||
void GObject::deleteLater()
|
||||
{
|
||||
GEventLoop::main().postEvent(this, make<GEvent>(GEvent::DeferredDestroy));
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue