mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 19:15:06 +00:00
LibGUI: Put all classes in the GUI namespace and remove the leading G
This took me a moment. Welcome to the new world of GUI::Widget! :^)
This commit is contained in:
parent
2d39da5405
commit
c5bd9d4ed1
337 changed files with 5400 additions and 4816 deletions
|
@ -36,26 +36,28 @@
|
|||
#include <LibGUI/GTextDocument.h>
|
||||
#include <LibGUI/GTextRange.h>
|
||||
|
||||
class GAction;
|
||||
class GMenu;
|
||||
class GScrollBar;
|
||||
class Painter;
|
||||
namespace GUI {
|
||||
|
||||
class GTextEditor
|
||||
: public GScrollableWidget
|
||||
, public GTextDocument::Client {
|
||||
C_OBJECT(GTextEditor)
|
||||
class Action;
|
||||
class Menu;
|
||||
class Painter;
|
||||
class ScrollBar;
|
||||
|
||||
class TextEditor
|
||||
: public ScrollableWidget
|
||||
, public TextDocument::Client {
|
||||
C_OBJECT(TextEditor)
|
||||
public:
|
||||
enum Type {
|
||||
MultiLine,
|
||||
SingleLine
|
||||
};
|
||||
virtual ~GTextEditor() override;
|
||||
virtual ~TextEditor() override;
|
||||
|
||||
const GTextDocument& document() const { return *m_document; }
|
||||
GTextDocument& document() { return *m_document; }
|
||||
const TextDocument& document() const { return *m_document; }
|
||||
TextDocument& document() { return *m_document; }
|
||||
|
||||
void set_document(GTextDocument&);
|
||||
void set_document(TextDocument&);
|
||||
|
||||
bool is_readonly() const { return m_readonly; }
|
||||
void set_readonly(bool);
|
||||
|
@ -83,12 +85,12 @@ public:
|
|||
|
||||
void set_text(const StringView&);
|
||||
void scroll_cursor_into_view();
|
||||
void scroll_position_into_view(const GTextPosition&);
|
||||
void scroll_position_into_view(const TextPosition&);
|
||||
size_t line_count() const { return document().line_count(); }
|
||||
int line_spacing() const { return m_line_spacing; }
|
||||
int line_height() const { return font().glyph_height() + m_line_spacing; }
|
||||
GTextPosition cursor() const { return m_cursor; }
|
||||
GTextRange normalized_selection() const { return m_selection.normalized(); }
|
||||
TextPosition cursor() const { return m_cursor; }
|
||||
TextRange normalized_selection() const { return m_selection.normalized(); }
|
||||
// FIXME: This should take glyph spacing into account, no?
|
||||
int glyph_width() const { return font().glyph_width('x'); }
|
||||
|
||||
|
@ -96,7 +98,7 @@ public:
|
|||
bool write_to_file(const StringView& path);
|
||||
bool has_selection() const { return m_selection.is_valid(); }
|
||||
String selected_text() const;
|
||||
void set_selection(const GTextRange&);
|
||||
void set_selection(const TextRange&);
|
||||
void clear_selection();
|
||||
bool can_undo() const { return document().can_undo(); }
|
||||
bool can_redo() const { return document().can_redo(); }
|
||||
|
@ -118,53 +120,53 @@ public:
|
|||
Function<void()> on_return_pressed;
|
||||
Function<void()> on_escape_pressed;
|
||||
|
||||
GAction& undo_action() { return *m_undo_action; }
|
||||
GAction& redo_action() { return *m_redo_action; }
|
||||
GAction& cut_action() { return *m_cut_action; }
|
||||
GAction& copy_action() { return *m_copy_action; }
|
||||
GAction& paste_action() { return *m_paste_action; }
|
||||
GAction& delete_action() { return *m_delete_action; }
|
||||
GAction& go_to_line_action() { return *m_go_to_line_action; }
|
||||
Action& undo_action() { return *m_undo_action; }
|
||||
Action& redo_action() { return *m_redo_action; }
|
||||
Action& cut_action() { return *m_cut_action; }
|
||||
Action& copy_action() { return *m_copy_action; }
|
||||
Action& paste_action() { return *m_paste_action; }
|
||||
Action& delete_action() { return *m_delete_action; }
|
||||
Action& go_to_line_action() { return *m_go_to_line_action; }
|
||||
|
||||
void add_custom_context_menu_action(GAction&);
|
||||
void add_custom_context_menu_action(Action&);
|
||||
|
||||
void set_cursor(size_t line, size_t column);
|
||||
void set_cursor(const GTextPosition&);
|
||||
void set_cursor(const TextPosition&);
|
||||
|
||||
protected:
|
||||
explicit GTextEditor(GWidget* parent);
|
||||
explicit GTextEditor(Type, GWidget* parent);
|
||||
explicit TextEditor(Widget* parent);
|
||||
explicit TextEditor(Type, Widget* parent);
|
||||
|
||||
virtual void did_change_font() override;
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
virtual void mouseup_event(GMouseEvent&) override;
|
||||
virtual void mousemove_event(GMouseEvent&) override;
|
||||
virtual void doubleclick_event(GMouseEvent&) override;
|
||||
virtual void keydown_event(GKeyEvent&) override;
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
virtual void mousedown_event(MouseEvent&) override;
|
||||
virtual void mouseup_event(MouseEvent&) override;
|
||||
virtual void mousemove_event(MouseEvent&) override;
|
||||
virtual void doubleclick_event(MouseEvent&) override;
|
||||
virtual void keydown_event(KeyEvent&) override;
|
||||
virtual void focusin_event(Core::Event&) override;
|
||||
virtual void focusout_event(Core::Event&) override;
|
||||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
virtual bool accepts_focus() const override { return true; }
|
||||
virtual void enter_event(Core::Event&) override;
|
||||
virtual void leave_event(Core::Event&) override;
|
||||
virtual void context_menu_event(GContextMenuEvent&) override;
|
||||
virtual void resize_event(GResizeEvent&) override;
|
||||
virtual void context_menu_event(ContextMenuEvent&) override;
|
||||
virtual void resize_event(ResizeEvent&) override;
|
||||
virtual void cursor_did_change() {}
|
||||
|
||||
GTextPosition text_position_at(const Point&) const;
|
||||
TextPosition text_position_at(const Point&) const;
|
||||
|
||||
private:
|
||||
friend class GTextDocumentLine;
|
||||
friend class TextDocumentLine;
|
||||
|
||||
// ^GTextDocument::Client
|
||||
// ^TextDocument::Client
|
||||
virtual void document_did_append_line() override;
|
||||
virtual void document_did_insert_line(size_t) override;
|
||||
virtual void document_did_remove_line(size_t) override;
|
||||
virtual void document_did_remove_all_lines() override;
|
||||
virtual void document_did_change() override;
|
||||
virtual void document_did_set_text() override;
|
||||
virtual void document_did_set_cursor(const GTextPosition&) override;
|
||||
virtual void document_did_set_cursor(const TextPosition&) override;
|
||||
|
||||
void create_actions();
|
||||
void paint_ruler(Painter&);
|
||||
|
@ -174,20 +176,20 @@ private:
|
|||
Rect line_content_rect(size_t item_index) const;
|
||||
Rect line_widget_rect(size_t line_index) const;
|
||||
Rect cursor_content_rect() const;
|
||||
Rect content_rect_for_position(const GTextPosition&) const;
|
||||
Rect content_rect_for_position(const TextPosition&) const;
|
||||
void update_cursor();
|
||||
const NonnullOwnPtrVector<GTextDocumentLine>& lines() const { return document().lines(); }
|
||||
NonnullOwnPtrVector<GTextDocumentLine>& lines() { return document().lines(); }
|
||||
GTextDocumentLine& line(size_t index) { return document().line(index); }
|
||||
const GTextDocumentLine& line(size_t index) const { return document().line(index); }
|
||||
GTextDocumentLine& current_line() { return line(m_cursor.line()); }
|
||||
const GTextDocumentLine& current_line() const { return line(m_cursor.line()); }
|
||||
const NonnullOwnPtrVector<TextDocumentLine>& lines() const { return document().lines(); }
|
||||
NonnullOwnPtrVector<TextDocumentLine>& lines() { return document().lines(); }
|
||||
TextDocumentLine& line(size_t index) { return document().line(index); }
|
||||
const TextDocumentLine& line(size_t index) const { return document().line(index); }
|
||||
TextDocumentLine& current_line() { return line(m_cursor.line()); }
|
||||
const TextDocumentLine& current_line() const { return line(m_cursor.line()); }
|
||||
int ruler_width() const;
|
||||
Rect ruler_content_rect(size_t line) const;
|
||||
void toggle_selection_if_needed_for_event(const GKeyEvent&);
|
||||
void toggle_selection_if_needed_for_event(const KeyEvent&);
|
||||
void delete_selection();
|
||||
void did_update_selection();
|
||||
int content_x_for_position(const GTextPosition&) const;
|
||||
int content_x_for_position(const TextPosition&) const;
|
||||
Rect ruler_rect_in_inner_coordinates() const;
|
||||
Rect visible_text_rect_in_inner_coordinates() const;
|
||||
void recompute_all_visual_lines();
|
||||
|
@ -211,7 +213,7 @@ private:
|
|||
|
||||
Type m_type { MultiLine };
|
||||
|
||||
GTextPosition m_cursor;
|
||||
TextPosition m_cursor;
|
||||
TextAlignment m_text_alignment { TextAlignment::CenterLeft };
|
||||
bool m_cursor_state { true };
|
||||
bool m_in_drag_select { false };
|
||||
|
@ -223,19 +225,19 @@ private:
|
|||
int m_line_spacing { 4 };
|
||||
size_t m_soft_tab_width { 4 };
|
||||
int m_horizontal_content_padding { 2 };
|
||||
GTextRange m_selection;
|
||||
RefPtr<GMenu> m_context_menu;
|
||||
RefPtr<GAction> m_undo_action;
|
||||
RefPtr<GAction> m_redo_action;
|
||||
RefPtr<GAction> m_cut_action;
|
||||
RefPtr<GAction> m_copy_action;
|
||||
RefPtr<GAction> m_paste_action;
|
||||
RefPtr<GAction> m_delete_action;
|
||||
RefPtr<GAction> m_go_to_line_action;
|
||||
TextRange m_selection;
|
||||
RefPtr<Menu> m_context_menu;
|
||||
RefPtr<Action> m_undo_action;
|
||||
RefPtr<Action> m_redo_action;
|
||||
RefPtr<Action> m_cut_action;
|
||||
RefPtr<Action> m_copy_action;
|
||||
RefPtr<Action> m_paste_action;
|
||||
RefPtr<Action> m_delete_action;
|
||||
RefPtr<Action> m_go_to_line_action;
|
||||
Core::ElapsedTimer m_triple_click_timer;
|
||||
NonnullRefPtrVector<GAction> m_custom_context_menu_actions;
|
||||
NonnullRefPtrVector<Action> m_custom_context_menu_actions;
|
||||
|
||||
RefPtr<GTextDocument> m_document;
|
||||
RefPtr<TextDocument> m_document;
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_visual_line(size_t line_index, Callback) const;
|
||||
|
@ -247,3 +249,5 @@ private:
|
|||
|
||||
NonnullOwnPtrVector<LineVisualData> m_line_visual_data;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue