Mercurial > dwindows
comparison win/dw.c @ 22:6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
on OS/2 and Win32. Added another function to compat to deal with MSVC
runtime library conflicts.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 02 Aug 2001 09:57:21 +0000 |
parents | f26eced21a30 |
children | b1d7e8a28dfa |
comparison
equal
deleted
inserted
replaced
21:c6e76b796b28 | 22:6a246b3bb14f |
---|---|
35 | 35 |
36 int main(int argc, char *argv[]); | 36 int main(int argc, char *argv[]); |
37 | 37 |
38 #define ICON_INDEX_LIMIT 200 | 38 #define ICON_INDEX_LIMIT 200 |
39 HICON lookup[200]; | 39 HICON lookup[200]; |
40 HIMAGELIST hSmall, hLarge; | 40 HIMAGELIST hSmall = 0, hLarge = 0; |
41 | 41 |
42 #define THREAD_LIMIT 128 | 42 #define THREAD_LIMIT 128 |
43 COLORREF _foreground[THREAD_LIMIT]; | 43 COLORREF _foreground[THREAD_LIMIT]; |
44 COLORREF _background[THREAD_LIMIT]; | 44 COLORREF _background[THREAD_LIMIT]; |
45 HPEN _hPen[THREAD_LIMIT]; | 45 HPEN _hPen[THREAD_LIMIT]; |
70 DW_CLR_PALEGRAY, | 70 DW_CLR_PALEGRAY, |
71 DW_CLR_WHITE | 71 DW_CLR_WHITE |
72 }; | 72 }; |
73 | 73 |
74 void _resize_notebook_page(HWND handle, int pageid); | 74 void _resize_notebook_page(HWND handle, int pageid); |
75 int _lookup_icon(HWND handle, HICON hicon, int type); | |
75 | 76 |
76 #ifdef NO_SIGNALS | 77 #ifdef NO_SIGNALS |
77 #define USE_FILTER | 78 #define USE_FILTER |
78 #else | 79 #else |
79 typedef struct _sighandler | 80 typedef struct _sighandler |
670 | 671 |
671 if(thisbox->type == BOXHORZ) | 672 if(thisbox->type == BOXHORZ) |
672 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); | 673 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); |
673 else | 674 else |
674 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); | 675 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); |
676 | |
677 if(thisbox->items[z].type == TYPEBOX) | |
678 { | |
679 Box *tmp = (Box *)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA); | |
680 | |
681 if(tmp) | |
682 { | |
683 tmp->parentxratio = thisbox->items[z].xratio; | |
684 tmp->parentyratio = thisbox->items[z].yratio; | |
685 } | |
686 } | |
687 | |
675 #ifdef DWDEBUG | 688 #ifdef DWDEBUG |
676 fprintf(f, "RATIO- xratio = %f, yratio = %f, width = %d, height = %d, pad = %d, box xratio = %f, box yratio = %f, parent xratio = %f, parent yratio = %f, minwidth = %d, minheight = %d, width = %d, height = %d, upx = %d, upy = %d\r\n\r\n", | 689 fprintf(f, "RATIO- xratio = %f, yratio = %f, width = %d, height = %d, pad = %d, box xratio = %f, box yratio = %f, parent xratio = %f, parent yratio = %f, minwidth = %d, minheight = %d, width = %d, height = %d, upx = %d, upy = %d\r\n\r\n", |
677 thisbox->items[z].xratio, thisbox->items[z].yratio, thisbox->items[z].width, thisbox->items[z].height, thisbox->items[z].pad, thisbox->xratio, thisbox->yratio, thisbox->parentxratio, thisbox->parentyratio, thisbox->minwidth, thisbox->minheight, thisbox->width, thisbox->height, thisbox->upx, thisbox->upy); | 690 thisbox->items[z].xratio, thisbox->items[z].yratio, thisbox->items[z].width, thisbox->items[z].height, thisbox->items[z].pad, thisbox->xratio, thisbox->yratio, thisbox->parentxratio, thisbox->parentyratio, thisbox->minwidth, thisbox->minheight, thisbox->width, thisbox->height, thisbox->upx, thisbox->upy); |
678 reopen(); | 691 reopen(); |
679 #endif | 692 #endif |
1233 */ | 1246 */ |
1234 _free_window_memory(hWnd, 0); | 1247 _free_window_memory(hWnd, 0); |
1235 EnumChildWindows(hWnd, _free_window_memory, 0); | 1248 EnumChildWindows(hWnd, _free_window_memory, 0); |
1236 #endif | 1249 #endif |
1237 break; | 1250 break; |
1238 } | |
1239 if(filterfunc && result != -1) | |
1240 return result; | |
1241 else | |
1242 return DefWindowProc(hWnd, msg, mp1, mp2); | |
1243 } | |
1244 | |
1245 BOOL CALLBACK _framewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | |
1246 { | |
1247 switch( msg ) | |
1248 { | |
1249 case WM_LBUTTONDOWN: | |
1250 case WM_MBUTTONDOWN: | |
1251 case WM_RBUTTONDOWN: | |
1252 SetActiveWindow(hWnd); | |
1253 break; | |
1254 case WM_COMMAND: | |
1255 case WM_NOTIFY: | |
1256 _wndproc(hWnd, msg, mp1, mp2); | |
1257 break; | |
1258 } | |
1259 return DefWindowProc(hWnd, msg, mp1, mp2); | |
1260 } | |
1261 | |
1262 BOOL CALLBACK _rendwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | |
1263 { | |
1264 switch( msg ) | |
1265 { | |
1266 case WM_LBUTTONDOWN: | |
1267 case WM_MBUTTONDOWN: | |
1268 case WM_RBUTTONDOWN: | |
1269 SetActiveWindow(hWnd); | |
1270 _wndproc(hWnd, msg, mp1, mp2); | |
1271 break; | |
1272 case WM_LBUTTONUP: | |
1273 case WM_MBUTTONUP: | |
1274 case WM_RBUTTONUP: | |
1275 case WM_MOUSEMOVE: | |
1276 case WM_PAINT: | |
1277 case WM_SIZE: | |
1278 case WM_COMMAND: | |
1279 _wndproc(hWnd, msg, mp1, mp2); | |
1280 break; | |
1281 } | |
1282 return DefWindowProc(hWnd, msg, mp1, mp2); | |
1283 } | |
1284 | |
1285 BOOL CALLBACK _spinnerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | |
1286 { | |
1287 ColorInfo *cinfo; | |
1288 | |
1289 cinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA); | |
1290 | |
1291 if(cinfo) | |
1292 { | |
1293 switch( msg ) | |
1294 { | |
1295 case WM_LBUTTONDOWN: | |
1296 case WM_MBUTTONDOWN: | |
1297 case WM_RBUTTONDOWN: | |
1298 case WM_CHAR: | |
1299 { | |
1300 BOOL ret; | |
1301 | |
1302 if(!cinfo || !cinfo->pOldProc) | |
1303 ret = DefWindowProc(hWnd, msg, mp1, mp2); | |
1304 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); | |
1305 | |
1306 /* Tell the edit control that a buttonpress has | |
1307 * occured and to update it's window title. | |
1308 */ | |
1309 if(cinfo->buddy) | |
1310 SendMessage(cinfo->buddy, WM_USER+10, 0, 0); | |
1311 | |
1312 return ret; | |
1313 } | |
1314 break; | |
1315 case WM_USER+10: | |
1316 { | |
1317 if(cinfo->buddy) | |
1318 { | |
1319 char tempbuf[100] = ""; | |
1320 long position; | |
1321 | |
1322 GetWindowText(cinfo->buddy, tempbuf, 99); | |
1323 | |
1324 position = atol(tempbuf); | |
1325 | |
1326 if(IS_WIN98PLUS) | |
1327 SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position); | |
1328 else | |
1329 SendMessage(hWnd, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0)); | |
1330 } | |
1331 } | |
1332 break; | |
1333 } | |
1334 } | |
1335 | |
1336 if(!cinfo || !cinfo->pOldProc) | |
1337 return DefWindowProc(hWnd, msg, mp1, mp2); | |
1338 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); | |
1339 } | |
1340 | |
1341 BOOL CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | |
1342 { | |
1343 ColorInfo *cinfo; | |
1344 char tmpbuf[100]; | |
1345 | |
1346 cinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA); | |
1347 | |
1348 GetClassName(hWnd, tmpbuf, 99); | |
1349 if(strcmp(tmpbuf, FRAMECLASSNAME) == 0) | |
1350 cinfo = &(((Box *)cinfo)->cinfo); | |
1351 | |
1352 if(cinfo) | |
1353 { | |
1354 switch( msg ) | |
1355 { | |
1356 case WM_CHAR: | |
1357 if(LOWORD(mp1) == '\t') | |
1358 { | |
1359 if(cinfo->buddy) | |
1360 _shift_focus(cinfo->buddy); | |
1361 else | |
1362 _shift_focus(hWnd); | |
1363 return FALSE; | |
1364 } | |
1365 /* Tell the spinner control that a keypress has | |
1366 * occured and to update it's internal value. | |
1367 */ | |
1368 if(cinfo->buddy) | |
1369 SendMessage(cinfo->buddy, WM_USER+10, 0, 0); | |
1370 break; | |
1371 case WM_USER+10: | |
1372 { | |
1373 if(cinfo->buddy) | |
1374 { | |
1375 long val, position; | |
1376 char tmpbuf[100] = ""; | |
1377 | |
1378 GetWindowText(cinfo->buddy, tmpbuf, 99); | |
1379 | |
1380 position = atol(tmpbuf); | |
1381 | |
1382 if(IS_WIN98PLUS) | |
1383 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0); | |
1384 else | |
1385 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS, 0, 0); | |
1386 | |
1387 if(val != position) | |
1388 { | |
1389 sprintf(tmpbuf, "%d", val); | |
1390 SetWindowText(hWnd, tmpbuf); | |
1391 } | |
1392 } | |
1393 } | |
1394 break; | |
1395 case WM_KEYUP: | |
1396 { | |
1397 if(mp1 == VK_UP || mp1 == VK_DOWN) | |
1398 { | |
1399 if(cinfo->buddy) | |
1400 PostMessage(hWnd, WM_USER+10, 0, 0); | |
1401 } | |
1402 } | |
1403 break; | |
1404 case WM_CTLCOLORSTATIC: | 1251 case WM_CTLCOLORSTATIC: |
1405 case WM_CTLCOLORLISTBOX: | 1252 case WM_CTLCOLORLISTBOX: |
1406 case WM_CTLCOLORBTN: | 1253 case WM_CTLCOLORBTN: |
1407 case WM_CTLCOLOREDIT: | 1254 case WM_CTLCOLOREDIT: |
1408 case WM_CTLCOLORMSGBOX: | 1255 case WM_CTLCOLORMSGBOX: |
1409 case WM_CTLCOLORSCROLLBAR: | 1256 case WM_CTLCOLORSCROLLBAR: |
1257 case WM_CTLCOLORDLG: | |
1410 { | 1258 { |
1411 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA); | 1259 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA); |
1412 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) | 1260 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) |
1413 { | 1261 { |
1414 if(thiscinfo->fore > -1 && thiscinfo->back > -1 && | 1262 if(thiscinfo->fore > -1 && thiscinfo->back > -1 && |
1418 _green[thiscinfo->fore], | 1266 _green[thiscinfo->fore], |
1419 _blue[thiscinfo->fore])); | 1267 _blue[thiscinfo->fore])); |
1420 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], | 1268 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], |
1421 _green[thiscinfo->back], | 1269 _green[thiscinfo->back], |
1422 _blue[thiscinfo->back])); | 1270 _blue[thiscinfo->back])); |
1423 SelectObject((HDC)mp1, _colors[thiscinfo->back]); | 1271 DeleteObject(thiscinfo->hbrush); |
1424 return (LONG)_colors[thiscinfo->back]; | 1272 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], |
1273 _green[thiscinfo->back], | |
1274 _blue[thiscinfo->back])); | |
1275 SelectObject((HDC)mp1, thiscinfo->hbrush); | |
1276 return (LONG)thiscinfo->hbrush; | |
1425 } | 1277 } |
1426 if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) | 1278 if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) |
1427 { | 1279 { |
1428 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), | 1280 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), |
1429 DW_GREEN_VALUE(thiscinfo->fore), | 1281 DW_GREEN_VALUE(thiscinfo->fore), |
1440 } | 1292 } |
1441 } | 1293 } |
1442 | 1294 |
1443 } | 1295 } |
1444 break; | 1296 break; |
1297 } | |
1298 if(result != -1) | |
1299 return result; | |
1300 else | |
1301 return DefWindowProc(hWnd, msg, mp1, mp2); | |
1302 } | |
1303 | |
1304 BOOL CALLBACK _framewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | |
1305 { | |
1306 switch( msg ) | |
1307 { | |
1308 case WM_LBUTTONDOWN: | |
1309 case WM_MBUTTONDOWN: | |
1310 case WM_RBUTTONDOWN: | |
1311 SetActiveWindow(hWnd); | |
1312 break; | |
1313 case WM_COMMAND: | |
1314 case WM_NOTIFY: | |
1315 _wndproc(hWnd, msg, mp1, mp2); | |
1316 break; | |
1317 } | |
1318 return DefWindowProc(hWnd, msg, mp1, mp2); | |
1319 } | |
1320 | |
1321 BOOL CALLBACK _rendwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | |
1322 { | |
1323 switch( msg ) | |
1324 { | |
1325 case WM_LBUTTONDOWN: | |
1326 case WM_MBUTTONDOWN: | |
1327 case WM_RBUTTONDOWN: | |
1328 SetActiveWindow(hWnd); | |
1329 _wndproc(hWnd, msg, mp1, mp2); | |
1330 break; | |
1331 case WM_LBUTTONUP: | |
1332 case WM_MBUTTONUP: | |
1333 case WM_RBUTTONUP: | |
1334 case WM_MOUSEMOVE: | |
1335 case WM_PAINT: | |
1336 case WM_SIZE: | |
1337 case WM_COMMAND: | |
1338 _wndproc(hWnd, msg, mp1, mp2); | |
1339 break; | |
1340 } | |
1341 return DefWindowProc(hWnd, msg, mp1, mp2); | |
1342 } | |
1343 | |
1344 BOOL CALLBACK _spinnerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | |
1345 { | |
1346 ColorInfo *cinfo; | |
1347 | |
1348 cinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA); | |
1349 | |
1350 if(cinfo) | |
1351 { | |
1352 switch( msg ) | |
1353 { | |
1354 case WM_LBUTTONDOWN: | |
1355 case WM_MBUTTONDOWN: | |
1356 case WM_RBUTTONDOWN: | |
1357 case WM_CHAR: | |
1358 { | |
1359 BOOL ret; | |
1360 | |
1361 if(!cinfo || !cinfo->pOldProc) | |
1362 ret = DefWindowProc(hWnd, msg, mp1, mp2); | |
1363 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); | |
1364 | |
1365 /* Tell the edit control that a buttonpress has | |
1366 * occured and to update it's window title. | |
1367 */ | |
1368 if(cinfo->buddy) | |
1369 SendMessage(cinfo->buddy, WM_USER+10, 0, 0); | |
1370 | |
1371 return ret; | |
1372 } | |
1373 break; | |
1374 case WM_USER+10: | |
1375 { | |
1376 if(cinfo->buddy) | |
1377 { | |
1378 char tempbuf[100] = ""; | |
1379 long position; | |
1380 | |
1381 GetWindowText(cinfo->buddy, tempbuf, 99); | |
1382 | |
1383 position = atol(tempbuf); | |
1384 | |
1385 if(IS_WIN98PLUS) | |
1386 SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position); | |
1387 else | |
1388 SendMessage(hWnd, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0)); | |
1389 } | |
1390 } | |
1391 break; | |
1392 } | |
1393 } | |
1394 | |
1395 if(!cinfo || !cinfo->pOldProc) | |
1396 return DefWindowProc(hWnd, msg, mp1, mp2); | |
1397 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); | |
1398 } | |
1399 | |
1400 BOOL CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | |
1401 { | |
1402 ColorInfo *cinfo; | |
1403 char tmpbuf[100]; | |
1404 | |
1405 cinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA); | |
1406 | |
1407 GetClassName(hWnd, tmpbuf, 99); | |
1408 if(strcmp(tmpbuf, FRAMECLASSNAME) == 0) | |
1409 cinfo = &(((Box *)cinfo)->cinfo); | |
1410 | |
1411 if(cinfo) | |
1412 { | |
1413 switch( msg ) | |
1414 { | |
1415 case WM_CHAR: | |
1416 if(LOWORD(mp1) == '\t') | |
1417 { | |
1418 if(cinfo->buddy) | |
1419 _shift_focus(cinfo->buddy); | |
1420 else | |
1421 _shift_focus(hWnd); | |
1422 return FALSE; | |
1423 } | |
1424 /* Tell the spinner control that a keypress has | |
1425 * occured and to update it's internal value. | |
1426 */ | |
1427 if(cinfo->buddy) | |
1428 SendMessage(cinfo->buddy, WM_USER+10, 0, 0); | |
1429 break; | |
1430 case WM_USER+10: | |
1431 { | |
1432 if(cinfo->buddy) | |
1433 { | |
1434 long val, position; | |
1435 char tmpbuf[100] = ""; | |
1436 | |
1437 GetWindowText(cinfo->buddy, tmpbuf, 99); | |
1438 | |
1439 position = atol(tmpbuf); | |
1440 | |
1441 if(IS_WIN98PLUS) | |
1442 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0); | |
1443 else | |
1444 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS, 0, 0); | |
1445 | |
1446 if(val != position) | |
1447 { | |
1448 sprintf(tmpbuf, "%d", val); | |
1449 SetWindowText(hWnd, tmpbuf); | |
1450 } | |
1451 } | |
1452 } | |
1453 break; | |
1454 case WM_KEYUP: | |
1455 { | |
1456 if(mp1 == VK_UP || mp1 == VK_DOWN) | |
1457 { | |
1458 if(cinfo->buddy) | |
1459 PostMessage(hWnd, WM_USER+10, 0, 0); | |
1460 } | |
1461 } | |
1462 break; | |
1463 case WM_CTLCOLORSTATIC: | |
1464 case WM_CTLCOLORLISTBOX: | |
1465 case WM_CTLCOLORBTN: | |
1466 case WM_CTLCOLOREDIT: | |
1467 case WM_CTLCOLORMSGBOX: | |
1468 case WM_CTLCOLORSCROLLBAR: | |
1469 case WM_CTLCOLORDLG: | |
1470 { | |
1471 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA); | |
1472 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) | |
1473 { | |
1474 if(thiscinfo->fore > -1 && thiscinfo->back > -1 && | |
1475 thiscinfo->fore < 18 && thiscinfo->back < 18) | |
1476 { | |
1477 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], | |
1478 _green[thiscinfo->fore], | |
1479 _blue[thiscinfo->fore])); | |
1480 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], | |
1481 _green[thiscinfo->back], | |
1482 _blue[thiscinfo->back])); | |
1483 DeleteObject(thiscinfo->hbrush); | |
1484 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], | |
1485 _green[thiscinfo->back], | |
1486 _blue[thiscinfo->back])); | |
1487 SelectObject((HDC)mp1, thiscinfo->hbrush); | |
1488 return (LONG)thiscinfo->hbrush; | |
1489 } | |
1490 if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) | |
1491 { | |
1492 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), | |
1493 DW_GREEN_VALUE(thiscinfo->fore), | |
1494 DW_BLUE_VALUE(thiscinfo->fore))); | |
1495 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), | |
1496 DW_GREEN_VALUE(thiscinfo->back), | |
1497 DW_BLUE_VALUE(thiscinfo->back))); | |
1498 DeleteObject(thiscinfo->hbrush); | |
1499 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back), | |
1500 DW_GREEN_VALUE(thiscinfo->back), | |
1501 DW_BLUE_VALUE(thiscinfo->back))); | |
1502 SelectObject((HDC)mp1, thiscinfo->hbrush); | |
1503 return (LONG)thiscinfo->hbrush; | |
1504 } | |
1505 } | |
1506 | |
1507 } | |
1508 break; | |
1445 } | 1509 } |
1446 } | 1510 } |
1447 | 1511 |
1448 if(!cinfo || !cinfo->pOldProc) | 1512 if(!cinfo || !cinfo->pOldProc) |
1449 return DefWindowProc(hWnd, msg, mp1, mp2); | 1513 return DefWindowProc(hWnd, msg, mp1, mp2); |
1803 oldBrush = _hBrush[threadid]; | 1867 oldBrush = _hBrush[threadid]; |
1804 oldPen = _hPen[threadid]; | 1868 oldPen = _hPen[threadid]; |
1805 | 1869 |
1806 dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy); | 1870 dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy); |
1807 | 1871 |
1808 _hBrush[threadid] = GetStockObject(LTGRAY_BRUSH); | 1872 |
1873 _hBrush[threadid] = CreateSolidBrush(GetSysColor(COLOR_3DFACE)); | |
1809 | 1874 |
1810 dw_draw_rect(hwnd, 0, TRUE, 0, 0, cx, cy); | 1875 dw_draw_rect(hwnd, 0, TRUE, 0, 0, cx, cy); |
1811 | 1876 |
1812 _hPen[threadid] = CreatePen(PS_SOLID, 1, RGB(_red[DW_CLR_DARKGRAY], | 1877 _hPen[threadid] = CreatePen(PS_SOLID, 1, RGB(_red[DW_CLR_DARKGRAY], |
1813 _green[DW_CLR_DARKGRAY], | 1878 _green[DW_CLR_DARKGRAY], |
1837 | 1902 |
1838 ExtTextOut(hdcPaint, 3, 1, ETO_CLIPPED, &rc, tempbuf, strlen(tempbuf), NULL); | 1903 ExtTextOut(hdcPaint, 3, 1, ETO_CLIPPED, &rc, tempbuf, strlen(tempbuf), NULL); |
1839 | 1904 |
1840 SelectObject(hdcPaint, hFont); | 1905 SelectObject(hdcPaint, hFont); |
1841 | 1906 |
1907 DeleteObject(_hBrush[threadid]); | |
1842 _hBrush[threadid] = oldBrush; | 1908 _hBrush[threadid] = oldBrush; |
1843 _hPen[threadid] = oldPen; | 1909 _hPen[threadid] = oldPen; |
1844 ReleaseDC(hwnd, hdcPaint); | 1910 ReleaseDC(hwnd, hdcPaint); |
1845 } | 1911 } |
1846 return FALSE; | 1912 return FALSE; |
2177 _background[z] = 0; | 2243 _background[z] = 0; |
2178 _hPen[z] = CreatePen(PS_SOLID, 1, _foreground[z]); | 2244 _hPen[z] = CreatePen(PS_SOLID, 1, _foreground[z]); |
2179 _hBrush[z] = CreateSolidBrush(_foreground[z]); | 2245 _hBrush[z] = CreateSolidBrush(_foreground[z]); |
2180 } | 2246 } |
2181 | 2247 |
2248 #if 0 | |
2249 { | |
2250 DWORD dwResult = GetSysColor(COLOR_3DFACE); | |
2251 | |
2252 dw_messagebox("DW", | |
2253 "Window color: {%x, %x, %x}", | |
2254 GetRValue(dwResult), | |
2255 GetGValue(dwResult), | |
2256 GetBValue(dwResult)); | |
2257 } | |
2258 #endif | |
2182 return 0; | 2259 return 0; |
2183 } | 2260 } |
2184 | 2261 |
2185 /* | 2262 /* |
2186 * Runs a message loop for Dynamic Windows. | 2263 * Runs a message loop for Dynamic Windows. |
2303 * Returns: | 2380 * Returns: |
2304 * True if YES False of NO. | 2381 * True if YES False of NO. |
2305 */ | 2382 */ |
2306 int dw_yesno(char *title, char *text) | 2383 int dw_yesno(char *title, char *text) |
2307 { | 2384 { |
2308 if(MessageBox(HWND_DESKTOP, text, title, MB_YESNO)==IDYES) | 2385 if(MessageBox(HWND_DESKTOP, text, title, MB_YESNO) == IDYES) |
2309 return TRUE; | 2386 return TRUE; |
2310 return FALSE; | 2387 return FALSE; |
2311 } | 2388 } |
2312 | 2389 |
2313 /* | 2390 /* |
2518 { | 2595 { |
2519 ReleaseCapture(); | 2596 ReleaseCapture(); |
2520 } | 2597 } |
2521 | 2598 |
2522 /* | 2599 /* |
2600 * Changes the appearance of the mouse pointer. | |
2601 * Parameters: | |
2602 * handle: Handle to widget for which to change. | |
2603 * cursortype: ID of the pointer you want. | |
2604 */ | |
2605 void dw_window_pointer(HWND handle, int pointertype) | |
2606 { | |
2607 SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(pointertype))); | |
2608 } | |
2609 | |
2610 /* | |
2523 * Create a new Window Frame. | 2611 * Create a new Window Frame. |
2524 * Parameters: | 2612 * Parameters: |
2525 * owner: The Owner's window handle or HWND_DESKTOP. | 2613 * owner: The Owner's window handle or HWND_DESKTOP. |
2526 * title: The Window title. | 2614 * title: The Window title. |
2527 * flStyle: Style flags, see the DW reference. | 2615 * flStyle: Style flags, see the DW reference. |
2889 dw_window_set_font(tmp, DefaultFont); | 2977 dw_window_set_font(tmp, DefaultFont); |
2890 return tmp; | 2978 return tmp; |
2891 } | 2979 } |
2892 | 2980 |
2893 /* | 2981 /* |
2982 * Create a tree object to be packed. | |
2983 * Parameters: | |
2984 * id: An ID to be used for getting the resource from the | |
2985 * resource file. | |
2986 */ | |
2987 HWND dw_tree_new(ULONG id) | |
2988 { | |
2989 HWND tmp = CreateWindow(WC_TREEVIEW, | |
2990 "", | |
2991 WS_CHILD | TVS_HASLINES | | |
2992 TVS_HASBUTTONS | TVS_LINESATROOT | | |
2993 WS_BORDER | WS_CLIPCHILDREN, | |
2994 0,0,2000,1000, | |
2995 DW_HWND_OBJECT, | |
2996 (HMENU)id, | |
2997 NULL, | |
2998 NULL); | |
2999 TreeView_SetItemHeight(tmp, 16); | |
3000 dw_window_set_font(tmp, DefaultFont); | |
3001 return tmp; | |
3002 } | |
3003 | |
3004 /* | |
2894 * Returns the current X and Y coordinates of the mouse pointer. | 3005 * Returns the current X and Y coordinates of the mouse pointer. |
2895 * Parameters: | 3006 * Parameters: |
2896 * x: Pointer to variable to store X coordinate. | 3007 * x: Pointer to variable to store X coordinate. |
2897 * y: Pointer to variable to store Y coordinate. | 3008 * y: Pointer to variable to store Y coordinate. |
2898 */ | 3009 */ |
2968 HWND dw_mle_new(ULONG id) | 3079 HWND dw_mle_new(ULONG id) |
2969 { | 3080 { |
2970 | 3081 |
2971 HWND tmp = CreateWindow(EDITCLASSNAME, | 3082 HWND tmp = CreateWindow(EDITCLASSNAME, |
2972 "", | 3083 "", |
2973 WS_BORDER | ES_AUTOHSCROLL | | 3084 WS_BORDER | |
2974 WS_VSCROLL | ES_MULTILINE | | 3085 WS_VSCROLL | ES_MULTILINE | |
2975 ES_WANTRETURN | WS_CHILD | | 3086 ES_WANTRETURN | WS_CHILD | |
2976 WS_CLIPCHILDREN, | 3087 WS_CLIPCHILDREN, |
2977 0,0,2000,1000, | 3088 0,0,2000,1000, |
2978 DW_HWND_OBJECT, | 3089 DW_HWND_OBJECT, |
4142 * handle: Handle to the MLE. | 4253 * handle: Handle to the MLE. |
4143 * state: TRUE if it wraps, FALSE if it doesn't. | 4254 * state: TRUE if it wraps, FALSE if it doesn't. |
4144 */ | 4255 */ |
4145 void dw_mle_set_word_wrap(HWND handle, int state) | 4256 void dw_mle_set_word_wrap(HWND handle, int state) |
4146 { | 4257 { |
4258 /* If ES_AUTOHSCROLL is not set and there is not | |
4259 * horizontal scrollbar it word wraps. | |
4260 */ | |
4261 if(state) | |
4262 dw_window_set_style(handle, 0, ES_AUTOHSCROLL); | |
4263 else | |
4264 dw_window_set_style(handle, ES_AUTOHSCROLL, ES_AUTOHSCROLL); | |
4147 } | 4265 } |
4148 | 4266 |
4149 /* | 4267 /* |
4150 * Sets the current cursor position of an MLE box. | 4268 * Sets the current cursor position of an MLE box. |
4151 * Parameters: | 4269 * Parameters: |
4329 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); | 4447 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); |
4330 | 4448 |
4331 if(cinfo && !cinfo->user) | 4449 if(cinfo && !cinfo->user) |
4332 SendMessage(handle, BM_CLICK, 0, 0); | 4450 SendMessage(handle, BM_CLICK, 0, 0); |
4333 SendMessage(handle, BM_SETCHECK, (WPARAM)value, 0); | 4451 SendMessage(handle, BM_SETCHECK, (WPARAM)value, 0); |
4452 } | |
4453 | |
4454 /* | |
4455 * Inserts an item into a tree window (widget). | |
4456 * Parameters: | |
4457 * handle: Handle to the tree to be inserted. | |
4458 * title: The text title of the entry. | |
4459 * icon: Handle to coresponding icon. | |
4460 * parent: Parent handle or 0 if root. | |
4461 */ | |
4462 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent) | |
4463 { | |
4464 TVITEM tvi; | |
4465 TVINSERTSTRUCT tvins; | |
4466 HTREEITEM hti; | |
4467 | |
4468 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE ; | |
4469 tvi.pszText = title; | |
4470 tvi.cchTextMax = strlen(title); | |
4471 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1); | |
4472 | |
4473 tvins.item = tvi; | |
4474 tvins.hParent = (HTREEITEM)parent; | |
4475 tvins.hInsertAfter = TVI_LAST; | |
4476 | |
4477 hti = TreeView_InsertItem(handle, &tvins); | |
4478 | |
4479 return (HWND)hti; | |
4334 } | 4480 } |
4335 | 4481 |
4336 /* | 4482 /* |
4337 * Sets up the container columns. | 4483 * Sets up the container columns. |
4338 * Parameters: | 4484 * Parameters: |
4432 LV_ITEM lvi; | 4578 LV_ITEM lvi; |
4433 int z; | 4579 int z; |
4434 | 4580 |
4435 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT; | 4581 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT; |
4436 lvi.iSubItem = 0; | 4582 lvi.iSubItem = 0; |
4583 /* Insert at the end */ | |
4584 lvi.iItem = 1000000; | |
4437 lvi.pszText = ""; | 4585 lvi.pszText = ""; |
4438 lvi.cchTextMax = 1; | 4586 lvi.cchTextMax = 1; |
4439 | 4587 |
4440 for(z=0;z<rowcount;z++) | 4588 for(z=0;z<rowcount;z++) |
4441 ListView_InsertItem(handle, &lvi); | 4589 ListView_InsertItem(handle, &lvi); |
4443 } | 4591 } |
4444 | 4592 |
4445 /* Finds a icon in the table, otherwise it adds it to the table | 4593 /* Finds a icon in the table, otherwise it adds it to the table |
4446 * and returns the index in the table. | 4594 * and returns the index in the table. |
4447 */ | 4595 */ |
4448 int _lookup_icon(HWND handle, HICON hicon) | 4596 int _lookup_icon(HWND handle, HICON hicon, int type) |
4449 { | 4597 { |
4450 int z; | 4598 int z; |
4451 static HWND lasthwnd = NULL; | 4599 static HWND lasthwnd = NULL; |
4452 | 4600 |
4453 if(!lookup[0]) | 4601 if(!hSmall || !hLarge) |
4454 { | 4602 { |
4455 hSmall = ImageList_Create(16, 16, FALSE, ICON_INDEX_LIMIT, 0); | 4603 hSmall = ImageList_Create(16, 16, FALSE, ICON_INDEX_LIMIT, 0); |
4456 hLarge = ImageList_Create(32, 32, FALSE, ICON_INDEX_LIMIT, 0); | 4604 hLarge = ImageList_Create(32, 32, FALSE, ICON_INDEX_LIMIT, 0); |
4457 } | 4605 } |
4458 for(z=0;z<ICON_INDEX_LIMIT;z++) | 4606 for(z=0;z<ICON_INDEX_LIMIT;z++) |
4460 if(!lookup[z]) | 4608 if(!lookup[z]) |
4461 { | 4609 { |
4462 lookup[z] = hicon; | 4610 lookup[z] = hicon; |
4463 ImageList_AddIcon(hSmall, hicon); | 4611 ImageList_AddIcon(hSmall, hicon); |
4464 ImageList_AddIcon(hLarge, hicon); | 4612 ImageList_AddIcon(hLarge, hicon); |
4465 ListView_SetImageList(handle, hSmall, LVSIL_SMALL); | 4613 if(type) |
4466 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL); | 4614 { |
4615 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL); | |
4616 } | |
4617 else | |
4618 { | |
4619 ListView_SetImageList(handle, hSmall, LVSIL_SMALL); | |
4620 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL); | |
4621 } | |
4467 lasthwnd = handle; | 4622 lasthwnd = handle; |
4468 return z; | 4623 return z; |
4469 } | 4624 } |
4470 | 4625 |
4471 if(hicon == lookup[z]) | 4626 if(hicon == lookup[z]) |
4472 { | 4627 { |
4473 if(lasthwnd != handle) | 4628 if(lasthwnd != handle) |
4474 { | 4629 { |
4475 ListView_SetImageList(handle, hSmall, LVSIL_SMALL); | 4630 if(type) |
4476 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL); | 4631 { |
4632 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL); | |
4633 } | |
4634 else | |
4635 { | |
4636 ListView_SetImageList(handle, hSmall, LVSIL_SMALL); | |
4637 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL); | |
4638 } | |
4477 lasthwnd = handle; | 4639 lasthwnd = handle; |
4478 } | 4640 } |
4479 return z; | 4641 return z; |
4480 } | 4642 } |
4481 } | 4643 } |
4498 lvi.iItem = row; | 4660 lvi.iItem = row; |
4499 lvi.iSubItem = 0; | 4661 lvi.iSubItem = 0; |
4500 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE | LVIF_TEXT; | 4662 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE | LVIF_TEXT; |
4501 lvi.pszText = filename; | 4663 lvi.pszText = filename; |
4502 lvi.cchTextMax = strlen(filename); | 4664 lvi.cchTextMax = strlen(filename); |
4503 lvi.iImage = _lookup_icon(handle, (HICON)icon); | 4665 lvi.iImage = _lookup_icon(handle, (HICON)icon, 0); |
4504 | 4666 |
4505 ListView_SetItem(handle, &lvi); | 4667 ListView_SetItem(handle, &lvi); |
4506 } | 4668 } |
4507 | 4669 |
4508 /* | 4670 /* |
4549 HICON hicon = *((HICON *)data); | 4711 HICON hicon = *((HICON *)data); |
4550 | 4712 |
4551 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE; | 4713 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE; |
4552 lvi.pszText = NULL; | 4714 lvi.pszText = NULL; |
4553 lvi.cchTextMax = 0; | 4715 lvi.cchTextMax = 0; |
4554 lvi.iImage = _lookup_icon(handle, hicon); | 4716 |
4717 lvi.iImage = _lookup_icon(handle, hicon, 0); | |
4555 } | 4718 } |
4556 else if(flags[column] & DW_CFA_STRING) | 4719 else if(flags[column] & DW_CFA_STRING) |
4557 { | 4720 { |
4558 char *tmp = *((char **)data); | 4721 char *tmp = *((char **)data); |
4722 | |
4723 if(!tmp) | |
4724 tmp = ""; | |
4559 | 4725 |
4560 lvi.pszText = tmp; | 4726 lvi.pszText = tmp; |
4561 lvi.cchTextMax = strlen(tmp); | 4727 lvi.cchTextMax = strlen(tmp); |
4562 destptr = tmp; | 4728 destptr = tmp; |
4563 } | 4729 } |
4588 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); | 4754 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes); |
4589 lvi.pszText = textbuffer; | 4755 lvi.pszText = textbuffer; |
4590 lvi.cchTextMax = strlen(textbuffer); | 4756 lvi.cchTextMax = strlen(textbuffer); |
4591 } | 4757 } |
4592 | 4758 |
4593 ListView_SetItemText(handle, row, column, destptr); | 4759 ListView_SetItem(handle, &lvi); |
4760 } | |
4761 | |
4762 /* | |
4763 * Sets the width of a column in the container. | |
4764 * Parameters: | |
4765 * handle: Handle to window (widget) of container. | |
4766 * column: Zero based column of width being set. | |
4767 * width: Width of column in pixels. | |
4768 */ | |
4769 void dw_container_set_column_width(HWND handle, int column, int width) | |
4770 { | |
4771 ListView_SetColumnWidth(handle, column, width); | |
4594 } | 4772 } |
4595 | 4773 |
4596 /* | 4774 /* |
4597 * Sets the title of a row in the container. | 4775 * Sets the title of a row in the container. |
4598 * Parameters: | 4776 * Parameters: |
4632 * Parameters: | 4810 * Parameters: |
4633 * handle: Handle to the window (widget) to be cleared. | 4811 * handle: Handle to the window (widget) to be cleared. |
4634 */ | 4812 */ |
4635 void dw_container_clear(HWND handle) | 4813 void dw_container_clear(HWND handle) |
4636 { | 4814 { |
4637 /* May need to delete manually so I can | |
4638 * remove the memory allocated for the | |
4639 * lParam field. | |
4640 */ | |
4641 ListView_DeleteAllItems(handle); | 4815 ListView_DeleteAllItems(handle); |
4816 } | |
4817 | |
4818 /* | |
4819 * Removes the first x rows from a container. | |
4820 * Parameters: | |
4821 * handle: Handle to the window (widget) to be deleted from. | |
4822 * rowcount: The number of rows to be deleted. | |
4823 */ | |
4824 void dw_container_delete(HWND handle, int rowcount) | |
4825 { | |
4826 int z; | |
4827 | |
4828 for(z=0;z<rowcount;z++) | |
4829 { | |
4830 ListView_DeleteItem(handle, 0); | |
4831 } | |
4832 } | |
4833 | |
4834 /* | |
4835 * Scrolls container up or down. | |
4836 * Parameters: | |
4837 * handle: Handle to the window (widget) to be scrolled. | |
4838 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or | |
4839 * DW_SCROLL_BOTTOM. (rows is ignored for last two) | |
4840 * rows: The number of rows to be scrolled. | |
4841 */ | |
4842 void dw_container_scroll(HWND handle, int direction, long rows) | |
4843 { | |
4844 switch(direction) | |
4845 { | |
4846 case DW_SCROLL_TOP: | |
4847 ListView_Scroll(handle, 0, -10000000); | |
4848 break; | |
4849 case DW_SCROLL_BOTTOM: | |
4850 ListView_Scroll(handle, 0, 10000000); | |
4851 break; | |
4852 } | |
4642 } | 4853 } |
4643 | 4854 |
4644 /* | 4855 /* |
4645 * Removes all rows from a container. | 4856 * Removes all rows from a container. |
4646 * Parameters: | 4857 * Parameters: |