Mercurial > dwindows
changeset 1569:866d7d05d425
Added second calculation method for container on OS/2.
Use the scrollbars to determine sizes when there are no items.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 21 Jan 2012 04:42:49 +0000 |
parents | 625c4d1555fe |
children | d6988022c5cf |
files | os2/dw.c |
diffstat | 1 files changed, 59 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/os2/dw.c Sat Jan 21 03:13:32 2012 +0000 +++ b/os2/dw.c Sat Jan 21 04:42:49 2012 +0000 @@ -4816,40 +4816,71 @@ /* If there are column titles ... */ if(title) { - int height = 0; - - dw_window_get_pos_size(handle, 0, 0, 0, &height); - height += thisheight; + unsigned long height = 0; + + dw_window_get_pos_size(title, 0, 0, 0, &height); + if(height) + thisheight += height; + else + thisheight += 28; } /* Cycle through all the records finding the maximums */ pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); - while(pCore) + + /* Method 1: With items in container */ + if(pCore) { - QUERYRECORDRECT qrr; - int vector; - - qrr.cb = sizeof(QUERYRECORDRECT); - qrr.pRecord = pCore; - qrr.fRightSplitWindow = right; - qrr.fsExtent = CMA_TEXT; - - WinSendMsg(handle, CM_QUERYRECORDRECT, (MPARAM)&item, (MPARAM)&qrr); - - vector = item.xRight - item.xLeft; - - if(vector > max) - max = vector; - - thisheight += (item.yTop - item.yBottom); - - pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); + while(pCore) + { + QUERYRECORDRECT qrr; + int vector; + + qrr.cb = sizeof(QUERYRECORDRECT); + qrr.pRecord = pCore; + qrr.fRightSplitWindow = right; + qrr.fsExtent = CMA_TEXT; + + WinSendMsg(handle, CM_QUERYRECORDRECT, (MPARAM)&item, (MPARAM)&qrr); + + vector = item.xRight - item.xLeft; + + if(vector > max) + max = vector; + + thisheight += (item.yTop - item.yBottom); + + pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); + } + + /* Add the widest item to the width */ + thiswidth += max; } - - /* Add the widest item to the width */ - thiswidth += max; - - /* Clampt to min and max */ + else + { + /* Method 2: No items */ + unsigned long width, height; + HWND hscroll = WinWindowFromID(handle, right ? 32756 : 32755); + MRESULT mr; + + /* Save the original size */ + dw_window_get_pos_size(handle, 0, 0, &width, &height); + + /* Set the size to the minimum */ + dw_window_set_size(handle, _DW_SCROLLED_MIN_WIDTH, _DW_SCROLLED_MIN_HEIGHT); + + /* With the minimum size check to see what the scrollbar says */ + mr = WinSendMsg(hscroll, SBM_QUERYRANGE, 0, 0); + if(right) + thiswidth += SHORT2FROMMP(mr); + else if(SHORT2FROMMP(mr) != _DW_SCROLLED_MIN_HEIGHT) + thiswidth += SHORT2FROMMP(mr) + _DW_SCROLLED_MIN_HEIGHT + WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL); + + /* Reload the original size */ + dw_window_set_size(handle, width, height); + } + + /* Clamp to min and max */ if(thiswidth > _DW_SCROLLED_MAX_WIDTH) thiswidth = _DW_SCROLLED_MAX_WIDTH; if(thiswidth < _DW_SCROLLED_MIN_WIDTH)