Mercurial > dwindows
comparison gtk/dw.c @ 1669:36a090da4cb1
Initial implementation of dw_box_remove() for GTK2/3 and stub for dw_box_remove_at_index().
Fixed errors in the OS/2 and Windows dw_box_remove_at_index() implementations.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 26 Apr 2012 21:18:37 +0000 |
parents | f2a3b25a9507 |
children | ca5123dc5819 |
comparison
equal
deleted
inserted
replaced
1668:724a7361cb42 | 1669:36a090da4cb1 |
---|---|
10227 | 10227 |
10228 /* Can't pack nothing with GTK, so create an empty label */ | 10228 /* Can't pack nothing with GTK, so create an empty label */ |
10229 if(!item) | 10229 if(!item) |
10230 { | 10230 { |
10231 item = gtk_label_new(""); | 10231 item = gtk_label_new(""); |
10232 gtk_object_set_data(GTK_OBJECT(item), "_dw_padding", GINT_TO_POINTER(1)); | |
10232 gtk_widget_show_all(item); | 10233 gtk_widget_show_all(item); |
10233 } | 10234 } |
10234 | 10235 |
10235 /* Check if the item to be packed is a special box */ | 10236 /* Check if the item to be packed is a special box */ |
10236 tmpitem = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxhandle"); | 10237 tmpitem = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxhandle"); |
10324 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | 10325 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); |
10325 } | 10326 } |
10326 else | 10327 else |
10327 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); | 10328 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); |
10328 } | 10329 } |
10330 /* If we previously incremented the reference count... drop it now that it is packed */ | |
10331 if(gtk_object_get_data(GTK_OBJECT(item), "_dw_refed")) | |
10332 { | |
10333 g_object_unref(G_OBJECT(item)); | |
10334 gtk_object_set_data(GTK_OBJECT(item), "_dw_refed", NULL); | |
10335 } | |
10329 } | 10336 } |
10330 DW_MUTEX_UNLOCK; | 10337 DW_MUTEX_UNLOCK; |
10331 | 10338 |
10332 if(warn) | 10339 if(warn) |
10333 { | 10340 { |
10334 if ( width == 0 && hsize == FALSE ) | 10341 if ( width == 0 && hsize == FALSE ) |
10335 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); | 10342 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); |
10336 if ( height == 0 && vsize == FALSE ) | 10343 if ( height == 0 && vsize == FALSE ) |
10337 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); | 10344 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); |
10338 } | 10345 } |
10346 } | |
10347 | |
10348 /* | |
10349 * Remove windows (widgets) from the box they are packed into. | |
10350 * Parameters: | |
10351 * handle: Window handle of the item to be back. | |
10352 * Returns: | |
10353 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. | |
10354 */ | |
10355 int API dw_box_remove(HWND handle) | |
10356 { | |
10357 int _locked_by_me = FALSE, retcode = DW_ERROR_GENERAL; | |
10358 | |
10359 DW_MUTEX_LOCK; | |
10360 if(GTK_IS_WIDGET(handle)) | |
10361 { | |
10362 GtkWidget *box, *handle2 = handle; | |
10363 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_eventbox"); | |
10364 | |
10365 /* Handle the invisible event box if it exists */ | |
10366 if(eventbox && GTK_IS_WIDGET(eventbox)) | |
10367 handle2 = eventbox; | |
10368 | |
10369 /* Check if we are removing a widget from a box */ | |
10370 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_TABLE(box)) | |
10371 { | |
10372 /* Get the number of items in the box... */ | |
10373 int boxcount = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(box), "_dw_boxcount")); | |
10374 int boxtype = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(box), "_dw_boxtype")); | |
10375 gint pos; | |
10376 | |
10377 gtk_container_child_get(GTK_CONTAINER(box), handle2, boxtype == DW_VERT ? "top-attach" : "left-attach", &pos, NULL); | |
10378 /* If we haven't incremented the reference count... raised it before removal */ | |
10379 if(!gtk_object_get_data(GTK_OBJECT(handle2), "_dw_refed")) | |
10380 { | |
10381 g_object_ref(G_OBJECT(handle2)); | |
10382 gtk_object_set_data(GTK_OBJECT(handle2), "_dw_refed", GINT_TO_POINTER(1)); | |
10383 } | |
10384 gtk_container_remove(GTK_CONTAINER(box), handle2); | |
10385 retcode = DW_ERROR_NONE; | |
10386 | |
10387 /* If we are destroying the last item in the box this isn't necessary */ | |
10388 if((pos+1) < boxcount) | |
10389 { | |
10390 /* If we need to contract the table, reposition all the children */ | |
10391 gtk_container_forall(GTK_CONTAINER(box),_rearrange_table_destroy, GINT_TO_POINTER(boxtype == DW_VERT ? pos : -(pos+1))); | |
10392 } | |
10393 | |
10394 if(boxcount > 0) | |
10395 { | |
10396 /* Decrease the count by 1 */ | |
10397 boxcount--; | |
10398 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount)); | |
10399 } | |
10400 | |
10401 /* If we aren't trying to resize the table to 0... */ | |
10402 if(boxcount > 0) | |
10403 { | |
10404 /* Contract the table to the size we need */ | |
10405 gtk_table_resize(GTK_TABLE(box), boxtype == DW_VERT ? boxcount : 1, boxtype == DW_VERT ? 1 : boxcount); | |
10406 } | |
10407 } | |
10408 } | |
10409 DW_MUTEX_UNLOCK; | |
10410 return retcode; | |
10411 } | |
10412 | |
10413 /* | |
10414 * Remove windows (widgets) from a box at an arbitrary location. | |
10415 * Parameters: | |
10416 * box: Window handle of the box to be removed from. | |
10417 * index: 0 based index of packed items. | |
10418 * Returns: | |
10419 * Handle to the removed item on success, 0 on failure. | |
10420 */ | |
10421 HWND API dw_box_remove_at_index(HWND box, int index) | |
10422 { | |
10423 return 0; | |
10339 } | 10424 } |
10340 | 10425 |
10341 /* | 10426 /* |
10342 * Pack windows (widgets) into a box at an arbitrary location. | 10427 * Pack windows (widgets) into a box at an arbitrary location. |
10343 * Parameters: | 10428 * Parameters: |