gdk_draw_* and friends



Digging randomly through the gdk.h include file, I stopped at
gdk_draw_* functions. I noticed the functions:
gdk_draw_point
gdk_draw_points
gdk_draw_line
gdk_draw_lines
gdk_draw_segments
gdk_draw_polygon
.... (others)

and of course:
gdk_draw_rectangle             (*)
gdk_draw_arc                        (*)

Then, I realized than X has more drawing functions...
I issued an "apropos", and XDrawRectangles, XDrawArcs appeared.

Then I thought why shouldn't gdk wrap these two X drawing functions as
well.
If I'm correct, these two functions are used to send the X Server a
bunch of rectangles or arcs, which is a very useful thing because the X
Server may communicate with the clients through a network.

So, wouldn't be nice to add two more functions to gdk?

1) void gdk_draw_rectangles(GdkDrawable  *drawable,
                                                     GdkGC        *gc,
                                                     GdkRectangle
*rectangles,
                                                      gint nrectangles);

where GdkRectangle  is already defined (although used for things like
clipping):

typedef struct _GdkRectangle   GdkRectangle;
struct _GdkRectangle {
gint16 x;
gint16 y;
guint16 width;
guint16 height;
}

(Problem: How do I specify if the rectangles should be filled or not?.
However that should come out of the graphics context GC, shouldn't it?.
Is there a way to change the filling style of a graphics contexts in
GDK?)

2) void gdk_draw_arcs(GdkDrawable  *drawable,
                                           GdkGC              *gc,
                                           GdkArc             *arcs,
                                            gint narcs);

where GdkArc  is defined like: (in gdktypes.h)

typedef struct _GdkArc   GdkArc;
struct _GdkArc {
gint16 x;
gint16 y;
guint16 width;
guint16 height;
gint16 angle1,angle2;            // angle in degrees*64
}

(Problem: The same problem with filled arcs that stated previously).

By the way, if gdk had functions to change the parameters of a graphics
context, then we simply shouldn't need the filled parameter in functions
like gdk_draw_rectangle,gdk_draw_arc. I think that would be a more
elegant approach, because if gdk_draw_rectangle,gdk_draw_arc does have
the filled argument, then gdk_draw_rectangles, gdk_draw_arcs should had
it too, but as you can see with "man XDrawArcs/XDrawRectangles" the
filled parameter is obtained through the graphic context, as it is with
XDrawArc/XDrawRectangle.

Currently I'm using GTK 1.2.3.

Changing the api could break down compatibility, but in the stage that
we're I think the most important is to develop a congruent and elegant
api, so our heads aren't aching in the future...





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]