+typedef enum _ticks { ACRE_TICKS_X, ACRE_TICKS_Y } acre_ticks_t;
+
+static void
+_draw_ticks (acre_t *acre,
+ double axis_min, double axis_max,
+ acre_ticks_t ticks)
+{
+ cairo_t *cr = acre->cr;
+ double t, step, sub_step;
+ int minor_divisions;
+
+ cairo_save (cr);
+
+ _set_transform_to_data_space (acre);
+
+ step = _step_for_range (axis_max - axis_min, &minor_divisions);
+ sub_step = step / minor_divisions;
+
+ for (t = (floor (axis_min / sub_step) + 1) * sub_step;
+ t <= axis_max;
+ t += sub_step)
+ {
+ int tick_size;
+ if (fabs((t / step) - (int) (t / step)) < 0.5 * (sub_step / step))
+ tick_size = ACRE_TICK_MAJOR_SIZE;
+ else
+ tick_size = ACRE_TICK_MINOR_SIZE;
+
+ /* tick */
+ cairo_save (cr);
+ {
+ if (ticks == ACRE_TICKS_X)
+ cairo_move_to (cr, t, acre->y_axis.min);
+ else
+ cairo_move_to (cr, acre->x_axis.min, t);
+
+ cairo_identity_matrix (cr);
+
+ if (ticks == ACRE_TICKS_X) {
+ cairo_rel_line_to (cr, 0, 0.5);
+ cairo_rel_line_to (cr, 0, -tick_size - 0.5);
+ } else {
+ cairo_rel_line_to (cr, -0.5, 0);
+ cairo_rel_line_to (cr, tick_size + 0.5, 0);
+ }
+
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke (cr);
+ }
+ cairo_restore (cr);
+
+ /* label */
+ if (tick_size == ACRE_TICK_MAJOR_SIZE)
+ {
+ PangoLayout *layout;
+ int width, height;
+
+ cairo_save (cr);
+
+ layout = _create_layout_printf (acre, "%g", t);
+
+ if (ticks == ACRE_TICKS_X)
+ cairo_move_to (cr, t, acre->y_axis.min);
+ else
+ cairo_move_to (cr, acre->x_axis.min, t);
+
+ cairo_identity_matrix (cr);
+ pango_layout_get_pixel_size (layout, &width, &height);
+
+ if (ticks == ACRE_TICKS_X)
+ cairo_rel_move_to (cr, -width / 2, ACRE_X_TICK_VALUE_PAD);
+ else
+ cairo_rel_move_to (cr, -width - ACRE_Y_TICK_VALUE_PAD,
+ -height/2);
+
+ _show_layout (cr, layout);
+
+ cairo_restore (cr);
+ }
+ }
+
+ cairo_restore (cr);
+}
+