comparison os2/dw.c @ 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
comparison
equal deleted inserted replaced
1568:625c4d1555fe 1569:866d7d05d425
4814 } 4814 }
4815 4815
4816 /* If there are column titles ... */ 4816 /* If there are column titles ... */
4817 if(title) 4817 if(title)
4818 { 4818 {
4819 int height = 0; 4819 unsigned long height = 0;
4820 4820
4821 dw_window_get_pos_size(handle, 0, 0, 0, &height); 4821 dw_window_get_pos_size(title, 0, 0, 0, &height);
4822 height += thisheight; 4822 if(height)
4823 thisheight += height;
4824 else
4825 thisheight += 28;
4823 } 4826 }
4824 4827
4825 /* Cycle through all the records finding the maximums */ 4828 /* Cycle through all the records finding the maximums */
4826 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 4829 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
4827 while(pCore) 4830
4831 /* Method 1: With items in container */
4832 if(pCore)
4828 { 4833 {
4829 QUERYRECORDRECT qrr; 4834 while(pCore)
4830 int vector; 4835 {
4831 4836 QUERYRECORDRECT qrr;
4832 qrr.cb = sizeof(QUERYRECORDRECT); 4837 int vector;
4833 qrr.pRecord = pCore; 4838
4834 qrr.fRightSplitWindow = right; 4839 qrr.cb = sizeof(QUERYRECORDRECT);
4835 qrr.fsExtent = CMA_TEXT; 4840 qrr.pRecord = pCore;
4836 4841 qrr.fRightSplitWindow = right;
4837 WinSendMsg(handle, CM_QUERYRECORDRECT, (MPARAM)&item, (MPARAM)&qrr); 4842 qrr.fsExtent = CMA_TEXT;
4838 4843
4839 vector = item.xRight - item.xLeft; 4844 WinSendMsg(handle, CM_QUERYRECORDRECT, (MPARAM)&item, (MPARAM)&qrr);
4840 4845
4841 if(vector > max) 4846 vector = item.xRight - item.xLeft;
4842 max = vector; 4847
4843 4848 if(vector > max)
4844 thisheight += (item.yTop - item.yBottom); 4849 max = vector;
4845 4850
4846 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 4851 thisheight += (item.yTop - item.yBottom);
4852
4853 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
4854 }
4855
4856 /* Add the widest item to the width */
4857 thiswidth += max;
4847 } 4858 }
4848 4859 else
4849 /* Add the widest item to the width */ 4860 {
4850 thiswidth += max; 4861 /* Method 2: No items */
4851 4862 unsigned long width, height;
4852 /* Clampt to min and max */ 4863 HWND hscroll = WinWindowFromID(handle, right ? 32756 : 32755);
4864 MRESULT mr;
4865
4866 /* Save the original size */
4867 dw_window_get_pos_size(handle, 0, 0, &width, &height);
4868
4869 /* Set the size to the minimum */
4870 dw_window_set_size(handle, _DW_SCROLLED_MIN_WIDTH, _DW_SCROLLED_MIN_HEIGHT);
4871
4872 /* With the minimum size check to see what the scrollbar says */
4873 mr = WinSendMsg(hscroll, SBM_QUERYRANGE, 0, 0);
4874 if(right)
4875 thiswidth += SHORT2FROMMP(mr);
4876 else if(SHORT2FROMMP(mr) != _DW_SCROLLED_MIN_HEIGHT)
4877 thiswidth += SHORT2FROMMP(mr) + _DW_SCROLLED_MIN_HEIGHT + WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL);
4878
4879 /* Reload the original size */
4880 dw_window_set_size(handle, width, height);
4881 }
4882
4883 /* Clamp to min and max */
4853 if(thiswidth > _DW_SCROLLED_MAX_WIDTH) 4884 if(thiswidth > _DW_SCROLLED_MAX_WIDTH)
4854 thiswidth = _DW_SCROLLED_MAX_WIDTH; 4885 thiswidth = _DW_SCROLLED_MAX_WIDTH;
4855 if(thiswidth < _DW_SCROLLED_MIN_WIDTH) 4886 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
4856 thiswidth = _DW_SCROLLED_MIN_WIDTH; 4887 thiswidth = _DW_SCROLLED_MIN_WIDTH;
4857 if(thisheight < _DW_SCROLLED_MIN_HEIGHT) 4888 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)