API: remove gdk_draw_arc()

This commit is contained in:
Benjamin Otte 2010-07-14 14:07:21 +02:00
parent 9b713fa4fd
commit 559ae63f01
13 changed files with 8 additions and 408 deletions

View File

@ -341,7 +341,6 @@ gdk_draw_lines
gdk_draw_segments
GdkSegment
gdk_draw_rectangle
gdk_draw_arc
gdk_draw_polygon
gdk_draw_trapezoids
GdkTrapezoid

View File

@ -208,21 +208,6 @@ function.
@height:
<!-- ##### FUNCTION gdk_draw_arc ##### -->
<para>
</para>
@drawable:
@gc:
@filled:
@x:
@y:
@width:
@height:
@angle1:
@angle2:
<!-- ##### FUNCTION gdk_draw_polygon ##### -->
<para>
</para>

View File

@ -55,11 +55,14 @@ that drawing is implicitly clipped to the exposed area.
gboolean
expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
gdk_draw_arc (widget->window,
widget->style->fg_gc[gtk_widget_get_state (widget)],
TRUE,
0, 0, widget->allocation.width, widget->allocation.height,
0, 64 * 360);
cairo_t *cr;
cr = gdk_cairo_create (event->window);
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
cairo_paint (cr);
cairo_destroy (cr);
return TRUE;
}

View File

@ -553,20 +553,6 @@ gdk_directfb_draw_rectangle (GdkDrawable *drawable,
}
}
static void
gdk_directfb_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
D_UNIMPLEMENTED();
}
static void
gdk_directfb_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
@ -987,7 +973,6 @@ gdk_drawable_impl_directfb_class_init (GdkDrawableImplDirectFBClass *klass)
drawable_class->create_gc = _gdk_directfb_gc_new;
drawable_class->draw_rectangle = gdk_directfb_draw_rectangle;
drawable_class->draw_arc = gdk_directfb_draw_arc;
drawable_class->draw_polygon = gdk_directfb_draw_polygon;
drawable_class->draw_drawable = gdk_directfb_draw_drawable;
drawable_class->draw_points = gdk_directfb_draw_points;

View File

@ -549,7 +549,6 @@ gdk_drawable_get_type G_GNUC_CONST
gdk_drawable_get_visible_region
gdk_drawable_get_visual
gdk_drawable_set_colormap
gdk_draw_arc
gdk_draw_drawable
gdk_draw_glyphs
gdk_draw_glyphs_transformed

View File

