comparison os2/dw.c @ 535:b0b5b880513a

Don't reverse packing on vertical boxes to compensate for the inverted Y-axis on OS/2. Instead this should be dealt with in the layout code taking into account the size of the box the items are sitting on. This new code mostly works, but has some problems.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 24 Mar 2004 00:05:39 +0000
parents 79696a852401
children 81e29ea5dc2f
comparison
equal deleted inserted replaced
534:222b0f32e7c9 535:b0b5b880513a
205 if(box > 0) 205 if(box > 0)
206 return lastbox; 206 return lastbox;
207 return handle; 207 return handle;
208 } 208 }
209 209
210
211 /* Returns height of specified window. */
212 int _get_height(HWND handle)
213 {
214 unsigned long height;
215 dw_window_get_pos_size(handle, NULL, NULL, NULL, &height);
216 return (int)height;
217 }
218
219 /* Find the height of the frame a desktop style window is sitting on */
220 int _get_frame_height(HWND handle)
221 {
222 while(handle)
223 {
224 HWND client;
225 if((client = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE)
226 {
227 return _get_height(WinQueryWindow(handle, QW_PARENT));
228 }
229 handle = WinQueryWindow(handle, QW_PARENT);
230 }
231 return dw_screen_height();
232 }
210 233
211 /* A "safe" WinSendMsg() that tries multiple times in case the 234 /* A "safe" WinSendMsg() that tries multiple times in case the
212 * queue is blocked for one reason or another. 235 * queue is blocked for one reason or another.
213 */ 236 */
214 MRESULT _dw_send_msg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, int failure) 237 MRESULT _dw_send_msg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, int failure)
914 if(color < 16) 937 if(color < 16)
915 return _colors[color]; 938 return _colors[color];
916 return color; 939 return color;
917 } 940 }
918 941
942 BOOL _MySetWindowPos(HWND hwnd, HWND parent, HWND behind, LONG x, LONG y, LONG cx, LONG cy, ULONG fl)
943 {
944 int height = _get_height(parent);
945
946 return WinSetWindowPos(hwnd, behind, x, height - y - cy, cx, cy, fl);
947 }
948
919 /* This function calculates how much space the widgets and boxes require 949 /* This function calculates how much space the widgets and boxes require
920 * and does expansion as necessary. 950 * and does expansion as necessary.
921 */ 951 */
922 int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, 952 int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy,
923 int pass, int *usedpadx, int *usedpady) 953 int pass, int *usedpadx, int *usedpady)
1263 { 1293 {
1264 HWND frame = (HWND)dw_window_get_data(handle, "_dw_combo_box"); 1294 HWND frame = (HWND)dw_window_get_data(handle, "_dw_combo_box");
1265 /* Make the combobox big enough to drop down. :) */ 1295 /* Make the combobox big enough to drop down. :) */
1266 WinSetWindowPos(handle, HWND_TOP, 0, -100, 1296 WinSetWindowPos(handle, HWND_TOP, 0, -100,
1267 width + vectorx, (height + vectory) + 100, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1297 width + vectorx, (height + vectory) + 100, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1268 WinSetWindowPos(frame, HWND_TOP, currentx + pad, currenty + pad, 1298 _MySetWindowPos(frame, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad,
1269 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1299 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1270 } 1300 }
1271 else if(strncmp(tmpbuf, "#6", 3)==0) 1301 else if(strncmp(tmpbuf, "#6", 3)==0)
1272 { 1302 {
1273 /* Entryfields on OS/2 have a thick border that isn't on Windows and GTK */ 1303 /* Entryfields on OS/2 have a thick border that isn't on Windows and GTK */
1274 WinSetWindowPos(handle, HWND_TOP, (currentx + pad) + 3, (currenty + pad) + 3, 1304 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, (currentx + pad) + 3, (currenty + pad) + 3,
1275 (width + vectorx) - 6, (height + vectory) - 6, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1305 (width + vectorx) - 6, (height + vectory) - 6, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1276 } 1306 }
1277 else if(strncmp(tmpbuf, "#40", 5)==0) 1307 else if(strncmp(tmpbuf, "#40", 5)==0)
1278 { 1308 {
1279 WinSetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, 1309 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad,
1280 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1310 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1281 _check_resize_notebook(handle); 1311 _check_resize_notebook(handle);
1282 } 1312 }
1283 else if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) 1313 else if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
1284 { 1314 {
1286 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); 1316 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
1287 int type = (int)dw_window_get_data(handle, "_dw_type"); 1317 int type = (int)dw_window_get_data(handle, "_dw_type");
1288 int cx = width + vectorx; 1318 int cx = width + vectorx;
1289 int cy = height + vectory; 1319 int cy = height + vectory;
1290 1320
1291 WinSetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, 1321 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad,
1292 cx, cy, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1322 cx, cy, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1293 1323
1294 if(cx > 0 && cy > 0 && percent) 1324 if(cx > 0 && cy > 0 && percent)
1295 _handle_splitbar_resize(handle, *percent, type, cx, cy); 1325 _handle_splitbar_resize(handle, *percent, type, cx, cy);
1296 } 1326 }
1297 else 1327 else
1298 { 1328 {
1299 WinSetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, 1329 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad,
1300 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1330 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1301 if(thisbox->items[z].type == TYPEBOX) 1331 if(thisbox->items[z].type == TYPEBOX)
1302 { 1332 {
1303 Box *boxinfo = WinQueryWindowPtr(handle, QWP_USER); 1333 Box *boxinfo = WinQueryWindowPtr(handle, QWP_USER);
1304 1334
1943 1973
1944 if(PP_FONTNAMESIZE == AttrFound && cbRetLen) 1974 if(PP_FONTNAMESIZE == AttrFound && cbRetLen)
1945 { 1975 {
1946 memcpy(buff, AttrValue, cbRetLen); 1976 memcpy(buff, AttrValue, cbRetLen);
1947 } 1977 }
1948 }
1949
1950 /* Returns height of specified window. */
1951 int _get_height(HWND handle)
1952 {
1953 unsigned long height;
1954 dw_window_get_pos_size(handle, NULL, NULL, NULL, &height);
1955 return (int)height;
1956 }
1957
1958 /* Find the height of the frame a desktop style window is sitting on */
1959 int _get_frame_height(HWND handle)
1960 {
1961 while(handle)
1962 {
1963 HWND client;
1964 if((client = WinWindowFromID(handle, FID_CLIENT)) != NULLHANDLE)
1965 {
1966 return _get_height(WinQueryWindow(handle, QW_PARENT));
1967 }
1968 handle = WinQueryWindow(handle, QW_PARENT);
1969 }
1970 return dw_screen_height();
1971 } 1978 }
1972 1979
1973 int _HandleScroller(HWND handle, int pos, int which) 1980 int _HandleScroller(HWND handle, int pos, int which)
1974 { 1981 {
1975 MPARAM res; 1982 MPARAM res;
3911 * title: The Window title. 3918 * title: The Window title.
3912 * flStyle: Style flags, see the PM reference. 3919 * flStyle: Style flags, see the PM reference.
3913 */ 3920 */
3914 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) 3921 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
3915 { 3922 {
3916 HWND hwndclient = 0, hwndframe; 3923 HWND hwndframe;
3917 Box *newbox = calloc(1, sizeof(Box)); 3924 Box *newbox = calloc(1, sizeof(Box));
3918 WindowData *blah = calloc(1, sizeof(WindowData)); 3925 WindowData *blah = calloc(1, sizeof(WindowData));
3919 ULONG winStyle = 0L; 3926 ULONG winStyle = 0L;
3920 3927
3921 newbox->pad = 0; 3928 newbox->pad = 0;
3941 { 3948 {
3942 winStyle |= WS_MINIMIZED; 3949 winStyle |= WS_MINIMIZED;
3943 flStyle &= ~WS_MINIMIZED; 3950 flStyle &= ~WS_MINIMIZED;
3944 } 3951 }
3945 3952
3946 hwndframe = WinCreateStdWindow(hwndOwner, winStyle, &flStyle, ClassName, title, 0L, NULLHANDLE, 0L, &hwndclient); 3953 hwndframe = WinCreateStdWindow(hwndOwner, winStyle, &flStyle, ClassName, title, 0L, NULLHANDLE, 0L, &newbox->hwnd);
3947 newbox->hwndtitle = WinWindowFromID(hwndframe, FID_TITLEBAR); 3954 newbox->hwndtitle = WinWindowFromID(hwndframe, FID_TITLEBAR);
3948 if(!newbox->titlebar && newbox->hwndtitle) 3955 if(!newbox->titlebar && newbox->hwndtitle)
3949 WinSetParent(newbox->hwndtitle, HWND_OBJECT, FALSE); 3956 WinSetParent(newbox->hwndtitle, HWND_OBJECT, FALSE);
3950 blah->oldproc = WinSubclassWindow(hwndframe, _sizeproc); 3957 blah->oldproc = WinSubclassWindow(hwndframe, _sizeproc);
3951 WinSetWindowPtr(hwndframe, QWP_USER, blah); 3958 WinSetWindowPtr(hwndframe, QWP_USER, blah);
3952 WinSetWindowPtr(hwndclient, QWP_USER, newbox); 3959 WinSetWindowPtr(newbox->hwnd, QWP_USER, newbox);
3953 3960
3954 return hwndframe; 3961 return hwndframe;
3955 } 3962 }
3956 3963
3957 /* 3964 /*
3961 * pad: Number of pixels to pad around the box. 3968 * pad: Number of pixels to pad around the box.
3962 */ 3969 */
3963 HWND API dw_box_new(int type, int pad) 3970 HWND API dw_box_new(int type, int pad)
3964 { 3971 {
3965 Box *newbox = calloc(1, sizeof(Box)); 3972 Box *newbox = calloc(1, sizeof(Box));
3966 HWND hwndframe;
3967 3973
3968 newbox->pad = pad; 3974 newbox->pad = pad;
3969 newbox->type = type; 3975 newbox->type = type;
3970 newbox->count = 0; 3976 newbox->count = 0;
3971 newbox->grouphwnd = NULLHANDLE; 3977 newbox->grouphwnd = NULLHANDLE;
3972 3978
3973 hwndframe = WinCreateWindow(HWND_OBJECT, 3979 newbox->hwnd = WinCreateWindow(HWND_OBJECT,
3974 WC_FRAME, 3980 WC_FRAME,
3975 NULL, 3981 NULL,
3976 WS_VISIBLE | WS_CLIPCHILDREN | 3982 WS_VISIBLE | WS_CLIPCHILDREN |
3977 FS_NOBYTEALIGN, 3983 FS_NOBYTEALIGN,
3978 0,0,2000,1000, 3984 0,0,2000,1000,
3979 NULLHANDLE, 3985 NULLHANDLE,
3980 HWND_TOP, 3986 HWND_TOP,
3981 0L, 3987 0L,
3982 NULL, 3988 NULL,
3983 NULL); 3989 NULL);
3984 3990
3985 newbox->oldproc = WinSubclassWindow(hwndframe, _controlproc); 3991 newbox->oldproc = WinSubclassWindow(newbox->hwnd, _controlproc);
3986 WinSetWindowPtr(hwndframe, QWP_USER, newbox); 3992 WinSetWindowPtr(newbox->hwnd, QWP_USER, newbox);
3987 dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); 3993 dw_window_set_color(newbox->hwnd, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
3988 return hwndframe; 3994 return newbox->hwnd;
3989 } 3995 }
3990 3996
3991 /* 3997 /*
3992 * Create a new Group Box to be packed. 3998 * Create a new Group Box to be packed.
3993 * Parameters: 3999 * Parameters:
3996 * title: Text to be displayined in the group outline. 4002 * title: Text to be displayined in the group outline.
3997 */ 4003 */
3998 HWND API dw_groupbox_new(int type, int pad, char *title) 4004 HWND API dw_groupbox_new(int type, int pad, char *title)
3999 { 4005 {
4000 Box *newbox = calloc(1, sizeof(Box)); 4006 Box *newbox = calloc(1, sizeof(Box));
4001 HWND hwndframe;
4002
4003 newbox->pad = pad; 4007 newbox->pad = pad;
4004 newbox->type = type; 4008 newbox->type = type;
4005 newbox->count = 0; 4009 newbox->count = 0;
4006 4010
4007 hwndframe = WinCreateWindow(HWND_OBJECT, 4011 newbox->hwnd = WinCreateWindow(HWND_OBJECT,
4008 WC_FRAME, 4012 WC_FRAME,
4009 NULL, 4013 NULL,
4010 WS_VISIBLE | 4014 WS_VISIBLE |
4011 FS_NOBYTEALIGN, 4015 FS_NOBYTEALIGN,
4012 0,0,2000,1000, 4016 0,0,2000,1000,
4013 NULLHANDLE, 4017 NULLHANDLE,
4014 HWND_TOP, 4018 HWND_TOP,
4015 0L, 4019 0L,
4016 NULL, 4020 NULL,
4017 NULL); 4021 NULL);
4018 4022
4019 newbox->grouphwnd = WinCreateWindow(hwndframe, 4023 newbox->grouphwnd = WinCreateWindow(newbox->hwnd,
4020 WC_STATIC, 4024 WC_STATIC,
4021 title, 4025 title,
4022 WS_VISIBLE | SS_GROUPBOX | 4026 WS_VISIBLE | SS_GROUPBOX |
4023 WS_GROUP, 4027 WS_GROUP,
4024 0,0,2000,1000, 4028 0,0,2000,1000,
4026 HWND_TOP, 4030 HWND_TOP,
4027 0L, 4031 0L,
4028 NULL, 4032 NULL,
4029 NULL); 4033 NULL);
4030 4034
4031 WinSetWindowPtr(hwndframe, QWP_USER, newbox); 4035 WinSetWindowPtr(newbox->hwnd, QWP_USER, newbox);
4032 dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); 4036 dw_window_set_color(newbox->hwnd, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
4033 dw_window_set_color(newbox->grouphwnd, DW_CLR_BLACK, DW_CLR_PALEGRAY); 4037 dw_window_set_color(newbox->grouphwnd, DW_CLR_BLACK, DW_CLR_PALEGRAY);
4034 dw_window_set_font(newbox->grouphwnd, DefaultFont); 4038 dw_window_set_font(newbox->grouphwnd, DefaultFont);
4035 return hwndframe; 4039 return newbox->hwnd;
4036 } 4040 }
4037 4041
4038 /* 4042 /*
4039 * Create a new MDI Frame to be packed. 4043 * Create a new MDI Frame to be packed.
4040 * Parameters: 4044 * Parameters:
5234 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 5238 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
5235 * pad: Number of pixels of padding around the item. 5239 * pad: Number of pixels of padding around the item.
5236 */ 5240 */
5237 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) 5241 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
5238 { 5242 {
5239 Box *thisbox;
5240 char *funcname = "dw_box_pack_end()"; 5243 char *funcname = "dw_box_pack_end()";
5241 5244
5242 /* 5245 /*
5243 * If you try and pack an item into itself VERY bad things can happen; like at least an 5246 * If you try and pack an item into itself VERY bad things can happen; like at least an
5244 * infinite loop on GTK! Lets be safe! 5247 * infinite loop on GTK! Lets be safe!
5250 } 5253 }
5251 5254
5252 if(WinWindowFromID(box, FID_CLIENT)) 5255 if(WinWindowFromID(box, FID_CLIENT))
5253 { 5256 {
5254 box = WinWindowFromID(box, FID_CLIENT); 5257 box = WinWindowFromID(box, FID_CLIENT);
5255 thisbox = WinQueryWindowPtr(box, QWP_USER);
5256 hsize = TRUE; 5258 hsize = TRUE;
5257 vsize = TRUE; 5259 vsize = TRUE;
5258 } 5260 }
5259 else 5261 _dw_box_pack_end(box, item, width, height, hsize, vsize, pad, funcname);
5260 thisbox = WinQueryWindowPtr(box, QWP_USER);
5261 if(thisbox)
5262 {
5263 if(thisbox->type == DW_HORZ)
5264 _dw_box_pack_start(box, item, width, height, hsize, vsize, pad, funcname);
5265 else
5266 _dw_box_pack_end(box, item, width, height, hsize, vsize, pad, funcname);
5267 }
5268 } 5262 }
5269 5263
5270 void _dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname) 5264 void _dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname)
5271 { 5265 {
5272 Box *thisbox = WinQueryWindowPtr(box, QWP_USER); 5266 Box *thisbox = WinQueryWindowPtr(box, QWP_USER);
5280 5274
5281 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); 5275 tmpitem = malloc(sizeof(Item)*(thisbox->count+1));
5282 5276
5283 for(z=0;z<thisbox->count;z++) 5277 for(z=0;z<thisbox->count;z++)
5284 { 5278 {
5285 tmpitem[z] = thisitem[z]; 5279 tmpitem[z+1] = thisitem[z];
5286 } 5280 }
5287 5281
5288 WinQueryClassName(item, 99, tmpbuf); 5282 WinQueryClassName(item, 99, tmpbuf);
5289 5283
5290 if(vsize && !height) 5284 if(vsize && !height)
5291 height = 1; 5285 height = 1;
5292 if(hsize && !width) 5286 if(hsize && !width)
5293 width = 1; 5287 width = 1;
5294 5288
5295 if(strncmp(tmpbuf, "#1", 3)==0) 5289 if(strncmp(tmpbuf, "#1", 3)==0)
5296 tmpitem[thisbox->count].type = TYPEBOX; 5290 tmpitem[0].type = TYPEBOX;
5297 else 5291 else
5298 { 5292 {
5299 if ( width == 0 && hsize == FALSE ) 5293 if ( width == 0 && hsize == FALSE )
5300 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); 5294 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item);
5301 if ( height == 0 && vsize == FALSE ) 5295 if ( height == 0 && vsize == FALSE )
5302 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); 5296 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item);
5303 5297
5304 tmpitem[thisbox->count].type = TYPEITEM; 5298 tmpitem[0].type = TYPEITEM;
5305 } 5299 }
5306 5300
5307 tmpitem[thisbox->count].hwnd = item; 5301 tmpitem[0].hwnd = item;
5308 tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width; 5302 tmpitem[0].origwidth = tmpitem[0].width = width;
5309 tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height; 5303 tmpitem[0].origheight = tmpitem[0].height = height;
5310 tmpitem[thisbox->count].pad = pad; 5304 tmpitem[0].pad = pad;
5311 if(hsize) 5305 if(hsize)
5312 tmpitem[thisbox->count].hsize = SIZEEXPAND; 5306 tmpitem[0].hsize = SIZEEXPAND;
5313 else 5307 else
5314 tmpitem[thisbox->count].hsize = SIZESTATIC; 5308 tmpitem[0].hsize = SIZESTATIC;
5315 5309
5316 if(vsize) 5310 if(vsize)
5317 tmpitem[thisbox->count].vsize = SIZEEXPAND; 5311 tmpitem[0].vsize = SIZEEXPAND;
5318 else 5312 else
5319 tmpitem[thisbox->count].vsize = SIZESTATIC; 5313 tmpitem[0].vsize = SIZESTATIC;
5320 5314
5321 thisbox->items = tmpitem; 5315 thisbox->items = tmpitem;
5322 5316
5323 if(thisbox->count) 5317 if(thisbox->count)
5324 free(thisitem); 5318 free(thisitem);
5325 5319
5326 thisbox->count++; 5320 thisbox->count++;
5327 5321
5328 /* Don't set the ownership if it's an entryfield or spinbutton */
5329 WinQueryClassName(item, 99, tmpbuf); 5322 WinQueryClassName(item, 99, tmpbuf);
5323 /* Don't set the ownership if it's an entryfield or spinbutton */
5330 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0) 5324 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0)
5331 WinSetOwner(item, box); 5325 WinSetOwner(item, box);
5332 WinSetParent(frame ? frame : item, box, FALSE); 5326 WinSetParent(frame ? frame : item, box, FALSE);
5333 } 5327 }
5334 } 5328 }
8031 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 8025 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
8032 * pad: Number of pixels of padding around the item. 8026 * pad: Number of pixels of padding around the item.
8033 */ 8027 */
8034 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) 8028 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
8035 { 8029 {
8036 Box *thisbox;
8037 char *funcname = "dw_box_pack_start()"; 8030 char *funcname = "dw_box_pack_start()";
8038 8031
8039 /* 8032 /*
8040 * If you try and pack an item into itself VERY bad things can happen; like at least an 8033 * If you try and pack an item into itself VERY bad things can happen; like at least an
8041 * infinite loop on GTK! Lets be safe! 8034 * infinite loop on GTK! Lets be safe!
8042 */ 8035 */
8043 if(box == item) 8036 if(box == item)
8044 { 8037 {
8045 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!"); 8038 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
8046 return; 8039 return;
8047 } 8040 }
8048 8041
8049 if(WinWindowFromID(box, FID_CLIENT)) 8042 if(WinWindowFromID(box, FID_CLIENT))
8050 { 8043 {
8051 box = WinWindowFromID(box, FID_CLIENT); 8044 box = WinWindowFromID(box, FID_CLIENT);
8052 thisbox = WinQueryWindowPtr(box, QWP_USER);
8053 hsize = TRUE; 8045 hsize = TRUE;
8054 vsize = TRUE; 8046 vsize = TRUE;
8055 } 8047 }
8056 else 8048 _dw_box_pack_start(box, item, width, height, hsize, vsize, pad, funcname);
8057 thisbox = WinQueryWindowPtr(box, QWP_USER);
8058 if(thisbox)
8059 {
8060 if(thisbox->type == DW_HORZ)
8061 _dw_box_pack_end(box, item, width, height, hsize, vsize, pad, funcname);
8062 else
8063 _dw_box_pack_start(box, item, width, height, hsize, vsize, pad, funcname);
8064 }
8065 } 8049 }
8066 8050
8067 void _dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname) 8051 void _dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad, char *functionname)
8068 { 8052 {
8069 Box *thisbox = WinQueryWindowPtr(box, QWP_USER); 8053 Box *thisbox = WinQueryWindowPtr(box, QWP_USER);
8077 8061
8078 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); 8062 tmpitem = malloc(sizeof(Item)*(thisbox->count+1));
8079 8063
8080 for(z=0;z<thisbox->count;z++) 8064 for(z=0;z<thisbox->count;z++)
8081 { 8065 {
8082 tmpitem[z+1] = thisitem[z]; 8066 tmpitem[z] = thisitem[z];
8083 } 8067 }
8084 8068
8085 WinQueryClassName(item, 99, tmpbuf); 8069 WinQueryClassName(item, 99, tmpbuf);
8086 8070
8087 if(vsize && !height) 8071 if(vsize && !height)
8088 height = 1; 8072 height = 1;
8089 if(hsize && !width) 8073 if(hsize && !width)
8090 width = 1; 8074 width = 1;
8091 8075
8092 if(strncmp(tmpbuf, "#1", 3)==0) 8076 if(strncmp(tmpbuf, "#1", 3)==0)
8093 tmpitem[0].type = TYPEBOX; 8077 tmpitem[thisbox->count].type = TYPEBOX;
8094 else 8078 else
8095 { 8079 {
8096 if ( width == 0 && hsize == FALSE ) 8080 if ( width == 0 && hsize == FALSE )
8097 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); 8081 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item);
8098 if ( height == 0 && vsize == FALSE ) 8082 if ( height == 0 && vsize == FALSE )
8099 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); 8083 dw_messagebox(functionname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item);
8100 8084
8101 tmpitem[0].type = TYPEITEM; 8085 tmpitem[thisbox->count].type = TYPEITEM;
8102 } 8086 }
8103 8087
8104 tmpitem[0].hwnd = item; 8088 tmpitem[thisbox->count].hwnd = item;
8105 tmpitem[0].origwidth = tmpitem[0].width = width; 8089 tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width;
8106 tmpitem[0].origheight = tmpitem[0].height = height; 8090 tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height;
8107 tmpitem[0].pad = pad; 8091 tmpitem[thisbox->count].pad = pad;
8108 if(hsize) 8092 if(hsize)
8109 tmpitem[0].hsize = SIZEEXPAND; 8093 tmpitem[thisbox->count].hsize = SIZEEXPAND;
8110 else 8094 else
8111 tmpitem[0].hsize = SIZESTATIC; 8095 tmpitem[thisbox->count].hsize = SIZESTATIC;
8112 8096
8113 if(vsize) 8097 if(vsize)
8114 tmpitem[0].vsize = SIZEEXPAND; 8098 tmpitem[thisbox->count].vsize = SIZEEXPAND;
8115 else 8099 else
8116 tmpitem[0].vsize = SIZESTATIC; 8100 tmpitem[thisbox->count].vsize = SIZESTATIC;
8117 8101
8118 thisbox->items = tmpitem; 8102 thisbox->items = tmpitem;
8119 8103
8120 if(thisbox->count) 8104 if(thisbox->count)
8121 free(thisitem); 8105 free(thisitem);
8122 8106
8123 thisbox->count++; 8107 thisbox->count++;
8124 8108
8109 /* Don't set the ownership if it's an entryfield or spinbutton */
8125 WinQueryClassName(item, 99, tmpbuf); 8110 WinQueryClassName(item, 99, tmpbuf);
8126 /* Don't set the ownership if it's an entryfield or spinbutton */
8127 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0) 8111 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0)
8128 WinSetOwner(item, box); 8112 WinSetOwner(item, box);
8129 WinSetParent(frame ? frame : item, box, FALSE); 8113 WinSetParent(frame ? frame : item, box, FALSE);
8130 } 8114 }
8131 } 8115 }