Just as I get my problem with screen size fixed, another one creeps in and 
messes with me.

If I create any UI object, a button, a label, whatever, and place it on the 
main window, it automatically scales up to fill the entire window.  The killer 
here is that the objects are ignoring explicit sizing commands 
(gtk_widget_set_usize).

Anyone have any suggestions here?

Here is the test code I am working with.

Thanks!

Ron Gage - Westland, MI


#include <string.h>
#include <gtk/gtk.h>

static void hello (GtkWidget *widget, gpointer data)
{
g_print ("Hello World.\n");
}

static gboolean delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
{
g_print ("delete event occurred.\n");
return TRUE;
}

static void destroy(GtkWidget *widget, gpointer data)
{
gtk_main_quit();
}

GtkWidget *dfblabel(char *text, int pos_x, int pos_y, int size_x, int size_y, 
GdkColor *bg, GdkColor *fg)
{
GtkWidget *label;
label = gtk_label_new (text);
gtk_label_set_line_wrap (GTK_LABEL(label), TRUE);
gtk_widget_set_uposition(GTK_WIDGET(label), pos_x, pos_y);
gtk_widget_set_usize(GTK_WIDGET(label), size_x, size_y);
if (bg != NULL)
  gtk_widget_modify_bg(GTK_WIDGET(label), GTK_STATE_NORMAL, bg);
if (fg != NULL)
  gtk_widget_modify_fg(GTK_WIDGET(label), GTK_STATE_NORMAL, fg);
return label;
}


int main (int argc, char **argv)
{
GtkWidget *window;
GtkWidget *button;
GdkColor black,white,blue;
GtkWidget *label;

gtk_init (&argc, &argv);
gdk_color_parse("Black",&black);
gdk_color_parse("White",&white);
gdk_color_parse("Blue",&blue);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable(GTK_WINDOW(window),TRUE);
gtk_widget_set_size_request(window, 1024,768);
//gtk_window_maximize(GTK_WINDOW(window));
//gtk_window_fullscreen(GTK_WINDOW(window));
g_signal_connect (G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), 
NULL);
g_signal_connect (G_OBJECT(window), "destroy",G_CALLBACK(destroy), NULL);
//gtk_container_set_border_width (GTK_CONTAINER(window),10);
gtk_widget_modify_bg(GTK_WIDGET(window), GTK_STATE_NORMAL, &blue);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_widget_set_usize(GTK_WIDGET(window),1024,768);

label = dfblabel("Test label",4,10,20,100,&black,&white);
button = gtk_button_new_with_label ("Test button");
gtk_widget_set_usize(GTK_WIDGET(button),.01,.02);
//gtk_widget_set_uposition(GTK_WIDGET(button),200,200);
g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(hello), NULL);
g_signal_connect_swapped (G_OBJECT(button), "clicked", 
G_CALLBACK(gtk_widget_destroy), G_OBJECT(window));
//gtk_container_add (GTK_CONTAINER(window),button);
gtk_container_add (GTK_CONTAINER(window),label);
gtk_widget_show_all(window);
gtk_main();
return(0);
}


_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to