diff --git a/LibGUI/GListBox.cpp b/LibGUI/GListBox.cpp deleted file mode 100644 index f4a9adab69..0000000000 --- a/LibGUI/GListBox.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "GListBox.h" -#include -#include - -GListBox::GListBox(GWidget* parent) - : GWidget(parent) -{ -} - -GListBox::~GListBox() -{ -} - -Rect GListBox::item_rect(int index) const -{ - int item_height = font().glyph_height() + 2; - return Rect { 2, 2 + (index * item_height), width() - 4, item_height }; -} - -void GListBox::paint_event(GPaintEvent& event) -{ - GPainter painter(*this); - painter.add_clip_rect(event.rect()); - - painter.fill_rect({ rect().x() + 1, rect().y() + 1, rect().width() - 2, rect().height() - 2 }, background_color()); - painter.draw_rect(rect(), foreground_color()); - - if (is_focused()) - painter.draw_focus_rect(rect()); - - for (int i = m_scroll_offset; i < static_cast(m_items.size()); ++i) { - auto item_rect = this->item_rect(i); - Rect text_rect(item_rect.x() + 1, item_rect.y() + 1, item_rect.width() - 2, item_rect.height() - 2); - - Color item_text_color = foreground_color(); - if (m_selected_index == i) { - if (is_focused()) - painter.fill_rect(item_rect, Color(0, 32, 128)); - else - painter.fill_rect(item_rect, Color(96, 96, 96)); - item_text_color = Color::White; - } - painter.draw_text(item_rect, m_items[i], TextAlignment::TopLeft, item_text_color); - } -} - -void GListBox::mousedown_event(GMouseEvent& event) -{ - dbgprintf("GListBox::mouseDownEvent %d,%d\n", event.x(), event.y()); - for (int i = m_scroll_offset; i < static_cast(m_items.size()); ++i) { - auto item_rect = this->item_rect(i); - if (item_rect.contains(event.position())) { - m_selected_index = i; - dbgprintf("GListBox: selected item %u (\"%s\")\n", i, m_items[i].characters()); - update(); - return; - } - } -} - -void GListBox::add_item(String&& item) -{ - m_items.append(move(item)); - if (m_selected_index == -1) - m_selected_index = 0; -} - diff --git a/LibGUI/GListBox.h b/LibGUI/GListBox.h deleted file mode 100644 index b2c1bd705f..0000000000 --- a/LibGUI/GListBox.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "GWidget.h" - -class GListBox final : public GWidget { -public: - explicit GListBox(GWidget* parent); - virtual ~GListBox() override; - - 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 bool accepts_focus() const override { return true; } - - Rect item_rect(int index) const; - - int m_scroll_offset { 0 }; - int m_selected_index { -1 }; - - Vector m_items; -}; - diff --git a/LibGUI/Makefile b/LibGUI/Makefile index 6ee8b250c6..fac3de3998 100644 --- a/LibGUI/Makefile +++ b/LibGUI/Makefile @@ -14,7 +14,6 @@ LIBGUI_OBJS = \ GCheckBox.o \ GEventLoop.o \ GLabel.o \ - GListBox.o \ GTextBox.o \ GScrollBar.o \ GStatusBar.o \