mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +00:00
LibGUI: Turn GTextBox into a wrapper around a single-line GTextEditor.
This commit is contained in:
parent
981623f4ee
commit
313ac51832
11 changed files with 25 additions and 260 deletions
|
@ -1,39 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "GWidget.h"
|
||||
#include <LibGUI/GTextEditor.h>
|
||||
#include <AK/Function.h>
|
||||
|
||||
class GTextBox final : public GWidget {
|
||||
class GTextBox final : public GTextEditor {
|
||||
public:
|
||||
explicit GTextBox(GWidget* parent);
|
||||
virtual ~GTextBox() override;
|
||||
|
||||
String text() const { return m_text; }
|
||||
void set_text(const String&);
|
||||
|
||||
Function<void(GTextBox&)> on_return_pressed;
|
||||
Function<void(GTextBox&)> on_change;
|
||||
|
||||
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;
|
||||
virtual void timer_event(GTimerEvent&) override;
|
||||
virtual void focusin_event(GEvent&) override;
|
||||
virtual void focusout_event(GEvent&) override;
|
||||
virtual void resize_event(GResizeEvent&) override;
|
||||
virtual bool accepts_focus() const override { return true; }
|
||||
|
||||
Point cursor_content_position() const;
|
||||
Rect visible_content_rect() const;
|
||||
void handle_backspace();
|
||||
void scroll_cursor_into_view(HorizontalDirection);
|
||||
|
||||
String m_text;
|
||||
int m_cursor_position { 0 };
|
||||
int m_scroll_offset { 0 };
|
||||
bool m_cursor_blink_state { false };
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue