comparison gtk/dw.c @ 1082:7821a35e1e11

Implemented table rearranging on GTK2 getting dw_box_pack_at_index() working there too.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 28 Jun 2011 06:55:45 +0000
parents 27e9a063fbb5
children 97c221691665
comparison
equal deleted inserted replaced
1081:f9232a52367a 1082:7821a35e1e11
9124 exit(exitcode); 9124 exit(exitcode);
9125 } 9125 }
9126 9126
9127 #define DW_EXPAND (GTK_EXPAND | GTK_SHRINK | GTK_FILL) 9127 #define DW_EXPAND (GTK_EXPAND | GTK_SHRINK | GTK_FILL)
9128 9128
9129 /* Internal function that changes the attachment properties in a table. */
9130 void _rearrange_table(GtkWidget *widget, gpointer data)
9131 {
9132 gint pos = GPOINTER_TO_INT(data);
9133 GtkContainer *cont = gtk_object_get_data(GTK_OBJECT(widget), "_dw_table");
9134 guint oldpos;
9135
9136 /* Drop out if missing table */
9137 if(!cont)
9138 return;
9139
9140 /* Check orientation */
9141 if(pos < 0)
9142 {
9143 /* Horz */
9144 pos = -(pos + 1);
9145 gtk_container_child_get(cont, widget, "left-attach", &oldpos, NULL);
9146 if(oldpos >= pos)
9147 {
9148 gtk_container_child_set(cont, widget, "left-attach", (oldpos + 1), "right-attach", (oldpos+2), NULL);
9149 }
9150 }
9151 else
9152 {
9153 /* Vert */
9154 gtk_container_child_get(cont, widget, "top-attach", &oldpos, NULL);
9155 if(oldpos >= pos)
9156 {
9157 gtk_container_child_set(cont, widget, "top-attach", (oldpos + 1), "bottom-attach", (oldpos+2), NULL);
9158 }
9159 }
9160 }
9161
9129 /* 9162 /*
9130 * Pack windows (widgets) into a box at an arbitrary location. 9163 * Pack windows (widgets) into a box at an arbitrary location.
9131 * Parameters: 9164 * Parameters:
9132 * box: Window handle of the box to be packed into. 9165 * box: Window handle of the box to be packed into.
9133 * item: Window handle of the item to be back. 9166 * item: Window handle of the item to be back.
9237 x = index; 9270 x = index;
9238 y = 0; 9271 y = 0;
9239 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1); 9272 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1);
9240 } 9273 }
9241 9274
9275 gtk_object_set_data(GTK_OBJECT(item), "_dw_table", box);
9276 gtk_container_forall(GTK_CONTAINER(box),_rearrange_table, GINT_TO_POINTER(boxtype == DW_VERT ? index : -(index+1)));
9242 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad); 9277 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad);
9243 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1)); 9278 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1));
9244 gtk_widget_set_usize(item, width, height); 9279 gtk_widget_set_usize(item, width, height);
9245 if(GTK_IS_RADIO_BUTTON(item)) 9280 if(GTK_IS_RADIO_BUTTON(item))
9246 { 9281 {
9247 GSList *group; 9282 GSList *group;
9248 GtkWidget *groupstart = (GtkWidget *)g_object_get_data(G_OBJECT(box), "_dw_group"); 9283 GtkWidget *groupstart = (GtkWidget *)g_object_get_data(G_OBJECT(box), "_dw_group");
9388 if(boxtype == DW_VERT) 9423 if(boxtype == DW_VERT)
9389 gtk_table_resize(GTK_TABLE(box), boxcount + 1, 1); 9424 gtk_table_resize(GTK_TABLE(box), boxcount + 1, 1);
9390 else 9425 else
9391 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1); 9426 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1);
9392 9427
9428 gtk_object_set_data(GTK_OBJECT(item), "_dw_table", box);
9393 gtk_table_attach(GTK_TABLE(box), item, 0, 1, 0, 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad); 9429 gtk_table_attach(GTK_TABLE(box), item, 0, 1, 0, 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad);
9394 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1)); 9430 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1));
9395 gtk_widget_set_usize(item, width, height); 9431 gtk_widget_set_usize(item, width, height);
9396 if(GTK_IS_RADIO_BUTTON(item)) 9432 if(GTK_IS_RADIO_BUTTON(item))
9397 { 9433 {
10867 x = boxcount; 10903 x = boxcount;
10868 y = 0; 10904 y = 0;
10869 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1); 10905 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1);
10870 } 10906 }
10871 10907
10908 gtk_object_set_data(GTK_OBJECT(item), "_dw_table", box);
10872 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad); 10909 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad);
10873 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1)); 10910 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1));
10874 gtk_widget_set_usize(item, width, height); 10911 gtk_widget_set_usize(item, width, height);
10875 if (GTK_IS_RADIO_BUTTON(item)) 10912 if (GTK_IS_RADIO_BUTTON(item))
10876 { 10913 {