1 /*******************************************************************************
2 **3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
3 ** 10 20 30 40 50 60 70 80
5 ** library for GtkXPaned-widget, a 2x2 grid-like variation of GtkPaned of gtk+
6 ** Copyright (C) 2012 Free Software Foundation, Inc.
7 ** Copyright (C) 2005-2006 Mirco "MacSlow" Müller <macslow@bangang.de>
9 ** This library is free software; you can redistribute it and/or
10 ** modify it under the terms of the GNU Lesser General Public
11 ** License as published by the Free Software Foundation; either
12 ** version 2.1 of the License, or (at your option) any later version.
14 ** This library is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ** Lesser General Public License for more details.
19 ** You should have received a copy of the GNU Lesser General Public
20 ** License along with this library; if not, write to the Free Software
21 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 ** GtkXPaned is based on GtkPaned which was done by...
25 ** "Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald"
27 ** and later modified by...
29 ** "the GTK+ Team and others 1997-2000"
31 *******************************************************************************/
34 #include "gtkxpaned.h"
37 #include <ui/gui/psppire-marshal.h>
38 #include <gdk/gdkkeysyms.h>
71 static void gtk_xpaned_class_init (GtkXPanedClass * klass);
73 static void gtk_xpaned_init (GtkXPaned * xpaned);
75 static void gtk_xpaned_size_request (GtkWidget * widget,
76 GtkRequisition * requisition);
78 static void gtk_xpaned_size_allocate (GtkWidget * widget,
79 GtkAllocation * allocation);
81 static void gtk_xpaned_set_property (GObject * object,
86 static void gtk_xpaned_get_property (GObject * object,
88 GValue * value, GParamSpec * pspec);
90 static void gtk_xpaned_set_child_property (GtkContainer * container,
96 static void gtk_xpaned_get_child_property (GtkContainer * container,
102 static void gtk_xpaned_finalize (GObject * object);
104 static void gtk_xpaned_realize (GtkWidget * widget);
106 static void gtk_xpaned_unrealize (GtkWidget * widget);
108 static void gtk_xpaned_map (GtkWidget * widget);
110 static void gtk_xpaned_unmap (GtkWidget * widget);
112 static gboolean gtk_xpaned_expose (GtkWidget * widget,
113 GdkEventExpose * event);
115 static gboolean gtk_xpaned_enter (GtkWidget * widget,
116 GdkEventCrossing * event);
118 static gboolean gtk_xpaned_leave (GtkWidget * widget,
119 GdkEventCrossing * event);
121 static gboolean gtk_xpaned_button_press (GtkWidget * widget,
122 GdkEventButton * event);
124 static gboolean gtk_xpaned_button_release (GtkWidget * widget,
125 GdkEventButton * event);
127 static gboolean gtk_xpaned_motion (GtkWidget * widget,
128 GdkEventMotion * event);
130 static gboolean gtk_xpaned_focus (GtkWidget * widget,
131 GtkDirectionType direction);
133 static void gtk_xpaned_add (GtkContainer * container, GtkWidget * widget);
135 static void gtk_xpaned_remove (GtkContainer * container, GtkWidget * widget);
137 static void gtk_xpaned_forall (GtkContainer * container,
138 gboolean include_internals,
139 GtkCallback callback, gpointer callback_data);
141 static void gtk_xpaned_set_focus_child (GtkContainer * container,
144 static void gtk_xpaned_set_saved_focus (GtkXPaned * xpaned,
147 static void gtk_xpaned_set_first_xpaned (GtkXPaned * xpaned,
148 GtkXPaned * first_xpaned);
150 static void gtk_xpaned_set_last_top_left_child_focus (GtkXPaned * xpaned,
153 static void gtk_xpaned_set_last_top_right_child_focus (GtkXPaned * xpaned,
156 static void gtk_xpaned_set_last_bottom_left_child_focus (GtkXPaned * xpaned,
159 static void gtk_xpaned_set_last_bottom_right_child_focus (GtkXPaned * xpaned,
162 static gboolean gtk_xpaned_cycle_child_focus (GtkXPaned * xpaned,
165 static gboolean gtk_xpaned_cycle_handle_focus (GtkXPaned * xpaned,
168 static gboolean gtk_xpaned_move_handle (GtkXPaned * xpaned,
169 GtkScrollType scroll);
171 static gboolean gtk_xpaned_accept_position (GtkXPaned * xpaned);
173 static gboolean gtk_xpaned_cancel_position (GtkXPaned * xpaned);
175 static gboolean gtk_xpaned_toggle_handle_focus (GtkXPaned * xpaned);
177 static GType gtk_xpaned_child_type (GtkContainer * container);
179 static GtkContainerClass *parent_class = NULL;
181 struct _GtkXPanedPrivate
183 GtkWidget *saved_focus;
184 GtkXPaned *first_xpaned;
188 gtk_xpaned_get_type (void)
190 static GType xpaned_type = 0;
194 static const GTypeInfo xpaned_info = {
195 sizeof (GtkXPanedClass),
196 NULL, /* base_init */
197 NULL, /* base_finalize */
198 (GClassInitFunc) gtk_xpaned_class_init,
199 NULL, /* class_finalize */
200 NULL, /* class_data */
203 (GInstanceInitFunc) gtk_xpaned_init
206 xpaned_type = g_type_register_static (GTK_TYPE_CONTAINER,
207 "GtkXPaned", &xpaned_info, 0);
214 gtk_xpaned_new (void)
218 xpaned = g_object_new (GTK_TYPE_XPANED, NULL);
220 return GTK_WIDGET (xpaned);
223 static guint signals[LAST_SIGNAL] = { 0 };
226 add_tab_bindings (GtkBindingSet * binding_set, GdkModifierType modifiers)
228 gtk_binding_entry_add_signal (binding_set,
229 GDK_Tab, modifiers, "toggle_handle_focus", 0);
231 gtk_binding_entry_add_signal (binding_set,
233 modifiers, "toggle_handle_focus", 0);
237 add_move_binding (GtkBindingSet * binding_set,
238 guint keyval, GdkModifierType mask, GtkScrollType scroll)
240 gtk_binding_entry_add_signal (binding_set,
244 1, GTK_TYPE_SCROLL_TYPE, scroll);
248 gtk_xpaned_class_init (GtkXPanedClass * class)
250 GObjectClass *object_class;
251 GtkWidgetClass *widget_class;
252 GtkContainerClass *container_class;
253 GtkXPanedClass *xpaned_class;
254 GtkBindingSet *binding_set;
256 object_class = (GObjectClass *) class;
257 widget_class = (GtkWidgetClass *) class;
258 container_class = (GtkContainerClass *) class;
259 xpaned_class = (GtkXPanedClass *) class;
261 parent_class = g_type_class_peek_parent (class);
263 object_class->set_property = gtk_xpaned_set_property;
264 object_class->get_property = gtk_xpaned_get_property;
265 object_class->finalize = gtk_xpaned_finalize;
267 widget_class->realize = gtk_xpaned_realize;
268 widget_class->unrealize = gtk_xpaned_unrealize;
269 widget_class->map = gtk_xpaned_map;
270 widget_class->unmap = gtk_xpaned_unmap;
271 widget_class->expose_event = gtk_xpaned_expose;
272 widget_class->focus = gtk_xpaned_focus;
273 widget_class->enter_notify_event = gtk_xpaned_enter;
274 widget_class->leave_notify_event = gtk_xpaned_leave;
275 widget_class->button_press_event = gtk_xpaned_button_press;
276 widget_class->button_release_event = gtk_xpaned_button_release;
277 widget_class->motion_notify_event = gtk_xpaned_motion;
278 widget_class->size_request = gtk_xpaned_size_request;
279 widget_class->size_allocate = gtk_xpaned_size_allocate;
281 container_class->add = gtk_xpaned_add;
282 container_class->remove = gtk_xpaned_remove;
283 container_class->forall = gtk_xpaned_forall;
284 container_class->child_type = gtk_xpaned_child_type;
285 container_class->set_focus_child = gtk_xpaned_set_focus_child;
286 container_class->set_child_property = gtk_xpaned_set_child_property;
287 container_class->get_child_property = gtk_xpaned_get_child_property;
289 xpaned_class->cycle_child_focus = gtk_xpaned_cycle_child_focus;
290 xpaned_class->toggle_handle_focus = gtk_xpaned_toggle_handle_focus;
291 xpaned_class->move_handle = gtk_xpaned_move_handle;
292 xpaned_class->cycle_handle_focus = gtk_xpaned_cycle_handle_focus;
293 xpaned_class->accept_position = gtk_xpaned_accept_position;
294 xpaned_class->cancel_position = gtk_xpaned_cancel_position;
296 g_object_class_install_property (object_class,
298 g_param_spec_int ("x-position",
300 ("x-Position of paned separator in pixels (0 means all the way to the left)"),
307 g_object_class_install_property (object_class,
309 g_param_spec_int ("y-position",
311 "y-Position of paned separator in pixels (0 means all the way to the top)",
318 g_object_class_install_property (object_class,
320 g_param_spec_boolean ("position-set",
322 "TRUE if the Position property should be used",
327 gtk_widget_class_install_style_property (widget_class,
328 g_param_spec_int ("handle-size",
336 * GtkXPaned:min-x-position:
338 * The smallest possible value for the x-position property. This property is derived from the
339 * size and shrinkability of the widget's children.
343 g_object_class_install_property (object_class,
345 g_param_spec_int ("min-x-position",
346 "Minimal x-Position",
347 "Smallest possible value for the \"x-position\" property",
350 0, G_PARAM_READABLE));
353 * GtkXPaned:min-y-position:
355 * The smallest possible value for the y-position property. This property is derived from the
356 * size and shrinkability of the widget's children.
360 g_object_class_install_property (object_class,
362 g_param_spec_int ("min-y-position",
363 "Minimal y-Position",
364 "Smallest possible value for the \"y-position\" property",
367 0, G_PARAM_READABLE));
370 * GtkPaned:max-x-position:
372 * The largest possible value for the x-position property. This property is derived from the
373 * size and shrinkability of the widget's children.
377 g_object_class_install_property (object_class,
379 g_param_spec_int ("max-x-position",
380 "Maximal x-Position",
381 "Largest possible value for the \"x-position\" property",
388 * GtkPaned:max-y-position:
390 * The largest possible value for the y-position property. This property is derived from the
391 * size and shrinkability of the widget's children.
395 g_object_class_install_property (object_class,
397 g_param_spec_int ("max-y-position",
398 "Maximal y-Position",
399 "Largest possible value for the \"y-position\" property",
408 * The "resize" child property determines whether the child expands and
409 * shrinks along with the paned widget.
413 gtk_container_class_install_child_property (container_class,
415 g_param_spec_boolean ("resize",
417 "If TRUE, the child expands and shrinks along with the paned widget",
424 * The "shrink" child property determines whether the child can be made
425 * smaller than its requisition.
429 gtk_container_class_install_child_property (container_class,
431 g_param_spec_boolean ("shrink",
433 "If TRUE, the child can be made smaller than its requisition",
437 signals[CYCLE_CHILD_FOCUS] = g_signal_new ("cycle-child-focus",
438 G_TYPE_FROM_CLASS (object_class),
441 G_STRUCT_OFFSET (GtkXPanedClass,
444 psppire_marshal_BOOLEAN__BOOLEAN,
448 signals[TOGGLE_HANDLE_FOCUS] = g_signal_new ("toggle-handle-focus",
455 toggle_handle_focus), NULL,
457 psppire_marshal_BOOLEAN__VOID,
460 signals[MOVE_HANDLE] = g_signal_new ("move-handle",
461 G_TYPE_FROM_CLASS (object_class),
462 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
463 G_STRUCT_OFFSET (GtkXPanedClass,
465 NULL, psppire_marshal_BOOLEAN__ENUM,
467 GTK_TYPE_SCROLL_TYPE);
469 signals[CYCLE_HANDLE_FOCUS] = g_signal_new ("cycle-handle-focus",
474 G_STRUCT_OFFSET (GtkXPanedClass,
477 psppire_marshal_BOOLEAN__BOOLEAN,
481 signals[ACCEPT_POSITION] = g_signal_new ("accept-position",
482 G_TYPE_FROM_CLASS (object_class),
485 G_STRUCT_OFFSET (GtkXPanedClass,
488 psppire_marshal_BOOLEAN__VOID,
491 signals[CANCEL_POSITION] = g_signal_new ("cancel-position",
492 G_TYPE_FROM_CLASS (object_class),
495 G_STRUCT_OFFSET (GtkXPanedClass,
498 psppire_marshal_BOOLEAN__VOID,
501 binding_set = gtk_binding_set_by_class (class);
504 gtk_binding_entry_add_signal (binding_set,
506 "cycle-child-focus", 1,
507 G_TYPE_BOOLEAN, FALSE);
509 gtk_binding_entry_add_signal (binding_set,
510 GDK_F6, GDK_SHIFT_MASK,
511 "cycle-child-focus", 1, G_TYPE_BOOLEAN, TRUE);
514 gtk_binding_entry_add_signal (binding_set,
516 "cycle-handle-focus", 1,
517 G_TYPE_BOOLEAN, FALSE);
519 gtk_binding_entry_add_signal (binding_set,
520 GDK_F8, GDK_SHIFT_MASK,
521 "cycle-handle-focus", 1,
522 G_TYPE_BOOLEAN, TRUE);
524 add_tab_bindings (binding_set, 0);
525 add_tab_bindings (binding_set, GDK_CONTROL_MASK);
526 add_tab_bindings (binding_set, GDK_SHIFT_MASK);
527 add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK);
529 /* accept and cancel positions */
530 gtk_binding_entry_add_signal (binding_set,
531 GDK_Escape, 0, "cancel-position", 0);
533 gtk_binding_entry_add_signal (binding_set,
534 GDK_Return, 0, "accept-position", 0);
536 gtk_binding_entry_add_signal (binding_set,
537 GDK_KP_Enter, 0, "accept-position", 0);
539 gtk_binding_entry_add_signal (binding_set,
540 GDK_space, 0, "accept-position", 0);
542 gtk_binding_entry_add_signal (binding_set,
543 GDK_KP_Space, 0, "accept-position", 0);
546 add_move_binding (binding_set, GDK_Left, 0, GTK_SCROLL_STEP_LEFT);
547 add_move_binding (binding_set, GDK_KP_Left, 0, GTK_SCROLL_STEP_LEFT);
548 add_move_binding (binding_set, GDK_Left, GDK_CONTROL_MASK,
549 GTK_SCROLL_PAGE_LEFT);
550 add_move_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK,
551 GTK_SCROLL_PAGE_LEFT);
553 add_move_binding (binding_set, GDK_Right, 0, GTK_SCROLL_STEP_RIGHT);
554 add_move_binding (binding_set, GDK_Right, GDK_CONTROL_MASK,
555 GTK_SCROLL_PAGE_RIGHT);
556 add_move_binding (binding_set, GDK_KP_Right, 0, GTK_SCROLL_STEP_RIGHT);
557 add_move_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK,
558 GTK_SCROLL_PAGE_RIGHT);
560 add_move_binding (binding_set, GDK_Up, 0, GTK_SCROLL_STEP_UP);
561 add_move_binding (binding_set, GDK_Up, GDK_CONTROL_MASK,
563 add_move_binding (binding_set, GDK_KP_Up, 0, GTK_SCROLL_STEP_UP);
564 add_move_binding (binding_set, GDK_KP_Up, GDK_CONTROL_MASK,
566 add_move_binding (binding_set, GDK_Page_Up, 0, GTK_SCROLL_PAGE_UP);
567 add_move_binding (binding_set, GDK_KP_Page_Up, 0, GTK_SCROLL_PAGE_UP);
569 add_move_binding (binding_set, GDK_Down, 0, GTK_SCROLL_STEP_DOWN);
570 add_move_binding (binding_set, GDK_Down, GDK_CONTROL_MASK,
571 GTK_SCROLL_PAGE_DOWN);
572 add_move_binding (binding_set, GDK_KP_Down, 0, GTK_SCROLL_STEP_DOWN);
573 add_move_binding (binding_set, GDK_KP_Down, GDK_CONTROL_MASK,
574 GTK_SCROLL_PAGE_DOWN);
575 add_move_binding (binding_set, GDK_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT);
576 add_move_binding (binding_set, GDK_KP_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT);
578 add_move_binding (binding_set, GDK_Home, 0, GTK_SCROLL_START);
579 add_move_binding (binding_set, GDK_KP_Home, 0, GTK_SCROLL_START);
580 add_move_binding (binding_set, GDK_End, 0, GTK_SCROLL_END);
581 add_move_binding (binding_set, GDK_KP_End, 0, GTK_SCROLL_END);
585 gtk_xpaned_child_type (GtkContainer * container)
587 if (!GTK_XPANED (container)->top_left_child ||
588 !GTK_XPANED (container)->top_right_child ||
589 !GTK_XPANED (container)->bottom_left_child ||
590 !GTK_XPANED (container)->bottom_right_child)
591 return GTK_TYPE_WIDGET;
597 gtk_xpaned_init (GtkXPaned * xpaned)
599 gtk_widget_set_can_focus (GTK_WIDGET (xpaned), TRUE);
600 gtk_widget_set_has_window (GTK_WIDGET (xpaned), FALSE);
602 xpaned->top_left_child = NULL;
603 xpaned->top_right_child = NULL;
604 xpaned->bottom_left_child = NULL;
605 xpaned->bottom_right_child = NULL;
606 xpaned->handle_east = NULL;
607 xpaned->handle_west = NULL;
608 xpaned->handle_north = NULL;
609 xpaned->handle_south = NULL;
610 xpaned->handle_middle = NULL;
611 xpaned->xor_gc = NULL;
612 xpaned->cursor_type_east = GDK_SB_V_DOUBLE_ARROW;
613 xpaned->cursor_type_west = GDK_SB_V_DOUBLE_ARROW;
614 xpaned->cursor_type_north = GDK_SB_H_DOUBLE_ARROW;
615 xpaned->cursor_type_south = GDK_SB_H_DOUBLE_ARROW;
616 xpaned->cursor_type_middle = GDK_FLEUR;
618 xpaned->handle_pos_east.width = 5;
619 xpaned->handle_pos_east.height = 5;
620 xpaned->handle_pos_west.width = 5;
621 xpaned->handle_pos_west.height = 5;
622 xpaned->handle_pos_north.width = 5;
623 xpaned->handle_pos_north.height = 5;
624 xpaned->handle_pos_south.width = 5;
625 xpaned->handle_pos_south.height = 5;
626 xpaned->handle_pos_middle.width = 5;
627 xpaned->handle_pos_middle.height = 5;
629 xpaned->position_set = FALSE;
630 xpaned->last_allocation.width = -1;
631 xpaned->last_allocation.height = -1;
632 xpaned->in_drag_vert = FALSE;
633 xpaned->in_drag_horiz = FALSE;
634 xpaned->in_drag_vert_and_horiz = FALSE;
636 xpaned->maximized[GTK_XPANED_TOP_LEFT] = FALSE;
637 xpaned->maximized[GTK_XPANED_TOP_RIGHT] = FALSE;
638 xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] = FALSE;
639 xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT] = FALSE;
641 xpaned->priv = g_new0 (GtkXPanedPrivate, 1);
642 xpaned->last_top_left_child_focus = NULL;
643 xpaned->last_top_right_child_focus = NULL;
644 xpaned->last_bottom_left_child_focus = NULL;
645 xpaned->last_bottom_right_child_focus = NULL;
646 xpaned->in_recursion = FALSE;
647 xpaned->handle_prelit = FALSE;
648 xpaned->original_position.x = -1;
649 xpaned->original_position.y = -1;
650 xpaned->unmaximized_position.x = -1;
651 xpaned->unmaximized_position.y = -1;
653 xpaned->handle_pos_east.x = -1;
654 xpaned->handle_pos_east.y = -1;
655 xpaned->handle_pos_west.x = -1;
656 xpaned->handle_pos_west.y = -1;
657 xpaned->handle_pos_north.x = -1;
658 xpaned->handle_pos_north.y = -1;
659 xpaned->handle_pos_south.x = -1;
660 xpaned->handle_pos_south.y = -1;
661 xpaned->handle_pos_middle.x = -1;
662 xpaned->handle_pos_middle.y = -1;
664 xpaned->drag_pos.x = -1;
665 xpaned->drag_pos.y = -1;
669 gtk_xpaned_size_request (GtkWidget * widget, GtkRequisition * requisition)
671 GtkXPaned *xpaned = GTK_XPANED (widget);
672 GtkRequisition child_requisition;
674 requisition->width = 0;
675 requisition->height = 0;
677 if (xpaned->top_left_child
678 && gtk_widget_get_visible (xpaned->top_left_child))
680 gtk_widget_size_request (xpaned->top_left_child, &child_requisition);
682 requisition->width = child_requisition.width;
683 requisition->height = child_requisition.height;
686 if (xpaned->top_right_child
687 && gtk_widget_get_visible (xpaned->top_right_child))
689 gtk_widget_size_request (xpaned->top_right_child, &child_requisition);
691 requisition->width += child_requisition.width;
692 requisition->height =
693 MAX (requisition->height, child_requisition.height);
696 if (xpaned->bottom_left_child
697 && gtk_widget_get_visible (xpaned->bottom_left_child))
699 gtk_widget_size_request (xpaned->bottom_left_child, &child_requisition);
701 requisition->width = MAX (requisition->width, child_requisition.width);
702 requisition->height += child_requisition.height;
705 if (xpaned->bottom_right_child
706 && gtk_widget_get_visible (xpaned->bottom_right_child))
708 gtk_widget_size_request (xpaned->bottom_right_child,
711 requisition->width = child_requisition.width;
712 requisition->height = child_requisition.height;
715 /* add 2 times the set border-width to the GtkXPaneds requisition */
716 requisition->width += GTK_CONTAINER (xpaned)->border_width * 2;
717 requisition->height += GTK_CONTAINER (xpaned)->border_width * 2;
719 /* also add the handle "thickness" to GtkXPaneds width- and height-requisitions */
720 if (xpaned->top_left_child
721 && gtk_widget_get_visible (xpaned->top_left_child)
722 && xpaned->top_right_child
723 && gtk_widget_get_visible (xpaned->top_right_child)
724 && xpaned->bottom_left_child
725 && gtk_widget_get_visible (xpaned->bottom_left_child)
726 && xpaned->bottom_right_child
727 && gtk_widget_get_visible (xpaned->bottom_right_child))
731 gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
732 requisition->width += handle_size;
733 requisition->height += handle_size;
738 gtk_xpaned_compute_position (GtkXPaned * xpaned,
739 const GtkAllocation * allocation,
740 GtkRequisition * top_left_child_req,
741 GtkRequisition * top_right_child_req,
742 GtkRequisition * bottom_left_child_req,
743 GtkRequisition * bottom_right_child_req);
747 gtk_xpaned_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
749 GtkXPaned *xpaned = GTK_XPANED (widget);
750 gint border_width = GTK_CONTAINER (xpaned)->border_width;
751 GtkAllocation top_left_child_allocation;
752 GtkAllocation top_right_child_allocation;
753 GtkAllocation bottom_left_child_allocation;
754 GtkAllocation bottom_right_child_allocation;
755 GtkRequisition top_left_child_requisition;
756 GtkRequisition top_right_child_requisition;
757 GtkRequisition bottom_left_child_requisition;
758 GtkRequisition bottom_right_child_requisition;
761 /* determine size of handle(s) */
762 gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
764 widget->allocation = *allocation;
766 if (xpaned->top_left_child
767 && gtk_widget_get_visible (xpaned->top_left_child)
768 && xpaned->top_right_child
769 && gtk_widget_get_visible (xpaned->top_right_child)
770 && xpaned->bottom_left_child
771 && gtk_widget_get_visible (xpaned->bottom_left_child)
772 && xpaned->bottom_right_child
773 && gtk_widget_get_visible (xpaned->bottom_right_child))
775 /* what sizes do the children want to be at least at */
776 gtk_widget_get_child_requisition (xpaned->top_left_child,
777 &top_left_child_requisition);
778 gtk_widget_get_child_requisition (xpaned->top_right_child,
779 &top_right_child_requisition);
780 gtk_widget_get_child_requisition (xpaned->bottom_left_child,
781 &bottom_left_child_requisition);
782 gtk_widget_get_child_requisition (xpaned->bottom_right_child,
783 &bottom_right_child_requisition);
785 /* determine the total requisition-sum of all requisitions of borders,
786 * handles, children etc. */
787 gtk_xpaned_compute_position (xpaned,
789 &top_left_child_requisition,
790 &top_right_child_requisition,
791 &bottom_left_child_requisition,
792 &bottom_right_child_requisition);
794 /* calculate the current positions and sizes of the handles */
795 xpaned->handle_pos_east.x =
796 widget->allocation.x + border_width +
797 xpaned->top_left_child_size.width + handle_size;
798 xpaned->handle_pos_east.y =
799 widget->allocation.y + border_width +
800 xpaned->top_left_child_size.height;
801 xpaned->handle_pos_east.width =
802 widget->allocation.width - xpaned->top_left_child_size.width -
803 2 * border_width - handle_size;
804 xpaned->handle_pos_east.height = handle_size;
806 xpaned->handle_pos_west.x = widget->allocation.x + border_width;
807 xpaned->handle_pos_west.y = xpaned->handle_pos_east.y;
808 xpaned->handle_pos_west.width =
809 widget->allocation.width - xpaned->handle_pos_east.width -
810 2 * border_width - handle_size;
811 xpaned->handle_pos_west.height = handle_size;
813 xpaned->handle_pos_north.x = xpaned->handle_pos_east.x - handle_size;
814 xpaned->handle_pos_north.y = widget->allocation.y + border_width;
815 xpaned->handle_pos_north.width = handle_size;
816 xpaned->handle_pos_north.height =
817 xpaned->handle_pos_east.y - widget->allocation.y - border_width;
819 xpaned->handle_pos_south.x = xpaned->handle_pos_north.x;
820 xpaned->handle_pos_south.y = xpaned->handle_pos_east.y + handle_size;
821 xpaned->handle_pos_south.width = handle_size;
822 xpaned->handle_pos_south.height =
823 widget->allocation.height - xpaned->handle_pos_north.height -
824 2 * border_width - handle_size;
828 xpaned->handle_pos_middle.x = xpaned->handle_pos_north.x;
829 xpaned->handle_pos_middle.y = xpaned->handle_pos_east.y;
830 xpaned->handle_pos_middle.width = handle_size + CENTRUM;
831 xpaned->handle_pos_middle.height = handle_size + CENTRUM;
833 /* set allocation for top-left child */
834 top_left_child_allocation.x = widget->allocation.x + border_width;
835 top_left_child_allocation.y = widget->allocation.y + border_width;
836 top_left_child_allocation.width = xpaned->handle_pos_west.width;
837 top_left_child_allocation.height = xpaned->handle_pos_north.height;
839 /* set allocation for top-right child */
840 top_right_child_allocation.x =
841 widget->allocation.x + border_width + handle_size +
842 top_left_child_allocation.width;
843 top_right_child_allocation.y = widget->allocation.y + border_width;
844 top_right_child_allocation.width = xpaned->handle_pos_east.width;
845 top_right_child_allocation.height = xpaned->handle_pos_north.height;
847 /* set allocation for bottom-left child */
848 bottom_left_child_allocation.x = xpaned->handle_pos_west.x;
849 bottom_left_child_allocation.y = xpaned->handle_pos_south.y;
850 bottom_left_child_allocation.width = xpaned->handle_pos_west.width;
851 bottom_left_child_allocation.height = xpaned->handle_pos_south.height;
853 /* set allocation for bottom-right child */
854 bottom_right_child_allocation.x = top_right_child_allocation.x;
855 bottom_right_child_allocation.y = bottom_left_child_allocation.y;
856 bottom_right_child_allocation.width = xpaned->handle_pos_east.width;
857 bottom_right_child_allocation.height = xpaned->handle_pos_south.height;
859 if (gtk_widget_get_realized (widget))
861 if (gtk_widget_get_mapped (widget))
863 gdk_window_show (xpaned->handle_east);
864 gdk_window_show (xpaned->handle_west);
865 gdk_window_show (xpaned->handle_north);
866 gdk_window_show (xpaned->handle_south);
867 gdk_window_show (xpaned->handle_middle);
870 gdk_window_move_resize (xpaned->handle_east,
871 xpaned->handle_pos_east.x,
872 xpaned->handle_pos_east.y,
873 xpaned->handle_pos_east.width,
874 xpaned->handle_pos_east.height);
876 gdk_window_move_resize (xpaned->handle_west,
877 xpaned->handle_pos_west.x,
878 xpaned->handle_pos_west.y,
879 xpaned->handle_pos_west.width,
880 xpaned->handle_pos_west.height);
882 gdk_window_move_resize (xpaned->handle_north,
883 xpaned->handle_pos_north.x,
884 xpaned->handle_pos_north.y,
885 xpaned->handle_pos_north.width,
886 xpaned->handle_pos_north.height);
888 gdk_window_move_resize (xpaned->handle_south,
889 xpaned->handle_pos_south.x,
890 xpaned->handle_pos_south.y,
891 xpaned->handle_pos_south.width,
892 xpaned->handle_pos_south.height);
894 gdk_window_move_resize (xpaned->handle_middle,
895 xpaned->handle_pos_middle.x,
896 xpaned->handle_pos_middle.y,
897 xpaned->handle_pos_middle.width,
898 xpaned->handle_pos_middle.height);
901 /* Now allocate the childen, making sure, when resizing not to
902 * overlap the windows
904 if (gtk_widget_get_mapped (widget))
906 gtk_widget_size_allocate (xpaned->top_right_child,
907 &top_right_child_allocation);
908 gtk_widget_size_allocate (xpaned->top_left_child,
909 &top_left_child_allocation);
910 gtk_widget_size_allocate (xpaned->bottom_left_child,
911 &bottom_left_child_allocation);
912 gtk_widget_size_allocate (xpaned->bottom_right_child,
913 &bottom_right_child_allocation);
919 gtk_xpaned_set_property (GObject * object,
921 const GValue * value, GParamSpec * pspec)
923 GtkXPaned *xpaned = GTK_XPANED (object);
927 case PROP_X_POSITION:
928 gtk_xpaned_set_position_x (xpaned, g_value_get_int (value));
931 case PROP_Y_POSITION:
932 gtk_xpaned_set_position_y (xpaned, g_value_get_int (value));
935 case PROP_POSITION_SET:
936 xpaned->position_set = g_value_get_boolean (value);
937 gtk_widget_queue_resize (GTK_WIDGET (xpaned));
941 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
947 gtk_xpaned_get_property (GObject * object,
948 guint prop_id, GValue * value, GParamSpec * pspec)
950 GtkXPaned *xpaned = GTK_XPANED (object);
954 case PROP_X_POSITION:
955 g_value_set_int (value, xpaned->top_left_child_size.width);
958 case PROP_Y_POSITION:
959 g_value_set_int (value, xpaned->top_left_child_size.height);
962 case PROP_POSITION_SET:
963 g_value_set_boolean (value, xpaned->position_set);
966 case PROP_MIN_X_POSITION:
967 g_value_set_int (value, xpaned->min_position.x);
970 case PROP_MIN_Y_POSITION:
971 g_value_set_int (value, xpaned->min_position.y);
974 case PROP_MAX_X_POSITION:
975 g_value_set_int (value, xpaned->max_position.x);
978 case PROP_MAX_Y_POSITION:
979 g_value_set_int (value, xpaned->max_position.y);
983 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
989 gtk_xpaned_set_child_property (GtkContainer * container,
992 const GValue * value, GParamSpec * pspec)
994 GtkXPaned *xpaned = GTK_XPANED (container);
995 gboolean old_value = FALSE;
996 gboolean new_value = FALSE;
998 g_assert (child == xpaned->top_left_child ||
999 child == xpaned->top_right_child ||
1000 child == xpaned->bottom_left_child ||
1001 child == xpaned->bottom_right_child);
1003 new_value = g_value_get_boolean (value);
1005 switch (property_id)
1007 case CHILD_PROP_RESIZE:
1008 if (child == xpaned->top_left_child)
1010 old_value = xpaned->top_left_child_resize;
1011 xpaned->top_left_child_resize = new_value;
1013 else if (child == xpaned->top_right_child)
1015 old_value = xpaned->top_right_child_resize;
1016 xpaned->top_right_child_resize = new_value;
1018 else if (child == xpaned->bottom_left_child)
1020 old_value = xpaned->bottom_left_child_resize;
1021 xpaned->bottom_left_child_resize = new_value;
1023 else if (child == xpaned->bottom_right_child)
1025 old_value = xpaned->bottom_right_child_resize;
1026 xpaned->bottom_right_child_resize = new_value;
1030 case CHILD_PROP_SHRINK:
1031 if (child == xpaned->top_left_child)
1033 old_value = xpaned->top_left_child_shrink;
1034 xpaned->top_left_child_shrink = new_value;
1036 else if (child == xpaned->top_right_child)
1038 old_value = xpaned->top_right_child_shrink;
1039 xpaned->top_right_child_shrink = new_value;
1041 else if (child == xpaned->bottom_left_child)
1043 old_value = xpaned->bottom_left_child_shrink;
1044 xpaned->bottom_left_child_shrink = new_value;
1046 else if (child == xpaned->bottom_right_child)
1048 old_value = xpaned->bottom_right_child_shrink;
1049 xpaned->bottom_right_child_shrink = new_value;
1054 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container,
1055 property_id, pspec);
1056 old_value = -1; /* quiet gcc */
1060 if (old_value != new_value)
1061 gtk_widget_queue_resize (GTK_WIDGET (container));
1065 gtk_xpaned_get_child_property (GtkContainer * container,
1068 GValue * value, GParamSpec * pspec)
1070 GtkXPaned *xpaned = GTK_XPANED (container);
1072 g_assert (child == xpaned->top_left_child ||
1073 child == xpaned->top_right_child ||
1074 child == xpaned->bottom_left_child ||
1075 child == xpaned->bottom_right_child);
1077 switch (property_id)
1079 case CHILD_PROP_RESIZE:
1080 if (child == xpaned->top_left_child)
1081 g_value_set_boolean (value, xpaned->top_left_child_resize);
1082 else if (child == xpaned->top_right_child)
1083 g_value_set_boolean (value, xpaned->top_right_child_resize);
1084 else if (child == xpaned->bottom_left_child)
1085 g_value_set_boolean (value, xpaned->bottom_left_child_resize);
1086 else if (child == xpaned->bottom_right_child)
1087 g_value_set_boolean (value, xpaned->bottom_right_child_resize);
1090 case CHILD_PROP_SHRINK:
1091 if (child == xpaned->top_left_child)
1092 g_value_set_boolean (value, xpaned->top_left_child_shrink);
1093 else if (child == xpaned->top_right_child)
1094 g_value_set_boolean (value, xpaned->top_right_child_shrink);
1095 else if (child == xpaned->bottom_left_child)
1096 g_value_set_boolean (value, xpaned->bottom_left_child_shrink);
1097 else if (child == xpaned->bottom_right_child)
1098 g_value_set_boolean (value, xpaned->bottom_right_child_shrink);
1102 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container,
1103 property_id, pspec);
1109 gtk_xpaned_finalize (GObject * object)
1111 GtkXPaned *xpaned = GTK_XPANED (object);
1113 gtk_xpaned_set_saved_focus (xpaned, NULL);
1114 gtk_xpaned_set_first_xpaned (xpaned, NULL);
1116 g_free (xpaned->priv);
1118 G_OBJECT_CLASS (parent_class)->finalize (object);
1122 gtk_xpaned_realize (GtkWidget * widget)
1125 GdkWindowAttr attributes_east;
1126 GdkWindowAttr attributes_west;
1127 GdkWindowAttr attributes_north;
1128 GdkWindowAttr attributes_south;
1129 GdkWindowAttr attributes_middle;
1130 gint attributes_mask_east;
1131 gint attributes_mask_west;
1132 gint attributes_mask_north;
1133 gint attributes_mask_south;
1134 gint attributes_mask_middle;
1136 gtk_widget_set_realized (widget, TRUE);
1137 xpaned = GTK_XPANED (widget);
1139 widget->window = gtk_widget_get_parent_window (widget);
1140 g_object_ref (widget->window);
1142 attributes_east.window_type = GDK_WINDOW_CHILD;
1143 attributes_west.window_type = GDK_WINDOW_CHILD;
1144 attributes_north.window_type = GDK_WINDOW_CHILD;
1145 attributes_south.window_type = GDK_WINDOW_CHILD;
1146 attributes_middle.window_type = GDK_WINDOW_CHILD;
1148 attributes_east.wclass = GDK_INPUT_ONLY;
1149 attributes_west.wclass = GDK_INPUT_ONLY;
1150 attributes_north.wclass = GDK_INPUT_ONLY;
1151 attributes_south.wclass = GDK_INPUT_ONLY;
1152 attributes_middle.wclass = GDK_INPUT_ONLY;
1154 attributes_east.x = xpaned->handle_pos_east.x;
1155 attributes_east.y = xpaned->handle_pos_east.y;
1156 attributes_east.width = xpaned->handle_pos_east.width;
1157 attributes_east.height = xpaned->handle_pos_east.height;
1159 attributes_west.x = xpaned->handle_pos_west.x;
1160 attributes_west.y = xpaned->handle_pos_west.y;
1161 attributes_west.width = xpaned->handle_pos_west.width;
1162 attributes_west.height = xpaned->handle_pos_west.height;
1164 attributes_north.x = xpaned->handle_pos_north.x;
1165 attributes_north.y = xpaned->handle_pos_north.y;
1166 attributes_north.width = xpaned->handle_pos_north.width;
1167 attributes_north.height = xpaned->handle_pos_north.height;
1169 attributes_south.x = xpaned->handle_pos_south.x;
1170 attributes_south.y = xpaned->handle_pos_south.y;
1171 attributes_south.width = xpaned->handle_pos_south.width;
1172 attributes_south.height = xpaned->handle_pos_south.height;
1174 attributes_middle.x = xpaned->handle_pos_middle.x;
1175 attributes_middle.y = xpaned->handle_pos_middle.y;
1176 attributes_middle.width = xpaned->handle_pos_middle.width;
1177 attributes_middle.height = xpaned->handle_pos_middle.height;
1179 attributes_east.cursor =
1180 gdk_cursor_new_for_display (gtk_widget_get_display (widget),
1181 xpaned->cursor_type_east);
1182 attributes_west.cursor =
1183 gdk_cursor_new_for_display (gtk_widget_get_display (widget),
1184 xpaned->cursor_type_west);
1185 attributes_north.cursor =
1186 gdk_cursor_new_for_display (gtk_widget_get_display (widget),
1187 xpaned->cursor_type_north);
1188 attributes_south.cursor =
1189 gdk_cursor_new_for_display (gtk_widget_get_display (widget),
1190 xpaned->cursor_type_south);
1191 attributes_middle.cursor =
1192 gdk_cursor_new_for_display (gtk_widget_get_display (widget),
1193 xpaned->cursor_type_middle);
1195 attributes_east.event_mask = gtk_widget_get_events (widget);
1196 attributes_west.event_mask = gtk_widget_get_events (widget);
1197 attributes_north.event_mask = gtk_widget_get_events (widget);
1198 attributes_south.event_mask = gtk_widget_get_events (widget);
1199 attributes_middle.event_mask = gtk_widget_get_events (widget);
1201 attributes_east.event_mask |= (GDK_BUTTON_PRESS_MASK |
1202 GDK_BUTTON_RELEASE_MASK |
1203 GDK_ENTER_NOTIFY_MASK |
1204 GDK_LEAVE_NOTIFY_MASK |
1205 GDK_POINTER_MOTION_MASK |
1206 GDK_POINTER_MOTION_HINT_MASK);
1207 attributes_west.event_mask |= (GDK_BUTTON_PRESS_MASK |
1208 GDK_BUTTON_RELEASE_MASK |
1209 GDK_ENTER_NOTIFY_MASK |
1210 GDK_LEAVE_NOTIFY_MASK |
1211 GDK_POINTER_MOTION_MASK |
1212 GDK_POINTER_MOTION_HINT_MASK);
1213 attributes_north.event_mask |= (GDK_BUTTON_PRESS_MASK |
1214 GDK_BUTTON_RELEASE_MASK |
1215 GDK_ENTER_NOTIFY_MASK |
1216 GDK_LEAVE_NOTIFY_MASK |
1217 GDK_POINTER_MOTION_MASK |
1218 GDK_POINTER_MOTION_HINT_MASK);
1219 attributes_south.event_mask |= (GDK_BUTTON_PRESS_MASK |
1220 GDK_BUTTON_RELEASE_MASK |
1221 GDK_ENTER_NOTIFY_MASK |
1222 GDK_LEAVE_NOTIFY_MASK |
1223 GDK_POINTER_MOTION_MASK |
1224 GDK_POINTER_MOTION_HINT_MASK);
1225 attributes_middle.event_mask |= (GDK_BUTTON_PRESS_MASK |
1226 GDK_BUTTON_RELEASE_MASK |
1227 GDK_ENTER_NOTIFY_MASK |
1228 GDK_LEAVE_NOTIFY_MASK |
1229 GDK_POINTER_MOTION_MASK |
1230 GDK_POINTER_MOTION_HINT_MASK);
1232 attributes_mask_east = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
1233 attributes_mask_west = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
1234 attributes_mask_north = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
1235 attributes_mask_south = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
1236 attributes_mask_middle = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
1238 xpaned->handle_east = gdk_window_new (widget->window,
1240 attributes_mask_east);
1241 xpaned->handle_west = gdk_window_new (widget->window,
1243 attributes_mask_west);
1244 xpaned->handle_north = gdk_window_new (widget->window,
1246 attributes_mask_north);
1247 xpaned->handle_south = gdk_window_new (widget->window,
1249 attributes_mask_south);
1250 xpaned->handle_middle = gdk_window_new (widget->window,
1252 attributes_mask_middle);
1254 gdk_window_set_user_data (xpaned->handle_east, xpaned);
1255 gdk_window_set_user_data (xpaned->handle_west, xpaned);
1256 gdk_window_set_user_data (xpaned->handle_north, xpaned);
1257 gdk_window_set_user_data (xpaned->handle_south, xpaned);
1258 gdk_window_set_user_data (xpaned->handle_middle, xpaned);
1260 gdk_cursor_unref (attributes_east.cursor);
1261 gdk_cursor_unref (attributes_west.cursor);
1262 gdk_cursor_unref (attributes_north.cursor);
1263 gdk_cursor_unref (attributes_south.cursor);
1264 gdk_cursor_unref (attributes_middle.cursor);
1266 widget->style = gtk_style_attach (widget->style, widget->window);
1268 if (xpaned->top_left_child
1269 && gtk_widget_get_visible (xpaned->top_left_child)
1270 && xpaned->top_right_child
1271 && gtk_widget_get_visible (xpaned->top_right_child)
1272 && xpaned->bottom_left_child
1273 && gtk_widget_get_visible (xpaned->bottom_left_child)
1274 && xpaned->bottom_right_child
1275 && gtk_widget_get_visible (xpaned->bottom_right_child))
1277 gdk_window_show (xpaned->handle_east);
1278 gdk_window_show (xpaned->handle_west);
1279 gdk_window_show (xpaned->handle_north);
1280 gdk_window_show (xpaned->handle_south);
1281 gdk_window_show (xpaned->handle_middle);
1286 gtk_xpaned_unrealize (GtkWidget * widget)
1288 GtkXPaned *xpaned = GTK_XPANED (widget);
1292 g_object_unref (xpaned->xor_gc);
1293 xpaned->xor_gc = NULL;
1296 if (xpaned->handle_east)
1298 gdk_window_set_user_data (xpaned->handle_east, NULL);
1299 gdk_window_destroy (xpaned->handle_east);
1300 xpaned->handle_east = NULL;
1303 if (xpaned->handle_west)
1305 gdk_window_set_user_data (xpaned->handle_west, NULL);
1306 gdk_window_destroy (xpaned->handle_west);
1307 xpaned->handle_west = NULL;
1310 if (xpaned->handle_north)
1312 gdk_window_set_user_data (xpaned->handle_north, NULL);
1313 gdk_window_destroy (xpaned->handle_north);
1314 xpaned->handle_north = NULL;
1317 if (xpaned->handle_south)
1319 gdk_window_set_user_data (xpaned->handle_south, NULL);
1320 gdk_window_destroy (xpaned->handle_south);
1321 xpaned->handle_south = NULL;
1324 if (xpaned->handle_middle)
1326 gdk_window_set_user_data (xpaned->handle_middle, NULL);
1327 gdk_window_destroy (xpaned->handle_middle);
1328 xpaned->handle_middle = NULL;
1331 gtk_xpaned_set_last_top_left_child_focus (xpaned, NULL);
1332 gtk_xpaned_set_last_top_right_child_focus (xpaned, NULL);
1333 gtk_xpaned_set_last_bottom_left_child_focus (xpaned, NULL);
1334 gtk_xpaned_set_last_bottom_right_child_focus (xpaned, NULL);
1335 gtk_xpaned_set_saved_focus (xpaned, NULL);
1336 gtk_xpaned_set_first_xpaned (xpaned, NULL);
1338 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
1339 (*GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
1343 gtk_xpaned_map (GtkWidget * widget)
1345 GtkXPaned *xpaned = GTK_XPANED (widget);
1347 gdk_window_show (xpaned->handle_east);
1348 gdk_window_show (xpaned->handle_west);
1349 gdk_window_show (xpaned->handle_north);
1350 gdk_window_show (xpaned->handle_south);
1351 gdk_window_show (xpaned->handle_middle);
1353 GTK_WIDGET_CLASS (parent_class)->map (widget);
1357 gtk_xpaned_unmap (GtkWidget * widget)
1359 GtkXPaned *xpaned = GTK_XPANED (widget);
1361 gdk_window_hide (xpaned->handle_east);
1362 gdk_window_hide (xpaned->handle_west);
1363 gdk_window_hide (xpaned->handle_north);
1364 gdk_window_hide (xpaned->handle_south);
1365 gdk_window_hide (xpaned->handle_middle);
1367 GTK_WIDGET_CLASS (parent_class)->unmap (widget);
1371 gtk_xpaned_expose (GtkWidget * widget, GdkEventExpose * event)
1373 GtkXPaned *xpaned = GTK_XPANED (widget);
1375 GdkRectangle horizontalClipArea;
1376 GdkRectangle verticalClipArea;
1378 /* determine size of handle(s) */
1379 gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
1381 /* I want the handle-"thickness" to be at least 3 */
1382 g_assert (handle_size >= 3);
1384 if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget) &&
1385 xpaned->top_left_child
1386 && gtk_widget_get_visible (xpaned->top_left_child)
1387 && xpaned->top_right_child
1388 && gtk_widget_get_visible (xpaned->top_right_child)
1389 && xpaned->bottom_left_child
1390 && gtk_widget_get_visible (xpaned->bottom_left_child)
1391 && xpaned->bottom_right_child
1392 && gtk_widget_get_visible (xpaned->bottom_right_child))
1396 if (gtk_widget_is_focus (widget))
1397 state = GTK_STATE_SELECTED;
1398 else if (xpaned->handle_prelit)
1399 state = GTK_STATE_PRELIGHT;
1401 state = gtk_widget_get_state (widget);
1403 horizontalClipArea.x = xpaned->handle_pos_west.x;
1404 horizontalClipArea.y = xpaned->handle_pos_west.y;
1405 horizontalClipArea.width =
1406 xpaned->handle_pos_west.width + handle_size +
1407 xpaned->handle_pos_east.width;
1408 horizontalClipArea.height = handle_size;
1410 verticalClipArea.x = xpaned->handle_pos_north.x;
1411 verticalClipArea.y = xpaned->handle_pos_north.y;
1412 verticalClipArea.width = handle_size;
1413 verticalClipArea.height =
1414 xpaned->handle_pos_north.height + handle_size +
1415 xpaned->handle_pos_south.height;
1417 gtk_paint_handle (widget->style,
1421 &horizontalClipArea,
1424 xpaned->handle_pos_east.x - handle_size - 256 / 2,
1425 xpaned->handle_pos_west.y + 1,
1426 256 + handle_size, handle_size - 2,
1427 /*xpaned->handle_pos_west.x,
1428 xpaned->handle_pos_west.y + 1,
1429 xpaned->handle_pos_west.width + handle_size + xpaned->handle_pos_east.width,
1431 GTK_ORIENTATION_HORIZONTAL);
1432 gtk_paint_handle (widget->style,
1439 xpaned->handle_pos_north.x + 1,
1440 xpaned->handle_pos_south.y - handle_size - 256 / 2,
1441 handle_size - 2, 256 + handle_size,
1442 /*xpaned->handle_pos_north.x + 1,
1443 xpaned->handle_pos_north.y,
1445 xpaned->handle_pos_north.height + handle_size + xpaned->handle_pos_south.height, */
1446 GTK_ORIENTATION_VERTICAL);
1449 /* Chain up to draw children */
1450 GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
1456 is_rtl (GtkXPaned * xpaned)
1458 if (gtk_widget_get_direction (GTK_WIDGET (xpaned)) == GTK_TEXT_DIR_RTL)
1465 update_drag (GtkXPaned * xpaned)
1469 GtkRequisition size;
1471 gtk_widget_get_pointer (GTK_WIDGET (xpaned), &pos.x, &pos.y);
1473 if (xpaned->in_drag_vert)
1475 pos.y -= xpaned->drag_pos.y;
1477 if (is_rtl (xpaned))
1479 gtk_widget_style_get (GTK_WIDGET (xpaned),
1480 "handle-size", &handle_size, NULL);
1483 GTK_WIDGET (xpaned)->allocation.height - pos.y - handle_size;
1487 size.height = pos.y;
1490 size.height -= GTK_CONTAINER (xpaned)->border_width;
1493 CLAMP (size.height, xpaned->min_position.y, xpaned->max_position.y);
1495 if (size.height != xpaned->top_left_child_size.height)
1496 gtk_xpaned_set_position_y (xpaned, size.height);
1499 if (xpaned->in_drag_horiz)
1501 pos.x -= xpaned->drag_pos.x;
1503 if (is_rtl (xpaned))
1505 gtk_widget_style_get (GTK_WIDGET (xpaned),
1506 "handle-size", &handle_size, NULL);
1509 GTK_WIDGET (xpaned)->allocation.width - pos.x - handle_size;
1516 size.width -= GTK_CONTAINER (xpaned)->border_width;
1519 CLAMP (size.width, xpaned->min_position.x, xpaned->max_position.x);
1521 if (size.width != xpaned->top_left_child_size.width)
1522 gtk_xpaned_set_position_x (xpaned, size.width);
1525 if (xpaned->in_drag_vert_and_horiz)
1527 pos.x -= xpaned->drag_pos.x;
1528 pos.y -= xpaned->drag_pos.y;
1530 if (is_rtl (xpaned))
1532 gtk_widget_style_get (GTK_WIDGET (xpaned),
1533 "handle-size", &handle_size, NULL);
1536 GTK_WIDGET (xpaned)->allocation.width - pos.x - handle_size;
1538 GTK_WIDGET (xpaned)->allocation.height - pos.y - handle_size;
1543 size.height = pos.y;
1546 size.width -= GTK_CONTAINER (xpaned)->border_width;
1547 size.height -= GTK_CONTAINER (xpaned)->border_width;
1550 CLAMP (size.width, xpaned->min_position.x, xpaned->max_position.x);
1552 CLAMP (size.height, xpaned->min_position.y, xpaned->max_position.y);
1554 if (size.width != xpaned->top_left_child_size.width)
1555 gtk_xpaned_set_position_x (xpaned, size.width);
1557 if (size.height != xpaned->top_left_child_size.height)
1558 gtk_xpaned_set_position_y (xpaned, size.height);
1563 gtk_xpaned_enter (GtkWidget * widget, GdkEventCrossing * event)
1565 GtkXPaned *xpaned = GTK_XPANED (widget);
1567 if (xpaned->in_drag_vert ||
1568 xpaned->in_drag_horiz || xpaned->in_drag_vert_and_horiz)
1569 update_drag (xpaned);
1572 xpaned->handle_prelit = TRUE;
1574 gtk_widget_queue_draw_area (widget,
1575 xpaned->handle_pos_east.x,
1576 xpaned->handle_pos_east.y,
1577 xpaned->handle_pos_east.width,
1578 xpaned->handle_pos_east.height);
1580 gtk_widget_queue_draw_area (widget,
1581 xpaned->handle_pos_west.x,
1582 xpaned->handle_pos_west.y,
1583 xpaned->handle_pos_west.width,
1584 xpaned->handle_pos_west.height);
1586 gtk_widget_queue_draw_area (widget,
1587 xpaned->handle_pos_north.x,
1588 xpaned->handle_pos_north.y,
1589 xpaned->handle_pos_north.width,
1590 xpaned->handle_pos_north.height);
1592 gtk_widget_queue_draw_area (widget,
1593 xpaned->handle_pos_south.x,
1594 xpaned->handle_pos_south.y,
1595 xpaned->handle_pos_south.width,
1596 xpaned->handle_pos_south.height);
1598 gtk_widget_queue_draw_area (widget,
1599 xpaned->handle_pos_middle.x,
1600 xpaned->handle_pos_middle.y,
1601 xpaned->handle_pos_middle.width,
1602 xpaned->handle_pos_middle.height);
1609 gtk_xpaned_leave (GtkWidget * widget, GdkEventCrossing * event)
1611 GtkXPaned *xpaned = GTK_XPANED (widget);
1613 if (xpaned->in_drag_vert ||
1614 xpaned->in_drag_horiz || xpaned->in_drag_vert_and_horiz)
1615 update_drag (xpaned);
1618 xpaned->handle_prelit = FALSE;
1620 gtk_widget_queue_draw_area (widget,
1621 xpaned->handle_pos_east.x,
1622 xpaned->handle_pos_east.y,
1623 xpaned->handle_pos_east.width,
1624 xpaned->handle_pos_east.height);
1626 gtk_widget_queue_draw_area (widget,
1627 xpaned->handle_pos_west.x,
1628 xpaned->handle_pos_west.y,
1629 xpaned->handle_pos_west.width,
1630 xpaned->handle_pos_west.height);
1632 gtk_widget_queue_draw_area (widget,
1633 xpaned->handle_pos_north.x,
1634 xpaned->handle_pos_north.y,
1635 xpaned->handle_pos_north.width,
1636 xpaned->handle_pos_north.height);
1638 gtk_widget_queue_draw_area (widget,
1639 xpaned->handle_pos_south.x,
1640 xpaned->handle_pos_south.y,
1641 xpaned->handle_pos_south.width,
1642 xpaned->handle_pos_south.height);
1644 gtk_widget_queue_draw_area (widget,
1645 xpaned->handle_pos_middle.x,
1646 xpaned->handle_pos_middle.y,
1647 xpaned->handle_pos_middle.width,
1648 xpaned->handle_pos_middle.height);
1655 gtk_xpaned_focus (GtkWidget * widget, GtkDirectionType direction)
1659 /* This is a hack, but how can this be done without
1660 * excessive cut-and-paste from gtkcontainer.c?
1663 gtk_widget_set_can_focus (GTK_WIDGET (widget), FALSE);
1664 retval = (*GTK_WIDGET_CLASS (parent_class)->focus) (widget, direction);
1665 gtk_widget_set_can_focus (GTK_WIDGET (widget), TRUE);
1671 gtk_xpaned_button_press (GtkWidget * widget, GdkEventButton * event)
1673 GtkXPaned *xpaned = GTK_XPANED (widget);
1675 /* if any child is currently maximized, jump right back */
1676 if (xpaned->maximized[GTK_XPANED_TOP_LEFT] ||
1677 xpaned->maximized[GTK_XPANED_TOP_RIGHT] ||
1678 xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] ||
1679 xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT])
1682 /* if user is dragging the handles around */
1683 if (!xpaned->in_drag_vert_and_horiz &&
1684 event->window != xpaned->handle_east &&
1685 event->window != xpaned->handle_west &&
1686 event->window != xpaned->handle_north &&
1687 event->window != xpaned->handle_south &&
1688 event->window == xpaned->handle_middle && event->button == 1)
1690 xpaned->in_drag_vert_and_horiz = TRUE;
1692 /* We need a server grab here, not gtk_grab_add(), since
1693 * we don't want to pass events on to the widget's children */
1694 if (gdk_pointer_grab (xpaned->handle_middle,
1696 GDK_POINTER_MOTION_HINT_MASK
1697 | GDK_BUTTON1_MOTION_MASK
1698 | GDK_BUTTON_RELEASE_MASK
1699 | GDK_ENTER_NOTIFY_MASK
1700 | GDK_LEAVE_NOTIFY_MASK,
1701 NULL, NULL, event->time) == GDK_GRAB_SUCCESS)
1705 xpaned->drag_pos.x = event->x;
1706 xpaned->drag_pos.y = event->y;
1710 else if (!xpaned->in_drag_vert &&
1711 event->window == xpaned->handle_east &&
1712 event->window != xpaned->handle_west &&
1713 event->window != xpaned->handle_north &&
1714 event->window != xpaned->handle_south &&
1715 event->window != xpaned->handle_middle && event->button == 1)
1717 xpaned->in_drag_vert = TRUE;
1719 /* We need a server grab here, not gtk_grab_add(), since
1720 * we don't want to pass events on to the widget's children */
1721 if (gdk_pointer_grab (xpaned->handle_east,
1723 GDK_POINTER_MOTION_HINT_MASK
1724 | GDK_BUTTON1_MOTION_MASK
1725 | GDK_BUTTON_RELEASE_MASK
1726 | GDK_ENTER_NOTIFY_MASK
1727 | GDK_LEAVE_NOTIFY_MASK,
1728 NULL, NULL, event->time) == GDK_GRAB_SUCCESS)
1732 xpaned->drag_pos.y = event->y;
1736 else if (!xpaned->in_drag_vert &&
1737 event->window != xpaned->handle_east &&
1738 event->window == xpaned->handle_west &&
1739 event->window != xpaned->handle_north &&
1740 event->window != xpaned->handle_south &&
1741 event->window != xpaned->handle_middle && event->button == 1)
1743 xpaned->in_drag_vert = TRUE;
1745 /* We need a server grab here, not gtk_grab_add(), since
1746 * we don't want to pass events on to the widget's children */
1747 if (gdk_pointer_grab (xpaned->handle_west,
1749 GDK_POINTER_MOTION_HINT_MASK
1750 | GDK_BUTTON1_MOTION_MASK
1751 | GDK_BUTTON_RELEASE_MASK
1752 | GDK_ENTER_NOTIFY_MASK
1753 | GDK_LEAVE_NOTIFY_MASK,
1754 NULL, NULL, event->time) == GDK_GRAB_SUCCESS)
1758 xpaned->drag_pos.y = event->y;
1762 else if (!xpaned->in_drag_horiz &&
1763 event->window != xpaned->handle_east &&
1764 event->window != xpaned->handle_west &&
1765 event->window == xpaned->handle_north &&
1766 event->window != xpaned->handle_south &&
1767 event->window != xpaned->handle_middle && event->button == 1)
1769 xpaned->in_drag_horiz = TRUE;
1771 /* We need a server grab here, not gtk_grab_add(), since
1772 * we don't want to pass events on to the widget's children */
1773 if (gdk_pointer_grab (xpaned->handle_north,
1775 GDK_POINTER_MOTION_HINT_MASK
1776 | GDK_BUTTON1_MOTION_MASK
1777 | GDK_BUTTON_RELEASE_MASK
1778 | GDK_ENTER_NOTIFY_MASK
1779 | GDK_LEAVE_NOTIFY_MASK,
1780 NULL, NULL, event->time) == GDK_GRAB_SUCCESS)
1784 xpaned->drag_pos.x = event->x;
1788 else if (!xpaned->in_drag_horiz &&
1789 event->window != xpaned->handle_east &&
1790 event->window != xpaned->handle_west &&
1791 event->window != xpaned->handle_north &&
1792 event->window == xpaned->handle_south &&
1793 event->window != xpaned->handle_middle && event->button == 1)
1795 xpaned->in_drag_horiz = TRUE;
1797 /* We need a server grab here, not gtk_grab_add(), since
1798 * we don't want to pass events on to the widget's children */
1799 if (gdk_pointer_grab (xpaned->handle_south,
1801 GDK_POINTER_MOTION_HINT_MASK
1802 | GDK_BUTTON1_MOTION_MASK
1803 | GDK_BUTTON_RELEASE_MASK
1804 | GDK_ENTER_NOTIFY_MASK
1805 | GDK_LEAVE_NOTIFY_MASK,
1806 NULL, NULL, event->time) == GDK_GRAB_SUCCESS)
1810 xpaned->drag_pos.x = event->x;
1818 gtk_xpaned_button_release (GtkWidget * widget, GdkEventButton * event)
1820 GtkXPaned *xpaned = GTK_XPANED (widget);
1822 if (xpaned->in_drag_vert && (event->button == 1))
1824 xpaned->in_drag_vert = FALSE;
1825 xpaned->drag_pos.y = -1;
1826 xpaned->position_set = TRUE;
1827 gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
1831 else if (xpaned->in_drag_horiz && (event->button == 1))
1833 xpaned->in_drag_horiz = FALSE;
1834 xpaned->drag_pos.x = -1;
1835 xpaned->position_set = TRUE;
1836 gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
1840 else if (xpaned->in_drag_vert_and_horiz && (event->button == 1))
1842 xpaned->in_drag_vert_and_horiz = FALSE;
1843 xpaned->drag_pos.x = -1;
1844 xpaned->drag_pos.y = -1;
1845 xpaned->position_set = TRUE;
1846 gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
1855 gtk_xpaned_motion (GtkWidget * widget, GdkEventMotion * event)
1857 GtkXPaned *xpaned = GTK_XPANED (widget);
1859 if (xpaned->in_drag_vert ||
1860 xpaned->in_drag_horiz || xpaned->in_drag_vert_and_horiz)
1863 update_drag (xpaned);
1871 gtk_xpaned_add_top_left (GtkXPaned * xpaned, GtkWidget * widget)
1873 gtk_xpaned_pack_top_left (xpaned, widget, FALSE, TRUE);
1877 gtk_xpaned_add_top_right (GtkXPaned * xpaned, GtkWidget * widget)
1879 gtk_xpaned_pack_top_right (xpaned, widget, FALSE, TRUE);
1883 gtk_xpaned_add_bottom_left (GtkXPaned * xpaned, GtkWidget * widget)
1885 gtk_xpaned_pack_bottom_left (xpaned, widget, FALSE, TRUE);
1889 gtk_xpaned_add_bottom_right (GtkXPaned * xpaned, GtkWidget * widget)
1891 gtk_xpaned_pack_bottom_right (xpaned, widget, FALSE, TRUE);
1895 gtk_xpaned_pack_top_left (GtkXPaned * xpaned,
1896 GtkWidget * child, gboolean resize, gboolean shrink)
1898 g_return_if_fail (GTK_IS_XPANED (xpaned));
1899 g_return_if_fail (GTK_IS_WIDGET (child));
1901 if (!xpaned->top_left_child)
1903 xpaned->top_left_child = child;
1904 xpaned->top_left_child_resize = resize;
1905 xpaned->top_left_child_shrink = shrink;
1907 gtk_widget_set_parent (child, GTK_WIDGET (xpaned));
1912 gtk_xpaned_pack_top_right (GtkXPaned * xpaned,
1914 gboolean resize, gboolean shrink)
1916 g_return_if_fail (GTK_IS_XPANED (xpaned));
1917 g_return_if_fail (GTK_IS_WIDGET (child));
1919 if (!xpaned->top_right_child)
1921 xpaned->top_right_child = child;
1922 xpaned->top_right_child_resize = resize;
1923 xpaned->top_right_child_shrink = shrink;
1925 gtk_widget_set_parent (child, GTK_WIDGET (xpaned));
1930 gtk_xpaned_pack_bottom_left (GtkXPaned * xpaned,
1932 gboolean resize, gboolean shrink)
1934 g_return_if_fail (GTK_IS_XPANED (xpaned));
1935 g_return_if_fail (GTK_IS_WIDGET (child));
1937 if (!xpaned->bottom_left_child)
1939 xpaned->bottom_left_child = child;
1940 xpaned->bottom_left_child_resize = resize;
1941 xpaned->bottom_left_child_shrink = shrink;
1943 gtk_widget_set_parent (child, GTK_WIDGET (xpaned));
1948 gtk_xpaned_pack_bottom_right (GtkXPaned * xpaned,
1950 gboolean resize, gboolean shrink)
1952 g_return_if_fail (GTK_IS_XPANED (xpaned));
1953 g_return_if_fail (GTK_IS_WIDGET (child));
1955 if (!xpaned->bottom_right_child)
1957 xpaned->bottom_right_child = child;
1958 xpaned->bottom_right_child_resize = resize;
1959 xpaned->bottom_right_child_shrink = shrink;
1961 gtk_widget_set_parent (child, GTK_WIDGET (xpaned));
1966 gtk_xpaned_add (GtkContainer * container, GtkWidget * widget)
1970 g_return_if_fail (GTK_IS_XPANED (container));
1972 xpaned = GTK_XPANED (container);
1974 if (!xpaned->top_left_child)
1975 gtk_xpaned_add_top_left (xpaned, widget);
1976 else if (!xpaned->top_right_child)
1977 gtk_xpaned_add_top_right (xpaned, widget);
1978 else if (!xpaned->bottom_left_child)
1979 gtk_xpaned_add_bottom_left (xpaned, widget);
1980 else if (!xpaned->bottom_right_child)
1981 gtk_xpaned_add_bottom_right (xpaned, widget);
1983 g_warning ("GtkXPaned cannot have more than 4 children\n");
1987 gtk_xpaned_remove (GtkContainer * container, GtkWidget * widget)
1990 gboolean was_visible;
1992 xpaned = GTK_XPANED (container);
1993 was_visible = gtk_widget_get_visible (widget);
1995 if (xpaned->top_left_child == widget)
1997 gtk_widget_unparent (widget);
1999 xpaned->top_left_child = NULL;
2001 if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
2002 gtk_widget_queue_resize (GTK_WIDGET (container));
2004 else if (xpaned->top_right_child == widget)
2006 gtk_widget_unparent (widget);
2008 xpaned->top_right_child = NULL;
2010 if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
2011 gtk_widget_queue_resize (GTK_WIDGET (container));
2013 else if (xpaned->bottom_left_child == widget)
2015 gtk_widget_unparent (widget);
2017 xpaned->bottom_left_child = NULL;
2019 if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
2020 gtk_widget_queue_resize (GTK_WIDGET (container));
2022 else if (xpaned->bottom_right_child == widget)
2024 gtk_widget_unparent (widget);
2026 xpaned->bottom_right_child = NULL;
2028 if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
2029 gtk_widget_queue_resize (GTK_WIDGET (container));
2032 g_warning ("GtkXPaned has no more children attached\n");
2037 gtk_xpaned_forall (GtkContainer * container,
2038 gboolean include_internals,
2039 GtkCallback callback, gpointer callback_data)
2043 g_return_if_fail (callback != NULL);
2045 xpaned = GTK_XPANED (container);
2047 if (xpaned->top_left_child)
2048 (*callback) (xpaned->top_left_child, callback_data);
2049 if (xpaned->top_right_child)
2050 (*callback) (xpaned->top_right_child, callback_data);
2051 if (xpaned->bottom_left_child)
2052 (*callback) (xpaned->bottom_left_child, callback_data);
2053 if (xpaned->bottom_right_child)
2054 (*callback) (xpaned->bottom_right_child, callback_data);
2058 * gtk_xpaned_get_position_x:
2059 * @paned: a #GtkXPaned widget
2061 * Obtains the x-position of the divider.
2063 * Return value: x-position of the divider
2066 gtk_xpaned_get_position_x (GtkXPaned * xpaned)
2068 g_return_val_if_fail (GTK_IS_XPANED (xpaned), 0);
2070 return xpaned->top_left_child_size.width;
2074 * gtk_xpaned_get_position_y:
2075 * @paned: a #GtkXPaned widget
2077 * Obtains the y-position of the divider.
2079 * Return value: y-position of the divider
2082 gtk_xpaned_get_position_y (GtkXPaned * xpaned)
2084 g_return_val_if_fail (GTK_IS_XPANED (xpaned), 0);
2086 return xpaned->top_left_child_size.height;
2090 * gtk_xpaned_set_position_x:
2091 * @paned: a #GtkXPaned widget
2092 * @xposition: pixel x-position of divider, a negative values
2093 * of a component mean that the position is unset.
2095 * Sets the x-position of the divider between the four panes.
2098 gtk_xpaned_set_position_x (GtkXPaned * xpaned, gint xposition)
2102 g_return_if_fail (GTK_IS_XPANED (xpaned));
2104 /* if any child is currently maximized, jump right back */
2105 if (xpaned->maximized[GTK_XPANED_TOP_LEFT] ||
2106 xpaned->maximized[GTK_XPANED_TOP_RIGHT] ||
2107 xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] ||
2108 xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT])
2111 object = G_OBJECT (xpaned);
2115 /* We don't clamp here - the assumption is that
2116 * if the total allocation changes at the same time
2117 * as the position, the position set is with reference
2118 * to the new total size. If only the position changes,
2119 * then clamping will occur in gtk_paned_compute_position()
2122 xpaned->top_left_child_size.width = xposition;
2123 xpaned->position_set = TRUE;
2127 xpaned->position_set = FALSE;
2130 g_object_freeze_notify (object);
2131 g_object_notify (object, "x-position");
2132 g_object_notify (object, "position-set");
2133 g_object_thaw_notify (object);
2135 gtk_widget_queue_resize (GTK_WIDGET (xpaned));
2139 * gtk_xpaned_set_position_y:
2140 * @paned: a #GtkXPaned widget
2141 * @yposition: pixel y-position of divider, a negative values
2142 * of a component mean that the position is unset.
2144 * Sets the y-position of the divider between the four panes.
2147 gtk_xpaned_set_position_y (GtkXPaned * xpaned, gint yposition)
2151 g_return_if_fail (GTK_IS_XPANED (xpaned));
2153 /* if any child is currently maximized, jump right back */
2154 if (xpaned->maximized[GTK_XPANED_TOP_LEFT] ||
2155 xpaned->maximized[GTK_XPANED_TOP_RIGHT] ||
2156 xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] ||
2157 xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT])
2160 object = G_OBJECT (xpaned);
2164 /* We don't clamp here - the assumption is that
2165 * if the total allocation changes at the same time
2166 * as the position, the position set is with reference
2167 * to the new total size. If only the position changes,
2168 * then clamping will occur in gtk_paned_compute_position()
2171 xpaned->top_left_child_size.height = yposition;
2172 xpaned->position_set = TRUE;
2176 xpaned->position_set = FALSE;
2179 g_object_freeze_notify (object);
2180 g_object_notify (object, "y-position");
2181 g_object_notify (object, "position-set");
2182 g_object_thaw_notify (object);
2184 gtk_widget_queue_resize (GTK_WIDGET (xpaned));
2187 /* this call is private and only intended for internal use! */
2189 gtk_xpaned_save_unmaximized_x (GtkXPaned * xpaned)
2191 xpaned->unmaximized_position.x = gtk_xpaned_get_position_x (xpaned);
2194 /* this call is private and only intended for internal use! */
2196 gtk_xpaned_save_unmaximized_y (GtkXPaned * xpaned)
2198 xpaned->unmaximized_position.y = gtk_xpaned_get_position_y (xpaned);
2201 /* this call is private and only intended for internal use! */
2203 gtk_xpaned_fetch_unmaximized_x (GtkXPaned * xpaned)
2205 return xpaned->unmaximized_position.x;
2208 /* this call is private and only intended for internal use! */
2210 gtk_xpaned_fetch_unmaximized_y (GtkXPaned * xpaned)
2212 return xpaned->unmaximized_position.y;
2216 * gtk_xpaned_get_top_left_child:
2217 * @xpaned: a #GtkXPaned widget
2219 * Obtains the top-left child of the xpaned widget.
2221 * Return value: top-left child, or %NULL if it is not set.
2226 gtk_xpaned_get_top_left_child (GtkXPaned * xpaned)
2228 g_return_val_if_fail (GTK_IS_XPANED (xpaned), NULL);
2230 return xpaned->top_left_child;
2234 * gtk_xpaned_get_top_right_child:
2235 * @xpaned: a #GtkXPaned widget
2237 * Obtains the top-right child of the xpaned widget.
2239 * Return value: top-right child, or %NULL if it is not set.
2244 gtk_xpaned_get_top_right_child (GtkXPaned * xpaned)
2246 g_return_val_if_fail (GTK_IS_XPANED (xpaned), NULL);
2248 return xpaned->top_right_child;
2252 * gtk_xpaned_get_bottom_left_child:
2253 * @xpaned: a #GtkXPaned widget
2255 * Obtains the bottom-left child of the xpaned widget.
2257 * Return value: bottom-left child, or %NULL if it is not set.
2262 gtk_xpaned_get_bottom_left_child (GtkXPaned * xpaned)
2264 g_return_val_if_fail (GTK_IS_XPANED (xpaned), NULL);
2266 return xpaned->bottom_left_child;
2270 * gtk_xpaned_get_bottom_right_child:
2271 * @xpaned: a #GtkXPaned widget
2273 * Obtains the bottom-right child of the xpaned widget.
2275 * Return value: bottom-right child, or %NULL if it is not set.
2280 gtk_xpaned_get_bottom_right_child (GtkXPaned * xpaned)
2282 g_return_val_if_fail (GTK_IS_XPANED (xpaned), NULL);
2284 return xpaned->bottom_right_child;
2288 gtk_xpaned_maximize_top_left (GtkXPaned * xpaned, gboolean maximize)
2292 /* see if any child is already maximized */
2293 if (!xpaned->maximized[GTK_XPANED_TOP_LEFT] &&
2294 !xpaned->maximized[GTK_XPANED_TOP_RIGHT] &&
2295 !xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] &&
2296 !xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT])
2298 /* save current position */
2299 gtk_xpaned_save_unmaximized_x (xpaned);
2300 gtk_xpaned_save_unmaximized_y (xpaned);
2302 /* set new maximized position */
2303 gtk_xpaned_set_position_x (xpaned, xpaned->max_position.x);
2304 gtk_xpaned_set_position_y (xpaned, xpaned->max_position.y);
2306 /* mark maximized flag for top-left child */
2307 xpaned->maximized[GTK_XPANED_TOP_LEFT] = TRUE;
2311 /* already one child maximized, report error */
2317 /* verify that top-left child is really currently maximized */
2318 if (xpaned->maximized[GTK_XPANED_TOP_LEFT])
2320 /* clear maximized flat for top-left child */
2321 xpaned->maximized[GTK_XPANED_TOP_LEFT] = FALSE;
2323 /* restore unmaximized position */
2324 gtk_xpaned_set_position_x (xpaned,
2325 gtk_xpaned_fetch_unmaximized_x (xpaned));
2326 gtk_xpaned_set_position_y (xpaned,
2327 gtk_xpaned_fetch_unmaximized_y (xpaned));
2331 /* top-left child is currently not maximized, report error */
2338 gtk_xpaned_maximize_top_right (GtkXPaned * xpaned, gboolean maximize)
2342 /* see if any child is already maximized */
2343 if (!xpaned->maximized[GTK_XPANED_TOP_LEFT] &&
2344 !xpaned->maximized[GTK_XPANED_TOP_RIGHT] &&
2345 !xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] &&
2346 !xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT])
2348 /* save current position */
2349 gtk_xpaned_save_unmaximized_x (xpaned);
2350 gtk_xpaned_save_unmaximized_y (xpaned);
2352 /* set new maximized position */
2353 gtk_xpaned_set_position_x (xpaned, xpaned->min_position.x);
2354 gtk_xpaned_set_position_y (xpaned, xpaned->max_position.y);
2356 /* mark maximized flag for top-right child */
2357 xpaned->maximized[GTK_XPANED_TOP_RIGHT] = TRUE;
2361 /* already one child maximized, report error */
2367 /* verify that top-right child is really currently maximized */
2368 if (xpaned->maximized[GTK_XPANED_TOP_RIGHT])
2370 /* clear maximized flat for top-right child */
2371 xpaned->maximized[GTK_XPANED_TOP_RIGHT] = FALSE;
2373 /* restore unmaximized position */
2374 gtk_xpaned_set_position_x (xpaned,
2375 gtk_xpaned_fetch_unmaximized_x (xpaned));
2376 gtk_xpaned_set_position_y (xpaned,
2377 gtk_xpaned_fetch_unmaximized_y (xpaned));
2381 /* top-right child is currently not maximized, report error */
2388 gtk_xpaned_maximize_bottom_left (GtkXPaned * xpaned, gboolean maximize)
2392 /* see if any child is already maximized */
2393 if (!xpaned->maximized[GTK_XPANED_TOP_LEFT] &&
2394 !xpaned->maximized[GTK_XPANED_TOP_RIGHT] &&
2395 !xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] &&
2396 !xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT])
2398 /* save current position */
2399 gtk_xpaned_save_unmaximized_x (xpaned);
2400 gtk_xpaned_save_unmaximized_y (xpaned);
2402 /* set new maximized position */
2403 gtk_xpaned_set_position_x (xpaned, xpaned->max_position.x);
2404 gtk_xpaned_set_position_y (xpaned, xpaned->min_position.y);
2406 /* mark maximized flag for bottom-left child */
2407 xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] = TRUE;
2411 /* already one child maximized, report error */
2417 /* verify that bottom-left child is really currently maximized */
2418 if (xpaned->maximized[GTK_XPANED_BOTTOM_LEFT])
2420 /* clear maximized flat for bottom-left child */
2421 xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] = FALSE;
2423 /* restore unmaximized position */
2424 gtk_xpaned_set_position_x (xpaned,
2425 gtk_xpaned_fetch_unmaximized_x (xpaned));
2426 gtk_xpaned_set_position_y (xpaned,
2427 gtk_xpaned_fetch_unmaximized_y (xpaned));
2431 /* bottom-left child is currently not maximized, report error */
2438 gtk_xpaned_maximize_bottom_right (GtkXPaned * xpaned, gboolean maximize)
2442 /* see if any child is already maximized */
2443 if (!xpaned->maximized[GTK_XPANED_TOP_LEFT] &&
2444 !xpaned->maximized[GTK_XPANED_TOP_RIGHT] &&
2445 !xpaned->maximized[GTK_XPANED_BOTTOM_LEFT] &&
2446 !xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT])
2448 /* save current position */
2449 gtk_xpaned_save_unmaximized_x (xpaned);
2450 gtk_xpaned_save_unmaximized_y (xpaned);
2452 /* set new maximized position */
2453 gtk_xpaned_set_position_x (xpaned, xpaned->min_position.x);
2454 gtk_xpaned_set_position_y (xpaned, xpaned->min_position.y);
2456 /* mark maximized flag for bottom-right child */
2457 xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT] = TRUE;
2461 /* already one child maximized, report error */
2467 /* verify that bottom-right child is really currently maximized */
2468 if (xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT])
2470 /* clear maximized flat for bottom-right child */
2471 xpaned->maximized[GTK_XPANED_BOTTOM_RIGHT] = FALSE;
2473 /* restore unmaximized position */
2474 gtk_xpaned_set_position_x (xpaned,
2475 gtk_xpaned_fetch_unmaximized_x (xpaned));
2476 gtk_xpaned_set_position_y (xpaned,
2477 gtk_xpaned_fetch_unmaximized_y (xpaned));
2481 /* bottom-right child is currently not maximized, report error */
2488 gtk_xpaned_compute_position (GtkXPaned * xpaned,
2489 const GtkAllocation * allocation,
2490 GtkRequisition * top_left_child_req,
2491 GtkRequisition * top_right_child_req,
2492 GtkRequisition * bottom_left_child_req,
2493 GtkRequisition * bottom_right_child_req)
2495 GdkPoint old_position;
2496 GdkPoint old_min_position;
2497 GdkPoint old_max_position;
2499 gint border_width = GTK_CONTAINER (xpaned)->border_width;
2501 g_return_if_fail (GTK_IS_XPANED (xpaned));
2503 old_position.x = xpaned->top_left_child_size.width;
2504 old_position.y = xpaned->top_left_child_size.height;
2505 old_min_position.x = xpaned->min_position.x;
2506 old_min_position.y = xpaned->min_position.y;
2507 old_max_position.x = xpaned->max_position.x;
2508 old_max_position.y = xpaned->max_position.y;
2510 xpaned->min_position.x =
2511 xpaned->top_left_child_shrink ? 0 : top_left_child_req->width;
2512 xpaned->min_position.y =
2513 xpaned->top_left_child_shrink ? 0 : top_left_child_req->height;
2515 gtk_widget_style_get (GTK_WIDGET (xpaned), "handle-size", &handle_size,
2518 xpaned->max_position.x = allocation->width - 2 * border_width - handle_size;
2519 xpaned->max_position.y =
2520 allocation->height - 2 * border_width - handle_size;
2521 if (!xpaned->top_left_child_shrink)
2522 xpaned->max_position.x =
2523 MAX (1, xpaned->max_position.x - top_left_child_req->width);
2524 xpaned->max_position.x =
2525 MAX (xpaned->min_position.x, xpaned->max_position.x);
2527 if (!xpaned->position_set)
2529 if (xpaned->top_left_child_resize && !xpaned->top_right_child_resize)
2531 xpaned->top_left_child_size.width =
2532 MAX (0, allocation->width - top_right_child_req->width);
2533 xpaned->top_left_child_size.height =
2534 MAX (0, allocation->height - top_right_child_req->height);
2536 else if (!xpaned->top_left_child_resize
2537 && xpaned->top_right_child_resize)
2539 xpaned->top_left_child_size.width = top_left_child_req->width;
2540 xpaned->top_left_child_size.height = top_left_child_req->height;
2544 xpaned->top_left_child_size.width = allocation->width * 0.5 + 0.5;
2545 xpaned->top_left_child_size.height = allocation->height * 0.5 + 0.5;
2550 /* If the position was set before the initial allocation.
2551 ** (paned->last_allocation <= 0) just clamp it and leave it. */
2552 if (xpaned->last_allocation.width > 0)
2554 if (xpaned->top_left_child_resize
2555 && !xpaned->top_right_child_resize)
2557 xpaned->top_left_child_size.width += allocation->width
2558 - xpaned->last_allocation.width;
2560 xpaned->top_left_child_size.height += allocation->height
2561 - xpaned->last_allocation.height;
2565 (!xpaned->top_left_child_resize
2566 && xpaned->top_right_child_resize))
2568 xpaned->top_left_child_size.width = allocation->width
2569 * ((gdouble) xpaned->top_left_child_size.width /
2570 (xpaned->last_allocation.width)) + 0.5;
2572 xpaned->top_left_child_size.height = allocation->height
2573 * ((gdouble) xpaned->top_left_child_size.height /
2574 (xpaned->last_allocation.height)) + 0.5;
2577 if (xpaned->last_allocation.height > 0)
2579 if (xpaned->top_left_child_resize
2580 && !xpaned->top_right_child_resize)
2582 xpaned->top_left_child_size.width +=
2583 allocation->width - xpaned->last_allocation.width;
2584 xpaned->top_left_child_size.height +=
2585 allocation->height - xpaned->last_allocation.height;
2589 (!xpaned->top_left_child_resize
2590 && xpaned->top_right_child_resize))
2592 xpaned->top_left_child_size.width =
2594 ((gdouble) xpaned->top_left_child_size.width /
2595 (xpaned->last_allocation.width)) + 0.5;
2596 xpaned->top_left_child_size.height =
2597 allocation->height *
2598 ((gdouble) xpaned->top_left_child_size.height /
2599 (xpaned->last_allocation.height)) + 0.5;
2605 xpaned->top_left_child_size.width =
2606 CLAMP (xpaned->top_left_child_size.width, xpaned->min_position.x,
2607 xpaned->max_position.x);
2608 xpaned->top_left_child_size.height =
2609 CLAMP (xpaned->top_left_child_size.height, xpaned->min_position.y,
2610 xpaned->max_position.y);
2612 xpaned->top_right_child_size.width =
2613 CLAMP (xpaned->top_right_child_size.width, xpaned->min_position.x,
2614 xpaned->max_position.x);
2615 xpaned->top_right_child_size.height =
2616 CLAMP (xpaned->top_right_child_size.height, xpaned->min_position.y,
2617 xpaned->max_position.y);
2619 xpaned->bottom_left_child_size.width =
2620 CLAMP (xpaned->bottom_left_child_size.width, xpaned->min_position.x,
2621 xpaned->max_position.x);
2622 xpaned->bottom_left_child_size.height =
2623 CLAMP (xpaned->bottom_left_child_size.height, xpaned->min_position.y,
2624 xpaned->max_position.y);
2626 xpaned->bottom_right_child_size.width =
2627 CLAMP (xpaned->bottom_right_child_size.width, xpaned->min_position.x,
2628 xpaned->max_position.x);
2629 xpaned->bottom_right_child_size.height =
2630 CLAMP (xpaned->bottom_right_child_size.height, xpaned->min_position.y,
2631 xpaned->max_position.y);
2633 gtk_widget_set_child_visible (xpaned->top_left_child, TRUE);
2634 gtk_widget_set_child_visible (xpaned->top_right_child, TRUE);
2635 gtk_widget_set_child_visible (xpaned->bottom_left_child, TRUE);
2636 gtk_widget_set_child_visible (xpaned->bottom_right_child, TRUE);
2638 g_object_freeze_notify (G_OBJECT (xpaned));
2640 if (xpaned->top_left_child_size.width != old_position.x)
2641 g_object_notify (G_OBJECT (xpaned), "x-position");
2642 if (xpaned->top_left_child_size.height != old_position.y)
2643 g_object_notify (G_OBJECT (xpaned), "y-position");
2645 if (xpaned->top_right_child_size.width != old_position.x)
2646 g_object_notify (G_OBJECT (xpaned), "x-position");
2647 if (xpaned->top_right_child_size.height != old_position.y)
2648 g_object_notify (G_OBJECT (xpaned), "y-position");
2650 if (xpaned->bottom_left_child_size.width != old_position.x)
2651 g_object_notify (G_OBJECT (xpaned), "x-position");
2652 if (xpaned->bottom_left_child_size.height != old_position.y)
2653 g_object_notify (G_OBJECT (xpaned), "y-position");
2655 if (xpaned->bottom_right_child_size.width != old_position.x)
2656 g_object_notify (G_OBJECT (xpaned), "x-position");
2657 if (xpaned->bottom_right_child_size.height != old_position.y)
2658 g_object_notify (G_OBJECT (xpaned), "y-position");
2660 if (xpaned->min_position.x != old_min_position.x)
2661 g_object_notify (G_OBJECT (xpaned), "min-x-position");
2662 if (xpaned->min_position.y != old_min_position.y)
2663 g_object_notify (G_OBJECT (xpaned), "min-y-position");
2665 if (xpaned->max_position.x != old_max_position.x)
2666 g_object_notify (G_OBJECT (xpaned), "max-y-position");
2667 if (xpaned->max_position.y != old_max_position.y)
2668 g_object_notify (G_OBJECT (xpaned), "max-y-position");
2670 g_object_thaw_notify (G_OBJECT (xpaned));
2672 xpaned->last_allocation.width = allocation->width;
2673 xpaned->last_allocation.height = allocation->height;
2677 gtk_xpaned_set_saved_focus (GtkXPaned * xpaned, GtkWidget * widget)
2679 if (xpaned->priv->saved_focus)
2680 g_object_remove_weak_pointer (G_OBJECT (xpaned->priv->saved_focus),
2681 (gpointer *) & (xpaned->priv->saved_focus));
2683 xpaned->priv->saved_focus = widget;
2685 if (xpaned->priv->saved_focus)
2686 g_object_add_weak_pointer (G_OBJECT (xpaned->priv->saved_focus),
2687 (gpointer *) & (xpaned->priv->saved_focus));
2691 gtk_xpaned_set_first_xpaned (GtkXPaned * xpaned, GtkXPaned * first_xpaned)
2693 if (xpaned->priv->first_xpaned)
2694 g_object_remove_weak_pointer (G_OBJECT (xpaned->priv->first_xpaned),
2695 (gpointer *) & (xpaned->priv->
2698 xpaned->priv->first_xpaned = first_xpaned;
2700 if (xpaned->priv->first_xpaned)
2701 g_object_add_weak_pointer (G_OBJECT (xpaned->priv->first_xpaned),
2702 (gpointer *) & (xpaned->priv->first_xpaned));
2706 gtk_xpaned_set_last_top_left_child_focus (GtkXPaned * xpaned,
2709 if (xpaned->last_top_left_child_focus)
2710 g_object_remove_weak_pointer (G_OBJECT
2711 (xpaned->last_top_left_child_focus),
2712 (gpointer *) & (xpaned->
2713 last_top_left_child_focus));
2715 xpaned->last_top_left_child_focus = widget;
2717 if (xpaned->last_top_left_child_focus)
2718 g_object_add_weak_pointer (G_OBJECT (xpaned->last_top_left_child_focus),
2719 (gpointer *) & (xpaned->
2720 last_top_left_child_focus));
2724 gtk_xpaned_set_last_top_right_child_focus (GtkXPaned * xpaned,
2727 if (xpaned->last_top_right_child_focus)
2728 g_object_remove_weak_pointer (G_OBJECT
2729 (xpaned->last_top_right_child_focus),
2730 (gpointer *) & (xpaned->
2731 last_top_right_child_focus));
2733 xpaned->last_top_right_child_focus = widget;
2735 if (xpaned->last_top_right_child_focus)
2736 g_object_add_weak_pointer (G_OBJECT (xpaned->last_top_right_child_focus),
2737 (gpointer *) & (xpaned->
2738 last_top_right_child_focus));
2742 gtk_xpaned_set_last_bottom_left_child_focus (GtkXPaned * xpaned,
2745 if (xpaned->last_bottom_left_child_focus)
2746 g_object_remove_weak_pointer (G_OBJECT
2747 (xpaned->last_bottom_left_child_focus),
2748 (gpointer *) & (xpaned->
2749 last_bottom_left_child_focus));
2751 xpaned->last_bottom_left_child_focus = widget;
2753 if (xpaned->last_bottom_left_child_focus)
2754 g_object_add_weak_pointer (G_OBJECT
2755 (xpaned->last_bottom_left_child_focus),
2756 (gpointer *) & (xpaned->
2757 last_bottom_left_child_focus));
2761 gtk_xpaned_set_last_bottom_right_child_focus (GtkXPaned * xpaned,
2764 if (xpaned->last_bottom_right_child_focus)
2765 g_object_remove_weak_pointer (G_OBJECT
2766 (xpaned->last_bottom_right_child_focus),
2767 (gpointer *) & (xpaned->
2768 last_bottom_right_child_focus));
2770 xpaned->last_bottom_right_child_focus = widget;
2772 if (xpaned->last_bottom_right_child_focus)
2773 g_object_add_weak_pointer (G_OBJECT
2774 (xpaned->last_bottom_right_child_focus),
2775 (gpointer *) & (xpaned->
2776 last_bottom_right_child_focus));
2780 xpaned_get_focus_widget (GtkXPaned * xpaned)
2782 GtkWidget *toplevel;
2784 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (xpaned));
2785 if (gtk_widget_is_toplevel (toplevel))
2786 return GTK_WINDOW (toplevel)->focus_widget;
2792 gtk_xpaned_set_focus_child (GtkContainer * container, GtkWidget * focus_child)
2796 g_return_if_fail (GTK_IS_XPANED (container));
2798 xpaned = GTK_XPANED (container);
2800 if (focus_child == NULL)
2802 GtkWidget *last_focus;
2805 last_focus = xpaned_get_focus_widget (xpaned);
2809 /* If there is one or more paned widgets between us and the
2810 * focus widget, we want the topmost of those as last_focus
2812 for (w = last_focus; w != GTK_WIDGET (xpaned); w = w->parent)
2813 if (GTK_IS_XPANED (w))
2816 if (container->focus_child == xpaned->top_left_child)
2817 gtk_xpaned_set_last_top_left_child_focus (xpaned, last_focus);
2818 else if (container->focus_child == xpaned->top_right_child)
2819 gtk_xpaned_set_last_top_right_child_focus (xpaned, last_focus);
2820 else if (container->focus_child == xpaned->bottom_left_child)
2821 gtk_xpaned_set_last_bottom_left_child_focus (xpaned, last_focus);
2822 else if (container->focus_child == xpaned->bottom_right_child)
2823 gtk_xpaned_set_last_bottom_right_child_focus (xpaned, last_focus);
2827 if (parent_class->set_focus_child)
2828 (*parent_class->set_focus_child) (container, focus_child);
2832 gtk_xpaned_get_cycle_chain (GtkXPaned * xpaned,
2833 GtkDirectionType direction, GList ** widgets)
2835 GtkContainer *container = GTK_CONTAINER (xpaned);
2836 GtkWidget *ancestor = NULL;
2837 GList *temp_list = NULL;
2840 if (xpaned->in_recursion)
2843 g_assert (widgets != NULL);
2845 if (xpaned->last_top_left_child_focus &&
2846 !gtk_widget_is_ancestor (xpaned->last_top_left_child_focus,
2847 GTK_WIDGET (xpaned)))
2849 gtk_xpaned_set_last_top_left_child_focus (xpaned, NULL);
2852 if (xpaned->last_top_right_child_focus &&
2853 !gtk_widget_is_ancestor (xpaned->last_top_right_child_focus,
2854 GTK_WIDGET (xpaned)))
2856 gtk_xpaned_set_last_top_right_child_focus (xpaned, NULL);
2859 if (xpaned->last_bottom_left_child_focus &&
2860 !gtk_widget_is_ancestor (xpaned->last_bottom_left_child_focus,
2861 GTK_WIDGET (xpaned)))
2863 gtk_xpaned_set_last_bottom_left_child_focus (xpaned, NULL);
2866 if (xpaned->last_bottom_right_child_focus &&
2867 !gtk_widget_is_ancestor (xpaned->last_bottom_right_child_focus,
2868 GTK_WIDGET (xpaned)))
2870 gtk_xpaned_set_last_bottom_right_child_focus (xpaned, NULL);
2873 if (GTK_WIDGET (xpaned)->parent)
2874 ancestor = gtk_widget_get_ancestor (GTK_WIDGET (xpaned)->parent,
2877 /* The idea here is that temp_list is a list of widgets we want to cycle
2878 * to. The list is prioritized so that the first element is our first
2879 * choice, the next our second, and so on.
2881 * We can't just use g_list_reverse(), because we want to try
2882 * paned->last_child?_focus before paned->child?, both when we
2883 * are going forward and backward.
2885 if (direction == GTK_DIR_TAB_FORWARD)
2887 if (container->focus_child == xpaned->top_left_child)
2890 g_list_append (temp_list, xpaned->last_top_right_child_focus);
2891 temp_list = g_list_append (temp_list, xpaned->top_right_child);
2892 temp_list = g_list_append (temp_list, ancestor);
2894 else if (container->focus_child == xpaned->top_right_child)
2896 temp_list = g_list_append (temp_list, ancestor);
2898 g_list_append (temp_list, xpaned->last_bottom_left_child_focus);
2899 temp_list = g_list_append (temp_list, xpaned->bottom_left_child);
2901 else if (container->focus_child == xpaned->bottom_left_child)
2903 temp_list = g_list_append (temp_list, ancestor);
2905 g_list_append (temp_list, xpaned->last_bottom_right_child_focus);
2906 temp_list = g_list_append (temp_list, xpaned->bottom_right_child);
2908 else if (container->focus_child == xpaned->bottom_right_child)
2910 temp_list = g_list_append (temp_list, ancestor);
2912 g_list_append (temp_list, xpaned->last_top_left_child_focus);
2913 temp_list = g_list_append (temp_list, xpaned->top_left_child);
2918 g_list_append (temp_list, xpaned->last_top_left_child_focus);
2919 temp_list = g_list_append (temp_list, xpaned->top_left_child);
2921 g_list_append (temp_list, xpaned->last_top_right_child_focus);
2922 temp_list = g_list_append (temp_list, xpaned->top_right_child);
2924 g_list_append (temp_list, xpaned->last_bottom_left_child_focus);
2925 temp_list = g_list_append (temp_list, xpaned->bottom_left_child);
2927 g_list_append (temp_list, xpaned->last_bottom_right_child_focus);
2928 temp_list = g_list_append (temp_list, xpaned->bottom_right_child);
2929 temp_list = g_list_append (temp_list, ancestor);
2934 if (container->focus_child == xpaned->top_left_child)
2936 temp_list = g_list_append (temp_list, ancestor);
2938 g_list_append (temp_list, xpaned->last_top_right_child_focus);
2939 temp_list = g_list_append (temp_list, xpaned->top_right_child);
2941 else if (container->focus_child == xpaned->top_right_child)
2944 g_list_append (temp_list, xpaned->last_bottom_left_child_focus);
2945 temp_list = g_list_append (temp_list, xpaned->bottom_left_child);
2946 temp_list = g_list_append (temp_list, ancestor);
2948 else if (container->focus_child == xpaned->bottom_right_child)
2951 g_list_append (temp_list, xpaned->last_bottom_left_child_focus);
2952 temp_list = g_list_append (temp_list, xpaned->bottom_left_child);
2953 temp_list = g_list_append (temp_list, ancestor);
2955 else if (container->focus_child == xpaned->top_right_child)
2958 g_list_append (temp_list, xpaned->last_bottom_left_child_focus);
2959 temp_list = g_list_append (temp_list, xpaned->bottom_left_child);
2960 temp_list = g_list_append (temp_list, ancestor);
2965 g_list_append (temp_list, xpaned->last_bottom_right_child_focus);
2966 temp_list = g_list_append (temp_list, xpaned->bottom_right_child);
2968 g_list_append (temp_list, xpaned->last_bottom_left_child_focus);
2969 temp_list = g_list_append (temp_list, xpaned->bottom_left_child);
2971 g_list_append (temp_list, xpaned->last_top_right_child_focus);
2972 temp_list = g_list_append (temp_list, xpaned->top_right_child);
2974 g_list_append (temp_list, xpaned->last_top_left_child_focus);
2975 temp_list = g_list_append (temp_list, xpaned->top_left_child);
2976 temp_list = g_list_append (temp_list, ancestor);
2980 /* Walk the list and expand all the paned widgets. */
2981 for (list = temp_list; list != NULL; list = list->next)
2983 GtkWidget *widget = list->data;
2987 if (GTK_IS_XPANED (widget))
2989 xpaned->in_recursion = TRUE;
2990 gtk_xpaned_get_cycle_chain (GTK_XPANED (widget),
2991 direction, widgets);
2992 xpaned->in_recursion = FALSE;
2996 *widgets = g_list_append (*widgets, widget);
3001 g_list_free (temp_list);
3005 gtk_xpaned_cycle_child_focus (GtkXPaned * xpaned, gboolean reversed)
3007 GList *cycle_chain = NULL;
3010 GtkDirectionType direction =
3011 reversed ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD;
3013 /* ignore f6 if the handle is focused */
3014 if (gtk_widget_is_focus (GTK_WIDGET (xpaned)))
3017 /* we can't just let the event propagate up the hierarchy,
3018 * because the paned will want to cycle focus _unless_ an
3019 * ancestor paned handles the event
3021 gtk_xpaned_get_cycle_chain (xpaned, direction, &cycle_chain);
3023 for (list = cycle_chain; list != NULL; list = list->next)
3024 if (gtk_widget_child_focus (GTK_WIDGET (list->data), direction))
3027 g_list_free (cycle_chain);
3033 get_child_xpanes (GtkWidget * widget, GList ** xpanes)
3035 if (GTK_IS_XPANED (widget))
3037 GtkXPaned *xpaned = GTK_XPANED (widget);
3039 get_child_xpanes (xpaned->top_left_child, xpanes);
3040 *xpanes = g_list_prepend (*xpanes, widget);
3041 get_child_xpanes (xpaned->top_right_child, xpanes);
3042 *xpanes = g_list_prepend (*xpanes, widget);
3043 get_child_xpanes (xpaned->bottom_left_child, xpanes);
3044 *xpanes = g_list_prepend (*xpanes, widget);
3045 get_child_xpanes (xpaned->bottom_right_child, xpanes);
3047 else if (GTK_IS_CONTAINER (widget))
3049 gtk_container_foreach (GTK_CONTAINER (widget),
3050 (GtkCallback) get_child_xpanes, xpanes);
3055 get_all_xpanes (GtkXPaned * xpaned)
3057 GtkXPaned *topmost = NULL;
3058 GList *result = NULL;
3061 for (w = GTK_WIDGET (xpaned); w != NULL; w = w->parent)
3063 if (GTK_IS_XPANED (w))
3064 topmost = GTK_XPANED (w);
3069 get_child_xpanes (GTK_WIDGET (topmost), &result);
3071 return g_list_reverse (result);
3075 gtk_xpaned_find_neighbours (GtkXPaned * xpaned,
3076 GtkXPaned ** next, GtkXPaned ** prev)
3081 all_xpanes = get_all_xpanes (xpaned);
3082 g_assert (all_xpanes);
3084 this_link = g_list_find (all_xpanes, xpaned);
3086 g_assert (this_link);
3088 if (this_link->next)
3089 *next = this_link->next->data;
3091 *next = all_xpanes->data;
3093 if (this_link->prev)
3094 *prev = this_link->prev->data;
3096 *prev = g_list_last (all_xpanes)->data;
3098 g_list_free (all_xpanes);
3102 gtk_xpaned_move_handle (GtkXPaned * xpaned, GtkScrollType scroll)
3104 if (gtk_widget_is_focus (GTK_WIDGET (xpaned)))
3106 GdkPoint old_position;
3107 GdkPoint new_position;
3112 SINGLE_STEP_SIZE = 1,
3116 new_position.x = old_position.x = gtk_xpaned_get_position_x (xpaned);
3117 new_position.y = old_position.y = gtk_xpaned_get_position_y (xpaned);
3122 case GTK_SCROLL_STEP_LEFT:
3123 case GTK_SCROLL_STEP_UP:
3124 case GTK_SCROLL_STEP_BACKWARD:
3125 increment = -SINGLE_STEP_SIZE;
3128 case GTK_SCROLL_STEP_RIGHT:
3129 case GTK_SCROLL_STEP_DOWN:
3130 case GTK_SCROLL_STEP_FORWARD:
3131 increment = SINGLE_STEP_SIZE;
3134 case GTK_SCROLL_PAGE_LEFT:
3135 case GTK_SCROLL_PAGE_UP:
3136 case GTK_SCROLL_PAGE_BACKWARD:
3137 increment = -PAGE_STEP_SIZE;
3140 case GTK_SCROLL_PAGE_RIGHT:
3141 case GTK_SCROLL_PAGE_DOWN:
3142 case GTK_SCROLL_PAGE_FORWARD:
3143 increment = PAGE_STEP_SIZE;
3146 case GTK_SCROLL_START:
3147 new_position.x = xpaned->min_position.x;
3148 new_position.y = xpaned->min_position.y;
3151 case GTK_SCROLL_END:
3152 new_position.x = xpaned->max_position.x;
3153 new_position.y = xpaned->max_position.y;
3162 if (is_rtl (xpaned))
3163 increment = -increment;
3165 new_position.x = old_position.x + increment;
3166 new_position.y = old_position.y + increment;
3169 new_position.x = CLAMP (new_position.x,
3170 xpaned->min_position.x, xpaned->max_position.x);
3172 new_position.y = CLAMP (new_position.y,
3173 xpaned->min_position.y, xpaned->max_position.y);
3175 if (old_position.x != new_position.x)
3176 gtk_xpaned_set_position_x (xpaned, new_position.x);
3178 if (old_position.y != new_position.y)
3179 gtk_xpaned_set_position_y (xpaned, new_position.y);
3188 gtk_xpaned_restore_focus (GtkXPaned * xpaned)
3190 if (gtk_widget_is_focus (GTK_WIDGET (xpaned)))
3192 if (xpaned->priv->saved_focus &&
3193 gtk_widget_get_sensitive (xpaned->priv->saved_focus))
3195 gtk_widget_grab_focus (xpaned->priv->saved_focus);
3199 /* the saved focus is somehow not available for focusing,
3201 * 1) tabbing into the paned widget
3202 * if that didn't work,
3203 * 2) unset focus for the window if there is one
3206 if (!gtk_widget_child_focus
3207 (GTK_WIDGET (xpaned), GTK_DIR_TAB_FORWARD))
3209 GtkWidget *toplevel =
3210 gtk_widget_get_toplevel (GTK_WIDGET (xpaned));
3212 if (GTK_IS_WINDOW (toplevel))
3213 gtk_window_set_focus (GTK_WINDOW (toplevel), NULL);
3217 gtk_xpaned_set_saved_focus (xpaned, NULL);
3218 gtk_xpaned_set_first_xpaned (xpaned, NULL);
3223 gtk_xpaned_accept_position (GtkXPaned * xpaned)
3225 if (gtk_widget_is_focus (GTK_WIDGET (xpaned)))
3227 xpaned->original_position.x = -1;
3228 xpaned->original_position.y = -1;
3229 gtk_xpaned_restore_focus (xpaned);
3238 gtk_xpaned_cancel_position (GtkXPaned * xpaned)
3240 if (gtk_widget_is_focus (GTK_WIDGET (xpaned)))
3242 if (xpaned->original_position.x != -1)
3244 gtk_xpaned_set_position_x (xpaned, xpaned->original_position.x);
3245 xpaned->original_position.x = -1;
3248 if (xpaned->original_position.y != -1)
3250 gtk_xpaned_set_position_y (xpaned, xpaned->original_position.y);
3251 xpaned->original_position.y = -1;
3254 gtk_xpaned_restore_focus (xpaned);
3262 gtk_xpaned_cycle_handle_focus (GtkXPaned * xpaned, gboolean reversed)
3267 if (gtk_widget_is_focus (GTK_WIDGET (xpaned)))
3269 GtkXPaned *focus = NULL;
3271 if (!xpaned->priv->first_xpaned)
3273 /* The first_pane has disappeared. As an ad-hoc solution,
3274 * we make the currently focused paned the first_paned. To the
3275 * user this will seem like the paned cycling has been reset.
3277 gtk_xpaned_set_first_xpaned (xpaned, xpaned);
3280 gtk_xpaned_find_neighbours (xpaned, &next, &prev);
3282 if (reversed && prev &&
3283 prev != xpaned && xpaned != xpaned->priv->first_xpaned)
3287 else if (!reversed &&
3288 next && next != xpaned && next != xpaned->priv->first_xpaned)
3294 gtk_xpaned_accept_position (xpaned);
3300 gtk_xpaned_set_saved_focus (focus, xpaned->priv->saved_focus);
3301 gtk_xpaned_set_first_xpaned (focus, xpaned->priv->first_xpaned);
3303 gtk_xpaned_set_saved_focus (xpaned, NULL);
3304 gtk_xpaned_set_first_xpaned (xpaned, NULL);
3306 gtk_widget_grab_focus (GTK_WIDGET (focus));
3308 if (!gtk_widget_is_focus (GTK_WIDGET (xpaned)))
3310 xpaned->original_position.x = -1;
3311 xpaned->original_position.y = -1;
3312 focus->original_position.x = gtk_xpaned_get_position_x (focus);
3313 focus->original_position.y = gtk_xpaned_get_position_y (focus);
3318 GtkContainer *container = GTK_CONTAINER (xpaned);
3323 GtkWidget *toplevel;
3325 gtk_xpaned_find_neighbours (xpaned, &next, &prev);
3327 if (container->focus_child == xpaned->top_left_child)
3340 else if (container->focus_child == xpaned->top_right_child)
3355 /* Focus is not inside this xpaned, and we don't have focus.
3356 * Presumably this happened because the application wants us
3357 * to start keyboard navigating.
3367 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (xpaned));
3369 if (GTK_IS_WINDOW (toplevel))
3370 gtk_xpaned_set_saved_focus (focus,
3371 GTK_WINDOW (toplevel)->focus_widget);
3372 gtk_xpaned_set_first_xpaned (focus, first);
3373 focus->original_position.x = gtk_xpaned_get_position_x (focus);
3374 focus->original_position.y = gtk_xpaned_get_position_y (focus);
3376 gtk_widget_grab_focus (GTK_WIDGET (focus));
3383 gtk_xpaned_toggle_handle_focus (GtkXPaned * xpaned)
3385 /* This function/signal has the wrong name. It is called when you
3386 * press Tab or Shift-Tab and what we do is act as if
3387 * the user pressed Return and then Tab or Shift-Tab
3389 if (gtk_widget_is_focus (GTK_WIDGET (xpaned)))
3390 gtk_xpaned_accept_position (xpaned);
3395 /*#define __GTK_XPANED_C__*/
3396 /*#include "gtkaliasdef.c"*/