@ -323,55 +323,6 @@ gdk_draw_rectangle (GdkDrawable *drawable,
width, height);
}
/**
* gdk_draw_arc:
* @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
* @gc: a #GdkGC.
* @filled: %TRUE if the arc should be filled, producing a 'pie slice'.
* @x: the x coordinate of the left edge of the bounding rectangle.
* @y: the y coordinate of the top edge of the bounding rectangle.
* @width: the width of the bounding rectangle.
* @height: the height of the bounding rectangle.
* @angle1: the start angle of the arc, relative to the 3 o'clock position,
* counter-clockwise, in 1/64ths of a degree.
* @angle2: the end angle of the arc, relative to @angle1, in 1/64ths
* of a degree.
*
* Draws an arc or a filled 'pie slice'. The arc is defined by the bounding
* rectangle of the entire ellipse, and the start and end angles of the part
* of the ellipse to be drawn.
**/
void
gdk_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
g_return_if_fail (GDK_IS_GC (gc));
if (width < 0 || height < 0)
{
gint real_width;
gint real_height;
gdk_drawable_get_size (drawable, &real_width, &real_height);
if (width < 0)
width = real_width;
if (height < 0)
height = real_height;
}
GDK_DRAWABLE_GET_CLASS (drawable)->draw_arc (drawable, gc, filled,
x, y, width, height, angle1, angle2);
}
/**
* gdk_draw_polygon:
* @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).

View File

@ -68,15 +68,6 @@ struct _GdkDrawableClass
gint y,
gint width,
gint height);
void (*draw_arc) (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2);
void (*draw_polygon) (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
@ -218,15 +209,6 @@ void gdk_draw_rectangle (GdkDrawable *drawable,
gint y,
gint width,
gint height);
void gdk_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2);
void gdk_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,

View File

@ -323,32 +323,6 @@ gdk_offscreen_window_draw_rectangle (GdkDrawable *drawable,
}
static void
gdk_offscreen_window_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (drawable);
GdkDrawable *real_drawable = get_real_drawable (offscreen);
gdk_draw_arc (real_drawable,
gc,
filled,
x,
y,
width,
height,
angle1,
angle2);
add_damage (offscreen, x, y, width, height, !filled);
}
static void
gdk_offscreen_window_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
@ -1109,7 +1083,6 @@ gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass)
drawable_class->get_composite_drawable = gdk_offscreen_window_get_composite_drawable;
drawable_class->draw_rectangle = gdk_offscreen_window_draw_rectangle;
drawable_class->draw_arc = gdk_offscreen_window_draw_arc;
drawable_class->draw_polygon = gdk_offscreen_window_draw_polygon;
drawable_class->draw_drawable_with_src = gdk_offscreen_window_draw_drawable;
drawable_class->draw_points = gdk_offscreen_window_draw_points;

View File

@ -41,15 +41,6 @@ static void gdk_pixmap_draw_rectangle (GdkDrawable *drawable,
gint y,
gint width,
gint height);
static void gdk_pixmap_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2);
static void gdk_pixmap_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
@ -155,7 +146,6 @@ gdk_pixmap_class_init (GdkPixmapObjectClass *klass)
drawable_class->create_gc = gdk_pixmap_create_gc;
drawable_class->draw_rectangle = gdk_pixmap_draw_rectangle;
drawable_class->draw_arc = gdk_pixmap_draw_arc;
drawable_class->draw_polygon = gdk_pixmap_draw_polygon;
drawable_class->draw_drawable_with_src = gdk_pixmap_draw_drawable;
drawable_class->draw_points = gdk_pixmap_draw_points;
@ -258,25 +248,6 @@ gdk_pixmap_draw_rectangle (GdkDrawable *drawable,
x, y, width, height);
}
static void
gdk_pixmap_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
GdkPixmapObject *private = (GdkPixmapObject *)drawable;
_gdk_gc_remove_drawable_clip (gc);
gdk_draw_arc (private->impl, gc, filled,
x, y,
width, height, angle1, angle2);
}
static void
gdk_pixmap_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,

View File

@ -236,15 +236,6 @@ static void gdk_window_draw_rectangle (GdkDrawable *drawable,
gint y,
gint width,
gint height);
static void gdk_window_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2);
static void gdk_window_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
@ -470,7 +461,6 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
drawable_class->create_gc = gdk_window_create_gc;
drawable_class->draw_rectangle = gdk_window_draw_rectangle;
drawable_class->draw_arc = gdk_window_draw_arc;
drawable_class->draw_polygon = gdk_window_draw_polygon;
drawable_class->draw_drawable_with_src = gdk_window_draw_drawable;
drawable_class->draw_points = gdk_window_draw_points;
@ -3969,27 +3959,6 @@ gdk_window_draw_rectangle (GdkDrawable *drawable,
END_DRAW;
}
static void
gdk_window_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
if (GDK_WINDOW_DESTROYED (drawable))
return;
BEGIN_DRAW;
gdk_draw_arc (impl, gc, filled,
x - x_offset, y - y_offset,
width, height, angle1, angle2);
END_DRAW;
}
static void
gdk_window_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,

View File

@ -184,80 +184,6 @@ gdk_quartz_draw_rectangle (GdkDrawable *drawable,
gdk_quartz_drawable_release_context (drawable, context);
}
static void
gdk_quartz_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
float start_angle, end_angle;
gboolean clockwise = FALSE;
if (!context)
return;
_gdk_quartz_gc_update_cg_context (gc, drawable, context,
filled ?
GDK_QUARTZ_CONTEXT_FILL :
GDK_QUARTZ_CONTEXT_STROKE);
start_angle = angle1 * 2.0 * G_PI / 360.0 / 64.0;
end_angle = start_angle + angle2 * 2.0 * G_PI / 360.0 / 64.0;
/* angle2 is relative to angle1 and can be negative, which switches
* the drawing direction
*/
if (angle2 < 0)
clockwise = TRUE;
/* below, flip the coordinate system back to its original y-diretion
* so the angles passed to CGContextAddArc() are interpreted as
* expected
*
* FIXME: the implementation below works only for perfect circles
* (width == height). Any other aspect ratio either scales the
* line width unevenly or scales away the path entirely for very
* small line widths (esp. for line_width == 0, which is a hair
* line on X11 but must be approximated with the thinnest possible
* line on quartz).
*/
if (filled)
{
CGContextTranslateCTM (context,
x + width / 2.0,
y + height / 2.0);
CGContextScaleCTM (context, 1.0, - (double)height / (double)width);
CGContextMoveToPoint (context, 0, 0);
CGContextAddArc (context, 0, 0, width / 2.0,
start_angle, end_angle,
clockwise);
CGContextClosePath (context);
CGContextFillPath (context);
}
else
{
CGContextTranslateCTM (context,
x + width / 2.0 + 0.5,
y + height / 2.0 + 0.5);
CGContextScaleCTM (context, 1.0, - (double)height / (double)width);
CGContextAddArc (context, 0, 0, width / 2.0,
start_angle, end_angle,
clockwise);
CGContextStrokePath (context);
}
gdk_quartz_drawable_release_context (drawable, context);
}
static void
gdk_quartz_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
@ -529,7 +455,6 @@ gdk_drawable_impl_quartz_class_init (GdkDrawableImplQuartzClass *klass)
drawable_class->create_gc = _gdk_quartz_gc_new;
drawable_class->draw_rectangle = gdk_quartz_draw_rectangle;
drawable_class->draw_arc = gdk_quartz_draw_arc;
drawable_class->draw_polygon = gdk_quartz_draw_polygon;
drawable_class->draw_drawable_with_src = gdk_quartz_draw_drawable;
drawable_class->draw_points = gdk_quartz_draw_points;

