#include "gtkintl.h"
#include "gtktypebuiltins.h"
+#include "a11y/gtkspinbuttonaccessible.h"
+
#define MIN_SPIN_BUTTON_WIDTH 30
#define MAX_TIMER_CALLS 5
#define EPSILON 1e-10
add_spin_binding (binding_set, GDK_KEY_Page_Down, GDK_CONTROL_MASK, GTK_SCROLL_START);
g_type_class_add_private (class, sizeof (GtkSpinButtonPrivate));
+
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SPIN_BUTTON_ACCESSIBLE);
}
static void
gint attributes_mask;
gboolean return_val;
gint arrow_size;
+ gint req_height;
GtkBorder padding;
arrow_size = spin_button_get_arrow_size (spin_button);
gtk_widget_get_preferred_size (widget, &requisition, NULL);
+ req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
gtk_widget_get_allocation (widget, &allocation);
gtk_widget_set_events (widget, gtk_widget_get_events (widget) |
gtk_style_context_get_padding (context, state, &padding);
attributes.x = allocation.x + allocation.width - arrow_size - (padding.left + padding.right);
- attributes.y = allocation.y + (allocation.height - requisition.height) / 2;
+ attributes.y = allocation.y + (allocation.height - req_height) / 2;
attributes.width = arrow_size + padding.left + padding.right;
- attributes.height = requisition.height;
+ attributes.height = req_height;
priv->panel = gdk_window_new (gtk_widget_get_window (widget),
&attributes, attributes_mask);
GtkBorder padding;
gint arrow_size;
gint panel_width;
+ gint req_height;
arrow_size = spin_button_get_arrow_size (spin);
context = gtk_widget_get_style_context (widget);
panel_width = arrow_size + padding.left + padding.right;
gtk_widget_get_preferred_size (widget, &requisition, NULL);
+ req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
gtk_widget_set_allocation (widget, allocation);
panel_allocation.x = allocation->x + allocation->width - panel_width;
panel_allocation.width = panel_width;
- panel_allocation.height = MIN (requisition.height, allocation->height);
+ panel_allocation.height = MIN (req_height, allocation->height);
panel_allocation.y = allocation->y +
- (allocation->height - requisition.height) / 2;
+ (allocation->height - req_height) / 2;
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_allocate (widget, allocation);
gtk_cairo_transform_to_window (cr, widget, priv->panel);
- if (gtk_entry_get_has_frame (GTK_ENTRY (widget)))
- gtk_render_background (context, cr, 0, 0,
- gdk_window_get_width (priv->panel),
- gdk_window_get_height (priv->panel));
-
gtk_spin_button_draw_arrow (spin, context, cr, GTK_ARROW_UP);
gtk_spin_button_draw_arrow (spin, context, cr, GTK_ARROW_DOWN);
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv;
GtkRequisition requisition;
+ gint req_height;
if (event->window == priv->panel)
{
gdk_window_get_device_position (priv->panel, device, &x, &y, NULL);
gtk_widget_get_preferred_size (widget, &requisition, NULL);
+ req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
- if (y <= requisition.height / 2)
+ if (y <= req_height / 2)
priv->in_child = GTK_ARROW_UP;
else
priv->in_child = GTK_ARROW_DOWN;
if (event->window == priv->panel)
{
GtkRequisition requisition;
+ gint req_height;
if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
gtk_spin_button_update (spin);
gtk_widget_get_preferred_size (widget, &requisition, NULL);
+ req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
- if (event->y <= requisition.height / 2)
+ if (event->y <= req_height / 2)
{
if (event->button == 1)
start_spinning (spin, GTK_ARROW_UP, gtk_adjustment_get_step_increment (priv->adjustment));
if (event->button == 3)
{
GtkRequisition requisition;
+ gint req_height;
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
gtk_widget_get_preferred_size (widget, &requisition, NULL);
+ req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
if (event->y >= 0 && event->x >= 0 &&
- event->y <= requisition.height &&
+ event->y <= req_height &&
event->x <= arrow_size + padding.left + padding.right)
{
if (click_child == GTK_ARROW_UP &&
- event->y <= requisition.height / 2)
+ event->y <= req_height / 2)
{
gdouble diff;
gtk_spin_button_real_spin (spin, diff);
}
else if (click_child == GTK_ARROW_DOWN &&
- event->y > requisition.height / 2)
+ event->y > req_height / 2)
{
gdouble diff;
if (event->window == priv->panel)
{
GtkRequisition requisition;
+ gint req_height;
gint y = event->y;
gdk_event_request_motions (event);
gtk_widget_get_preferred_size (widget, &requisition, NULL);
+ req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
- if (y <= requisition.height / 2 &&
+ if (y <= req_height / 2 &&
priv->in_child == GTK_ARROW_DOWN)
{
priv->in_child = GTK_ARROW_UP;
gtk_widget_queue_draw (GTK_WIDGET (spin));
}
- else if (y > requisition.height / 2 &&
+ else if (y > req_height / 2 &&
priv->in_child == GTK_ARROW_UP)
{
priv->in_child = GTK_ARROW_DOWN;