Re: ImageButton



On Mon, Feb 2, 2009 at 5:39 PM,  <jcupitt gmail com> wrote:
> 2009/2/2 Steffen Toksvig <s toksvig gmail com>:
>> What is the best way to make an 'owner drawn' button that draws
>> different images depending on  the state of the button.
>> The button would draw only the relevant image, possibly scaled if the
>> button has a different size compared to the image and a label. But it
>> should not draw any of the normal button graphics.

If your needs are standard enough (I'm dont think you can get scaling
except for some default useful sizes) then you can use GtkIconFactory;
install different sources for different button states/sizes, and assign the
button the stock id you created in your factory, I think this is
probably easiest.

Note that you will also be able to do this without code using
GtkBuilder and Glade in GNOME 2.26.

Cheers,
            -Tristan

>
> Just make a regular button and turn off the relief decoration and the border:
>
>        gtk_button_set_relief( GTK_BUTTON( but ), GTK_RELIEF_NONE );
>        gtk_container_set_border_width( GTK_CONTAINER( but ), 0 );
>
> No doubt you could do this with a style file too.
>
> Put a GtkImage inside the button and change the graphic to whatever
> you want, whenever you want.
>
> You'll still get the mouseover and press effects, but they're rather
> useful, I think.
>
> John
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>


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