# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1322883103 0 # Node ID 1bb1865fed9d91df6701abe947e556cba11d555e # Parent 131bedf41332bb1460121ed4c93f4059db59801a Revert experimental GTK2 change and add OS/2 support for auto-redrawing and auto-calculating bitmaps and bitmap buttons. diff -r 131bedf41332 -r 1bb1865fed9d gtk/dw.c --- a/gtk/dw.c Sat Dec 03 02:08:40 2011 +0000 +++ b/gtk/dw.c Sat Dec 03 03:31:43 2011 +0000 @@ -9989,7 +9989,7 @@ gtk_object_set_data(GTK_OBJECT(item), "_dw_table", box); if(index < boxcount) gtk_container_forall(GTK_CONTAINER(box),_rearrange_table, GINT_TO_POINTER(boxtype == DW_VERT ? index : -(index+1))); - gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : GTK_FILL, vsize ? DW_EXPAND : GTK_FILL, pad, pad); + gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad); gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount + 1)); gtk_widget_set_usize(item, width, height); if(GTK_IS_RADIO_BUTTON(item)) diff -r 131bedf41332 -r 1bb1865fed9d os2/dw.c --- a/os2/dw.c Sat Dec 03 02:08:40 2011 +0000 +++ b/os2/dw.c Sat Dec 03 03:31:43 2011 +0000 @@ -234,6 +234,21 @@ return TRUE; } +/* Internal function to queue a window redraw */ +void _dw_redraw(HWND window, int skip) +{ + static HWND lastwindow = 0; + + if(skip && !window) + return; + + if(lastwindow != window && lastwindow) + { + dw_window_redraw(lastwindow); + } + lastwindow = window; +} + /* Find the desktop window handle */ HWND _toplevel_window(HWND handle) { @@ -3257,6 +3272,12 @@ tmp = tmp->next; } + if(result != -1) + { + /* Make sure any queued redraws are handled */ + _dw_redraw(0, FALSE); + /* Then finally return */ + } return (MRESULT)result; } @@ -4702,6 +4723,35 @@ if(thisheight < 18) thisheight = 18; } + /* Bitmap/Static */ + else if(strncmp(tmpbuf, "#5", 3)==0) + { + int bmwidth = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_width")); + int bmheight = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_height")); + + if(bmwidth > 0 && bmheight > 0) + { + thiswidth = bmwidth; + thisheight = bmheight; + } + } + /* Ranged: Slider/Percent/Scrollbar */ + else if(strncmp(tmpbuf, "#38", 4)== 0 || + strncmp(tmpbuf, "#8", 3)== 0) + { + /* Check for vertical scrollbar */ + if(strncmp(tmpbuf, "#8", 3)== 0 && + WinQueryWindowULong(handle, QWL_STYLE) & SBS_VERT) + { + thiswidth = 14; + thisheight = 100; + } + else + { + thiswidth = 100; + thisheight = 14; + } + } /* Spinbutton */ else if(strncmp(tmpbuf, "#32", 4)==0) { @@ -4720,7 +4770,30 @@ { ULONG style = WinQueryWindowULong(handle, QWL_STYLE); - if(style & BS_AUTOCHECKBOX || style & BS_AUTORADIOBUTTON) + /* Handle bitmap buttons */ + if(dw_window_get_data(handle, "_dw_bitmapbutton")) + { + WNDPARAMS wp; + BTNCDATA bcd; + + wp.fsStatus = WPM_CTLDATA; + wp.cbCtlData = sizeof(BTNCDATA); + wp.pCtlData = &bcd; + + /* Query the button's bitmap */ + if(WinSendMsg(handle, WM_QUERYWINDOWPARAMS, (MPARAM)&wp, MPVOID) && bcd.hImage) + { + BITMAPINFOHEADER2 bmp; + bmp.cbFix = sizeof(BITMAPINFOHEADER2); + /* Get the parameters of the bitmap */ + if(GpiQueryBitmapInfoHeader(bcd.hImage, &bmp)) + { + thiswidth = bmp.cx; + thisheight = bmp.cy; + } + } + } + else if(style & BS_AUTOCHECKBOX || style & BS_AUTORADIOBUTTON) { extrawidth = 24; extraheight = 4; @@ -4755,7 +4828,11 @@ /* Check to see if any of the sizes need to be recalculated */ if(item && (item->origwidth == -1 || item->origheight == -1)) + { _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); + /* Queue a redraw on the top-level window */ + _dw_redraw(_toplevel_window(handle), TRUE); + } return DW_ERROR_NONE; } return DW_ERROR_UNKNOWN; @@ -6428,6 +6505,19 @@ if ( id ) WinReleasePS(hps); dw_window_set_data(handle, "_dw_bitmap", (void *)hbm); + + /* If we changed the bitmap... */ + { + Item *item = _box_item(handle); + + /* Check to see if any of the sizes need to be recalculated */ + if(item && (item->origwidth == -1 || item->origheight == -1)) + { + _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); + /* Queue a redraw on the top-level window */ + _dw_redraw(_toplevel_window(handle), TRUE); + } + } } /* @@ -6516,7 +6606,11 @@ /* Check to see if any of the sizes need to be recalculated */ if(item && (item->origwidth == -1 || item->origheight == -1)) + { _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); + /* Queue a redraw on the top-level window */ + _dw_redraw(_toplevel_window(handle), TRUE); + } } } @@ -6788,6 +6882,8 @@ if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0) WinSetOwner(item, box); WinSetParent(frame ? frame : item, box, FALSE); + /* Queue a redraw on the top-level window */ + _dw_redraw(_toplevel_window(item), TRUE); } }