2008-07-01 22:57:50 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
1997-11-24 22:37:52 +00:00
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
|
* files for a list of changes. These files are distributed with
|
2010-10-27 02:28:24 +00:00
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
1999-02-24 07:37:18 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2011-01-15 13:50:24 +00:00
|
|
|
|
/**
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* GtkFixed:
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* `GtkFixed` places its child widgets at fixed positions and with fixed sizes.
|
|
|
|
|
*
|
|
|
|
|
* `GtkFixed` performs no automatic layout management.
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*
|
|
|
|
|
* For most applications, you should not use this container! It keeps
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* you from having to learn about the other GTK containers, but it
|
|
|
|
|
* results in broken applications. With `GtkFixed`, the following
|
2011-01-15 13:50:24 +00:00
|
|
|
|
* things will result in truncated text, overlapping widgets, and
|
|
|
|
|
* other display bugs:
|
2014-02-02 06:07:39 +00:00
|
|
|
|
*
|
|
|
|
|
* - Themes, which may change widget sizes.
|
|
|
|
|
*
|
|
|
|
|
* - Fonts other than the one you used to write the app will of course
|
2011-01-15 13:50:24 +00:00
|
|
|
|
* change the size of widgets containing text; keep in mind that
|
|
|
|
|
* users may use a larger font because of difficulty reading the
|
2017-08-03 11:42:20 +00:00
|
|
|
|
* default, or they may be using a different OS that provides different fonts.
|
2014-02-02 06:07:39 +00:00
|
|
|
|
*
|
|
|
|
|
* - Translation of text into other languages changes its size. Also,
|
2011-01-15 13:50:24 +00:00
|
|
|
|
* display of non-English text will use a different font in many
|
|
|
|
|
* cases.
|
|
|
|
|
*
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* In addition, `GtkFixed` does not pay attention to text direction and
|
|
|
|
|
* thus may produce unwanted results if your app is run under right-to-left
|
|
|
|
|
* languages such as Hebrew or Arabic. That is: normally GTK will order
|
|
|
|
|
* containers appropriately for the text direction, e.g. to put labels to
|
|
|
|
|
* the right of the thing they label when using an RTL language, but it can’t
|
|
|
|
|
* do that with `GtkFixed`. So if you need to reorder widgets depending on
|
|
|
|
|
* the text direction, you would need to manually detect it and adjust child
|
|
|
|
|
* positions accordingly.
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*
|
|
|
|
|
* Finally, fixed positioning makes it kind of annoying to add/remove
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* UI elements, since you have to reposition all the other elements. This
|
|
|
|
|
* is a long-term maintenance problem for your application.
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*
|
|
|
|
|
* If you know none of these things are an issue for your application,
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* and prefer the simplicity of `GtkFixed`, by all means use the
|
2011-01-15 13:50:24 +00:00
|
|
|
|
* widget. But you should be aware of the tradeoffs.
|
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2010-09-09 13:35:58 +00:00
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
#include "gtkfixed.h"
|
2010-09-09 13:35:58 +00:00
|
|
|
|
|
2019-03-26 16:50:30 +00:00
|
|
|
|
#include "gtkfixedlayout.h"
|
2016-11-15 03:07:16 +00:00
|
|
|
|
#include "gtkintl.h"
|
2019-03-26 16:50:30 +00:00
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
#include "gtkwidgetprivate.h"
|
2020-05-07 19:40:20 +00:00
|
|
|
|
#include "gtkbuildable.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2019-03-26 16:50:30 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
GtkLayoutManager *layout;
|
|
|
|
|
} GtkFixedPrivate;
|
2018-07-05 17:06:48 +00:00
|
|
|
|
|
2020-05-07 19:40:20 +00:00
|
|
|
|
static void gtk_fixed_buildable_iface_init (GtkBuildableIface *iface);
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkFixed, gtk_fixed, GTK_TYPE_WIDGET,
|
|
|
|
|
G_ADD_PRIVATE (GtkFixed)
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
|
gtk_fixed_buildable_iface_init))
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_fixed_compute_expand (GtkWidget *widget,
|
|
|
|
|
gboolean *hexpand_p,
|
|
|
|
|
gboolean *vexpand_p)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *w;
|
|
|
|
|
gboolean hexpand = FALSE;
|
|
|
|
|
gboolean vexpand = FALSE;
|
|
|
|
|
|
|
|
|
|
for (w = gtk_widget_get_first_child (widget);
|
|
|
|
|
w != NULL;
|
|
|
|
|
w = gtk_widget_get_next_sibling (w))
|
|
|
|
|
{
|
|
|
|
|
hexpand = hexpand || gtk_widget_compute_expand (w, GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
|
vexpand = vexpand || gtk_widget_compute_expand (w, GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*hexpand_p = hexpand;
|
|
|
|
|
*vexpand_p = vexpand;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GtkSizeRequestMode
|
|
|
|
|
gtk_fixed_get_request_mode (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *w;
|
|
|
|
|
int wfh = 0, hfw = 0;
|
|
|
|
|
|
|
|
|
|
for (w = gtk_widget_get_first_child (widget);
|
|
|
|
|
w != NULL;
|
|
|
|
|
w = gtk_widget_get_next_sibling (w))
|
|
|
|
|
{
|
|
|
|
|
GtkSizeRequestMode mode = gtk_widget_get_request_mode (w);
|
|
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
|
{
|
|
|
|
|
case GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH:
|
|
|
|
|
hfw ++;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT:
|
|
|
|
|
wfh ++;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_SIZE_REQUEST_CONSTANT_SIZE:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hfw == 0 && wfh == 0)
|
|
|
|
|
return GTK_SIZE_REQUEST_CONSTANT_SIZE;
|
|
|
|
|
else
|
|
|
|
|
return wfh > hfw ?
|
|
|
|
|
GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT :
|
|
|
|
|
GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_fixed_dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
|
|
|
|
while ((child = gtk_widget_get_first_child (GTK_WIDGET (object))))
|
|
|
|
|
gtk_fixed_remove (GTK_FIXED (object), child);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_fixed_parent_class)->dispose (object);
|
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
|
|
static void
|
2019-03-26 16:50:30 +00:00
|
|
|
|
gtk_fixed_class_init (GtkFixedClass *klass)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2020-05-07 19:40:20 +00:00
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2019-05-06 11:06:27 +00:00
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2020-05-07 19:40:20 +00:00
|
|
|
|
object_class->dispose = gtk_fixed_dispose;
|
|
|
|
|
|
|
|
|
|
widget_class->compute_expand = gtk_fixed_compute_expand;
|
|
|
|
|
widget_class->get_request_mode = gtk_fixed_get_request_mode;
|
2019-05-06 11:06:27 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_FIXED_LAYOUT);
|
1998-06-16 05:20:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-07 19:40:20 +00:00
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_fixed_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *type)
|
2020-05-07 19:40:20 +00:00
|
|
|
|
{
|
|
|
|
|
if (GTK_IS_WIDGET (child))
|
|
|
|
|
gtk_fixed_put (GTK_FIXED (buildable), GTK_WIDGET (child), 0, 0);
|
|
|
|
|
else
|
|
|
|
|
parent_buildable_iface->add_child (buildable, builder, child, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_fixed_buildable_iface_init (GtkBuildableIface *iface)
|
1998-06-16 05:20:05 +00:00
|
|
|
|
{
|
2020-05-07 19:40:20 +00:00
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
|
|
|
|
|
iface->add_child = gtk_fixed_buildable_add_child;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-03-26 16:50:30 +00:00
|
|
|
|
gtk_fixed_init (GtkFixed *self)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2019-03-26 16:50:30 +00:00
|
|
|
|
GtkFixedPrivate *priv = gtk_fixed_get_instance_private (self);
|
|
|
|
|
|
2019-04-01 17:11:19 +00:00
|
|
|
|
gtk_widget_set_overflow (GTK_WIDGET (self), GTK_OVERFLOW_HIDDEN);
|
2019-03-26 16:50:30 +00:00
|
|
|
|
|
2020-05-07 19:40:20 +00:00
|
|
|
|
priv->layout = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 13:50:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_fixed_new:
|
|
|
|
|
*
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* Creates a new `GtkFixed`.
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* Returns: a new `GtkFixed`.
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
GtkWidget*
|
1998-05-03 22:41:32 +00:00
|
|
|
|
gtk_fixed_new (void)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2002-10-10 01:02:25 +00:00
|
|
|
|
return g_object_new (GTK_TYPE_FIXED, NULL);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 13:50:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_fixed_put:
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* @fixed: a `GtkFixed`
|
|
|
|
|
* @widget: the widget to add
|
|
|
|
|
* @x: the horizontal position to place the widget at
|
|
|
|
|
* @y: the vertical position to place the widget at
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* Adds a widget to a `GtkFixed` at the given position.
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
void
|
2010-10-27 02:28:24 +00:00
|
|
|
|
gtk_fixed_put (GtkFixed *fixed,
|
|
|
|
|
GtkWidget *widget,
|
2020-05-22 21:19:35 +00:00
|
|
|
|
double x,
|
|
|
|
|
double y)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2019-03-26 16:50:30 +00:00
|
|
|
|
GtkFixedPrivate *priv = gtk_fixed_get_instance_private (fixed);
|
|
|
|
|
GtkFixedLayoutChild *child_info;
|
2019-03-26 19:17:26 +00:00
|
|
|
|
GskTransform *transform = NULL;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_FIXED (fixed));
|
2005-08-02 03:49:39 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
2017-10-12 13:05:09 +00:00
|
|
|
|
g_return_if_fail (_gtk_widget_get_parent (widget) == NULL);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_set_parent (widget, GTK_WIDGET (fixed));
|
2019-03-26 16:50:30 +00:00
|
|
|
|
|
|
|
|
|
child_info = GTK_FIXED_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout, widget));
|
2019-03-26 19:17:26 +00:00
|
|
|
|
|
|
|
|
|
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (x, y));
|
2019-08-25 12:56:13 +00:00
|
|
|
|
gtk_fixed_layout_child_set_transform (child_info, transform);
|
2019-03-26 19:17:26 +00:00
|
|
|
|
gsk_transform_unref (transform);
|
fix a typo.
2001-08-07 Havoc Pennington <hp@pobox.com>
* gtk/gtkfilesel.c (open_ref_dir): fix a typo.
* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
some fixage is needed here, but nothing simple. Owen understands
it. ;-)
* gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
sizing and positioning. Also, fix bug in compute_geometry_hints
(width/height confusion for setting min size).
(gtk_window_move): new function
(gtk_window_resize): new function
(gtk_window_get_size): new function
(gtk_window_get_position): new function
(gtk_window_parse_geometry): new function
* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
(gtk_widget_get_size_request): new function
(gtk_widget_get_usize): delete, that was a short-lived function
;-)
(gtk_widget_set_usize): deprecate
(gtk_widget_set_uposition): deprecate, make it a trivial
gtk_window_move() wrapper
(gtk_widget_class_init): remove x/y/width/height properties,
add width_request height_request
* demos/*: update to avoid deprecated functions
* gtk/gtklayout.c: add x/y child properties
* gtk/gtkfixed.c: add x/y child properties, and get rid of
uses of "gint16"
* tests/testgtk.c (create_window_sizing): lots of tweaks to window
sizing test
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
configure events on toplevel windows are always in root window
coordinates, following ICCCM spec that all synthetic events
are in root window coords already, while real events are
in parent window coords. Previously the code assumed that
coords of 0,0 were parent window coords, which was
really broken.
* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
warning
* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
and GDK_HINT_USER_SIZE so we can set USSize and USPosition
hints in gtk_window_parse_geometry()
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
new USER_POS USER_SIZE hints
2001-08-10 03:46:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 16:50:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_fixed_get_child_position:
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* @fixed: a `GtkFixed`
|
2019-03-26 16:50:30 +00:00
|
|
|
|
* @widget: a child of @fixed
|
|
|
|
|
* @x: (out): the horizontal position of the @widget
|
|
|
|
|
* @y: (out): the vertical position of the @widget
|
|
|
|
|
*
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* Retrieves the translation transformation of the
|
|
|
|
|
* given child `GtkWidget` in the `GtkFixed`.
|
2019-04-02 14:48:46 +00:00
|
|
|
|
*
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* See also: [method@Gtk.Fixed.get_child_transform].
|
2019-03-26 16:50:30 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_fixed_get_child_position (GtkFixed *fixed,
|
|
|
|
|
GtkWidget *widget,
|
2020-05-22 21:19:35 +00:00
|
|
|
|
double *x,
|
|
|
|
|
double *y)
|
fix a typo.
2001-08-07 Havoc Pennington <hp@pobox.com>
* gtk/gtkfilesel.c (open_ref_dir): fix a typo.
* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
some fixage is needed here, but nothing simple. Owen understands
it. ;-)
* gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
sizing and positioning. Also, fix bug in compute_geometry_hints
(width/height confusion for setting min size).
(gtk_window_move): new function
(gtk_window_resize): new function
(gtk_window_get_size): new function
(gtk_window_get_position): new function
(gtk_window_parse_geometry): new function
* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
(gtk_widget_get_size_request): new function
(gtk_widget_get_usize): delete, that was a short-lived function
;-)
(gtk_widget_set_usize): deprecate
(gtk_widget_set_uposition): deprecate, make it a trivial
gtk_window_move() wrapper
(gtk_widget_class_init): remove x/y/width/height properties,
add width_request height_request
* demos/*: update to avoid deprecated functions
* gtk/gtklayout.c: add x/y child properties
* gtk/gtkfixed.c: add x/y child properties, and get rid of
uses of "gint16"
* tests/testgtk.c (create_window_sizing): lots of tweaks to window
sizing test
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
configure events on toplevel windows are always in root window
coordinates, following ICCCM spec that all synthetic events
are in root window coords already, while real events are
in parent window coords. Previously the code assumed that
coords of 0,0 were parent window coords, which was
really broken.
* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
warning
* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
and GDK_HINT_USER_SIZE so we can set USSize and USPosition
hints in gtk_window_parse_geometry()
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
new USER_POS USER_SIZE hints
2001-08-10 03:46:08 +00:00
|
|
|
|
{
|
2019-03-26 16:50:30 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_FIXED (fixed));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
2019-08-25 12:59:01 +00:00
|
|
|
|
g_return_if_fail (x != NULL);
|
|
|
|
|
g_return_if_fail (y != NULL);
|
2019-03-26 16:50:30 +00:00
|
|
|
|
g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (fixed));
|
fix a typo.
2001-08-07 Havoc Pennington <hp@pobox.com>
* gtk/gtkfilesel.c (open_ref_dir): fix a typo.
* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
some fixage is needed here, but nothing simple. Owen understands
it. ;-)
* gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
sizing and positioning. Also, fix bug in compute_geometry_hints
(width/height confusion for setting min size).
(gtk_window_move): new function
(gtk_window_resize): new function
(gtk_window_get_size): new function
(gtk_window_get_position): new function
(gtk_window_parse_geometry): new function
* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
(gtk_widget_get_size_request): new function
(gtk_widget_get_usize): delete, that was a short-lived function
;-)
(gtk_widget_set_usize): deprecate
(gtk_widget_set_uposition): deprecate, make it a trivial
gtk_window_move() wrapper
(gtk_widget_class_init): remove x/y/width/height properties,
add width_request height_request
* demos/*: update to avoid deprecated functions
* gtk/gtklayout.c: add x/y child properties
* gtk/gtkfixed.c: add x/y child properties, and get rid of
uses of "gint16"
* tests/testgtk.c (create_window_sizing): lots of tweaks to window
sizing test
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
configure events on toplevel windows are always in root window
coordinates, following ICCCM spec that all synthetic events
are in root window coords already, while real events are
in parent window coords. Previously the code assumed that
coords of 0,0 were parent window coords, which was
really broken.
* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
warning
* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
and GDK_HINT_USER_SIZE so we can set USSize and USPosition
hints in gtk_window_parse_geometry()
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
new USER_POS USER_SIZE hints
2001-08-10 03:46:08 +00:00
|
|
|
|
|
2020-05-22 21:19:35 +00:00
|
|
|
|
gtk_widget_translate_coordinates (widget, GTK_WIDGET (fixed), 0, 0, x, y);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-02 14:48:46 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_fixed_set_child_transform:
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* @fixed: a `GtkFixed`
|
|
|
|
|
* @widget: a `GtkWidget`, child of @fixed
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @transform: (nullable): the transformation assigned to @widget
|
2019-08-25 13:02:57 +00:00
|
|
|
|
* to reset @widget's transform
|
2019-04-02 14:48:46 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the transformation for @widget.
|
|
|
|
|
*
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* This is a convenience function that retrieves the
|
|
|
|
|
* [class@Gtk.FixedLayoutChild] instance associated to
|
|
|
|
|
* @widget and calls [method@Gtk.FixedLayoutChild.set_transform].
|
2019-04-02 14:48:46 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_fixed_set_child_transform (GtkFixed *fixed,
|
|
|
|
|
GtkWidget *widget,
|
|
|
|
|
GskTransform *transform)
|
|
|
|
|
{
|
|
|
|
|
GtkFixedPrivate *priv = gtk_fixed_get_instance_private (fixed);
|
|
|
|
|
GtkFixedLayoutChild *child_info;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_FIXED (fixed));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (fixed));
|
|
|
|
|
|
|
|
|
|
child_info = GTK_FIXED_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout, widget));
|
2019-08-25 12:56:13 +00:00
|
|
|
|
gtk_fixed_layout_child_set_transform (child_info, transform);
|
2019-04-02 14:48:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_fixed_get_child_transform:
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* @fixed: a `GtkFixed`
|
|
|
|
|
* @widget: a `GtkWidget`, child of @fixed
|
2019-04-02 14:48:46 +00:00
|
|
|
|
*
|
|
|
|
|
* Retrieves the transformation for @widget set using
|
|
|
|
|
* gtk_fixed_set_child_transform().
|
|
|
|
|
*
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* Returns: (transfer none) (nullable): a `GskTransform`
|
2019-04-02 14:48:46 +00:00
|
|
|
|
*/
|
|
|
|
|
GskTransform *
|
|
|
|
|
gtk_fixed_get_child_transform (GtkFixed *fixed,
|
|
|
|
|
GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GtkFixedPrivate *priv = gtk_fixed_get_instance_private (fixed);
|
|
|
|
|
GtkFixedLayoutChild *child_info;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_FIXED (fixed), NULL);
|
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
|
|
|
|
g_return_val_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (fixed), NULL);
|
|
|
|
|
|
|
|
|
|
child_info = GTK_FIXED_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout, widget));
|
2019-08-25 12:56:13 +00:00
|
|
|
|
return gtk_fixed_layout_child_get_transform (child_info);
|
2019-04-02 14:48:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 13:50:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_fixed_move:
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* @fixed: a `GtkFixed`
|
|
|
|
|
* @widget: the child widget
|
|
|
|
|
* @x: the horizontal position to move the widget to
|
|
|
|
|
* @y: the vertical position to move the widget to
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* Sets a translation transformation to the given @x and @y
|
|
|
|
|
* coordinates to the child @widget of the `GtkFixed`.
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
void
|
2010-10-27 02:28:24 +00:00
|
|
|
|
gtk_fixed_move (GtkFixed *fixed,
|
|
|
|
|
GtkWidget *widget,
|
2020-05-22 21:19:35 +00:00
|
|
|
|
double x,
|
|
|
|
|
double y)
|
fix a typo.
2001-08-07 Havoc Pennington <hp@pobox.com>
* gtk/gtkfilesel.c (open_ref_dir): fix a typo.
* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
some fixage is needed here, but nothing simple. Owen understands
it. ;-)
* gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
sizing and positioning. Also, fix bug in compute_geometry_hints
(width/height confusion for setting min size).
(gtk_window_move): new function
(gtk_window_resize): new function
(gtk_window_get_size): new function
(gtk_window_get_position): new function
(gtk_window_parse_geometry): new function
* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
(gtk_widget_get_size_request): new function
(gtk_widget_get_usize): delete, that was a short-lived function
;-)
(gtk_widget_set_usize): deprecate
(gtk_widget_set_uposition): deprecate, make it a trivial
gtk_window_move() wrapper
(gtk_widget_class_init): remove x/y/width/height properties,
add width_request height_request
* demos/*: update to avoid deprecated functions
* gtk/gtklayout.c: add x/y child properties
* gtk/gtkfixed.c: add x/y child properties, and get rid of
uses of "gint16"
* tests/testgtk.c (create_window_sizing): lots of tweaks to window
sizing test
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
configure events on toplevel windows are always in root window
coordinates, following ICCCM spec that all synthetic events
are in root window coords already, while real events are
in parent window coords. Previously the code assumed that
coords of 0,0 were parent window coords, which was
really broken.
* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
warning
* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
and GDK_HINT_USER_SIZE so we can set USSize and USPosition
hints in gtk_window_parse_geometry()
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
new USER_POS USER_SIZE hints
2001-08-10 03:46:08 +00:00
|
|
|
|
{
|
2019-03-26 16:50:30 +00:00
|
|
|
|
GtkFixedPrivate *priv = gtk_fixed_get_instance_private (fixed);
|
|
|
|
|
GtkFixedLayoutChild *child_info;
|
2019-03-26 19:17:26 +00:00
|
|
|
|
GskTransform *transform = NULL;
|
2010-10-27 02:28:24 +00:00
|
|
|
|
|
2019-03-26 16:50:30 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_FIXED (fixed));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (fixed));
|
2010-10-27 02:28:24 +00:00
|
|
|
|
|
2019-03-26 16:50:30 +00:00
|
|
|
|
child_info = GTK_FIXED_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout, widget));
|
2019-03-26 19:17:26 +00:00
|
|
|
|
|
|
|
|
|
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (x, y));
|
2019-08-25 12:56:13 +00:00
|
|
|
|
gtk_fixed_layout_child_set_transform (child_info, transform);
|
2019-03-26 19:17:26 +00:00
|
|
|
|
gsk_transform_unref (transform);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-07 19:02:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_fixed_remove:
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* @fixed: a `GtkFixed`
|
2020-05-07 19:02:39 +00:00
|
|
|
|
* @widget: the child widget to remove
|
|
|
|
|
*
|
2021-02-28 18:09:01 +00:00
|
|
|
|
* Removes a child from @fixed.
|
2020-05-07 19:02:39 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_fixed_remove (GtkFixed *fixed,
|
|
|
|
|
GtkWidget *widget)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2020-05-07 19:02:39 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_FIXED (fixed));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (fixed));
|
|
|
|
|
|
2018-07-05 17:06:48 +00:00
|
|
|
|
gtk_widget_unparent (widget);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|