View File

@ -55,15 +55,6 @@ static void gdk_win32_draw_rectangle (GdkDrawable *drawable,
gint y,
gint width,
gint height);
static void gdk_win32_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2);
static void gdk_win32_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
@ -122,7 +113,6 @@ _gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass)
drawable_class->create_gc = _gdk_win32_gc_new;
drawable_class->draw_rectangle = gdk_win32_draw_rectangle;
drawable_class->draw_arc = gdk_win32_draw_arc;
drawable_class->draw_polygon = gdk_win32_draw_polygon;
drawable_class->draw_drawable_with_src = gdk_win32_draw_drawable;
drawable_class->draw_points = gdk_win32_draw_points;
@ -782,104 +772,6 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable,
cairo_region_destroy (region);
}
static void
draw_arc (GdkGCWin32 *gcwin32,
HDC hdc,
gint x_offset,
gint y_offset,
va_list args)
{
HGDIOBJ old_pen;
gboolean filled;
gint x, y;
gint width, height;
gint angle1, angle2;
int nXStartArc, nYStartArc, nXEndArc, nYEndArc;
filled = va_arg (args, gboolean);
x = va_arg (args, gint);
y = va_arg (args, gint);
width = va_arg (args, gint);
height = va_arg (args, gint);
angle1 = va_arg (args, gint);
angle2 = va_arg (args, gint);
x -= x_offset;
y -= y_offset;
if (angle2 >= 360*64)
{
nXStartArc = nYStartArc = nXEndArc = nYEndArc = 0;
}
else if (angle2 > 0)
{
nXStartArc = x + width/2 + width * cos(angle1/64.*2.*G_PI/360.);
nYStartArc = y + height/2 + -height * sin(angle1/64.*2.*G_PI/360.);
nXEndArc = x + width/2 + width * cos((angle1+angle2)/64.*2.*G_PI/360.);
nYEndArc = y + height/2 + -height * sin((angle1+angle2)/64.*2.*G_PI/360.);
}
else
{
nXEndArc = x + width/2 + width * cos(angle1/64.*2.*G_PI/360.);
nYEndArc = y + height/2 + -height * sin(angle1/64.*2.*G_PI/360.);
nXStartArc = x + width/2 + width * cos((angle1+angle2)/64.*2.*G_PI/360.);
nYStartArc = y + height/2 + -height * sin((angle1+angle2)/64.*2.*G_PI/360.);
}
if (filled)
{
old_pen = SelectObject (hdc, GetStockObject (NULL_PEN));
GDK_NOTE (DRAW, g_print ("... Pie(%p,%d,%d,%d,%d,%d,%d,%d,%d)\n",
hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc));
GDI_CALL (Pie, (hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc));
GDI_CALL (SelectObject, (hdc, old_pen));
}
else
{
GDK_NOTE (DRAW, g_print ("... Arc(%p,%d,%d,%d,%d,%d,%d,%d,%d)\n",
hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc));
GDI_CALL (Arc, (hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc));
}
}
static void
gdk_win32_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
GdkRectangle bounds;
cairo_region_t *region;
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_arc: %s %d,%d,%d,%d %d %d\n",
_gdk_win32_drawable_description (drawable),
x, y, width, height, angle1, angle2));
if (width <= 2 || height <= 2 || angle2 == 0)
return;
bounds.x = x;
bounds.y = y;
bounds.width = width;
bounds.height = height;
region = widen_bounds (&bounds, GDK_GC_WIN32 (gc)->pen_width);
generic_draw (drawable, gc,
GDK_GC_FOREGROUND | (filled ? 0 : LINE_ATTRIBUTES),
draw_arc, region, filled, x, y, width, height, angle1, angle2);
cairo_region_destroy (region);
}
static void
draw_polygon (GdkGCWin32 *gcwin32,
HDC hdc,

View File

@ -55,15 +55,6 @@ static void gdk_x11_draw_rectangle (GdkDrawable *drawable,
gint y,
gint width,
gint height);
static void gdk_x11_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2);
static void gdk_x11_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
@ -118,7 +109,6 @@ _gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass)
drawable_class->create_gc = _gdk_x11_gc_new;
drawable_class->draw_rectangle = gdk_x11_draw_rectangle;
drawable_class->draw_arc = gdk_x11_draw_arc;
drawable_class->draw_polygon = gdk_x11_draw_polygon;
drawable_class->draw_drawable_with_src = gdk_x11_draw_drawable;
drawable_class->draw_points = gdk_x11_draw_points;
@ -340,30 +330,6 @@ gdk_x11_draw_rectangle (GdkDrawable *drawable,
GDK_GC_GET_XGC (gc), x, y, width, height);
}
static void
gdk_x11_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
GdkDrawableImplX11 *impl;
impl = GDK_DRAWABLE_IMPL_X11 (drawable);
if (filled)
XFillArc (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,
GDK_GC_GET_XGC (gc), x, y, width, height, angle1, angle2);
else
XDrawArc (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,
GDK_GC_GET_XGC (gc), x, y, width, height, angle1, angle2);
}
static void
gdk_x11_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,