Re: problem highlighting



On Fri, 24 Aug 2001 16:45:23 -0400 (EDT), Angelo Jerod Keresztes said:

 in my app, when a user clicks on a pixmap widget, I want it to appear to
 be highlighted.  So I was thinking I would just draw a box around the
 widget.
 
 the pixmap widget is placed inside a vbox which is inside
 gtkscrolledwindow widget.  to place the rectangle, I do something like
 this:
 
       gdk_draw_rectangle( side_vbox->window /*GdkDrawable *drawable*/,
                      side_vbox->style->bg_gc[GTK_STATE_SELECTED],
                      TRUE,                          /*FILL*/
                      GTK_WIDGET(widg)->allocation.x /*X*/,
                      GTK_WIDGET(widg)->allocation.y /*Y*/,
                      highlighted_tile->surface->w+5 /*width*/,
                      highlighted_tile->surface->h+5 /*height*/ );
 
 the rectangle gets drawn, but when I move the scrollbars, any part of the
 rectangle that gets moved off the screen is erased from the window
 altogether.
 
 Im thinking that I shouldnt be drawing to the vbox window, but am unsure
 what I should draw to.

I've done something similar like this, it's called a `primitives
palette' for a program called Vertex.

There was a window with a bunch of selectable icons similar to your
situation, here is how it was done.

Instead of using a scrolled window, I went directly to the GDK
level.

I created GTK scroll bars and a GtkDrawingArea, that was it, from
then on it was on to the GDK level.

I had GdkPixmaps and I used a custom GC with a mask to handle
transparency and another GC, the same but with a different
`function'. The function was set to invert target pixels, this was
for selection (similar to how you see DFM do things (if you ever
used DFM you know what I'm talking about).

So your application will need to check the GtkAdjustments you set
for the scroll bars, so you know which GdkPixmaps you want to draw.

To recap, on the GTK level you just need the scroll bars and
a GtkDrawingArea.

On the GDK level you need GdkPixmaps, just one for each icon, and
two GdkGC's (more if you like) one GC for drawing regular icons and
another for drawing selected ones. Create the selected icon GC with
a GC function of invert.

Also you may want to set the clip mask for each GC if you want to
draw with transparency using those GC's.



-- 
--
Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
.__                          ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe              '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.                "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.             __  7EMMMNNNNNWWWEEEEEEEOO.     " .
NNMMMMWWWMMMWEINMMMNn            "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
                  http://furry.ao.net/~learfox/






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