comparison os2/dw.c @ 30:b1d7e8a28dfa

Added tree view functions and signal.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 25 Aug 2001 05:39:33 +0000
parents d9e87e8bcf1d
children 17a08cfd45d2
comparison
equal deleted inserted replaced
29:a33dfdc5b40a 30:b1d7e8a28dfa
87 char name[30]; 87 char name[30];
88 88
89 } SignalList; 89 } SignalList;
90 90
91 /* List of signals and their equivilent OS/2 message */ 91 /* List of signals and their equivilent OS/2 message */
92 #define SIGNALMAX 12 92 #define SIGNALMAX 13
93 93
94 SignalList SignalTranslate[SIGNALMAX] = { 94 SignalList SignalTranslate[SIGNALMAX] = {
95 { WM_SIZE, "configure_event" }, 95 { WM_SIZE, "configure_event" },
96 { WM_CHAR, "key_press_event" }, 96 { WM_CHAR, "key_press_event" },
97 { WM_BUTTON1DOWN, "button_press_event" }, 97 { WM_BUTTON1DOWN, "button_press_event" },
101 { WM_PAINT, "expose_event" }, 101 { WM_PAINT, "expose_event" },
102 { WM_COMMAND, "clicked" }, 102 { WM_COMMAND, "clicked" },
103 { CN_ENTER, "container-select" }, 103 { CN_ENTER, "container-select" },
104 { CN_CONTEXTMENU, "container-context" }, 104 { CN_CONTEXTMENU, "container-context" },
105 { LN_SELECT, "item-select" }, 105 { LN_SELECT, "item-select" },
106 { WM_USER+1, "tree-select" },
106 { WM_SETFOCUS, "set-focus" } 107 { WM_SETFOCUS, "set-focus" }
107 }; 108 };
108 109
109 /* This function adds a signal handler callback into the linked list. 110 /* This function adds a signal handler callback into the linked list.
110 */ 111 */
1429 } 1430 }
1430 } 1431 }
1431 break; 1432 break;
1432 } 1433 }
1433 } 1434 }
1435
1436 if(origmsg == WM_BUTTON1DOWN)
1437 {
1438 if(tmp->message == WM_USER+1)
1439 {
1440 if(tmp->window == hWnd)
1441 {
1442 QUERYRECFROMRECT rc;
1443 POINTS pts = (*((POINTS*)&mp1));
1444 RECORDCORE *prc;
1445
1446 rc.cb = sizeof(QUERYRECFROMRECT);
1447 rc.rect.xLeft = pts.x;
1448 rc.rect.xRight = pts.x + 1;
1449 rc.rect.yTop = pts.y;
1450 rc.rect.yBottom = pts.y - 1;
1451 rc.fsSearch = CMA_PARTIAL | CMA_ITEMORDER;
1452
1453 prc = (RECORDCORE *)WinSendMsg(hWnd, CM_QUERYRECORDFROMRECT, (MPARAM)CMA_FIRST, MPFROMP(&rc));
1454
1455 if(prc)
1456 {
1457 int (*treeselectfunc)(HWND, HWND, char *, void *) = (int (*)(HWND, HWND, char *, void *))tmp->signalfunction;
1458
1459 result = treeselectfunc(tmp->window, (HWND)prc, prc->pszIcon, tmp->data);
1460
1461 tmp = NULL;
1462 }
1463 }
1464 }
1465 }
1466
1434 if(tmp) 1467 if(tmp)
1435 tmp = tmp->next; 1468 tmp = tmp->next;
1436 1469
1437 } 1470 }
1438 1471
1443 /* Handles control messages sent to the box (owner). */ 1476 /* Handles control messages sent to the box (owner). */
1444 MRESULT EXPENTRY _controlproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1477 MRESULT EXPENTRY _controlproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1445 { 1478 {
1446 Box *blah = WinQueryWindowPtr(hWnd, QWP_USER); 1479 Box *blah = WinQueryWindowPtr(hWnd, QWP_USER);
1447 1480
1481 #ifndef NO_SIGNALS
1448 switch(msg) 1482 switch(msg)
1449 { 1483 {
1450 case WM_CONTROL: 1484 case WM_CONTROL:
1451 _run_event(hWnd, msg, mp1, mp2); 1485 _run_event(hWnd, msg, mp1, mp2);
1452 break; 1486 break;
1453 } 1487 }
1488 #endif
1454 if(blah && blah->oldproc) 1489 if(blah && blah->oldproc)
1455 { 1490 {
1456 return blah->oldproc(hWnd, msg, mp1, mp2); 1491 return blah->oldproc(hWnd, msg, mp1, mp2);
1457 } 1492 }
1458 1493
2160 return (MPARAM)TRUE; 2195 return (MPARAM)TRUE;
2161 } 2196 }
2162 return WinDefWindowProc(hwnd, msg, mp1, mp2); 2197 return WinDefWindowProc(hwnd, msg, mp1, mp2);
2163 } 2198 }
2164 2199
2200 MRESULT EXPENTRY _TreeProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2201 {
2202 Box *blah = WinQueryWindowPtr(hwnd, QWP_USER);
2203
2204 #ifndef NO_SIGNALS
2205 _run_event(hwnd, msg, mp1, mp2);
2206 #endif
2207 if(blah && blah->oldproc)
2208 return blah->oldproc(hwnd, msg, mp1, mp2);
2209 return WinDefWindowProc(hwnd, msg, mp1, mp2);
2210 }
2211
2165 /* 2212 /*
2166 * Initializes the Dynamic Windows engine. 2213 * Initializes the Dynamic Windows engine.
2167 * Parameters: 2214 * Parameters:
2168 * newthread: True if this is the only thread. 2215 * newthread: True if this is the only thread.
2169 * False if there is already a message loop running. 2216 * False if there is already a message loop running.
2921 * resource file. 2968 * resource file.
2922 */ 2969 */
2923 HWND dw_tree_new(ULONG id) 2970 HWND dw_tree_new(ULONG id)
2924 { 2971 {
2925 CNRINFO cnrinfo; 2972 CNRINFO cnrinfo;
2973 Box *newbox = calloc(1, sizeof(Box));
2926 HWND tmp = WinCreateWindow(HWND_OBJECT, 2974 HWND tmp = WinCreateWindow(HWND_OBJECT,
2927 WC_CONTAINER, 2975 WC_CONTAINER,
2928 NULL, 2976 NULL,
2929 WS_VISIBLE | CCS_READONLY | 2977 WS_VISIBLE | CCS_READONLY |
2930 CCS_SINGLESEL | CCS_AUTOPOSITION, 2978 CCS_SINGLESEL | CCS_AUTOPOSITION,
2938 cnrinfo.flWindowAttr = CV_TREE | CA_TREELINE; 2986 cnrinfo.flWindowAttr = CV_TREE | CA_TREELINE;
2939 cnrinfo.slBitmapOrIcon.cx = 16; 2987 cnrinfo.slBitmapOrIcon.cx = 16;
2940 cnrinfo.slBitmapOrIcon.cy = 16; 2988 cnrinfo.slBitmapOrIcon.cy = 16;
2941 2989
2942 WinSendMsg(tmp, CM_SETCNRINFO, &cnrinfo, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON)); 2990 WinSendMsg(tmp, CM_SETCNRINFO, &cnrinfo, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON));
2991 newbox->oldproc = WinSubclassWindow(tmp, _TreeProc);
2992 WinSetWindowPtr(tmp, QWP_USER, newbox);
2943 dw_window_set_font(tmp, DefaultFont); 2993 dw_window_set_font(tmp, DefaultFont);
2944 return tmp; 2994 return tmp;
2945 } 2995 }
2946 2996
2947 /* 2997 /*
4245 4295
4246 /* Insert the record */ 4296 /* Insert the record */
4247 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri)); 4297 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri));
4248 4298
4249 return (HWND)pci; 4299 return (HWND)pci;
4300 }
4301
4302 /*
4303 * Removes all nodes from a tree.
4304 * Parameters:
4305 * handle: Handle to the window (widget) to be cleared.
4306 */
4307 void dw_tree_clear(HWND handle)
4308 {
4309 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, CMA_INVALIDATE | CMA_FREE));
4310 }
4311
4312 /*
4313 * Removes a node from a tree.
4314 * Parameters:
4315 * handle: Handle to the window (widget) to be cleared.
4316 * item: Handle to node to be deleted.
4317 */
4318 void dw_tree_delete(HWND handle, HWND item)
4319 {
4320 PCNRITEM pci = (PCNRITEM)item;
4321 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)&pci, MPFROM2SHORT(1, CMA_INVALIDATE | CMA_FREE));
4250 } 4322 }
4251 4323
4252 /* Some OS/2 specific container structs */ 4324 /* Some OS/2 specific container structs */
4253 typedef struct _containerinfo { 4325 typedef struct _containerinfo {
4254 int count; 4326 int count;