summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-13 22:51:50 +0200
committerAndreas Kling <awesomekling@gmail.com>2018-10-13 22:51:50 +0200
commita3fb19fe9c7f810bc997977eadb6ddb63e45cf93 (patch)
treecb10fe380ffb69d6d1c7f87a17a466c8ec9a0716
parentdfb70ed234fa82ea88665657af6758250bb54c3a (diff)
downloadserenity-a3fb19fe9c7f810bc997977eadb6ddb63e45cf93.zip
Use fooEvent() type names for the virtual event handlers.
-rw-r--r--Widgets/Button.cpp14
-rw-r--r--Widgets/Button.h6
-rw-r--r--Widgets/CheckBox.cpp6
-rw-r--r--Widgets/CheckBox.h4
-rw-r--r--Widgets/ClockWidget.cpp4
-rw-r--r--Widgets/ClockWidget.h4
-rw-r--r--Widgets/Label.cpp8
-rw-r--r--Widgets/Label.h4
-rw-r--r--Widgets/ListBox.cpp6
-rw-r--r--Widgets/ListBox.h4
-rw-r--r--Widgets/Object.cpp4
-rw-r--r--Widgets/Object.h2
-rw-r--r--Widgets/RootWidget.cpp12
-rw-r--r--Widgets/RootWidget.h4
-rw-r--r--Widgets/TerminalWidget.cpp10
-rw-r--r--Widgets/TerminalWidget.h8
-rw-r--r--Widgets/TextBox.cpp8
-rw-r--r--Widgets/TextBox.h8
-rw-r--r--Widgets/Widget.cpp36
-rw-r--r--Widgets/Widget.h16
20 files changed, 84 insertions, 84 deletions
diff --git a/Widgets/Button.cpp b/Widgets/Button.cpp
index f309d3f465..9313ed143b 100644
--- a/Widgets/Button.cpp
+++ b/Widgets/Button.cpp
@@ -19,7 +19,7 @@ void Button::setCaption(String&& caption)
update();
}
-void Button::onPaint(PaintEvent&)
+void Button::paintEvent(PaintEvent&)
{
Color buttonColor = Color::LightGray;
Color highlightColor = Color::White;
@@ -69,23 +69,23 @@ void Button::onPaint(PaintEvent&)
}
}
-void Button::onMouseDown(MouseEvent& event)
+void Button::mouseDownEvent(MouseEvent& event)
{
- printf("Button::onMouseDown: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button());
+ printf("Button::mouseDownEvent: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button());
m_beingPressed = true;
update();
- Widget::onMouseDown(event);
+ Widget::mouseDownEvent(event);
}
-void Button::onMouseUp(MouseEvent& event)
+void Button::mouseUpEvent(MouseEvent& event)
{
- printf("Button::onMouseUp: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button());
+ printf("Button::mouseUpEvent: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button());
m_beingPressed = false;
update();
- Widget::onMouseUp(event);
+ Widget::mouseUpEvent(event);
}
diff --git a/Widgets/Button.h b/Widgets/Button.h
index 040b363744..98c63596eb 100644
--- a/Widgets/Button.h
+++ b/Widgets/Button.h
@@ -12,9 +12,9 @@ public:
void setCaption(String&&);
private:
- virtual void onPaint(PaintEvent&) override;
- virtual void onMouseDown(MouseEvent&) override;
- virtual void onMouseUp(MouseEvent&) override;
+ virtual void paintEvent(PaintEvent&) override;
+ virtual void mouseDownEvent(MouseEvent&) override;
+ virtual void mouseUpEvent(MouseEvent&) override;
virtual const char* className() const override { return "Button"; }
diff --git a/Widgets/CheckBox.cpp b/Widgets/CheckBox.cpp
index ff2fff1c1b..372f1d208e 100644
--- a/Widgets/CheckBox.cpp
+++ b/Widgets/CheckBox.cpp
@@ -74,7 +74,7 @@ static const char* checkedBitmap = {
"###########"
};
-void CheckBox::onPaint(PaintEvent&)
+void CheckBox::paintEvent(PaintEvent&)
{
Painter painter(*this);
auto bitmap = CBitmap::createFromASCII(isChecked() ? checkedBitmap : uncheckedBitmap, 11, 11);
@@ -95,9 +95,9 @@ void CheckBox::onPaint(PaintEvent&)
}
}
-void CheckBox::onMouseDown(MouseEvent& event)
+void CheckBox::mouseDownEvent(MouseEvent& event)
{
- printf("CheckBox::onMouseDown: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button());
+ printf("CheckBox::mouseDownEvent: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button());
setIsChecked(!isChecked());
}
diff --git a/Widgets/CheckBox.h b/Widgets/CheckBox.h
index f653aa803d..485137f85d 100644
--- a/Widgets/CheckBox.h
+++ b/Widgets/CheckBox.h
@@ -15,8 +15,8 @@ public:
void setIsChecked(bool);
private:
- virtual void onPaint(PaintEvent&) override;
- virtual void onMouseDown(MouseEvent&) override;
+ virtual void paintEvent(PaintEvent&) override;
+ virtual void mouseDownEvent(MouseEvent&) override;
virtual const char* className() const override { return "CheckBox"; }
diff --git a/Widgets/ClockWidget.cpp b/Widgets/ClockWidget.cpp
index 950c450504..6f9a5eaad7 100644
--- a/Widgets/ClockWidget.cpp
+++ b/Widgets/ClockWidget.cpp
@@ -13,7 +13,7 @@ ClockWidget::~ClockWidget()
{
}
-void ClockWidget::onPaint(PaintEvent&)
+void ClockWidget::paintEvent(PaintEvent&)
{
auto now = time(nullptr);
auto& tm = *localtime(&now);
@@ -26,7 +26,7 @@ void ClockWidget::onPaint(PaintEvent&)
painter.drawText(rect(), timeBuf, Painter::TextAlignment::Center, Color::Black);
}
-void ClockWidget::onTimer(TimerEvent&)
+void ClockWidget::timerEvent(TimerEvent&)
{
auto now = time(nullptr);
if (now == m_lastSeenTimestamp)
diff --git a/Widgets/ClockWidget.h b/Widgets/ClockWidget.h
index 3ddf269030..a7326984ec 100644
--- a/Widgets/ClockWidget.h
+++ b/Widgets/ClockWidget.h
@@ -8,8 +8,8 @@ public:
virtual ~ClockWidget() override;
private:
- virtual void onPaint(PaintEvent&) override;
- virtual void onTimer(TimerEvent&) override;
+ virtual void paintEvent(PaintEvent&) override;
+ virtual void timerEvent(TimerEvent&) override;
dword m_lastSeenTimestamp { 0 };
};
diff --git a/Widgets/Label.cpp b/Widgets/Label.cpp
index 5d23e84294..98937d62a1 100644
--- a/Widgets/Label.cpp
+++ b/Widgets/Label.cpp
@@ -19,7 +19,7 @@ void Label::setText(String&& text)
update();
}
-void Label::onPaint(PaintEvent&)
+void Label::paintEvent(PaintEvent&)
{
Painter painter(*this);
painter.fillRect({ 0, 0, width(), height() }, backgroundColor());
@@ -27,9 +27,9 @@ void Label::onPaint(PaintEvent&)
painter.drawText({ 4, 4, width(), height() }, text(), Painter::TextAlignment::TopLeft, foregroundColor());
}
-void Label::onMouseMove(MouseEvent& event)
+void Label::mouseMoveEvent(MouseEvent& event)
{
- printf("Label::onMouseMove: x=%d, y=%d\n", event.x(), event.y());
- Widget::onMouseMove(event);
+ printf("Label::mouseMoveEvent: x=%d, y=%d\n", event.x(), event.y());
+ Widget::mouseMoveEvent(event);
}
diff --git a/Widgets/Label.h b/Widgets/Label.h
index 634a50e279..266d78b3c7 100644
--- a/Widgets/Label.h
+++ b/Widgets/Label.h
@@ -12,8 +12,8 @@ public:
void setText(String&&);
private:
- virtual void onPaint(PaintEvent&) override;
- virtual void onMouseMove(MouseEvent&) override;
+ virtual void paintEvent(PaintEvent&) override;
+ virtual void mouseMoveEvent(MouseEvent&) override;
virtual const char* className() const override { return "Label"; }
diff --git a/Widgets/ListBox.cpp b/Widgets/ListBox.cpp
index ab7306bfad..53d146fa88 100644
--- a/Widgets/ListBox.cpp
+++ b/Widgets/ListBox.cpp
@@ -17,7 +17,7 @@ unsigned ListBox::itemHeight() const
return Font::defaultFont().glyphHeight() + 2;
}
-void ListBox::onPaint(PaintEvent&)
+void ListBox::paintEvent(PaintEvent&)
{
Painter painter(*this);
@@ -44,9 +44,9 @@ void ListBox::onPaint(PaintEvent&)
}
}
-void ListBox::onMouseDown(MouseEvent& event)
+void ListBox::mouseDownEvent(MouseEvent& event)
{
- printf("ListBox::onMouseDown %d,%d\n", event.x(), event.y());
+ printf("ListBox::mouseDownEvent %d,%d\n", event.x(), event.y());
for (unsigned i = m_scrollOffset; i < m_items.size(); ++i) {
Rect itemRect(1, 1 + (i * itemHeight()), width() - 2, itemHeight());
if (itemRect.contains(event.position())) {
diff --git a/Widgets/ListBox.h b/Widgets/ListBox.h
index fe90f68ed2..ece6f46d9e 100644
--- a/Widgets/ListBox.h
+++ b/Widgets/ListBox.h
@@ -11,8 +11,8 @@ public:
int selectedIndex() const { return m_selectedIndex; }
private:
- virtual void onPaint(PaintEvent&) override;
- virtual void onMouseDown(MouseEvent&) override;
+ virtual void paintEvent(PaintEvent&) override;
+ virtual void mouseDownEvent(MouseEvent&) override;
unsigned itemHeight() const;
diff --git a/Widgets/Object.cpp b/Widgets/Object.cpp
index 19c48ce1ef..0eaaed08f6 100644
--- a/Widgets/Object.cpp
+++ b/Widgets/Object.cpp
@@ -27,7 +27,7 @@ void Object::event(Event& event)
{
switch (event.type()) {
case Event::Timer:
- return onTimer(static_cast<TimerEvent&>(event));
+ return timerEvent(static_cast<TimerEvent&>(event));
case Event::Invalid:
ASSERT_NOT_REACHED();
break;
@@ -51,7 +51,7 @@ void Object::removeChild(Object& object)
}
}
-void Object::onTimer(TimerEvent&)
+void Object::timerEvent(TimerEvent&)
{
}
diff --git a/Widgets/Object.h b/Widgets/Object.h
index 4bf672d8ae..8bf27c8d19 100644
--- a/Widgets/Object.h
+++ b/Widgets/Object.h
@@ -25,7 +25,7 @@ public:
bool hasTimer() const { return m_timerID; }
private:
- virtual void onTimer(TimerEvent&);
+ virtual void timerEvent(TimerEvent&);
void addChild(Object&);
void removeChild(Object&);
diff --git a/Widgets/RootWidget.cpp b/Widgets/RootWidget.cpp
index 4cd0cc8db5..971840bf64 100644
--- a/Widgets/RootWidget.cpp
+++ b/Widgets/RootWidget.cpp
@@ -11,11 +11,11 @@ RootWidget::~RootWidget()
{
}
-void RootWidget::onPaint(PaintEvent& event)
+void RootWidget::paintEvent(PaintEvent& event)
{
- Widget::onPaint(event);
+ Widget::paintEvent(event);
- printf("RootWidget::onPaint: %d,%d %dx%d\n",
+ printf("RootWidget::paintEvent: %d,%d %dx%d\n",
event.rect().x(),
event.rect().y(),
event.rect().width(),
@@ -24,9 +24,9 @@ void RootWidget::onPaint(PaintEvent& event)
painter.fillRect(event.rect(), Color(0, 72, 96));
}
-void RootWidget::onMouseMove(MouseEvent& event)
+void RootWidget::mouseMoveEvent(MouseEvent& event)
{
- //printf("RootWidget::onMouseMove: x=%d, y=%d\n", event.x(), event.y());
- Widget::onMouseMove(event);
+ //printf("RootWidget::mouseMoveEvent: x=%d, y=%d\n", event.x(), event.y());
+ Widget::mouseMoveEvent(event);
}
diff --git a/Widgets/RootWidget.h b/Widgets/RootWidget.h
index c025ed688d..06524f4f8a 100644
--- a/Widgets/RootWidget.h
+++ b/Widgets/RootWidget.h
@@ -8,6 +8,6 @@ public:
virtual ~RootWidget() override;
private:
- virtual void onPaint(PaintEvent&) override;
- virtual void onMouseMove(MouseEvent&) override;
+ virtual void paintEvent(PaintEvent&) override;
+ virtual void mouseMoveEvent(MouseEvent&) override;
};
diff --git a/Widgets/TerminalWidget.cpp b/Widgets/TerminalWidget.cpp
index 8bc8bd815c..729cf16b16 100644
--- a/Widgets/TerminalWidget.cpp
+++ b/Widgets/TerminalWidget.cpp
@@ -60,7 +60,7 @@ CharacterWithAttributes& TerminalWidget::at(unsigned row, unsigned column)
return m_screen[row * columns() + column];
}
-void TerminalWidget::onPaint(PaintEvent&)
+void TerminalWidget::paintEvent(PaintEvent&)
{
Painter painter(*this);
painter.fillRect(rect(), Color::Black);
@@ -144,16 +144,16 @@ void TerminalWidget::onReceive(byte ch)
update();
}
-void TerminalWidget::onKeyDown(KeyEvent& event)
+void TerminalWidget::keyDownEvent(KeyEvent& event)
{
if (event.text().isEmpty())
return;
write(g_fd, event.text().characters(), event.text().length());
}
-void TerminalWidget::onKeyUp(KeyEvent& event)
+void TerminalWidget::keyUpEvent(KeyEvent& event)
{
- return Widget::onKeyUp(event);
+ return Widget::keyUpEvent(event);
}
void TerminalWidget::bell()
@@ -165,7 +165,7 @@ void TerminalWidget::bell()
update();
}
-void TerminalWidget::onTimer(TimerEvent&)
+void TerminalWidget::timerEvent(TimerEvent&)
{
m_belling = false;
stopTimer();
diff --git a/Widgets/TerminalWidget.h b/Widgets/TerminalWidget.h
index d8f25d41b7..78b9415475 100644
--- a/Widgets/TerminalWidget.h
+++ b/Widgets/TerminalWidget.h
@@ -22,10 +22,10 @@ public:
private:
CharacterWithAttributes& at(unsigned row, unsigned column);
- virtual void onPaint(PaintEvent&) override;
- virtual void onKeyDown(KeyEvent&) override;
- virtual void onKeyUp(KeyEvent&) override;
- virtual void onTimer(TimerEvent&) override;
+ virtual void paintEvent(PaintEvent&) override;
+ virtual void keyDownEvent(KeyEvent&) override;
+ virtual void keyUpEvent(KeyEvent&) override;
+ virtual void timerEvent(TimerEvent&) override;
void bell();
diff --git a/Widgets/TextBox.cpp b/Widgets/TextBox.cpp
index 23f89783ba..d0883ea235 100644
--- a/Widgets/TextBox.cpp
+++ b/Widgets/TextBox.cpp
@@ -21,7 +21,7 @@ void TextBox::setText(String&& text)
update();
}
-void TextBox::onPaint(PaintEvent&)
+void TextBox::paintEvent(PaintEvent&)
{
Painter painter(*this);
@@ -63,7 +63,7 @@ void TextBox::onPaint(PaintEvent&)
}
}
-void TextBox::onMouseDown(MouseEvent&)
+void TextBox::mouseDownEvent(MouseEvent&)
{
}
@@ -90,7 +90,7 @@ void TextBox::handleBackspace()
update();
}
-void TextBox::onKeyDown(KeyEvent& event)
+void TextBox::keyDownEvent(KeyEvent& event)
{
switch (event.key()) {
case KeyboardKey::LeftArrow:
@@ -126,7 +126,7 @@ void TextBox::onKeyDown(KeyEvent& event)
}
}
-void TextBox::onTimer(TimerEvent&)
+void TextBox::timerEvent(TimerEvent&)
{
// FIXME: Disable the timer when not focused.
if (!isFocused())
diff --git a/Widgets/TextBox.h b/Widgets/TextBox.h
index 89a748cb25..1676980882 100644
--- a/Widgets/TextBox.h
+++ b/Widgets/TextBox.h
@@ -11,10 +11,10 @@ public:
void setText(String&&);
private:
- virtual void onPaint(PaintEvent&) override;
- virtual void onMouseDown(MouseEvent&) override;
- virtual void onKeyDown(KeyEvent&) override;
- virtual void onTimer(TimerEvent&) override;
+ virtual void paintEvent(PaintEvent&) override;
+ virtual void mouseDownEvent(MouseEvent&) override;
+ virtual void keyDownEvent(KeyEvent&) override;
+ virtual void timerEvent(TimerEvent&) override;
void handleBackspace();
diff --git a/Widgets/Widget.cpp b/Widgets/Widget.cpp
index 3436aa5c10..a4d98499c4 100644
--- a/Widgets/Widget.cpp
+++ b/Widgets/Widget.cpp
@@ -37,64 +37,64 @@ void Widget::event(Event& event)
return;
}
m_hasPendingPaintEvent = false;
- return onPaint(static_cast<PaintEvent&>(event));
+ return paintEvent(static_cast<PaintEvent&>(event));
case Event::Show:
- return onShow(static_cast<ShowEvent&>(event));
+ return showEvent(static_cast<ShowEvent&>(event));
case Event::Hide:
- return onHide(static_cast<HideEvent&>(event));
+ return hideEvent(static_cast<HideEvent&>(event));
case Event::KeyDown:
- return onKeyDown(static_cast<KeyEvent&>(event));
+ return keyDownEvent(static_cast<KeyEvent&>(event));
case Event::KeyUp:
- return onKeyUp(static_cast<KeyEvent&>(event));
+ return keyUpEvent(static_cast<KeyEvent&>(event));
case Event::MouseMove:
- return onMouseMove(static_cast<MouseEvent&>(event));
+ return mouseMoveEvent(static_cast<MouseEvent&>(event));
case Event::MouseDown:
if (auto* win = window()) {
// FIXME: if (acceptsFocus())
win->setFocusedWidget(this);
}
- return onMouseDown(static_cast<MouseEvent&>(event));
+ return mouseDownEvent(static_cast<MouseEvent&>(event));
case Event::MouseUp:
- return onMouseUp(static_cast<MouseEvent&>(event));
+ return mouseUpEvent(static_cast<MouseEvent&>(event));
default:
return Object::event(event);
}
}
-void Widget::onPaint(PaintEvent& event)
+void Widget::paintEvent(PaintEvent& event)
{
- //printf("Widget::onPaint :)\n");
+ //printf("Widget::paintEvent :)\n");
for (auto* ch : children()) {
auto* child = (Widget*)ch;
- child->onPaint(event);
+ child->paintEvent(event);
}
}
-void Widget::onShow(ShowEvent&)
+void Widget::showEvent(ShowEvent&)
{
}
-void Widget::onHide(HideEvent&)
+void Widget::hideEvent(HideEvent&)
{
}
-void Widget::onKeyDown(KeyEvent&)
+void Widget::keyDownEvent(KeyEvent&)
{
}
-void Widget::onKeyUp(KeyEvent&)
+void Widget::keyUpEvent(KeyEvent&)
{
}
-void Widget::onMouseDown(MouseEvent&)
+void Widget::mouseDownEvent(MouseEvent&)
{
}
-void Widget::onMouseUp(MouseEvent&)
+void Widget::mouseUpEvent(MouseEvent&)
{
}
-void Widget::onMouseMove(MouseEvent&)
+void Widget::mouseMoveEvent(MouseEvent&)
{
}
diff --git a/Widgets/Widget.h b/Widgets/Widget.h
index 5c2c09d6e4..d592e91375 100644
--- a/Widgets/Widget.h
+++ b/Widgets/Widget.h
@@ -14,14 +14,14 @@ public:
virtual ~Widget();
virtual void event(Event&);
- virtual void onPaint(PaintEvent&);
- virtual void onShow(ShowEvent&);
- virtual void onHide(HideEvent&);
- virtual void onKeyDown(KeyEvent&);
- virtual void onKeyUp(KeyEvent&);
- virtual void onMouseMove(MouseEvent&);
- virtual void onMouseDown(MouseEvent&);
- virtual void onMouseUp(MouseEvent&);
+ virtual void paintEvent(PaintEvent&);
+ virtual void showEvent(ShowEvent&);
+ virtual void hideEvent(HideEvent&);
+ virtual void keyDownEvent(KeyEvent&);
+ virtual void keyUpEvent(KeyEvent&);
+ virtual void mouseMoveEvent(MouseEvent&);
+ virtual void mouseDownEvent(MouseEvent&);
+ virtual void mouseUpEvent(MouseEvent&);
Rect relativeRect() const { return m_relativeRect; }
Point relativePosition() const { return m_relativeRect.location(); }