Mercurial > dwindows
comparison gtk3/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 | 01f59ba51e7f |
children | 923af93e4084 |
comparison
equal
deleted
inserted
replaced
1668:724a7361cb42 | 1669:36a090da4cb1 |
---|---|
8471 | 8471 |
8472 /* Can't pack nothing with GTK, so create an empty label */ | 8472 /* Can't pack nothing with GTK, so create an empty label */ |
8473 if(!item) | 8473 if(!item) |
8474 { | 8474 { |
8475 item = gtk_label_new(""); | 8475 item = gtk_label_new(""); |
8476 g_object_set_data(G_OBJECT(item), "_dw_padding", GINT_TO_POINTER(1)); | |
8476 gtk_widget_show_all(item); | 8477 gtk_widget_show_all(item); |
8477 } | 8478 } |
8478 /* Due to GTK3 minimum size limitations, if we are packing a widget | 8479 /* Due to GTK3 minimum size limitations, if we are packing a widget |
8479 * with an image, we need to scale the image down to fit the packed size. | 8480 * with an image, we need to scale the image down to fit the packed size. |
8480 */ | 8481 */ |
8624 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | 8625 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); |
8625 } | 8626 } |
8626 else | 8627 else |
8627 g_object_set_data(G_OBJECT(box), "_dw_group", (gpointer)item); | 8628 g_object_set_data(G_OBJECT(box), "_dw_group", (gpointer)item); |
8628 } | 8629 } |
8630 /* If we previously incremented the reference count... drop it now that it is packed */ | |
8631 if(g_object_get_data(G_OBJECT(item), "_dw_refed")) | |
8632 { | |
8633 g_object_unref(G_OBJECT(item)); | |
8634 g_object_set_data(G_OBJECT(item), "_dw_refed", NULL); | |
8635 } | |
8629 } | 8636 } |
8630 DW_MUTEX_UNLOCK; | 8637 DW_MUTEX_UNLOCK; |
8631 | 8638 |
8632 if(warn) | 8639 if(warn) |
8633 { | 8640 { |
8634 if ( width == 0 && hsize == FALSE ) | 8641 if ( width == 0 && hsize == FALSE ) |
8635 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); | 8642 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); |
8636 if ( height == 0 && vsize == FALSE ) | 8643 if ( height == 0 && vsize == FALSE ) |
8637 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); | 8644 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); |
8638 } | 8645 } |
8646 } | |
8647 | |
8648 /* | |
8649 * Remove windows (widgets) from the box they are packed into. | |
8650 * Parameters: | |
8651 * handle: Window handle of the item to be back. | |
8652 * Returns: | |
8653 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. | |
8654 */ | |
8655 int API dw_box_remove(HWND handle) | |
8656 { | |
8657 int _locked_by_me = FALSE, retcode = DW_ERROR_GENERAL; | |
8658 | |
8659 DW_MUTEX_LOCK; | |
8660 if(GTK_IS_WIDGET(handle)) | |
8661 { | |
8662 GtkWidget *box, *handle2 = handle; | |
8663 GtkWidget *eventbox = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_eventbox"); | |
8664 | |
8665 /* Handle the invisible event box if it exists */ | |
8666 if(eventbox && GTK_IS_WIDGET(eventbox)) | |
8667 handle2 = eventbox; | |
8668 | |
8669 /* Check if we are removing a widget from a box */ | |
8670 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box)) | |
8671 { | |
8672 /* Get the number of items in the box... */ | |
8673 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); | |
8674 | |
8675 if(boxcount > 0) | |
8676 { | |
8677 /* Decrease the count by 1 */ | |
8678 boxcount--; | |
8679 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount)); | |
8680 } | |
8681 /* If we haven't incremented the reference count... raise it before removal */ | |
8682 if(!g_object_get_data(G_OBJECT(handle2), "_dw_refed")) | |
8683 { | |
8684 g_object_ref(G_OBJECT(handle2)); | |
8685 g_object_set_data(G_OBJECT(handle2), "_dw_refed", GINT_TO_POINTER(1)); | |
8686 } | |
8687 /* Remove the widget from the box */ | |
8688 gtk_container_remove(GTK_CONTAINER(box), handle2); | |
8689 retcode = DW_ERROR_NONE; | |
8690 } | |
8691 } | |
8692 DW_MUTEX_UNLOCK; | |
8693 return retcode; | |
8694 } | |
8695 | |
8696 /* | |
8697 * Remove windows (widgets) from a box at an arbitrary location. | |
8698 * Parameters: | |
8699 * box: Window handle of the box to be removed from. | |
8700 * index: 0 based index of packed items. | |
8701 * Returns: | |
8702 * Handle to the removed item on success, 0 on failure. | |
8703 */ | |
8704 HWND API dw_box_remove_at_index(HWND box, int index) | |
8705 { | |
8706 return 0; | |
8639 } | 8707 } |
8640 | 8708 |
8641 /* | 8709 /* |
8642 * Pack windows (widgets) into a box at an arbitrary location. | 8710 * Pack windows (widgets) into a box at an arbitrary location. |
8643 * Parameters: | 8711 * Parameters: |