comparison os2/dw.c @ 1568:625c4d1555fe

Added code to calculate the container size on OS/2. With no items this can only detect the title height and splitbar position. With items in the container this should function properly. Will try to figure out the title widths with no items. Also some more formatting cleanups.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 21 Jan 2012 03:13:32 +0000
parents 91d3586cf2a4
children 866d7d05d425
comparison
equal deleted inserted replaced
1567:91d3586cf2a4 1568:625c4d1555fe
2039 } 2039 }
2040 2040
2041 /* This procedure handles scrollbox */ 2041 /* This procedure handles scrollbox */
2042 MRESULT EXPENTRY _scrollwndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 2042 MRESULT EXPENTRY _scrollwndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2043 { 2043 {
2044 switch(msg) 2044 switch(msg)
2045 { 2045 {
2046 case WM_PAINT: 2046 case WM_PAINT:
2047 { 2047 {
2048 HPS hpsPaint; 2048 HPS hpsPaint;
2049 RECTL rclPaint; 2049 RECTL rclPaint;
2050 2050
2051 hpsPaint = WinBeginPaint(hWnd, 0, 0); 2051 hpsPaint = WinBeginPaint(hWnd, 0, 0);
2052 WinQueryWindowRect(hWnd, &rclPaint); 2052 WinQueryWindowRect(hWnd, &rclPaint);
2053 WinFillRect(hpsPaint, &rclPaint, CLR_PALEGRAY); 2053 WinFillRect(hpsPaint, &rclPaint, CLR_PALEGRAY);
2054 WinEndPaint(hpsPaint); 2054 WinEndPaint(hpsPaint);
2055
2056 break; 2055 break;
2057 } 2056 }
2058 case WM_HSCROLL: 2057 case WM_HSCROLL:
2059 case WM_VSCROLL: 2058 case WM_VSCROLL:
2060 { 2059 {
2061 MPARAM res; 2060 MPARAM res;
2062 int *pos, min, max, page, which = SHORT2FROMMP(mp2); 2061 int *pos, min, max, page, which = SHORT2FROMMP(mp2);
2063 HWND handle, client = WinWindowFromID(hWnd, FID_CLIENT); 2062 HWND handle, client = WinWindowFromID(hWnd, FID_CLIENT);
2064 HWND box = (HWND)dw_window_get_data(hWnd, "_dw_resizebox"); 2063 HWND box = (HWND)dw_window_get_data(hWnd, "_dw_resizebox");
2065 HWND hscroll = WinWindowFromID(hWnd, FID_HORZSCROLL); 2064 HWND hscroll = WinWindowFromID(hWnd, FID_HORZSCROLL);
2066 HWND vscroll = WinWindowFromID(hWnd, FID_VERTSCROLL); 2065 HWND vscroll = WinWindowFromID(hWnd, FID_VERTSCROLL);
2067 int hpos = dw_scrollbar_get_pos(hscroll); 2066 int hpos = dw_scrollbar_get_pos(hscroll);
2068 int vpos = dw_scrollbar_get_pos(vscroll); 2067 int vpos = dw_scrollbar_get_pos(vscroll);
2069 int cy = (int)dw_window_get_data(hWnd, "_dw_cy"); 2068 int cy = (int)dw_window_get_data(hWnd, "_dw_cy");
2070 RECTL rect; 2069 RECTL rect;
2071 2070
2072 WinQueryWindowRect(client, &rect); 2071 WinQueryWindowRect(client, &rect);
2073 2072
2074 if(msg == WM_VSCROLL) 2073 if(msg == WM_VSCROLL)
2075 { 2074 {
2076 page = rect.yTop - rect.yBottom; 2075 page = rect.yTop - rect.yBottom;
2077 handle = vscroll; 2076 handle = vscroll;
2078 pos = &vpos; 2077 pos = &vpos;
2079 } 2078 }
2080 else 2079 else
2081 { 2080 {
2082 page = rect.xRight - rect.xLeft; 2081 page = rect.xRight - rect.xLeft;
2083 handle = hscroll; 2082 handle = hscroll;
2084 pos = &hpos; 2083 pos = &hpos;
2085 } 2084 }
2086 2085
2087 res = WinSendMsg(handle, SBM_QUERYRANGE, 0, 0); 2086 res = WinSendMsg(handle, SBM_QUERYRANGE, 0, 0);
2088 min = SHORT1FROMMP(res); 2087 min = SHORT1FROMMP(res);
2089 max = SHORT2FROMMP(res); 2088 max = SHORT2FROMMP(res);
2090 2089
2091 switch(which) 2090 switch(which)
2092 { 2091 {
2093 case SB_SLIDERTRACK: 2092 case SB_SLIDERTRACK:
2094 *pos = SHORT1FROMMP(mp2); 2093 *pos = SHORT1FROMMP(mp2);
2095 break; 2094 break;
2096 case SB_LINEUP: 2095 case SB_LINEUP:
2097 (*pos)--; 2096 (*pos)--;
2098 if(*pos < min) 2097 if(*pos < min)
2099 *pos = min; 2098 *pos = min;
2100 break; 2099 break;
2101 case SB_LINEDOWN: 2100 case SB_LINEDOWN:
2102 (*pos)++; 2101 (*pos)++;
2103 if(*pos > max) 2102 if(*pos > max)
2104 *pos = max; 2103 *pos = max;
2105 break; 2104 break;
2106 case SB_PAGEUP: 2105 case SB_PAGEUP:
2107 (*pos) -= page; 2106 (*pos) -= page;
2108 if(*pos < min) 2107 if(*pos < min)
2109 *pos = min; 2108 *pos = min;
2110 break; 2109 break;
2111 case SB_PAGEDOWN: 2110 case SB_PAGEDOWN:
2112 (*pos) += page; 2111 (*pos) += page;
2113 if(*pos > max) 2112 if(*pos > max)
2114 *pos = max; 2113 *pos = max;
2114 break;
2115 }
2116 WinSendMsg(handle, SBM_SETPOS, (MPARAM)*pos, 0);
2117 /* Position the scrolled box */
2118 WinSetWindowPos(box, HWND_TOP, -hpos, -(cy - vpos), 0, 0, SWP_MOVE);
2115 break; 2119 break;
2116 } 2120 }
2117 WinSendMsg(handle, SBM_SETPOS, (MPARAM)*pos, 0); 2121 }
2118 /* Position the scrolled box */ 2122 return WinDefWindowProc(hWnd, msg, mp1, mp2);
2119 WinSetWindowPos(box, HWND_TOP, -hpos, -(cy - vpos), 0, 0, SWP_MOVE);
2120 break;
2121 }
2122 }
2123 return WinDefWindowProc(hWnd, msg, mp1, mp2);
2124 } 2123 }
2125 2124
2126 void _click_default(HWND handle) 2125 void _click_default(HWND handle)
2127 { 2126 {
2128 char tmpbuf[100] = {0}; 2127 char tmpbuf[100] = {0};
4786 thisheight = _DW_SCROLLED_MAX_HEIGHT; 4785 thisheight = _DW_SCROLLED_MAX_HEIGHT;
4787 } 4786 }
4788 /* Container and Tree */ 4787 /* Container and Tree */
4789 else if(strncmp(tmpbuf, "#37", 4)==0) 4788 else if(strncmp(tmpbuf, "#37", 4)==0)
4790 { 4789 {
4791 thiswidth = (int)((_DW_SCROLLED_MAX_WIDTH + _DW_SCROLLED_MIN_WIDTH)/2); 4790 /* Container */
4792 thisheight = (int)((_DW_SCROLLED_MAX_HEIGHT + _DW_SCROLLED_MIN_HEIGHT)/2); 4791 if(dw_window_get_data(handle, "_dw_container"))
4792 {
4793 CNRINFO ci;
4794
4795 if(WinSendMsg(handle, CM_QUERYCNRINFO, MPFROMP(&ci), MPFROMSHORT(sizeof(CNRINFO))))
4796 {
4797 RECTL item;
4798 PRECORDCORE pCore = NULL;
4799 int right = FALSE, max = 0;
4800 /* Get the left title window */
4801 HWND title = WinWindowFromID(handle, 32752);
4802
4803 thiswidth = WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL);
4804 thisheight = WinQuerySysValue(HWND_DESKTOP, SV_CYHSCROLL);
4805
4806 /* If the pFieldInfoList is filled in we want to look at the right side */
4807 if(ci.pFieldInfoLast)
4808 {
4809 right = TRUE;
4810 /* Left side include splitbar position */
4811 thiswidth += ci.xVertSplitbar + 4;
4812 /* If split... find the right side */
4813 title = WinWindowFromID(handle, 32753);
4814 }
4815
4816 /* If there are column titles ... */
4817 if(title)
4818 {
4819 int height = 0;
4820
4821 dw_window_get_pos_size(handle, 0, 0, 0, &height);
4822 height += thisheight;
4823 }
4824
4825 /* Cycle through all the records finding the maximums */
4826 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
4827 while(pCore)
4828 {
4829 QUERYRECORDRECT qrr;
4830 int vector;
4831
4832 qrr.cb = sizeof(QUERYRECORDRECT);
4833 qrr.pRecord = pCore;
4834 qrr.fRightSplitWindow = right;
4835 qrr.fsExtent = CMA_TEXT;
4836
4837 WinSendMsg(handle, CM_QUERYRECORDRECT, (MPARAM)&item, (MPARAM)&qrr);
4838
4839 vector = item.xRight - item.xLeft;
4840
4841 if(vector > max)
4842 max = vector;
4843
4844 thisheight += (item.yTop - item.yBottom);
4845
4846 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
4847 }
4848
4849 /* Add the widest item to the width */
4850 thiswidth += max;
4851
4852 /* Clampt to min and max */
4853 if(thiswidth > _DW_SCROLLED_MAX_WIDTH)
4854 thiswidth = _DW_SCROLLED_MAX_WIDTH;
4855 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
4856 thiswidth = _DW_SCROLLED_MIN_WIDTH;
4857 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
4858 thisheight = _DW_SCROLLED_MIN_HEIGHT;
4859 if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
4860 thisheight = _DW_SCROLLED_MAX_HEIGHT;
4861 }
4862 }
4863 else
4864 {
4865 /* Tree */
4866 thiswidth = (int)((_DW_SCROLLED_MAX_WIDTH + _DW_SCROLLED_MIN_WIDTH)/2);
4867 thisheight = (int)((_DW_SCROLLED_MAX_HEIGHT + _DW_SCROLLED_MIN_HEIGHT)/2);
4868 }
4793 } 4869 }
4794 /* Button */ 4870 /* Button */
4795 else if(strncmp(tmpbuf, "#3", 3)==0) 4871 else if(strncmp(tmpbuf, "#3", 3)==0)
4796 { 4872 {
4797 ULONG style = WinQueryWindowULong(handle, QWL_STYLE); 4873 ULONG style = WinQueryWindowULong(handle, QWL_STYLE);