2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2018-10-10 15:12:38 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2021-03-07 03:24:20 -08:00
|
|
|
#include <AK/EnumBits.h>
|
2020-09-25 20:41:30 +02:00
|
|
|
#include <AK/JsonObject.h>
|
2019-11-10 10:58:03 +01:00
|
|
|
#include <AK/String.h>
|
2020-02-06 15:04:03 +01:00
|
|
|
#include <LibCore/Object.h>
|
2020-02-14 23:53:11 +01:00
|
|
|
#include <LibGUI/Event.h>
|
2020-02-16 09:17:49 +01:00
|
|
|
#include <LibGUI/Forward.h>
|
2020-04-24 18:55:29 +02:00
|
|
|
#include <LibGUI/Margins.h>
|
2020-02-06 12:04:00 +01:00
|
|
|
#include <LibGfx/Color.h>
|
2020-02-14 23:53:11 +01:00
|
|
|
#include <LibGfx/Forward.h>
|
2020-02-06 12:04:00 +01:00
|
|
|
#include <LibGfx/Orientation.h>
|
|
|
|
|
#include <LibGfx/Rect.h>
|
2020-09-11 14:17:35 +02:00
|
|
|
#include <LibGfx/StandardCursor.h>
|
2018-10-10 15:12:38 +02:00
|
|
|
|
2021-04-04 15:40:34 -06:00
|
|
|
namespace Core {
|
|
|
|
|
namespace Registration {
|
|
|
|
|
extern Core::ObjectClassRegistration registration_Widget;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define REGISTER_WIDGET(namespace_, class_name) \
|
|
|
|
|
namespace Core { \
|
|
|
|
|
namespace Registration { \
|
|
|
|
|
Core::ObjectClassRegistration registration_##class_name( \
|
|
|
|
|
#namespace_ "::" #class_name, []() { return static_ptr_cast<Core::Object>(namespace_::class_name::construct()); }, ®istration_Widget); \
|
|
|
|
|
} \
|
2021-01-02 16:30:13 -07:00
|
|
|
}
|
2020-02-02 15:07:41 +01:00
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
|
2019-06-07 17:13:23 +02:00
|
|
|
enum class HorizontalDirection {
|
2019-05-28 11:53:16 +02:00
|
|
|
Left,
|
|
|
|
|
Right
|
|
|
|
|
};
|
2021-09-18 12:16:57 +02:00
|
|
|
|
2019-06-07 17:13:23 +02:00
|
|
|
enum class VerticalDirection {
|
2019-05-28 11:53:16 +02:00
|
|
|
Up,
|
|
|
|
|
Down
|
|
|
|
|
};
|
2019-02-10 11:07:13 +01:00
|
|
|
|
2020-10-30 10:58:27 +01:00
|
|
|
enum class FocusPolicy {
|
|
|
|
|
NoFocus = 0,
|
|
|
|
|
TabFocus = 0x1,
|
|
|
|
|
ClickFocus = 0x2,
|
|
|
|
|
StrongFocus = TabFocus | ClickFocus,
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-07 03:24:20 -08:00
|
|
|
AK_ENUM_BITWISE_OPERATORS(FocusPolicy)
|
|
|
|
|
|
2021-09-18 12:16:57 +02:00
|
|
|
enum class CallOnChange {
|
|
|
|
|
No,
|
|
|
|
|
Yes
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class Widget : public Core::Object {
|
|
|
|
|
C_OBJECT(Widget)
|
2018-10-10 15:12:38 +02:00
|
|
|
public:
|
2020-02-02 15:07:41 +01:00
|
|
|
virtual ~Widget() override;
|
2019-01-20 04:49:48 +01:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
Layout* layout() { return m_layout.ptr(); }
|
|
|
|
|
const Layout* layout() const { return m_layout.ptr(); }
|
2020-03-05 09:21:46 +01:00
|
|
|
void set_layout(NonnullRefPtr<Layout>);
|
2019-02-10 11:07:13 +01:00
|
|
|
|
2020-03-05 09:21:46 +01:00
|
|
|
template<class T, class... Args>
|
|
|
|
|
inline T& set_layout(Args&&... args)
|
2020-03-03 21:42:48 +01:00
|
|
|
{
|
2020-03-05 09:21:46 +01:00
|
|
|
auto layout = T::construct(forward<Args>(args)...);
|
|
|
|
|
set_layout(*layout);
|
|
|
|
|
return layout;
|
2020-03-03 21:42:48 +01:00
|
|
|
}
|
|
|
|
|
|
2020-12-29 18:22:51 +01:00
|
|
|
Gfx::IntSize min_size() const { return m_min_size; }
|
|
|
|
|
void set_min_size(const Gfx::IntSize&);
|
|
|
|
|
void set_min_size(int width, int height) { set_min_size({ width, height }); }
|
|
|
|
|
|
|
|
|
|
int min_width() const { return m_min_size.width(); }
|
|
|
|
|
int min_height() const { return m_min_size.height(); }
|
|
|
|
|
void set_min_width(int width) { set_min_size(width, min_height()); }
|
|
|
|
|
void set_min_height(int height) { set_min_size(min_width(), height); }
|
|
|
|
|
|
|
|
|
|
Gfx::IntSize max_size() const { return m_max_size; }
|
|
|
|
|
void set_max_size(const Gfx::IntSize&);
|
|
|
|
|
void set_max_size(int width, int height) { set_max_size({ width, height }); }
|
|
|
|
|
|
|
|
|
|
int max_width() const { return m_max_size.width(); }
|
|
|
|
|
int max_height() const { return m_max_size.height(); }
|
|
|
|
|
void set_max_width(int width) { set_max_size(width, max_height()); }
|
|
|
|
|
void set_max_height(int height) { set_max_size(max_width(), height); }
|
|
|
|
|
|
2020-12-29 18:46:42 +01:00
|
|
|
void set_fixed_size(const Gfx::IntSize& size)
|
|
|
|
|
{
|
|
|
|
|
set_min_size(size);
|
|
|
|
|
set_max_size(size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_fixed_size(int width, int height) { set_fixed_size({ width, height }); }
|
|
|
|
|
|
|
|
|
|
void set_fixed_width(int width)
|
|
|
|
|
{
|
|
|
|
|
set_min_width(width);
|
|
|
|
|
set_max_width(width);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_fixed_height(int height)
|
|
|
|
|
{
|
|
|
|
|
set_min_height(height);
|
|
|
|
|
set_max_height(height);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-05 18:47:54 +02:00
|
|
|
virtual bool is_visible_for_timer_purposes() const override;
|
|
|
|
|
|
2019-04-08 18:58:44 +02:00
|
|
|
bool has_tooltip() const { return !m_tooltip.is_empty(); }
|
|
|
|
|
String tooltip() const { return m_tooltip; }
|
2021-04-16 19:12:37 +02:00
|
|
|
void set_tooltip(String);
|
2019-04-08 18:58:44 +02:00
|
|
|
|
2021-08-15 15:40:08 +10:00
|
|
|
bool is_auto_focusable() const { return m_auto_focusable; }
|
|
|
|
|
void set_auto_focusable(bool auto_focusable) { m_auto_focusable = auto_focusable; }
|
|
|
|
|
|
2019-04-12 02:51:16 +02:00
|
|
|
bool is_enabled() const { return m_enabled; }
|
|
|
|
|
void set_enabled(bool);
|
|
|
|
|
|
2019-05-02 03:46:37 +02:00
|
|
|
bool updates_enabled() const { return m_updates_enabled; }
|
|
|
|
|
void set_updates_enabled(bool);
|
|
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntRect relative_rect() const { return m_relative_rect; }
|
|
|
|
|
Gfx::IntPoint relative_position() const { return m_relative_rect.location(); }
|
2019-01-21 00:46:08 +01:00
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntRect window_relative_rect() const;
|
|
|
|
|
Gfx::IntRect screen_relative_rect() const;
|
2019-02-09 14:30:05 +01:00
|
|
|
|
2019-01-21 00:46:08 +01:00
|
|
|
int x() const { return m_relative_rect.x(); }
|
|
|
|
|
int y() const { return m_relative_rect.y(); }
|
|
|
|
|
int width() const { return m_relative_rect.width(); }
|
|
|
|
|
int height() const { return m_relative_rect.height(); }
|
2019-07-01 02:46:36 -05:00
|
|
|
int length(Orientation orientation) const { return orientation == Orientation::Vertical ? height() : width(); }
|
2018-10-12 14:15:14 +02:00
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntRect rect() const { return { 0, 0, width(), height() }; }
|
|
|
|
|
Gfx::IntSize size() const { return m_relative_rect.size(); }
|
2018-10-10 16:49:36 +02:00
|
|
|
|
2018-10-10 15:12:38 +02:00
|
|
|
void update();
|
2020-06-10 10:57:59 +02:00
|
|
|
void update(const Gfx::IntRect&);
|
2018-10-10 15:12:38 +02:00
|
|
|
|
2019-01-21 00:46:08 +01:00
|
|
|
bool is_focused() const;
|
2020-08-14 19:56:40 +02:00
|
|
|
void set_focus(bool, FocusSource = FocusSource::Programmatic);
|
2018-10-13 17:52:47 +02:00
|
|
|
|
2020-12-10 14:18:29 +10:00
|
|
|
Function<void(const bool, const FocusSource)> on_focus_change;
|
|
|
|
|
|
2020-10-30 23:38:42 +01:00
|
|
|
// Returns true if this widget or one of its descendants is focused.
|
|
|
|
|
bool has_focus_within() const;
|
|
|
|
|
|
2020-08-25 11:21:49 +02:00
|
|
|
Widget* focus_proxy() { return m_focus_proxy; }
|
|
|
|
|
const Widget* focus_proxy() const { return m_focus_proxy; }
|
|
|
|
|
void set_focus_proxy(Widget*);
|
|
|
|
|
|
2020-10-30 10:58:27 +01:00
|
|
|
void set_focus_policy(FocusPolicy policy);
|
|
|
|
|
FocusPolicy focus_policy() const;
|
|
|
|
|
|
2021-01-08 23:50:03 +01:00
|
|
|
enum class ShouldRespectGreediness {
|
|
|
|
|
No = 0,
|
|
|
|
|
Yes
|
|
|
|
|
};
|
2018-10-10 16:49:36 +02:00
|
|
|
struct HitTestResult {
|
2021-01-08 23:50:03 +01:00
|
|
|
WeakPtr<Widget> widget;
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntPoint local_position;
|
2018-10-10 16:49:36 +02:00
|
|
|
};
|
2020-06-10 10:57:59 +02:00
|
|
|
HitTestResult hit_test(const Gfx::IntPoint&, ShouldRespectGreediness = ShouldRespectGreediness::Yes);
|
|
|
|
|
Widget* child_at(const Gfx::IntPoint&) const;
|
2019-04-16 03:47:55 +02:00
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
void set_relative_rect(const Gfx::IntRect&);
|
2019-02-09 11:19:38 +01:00
|
|
|
void set_relative_rect(int x, int y, int width, int height) { set_relative_rect({ x, y, width, height }); }
|
2019-02-08 00:14:37 +01:00
|
|
|
|
2019-04-14 04:10:43 +02:00
|
|
|
void set_x(int x) { set_relative_rect(x, y(), width(), height()); }
|
|
|
|
|
void set_y(int y) { set_relative_rect(x(), y, width(), height()); }
|
|
|
|
|
void set_width(int width) { set_relative_rect(x(), y(), width, height()); }
|
|
|
|
|
void set_height(int height) { set_relative_rect(x(), y(), width(), height); }
|
|
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
void move_to(const Gfx::IntPoint& point) { set_relative_rect({ point, relative_rect().size() }); }
|
2019-02-08 00:14:37 +01:00
|
|
|
void move_to(int x, int y) { move_to({ x, y }); }
|
2020-06-10 10:57:59 +02:00
|
|
|
void resize(const Gfx::IntSize& size) { set_relative_rect({ relative_rect().location(), size }); }
|
2019-02-08 00:14:37 +01:00
|
|
|
void resize(int width, int height) { resize({ width, height }); }
|
2018-10-10 16:49:36 +02:00
|
|
|
|
2019-04-16 22:59:27 +02:00
|
|
|
void move_by(int x, int y) { move_by({ x, y }); }
|
2020-06-10 10:57:59 +02:00
|
|
|
void move_by(const Gfx::IntPoint& delta) { set_relative_rect({ relative_position().translated(delta), size() }); }
|
2019-04-16 22:59:27 +02:00
|
|
|
|
2020-02-14 23:53:11 +01:00
|
|
|
Gfx::ColorRole background_role() const { return m_background_role; }
|
|
|
|
|
void set_background_role(Gfx::ColorRole);
|
2019-12-24 20:57:54 +01:00
|
|
|
|
2020-02-14 23:53:11 +01:00
|
|
|
Gfx::ColorRole foreground_role() const { return m_foreground_role; }
|
|
|
|
|
void set_foreground_role(Gfx::ColorRole);
|
2019-12-24 20:57:54 +01:00
|
|
|
|
2019-07-10 21:12:09 +02:00
|
|
|
void set_autofill(bool b) { set_fill_with_background_color(b); }
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
Window* window()
|
2018-10-12 01:03:22 +02:00
|
|
|
{
|
2019-01-21 00:46:08 +01:00
|
|
|
if (auto* pw = parent_widget())
|
2018-10-12 01:03:22 +02:00
|
|
|
return pw->window();
|
|
|
|
|
return m_window;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
const Window* window() const
|
2018-10-12 01:03:22 +02:00
|
|
|
{
|
2019-01-21 00:46:08 +01:00
|
|
|
if (auto* pw = parent_widget())
|
2018-10-12 01:03:22 +02:00
|
|
|
return pw->window();
|
|
|
|
|
return m_window;
|
|
|
|
|
}
|
2018-10-11 16:52:40 +02:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
void set_window(Window*);
|
2018-10-12 02:41:27 +02:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
Widget* parent_widget();
|
|
|
|
|
const Widget* parent_widget() const;
|
2018-10-11 16:52:40 +02:00
|
|
|
|
2019-01-21 00:46:08 +01:00
|
|
|
void set_fill_with_background_color(bool b) { m_fill_with_background_color = b; }
|
|
|
|
|
bool fill_with_background_color() const { return m_fill_with_background_color; }
|
2018-10-14 00:21:42 +02:00
|
|
|
|
2020-02-06 11:56:38 +01:00
|
|
|
const Gfx::Font& font() const { return *m_font; }
|
2021-03-22 19:51:06 +00:00
|
|
|
|
2020-02-06 11:56:38 +01:00
|
|
|
void set_font(const Gfx::Font*);
|
|
|
|
|
void set_font(const Gfx::Font& font) { set_font(&font); }
|
2018-10-14 13:06:05 +02:00
|
|
|
|
2021-03-22 19:51:06 +00:00
|
|
|
void set_font_family(const String&);
|
|
|
|
|
void set_font_size(unsigned);
|
|
|
|
|
void set_font_weight(unsigned);
|
|
|
|
|
void set_font_fixed_width(bool);
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
void notify_layout_changed(Badge<Layout>);
|
2019-03-30 13:53:30 +01:00
|
|
|
void invalidate_layout();
|
2019-02-10 11:07:13 +01:00
|
|
|
|
2019-03-15 16:12:06 +01:00
|
|
|
bool is_visible() const { return m_visible; }
|
|
|
|
|
void set_visible(bool);
|
|
|
|
|
|
2019-03-29 02:20:22 +01:00
|
|
|
bool spans_entire_window_horizontally() const;
|
|
|
|
|
|
2019-04-11 03:34:37 +02:00
|
|
|
bool is_greedy_for_hits() const { return m_greedy_for_hits; }
|
|
|
|
|
void set_greedy_for_hits(bool b) { m_greedy_for_hits = b; }
|
|
|
|
|
|
2019-04-16 03:47:55 +02:00
|
|
|
void move_to_front();
|
|
|
|
|
void move_to_back();
|
|
|
|
|
|
|
|
|
|
bool is_frontmost() const;
|
|
|
|
|
bool is_backmost() const;
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
Action* action_for_key_event(const KeyEvent&);
|
2019-04-20 21:56:56 +02:00
|
|
|
|
2019-05-27 03:52:33 +02:00
|
|
|
template<typename Callback>
|
|
|
|
|
void for_each_child_widget(Callback callback)
|
|
|
|
|
{
|
2019-05-28 11:53:16 +02:00
|
|
|
for_each_child([&](auto& child) {
|
2020-07-26 17:16:35 +02:00
|
|
|
if (is<Widget>(child))
|
2021-06-24 19:53:42 +02:00
|
|
|
return callback(verify_cast<Widget>(child));
|
2019-05-27 03:52:33 +02:00
|
|
|
return IterationDecision::Continue;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 19:36:27 +04:30
|
|
|
Vector<Widget&> child_widgets() const;
|
2019-11-11 19:12:32 +01:00
|
|
|
|
2019-10-26 12:27:01 +02:00
|
|
|
void do_layout();
|
|
|
|
|
|
2020-02-14 23:53:11 +01:00
|
|
|
Gfx::Palette palette() const;
|
|
|
|
|
void set_palette(const Gfx::Palette&);
|
2019-12-24 20:57:54 +01:00
|
|
|
|
2020-04-24 18:55:29 +02:00
|
|
|
const Margins& content_margins() const { return m_content_margins; }
|
|
|
|
|
void set_content_margins(const Margins&);
|
|
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntRect content_rect() const;
|
2020-04-24 18:55:29 +02:00
|
|
|
|
2020-05-17 21:49:54 +02:00
|
|
|
void set_accepts_emoji_input(bool b) { m_accepts_emoji_input = b; }
|
|
|
|
|
bool accepts_emoji_input() const { return m_accepts_emoji_input; }
|
|
|
|
|
|
2020-08-25 21:24:45 +02:00
|
|
|
virtual Gfx::IntRect children_clip_rect() const;
|
|
|
|
|
|
2020-09-11 14:17:35 +02:00
|
|
|
Gfx::StandardCursor override_cursor() const { return m_override_cursor; }
|
|
|
|
|
void set_override_cursor(Gfx::StandardCursor);
|
|
|
|
|
|
2020-12-20 11:47:44 +01:00
|
|
|
bool load_from_gml(const StringView&);
|
2021-04-04 15:40:34 -06:00
|
|
|
bool load_from_gml(const StringView&, RefPtr<Core::Object> (*unregistered_child_handler)(const String&));
|
2020-12-20 11:47:44 +01:00
|
|
|
|
2021-01-04 18:17:14 +01:00
|
|
|
void set_shrink_to_fit(bool);
|
|
|
|
|
bool is_shrink_to_fit() const { return m_shrink_to_fit; }
|
|
|
|
|
|
2021-01-09 00:11:17 +01:00
|
|
|
bool has_pending_drop() const;
|
|
|
|
|
|
2019-09-01 20:51:20 +02:00
|
|
|
protected:
|
2020-02-23 12:07:13 +01:00
|
|
|
Widget();
|
2019-09-21 17:05:35 +02:00
|
|
|
|
2021-03-28 11:25:40 +02:00
|
|
|
virtual void event(Core::Event&) override;
|
|
|
|
|
|
|
|
|
|
// This is called after children have been painted.
|
|
|
|
|
virtual void second_paint_event(PaintEvent&);
|
|
|
|
|
|
2020-07-26 17:16:35 +02:00
|
|
|
virtual void custom_layout() { }
|
|
|
|
|
virtual void did_change_font() { }
|
|
|
|
|
virtual void did_layout() { }
|
2020-02-02 15:07:41 +01:00
|
|
|
virtual void paint_event(PaintEvent&);
|
|
|
|
|
virtual void resize_event(ResizeEvent&);
|
|
|
|
|
virtual void show_event(ShowEvent&);
|
|
|
|
|
virtual void hide_event(HideEvent&);
|
|
|
|
|
virtual void keydown_event(KeyEvent&);
|
|
|
|
|
virtual void keyup_event(KeyEvent&);
|
|
|
|
|
virtual void mousemove_event(MouseEvent&);
|
|
|
|
|
virtual void mousedown_event(MouseEvent&);
|
|
|
|
|
virtual void mouseup_event(MouseEvent&);
|
|
|
|
|
virtual void mousewheel_event(MouseEvent&);
|
|
|
|
|
virtual void doubleclick_event(MouseEvent&);
|
|
|
|
|
virtual void context_menu_event(ContextMenuEvent&);
|
2020-08-14 19:56:40 +02:00
|
|
|
virtual void focusin_event(FocusEvent&);
|
|
|
|
|
virtual void focusout_event(FocusEvent&);
|
2020-02-02 12:34:39 +01:00
|
|
|
virtual void enter_event(Core::Event&);
|
|
|
|
|
virtual void leave_event(Core::Event&);
|
|
|
|
|
virtual void child_event(Core::ChildEvent&) override;
|
2020-02-02 15:07:41 +01:00
|
|
|
virtual void change_event(Event&);
|
2021-01-08 22:23:06 +01:00
|
|
|
virtual void drag_enter_event(DragEvent&);
|
2020-02-13 21:43:32 +01:00
|
|
|
virtual void drag_move_event(DragEvent&);
|
2021-01-08 22:23:06 +01:00
|
|
|
virtual void drag_leave_event(Event&);
|
2020-02-02 15:07:41 +01:00
|
|
|
virtual void drop_event(DropEvent&);
|
2020-03-16 13:36:21 +02:00
|
|
|
virtual void theme_change_event(ThemeChangeEvent&);
|
2021-07-12 09:57:34 +02:00
|
|
|
virtual void fonts_change_event(FontsChangeEvent&);
|
2021-06-13 06:16:06 -06:00
|
|
|
virtual void screen_rects_change_event(ScreenRectsChangeEvent&);
|
2021-08-24 13:01:01 +01:00
|
|
|
virtual void applet_area_rect_change_event(AppletAreaRectChangeEvent&);
|
2019-09-01 12:26:35 +02:00
|
|
|
|
2020-03-05 14:42:05 +01:00
|
|
|
virtual void did_begin_inspection() override;
|
|
|
|
|
virtual void did_end_inspection() override;
|
|
|
|
|
|
2021-01-03 17:21:12 +01:00
|
|
|
void show_or_hide_tooltip();
|
|
|
|
|
|
2018-10-10 15:12:38 +02:00
|
|
|
private:
|
2020-02-02 15:07:41 +01:00
|
|
|
void handle_paint_event(PaintEvent&);
|
|
|
|
|
void handle_resize_event(ResizeEvent&);
|
|
|
|
|
void handle_mousedown_event(MouseEvent&);
|
|
|
|
|
void handle_mousedoubleclick_event(MouseEvent&);
|
|
|
|
|
void handle_mouseup_event(MouseEvent&);
|
2021-02-13 15:23:13 +01:00
|
|
|
void handle_keydown_event(KeyEvent&);
|
2020-02-02 12:34:39 +01:00
|
|
|
void handle_enter_event(Core::Event&);
|
|
|
|
|
void handle_leave_event(Core::Event&);
|
2021-01-02 01:54:30 +01:00
|
|
|
void focus_previous_widget(FocusSource, bool siblings_only);
|
|
|
|
|
void focus_next_widget(FocusSource, bool siblings_only);
|
2019-02-09 11:19:38 +01:00
|
|
|
|
2021-04-04 15:40:34 -06:00
|
|
|
virtual bool load_from_json(const JsonObject&, RefPtr<Core::Object> (*unregistered_child_handler)(const String&)) override;
|
2020-12-20 11:47:44 +01:00
|
|
|
|
2020-12-29 18:46:42 +01:00
|
|
|
// HACK: These are used as property getters for the fixed_* size property aliases.
|
|
|
|
|
int dummy_fixed_width() { return 0; }
|
|
|
|
|
int dummy_fixed_height() { return 0; }
|
|
|
|
|
Gfx::IntSize dummy_fixed_size() { return {}; }
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
Window* m_window { nullptr };
|
2020-03-05 09:21:46 +01:00
|
|
|
RefPtr<Layout> m_layout;
|
2018-10-12 01:03:22 +02:00
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
Gfx::IntRect m_relative_rect;
|
2020-02-14 23:53:11 +01:00
|
|
|
Gfx::ColorRole m_background_role;
|
|
|
|
|
Gfx::ColorRole m_foreground_role;
|
2020-02-06 11:56:38 +01:00
|
|
|
NonnullRefPtr<Gfx::Font> m_font;
|
2019-04-08 18:58:44 +02:00
|
|
|
String m_tooltip;
|
2018-10-11 12:33:03 +02:00
|
|
|
|
2020-12-29 18:22:51 +01:00
|
|
|
Gfx::IntSize m_min_size { -1, -1 };
|
|
|
|
|
Gfx::IntSize m_max_size { -1, -1 };
|
2020-04-24 18:55:29 +02:00
|
|
|
Margins m_content_margins;
|
2019-02-10 11:07:13 +01:00
|
|
|
|
2019-03-10 13:16:36 +01:00
|
|
|
bool m_fill_with_background_color { false };
|
2019-03-15 16:12:06 +01:00
|
|
|
bool m_visible { true };
|
2019-04-11 03:34:37 +02:00
|
|
|
bool m_greedy_for_hits { false };
|
2021-08-15 15:40:08 +10:00
|
|
|
bool m_auto_focusable { true };
|
2019-04-12 02:51:16 +02:00
|
|
|
bool m_enabled { true };
|
2019-05-02 03:46:37 +02:00
|
|
|
bool m_updates_enabled { true };
|
2020-05-17 21:49:54 +02:00
|
|
|
bool m_accepts_emoji_input { false };
|
2021-01-04 18:17:14 +01:00
|
|
|
bool m_shrink_to_fit { false };
|
2021-07-12 10:05:05 +02:00
|
|
|
bool m_default_font { true };
|
2019-03-25 01:42:15 +01:00
|
|
|
|
2020-02-06 11:56:38 +01:00
|
|
|
NonnullRefPtr<Gfx::PaletteImpl> m_palette;
|
2020-08-25 11:21:49 +02:00
|
|
|
|
|
|
|
|
WeakPtr<Widget> m_focus_proxy;
|
2020-10-30 10:58:27 +01:00
|
|
|
FocusPolicy m_focus_policy { FocusPolicy::NoFocus };
|
2020-09-11 14:17:35 +02:00
|
|
|
|
|
|
|
|
Gfx::StandardCursor m_override_cursor { Gfx::StandardCursor::None };
|
2018-10-10 15:12:38 +02:00
|
|
|
};
|
2019-05-27 04:06:01 +02:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
inline Widget* Widget::parent_widget()
|
2019-05-27 04:06:01 +02:00
|
|
|
{
|
2020-07-26 17:16:35 +02:00
|
|
|
if (parent() && is<Widget>(*parent()))
|
2021-06-24 19:53:42 +02:00
|
|
|
return &verify_cast<Widget>(*parent());
|
2019-05-27 04:06:01 +02:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
2020-02-02 15:07:41 +01:00
|
|
|
inline const Widget* Widget::parent_widget() const
|
2019-05-27 04:06:01 +02:00
|
|
|
{
|
2020-07-26 17:16:35 +02:00
|
|
|
if (parent() && is<Widget>(*parent()))
|
2021-06-24 19:53:42 +02:00
|
|
|
return &verify_cast<const Widget>(*parent());
|
2019-05-27 04:06:01 +02:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
2020-02-02 15:07:41 +01:00
|
|
|
}
|
2021-01-09 00:12:42 +01:00
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
struct AK::Formatter<GUI::Widget> : AK::Formatter<Core::Object> {
|
|
|
|
|
};
|