The button is to big or draws to big
- From: "Karl Schmitt" <karlschmitt1969 googlemail com>
- To: gtk-list gnome org
- Subject: The button is to big or draws to big
- Date: Fri, 17 Oct 2008 18:53:31 +0200
Dear Folks,
I do experiment with GTK+
and ran into an issue for which
I have no explanation.
I do want to create a UseCase button
which shows:
1) a big Title
2) a big Subtitle
3) a Pictogram (300x400 png)
3) a row of tree or more small logos (32x32 png)
everything draws fine but right below the row of logos
the button reserves unnecessary space and a huge
button surface is empty. I expect that the button
is sized to the exact space needed to draw the Title,
Subtitle, Pictogram and the Row of Logos but it reserves
way more space below the logo row:
#include <gtk/gtk.h>
int main( int argc, char *argv[] )
{
GtkWidget * window;
GtkWidget * frame;
GtkWidget * table;
GtkWidget * usecase_button;
GtkWidget * use_case_box;
GtkWidget * use_case_title;
GtkWidget * use_case_subtitle;
GtkWidget * use_case_image;
GtkWidget * info_button;
GtkWidget * info_image;
PangoFontDescription * fd1 = NULL;
PangoFontDescription * fd2 = NULL;
/*------------------------------*/
GtkWidget * logo_line;
GtkWidget * logo1;
GtkWidget * logo2;
GtkWidget * logo3;
/*----------------------------------*/
gtk_init ( &argc, &argv );
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Fraunhofer UseCase Button");
gtk_container_set_border_width (GTK_CONTAINER (window), 30);
/*----------------------------------*/
frame = gtk_frame_new(NULL);
gtk_container_add (GTK_CONTAINER (window), frame);
/*----------------------------------*/
table = gtk_table_new (4, 5, TRUE);
gtk_container_set_border_width (GTK_CONTAINER (table), 5);
gtk_container_add (GTK_CONTAINER (frame), table);
/*----------------------------------*/
use_case_box = gtk_vbox_new(FALSE,0);
/*----------------------------------*/
use_case_title = gtk_label_new("Title");
fd1 = pango_font_description_from_string ("Arial Black 18");
gtk_widget_modify_font ( use_case_title, fd1 );
gtk_box_pack_start( GTK_BOX(use_case_box), use_case_title, FALSE, FALSE, 0);
/*----------------------------------*/
use_case_subtitle = gtk_label_new("Subtitle");
fd2 = pango_font_description_from_string ("Arial 14");
gtk_widget_modify_font ( use_case_subtitle, fd2 );
gtk_box_pack_start( GTK_BOX(use_case_box), use_case_subtitle, FALSE, FALSE, 5);
/*----------------------------------*/
use_case_image = gtk_image_new_from_file("Graphics/pictogram.png");
gtk_box_pack_start( GTK_BOX(use_case_box), use_case_image, FALSE, FALSE, 0);
/*----------------------------------*/
logo_line = gtk_hbox_new(TRUE,0);
gtk_box_pack_start( GTK_BOX(use_case_box), logo_line, FALSE, FALSE, 5);
logo1 = gtk_image_new_from_file("Graphics/logo1.png");
gtk_box_pack_start( GTK_BOX(logo_line), logo1, FALSE, FALSE, 0);
logo2 = gtk_image_new_from_file("Graphics/logo2.png");
gtk_box_pack_start( GTK_BOX(logo_line), logo2, FALSE, FALSE, 0);
logo3 = gtk_image_new_from_file("Graphics/logo3.png");
gtk_box_pack_start( GTK_BOX(logo_line), logo3, FALSE, FALSE, 0);
/*----------------------------------*/
usecase_button = gtk_button_new();
gtk_container_add( GTK_CONTAINER(usecase_button), use_case_box );
gtk_table_attach_defaults (GTK_TABLE (table), usecase_button, 0, 4, 0, 4);
gtk_widget_show(usecase_button);
/*----------------------------------*/
info_button = gtk_button_new();
info_image = gtk_image_new_from_file("Graphics/help-icon.png");
gtk_container_add( GTK_CONTAINER(info_button) , info_image);
gtk_table_attach (GTK_TABLE (table), info_button, 4, 5, 3, 4, GTK_EXPAND, GTK_EXPAND, 10, 0);
/*----------------------------------*/
g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]