Re: proposal: gdk_draw_focus_rectangle

Hans Breuer <hans breuer org> writes:

> To give you an impression of what is possible with standard
> GDI functions I've attached a small image. 
> It contains vertical lines with all available linestyles.
> The border is drawn with DrawFocusRect().
Hmmm, this is pretty limiting. But I can't believe that it isn't
possible to draw a 1-pixel dotted line in Win32 at a somewhat
reasonable speed.

(Note that I'm pretty positive that drawing focus rectangles as a 
series of points would be fast enough.)

One possibility, is that for rectangles and 1 pixel horizontal
and vertical lines, if you have a functional stipple implementation,
to draw solid lines with a 2 pixel


Stipple. In fact, we could probably even make gtk_default_draw_focus() do
this at the GTK+ level. (The current drawing under X isn't completely
satisfactory either.)
> >>From gtkstyle.c/gtk_default_draw_focus:
> >
> >  if (detail && !strcmp (detail, "add-mode"))
> >    gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
> >  else
> >    gdk_gc_set_dashes (style->black_gc, 0, "\1\1", 2);
> >
> >[ "add-mode" is basically unused ]
> >
> >So if you have to implement it with:
> >
> > You use the GDI dotted style if it is 4/4
> > You use the GDI "focus" style if it is 1/1
> The "focus" style isn't available for drawing lines with GDI (win9x).
> It is only available from DrawFocusRect(), which can't be (miss-)used
> to draw lines because of it's XOR semantics.
> IMO it would be a really small compromise to wrap the focus
> rectangle drawing into it's own gdk function, but obviously
> it is simplier to put all the burden on the non X backends ...

Suprisingly, I'm not actually out to screw the Win32 backend.

(If we didn't care about Win32, well, we wouldn't have incorporated
into the GTK+ tree, we wouldn't have spent the time to virtualize
GDK, and so forth.)

However, I think your proposal doesn't quite fit into the way
that GTK+/GDK works.

 - GDK is about drawing graphics primitives
 - These primitives should behave (as much as possible) the same on
   all platforms.
 - How widgets are drawn depends is up to the widget implementation
   and theme.

So, either DrawFocus() is deterministic, and your proposal boils
down to adding a:

 "draw a dotted xor'ed rectangle"

primitive to GDK, or you are proposing a drawing call that could
be different on different backends. Neither seems right to me.


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