Re: Borderless buttons
- From: Todd Fisher <taf2 lehigh edu>
- To: Lars Clausen <lc statsbiblioteket dk>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Borderless buttons
- Date: Wed, 26 May 2004 10:54:55 -0400
Hi Lars!
I think you might find it easiest to use the pixmap theme engine to
create image buttons. By doing
something like the following:
style "checkradiobutton"
{
engine "pixmap" {
# Check marks
image
{
function = CHECK
recolorable = TRUE
shadow = OUT
overlay_file = "checkbutton/basic/3d_all_normal.png"
overlay_stretch = FALSE
}
image
{
function = CHECK
recolorable = TRUE
shadow = IN
overlay_file = "checkbutton/basic/check2.png"
overlay_stretch = FALSE
}
# Option marks
image
{
function = OPTION
recolorable = TRUE
shadow = OUT
overlay_file = "checkbutton/basic/3d_all_normal.png"
overlay_border = { 0,0,0,0 }
overlay_stretch = FALSE
}
image
{
function = OPTION
recolorable = TRUE
shadow = IN
overlay_file = "checkbutton/basic/radio2.png"
overlay_border = { 0,0,0,0 }
overlay_stretch = FALSE
}
image
{
function = FLAT_BOX
recolorable = TRUE
file = "checkbutton/basic/blank.png"
border = { 2, 2, 2, 2 }
stretch = TRUE
}
}
}
widget "*.orange_button*" style "checkradiobutton"
you can make just about any widget look however you like in this way...
Thing to keep in mind is that the widgets you apply this too will not be
themable outside your application.
hope this helps :)
-todd
Lars Clausen wrote:
Hi!
I'm trying to turn some image-based togglebuttons in Dia into cleaner
code. Previously, they've just been GtkDrawingAreas with event
handling, but I'd like them to be proper ToggleButtons that change the
image according to state. While I have the image handling in there, I
can't seem to get the six-pixel (or so) border away, making the buttons
look much clunkier than before. Is there a way to get rid of all
borders? Googling shows me some patches back in '99, but they don't
seem to have made it into Gtk.
Here's the code I use to create a togglebutton with images
(dia_get_image_from_file is just a utility function to make a GtkImage
from an installed image file):
dia_toggle_button_new_with_images(gchar *on_image, gchar *off_image)
{
GtkWidget *button = gtk_toggle_button_new();
struct image_pair *images = g_new0(struct image_pair, 1);
images->on = dia_get_image_from_file(on_image);
g_object_ref(images->on);
gtk_misc_set_padding(GTK_MISC(images->on), 0, 0);
gtk_widget_show(images->on);
images->off = dia_get_image_from_file(off_image);
g_object_ref(images->off);
gtk_misc_set_padding(GTK_MISC(images->off), 0, 0);
gtk_widget_show(images->off);
gtk_container_add(GTK_CONTAINER(button), images->off);
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
/* Don't want to force everybody into 2.4 just for this */
/* gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE);*/
gtk_container_set_border_width(GTK_CONTAINER(button), 0);
g_signal_connect(G_OBJECT(button), "toggled",
dia_toggle_button_swap_images, images);
g_signal_connect(G_OBJECT(button), "destroy",
dia_toggle_button_destroy, images);
return button;
}
Thanks,
-Lars
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]