Mercurial > dwindows
diff os2/dw.c @ 964:6c6b5bbd3a26
Some code cleanups for OS/2 while attempting to track down an issue in _free_window_data().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 02 May 2011 17:43:06 +0000 |
parents | ea356c38f7b6 |
children | 2b1b9b995748 |
line wrap: on
line diff
--- a/os2/dw.c Mon May 02 17:24:58 2011 +0000 +++ b/os2/dw.c Mon May 02 17:43:06 2011 +0000 @@ -1357,13 +1357,13 @@ /* Handle special case of scrollbox */ int cx = width + vectorx; int cy = height + vectory; - int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; - HWND box = (HWND)dw_window_get_data(handle, "_dw_resizebox"); - HWND client = WinWindowFromID(handle, FID_CLIENT); - HWND vscroll = WinWindowFromID(handle, FID_VERTSCROLL); + int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; + HWND box = (HWND)dw_window_get_data(handle, "_dw_resizebox"); + HWND client = WinWindowFromID(handle, FID_CLIENT); + HWND vscroll = WinWindowFromID(handle, FID_VERTSCROLL); HWND hscroll = WinWindowFromID(handle, FID_HORZSCROLL); - Box *thisbox = (Box *)WinQueryWindowPtr(box, QWP_USER); - int origx, origy; + Box *thisbox = (Box *)WinQueryWindowPtr(box, QWP_USER); + int origx, origy; unsigned int hpos = (unsigned int)WinSendMsg(hscroll, SBM_QUERYPOS, 0, 0); unsigned int vpos = (unsigned int)WinSendMsg(vscroll, SBM_QUERYPOS, 0, 0); @@ -1373,11 +1373,11 @@ WinSetWindowPos(hscroll, HWND_TOP, 0, 0, cx - _DW_DEFAULT_SCROLLBAR_WIDTH, _DW_DEFAULT_SCROLLBAR_WIDTH, SWP_MOVE | SWP_SIZE | SWP_ZORDER); WinSetWindowPos(vscroll, HWND_TOP, cx - _DW_DEFAULT_SCROLLBAR_WIDTH, _DW_DEFAULT_SCROLLBAR_WIDTH, _DW_DEFAULT_SCROLLBAR_WIDTH, cy - _DW_DEFAULT_SCROLLBAR_WIDTH, SWP_MOVE | SWP_SIZE | SWP_ZORDER); - origx = cx = cx - _DW_DEFAULT_SCROLLBAR_WIDTH; - origy = cy = cy - _DW_DEFAULT_SCROLLBAR_WIDTH; + origx = cx = cx - _DW_DEFAULT_SCROLLBAR_WIDTH; + origy = cy = cy - _DW_DEFAULT_SCROLLBAR_WIDTH; /* Get the required space for the box */ - _resize_box(thisbox, &depth, cx, cy, &usedx, &usedy, 1, &usedpadx, &usedpady); + _resize_box(thisbox, &depth, cx, cy, &usedx, &usedy, 1, &usedpadx, &usedpady); if(cx < usedx) { @@ -1389,25 +1389,25 @@ } /* Setup vertical scroller */ - WinSendMsg(vscroll, SBM_SETSCROLLBAR, (MPARAM)vpos, MPFROM2SHORT(0, (unsigned short)usedy - origy)); - WinSendMsg(vscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT((unsigned short)origy, usedy), 0); + WinSendMsg(vscroll, SBM_SETSCROLLBAR, (MPARAM)vpos, MPFROM2SHORT(0, (unsigned short)usedy - origy)); + WinSendMsg(vscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT((unsigned short)origy, usedy), 0); if(vpos > usedy) { - vpos = usedy; - WinSendMsg(vscroll, SBM_SETPOS, (MPARAM)vpos, 0); - } - + vpos = usedy; + WinSendMsg(vscroll, SBM_SETPOS, (MPARAM)vpos, 0); + } + /* Setup horizontal scroller */ - WinSendMsg(hscroll, SBM_SETSCROLLBAR, (MPARAM)hpos, MPFROM2SHORT(0, (unsigned short)usedx - origx)); - WinSendMsg(hscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT((unsigned short)origx, usedx), 0); + WinSendMsg(hscroll, SBM_SETSCROLLBAR, (MPARAM)hpos, MPFROM2SHORT(0, (unsigned short)usedx - origx)); + WinSendMsg(hscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT((unsigned short)origx, usedx), 0); if(hpos > usedx) { - hpos = usedx; - WinSendMsg(hscroll, SBM_SETPOS, (MPARAM)hpos, 0); - } - + hpos = usedx; + WinSendMsg(hscroll, SBM_SETPOS, (MPARAM)hpos, 0); + } + /* Position the scrolled box */ - WinSetWindowPos(box, HWND_TOP, 0, -(cy - origy), cx, cy, SWP_MOVE | SWP_SIZE | SWP_ZORDER); + WinSetWindowPos(box, HWND_TOP, 0, -(cy - origy), cx, cy, SWP_MOVE | SWP_SIZE | SWP_ZORDER); dw_window_set_data(handle, "_dw_cy", (void *)(cy - origy)); @@ -4291,25 +4291,25 @@ */ HWND API dw_scrollbox_new(int type, int pad) { - HWND hwndframe, box = dw_box_new(type, pad); - HWND client, tmpbox = dw_box_new(DW_VERT, 0); - WindowData *blah = calloc(sizeof(WindowData), 1); - dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0); - hwndframe = WinCreateWindow(HWND_OBJECT, ScrollClassName, "", WS_VISIBLE | WS_CLIPCHILDREN, - 0, 0, 2000, 1000, NULLHANDLE, HWND_TOP, 0, NULL, NULL); - WinCreateWindow(hwndframe, WC_SCROLLBAR, "", WS_VISIBLE | SBS_AUTOTRACK | SBS_VERT, - 0,0,2000,1000, hwndframe, HWND_TOP, FID_VERTSCROLL, NULL, NULL); + HWND hwndframe, box = dw_box_new(type, pad); + HWND client, tmpbox = dw_box_new(DW_VERT, 0); + WindowData *blah = calloc(sizeof(WindowData), 1); + dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0); + hwndframe = WinCreateWindow(HWND_OBJECT, ScrollClassName, "", WS_VISIBLE | WS_CLIPCHILDREN, + 0, 0, 2000, 1000, NULLHANDLE, HWND_TOP, 0, NULL, NULL); + WinCreateWindow(hwndframe, WC_SCROLLBAR, "", WS_VISIBLE | SBS_AUTOTRACK | SBS_VERT, + 0,0,2000,1000, hwndframe, HWND_TOP, FID_VERTSCROLL, NULL, NULL); WinCreateWindow(hwndframe, WC_SCROLLBAR, "", WS_VISIBLE | SBS_AUTOTRACK | SBS_HORZ, - 0,0,2000,1000, hwndframe, HWND_TOP, FID_HORZSCROLL, NULL, NULL); + 0,0,2000,1000, hwndframe, HWND_TOP, FID_HORZSCROLL, NULL, NULL); client = WinCreateWindow(hwndframe, WC_FRAME, "", WS_VISIBLE | WS_CLIPCHILDREN, - 0,0,2000,1000, NULLHANDLE, HWND_TOP, FID_CLIENT, NULL, NULL); - WinSetParent(tmpbox, client, FALSE); - WinSetWindowPtr(hwndframe, QWP_USER, blah); - dw_window_set_data(hwndframe, "_dw_resizebox", (void *)tmpbox); + 0,0,2000,1000, NULLHANDLE, HWND_TOP, FID_CLIENT, NULL, NULL); + WinSetParent(tmpbox, client, FALSE); + WinSetWindowPtr(hwndframe, QWP_USER, blah); + dw_window_set_data(hwndframe, "_dw_resizebox", (void *)tmpbox); dw_window_set_data(hwndframe, "_dw_box", (void *)box); - dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); - dw_window_set_color(client, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); - return hwndframe; + dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + dw_window_set_color(client, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); + return hwndframe; } /* @@ -4320,17 +4320,17 @@ */ int API dw_scrollbox_get_pos( HWND handle, int orient ) { - HWND scroll; - - if(orient == DW_VERT) - { - scroll = WinWindowFromID(handle, FID_VERTSCROLL); - } - else - { - scroll = WinWindowFromID(handle, FID_HORZSCROLL); - } - return (int)WinSendMsg(scroll, SBM_QUERYPOS, 0, 0); + HWND scroll; + + if(orient == DW_VERT) + { + scroll = WinWindowFromID(handle, FID_VERTSCROLL); + } + else + { + scroll = WinWindowFromID(handle, FID_HORZSCROLL); + } + return (int)WinSendMsg(scroll, SBM_QUERYPOS, 0, 0); } /* @@ -4341,17 +4341,17 @@ */ int API dw_scrollbox_get_range( HWND handle, int orient ) { - HWND scroll; - - if(orient == DW_VERT) - { - scroll = WinWindowFromID(handle, FID_VERTSCROLL); - } - else - { - scroll = WinWindowFromID(handle, FID_HORZSCROLL); - } - return SHORT2FROMMP(WinSendMsg(scroll, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0)); + HWND scroll; + + if(orient == DW_VERT) + { + scroll = WinWindowFromID(handle, FID_VERTSCROLL); + } + else + { + scroll = WinWindowFromID(handle, FID_HORZSCROLL); + } + return SHORT2FROMMP(WinSendMsg(scroll, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0)); } /*