Mercurial > dwindows
comparison gtk/dw.c @ 1451:95ca625b8ffc
Removed GtkVbox and associated code from top-level windows on GTK.
Replaced it with a with a GtkTable based vertical box.
More than one item can be packed into the top-level window on GTK.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 14 Dec 2011 05:11:57 +0000 |
parents | fbaec6e5df63 |
children | dbe16031ffb4 |
comparison
equal
deleted
inserted
replaced
1450:145edf67013e | 1451:95ca625b8ffc |
---|---|
3402 gtk_mdi_put(GTK_MDI(hwndOwner), tmp, 100, 75, label); | 3402 gtk_mdi_put(GTK_MDI(hwndOwner), tmp, 100, 75, label); |
3403 } | 3403 } |
3404 else | 3404 else |
3405 #endif | 3405 #endif |
3406 { | 3406 { |
3407 GtkWidget *box = dw_box_new(DW_VERT, 0); | |
3408 | |
3407 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 3409 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
3408 | 3410 |
3409 gtk_window_set_title(GTK_WINDOW(tmp), title); | 3411 gtk_window_set_title(GTK_WINDOW(tmp), title); |
3410 if(!(flStyle & DW_FCF_SIZEBORDER)) | 3412 if(!(flStyle & DW_FCF_SIZEBORDER)) |
3411 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE); | 3413 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE); |
3449 if(hwndOwner) | 3451 if(hwndOwner) |
3450 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0); | 3452 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0); |
3451 | 3453 |
3452 if(flStyle & DW_FCF_SIZEBORDER) | 3454 if(flStyle & DW_FCF_SIZEBORDER) |
3453 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_size", GINT_TO_POINTER(1)); | 3455 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_size", GINT_TO_POINTER(1)); |
3456 | |
3457 gtk_container_add(GTK_CONTAINER(tmp), box); | |
3458 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxhandle", (gpointer)box); | |
3454 } | 3459 } |
3455 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_style", GINT_TO_POINTER(flStyle)); | 3460 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_style", GINT_TO_POINTER(flStyle)); |
3456 DW_MUTEX_UNLOCK; | 3461 DW_MUTEX_UNLOCK; |
3457 return tmp; | 3462 return tmp; |
3458 } | 3463 } |
3697 * If there is no box already packed into the "location", the menu will not appear | 3702 * If there is no box already packed into the "location", the menu will not appear |
3698 * so tell the user. | 3703 * so tell the user. |
3699 */ | 3704 */ |
3700 HMENUI dw_menubar_new(HWND location) | 3705 HMENUI dw_menubar_new(HWND location) |
3701 { | 3706 { |
3707 int _locked_by_me = FALSE; | |
3708 GtkAccelGroup *accel_group; | |
3702 GtkWidget *box; | 3709 GtkWidget *box; |
3703 int _locked_by_me = FALSE; | 3710 HMENUI tmp = 0; |
3704 GtkAccelGroup *accel_group; | 3711 |
3705 HMENUI tmp; | 3712 DW_MUTEX_LOCK; |
3706 | 3713 if(GTK_IS_WINDOW(location) && |
3707 DW_MUTEX_LOCK; | 3714 (box = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(location), "_dw_boxhandle"))) |
3708 tmp = gtk_menu_bar_new(); | 3715 { |
3709 box = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(location)); | 3716 /* If there is an existing menu bar, remove it */ |
3710 gtk_widget_show(tmp); | 3717 GtkWidget *oldmenu = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(location), "_dw_menubar"); |
3711 accel_group = gtk_accel_group_new(); | 3718 if(oldmenu) |
3712 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group); | 3719 gtk_widget_destroy(oldmenu); |
3713 | 3720 /* Create a new menu bar */ |
3714 if (box) | 3721 tmp = gtk_menu_bar_new(); |
3715 gtk_box_pack_end(GTK_BOX(box), tmp, FALSE, FALSE, 0); | 3722 gtk_widget_show(tmp); |
3716 else | 3723 accel_group = gtk_accel_group_new(); |
3717 fprintf(stderr,"dw_menubar_new(): Coding error: You MUST pack a box into the window in which this menubar is to be added BEFORE calling this function.\n"); | 3724 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group); |
3718 | 3725 gtk_object_set_data(GTK_OBJECT(location), "_dw_menubar", (gpointer)tmp); |
3726 dw_box_pack_end(box, (HWND)tmp, -1, -1, TRUE, FALSE, 0); | |
3727 | |
3728 } | |
3719 DW_MUTEX_UNLOCK; | 3729 DW_MUTEX_UNLOCK; |
3720 return tmp; | 3730 return tmp; |
3721 } | 3731 } |
3722 | 3732 |
3723 /* | 3733 /* |
9920 return; | 9930 return; |
9921 } | 9931 } |
9922 | 9932 |
9923 DW_MUTEX_LOCK; | 9933 DW_MUTEX_LOCK; |
9924 | 9934 |
9935 /* If this is a special box, like: Window, Groupbox, Scrollbox... | |
9936 * get the internal box handle. | |
9937 */ | |
9925 if((tmp = gtk_object_get_data(GTK_OBJECT(box), "_dw_boxhandle"))) | 9938 if((tmp = gtk_object_get_data(GTK_OBJECT(box), "_dw_boxhandle"))) |
9926 box = tmp; | 9939 box = tmp; |
9927 | 9940 |
9941 /* Can't pack nothing with GTK, so create an empty label */ | |
9928 if(!item) | 9942 if(!item) |
9929 { | 9943 { |
9930 item = gtk_label_new(""); | 9944 item = gtk_label_new(""); |
9931 gtk_widget_show_all(item); | 9945 gtk_widget_show_all(item); |
9932 } | 9946 } |
9933 | 9947 |
9948 /* Check if the item to be packed is a special box */ | |
9934 tmpitem = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxhandle"); | 9949 tmpitem = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxhandle"); |
9935 | 9950 |
9951 /* Make sure our target box is valid */ | |
9936 if(GTK_IS_TABLE(box)) | 9952 if(GTK_IS_TABLE(box)) |
9937 { | 9953 { |
9938 int boxcount = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(box), "_dw_boxcount")); | 9954 int boxcount = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(box), "_dw_boxcount")); |
9939 int boxtype = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(box), "_dw_boxtype")); | 9955 int boxtype = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(box), "_dw_boxtype")); |
9940 int x, y; | 9956 int x, y; |
10003 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | 10019 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); |
10004 } | 10020 } |
10005 else | 10021 else |
10006 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); | 10022 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); |
10007 } | 10023 } |
10008 } | |
10009 else | |
10010 { | |
10011 GtkWidget *vbox = gtk_object_get_data(GTK_OBJECT(box), "_dw_vbox"); | |
10012 | |
10013 if(!vbox) | |
10014 { | |
10015 vbox = gtk_vbox_new(FALSE, 0); | |
10016 gtk_object_set_data(GTK_OBJECT(box), "_dw_vbox", vbox); | |
10017 gtk_container_add(GTK_CONTAINER(box), vbox); | |
10018 gtk_widget_show(vbox); | |
10019 } | |
10020 | |
10021 gtk_container_set_border_width(GTK_CONTAINER(box), pad); | |
10022 | |
10023 if(GTK_IS_TABLE(item) || (tmpitem && GTK_IS_TABLE(tmpitem))) | |
10024 { | |
10025 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_eventbox"); | |
10026 | |
10027 /* NOTE: I left in the ability to pack boxes with a size, | |
10028 * this eliminates that by forcing the size to 0. | |
10029 */ | |
10030 height = width = 0; | |
10031 | |
10032 if(eventbox) | |
10033 { | |
10034 int boxpad = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(item), "_dw_boxpad")); | |
10035 gtk_container_add(GTK_CONTAINER(eventbox), item); | |
10036 gtk_container_set_border_width(GTK_CONTAINER(eventbox), boxpad); | |
10037 item = eventbox; | |
10038 } | |
10039 } | |
10040 else | |
10041 { | |
10042 /* Only show warning if item is not a box */ | |
10043 warn = TRUE; | |
10044 } | |
10045 | |
10046 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); | |
10047 | |
10048 gtk_widget_set_usize(item, width, height); | |
10049 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
10050 } | 10024 } |
10051 DW_MUTEX_UNLOCK; | 10025 DW_MUTEX_UNLOCK; |
10052 | 10026 |
10053 if(warn) | 10027 if(warn) |
10054 { | 10028 { |