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
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkfixed
|
|
|
|
|
* @Short_description: A container which allows you to position
|
|
|
|
|
* widgets at fixed coordinates
|
|
|
|
|
* @Title: GtkFixed
|
2017-08-03 11:42:20 +00:00
|
|
|
|
* @See_also: #GtkLayout
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*
|
|
|
|
|
* The #GtkFixed widget is a container which can place child widgets
|
|
|
|
|
* at fixed positions and with fixed sizes, given in pixels. #GtkFixed
|
|
|
|
|
* performs no automatic layout management.
|
|
|
|
|
*
|
|
|
|
|
* For most applications, you should not use this container! It keeps
|
|
|
|
|
* you from having to learn about the other GTK+ containers, but it
|
|
|
|
|
* results in broken applications. With #GtkFixed, the following
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2017-08-03 11:42:20 +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
|
|
|
|
|
* GUI elements, since you have to reposition all the other
|
|
|
|
|
* elements. This is a long-term maintenance problem for your
|
|
|
|
|
* application.
|
|
|
|
|
*
|
|
|
|
|
* If you know none of these things are an issue for your application,
|
|
|
|
|
* and prefer the simplicity of #GtkFixed, by all means use the
|
|
|
|
|
* widget. But you should be aware of the tradeoffs.
|
2017-08-03 11:42:20 +00:00
|
|
|
|
*
|
|
|
|
|
* See also #GtkLayout, which shares the ability to perform fixed positioning
|
|
|
|
|
* of child widgets and additionally adds custom drawing and scrollability.
|
2011-01-15 13:50:24 +00:00
|
|
|
|
*/
|
|
|
|
|
|
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
|
|
|
|
|
2016-11-15 03:07:16 +00:00
|
|
|
|
#include "gtkcontainerprivate.h"
|
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"
|
2010-07-09 17:22:23 +00:00
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void gtk_fixed_add (GtkContainer *container,
|
2010-10-27 02:28:24 +00:00
|
|
|
|
GtkWidget *widget);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void gtk_fixed_remove (GtkContainer *container,
|
2010-10-27 02:28:24 +00:00
|
|
|
|
GtkWidget *widget);
|
GTK_MENU_DIR_CHILD: check for the existance of
Thu Sep 3 04:22:20 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmenushell.c (gtk_real_menu_shell_move_current):
GTK_MENU_DIR_CHILD: check for the existance of
menu_shell->active_menu_item before accessing its child.
GTK_MENU_DIR_PREV:
GTK_MENU_DIR_NEXT: if we haven't had an active item and still
don't, make a default selection.
Wed Sep 2 00:28:58 1998 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_propagate_state): iterate
the children with _forall for sensitivity changes and with
_foreach on pure state changes. this fixes a lot of the
old inclusions of internal widgets into _foreach calls.
* gtk/gtktree.c: removed gtk_tree_foreach, let gtk_tree_forall
do the work. don't walk the subtrees of first level children.
* gtk/gtktreeitem.c: provide a _forall implementation,
which walks the subtrees as well for include_internals.
* gtk/gtkmenuitem.c: provide a _forall implementation, which walks
the submenus as well for include_internals.
* gtk/gtkscrolledwindow.c: removed gtk_scrolled_window_foreach and
implemented gtk_scrolled_window_forall, which will iterate over
the viewport and the scrollbars for gtk_container_forall or
iterate over the viewports children for gtk_container_foreach.
* gtk/gtktoolbar.c:
* gtk/gtktable.c:
* gtk/gtkpaned.c:
* gtk/gtkpacker.c:
* gtk/gtkmenushell.c:
* gtk/gtklist.c:
* gtk/gtkfixed.c:
* gtk/gtkclist.c:
* gtk/gtkbox.c:
* gtk/gtkbin.c:
* gtk/gtknotebook.c:
removed the old gtk_*_foreach functions and provided gtk_*_forall.
* gtk/gtknotebook.c:
(gtk_notebook_real_switch_page): expose tabs.
(gtk_notebook_page_num): new function to return the page number
of a distinct child.
(gtk_notebook_focus): minor fixups. foxus handling is still screwed
under some circumstances.
* gtk/gtktreeitem.c:
(gtk_real_tree_item_select):
(gtk_real_tree_item_deselect): major fixes.
some general fixups wrt queue_redraw, and tree items not being
NO_WINDOW widgets.
* gtk/gtklistitem.c:
(gtk_real_list_item_select):
(gtk_real_list_item_deselect):
(gtk_real_list_item_toggle):
removed unneccessary queue_redraw calls.
Wed Aug 30 09:42:07 1998 Tim Janik <timj@gtk.org>
* gtk/gtkoptionmenu.c: allow optionmenus to have the focus and
automatically popup the menu on space bar.
Wed Aug 26 06:40:34 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.h:
* gtk/gtkcontainer.c: implemented gtk_container_forall() (as a class
method), which acts similar to gtk_container_foreach(), but iterates
over internal children. the GtkContainer::foreach signal vanished in
favour of a new class method ->forall() that optionally includes
internal widgets.
* gtk/gtkclist.c (gtk_clist_init): provide no _foreach implementation
but a _forall implementation, since all child widgets we have are
internal ones.
(column_button_create): set the parent window prior
to gtk_widget_set_parent().
* gtk/gtkwidget.c:
exchanged all calls to gtk_container_foreach() with
gtk_container_forall().
* gtk/gtkwidget.h:
* gtk/gtkwidget.c: added the GTK_COMPOSITE_CHILD, exported through
the GtkWidget::composite_child argument. to have a widget created
with the flag initially, two new functions got added to wrap a widgets
creation:
gtk_widget_push_composite_flag() and gtk_widget_pop_composite_flag().
Wed Aug 25 23:37:39 1998 Tim Janik <timj@gtk.org>
* gtk/gtktooltips.h:
* gtk/gtktooltips.c: exported gtk_tooltips_create_window() as
gtk_tooltips_force_window(), so tooltips->tip_window can be accessed
prior to the first tip being set.
don't put an extra reference on the window, since it is a toplevel,
it wont get destroyed from anywhere else.
* overall macro and GtkType fixups.
1998-09-03 02:38:53 +00:00
|
|
|
|
static void gtk_fixed_forall (GtkContainer *container,
|
2010-10-27 02:28:24 +00:00
|
|
|
|
GtkCallback callback,
|
|
|
|
|
gpointer callback_data);
|
2002-10-10 01:02:25 +00:00
|
|
|
|
static GType gtk_fixed_child_type (GtkContainer *container);
|
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
|
|
|
|
|
2019-03-26 16:50:30 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkFixed, gtk_fixed, GTK_TYPE_CONTAINER)
|
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
|
|
|
|
{
|
2019-03-26 16:50:30 +00:00
|
|
|
|
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
|
|
container_class->add = gtk_fixed_add;
|
|
|
|
|
container_class->remove = gtk_fixed_remove;
|
GTK_MENU_DIR_CHILD: check for the existance of
Thu Sep 3 04:22:20 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmenushell.c (gtk_real_menu_shell_move_current):
GTK_MENU_DIR_CHILD: check for the existance of
menu_shell->active_menu_item before accessing its child.
GTK_MENU_DIR_PREV:
GTK_MENU_DIR_NEXT: if we haven't had an active item and still
don't, make a default selection.
Wed Sep 2 00:28:58 1998 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_propagate_state): iterate
the children with _forall for sensitivity changes and with
_foreach on pure state changes. this fixes a lot of the
old inclusions of internal widgets into _foreach calls.
* gtk/gtktree.c: removed gtk_tree_foreach, let gtk_tree_forall
do the work. don't walk the subtrees of first level children.
* gtk/gtktreeitem.c: provide a _forall implementation,
which walks the subtrees as well for include_internals.
* gtk/gtkmenuitem.c: provide a _forall implementation, which walks
the submenus as well for include_internals.
* gtk/gtkscrolledwindow.c: removed gtk_scrolled_window_foreach and
implemented gtk_scrolled_window_forall, which will iterate over
the viewport and the scrollbars for gtk_container_forall or
iterate over the viewports children for gtk_container_foreach.
* gtk/gtktoolbar.c:
* gtk/gtktable.c:
* gtk/gtkpaned.c:
* gtk/gtkpacker.c:
* gtk/gtkmenushell.c:
* gtk/gtklist.c:
* gtk/gtkfixed.c:
* gtk/gtkclist.c:
* gtk/gtkbox.c:
* gtk/gtkbin.c:
* gtk/gtknotebook.c:
removed the old gtk_*_foreach functions and provided gtk_*_forall.
* gtk/gtknotebook.c:
(gtk_notebook_real_switch_page): expose tabs.
(gtk_notebook_page_num): new function to return the page number
of a distinct child.
(gtk_notebook_focus): minor fixups. foxus handling is still screwed
under some circumstances.
* gtk/gtktreeitem.c:
(gtk_real_tree_item_select):
(gtk_real_tree_item_deselect): major fixes.
some general fixups wrt queue_redraw, and tree items not being
NO_WINDOW widgets.
* gtk/gtklistitem.c:
(gtk_real_list_item_select):
(gtk_real_list_item_deselect):
(gtk_real_list_item_toggle):
removed unneccessary queue_redraw calls.
Wed Aug 30 09:42:07 1998 Tim Janik <timj@gtk.org>
* gtk/gtkoptionmenu.c: allow optionmenus to have the focus and
automatically popup the menu on space bar.
Wed Aug 26 06:40:34 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.h:
* gtk/gtkcontainer.c: implemented gtk_container_forall() (as a class
method), which acts similar to gtk_container_foreach(), but iterates
over internal children. the GtkContainer::foreach signal vanished in
favour of a new class method ->forall() that optionally includes
internal widgets.
* gtk/gtkclist.c (gtk_clist_init): provide no _foreach implementation
but a _forall implementation, since all child widgets we have are
internal ones.
(column_button_create): set the parent window prior
to gtk_widget_set_parent().
* gtk/gtkwidget.c:
exchanged all calls to gtk_container_foreach() with
gtk_container_forall().
* gtk/gtkwidget.h:
* gtk/gtkwidget.c: added the GTK_COMPOSITE_CHILD, exported through
the GtkWidget::composite_child argument. to have a widget created
with the flag initially, two new functions got added to wrap a widgets
creation:
gtk_widget_push_composite_flag() and gtk_widget_pop_composite_flag().
Wed Aug 25 23:37:39 1998 Tim Janik <timj@gtk.org>
* gtk/gtktooltips.h:
* gtk/gtktooltips.c: exported gtk_tooltips_create_window() as
gtk_tooltips_force_window(), so tooltips->tip_window can be accessed
prior to the first tip being set.
don't put an extra reference on the window, since it is a toplevel,
it wont get destroyed from anywhere else.
* overall macro and GtkType fixups.
1998-09-03 02:38:53 +00:00
|
|
|
|
container_class->forall = gtk_fixed_forall;
|
1998-06-16 05:20:05 +00:00
|
|
|
|
container_class->child_type = gtk_fixed_child_type;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-10 01:02:25 +00:00
|
|
|
|
static GType
|
2010-10-27 02:28:24 +00:00
|
|
|
|
gtk_fixed_child_type (GtkContainer *container)
|
1998-06-16 05:20:05 +00:00
|
|
|
|
{
|
|
|
|
|
return GTK_TYPE_WIDGET;
|
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);
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_has_surface (GTK_WIDGET (self), FALSE);
|
|
|
|
|
|
|
|
|
|
priv->layout = gtk_fixed_layout_new ();
|
|
|
|
|
gtk_widget_set_layout_manager (GTK_WIDGET (self), priv->layout);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 13:50:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_fixed_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #GtkFixed.
|
|
|
|
|
*
|
|
|
|
|
* Returns: a new #GtkFixed.
|
|
|
|
|
*/
|
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:
|
|
|
|
|
* @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.
|
|
|
|
|
*
|
|
|
|
|
* Adds a widget to a #GtkFixed container at the given position.
|
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
void
|
2010-10-27 02:28:24 +00:00
|
|
|
|
gtk_fixed_put (GtkFixed *fixed,
|
|
|
|
|
GtkWidget *widget,
|
|
|
|
|
gint x,
|
|
|
|
|
gint 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));
|
|
|
|
|
gtk_fixed_layout_child_set_position (child_info, transform);
|
|
|
|
|
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:
|
|
|
|
|
* @fixed: a #GtkFixed
|
|
|
|
|
* @widget: a child of @fixed
|
|
|
|
|
* @x: (out): the horizontal position of the @widget
|
|
|
|
|
* @y: (out): the vertical position of the @widget
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the position of the given child #GtkWidget in the given
|
|
|
|
|
* #GtkFixed container.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_fixed_get_child_position (GtkFixed *fixed,
|
|
|
|
|
GtkWidget *widget,
|
|
|
|
|
gint *x,
|
|
|
|
|
gint *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
|
|
|
|
float pos_x = 0.f, pos_y = 0.f;
|
|
|
|
|
GskTransform *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
|
|
|
|
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));
|
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
|
|
|
|
child_info = GTK_FIXED_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout, widget));
|
2019-03-26 19:17:26 +00:00
|
|
|
|
transform = gtk_fixed_layout_child_get_position (child_info);
|
|
|
|
|
gsk_transform_to_translate (transform, &pos_x, &pos_y);
|
2010-10-27 02:28:24 +00:00
|
|
|
|
|
2019-03-26 16:50:30 +00:00
|
|
|
|
if (x != NULL)
|
2019-03-26 19:17:26 +00:00
|
|
|
|
*x = floorf (pos_x);
|
2019-03-26 16:50:30 +00:00
|
|
|
|
if (y != NULL)
|
2019-03-26 19:17:26 +00:00
|
|
|
|
*y = floorf (pos_y);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 13:50:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_fixed_move:
|
|
|
|
|
* @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.
|
|
|
|
|
*
|
|
|
|
|
* Moves a child of a #GtkFixed container to the given position.
|
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
void
|
2010-10-27 02:28:24 +00:00
|
|
|
|
gtk_fixed_move (GtkFixed *fixed,
|
|
|
|
|
GtkWidget *widget,
|
|
|
|
|
gint x,
|
|
|
|
|
gint 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));
|
|
|
|
|
gtk_fixed_layout_child_set_position (child_info, transform);
|
|
|
|
|
gsk_transform_unref (transform);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_fixed_add (GtkContainer *container,
|
2010-10-27 02:28:24 +00:00
|
|
|
|
GtkWidget *widget)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_fixed_put (GTK_FIXED (container), widget, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_fixed_remove (GtkContainer *container,
|
2010-10-27 02:28:24 +00:00
|
|
|
|
GtkWidget *widget)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2018-07-05 17:06:48 +00:00
|
|
|
|
gtk_widget_unparent (widget);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
GTK_MENU_DIR_CHILD: check for the existance of
Thu Sep 3 04:22:20 1998 Tim Janik <timj@gtk.org>
* gtk/gtkmenushell.c (gtk_real_menu_shell_move_current):
GTK_MENU_DIR_CHILD: check for the existance of
menu_shell->active_menu_item before accessing its child.
GTK_MENU_DIR_PREV:
GTK_MENU_DIR_NEXT: if we haven't had an active item and still
don't, make a default selection.
Wed Sep 2 00:28:58 1998 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_propagate_state): iterate
the children with _forall for sensitivity changes and with
_foreach on pure state changes. this fixes a lot of the
old inclusions of internal widgets into _foreach calls.
* gtk/gtktree.c: removed gtk_tree_foreach, let gtk_tree_forall
do the work. don't walk the subtrees of first level children.
* gtk/gtktreeitem.c: provide a _forall implementation,
which walks the subtrees as well for include_internals.
* gtk/gtkmenuitem.c: provide a _forall implementation, which walks
the submenus as well for include_internals.
* gtk/gtkscrolledwindow.c: removed gtk_scrolled_window_foreach and
implemented gtk_scrolled_window_forall, which will iterate over
the viewport and the scrollbars for gtk_container_forall or
iterate over the viewports children for gtk_container_foreach.
* gtk/gtktoolbar.c:
* gtk/gtktable.c:
* gtk/gtkpaned.c:
* gtk/gtkpacker.c:
* gtk/gtkmenushell.c:
* gtk/gtklist.c:
* gtk/gtkfixed.c:
* gtk/gtkclist.c:
* gtk/gtkbox.c:
* gtk/gtkbin.c:
* gtk/gtknotebook.c:
removed the old gtk_*_foreach functions and provided gtk_*_forall.
* gtk/gtknotebook.c:
(gtk_notebook_real_switch_page): expose tabs.
(gtk_notebook_page_num): new function to return the page number
of a distinct child.
(gtk_notebook_focus): minor fixups. foxus handling is still screwed
under some circumstances.
* gtk/gtktreeitem.c:
(gtk_real_tree_item_select):
(gtk_real_tree_item_deselect): major fixes.
some general fixups wrt queue_redraw, and tree items not being
NO_WINDOW widgets.
* gtk/gtklistitem.c:
(gtk_real_list_item_select):
(gtk_real_list_item_deselect):
(gtk_real_list_item_toggle):
removed unneccessary queue_redraw calls.
Wed Aug 30 09:42:07 1998 Tim Janik <timj@gtk.org>
* gtk/gtkoptionmenu.c: allow optionmenus to have the focus and
automatically popup the menu on space bar.
Wed Aug 26 06:40:34 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.h:
* gtk/gtkcontainer.c: implemented gtk_container_forall() (as a class
method), which acts similar to gtk_container_foreach(), but iterates
over internal children. the GtkContainer::foreach signal vanished in
favour of a new class method ->forall() that optionally includes
internal widgets.
* gtk/gtkclist.c (gtk_clist_init): provide no _foreach implementation
but a _forall implementation, since all child widgets we have are
internal ones.
(column_button_create): set the parent window prior
to gtk_widget_set_parent().
* gtk/gtkwidget.c:
exchanged all calls to gtk_container_foreach() with
gtk_container_forall().
* gtk/gtkwidget.h:
* gtk/gtkwidget.c: added the GTK_COMPOSITE_CHILD, exported through
the GtkWidget::composite_child argument. to have a widget created
with the flag initially, two new functions got added to wrap a widgets
creation:
gtk_widget_push_composite_flag() and gtk_widget_pop_composite_flag().
Wed Aug 25 23:37:39 1998 Tim Janik <timj@gtk.org>
* gtk/gtktooltips.h:
* gtk/gtktooltips.c: exported gtk_tooltips_create_window() as
gtk_tooltips_force_window(), so tooltips->tip_window can be accessed
prior to the first tip being set.
don't put an extra reference on the window, since it is a toplevel,
it wont get destroyed from anywhere else.
* overall macro and GtkType fixups.
1998-09-03 02:38:53 +00:00
|
|
|
|
gtk_fixed_forall (GtkContainer *container,
|
2010-10-27 02:28:24 +00:00
|
|
|
|
GtkCallback callback,
|
|
|
|
|
gpointer callback_data)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2018-07-05 17:06:48 +00:00
|
|
|
|
GtkWidget *widget = GTK_WIDGET (container);
|
|
|
|
|
GtkWidget *child;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2018-07-05 17:06:48 +00:00
|
|
|
|
child = gtk_widget_get_first_child (widget);
|
|
|
|
|
while (child)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2018-07-05 17:06:48 +00:00
|
|
|
|
GtkWidget *next = gtk_widget_get_next_sibling (child);
|
|
|
|
|
|
|
|
|
|
(* callback) (child, callback_data);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2018-07-05 17:06:48 +00:00
|
|
|
|
child = next;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|