Re: Sliders



On Tue, 23 Nov 1999, Ivan Jager wrote:
[on trying to work out how to draw a slider "depressed" during dragging]

> I know it isn't too pretty, but it seems to be the only way (unless
> there is something I don't know --which is very likely) The question is
> what should I check in the widget parameter? or is there another way to
> do it?

Ok, I only really know Gtk 1.2, so this may be about to change, and is 
also coming partly from memory, which is not famous for reliability....

Well, the first bit of bad news is that the widget parameter can be NULL -
this happens if a widget decides to draw itself using gtk_draw_* functions
in gtkstyle.h.  No idea why these functions are needed, since they make
the same calls into the theme engine as the gtk_paint_* variety, which
pass more information. So you need to check for NULL.  If you get it, you
have no idea what widget is calling.  Fortunately, few widgets seem to do
this.

Detecting the correct class after that should probably use:

GTK_IS_RANGE (widget)

or, depending on what exactly you're trying to change:

GTK_IS_SCROLLBAR (widget)

You're now looking at the widget's struct _GtkRange or struct
_GtkScrollbar - see if you can find a useful member that will tell you
what you want (maybe "button"?).  Needless to say, this will break the
instant someone even thinks about changing the range/scrollbar internals.

BTW: Scrollbars and ranges draw the slider in different ways: range calls
the theme "draw_slider" function, and (I think) scrollbar calls 
"draw_box".

> Actually, I am just changing _most_ of the Metal theme. I saw it did
> some wierd stuff that I would need, but when I started I didn't see all
> the problems some of that wierd stuff would cause.

When I took a look at Metal, I was, how shall we say? "Intrigued"?  I
don't think Metal does anything superfluous.  However, the interaction
between Metal (in particular) and other themes (in general) and Gtk is far
from ideal.  Metal seems to be an extreme case.

> The part you just mentioned I had thought I would get rid of untill I
> fould out it keeps the slider from "errasing" the trough. I suspect
> there is a better way of doing it, but I don't know how.

The better way of doing it is to modify the GtkRange code in
gtkrange.c starting from the comment:

Don't redraw if we are only exposing the literal trough region.
this may not work correctly....

The widget code relies on the fact that the part of the trough that needs
to be redrawn is in its own Gdk window, and the server will set the
background colour automatically.  Which works as long as the background
for the trough is blank.  The fix is probably less work than the kludge.

As I said, this may have been fixed in CVS or released 1.3 versions of
Gtk.

-- 
-- Duncan Pierce  (D.R.Pierce@staffs.ac.uk)




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