diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-12-16 11:02:00 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-12-17 22:54:10 +0100 |
commit | 7056ea9c29c7e454c21b525e61cdc1e0c03f7301 (patch) | |
tree | aa39e77d1d420892312288ace9cf9ae89d71282c /vcl/inc/salvtables.hxx | |
parent | 13bdc2ba0cec0cb1c9e8077eb2217f69822a805f (diff) |
weld: Add weld::Grid to handle grid child positions
Currently, weld::Widget provides methods that can
be used to retrieve and change the position (and column
span) of widgets that are located inside of a grid
(parent), e.g. weld::Widget::set_grid_left_attach
to set the column.
These methods however only make sense for widgets
that are actually direct children of a grid, not
for any "random" weld::Widget.
Generally, it's the grid's responsibility to manage
child positions, and the gtk3/gtk4 implementations
actually assume that the parent is a GtkGrid, retrieve
that parent and then call the corresponding GTK API
functions for that grid.
Align the weld API more with the concept of the
grid being responsible for positioning its children
by introducing a new weld::Grid class with methods
equivalent to the current weld::Widget ones, but that
take the child widget as an additional parameter.
Take over the existing logic from the corresponding
weld::Widget methods for both, the gtk and vcl implementations
(e.g. GtkInstanceWidget::set_grid_left_attach
-> GtkInstanceGrid::set_child_left_attach).
Add an assert that the passed widget is actually
a grid child.
Deprecate the existing weld::Widget methods for grid
position handling. They will be removed once existing code has
been ported to the new weld::Grid API.
The fact that the vcl implementation, VclGrid
(used by vcl's new SalInstanceGrid implementation
of weld::Grid), still relies on its vcl::Window children
having the corresponding members set correctly remains
unaffected.
Change-Id: I67f5ea16b5108e8359820850f0815e34db439ef1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178570
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/inc/salvtables.hxx')
-rw-r--r-- | vcl/inc/salvtables.hxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 62dc0e8ea8db..c51f2c12a999 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -64,6 +64,8 @@ public: virtual std::unique_ptr<weld::Box> weld_box(const OUString& id) override; + virtual std::unique_ptr<weld::Grid> weld_grid(const OUString& id) override; + virtual std::unique_ptr<weld::Paned> weld_paned(const OUString& id) override; virtual std::unique_ptr<weld::Frame> weld_frame(const OUString& id) override; @@ -2137,6 +2139,19 @@ public: virtual void sort_native_button_order() override; }; +class SalInstanceGrid : public SalInstanceContainer, public virtual weld::Grid +{ +public: + SalInstanceGrid(VclGrid* pGrid, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + +public: + virtual void set_child_left_attach(weld::Widget& rWidget, int nAttach) override; + virtual int get_child_left_attach(weld::Widget& rWidget) const override; + virtual void set_child_column_span(weld::Widget& rWidget, int nCols) override; + virtual void set_child_top_attach(weld::Widget& rWidget, int nAttach) override; + virtual int get_child_top_attach(weld::Widget& rWidget) const override; +}; + class SalInstanceImage : public SalInstanceWidget, public virtual weld::Image { private: |