- xpaned->handle_pos_middle.x = xpaned->handle_pos_north.x ;
- xpaned->handle_pos_middle.y = xpaned->handle_pos_east.y ;
- xpaned->handle_pos_middle.width = handle_size + CENTRUM ;
- xpaned->handle_pos_middle.height = handle_size + CENTRUM;
-
- /* set allocation for top-left child */
- top_left_child_allocation.x = widget->allocation.x + border_width;
- top_left_child_allocation.y = widget->allocation.y + border_width;
- top_left_child_allocation.width = xpaned->handle_pos_west.width;
- top_left_child_allocation.height = xpaned->handle_pos_north.height;
-
- /* set allocation for top-right child */
- top_right_child_allocation.x = widget->allocation.x + border_width + handle_size + top_left_child_allocation.width;
- top_right_child_allocation.y = widget->allocation.y + border_width;
- top_right_child_allocation.width = xpaned->handle_pos_east.width;
- top_right_child_allocation.height = xpaned->handle_pos_north.height;
-
- /* set allocation for bottom-left child */
- bottom_left_child_allocation.x = xpaned->handle_pos_west.x;
- bottom_left_child_allocation.y = xpaned->handle_pos_south.y;
- bottom_left_child_allocation.width = xpaned->handle_pos_west.width;
- bottom_left_child_allocation.height = xpaned->handle_pos_south.height;
-
- /* set allocation for bottom-right child */
- bottom_right_child_allocation.x = top_right_child_allocation.x;
- bottom_right_child_allocation.y = bottom_left_child_allocation.y;
- bottom_right_child_allocation.width = xpaned->handle_pos_east.width;
- bottom_right_child_allocation.height = xpaned->handle_pos_south.height;
-
- if (gtk_widget_get_realized (widget))
- {
- if (gtk_widget_get_mapped (widget))
- {
- gdk_window_show (xpaned->handle_east);
- gdk_window_show (xpaned->handle_west);
- gdk_window_show (xpaned->handle_north);
- gdk_window_show (xpaned->handle_south);
- gdk_window_show (xpaned->handle_middle);
- }
-
- gdk_window_move_resize (xpaned->handle_east,
- xpaned->handle_pos_east.x,
- xpaned->handle_pos_east.y,
- xpaned->handle_pos_east.width,
- xpaned->handle_pos_east.height);
-
- gdk_window_move_resize (xpaned->handle_west,
- xpaned->handle_pos_west.x,
- xpaned->handle_pos_west.y,
- xpaned->handle_pos_west.width,
- xpaned->handle_pos_west.height);
-
- gdk_window_move_resize (xpaned->handle_north,
- xpaned->handle_pos_north.x,
- xpaned->handle_pos_north.y,
- xpaned->handle_pos_north.width,
- xpaned->handle_pos_north.height);
-
- gdk_window_move_resize (xpaned->handle_south,
- xpaned->handle_pos_south.x,
- xpaned->handle_pos_south.y,
- xpaned->handle_pos_south.width,
- xpaned->handle_pos_south.height);
-
- gdk_window_move_resize (xpaned->handle_middle,
- xpaned->handle_pos_middle.x,
- xpaned->handle_pos_middle.y,
- xpaned->handle_pos_middle.width,
- xpaned->handle_pos_middle.height);
- }
-
- /* Now allocate the childen, making sure, when resizing not to
- * overlap the windows
- */
- if (gtk_widget_get_mapped (widget))
- {
- gtk_widget_size_allocate (xpaned->top_right_child, &top_right_child_allocation);
- gtk_widget_size_allocate (xpaned->top_left_child, &top_left_child_allocation);
- gtk_widget_size_allocate (xpaned->bottom_left_child, &bottom_left_child_allocation);
- gtk_widget_size_allocate (xpaned->bottom_right_child, &bottom_right_child_allocation);
- }
- }
-}
-
-static void gtk_xpaned_set_property (GObject* object,
- guint prop_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- GtkXPaned* xpaned = GTK_XPANED (object);
-
- switch (prop_id)
- {
- case PROP_X_POSITION:
- gtk_xpaned_set_position_x (xpaned, g_value_get_int (value));
- break;
-
- case PROP_Y_POSITION:
- gtk_xpaned_set_position_y (xpaned, g_value_get_int (value));
- break;
-
- case PROP_POSITION_SET:
- xpaned->position_set = g_value_get_boolean (value);
- gtk_widget_queue_resize (GTK_WIDGET (xpaned));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void gtk_xpaned_get_property (GObject* object,
- guint prop_id,
- GValue* value,
- GParamSpec* pspec)
-{
- GtkXPaned* xpaned = GTK_XPANED (object);
-
- switch (prop_id)
- {
- case PROP_X_POSITION:
- g_value_set_int (value, xpaned->top_left_child_size.width);
- break;
-
- case PROP_Y_POSITION:
- g_value_set_int (value, xpaned->top_left_child_size.height);
- break;
-
- case PROP_POSITION_SET:
- g_value_set_boolean (value, xpaned->position_set);
- break;
-
- case PROP_MIN_X_POSITION:
- g_value_set_int (value, xpaned->min_position.x);
- break;
-
- case PROP_MIN_Y_POSITION:
- g_value_set_int (value, xpaned->min_position.y);
- break;
-
- case PROP_MAX_X_POSITION:
- g_value_set_int (value, xpaned->max_position.x);
- break;
-
- case PROP_MAX_Y_POSITION:
- g_value_set_int (value, xpaned->max_position.y);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void gtk_xpaned_set_child_property (GtkContainer* container,
- GtkWidget* child,
- guint property_id,
- const GValue* value,
- GParamSpec* pspec)
-{
- GtkXPaned* xpaned = GTK_XPANED (container);
- gboolean old_value = FALSE;
- gboolean new_value = FALSE;
-
- g_assert (child == xpaned->top_left_child ||
- child == xpaned->top_right_child ||
- child == xpaned->bottom_left_child ||
- child == xpaned->bottom_right_child);
-
- new_value = g_value_get_boolean (value);
-
- switch (property_id)
- {
- case CHILD_PROP_RESIZE:
- if (child == xpaned->top_left_child)
- {
- old_value = xpaned->top_left_child_resize;
- xpaned->top_left_child_resize = new_value;
- }
- else if (child == xpaned->top_right_child)
- {
- old_value = xpaned->top_right_child_resize;
- xpaned->top_right_child_resize = new_value;
- }
- else if (child == xpaned->bottom_left_child)
- {
- old_value = xpaned->bottom_left_child_resize;
- xpaned->bottom_left_child_resize = new_value;
- }
- else if (child == xpaned->bottom_right_child)
- {
- old_value = xpaned->bottom_right_child_resize;
- xpaned->bottom_right_child_resize = new_value;
- }
- break;
-
- case CHILD_PROP_SHRINK :
- if (child == xpaned->top_left_child)
- {
- old_value = xpaned->top_left_child_shrink;
- xpaned->top_left_child_shrink = new_value;
- }
- else if (child == xpaned->top_right_child)
- {
- old_value = xpaned->top_right_child_shrink;
- xpaned->top_right_child_shrink = new_value;
- }
- else if (child == xpaned->bottom_left_child)
- {
- old_value = xpaned->bottom_left_child_shrink;
- xpaned->bottom_left_child_shrink = new_value;
- }
- else if (child == xpaned->bottom_right_child)
- {
- old_value = xpaned->bottom_right_child_shrink;
- xpaned->bottom_right_child_shrink = new_value;
- }
- break;
-
- default:
- GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container,
- property_id,
- pspec);
- old_value = -1; /* quiet gcc */
- break;
- }
-
- if (old_value != new_value)
- gtk_widget_queue_resize (GTK_WIDGET (container));
-}
-
-static void gtk_xpaned_get_child_property (GtkContainer* container,
- GtkWidget* child,
- guint property_id,
- GValue* value,
- GParamSpec* pspec)
-{
- GtkXPaned* xpaned = GTK_XPANED (container);
-
- g_assert (child == xpaned->top_left_child ||
- child == xpaned->top_right_child ||
- child == xpaned->bottom_left_child ||
- child == xpaned->bottom_right_child);
-
- switch (property_id)
- {
- case CHILD_PROP_RESIZE :
- if (child == xpaned->top_left_child)
- g_value_set_boolean (value, xpaned->top_left_child_resize);
- else if (child == xpaned->top_right_child)
- g_value_set_boolean (value, xpaned->top_right_child_resize);
- else if (child == xpaned->bottom_left_child)
- g_value_set_boolean (value, xpaned->bottom_left_child_resize);
- else if (child == xpaned->bottom_right_child)
- g_value_set_boolean (value, xpaned->bottom_right_child_resize);
- break;
-
- case CHILD_PROP_SHRINK :
- if (child == xpaned->top_left_child)
- g_value_set_boolean (value, xpaned->top_left_child_shrink);
- else if (child == xpaned->top_right_child)
- g_value_set_boolean (value, xpaned->top_right_child_shrink);
- else if (child == xpaned->bottom_left_child)
- g_value_set_boolean (value, xpaned->bottom_left_child_shrink);
- else if (child == xpaned->bottom_right_child)
- g_value_set_boolean (value, xpaned->bottom_right_child_shrink);
- break;
-
- default:
- GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container,
- property_id,
- pspec);
- break;
- }
-}
-
-static void gtk_xpaned_finalize (GObject* object)
-{
- GtkXPaned* xpaned = GTK_XPANED (object);
-
- gtk_xpaned_set_saved_focus (xpaned, NULL);
- gtk_xpaned_set_first_xpaned (xpaned, NULL);
-
- g_free (xpaned->priv);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void gtk_xpaned_realize (GtkWidget* widget)
-{
- GtkXPaned* xpaned;
- GdkWindowAttr attributes_east;
- GdkWindowAttr attributes_west;
- GdkWindowAttr attributes_north;
- GdkWindowAttr attributes_south;
- GdkWindowAttr attributes_middle;
- gint attributes_mask_east;
- gint attributes_mask_west;
- gint attributes_mask_north;
- gint attributes_mask_south;
- gint attributes_mask_middle;
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
- xpaned = GTK_XPANED (widget);
-
- widget->window = gtk_widget_get_parent_window (widget);
- g_object_ref (widget->window);
-
- attributes_east.window_type = GDK_WINDOW_CHILD;
- attributes_west.window_type = GDK_WINDOW_CHILD;
- attributes_north.window_type = GDK_WINDOW_CHILD;
- attributes_south.window_type = GDK_WINDOW_CHILD;
- attributes_middle.window_type = GDK_WINDOW_CHILD;
-
- attributes_east.wclass = GDK_INPUT_ONLY;
- attributes_west.wclass = GDK_INPUT_ONLY;
- attributes_north.wclass = GDK_INPUT_ONLY;
- attributes_south.wclass = GDK_INPUT_ONLY;
- attributes_middle.wclass = GDK_INPUT_ONLY;
-
- attributes_east.x = xpaned->handle_pos_east.x;
- attributes_east.y = xpaned->handle_pos_east.y;
- attributes_east.width = xpaned->handle_pos_east.width;
- attributes_east.height = xpaned->handle_pos_east.height;
-
- attributes_west.x = xpaned->handle_pos_west.x;
- attributes_west.y = xpaned->handle_pos_west.y;
- attributes_west.width = xpaned->handle_pos_west.width;
- attributes_west.height = xpaned->handle_pos_west.height;
-
- attributes_north.x = xpaned->handle_pos_north.x;
- attributes_north.y = xpaned->handle_pos_north.y;
- attributes_north.width = xpaned->handle_pos_north.width;
- attributes_north.height = xpaned->handle_pos_north.height;
-
- attributes_south.x = xpaned->handle_pos_south.x;
- attributes_south.y = xpaned->handle_pos_south.y;
- attributes_south.width = xpaned->handle_pos_south.width;
- attributes_south.height = xpaned->handle_pos_south.height;
-
- attributes_middle.x = xpaned->handle_pos_middle.x;
- attributes_middle.y = xpaned->handle_pos_middle.y;
- attributes_middle.width = xpaned->handle_pos_middle.width;
- attributes_middle.height = xpaned->handle_pos_middle.height;
-
- attributes_east.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
- xpaned->cursor_type_east);
- attributes_west.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
- xpaned->cursor_type_west);
- attributes_north.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
- xpaned->cursor_type_north);
- attributes_south.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
- xpaned->cursor_type_south);
- attributes_middle.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
- xpaned->cursor_type_middle);
-
- attributes_east.event_mask = gtk_widget_get_events (widget);
- attributes_west.event_mask = gtk_widget_get_events (widget);
- attributes_north.event_mask = gtk_widget_get_events (widget);
- attributes_south.event_mask = gtk_widget_get_events (widget);
- attributes_middle.event_mask = gtk_widget_get_events (widget);
-
- attributes_east.event_mask |= (GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK);
- attributes_west.event_mask |= (GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK);
- attributes_north.event_mask |= (GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK);
- attributes_south.event_mask |= (GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK);
- attributes_middle.event_mask |= (GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK);
-
- attributes_mask_east = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
- attributes_mask_west = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
- attributes_mask_north = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
- attributes_mask_south = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
- attributes_mask_middle = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
-
- xpaned->handle_east = gdk_window_new (widget->window,
- &attributes_east,
- attributes_mask_east);
- xpaned->handle_west = gdk_window_new (widget->window,
- &attributes_west,
- attributes_mask_west);
- xpaned->handle_north = gdk_window_new (widget->window,
- &attributes_north,
- attributes_mask_north);
- xpaned->handle_south = gdk_window_new (widget->window,
- &attributes_south,
- attributes_mask_south);
- xpaned->handle_middle = gdk_window_new (widget->window,
- &attributes_middle,
- attributes_mask_middle);
-
- gdk_window_set_user_data (xpaned->handle_east, xpaned);
- gdk_window_set_user_data (xpaned->handle_west, xpaned);
- gdk_window_set_user_data (xpaned->handle_north, xpaned);
- gdk_window_set_user_data (xpaned->handle_south, xpaned);
- gdk_window_set_user_data (xpaned->handle_middle, xpaned);
-
- gdk_cursor_unref (attributes_east.cursor);
- gdk_cursor_unref (attributes_west.cursor);
- gdk_cursor_unref (attributes_north.cursor);
- gdk_cursor_unref (attributes_south.cursor);
- gdk_cursor_unref (attributes_middle.cursor);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- if (xpaned->top_left_child && gtk_widget_get_visible (xpaned->top_left_child) &&
- xpaned->top_right_child && gtk_widget_get_visible (xpaned->top_right_child) &&
- xpaned->bottom_left_child && gtk_widget_get_visible (xpaned->bottom_left_child) &&
- xpaned->bottom_right_child && gtk_widget_get_visible (xpaned->bottom_right_child))
- {
- gdk_window_show (xpaned->handle_east);
- gdk_window_show (xpaned->handle_west);
- gdk_window_show (xpaned->handle_north);
- gdk_window_show (xpaned->handle_south);
- gdk_window_show (xpaned->handle_middle);
- }
-}
-
-static void gtk_xpaned_unrealize (GtkWidget *widget)
-{
- GtkXPaned* xpaned = GTK_XPANED (widget);
-
- if (xpaned->xor_gc)
- {
- g_object_unref (xpaned->xor_gc);
- xpaned->xor_gc = NULL;
- }
-
- if (xpaned->handle_east)
- {
- gdk_window_set_user_data (xpaned->handle_east, NULL);
- gdk_window_destroy (xpaned->handle_east);
- xpaned->handle_east = NULL;
- }
-
- if (xpaned->handle_west)
- {
- gdk_window_set_user_data (xpaned->handle_west, NULL);
- gdk_window_destroy (xpaned->handle_west);
- xpaned->handle_west = NULL;
- }
-
- if (xpaned->handle_north)
- {
- gdk_window_set_user_data (xpaned->handle_north, NULL);
- gdk_window_destroy (xpaned->handle_north);
- xpaned->handle_north = NULL;
- }
-
- if (xpaned->handle_south)
- {
- gdk_window_set_user_data (xpaned->handle_south, NULL);
- gdk_window_destroy (xpaned->handle_south);
- xpaned->handle_south = NULL;
- }
-
- if (xpaned->handle_middle)
- {
- gdk_window_set_user_data (xpaned->handle_middle, NULL);
- gdk_window_destroy (xpaned->handle_middle);
- xpaned->handle_middle = NULL;
- }
-
- gtk_xpaned_set_last_top_left_child_focus (xpaned, NULL);
- gtk_xpaned_set_last_top_right_child_focus (xpaned, NULL);
- gtk_xpaned_set_last_bottom_left_child_focus (xpaned, NULL);
- gtk_xpaned_set_last_bottom_right_child_focus (xpaned, NULL);
- gtk_xpaned_set_saved_focus (xpaned, NULL);
- gtk_xpaned_set_first_xpaned (xpaned, NULL);
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-static void gtk_xpaned_map (GtkWidget* widget)
-{
- GtkXPaned* xpaned = GTK_XPANED (widget);
-
- gdk_window_show (xpaned->handle_east);
- gdk_window_show (xpaned->handle_west);
- gdk_window_show (xpaned->handle_north);
- gdk_window_show (xpaned->handle_south);
- gdk_window_show (xpaned->handle_middle);
-
- GTK_WIDGET_CLASS (parent_class)->map (widget);
-}
-
-static void gtk_xpaned_unmap (GtkWidget* widget)
-{
- GtkXPaned* xpaned = GTK_XPANED (widget);
-
- gdk_window_hide (xpaned->handle_east);
- gdk_window_hide (xpaned->handle_west);
- gdk_window_hide (xpaned->handle_north);
- gdk_window_hide (xpaned->handle_south);
- gdk_window_hide (xpaned->handle_middle);
-
- GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-}
-
-static gboolean gtk_xpaned_expose (GtkWidget* widget,
- GdkEventExpose* event)
-{
- GtkXPaned* xpaned = GTK_XPANED (widget);
- gint handle_size;
- GdkRectangle horizontalClipArea;
- GdkRectangle verticalClipArea;
-
- /* determine size of handle(s) */
- gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
-
- /* I want the handle-"thickness" to be at least 3 */
- g_assert (handle_size >= 3);
-
- if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget) &&
- xpaned->top_left_child && gtk_widget_get_visible (xpaned->top_left_child) &&
- xpaned->top_right_child && gtk_widget_get_visible (xpaned->top_right_child) &&
- xpaned->bottom_left_child && gtk_widget_get_visible (xpaned->bottom_left_child) &&
- xpaned->bottom_right_child && gtk_widget_get_visible (xpaned->bottom_right_child))
- {
- GtkStateType state;
-
- if (gtk_widget_is_focus (widget))
- state = GTK_STATE_SELECTED;
- else if (xpaned->handle_prelit)
- state = GTK_STATE_PRELIGHT;
- else
- state = gtk_widget_get_state (widget);
-
- horizontalClipArea.x = xpaned->handle_pos_west.x;
- horizontalClipArea.y = xpaned->handle_pos_west.y;
- horizontalClipArea.width = xpaned->handle_pos_west.width + handle_size + xpaned->handle_pos_east.width;
- horizontalClipArea.height = handle_size;
-
- verticalClipArea.x = xpaned->handle_pos_north.x;
- verticalClipArea.y = xpaned->handle_pos_north.y;
- verticalClipArea.width = handle_size;
- verticalClipArea.height = xpaned->handle_pos_north.height + handle_size + xpaned->handle_pos_south.height;
-
- gtk_paint_handle (widget->style,
- widget->window,
- state,
- GTK_SHADOW_NONE,
- &horizontalClipArea,
- widget,
- "paned",
- xpaned->handle_pos_east.x - handle_size - 256 / 2,
- xpaned->handle_pos_west.y + 1,
- 256 + handle_size,
- handle_size - 2,
- /*xpaned->handle_pos_west.x,
- xpaned->handle_pos_west.y + 1,
- xpaned->handle_pos_west.width + handle_size + xpaned->handle_pos_east.width,
- handle_size - 2,*/
- GTK_ORIENTATION_HORIZONTAL);
- gtk_paint_handle (widget->style,
- widget->window,
- state,
- GTK_SHADOW_NONE,
- &verticalClipArea,
- widget,
- "paned",
- xpaned->handle_pos_north.x + 1,
- xpaned->handle_pos_south.y - handle_size - 256 / 2,
- handle_size - 2,
- 256 + handle_size,
- /*xpaned->handle_pos_north.x + 1,
- xpaned->handle_pos_north.y,
- handle_size - 2,
- xpaned->handle_pos_north.height + handle_size + xpaned->handle_pos_south.height,*/
- GTK_ORIENTATION_VERTICAL);
- }
-
- /* Chain up to draw children */
- GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
-
- return FALSE;
-}
-
-static gboolean is_rtl (GtkXPaned* xpaned)
-{
- if (gtk_widget_get_direction (GTK_WIDGET (xpaned)) == GTK_TEXT_DIR_RTL)
- return TRUE;
-
- return FALSE;
-}
-
-static void update_drag (GtkXPaned* xpaned)
-{
- GdkPoint pos;
- gint handle_size;
- GtkRequisition size;
-
- gtk_widget_get_pointer (GTK_WIDGET (xpaned), &pos.x, &pos.y);
-
- if (xpaned->in_drag_vert)
- {
- pos.y -= xpaned->drag_pos.y;
-
- if (is_rtl (xpaned))
- {
- gtk_widget_style_get (GTK_WIDGET (xpaned),
- "handle-size", &handle_size,
- NULL);
-
- size.height = GTK_WIDGET (xpaned)->allocation.height - pos.y - handle_size;
- }
- else
- {
- size.height = pos.y;
- }
-
- size.height -= GTK_CONTAINER (xpaned)->border_width;
-
- size.height = CLAMP (size.height, xpaned->min_position.y, xpaned->max_position.y);
-
- if (size.height != xpaned->top_left_child_size.height)
- gtk_xpaned_set_position_y (xpaned, size.height);
- }
-
- if (xpaned->in_drag_horiz)
- {
- pos.x -= xpaned->drag_pos.x;
-
- if (is_rtl (xpaned))
- {
- gtk_widget_style_get (GTK_WIDGET (xpaned),
- "handle-size", &handle_size,
- NULL);
-
- size.width = GTK_WIDGET (xpaned)->allocation.width - pos.x - handle_size;
- }
- else
- {
- size.width = pos.x;
- }
-
- size.width -= GTK_CONTAINER (xpaned)->border_width;
-
- size.width = CLAMP (size.width, xpaned->min_position.x, xpaned->max_position.x);
-
- if (size.width != xpaned->top_left_child_size.width)
- gtk_xpaned_set_position_x (xpaned, size.width);
- }
-
- if (xpaned->in_drag_vert_and_horiz)
- {
- pos.x -= xpaned->drag_pos.x;
- pos.y -= xpaned->drag_pos.y;
-
- if (is_rtl (xpaned))
- {
- gtk_widget_style_get (GTK_WIDGET (xpaned),
- "handle-size", &handle_size,
- NULL);
-
- size.width = GTK_WIDGET (xpaned)->allocation.width - pos.x - handle_size;
- size.height = GTK_WIDGET (xpaned)->allocation.height - pos.y - handle_size;
- }
- else
- {
- size.width = pos.x;
- size.height = pos.y;
- }
-
- size.width -= GTK_CONTAINER (xpaned)->border_width;
- size.height -= GTK_CONTAINER (xpaned)->border_width;
-
- size.width = CLAMP (size.width, xpaned->min_position.x, xpaned->max_position.x);
- size.height = CLAMP (size.height, xpaned->min_position.y, xpaned->max_position.y);
-
- if (size.width != xpaned->top_left_child_size.width)
- gtk_xpaned_set_position_x (xpaned, size.width);
-
- if (size.height != xpaned->top_left_child_size.height)
- gtk_xpaned_set_position_y (xpaned, size.height);
- }
-}
-
-static gboolean gtk_xpaned_enter (GtkWidget* widget, GdkEventCrossing* event)
-{
- GtkXPaned* xpaned = GTK_XPANED (widget);
-
- if (xpaned->in_drag_vert ||
- xpaned->in_drag_horiz ||
- xpaned->in_drag_vert_and_horiz)
- update_drag (xpaned);
- else
- {
- xpaned->handle_prelit = TRUE;
-
- gtk_widget_queue_draw_area (widget,
- xpaned->handle_pos_east.x,
- xpaned->handle_pos_east.y,
- xpaned->handle_pos_east.width,
- xpaned->handle_pos_east.height);
-
- gtk_widget_queue_draw_area (widget,
- xpaned->handle_pos_west.x,
- xpaned->handle_pos_west.y,
- xpaned->handle_pos_west.width,
- xpaned->handle_pos_west.height);
-
- gtk_widget_queue_draw_area (widget,
- xpaned->handle_pos_north.x,
- xpaned->handle_pos_north.y,
- xpaned->handle_pos_north.width,
- xpaned->handle_pos_north.height);
-
- gtk_widget_queue_draw_area (widget,
- xpaned->handle_pos_south.x,
- xpaned->handle_pos_south.y,
- xpaned->handle_pos_south.width,
- xpaned->handle_pos_south.height);
-
- gtk_widget_queue_draw_area (widget,
- xpaned->handle_pos_middle.x,
- xpaned->handle_pos_middle.y,
- xpaned->handle_pos_middle.width,
- xpaned->handle_pos_middle.height);
- }
-
- return TRUE;
-}
-
-static gboolean gtk_xpaned_leave (GtkWidget* widget, GdkEventCrossing* event)
-{
- GtkXPaned* xpaned = GTK_XPANED (widget);
-
- if (xpaned->in_drag_vert ||
- xpaned->in_drag_horiz ||
- xpaned->in_drag_vert_and_horiz)
- update_drag (xpaned);
- else
- {
- xpaned->handle_prelit = FALSE;
-
- gtk_widget_queue_draw_area (widget,
- xpaned->handle_pos_east.x,
- xpaned->handle_pos_east.y,
- xpaned->handle_pos_east.width,
- xpaned->handle_pos_east.height);
-
- gtk_widget_queue_draw_area (widget,
- xpaned->handle_pos_west.x,
- xpaned->handle_pos_west.y,
- xpaned->handle_pos_west.width,
- xpaned->handle_pos_west.height);
-
- gtk_widget_queue_draw_area (widget,
- xpaned->handle_pos_north.x,
- xpaned->handle_pos_north.y,
- xpaned->handle_pos_north.width,
- xpaned->handle_pos_north.height);
-
- gtk_widget_queue_draw_area (widget,
- xpaned->handle_pos_south.x,
- xpaned->handle_pos_south.y,
- xpaned->handle_pos_south.width,
- xpaned->handle_pos_south.height);
+ xpaned->handle_pos_middle.x = xpaned->handle_pos_north.x;
+ xpaned->handle_pos_middle.y = xpaned->handle_pos_east.y;
+ xpaned->handle_pos_middle.width = handle_size + CENTRUM;
+ xpaned->handle_pos_middle.height = handle_size + CENTRUM;
+
+ /* set allocation for top-left child */
+ top_left_child_allocation.x = allocation->x + border_width;
+ top_left_child_allocation.y = allocation->y + border_width;
+ top_left_child_allocation.width = xpaned->handle_pos_west.width;
+ top_left_child_allocation.height = xpaned->handle_pos_north.height;
+
+ /* set allocation for top-right child */
+ top_right_child_allocation.x =
+ allocation->x + border_width + handle_size +
+ top_left_child_allocation.width;
+ top_right_child_allocation.y = allocation->y + border_width;
+ top_right_child_allocation.width = xpaned->handle_pos_east.width;
+ top_right_child_allocation.height = xpaned->handle_pos_north.height;
+
+ /* set allocation for bottom-left child */
+ bottom_left_child_allocation.x = xpaned->handle_pos_west.x;
+ bottom_left_child_allocation.y = xpaned->handle_pos_south.y;
+ bottom_left_child_allocation.width = xpaned->handle_pos_west.width;
+ bottom_left_child_allocation.height = xpaned->handle_pos_south.height;
+
+ /* set allocation for bottom-right child */
+ bottom_right_child_allocation.x = top_right_child_allocation.x;
+ bottom_right_child_allocation.y = bottom_left_child_allocation.y;
+ bottom_right_child_allocation.width = xpaned->handle_pos_east.width;
+ bottom_right_child_allocation.height = xpaned->handle_pos_south.height;
+
+ if (gtk_widget_get_realized (widget))
+ {
+ if (gtk_widget_get_mapped (widget))
+ {
+ gdk_window_show (xpaned->handle_east);
+ gdk_window_show (xpaned->handle_west);
+ gdk_window_show (xpaned->handle_north);
+ gdk_window_show (xpaned->handle_south);
+ gdk_window_show (xpaned->handle_middle);
+ }
+
+ gdk_window_move_resize (xpaned->handle_east,
+ xpaned->handle_pos_east.x,
+ xpaned->handle_pos_east.y,
+ xpaned->handle_pos_east.width,
+ xpaned->handle_pos_east.height);
+
+ gdk_window_move_resize (xpaned->handle_west,
+ xpaned->handle_pos_west.x,
+ xpaned->handle_pos_west.y,
+ xpaned->handle_pos_west.width,
+ xpaned->handle_pos_west.height);
+
+ gdk_window_move_resize (xpaned->handle_north,
+ xpaned->handle_pos_north.x,
+ xpaned->handle_pos_north.y,
+ xpaned->handle_pos_north.width,
+ xpaned->handle_pos_north.height);
+
+ gdk_window_move_resize (xpaned->handle_south,
+ xpaned->handle_pos_south.x,
+ xpaned->handle_pos_south.y,
+ xpaned->handle_pos_south.width,
+ xpaned->handle_pos_south.height);
+
+ gdk_window_move_resize (xpaned->handle_middle,
+ xpaned->handle_pos_middle.x,
+ xpaned->handle_pos_middle.y,
+ xpaned->handle_pos_middle.width,
+ xpaned->handle_pos_middle.height);
+ }
+
+ /* Now allocate the childen, making sure, when resizing not to
+ * overlap the windows
+ */
+ if (gtk_widget_get_mapped (widget))
+ {
+ gtk_widget_size_allocate (xpaned->top_right_child,
+ &top_right_child_allocation);
+ gtk_widget_size_allocate (xpaned->top_left_child,
+ &top_left_child_allocation);
+ gtk_widget_size_allocate (xpaned->bottom_left_child,
+ &bottom_left_child_allocation);
+ gtk_widget_size_allocate (xpaned->bottom_right_child,
+ &bottom_right_child_allocation);
+ }
+ }
+}
+
+static void
+gtk_xpaned_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GtkXPaned *xpaned = GTK_XPANED (object);
+
+ switch (prop_id)
+ {
+ case PROP_X_POSITION:
+ gtk_xpaned_set_position_x (xpaned, g_value_get_int (value));
+ break;
+
+ case PROP_Y_POSITION:
+ gtk_xpaned_set_position_y (xpaned, g_value_get_int (value));
+ break;
+
+ case PROP_POSITION_SET:
+ xpaned->position_set = g_value_get_boolean (value);
+ gtk_widget_queue_resize (GTK_WIDGET (xpaned));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_xpaned_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
+{
+ GtkXPaned *xpaned = GTK_XPANED (object);
+
+ switch (prop_id)
+ {
+ case PROP_X_POSITION:
+ g_value_set_int (value, xpaned->top_left_child_size.width);
+ break;
+
+ case PROP_Y_POSITION:
+ g_value_set_int (value, xpaned->top_left_child_size.height);
+ break;
+
+ case PROP_POSITION_SET:
+ g_value_set_boolean (value, xpaned->position_set);
+ break;
+
+ case PROP_MIN_X_POSITION:
+ g_value_set_int (value, xpaned->min_position.x);
+ break;
+
+ case PROP_MIN_Y_POSITION:
+ g_value_set_int (value, xpaned->min_position.y);
+ break;
+
+ case PROP_MAX_X_POSITION:
+ g_value_set_int (value, xpaned->max_position.x);
+ break;
+
+ case PROP_MAX_Y_POSITION:
+ g_value_set_int (value, xpaned->max_position.y);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_xpaned_set_child_property (GtkContainer * container,
+ GtkWidget * child,
+ guint property_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GtkXPaned *xpaned = GTK_XPANED (container);
+ gboolean old_value = FALSE;
+ gboolean new_value = FALSE;
+
+ g_assert (child == xpaned->top_left_child ||
+ child == xpaned->top_right_child ||
+ child == xpaned->bottom_left_child ||
+ child == xpaned->bottom_right_child);
+
+ new_value = g_value_get_boolean (value);
+
+ switch (property_id)
+ {
+ case CHILD_PROP_RESIZE:
+ if (child == xpaned->top_left_child)
+ {
+ old_value = xpaned->top_left_child_resize;
+ xpaned->top_left_child_resize = new_value;
+ }
+ else if (child == xpaned->top_right_child)
+ {
+ old_value = xpaned->top_right_child_resize;
+ xpaned->top_right_child_resize = new_value;
+ }
+ else if (child == xpaned->bottom_left_child)
+ {
+ old_value = xpaned->bottom_left_child_resize;
+ xpaned->bottom_left_child_resize = new_value;
+ }
+ else if (child == xpaned->bottom_right_child)
+ {
+ old_value = xpaned->bottom_right_child_resize;
+ xpaned->bottom_right_child_resize = new_value;
+ }
+ break;
+
+ case CHILD_PROP_SHRINK:
+ if (child == xpaned->top_left_child)
+ {
+ old_value = xpaned->top_left_child_shrink;
+ xpaned->top_left_child_shrink = new_value;
+ }
+ else if (child == xpaned->top_right_child)
+ {
+ old_value = xpaned->top_right_child_shrink;
+ xpaned->top_right_child_shrink = new_value;
+ }
+ else if (child == xpaned->bottom_left_child)
+ {
+ old_value = xpaned->bottom_left_child_shrink;
+ xpaned->bottom_left_child_shrink = new_value;
+ }
+ else if (child == xpaned->bottom_right_child)
+ {
+ old_value = xpaned->bottom_right_child_shrink;
+ xpaned->bottom_right_child_shrink = new_value;
+ }
+ break;
+
+ default:
+ GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container,
+ property_id, pspec);
+ old_value = -1; /* quiet gcc */
+ break;
+ }
+
+ if (old_value != new_value)
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+}
+
+static void
+gtk_xpaned_get_child_property (GtkContainer * container,
+ GtkWidget * child,
+ guint property_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GtkXPaned *xpaned = GTK_XPANED (container);
+
+ g_assert (child == xpaned->top_left_child ||
+ child == xpaned->top_right_child ||
+ child == xpaned->bottom_left_child ||
+ child == xpaned->bottom_right_child);
+
+ switch (property_id)
+ {
+ case CHILD_PROP_RESIZE:
+ if (child == xpaned->top_left_child)
+ g_value_set_boolean (value, xpaned->top_left_child_resize);
+ else if (child == xpaned->top_right_child)
+ g_value_set_boolean (value, xpaned->top_right_child_resize);
+ else if (child == xpaned->bottom_left_child)
+ g_value_set_boolean (value, xpaned->bottom_left_child_resize);
+ else if (child == xpaned->bottom_right_child)
+ g_value_set_boolean (value, xpaned->bottom_right_child_resize);
+ break;
+
+ case CHILD_PROP_SHRINK:
+ if (child == xpaned->top_left_child)
+ g_value_set_boolean (value, xpaned->top_left_child_shrink);
+ else if (child == xpaned->top_right_child)
+ g_value_set_boolean (value, xpaned->top_right_child_shrink);
+ else if (child == xpaned->bottom_left_child)
+ g_value_set_boolean (value, xpaned->bottom_left_child_shrink);
+ else if (child == xpaned->bottom_right_child)
+ g_value_set_boolean (value, xpaned->bottom_right_child_shrink);
+ break;
+
+ default:
+ GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container,
+ property_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_xpaned_finalize (GObject * object)
+{
+ GtkXPaned *xpaned = GTK_XPANED (object);
+
+ gtk_xpaned_set_saved_focus (xpaned, NULL);
+ gtk_xpaned_set_first_xpaned (xpaned, NULL);
+
+ g_free (xpaned->priv);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gtk_xpaned_realize (GtkWidget * widget)
+{
+ GtkXPaned *xpaned;
+ GdkWindowAttr attributes_east;
+ GdkWindowAttr attributes_west;
+ GdkWindowAttr attributes_north;
+ GdkWindowAttr attributes_south;
+ GdkWindowAttr attributes_middle;
+ gint attributes_mask_east;
+ gint attributes_mask_west;
+ gint attributes_mask_north;
+ gint attributes_mask_south;
+ gint attributes_mask_middle;
+
+ gtk_widget_set_realized (widget, TRUE);
+ xpaned = GTK_XPANED (widget);
+
+ gtk_widget_set_window (widget, gtk_widget_get_parent_window (widget));
+ // g_object_ref (widget->window);
+
+ attributes_east.window_type = GDK_WINDOW_CHILD;
+ attributes_west.window_type = GDK_WINDOW_CHILD;
+ attributes_north.window_type = GDK_WINDOW_CHILD;
+ attributes_south.window_type = GDK_WINDOW_CHILD;
+ attributes_middle.window_type = GDK_WINDOW_CHILD;
+
+ attributes_east.wclass = GDK_INPUT_ONLY;
+ attributes_west.wclass = GDK_INPUT_ONLY;
+ attributes_north.wclass = GDK_INPUT_ONLY;
+ attributes_south.wclass = GDK_INPUT_ONLY;
+ attributes_middle.wclass = GDK_INPUT_ONLY;
+
+ attributes_east.x = xpaned->handle_pos_east.x;
+ attributes_east.y = xpaned->handle_pos_east.y;
+ attributes_east.width = xpaned->handle_pos_east.width;
+ attributes_east.height = xpaned->handle_pos_east.height;
+
+ attributes_west.x = xpaned->handle_pos_west.x;
+ attributes_west.y = xpaned->handle_pos_west.y;
+ attributes_west.width = xpaned->handle_pos_west.width;
+ attributes_west.height = xpaned->handle_pos_west.height;
+
+ attributes_north.x = xpaned->handle_pos_north.x;
+ attributes_north.y = xpaned->handle_pos_north.y;
+ attributes_north.width = xpaned->handle_pos_north.width;
+ attributes_north.height = xpaned->handle_pos_north.height;
+
+ attributes_south.x = xpaned->handle_pos_south.x;
+ attributes_south.y = xpaned->handle_pos_south.y;
+ attributes_south.width = xpaned->handle_pos_south.width;
+ attributes_south.height = xpaned->handle_pos_south.height;
+
+ attributes_middle.x = xpaned->handle_pos_middle.x;
+ attributes_middle.y = xpaned->handle_pos_middle.y;
+ attributes_middle.width = xpaned->handle_pos_middle.width;
+ attributes_middle.height = xpaned->handle_pos_middle.height;
+
+ attributes_east.cursor =
+ gdk_cursor_new_for_display (gtk_widget_get_display (widget),
+ xpaned->cursor_type_east);
+ attributes_west.cursor =
+ gdk_cursor_new_for_display (gtk_widget_get_display (widget),
+ xpaned->cursor_type_west);
+ attributes_north.cursor =
+ gdk_cursor_new_for_display (gtk_widget_get_display (widget),
+ xpaned->cursor_type_north);
+ attributes_south.cursor =
+ gdk_cursor_new_for_display (gtk_widget_get_display (widget),
+ xpaned->cursor_type_south);
+ attributes_middle.cursor =
+ gdk_cursor_new_for_display (gtk_widget_get_display (widget),
+ xpaned->cursor_type_middle);
+
+ attributes_east.event_mask = gtk_widget_get_events (widget);
+ attributes_west.event_mask = gtk_widget_get_events (widget);
+ attributes_north.event_mask = gtk_widget_get_events (widget);
+ attributes_south.event_mask = gtk_widget_get_events (widget);
+ attributes_middle.event_mask = gtk_widget_get_events (widget);
+
+ attributes_east.event_mask |= (GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK);
+ attributes_west.event_mask |= (GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK);
+ attributes_north.event_mask |= (GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK);
+ attributes_south.event_mask |= (GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK);
+ attributes_middle.event_mask |= (GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK);
+
+ attributes_mask_east = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
+ attributes_mask_west = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
+ attributes_mask_north = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
+ attributes_mask_south = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
+ attributes_mask_middle = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
+
+ xpaned->handle_east = gdk_window_new (gtk_widget_get_window (widget),
+ &attributes_east,
+ attributes_mask_east);
+ xpaned->handle_west = gdk_window_new (gtk_widget_get_window (widget),
+ &attributes_west,
+ attributes_mask_west);
+ xpaned->handle_north = gdk_window_new (gtk_widget_get_window (widget),
+ &attributes_north,
+ attributes_mask_north);
+ xpaned->handle_south = gdk_window_new (gtk_widget_get_window (widget),
+ &attributes_south,
+ attributes_mask_south);
+ xpaned->handle_middle = gdk_window_new (gtk_widget_get_window (widget),
+ &attributes_middle,
+ attributes_mask_middle);
+
+ gdk_window_set_user_data (xpaned->handle_east, xpaned);
+ gdk_window_set_user_data (xpaned->handle_west, xpaned);
+ gdk_window_set_user_data (xpaned->handle_north, xpaned);
+ gdk_window_set_user_data (xpaned->handle_south, xpaned);
+ gdk_window_set_user_data (xpaned->handle_middle, xpaned);
+
+ g_object_unref (attributes_east.cursor);
+ g_object_unref (attributes_west.cursor);
+ g_object_unref (attributes_north.cursor);
+ g_object_unref (attributes_south.cursor);
+ g_object_unref (attributes_middle.cursor);
+
+ if (xpaned->top_left_child
+ && gtk_widget_get_visible (xpaned->top_left_child)
+ && xpaned->top_right_child
+ && gtk_widget_get_visible (xpaned->top_right_child)
+ && xpaned->bottom_left_child
+ && gtk_widget_get_visible (xpaned->bottom_left_child)
+ && xpaned->bottom_right_child
+ && gtk_widget_get_visible (xpaned->bottom_right_child))
+ {
+ gdk_window_show (xpaned->handle_east);
+ gdk_window_show (xpaned->handle_west);
+ gdk_window_show (xpaned->handle_north);
+ gdk_window_show (xpaned->handle_south);
+ gdk_window_show (xpaned->handle_middle);
+ }
+}
+
+static void
+gtk_xpaned_unrealize (GtkWidget * widget)
+{
+ GtkXPaned *xpaned = GTK_XPANED (widget);
+
+ if (xpaned->handle_east)
+ {
+ gdk_window_set_user_data (xpaned->handle_east, NULL);
+ gdk_window_destroy (xpaned->handle_east);
+ xpaned->handle_east = NULL;
+ }
+
+ if (xpaned->handle_west)
+ {
+ gdk_window_set_user_data (xpaned->handle_west, NULL);
+ gdk_window_destroy (xpaned->handle_west);
+ xpaned->handle_west = NULL;
+ }
+
+ if (xpaned->handle_north)
+ {
+ gdk_window_set_user_data (xpaned->handle_north, NULL);
+ gdk_window_destroy (xpaned->handle_north);
+ xpaned->handle_north = NULL;
+ }
+
+ if (xpaned->handle_south)
+ {
+ gdk_window_set_user_data (xpaned->handle_south, NULL);
+ gdk_window_destroy (xpaned->handle_south);
+ xpaned->handle_south = NULL;
+ }
+
+ if (xpaned->handle_middle)
+ {
+ gdk_window_set_user_data (xpaned->handle_middle, NULL);
+ gdk_window_destroy (xpaned->handle_middle);
+ xpaned->handle_middle = NULL;
+ }
+
+ gtk_xpaned_set_last_top_left_child_focus (xpaned, NULL);
+ gtk_xpaned_set_last_top_right_child_focus (xpaned, NULL);
+ gtk_xpaned_set_last_bottom_left_child_focus (xpaned, NULL);
+ gtk_xpaned_set_last_bottom_right_child_focus (xpaned, NULL);
+ gtk_xpaned_set_saved_focus (xpaned, NULL);
+ gtk_xpaned_set_first_xpaned (xpaned, NULL);
+
+ if (GTK_WIDGET_CLASS (parent_class)->unrealize)
+ (*GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
+}
+
+static void
+gtk_xpaned_map (GtkWidget * widget)
+{
+ GtkXPaned *xpaned = GTK_XPANED (widget);
+
+ gdk_window_show (xpaned->handle_east);
+ gdk_window_show (xpaned->handle_west);
+ gdk_window_show (xpaned->handle_north);
+ gdk_window_show (xpaned->handle_south);
+ gdk_window_show (xpaned->handle_middle);
+
+ GTK_WIDGET_CLASS (parent_class)->map (widget);
+}
+
+static void
+gtk_xpaned_unmap (GtkWidget * widget)
+{
+ GtkXPaned *xpaned = GTK_XPANED (widget);
+
+ gdk_window_hide (xpaned->handle_east);
+ gdk_window_hide (xpaned->handle_west);
+ gdk_window_hide (xpaned->handle_north);
+ gdk_window_hide (xpaned->handle_south);
+ gdk_window_hide (xpaned->handle_middle);
+
+ GTK_WIDGET_CLASS (parent_class)->unmap (widget);
+}
+
+static gboolean
+gtk_xpaned_draw (GtkWidget * widget, cairo_t *cr)
+{
+ GtkXPaned *xpaned = GTK_XPANED (widget);
+ gint handle_size;
+
+ /* determine size of handle(s) */
+ gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
+
+ /* I want the handle-"thickness" to be at least 3 */
+ g_assert (handle_size >= 3);
+
+ if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget) &&
+ xpaned->top_left_child
+ && gtk_widget_get_visible (xpaned->top_left_child)
+ && xpaned->top_right_child
+ && gtk_widget_get_visible (xpaned->top_right_child)
+ && xpaned->bottom_left_child
+ && gtk_widget_get_visible (xpaned->bottom_left_child)
+ && xpaned->bottom_right_child
+ && gtk_widget_get_visible (xpaned->bottom_right_child))
+ {
+ GtkStateType state;
+
+ if (gtk_widget_is_focus (widget))
+ state = GTK_STATE_SELECTED;
+ else if (xpaned->handle_prelit)
+ state = GTK_STATE_PRELIGHT;
+ else
+ state = gtk_widget_get_state (widget);
+
+ gtk_paint_handle (gtk_widget_get_style (widget),
+ cr,
+ state,
+ GTK_SHADOW_NONE,
+ widget,
+ "paned",
+ xpaned->handle_pos_east.x - handle_size - 256 / 2,
+ xpaned->handle_pos_west.y + 1,
+ 256 + handle_size, handle_size - 2,
+ /*xpaned->handle_pos_west.x,
+ xpaned->handle_pos_west.y + 1,
+ xpaned->handle_pos_west.width + handle_size + xpaned->handle_pos_east.width,
+ handle_size - 2, */
+ GTK_ORIENTATION_HORIZONTAL);
+
+ gtk_paint_handle (gtk_widget_get_style (widget),
+ cr,
+ state,
+ GTK_SHADOW_NONE,
+ widget,
+ "paned",
+ xpaned->handle_pos_north.x + 1,
+ xpaned->handle_pos_south.y - handle_size - 256 / 2,
+ handle_size - 2, 256 + handle_size,
+ /*xpaned->handle_pos_north.x + 1,
+ xpaned->handle_pos_north.y,
+ handle_size - 2,
+ xpaned->handle_pos_north.height + handle_size + xpaned->handle_pos_south.height, */
+ GTK_ORIENTATION_VERTICAL);
+ }
+
+ /* Chain up to draw children */
+ GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+
+ return FALSE;
+}
+
+static gboolean
+is_rtl (GtkXPaned * xpaned)
+{
+ if (gtk_widget_get_direction (GTK_WIDGET (xpaned)) == GTK_TEXT_DIR_RTL)
+ return TRUE;
+
+ return FALSE;
+}
+
+static void
+update_drag (GtkXPaned * xpaned)
+{
+ GdkPoint pos;
+ gint handle_size;
+ GtkRequisition size;
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (GTK_WIDGET (xpaned), &allocation);
+
+ gtk_widget_get_pointer (GTK_WIDGET (xpaned), &pos.x, &pos.y);
+
+ if (xpaned->in_drag_vert)
+ {
+ pos.y -= xpaned->drag_pos.y;