Commit c8515b2f authored by Soeren Sandmann's avatar Soeren Sandmann Committed by Søren Sandmann Pedersen

add vertical_padding style property.

Sat Jul  5 10:34:00 2003  Soeren Sandmann  <sandmann@daimi.au.dk>

        * gtk/gtkmenu.c: add vertical_padding style property.

        * gtk/gtkmenuitem.c: add style properties toggle_spacing,
        arrow_spacing and horizontal_padding. Also center separators and
        make them a bit taller.

        * gtk/*menuitem.c: use new style properties.

        * docs/widget_geometry.txt: Add note about GtkMenuItem

        * gtk/gtkstyle.c
        (gtk_default_draw_vline, gtk_default_draw_hline):
        fix +/-1 errors.

        (gtk_default_draw_shadow): draw a black border around menus.

        * gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix
        calls to gtk_paint_hline() and gtk_paint_vline() (they take x1,
        x2 and y1, y2 respectively, not x, width and y, height).
parent ba999da1
Sat Jul 5 10:34:00 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkmenu.c: add vertical_padding style property.
* gtk/gtkmenuitem.c: add style properties toggle_spacing,
arrow_spacing and horizontal_padding. Also center separators and
make them a bit taller.
* gtk/*menuitem.c: use new style properties.
* docs/widget_geometry.txt: Add note about GtkMenuItem
* gtk/gtkstyle.c
(gtk_default_draw_vline, gtk_default_draw_hline):
fix +/-1 errors.
(gtk_default_draw_shadow): draw a black border around menus.
* gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix
calls to gtk_paint_hline() and gtk_paint_vline() (they take x1,
x2 and y1, y2 respectively, not x, width and y, height).
Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup
......
Sat Jul 5 10:34:00 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkmenu.c: add vertical_padding style property.
* gtk/gtkmenuitem.c: add style properties toggle_spacing,
arrow_spacing and horizontal_padding. Also center separators and
make them a bit taller.
* gtk/*menuitem.c: use new style properties.
* docs/widget_geometry.txt: Add note about GtkMenuItem
* gtk/gtkstyle.c
(gtk_default_draw_vline, gtk_default_draw_hline):
fix +/-1 errors.
(gtk_default_draw_shadow): draw a black border around menus.
* gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix
calls to gtk_paint_hline() and gtk_paint_vline() (they take x1,
x2 and y1, y2 respectively, not x, width and y, height).
Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup
......
Sat Jul 5 10:34:00 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkmenu.c: add vertical_padding style property.
* gtk/gtkmenuitem.c: add style properties toggle_spacing,
arrow_spacing and horizontal_padding. Also center separators and
make them a bit taller.
* gtk/*menuitem.c: use new style properties.
* docs/widget_geometry.txt: Add note about GtkMenuItem
* gtk/gtkstyle.c
(gtk_default_draw_vline, gtk_default_draw_hline):
fix +/-1 errors.
(gtk_default_draw_shadow): draw a black border around menus.
* gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix
calls to gtk_paint_hline() and gtk_paint_vline() (they take x1,
x2 and y1, y2 respectively, not x, width and y, height).
Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup
......
Sat Jul 5 10:34:00 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkmenu.c: add vertical_padding style property.
* gtk/gtkmenuitem.c: add style properties toggle_spacing,
arrow_spacing and horizontal_padding. Also center separators and
make them a bit taller.
* gtk/*menuitem.c: use new style properties.
* docs/widget_geometry.txt: Add note about GtkMenuItem
* gtk/gtkstyle.c
(gtk_default_draw_vline, gtk_default_draw_hline):
fix +/-1 errors.
(gtk_default_draw_shadow): draw a black border around menus.
* gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix
calls to gtk_paint_hline() and gtk_paint_vline() (they take x1,
x2 and y1, y2 respectively, not x, width and y, height).
Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup
......
Sat Jul 5 10:34:00 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkmenu.c: add vertical_padding style property.
* gtk/gtkmenuitem.c: add style properties toggle_spacing,
arrow_spacing and horizontal_padding. Also center separators and
make them a bit taller.
* gtk/*menuitem.c: use new style properties.
* docs/widget_geometry.txt: Add note about GtkMenuItem
* gtk/gtkstyle.c
(gtk_default_draw_vline, gtk_default_draw_hline):
fix +/-1 errors.
(gtk_default_draw_shadow): draw a black border around menus.
* gtk/gtkvseparator, gtk/gtkhseparator.c, gtk/gtkmenuitem.c: fix
calls to gtk_paint_hline() and gtk_paint_vline() (they take x1,
x2 and y1, y2 respectively, not x, width and y, height).
Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup
......
......@@ -2,6 +2,38 @@ This file is some notes about how different widgets are drawn.
=============
GtkMenuItem
=============
arrowspacing
togglespacing
horizontal_padding
B
------------------
A C D E G A
+----+----------+-----+----------------------+----+-----------+----+
| | | | ^ | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | icon | | child | G | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | v | | | |
+----+----------+-----+----------------------+----+-----------+----+
A: horizontal_padding
B: width of icon or indicator + toggle_spacing
C: toggle_spacing
D: child's requested size
E: arrow spacing (if the item has a submenu
G: child's requested height (also used for width of arrow field
=============
GtkOptionMenu:
=============
......
......@@ -231,9 +231,15 @@ static void
gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item,
gint *requisition)
{
guint toggle_spacing;
g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (menu_item));
*requisition = CHECK_TOGGLE_SIZE;
gtk_widget_style_get (GTK_WIDGET (menu_item),
"toggle_spacing", &toggle_spacing,
NULL);
*requisition = CHECK_TOGGLE_SIZE + toggle_spacing;
}
void
......@@ -348,20 +354,42 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
GtkShadowType shadow_type;
gint width, height;
gint x, y;
gint offset;
if (GTK_WIDGET_DRAWABLE (check_menu_item))
{
guint offset;
guint toggle_size;
guint toggle_spacing;
guint horizontal_padding;
widget = GTK_WIDGET (check_menu_item);
gtk_widget_style_get (GTK_WIDGET (check_menu_item),
"toggle_spacing", &toggle_spacing,
"horizontal_padding", &horizontal_padding,
NULL);
width = 8;
height = 8;
toggle_size = GTK_MENU_ITEM (check_menu_item)->toggle_size;
offset = GTK_CONTAINER (check_menu_item)->border_width + widget->style->xthickness;
offset = GTK_CONTAINER (check_menu_item)->border_width +
widget->style->xthickness + 2;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
x = widget->allocation.x + offset;
widget->style->xthickness + 2;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
{
x = widget->allocation.x + offset + horizontal_padding +
(toggle_size - toggle_spacing - width) / 2;
}
else
x = widget->allocation.x + widget->allocation.width - width - offset;
{
x = widget->allocation.x + widget->allocation.width -
offset - horizontal_padding - toggle_size + toggle_spacing +
(toggle_size - toggle_spacing - width) / 2;
}
y = widget->allocation.y + (widget->allocation.height - height) / 2;
if (check_menu_item->active ||
......
......@@ -93,7 +93,7 @@ gtk_hseparator_expose (GtkWidget *widget,
gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL,
&event->area, widget, "hseparator",
widget->allocation.x,
widget->allocation.x + widget->allocation.width,
widget->allocation.x + widget->allocation.width - 1,
widget->allocation.y + (widget->allocation.height -
widget->style->ythickness) / 2);
......
......@@ -185,7 +185,15 @@ gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item);
if (image_menu_item->image)
*requisition = image_menu_item->image->requisition.width;
{
guint toggle_spacing;
gtk_widget_style_get (GTK_WIDGET (menu_item),
"toggle_spacing", &toggle_spacing,
NULL);
*requisition = image_menu_item->image->requisition.width + toggle_spacing;
}
else
*requisition = 0;
}
......@@ -237,6 +245,12 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
{
gint width, height, x, y, offset;
GtkAllocation child_allocation;
guint horizontal_padding, toggle_spacing;
gtk_widget_style_get (widget,
"horizontal_padding", &horizontal_padding,
"toggle_spacing", &toggle_spacing,
NULL);
/* Man this is lame hardcoding action, but I can't
* come up with a solution that's really better.
......@@ -245,14 +259,22 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
width = image_menu_item->image->requisition.width;
height = image_menu_item->image->requisition.height;
offset = GTK_CONTAINER (image_menu_item)->border_width +
widget->style->xthickness;
widget->style->xthickness;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
x = offset + (GTK_MENU_ITEM (image_menu_item)->toggle_size - width) / 2;
else
x = widget->allocation.width -
GTK_MENU_ITEM (image_menu_item)->toggle_size - offset +
(GTK_MENU_ITEM (image_menu_item)->toggle_size - width) / 2;
{
x = offset + horizontal_padding +
(GTK_MENU_ITEM (image_menu_item)->toggle_size -
toggle_spacing - width) / 2;
}
else
{
x = widget->allocation.width - offset - horizontal_padding -
GTK_MENU_ITEM (image_menu_item)->toggle_size + toggle_spacing +
(GTK_MENU_ITEM (image_menu_item)->toggle_size -
toggle_spacing - width) / 2;
}
y = (widget->allocation.height - height) / 2;
child_allocation.width = width;
......
......@@ -265,6 +265,15 @@ gtk_menu_class_init (GtkMenuClass *class)
"",
G_PARAM_READABLE | G_PARAM_WRITABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("vertical-padding",
_("Vertical Padding"),
_("Extra space at the top and bottom of the menu"),
0,
G_MAXINT,
1,
G_PARAM_READABLE));
object_class->destroy = gtk_menu_destroy;
widget_class->realize = gtk_menu_realize;
......@@ -1489,7 +1498,8 @@ gtk_menu_realize (GtkWidget *widget)
GtkMenu *menu;
GtkWidget *child;
GList *children;
guint vertical_padding;
g_return_if_fail (GTK_IS_MENU (widget));
menu = GTK_MENU (widget);
......@@ -1514,9 +1524,13 @@ gtk_menu_realize (GtkWidget *widget)
gdk_window_set_user_data (widget->window, widget);
border_width = GTK_CONTAINER (widget)->border_width;
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
NULL);
attributes.x = border_width + widget->style->xthickness;
attributes.y = border_width + widget->style->ythickness;
attributes.y = border_width + widget->style->ythickness + vertical_padding;
attributes.width = MAX (1, widget->allocation.width - attributes.x * 2);
attributes.height = MAX (1, widget->allocation.height - attributes.y * 2);
......@@ -1533,7 +1547,7 @@ gtk_menu_realize (GtkWidget *widget)
attributes.x = 0;
attributes.y = 0;
attributes.height = MAX (1, widget->requisition.height - (border_width + widget->style->ythickness) * 2);
attributes.height = MAX (1, widget->requisition.height - (border_width + widget->style->ythickness + vertical_padding) * 2);
menu->bin_window = gdk_window_new (menu->view_window, &attributes, attributes_mask);
gdk_window_set_user_data (menu->bin_window, menu);
......@@ -1648,6 +1662,7 @@ gtk_menu_size_request (GtkWidget *widget,
GList *children;
guint max_toggle_size;
guint max_accel_width;
guint vertical_padding;
GtkRequisition child_requisition;
g_return_if_fail (GTK_IS_MENU (widget));
......@@ -1689,11 +1704,15 @@ gtk_menu_size_request (GtkWidget *widget,
max_accel_width = MAX (max_accel_width, GTK_MENU_ITEM (child)->accelerator_width);
}
}
requisition->width += max_toggle_size + max_accel_width;
requisition->width += (GTK_CONTAINER (menu)->border_width +
widget->style->xthickness) * 2;
requisition->height += (GTK_CONTAINER (menu)->border_width +
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
NULL);
requisition->height += (GTK_CONTAINER (menu)->border_width + vertical_padding +
widget->style->ythickness) * 2;
menu->toggle_size = max_toggle_size;
......@@ -1715,6 +1734,7 @@ gtk_menu_size_allocate (GtkWidget *widget,
GList *children;
gint x, y;
gint width, height;
guint vertical_padding;
g_return_if_fail (GTK_IS_MENU (widget));
g_return_if_fail (allocation != NULL);
......@@ -1724,9 +1744,13 @@ gtk_menu_size_allocate (GtkWidget *widget,
widget->allocation = *allocation;
x = GTK_CONTAINER (menu)->border_width + widget->style->xthickness;
y = GTK_CONTAINER (menu)->border_width + widget->style->ythickness;
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
NULL);
x = GTK_CONTAINER (menu)->border_width + widget->style->xthickness;
y = GTK_CONTAINER (menu)->border_width + widget->style->ythickness + vertical_padding;
width = MAX (1, allocation->width - x * 2);
height = MAX (1, allocation->height - y * 2);
......@@ -1776,6 +1800,7 @@ gtk_menu_size_allocate (GtkWidget *widget,
gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
menu->toggle_size);
gtk_widget_size_allocate (child, &child_allocation);
gtk_widget_queue_draw (child);
......@@ -1838,17 +1863,25 @@ gtk_menu_paint (GtkWidget *widget,
GtkMenu *menu;
gint width, height;
gint border_x, border_y;
guint vertical_padding;
g_return_if_fail (GTK_IS_MENU (widget));
menu = GTK_MENU (widget);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
NULL);
border_x = GTK_CONTAINER (widget)->border_width + widget->style->xthickness;
border_y = GTK_CONTAINER (widget)->border_width + widget->style->ythickness;
border_y = GTK_CONTAINER (widget)->border_width + widget->style->ythickness + vertical_padding;
gdk_drawable_get_size (widget->window, &width, &height);
if (event->window == widget->window)
{
gint arrow_space = MENU_SCROLL_ARROW_HEIGHT - 2 * widget->style->ythickness;
gint arrow_size = 0.7 * arrow_space;
gtk_paint_box (widget->style,
widget->window,
GTK_STATE_NORMAL,
......@@ -1865,7 +1898,7 @@ gtk_menu_paint (GtkWidget *widget,
NULL, widget, "menu",
border_x,
border_y,
width - 2*border_x,
width - 2 * border_x,
MENU_SCROLL_ARROW_HEIGHT);
gtk_paint_arrow (widget->style,
......@@ -1873,13 +1906,12 @@ gtk_menu_paint (GtkWidget *widget,
menu->upper_arrow_prelight ?
GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
NULL, widget, "menu",
NULL, widget, "menu_scroll_arrow_up",
GTK_ARROW_UP,
TRUE,
width / 2 - MENU_SCROLL_ARROW_HEIGHT / 2 + 1,
2 * border_y + 1,
MENU_SCROLL_ARROW_HEIGHT - 2 * border_y - 2,
MENU_SCROLL_ARROW_HEIGHT - 2 * border_y - 2);
(width - arrow_size ) / 2,
border_y + widget->style->ythickness + (arrow_space - arrow_size)/2,
arrow_size, arrow_size);
}
if (menu->lower_arrow_visible && !menu->tearoff_active)
......@@ -1891,7 +1923,7 @@ gtk_menu_paint (GtkWidget *widget,
GTK_SHADOW_OUT,
NULL, widget, "menu",
border_x,
height - border_y - MENU_SCROLL_ARROW_HEIGHT + 1,
height - border_y - MENU_SCROLL_ARROW_HEIGHT,
width - 2*border_x,
MENU_SCROLL_ARROW_HEIGHT);
......@@ -1900,13 +1932,13 @@ gtk_menu_paint (GtkWidget *widget,
menu->lower_arrow_prelight ?
GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
NULL, widget, "menu",
NULL, widget, "menu_scroll_arrow_down",
GTK_ARROW_DOWN,
TRUE,
width / 2 - MENU_SCROLL_ARROW_HEIGHT / 2 + 1,
height - MENU_SCROLL_ARROW_HEIGHT + 1,
MENU_SCROLL_ARROW_HEIGHT - 2 * border_y - 2,
MENU_SCROLL_ARROW_HEIGHT - 2 * border_y - 2);
(width - arrow_size) / 2,
height - border_y - MENU_SCROLL_ARROW_HEIGHT +
widget->style->ythickness + (arrow_space - arrow_size)/2,
arrow_size, arrow_size);
}
}
}
......@@ -2242,13 +2274,19 @@ gtk_menu_handle_scrolling (GtkMenu *menu, gboolean enter)
GdkRectangle rect;
gboolean in_arrow;
gboolean scroll_fast = FALSE;
guint vertical_padding;
menu_shell = GTK_MENU_SHELL (menu);
gdk_window_get_pointer (GTK_WIDGET (menu)->window, &x, &y, NULL);
gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height);
border = GTK_CONTAINER (menu)->border_width + GTK_WIDGET (menu)->style->ythickness;
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
NULL);
border = GTK_CONTAINER (menu)->border_width +
GTK_WIDGET (menu)->style->ythickness + vertical_padding;
if (menu->upper_arrow_visible && !menu->tearoff_active)
{
......@@ -2783,6 +2821,7 @@ gtk_menu_scroll_to (GtkMenu *menu,
gint border_width;
gboolean last_visible;
gint menu_height;
guint vertical_padding;
widget = GTK_WIDGET (menu);
......@@ -2800,13 +2839,18 @@ gtk_menu_scroll_to (GtkMenu *menu,
view_width = widget->allocation.width;
view_height = widget->allocation.height;
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
NULL);
border_width = GTK_CONTAINER (menu)->border_width;
view_width -= (border_width + widget->style->xthickness) * 2;
view_height -= (border_width + widget->style->ythickness) * 2;
menu_height = widget->requisition.height - (border_width + widget->style->ythickness) * 2;
view_height -= (border_width + widget->style->ythickness + vertical_padding) * 2;
menu_height = widget->requisition.height -
(border_width + widget->style->ythickness + vertical_padding) * 2;
x = border_width + widget->style->xthickness;
y = border_width + widget->style->ythickness;
y = border_width + widget->style->ythickness + vertical_padding;
if (!menu->tearoff_active)
{
......@@ -2823,7 +2867,10 @@ gtk_menu_scroll_to (GtkMenu *menu,
/* If we hid the upper arrow, possibly remove timeout */
if (menu->scroll_step < 0)
gtk_menu_stop_scrolling (menu);
{
gtk_menu_stop_scrolling (menu);
gtk_widget_queue_draw (GTK_WIDGET (menu));
}
}
last_visible = menu->lower_arrow_visible;
......@@ -2839,7 +2886,10 @@ gtk_menu_scroll_to (GtkMenu *menu,
/* If we hid the lower arrow, possibly remove timeout */
if (menu->scroll_step > 0)
gtk_menu_stop_scrolling (menu);
{
gtk_menu_stop_scrolling (menu);
gtk_widget_queue_draw (GTK_WIDGET (menu));
}
}
if (menu->upper_arrow_visible)
......@@ -2926,10 +2976,16 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
if (compute_child_offset (menu, menu_item,
&child_offset, &child_height, &last_child))
{
guint vertical_padding;
y = menu->scroll_offset;
gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height);
height -= 2*GTK_CONTAINER (menu)->border_width + 2*GTK_WIDGET (menu)->style->ythickness;
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
NULL);
height -= 2*GTK_CONTAINER (menu)->border_width + 2*GTK_WIDGET (menu)->style->ythickness + 2*vertical_padding;
if (child_offset < y)
{
......
......@@ -35,12 +35,8 @@
#include "gtkmenuitem.h"
#include "gtkseparatormenuitem.h"
#define BORDER_SPACING 3
#define MENU_ITEM_CLASS(w) GTK_MENU_ITEM_CLASS (GTK_OBJECT (w)->klass)
enum {
ACTIVATE,
ACTIVATE_ITEM,
......@@ -211,6 +207,33 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
GTK_SHADOW_NONE,
G_PARAM_READABLE),
gtk_rc_property_parse_enum);
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("horizontal_padding",
"Horizontal Padding",
"Padding to left and right of the menu item",
0,
G_MAXINT,
3,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("toggle_spacing",
"Icon Spacing",
"Space between icon and label",
0,
G_MAXINT,
5,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("arrow_spacing",
"Arrow Spacing",
"Space between label and arrow",
0,
G_MAXINT,
10,
G_PARAM_READABLE));
}
static void
......@@ -449,16 +472,20 @@ gtk_menu_item_size_request (GtkWidget *widget,
GtkMenuItem *menu_item;
GtkBin *bin;
guint accel_width;
guint horizontal_padding;
g_return_if_fail (GTK_IS_MENU_ITEM (widget));
g_return_if_fail (requisition != NULL);
gtk_widget_style_get (widget,
"horizontal padding", &horizontal_padding,
NULL);
bin = GTK_BIN (widget);
menu_item = GTK_MENU_ITEM (widget);
requisition->width = (GTK_CONTAINER (widget)->border_width +
widget->style->xthickness +
BORDER_SPACING) * 2;
widget->style->xthickness + horizontal_padding) * 2;
requisition->height = (GTK_CONTAINER (widget)->border_width +
widget->style->ythickness) * 2;
......@@ -472,7 +499,21 @@ gtk_menu_item_size_request (GtkWidget *widget,
requisition->height += child_requisition.height;
if (menu_item->submenu && menu_item->show_submenu_indicator)
requisition->width += child_requisition.height;
{
guint arrow_spacing;
gtk_widget_style_get (widget,
"arrow_spacing", &arrow_spacing,
NULL);
requisition->width += child_requisition.height;
requisition->width += arrow_spacing;
}
}
else
{
/* separator item */
requisition->height += 4;
}
accel_width = 0;
......@@ -504,10 +545,15 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
if (bin->child)
{
GtkRequisition child_requisition;
guint horizontal_padding;
gtk_widget_style_get (widget,
"horizontal_padding", &horizontal_padding,
NULL);
child_allocation.x = (GTK_CONTAINER (widget)->border_width +
widget->style->xthickness +
BORDER_SPACING);
horizontal_padding);
child_allocation.y = (GTK_CONTAINER (widget)->border_width +
widget->style->ythickness);
child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
......@@ -649,29 +695,36 @@ gtk_menu_item_paint (GtkWidget *widget,
gint arrow_x, arrow_y;
gint arrow_size;
gint arrow_extent;
guint horizontal_padding;
GtkTextDirection direction;
GtkArrowType arrow_type;
direction = gtk_widget_get_direction (widget);
gtk_widget_style_get (widget,
"horizontal_padding", &horizontal_padding,
NULL);
gtk_widget_get_child_requisition (GTK_BIN (menu_item)->child,
&child_requisition);
arrow_size = child_requisition.height - 2 * widget->style->ythickness;
arrow_extent = arrow_size * 0.6;
arrow_extent = arrow_size * 0.8;
shadow_type = GTK_SHADOW_OUT;
if (state_type == GTK_STATE_PRELIGHT)
shadow_type = GTK_SHADOW_IN;
if (direction == GTK_TEXT_DIR_LTR) {
arrow_x = x + width - 1 - arrow_size + (arrow_size - arrow_extent) / 2;
arrow_type = GTK_ARROW_RIGHT;
}
else {
arrow_x = x + 1 + (arrow_size - arrow_extent) / 2;
arrow_type = GTK_ARROW_LEFT;
}
if (direction == GTK_TEXT_DIR_LTR)
{
arrow_x = x + width - horizontal_padding - arrow_extent;
arrow_type = GTK_ARROW_RIGHT;
}
else
{
arrow_x = x + horizontal_padding;
arrow_type = GTK_ARROW_LEFT;
}
arrow_y = y + (height - arrow_extent) / 2;
......@@ -684,10 +737,18 @@ gtk_menu_item_paint (GtkWidget *widget,
}
else if (!GTK_BIN (menu_item)->child)
{
guint horizontal_padding;
gtk_widget_style_get (widget,
"horizontal_padding", &horizontal_padding,
NULL);
gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL,
area, widget, "menuitem",
widget->allocation.x, widget->allocation.width,
widget->allocation.y);
widget->allocation.x + horizontal_padding + widget->style->xthickness,
widget->allocation.x + widget->allocation.width - horizontal_padding - widget->style->xthickness - 1,