* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "gtkprivate.h"
#include "gtkintl.h"
+#include "a11y/gtkarrowaccessible.h"
+
#define MIN_ARROW_SIZE 15
struct _GtkArrowPrivate
GTK_PARAM_READABLE));
g_type_class_add_private (class, sizeof (GtkArrowPrivate));
+
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ARROW_ACCESSIBLE);
}
static void
gint *minimum_size,
gint *natural_size)
{
- gint xpad;
+ GtkBorder border;
- gtk_misc_get_padding (GTK_MISC (widget), &xpad, NULL);
+ _gtk_misc_get_padding_and_border (GTK_MISC (widget), &border);
if (minimum_size)
- *minimum_size = MIN_ARROW_SIZE + xpad * 2;
+ *minimum_size = MIN_ARROW_SIZE + border.left + border.right;
if (natural_size)
- *natural_size = MIN_ARROW_SIZE + xpad * 2;
+ *natural_size = MIN_ARROW_SIZE + border.left + border.right;
}
static void
gint *minimum_size,
gint *natural_size)
{
- gint ypad;
+ GtkBorder border;
- gtk_misc_get_padding (GTK_MISC (widget), NULL, &ypad);
+ _gtk_misc_get_padding_and_border (GTK_MISC (widget), &border);
if (minimum_size)
- *minimum_size = MIN_ARROW_SIZE + ypad * 2;
+ *minimum_size = MIN_ARROW_SIZE + border.top + border.bottom;
if (natural_size)
- *natural_size = MIN_ARROW_SIZE + ypad * 2;
+ *natural_size = MIN_ARROW_SIZE + border.top + border.bottom;
}
-
/**
* gtk_arrow_new:
* @arrow_type: a valid #GtkArrowType.
}
}
-
static gboolean
gtk_arrow_draw (GtkWidget *widget,
cairo_t *cr)
{
GtkArrow *arrow = GTK_ARROW (widget);
GtkArrowPrivate *priv = arrow->priv;
- GtkMisc *misc = GTK_MISC (widget);
GtkStyleContext *context;
- GtkStateFlags state;
- gint x, y, width, height;
+ gdouble x, y;
+ gint width, height;
gint extent;
- gint xpad, ypad;
+ GtkBorder border;
gfloat xalign, yalign;
GtkArrowType effective_arrow_type;
gfloat arrow_scaling;
context = gtk_widget_get_style_context (widget);
gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL);
- gtk_misc_get_padding (misc, &xpad, &ypad);
- gtk_misc_get_alignment (misc, &xalign, &yalign);
+ _gtk_misc_get_padding_and_border (GTK_MISC (widget), &border);
+ gtk_misc_get_alignment (GTK_MISC (widget), &xalign, &yalign);
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_height (widget);
+ width = gtk_widget_get_allocated_width (widget) - border.left - border.right;
+ height = gtk_widget_get_allocated_height (widget) - border.top - border.bottom;
- extent = MIN (width - 2 * xpad, height - 2 * ypad) * arrow_scaling;
+ extent = MIN (width, height) * arrow_scaling;
effective_arrow_type = priv->arrow_type;
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
effective_arrow_type = GTK_ARROW_LEFT;
}
- x = floor (xpad + ((width - extent) * xalign));
- y = floor (ypad + ((height - extent) * yalign));
+ x = border.left + ((width - extent) * xalign);
+ y = border.top + ((height - extent) * yalign);
switch (effective_arrow_type)
{
break;
}
- gtk_style_context_save (context);
-
- state = gtk_widget_get_state_flags (widget);
- gtk_style_context_set_state (context, state);
gtk_render_arrow (context, cr, angle, x, y, extent);
- gtk_style_context_restore (context);
-
return FALSE;
}