comparison 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
comparison
equal deleted inserted replaced
963:ea356c38f7b6 964:6c6b5bbd3a26
1355 else if(strncmp(tmpbuf, ScrollClassName, strlen(ScrollClassName)+1)==0) 1355 else if(strncmp(tmpbuf, ScrollClassName, strlen(ScrollClassName)+1)==0)
1356 { 1356 {
1357 /* Handle special case of scrollbox */ 1357 /* Handle special case of scrollbox */
1358 int cx = width + vectorx; 1358 int cx = width + vectorx;
1359 int cy = height + vectory; 1359 int cy = height + vectory;
1360 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; 1360 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0;
1361 HWND box = (HWND)dw_window_get_data(handle, "_dw_resizebox"); 1361 HWND box = (HWND)dw_window_get_data(handle, "_dw_resizebox");
1362 HWND client = WinWindowFromID(handle, FID_CLIENT); 1362 HWND client = WinWindowFromID(handle, FID_CLIENT);
1363 HWND vscroll = WinWindowFromID(handle, FID_VERTSCROLL); 1363 HWND vscroll = WinWindowFromID(handle, FID_VERTSCROLL);
1364 HWND hscroll = WinWindowFromID(handle, FID_HORZSCROLL); 1364 HWND hscroll = WinWindowFromID(handle, FID_HORZSCROLL);
1365 Box *thisbox = (Box *)WinQueryWindowPtr(box, QWP_USER); 1365 Box *thisbox = (Box *)WinQueryWindowPtr(box, QWP_USER);
1366 int origx, origy; 1366 int origx, origy;
1367 unsigned int hpos = (unsigned int)WinSendMsg(hscroll, SBM_QUERYPOS, 0, 0); 1367 unsigned int hpos = (unsigned int)WinSendMsg(hscroll, SBM_QUERYPOS, 0, 0);
1368 unsigned int vpos = (unsigned int)WinSendMsg(vscroll, SBM_QUERYPOS, 0, 0); 1368 unsigned int vpos = (unsigned int)WinSendMsg(vscroll, SBM_QUERYPOS, 0, 0);
1369 1369
1370 /* Position the scrollbox parts */ 1370 /* Position the scrollbox parts */
1371 WinSetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, cx, cy, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1371 WinSetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, cx, cy, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1372 WinSetWindowPos(client, HWND_TOP, 0, _DW_DEFAULT_SCROLLBAR_WIDTH, cx - _DW_DEFAULT_SCROLLBAR_WIDTH, cy - _DW_DEFAULT_SCROLLBAR_WIDTH, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1372 WinSetWindowPos(client, HWND_TOP, 0, _DW_DEFAULT_SCROLLBAR_WIDTH, cx - _DW_DEFAULT_SCROLLBAR_WIDTH, cy - _DW_DEFAULT_SCROLLBAR_WIDTH, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1373 WinSetWindowPos(hscroll, HWND_TOP, 0, 0, cx - _DW_DEFAULT_SCROLLBAR_WIDTH, _DW_DEFAULT_SCROLLBAR_WIDTH, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1373 WinSetWindowPos(hscroll, HWND_TOP, 0, 0, cx - _DW_DEFAULT_SCROLLBAR_WIDTH, _DW_DEFAULT_SCROLLBAR_WIDTH, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1374 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); 1374 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);
1375 1375
1376 origx = cx = cx - _DW_DEFAULT_SCROLLBAR_WIDTH; 1376 origx = cx = cx - _DW_DEFAULT_SCROLLBAR_WIDTH;
1377 origy = cy = cy - _DW_DEFAULT_SCROLLBAR_WIDTH; 1377 origy = cy = cy - _DW_DEFAULT_SCROLLBAR_WIDTH;
1378 1378
1379 /* Get the required space for the box */ 1379 /* Get the required space for the box */
1380 _resize_box(thisbox, &depth, cx, cy, &usedx, &usedy, 1, &usedpadx, &usedpady); 1380 _resize_box(thisbox, &depth, cx, cy, &usedx, &usedy, 1, &usedpadx, &usedpady);
1381 1381
1382 if(cx < usedx) 1382 if(cx < usedx)
1383 { 1383 {
1384 cx = usedx; 1384 cx = usedx;
1385 } 1385 }
1387 { 1387 {
1388 cy = usedy; 1388 cy = usedy;
1389 } 1389 }
1390 1390
1391 /* Setup vertical scroller */ 1391 /* Setup vertical scroller */
1392 WinSendMsg(vscroll, SBM_SETSCROLLBAR, (MPARAM)vpos, MPFROM2SHORT(0, (unsigned short)usedy - origy)); 1392 WinSendMsg(vscroll, SBM_SETSCROLLBAR, (MPARAM)vpos, MPFROM2SHORT(0, (unsigned short)usedy - origy));
1393 WinSendMsg(vscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT((unsigned short)origy, usedy), 0); 1393 WinSendMsg(vscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT((unsigned short)origy, usedy), 0);
1394 if(vpos > usedy) 1394 if(vpos > usedy)
1395 { 1395 {
1396 vpos = usedy; 1396 vpos = usedy;
1397 WinSendMsg(vscroll, SBM_SETPOS, (MPARAM)vpos, 0); 1397 WinSendMsg(vscroll, SBM_SETPOS, (MPARAM)vpos, 0);
1398 } 1398 }
1399 1399
1400 /* Setup horizontal scroller */ 1400 /* Setup horizontal scroller */
1401 WinSendMsg(hscroll, SBM_SETSCROLLBAR, (MPARAM)hpos, MPFROM2SHORT(0, (unsigned short)usedx - origx)); 1401 WinSendMsg(hscroll, SBM_SETSCROLLBAR, (MPARAM)hpos, MPFROM2SHORT(0, (unsigned short)usedx - origx));
1402 WinSendMsg(hscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT((unsigned short)origx, usedx), 0); 1402 WinSendMsg(hscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT((unsigned short)origx, usedx), 0);
1403 if(hpos > usedx) 1403 if(hpos > usedx)
1404 { 1404 {
1405 hpos = usedx; 1405 hpos = usedx;
1406 WinSendMsg(hscroll, SBM_SETPOS, (MPARAM)hpos, 0); 1406 WinSendMsg(hscroll, SBM_SETPOS, (MPARAM)hpos, 0);
1407 } 1407 }
1408 1408
1409 /* Position the scrolled box */ 1409 /* Position the scrolled box */
1410 WinSetWindowPos(box, HWND_TOP, 0, -(cy - origy), cx, cy, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1410 WinSetWindowPos(box, HWND_TOP, 0, -(cy - origy), cx, cy, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1411 1411
1412 dw_window_set_data(handle, "_dw_cy", (void *)(cy - origy)); 1412 dw_window_set_data(handle, "_dw_cy", (void *)(cy - origy));
1413 1413
1414 /* Layout the content of the scrollbox */ 1414 /* Layout the content of the scrollbox */
1415 _do_resize(thisbox, cx, cy); 1415 _do_resize(thisbox, cx, cy);
4289 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). 4289 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
4290 * pad: Number of pixels to pad around the box. 4290 * pad: Number of pixels to pad around the box.
4291 */ 4291 */
4292 HWND API dw_scrollbox_new(int type, int pad) 4292 HWND API dw_scrollbox_new(int type, int pad)
4293 { 4293 {
4294 HWND hwndframe, box = dw_box_new(type, pad); 4294 HWND hwndframe, box = dw_box_new(type, pad);
4295 HWND client, tmpbox = dw_box_new(DW_VERT, 0); 4295 HWND client, tmpbox = dw_box_new(DW_VERT, 0);
4296 WindowData *blah = calloc(sizeof(WindowData), 1); 4296 WindowData *blah = calloc(sizeof(WindowData), 1);
4297 dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0); 4297 dw_box_pack_start(tmpbox, box, 1, 1, TRUE, TRUE, 0);
4298 hwndframe = WinCreateWindow(HWND_OBJECT, ScrollClassName, "", WS_VISIBLE | WS_CLIPCHILDREN, 4298 hwndframe = WinCreateWindow(HWND_OBJECT, ScrollClassName, "", WS_VISIBLE | WS_CLIPCHILDREN,
4299 0, 0, 2000, 1000, NULLHANDLE, HWND_TOP, 0, NULL, NULL); 4299 0, 0, 2000, 1000, NULLHANDLE, HWND_TOP, 0, NULL, NULL);
4300 WinCreateWindow(hwndframe, WC_SCROLLBAR, "", WS_VISIBLE | SBS_AUTOTRACK | SBS_VERT, 4300 WinCreateWindow(hwndframe, WC_SCROLLBAR, "", WS_VISIBLE | SBS_AUTOTRACK | SBS_VERT,
4301 0,0,2000,1000, hwndframe, HWND_TOP, FID_VERTSCROLL, NULL, NULL); 4301 0,0,2000,1000, hwndframe, HWND_TOP, FID_VERTSCROLL, NULL, NULL);
4302 WinCreateWindow(hwndframe, WC_SCROLLBAR, "", WS_VISIBLE | SBS_AUTOTRACK | SBS_HORZ, 4302 WinCreateWindow(hwndframe, WC_SCROLLBAR, "", WS_VISIBLE | SBS_AUTOTRACK | SBS_HORZ,
4303 0,0,2000,1000, hwndframe, HWND_TOP, FID_HORZSCROLL, NULL, NULL); 4303 0,0,2000,1000, hwndframe, HWND_TOP, FID_HORZSCROLL, NULL, NULL);
4304 client = WinCreateWindow(hwndframe, WC_FRAME, "", WS_VISIBLE | WS_CLIPCHILDREN, 4304 client = WinCreateWindow(hwndframe, WC_FRAME, "", WS_VISIBLE | WS_CLIPCHILDREN,
4305 0,0,2000,1000, NULLHANDLE, HWND_TOP, FID_CLIENT, NULL, NULL); 4305 0,0,2000,1000, NULLHANDLE, HWND_TOP, FID_CLIENT, NULL, NULL);
4306 WinSetParent(tmpbox, client, FALSE); 4306 WinSetParent(tmpbox, client, FALSE);
4307 WinSetWindowPtr(hwndframe, QWP_USER, blah); 4307 WinSetWindowPtr(hwndframe, QWP_USER, blah);
4308 dw_window_set_data(hwndframe, "_dw_resizebox", (void *)tmpbox); 4308 dw_window_set_data(hwndframe, "_dw_resizebox", (void *)tmpbox);
4309 dw_window_set_data(hwndframe, "_dw_box", (void *)box); 4309 dw_window_set_data(hwndframe, "_dw_box", (void *)box);
4310 dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); 4310 dw_window_set_color(hwndframe, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
4311 dw_window_set_color(client, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); 4311 dw_window_set_color(client, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
4312 return hwndframe; 4312 return hwndframe;
4313 } 4313 }
4314 4314
4315 /* 4315 /*
4316 * Returns the position of the scrollbar in the scrollbox 4316 * Returns the position of the scrollbar in the scrollbox
4317 * Parameters: 4317 * Parameters:
4318 * handle: Handle to the scrollbox to be queried. 4318 * handle: Handle to the scrollbox to be queried.
4319 * orient: The vertical or horizontal scrollbar. 4319 * orient: The vertical or horizontal scrollbar.
4320 */ 4320 */
4321 int API dw_scrollbox_get_pos( HWND handle, int orient ) 4321 int API dw_scrollbox_get_pos( HWND handle, int orient )
4322 { 4322 {
4323 HWND scroll; 4323 HWND scroll;
4324 4324
4325 if(orient == DW_VERT) 4325 if(orient == DW_VERT)
4326 { 4326 {
4327 scroll = WinWindowFromID(handle, FID_VERTSCROLL); 4327 scroll = WinWindowFromID(handle, FID_VERTSCROLL);
4328 } 4328 }
4329 else 4329 else
4330 { 4330 {
4331 scroll = WinWindowFromID(handle, FID_HORZSCROLL); 4331 scroll = WinWindowFromID(handle, FID_HORZSCROLL);
4332 } 4332 }
4333 return (int)WinSendMsg(scroll, SBM_QUERYPOS, 0, 0); 4333 return (int)WinSendMsg(scroll, SBM_QUERYPOS, 0, 0);
4334 } 4334 }
4335 4335
4336 /* 4336 /*
4337 * Gets the range for the scrollbar in the scrollbox. 4337 * Gets the range for the scrollbar in the scrollbox.
4338 * Parameters: 4338 * Parameters:
4339 * handle: Handle to the scrollbox to be queried. 4339 * handle: Handle to the scrollbox to be queried.
4340 * orient: The vertical or horizontal scrollbar. 4340 * orient: The vertical or horizontal scrollbar.
4341 */ 4341 */
4342 int API dw_scrollbox_get_range( HWND handle, int orient ) 4342 int API dw_scrollbox_get_range( HWND handle, int orient )
4343 { 4343 {
4344 HWND scroll; 4344 HWND scroll;
4345 4345
4346 if(orient == DW_VERT) 4346 if(orient == DW_VERT)
4347 { 4347 {
4348 scroll = WinWindowFromID(handle, FID_VERTSCROLL); 4348 scroll = WinWindowFromID(handle, FID_VERTSCROLL);
4349 } 4349 }
4350 else 4350 else
4351 { 4351 {
4352 scroll = WinWindowFromID(handle, FID_HORZSCROLL); 4352 scroll = WinWindowFromID(handle, FID_HORZSCROLL);
4353 } 4353 }
4354 return SHORT2FROMMP(WinSendMsg(scroll, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0)); 4354 return SHORT2FROMMP(WinSendMsg(scroll, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0));
4355 } 4355 }
4356 4356
4357 /* 4357 /*
4358 * Create a new Group Box to be packed. 4358 * Create a new Group Box to be packed.
4359 * Parameters: 4359 * Parameters: