Mercurial > dwindows
comparison os2/dw.c @ 40:88c9c7410c22
Lots of fixes and new functions on all platforms.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 22 Oct 2001 22:32:58 +0000 |
parents | 3aa9ef0b3996 |
children | 997e9ed670ef |
comparison
equal
deleted
inserted
replaced
39:3aa9ef0b3996 | 40:88c9c7410c22 |
---|---|
1196 } | 1196 } |
1197 | 1197 |
1198 return WinDefWindowProc(hWnd, msg, mp1, mp2); | 1198 return WinDefWindowProc(hWnd, msg, mp1, mp2); |
1199 } | 1199 } |
1200 | 1200 |
1201 void _click_default(HWND handle) | |
1202 { | |
1203 char tmpbuf[100]; | |
1204 | |
1205 WinQueryClassName(handle, 99, tmpbuf); | |
1206 | |
1207 /* These are the window classes which can | |
1208 * obtain input focus. | |
1209 */ | |
1210 if(strncmp(tmpbuf, "#3", 3)==0) | |
1211 { | |
1212 /* Generate click on default item */ | |
1213 SignalHandler *tmp = Root; | |
1214 | |
1215 /* Find any callbacks for this function */ | |
1216 while(tmp) | |
1217 { | |
1218 if(tmp->message == WM_COMMAND) | |
1219 { | |
1220 int (*clickfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction; | |
1221 | |
1222 /* Make sure it's the right window, and the right ID */ | |
1223 if(tmp->window == handle) | |
1224 { | |
1225 clickfunc(tmp->window, tmp->data); | |
1226 tmp = NULL; | |
1227 } | |
1228 } | |
1229 if(tmp) | |
1230 tmp= tmp->next; | |
1231 } | |
1232 } | |
1233 else | |
1234 WinSetFocus(HWND_DESKTOP, handle); | |
1235 } | |
1236 | |
1201 /* Originally just intended for entryfields, it now serves as a generic | 1237 /* Originally just intended for entryfields, it now serves as a generic |
1202 * procedure for handling TAB presses to change input focus on controls. | 1238 * procedure for handling TAB presses to change input focus on controls. |
1203 */ | 1239 */ |
1204 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 1240 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
1205 { | 1241 { |
1206 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); | 1242 WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER); |
1207 | 1243 |
1208 switch(msg) | 1244 switch(msg) |
1209 { | 1245 { |
1210 case WM_BUTTON1DOWN: | 1246 case WM_BUTTON1DOWN: |
1211 case WM_BUTTON2DOWN: | 1247 case WM_BUTTON2DOWN: |
1226 if(SHORT1FROMMP(mp2) == '\t') | 1262 if(SHORT1FROMMP(mp2) == '\t') |
1227 { | 1263 { |
1228 _shift_focus(hWnd); | 1264 _shift_focus(hWnd); |
1229 return FALSE; | 1265 return FALSE; |
1230 } | 1266 } |
1267 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault) | |
1268 _click_default(blah->clickdefault); | |
1269 | |
1231 break; | 1270 break; |
1232 } | 1271 } |
1233 if(blah && *blah) | 1272 if(blah && blah->oldproc) |
1234 { | 1273 return blah->oldproc(hWnd, msg, mp1, mp2); |
1235 PFNWP myfunc = *blah; | |
1236 return myfunc(hWnd, msg, mp1, mp2); | |
1237 } | |
1238 | 1274 |
1239 return WinDefWindowProc(hWnd, msg, mp1, mp2); | 1275 return WinDefWindowProc(hWnd, msg, mp1, mp2); |
1240 } | 1276 } |
1241 | 1277 |
1242 /* Handle correct painting of a combobox with the WS_CLIPCHILDREN | 1278 /* Handle correct painting of a combobox with the WS_CLIPCHILDREN |
1243 * flag enabled, and also handle TABs to switch input focus. | 1279 * flag enabled, and also handle TABs to switch input focus. |
1244 */ | 1280 */ |
1245 MRESULT EXPENTRY _comboproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 1281 MRESULT EXPENTRY _comboproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
1246 { | 1282 { |
1247 PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); | 1283 WindowData *blah = WinQueryWindowPtr(hWnd, QWP_USER); |
1248 | 1284 |
1249 switch(msg) | 1285 switch(msg) |
1250 { | 1286 { |
1251 case WM_CHAR: | 1287 case WM_CHAR: |
1252 if(SHORT1FROMMP(mp2) == '\t') | 1288 if(SHORT1FROMMP(mp2) == '\t') |
1253 { | 1289 { |
1254 _shift_focus(hWnd); | 1290 _shift_focus(hWnd); |
1255 return FALSE; | 1291 return FALSE; |
1256 } | 1292 } |
1293 else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault) | |
1294 _click_default(blah->clickdefault); | |
1257 break; | 1295 break; |
1258 case WM_BUTTON1DOWN: | 1296 case WM_BUTTON1DOWN: |
1259 case WM_BUTTON2DOWN: | 1297 case WM_BUTTON2DOWN: |
1260 case WM_BUTTON3DOWN: | 1298 case WM_BUTTON3DOWN: |
1261 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE); | 1299 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE); |
1287 | 1325 |
1288 WinReleasePS(hpsPaint); | 1326 WinReleasePS(hpsPaint); |
1289 } | 1327 } |
1290 break; | 1328 break; |
1291 } | 1329 } |
1292 if(blah && *blah) | 1330 if(blah && blah->oldproc) |
1293 { | 1331 return blah->oldproc(hWnd, msg, mp1, mp2); |
1294 PFNWP myfunc = *blah; | |
1295 return myfunc(hWnd, msg, mp1, mp2); | |
1296 } | |
1297 | 1332 |
1298 return WinDefWindowProc(hWnd, msg, mp1, mp2); | 1333 return WinDefWindowProc(hWnd, msg, mp1, mp2); |
1299 } | 1334 } |
1300 | 1335 |
1301 void _GetPPFont(HWND hwnd, char *buff) | 1336 void _GetPPFont(HWND hwnd, char *buff) |
2600 return TRUE; | 2635 return TRUE; |
2601 return FALSE; | 2636 return FALSE; |
2602 } | 2637 } |
2603 | 2638 |
2604 /* | 2639 /* |
2640 * Makes the window topmost. | |
2641 * Parameters: | |
2642 * handle: The window handle to make topmost. | |
2643 */ | |
2644 int dw_window_raise(HWND handle) | |
2645 { | |
2646 return WinSetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER); | |
2647 } | |
2648 | |
2649 /* | |
2650 * Makes the window bottommost. | |
2651 * Parameters: | |
2652 * handle: The window handle to make bottommost. | |
2653 */ | |
2654 int dw_window_lower(HWND handle) | |
2655 { | |
2656 return WinSetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER); | |
2657 } | |
2658 | |
2659 /* | |
2605 * Makes the window visible. | 2660 * Makes the window visible. |
2606 * Parameters: | 2661 * Parameters: |
2607 * handle: The window handle to make visible. | 2662 * handle: The window handle to make visible. |
2608 */ | 2663 */ |
2609 int dw_window_show(HWND handle) | 2664 int dw_window_show(HWND handle) |
3320 * text: The default text to be in the entryfield widget. | 3375 * text: The default text to be in the entryfield widget. |
3321 * id: An ID to be used with WinWindowFromID() or 0L. | 3376 * id: An ID to be used with WinWindowFromID() or 0L. |
3322 */ | 3377 */ |
3323 HWND dw_entryfield_new(char *text, ULONG id) | 3378 HWND dw_entryfield_new(char *text, ULONG id) |
3324 { | 3379 { |
3325 PFNWP *blah = malloc(sizeof(PFNWP)); | 3380 |
3381 WindowData *blah = calloc(1, sizeof(WindowData)); | |
3326 HWND tmp = WinCreateWindow(HWND_OBJECT, | 3382 HWND tmp = WinCreateWindow(HWND_OBJECT, |
3327 WC_ENTRYFIELD, | 3383 WC_ENTRYFIELD, |
3328 text, | 3384 text, |
3329 WS_VISIBLE | ES_MARGIN | | 3385 WS_VISIBLE | ES_MARGIN | |
3330 ES_AUTOSCROLL | WS_TABSTOP, | 3386 ES_AUTOSCROLL | WS_TABSTOP, |
3333 HWND_TOP, | 3389 HWND_TOP, |
3334 id, | 3390 id, |
3335 NULL, | 3391 NULL, |
3336 NULL); | 3392 NULL); |
3337 dw_window_set_font(tmp, DefaultFont); | 3393 dw_window_set_font(tmp, DefaultFont); |
3338 *blah = WinSubclassWindow(tmp, _entryproc); | 3394 blah->oldproc = WinSubclassWindow(tmp, _entryproc); |
3339 WinSetWindowPtr(tmp, QWP_USER, blah); | 3395 WinSetWindowPtr(tmp, QWP_USER, blah); |
3340 return tmp; | 3396 return tmp; |
3341 } | 3397 } |
3342 | 3398 |
3343 /* | 3399 /* |
3346 * text: The default text to be in the entryfield widget. | 3402 * text: The default text to be in the entryfield widget. |
3347 * id: An ID to be used with WinWindowFromID() or 0L. | 3403 * id: An ID to be used with WinWindowFromID() or 0L. |
3348 */ | 3404 */ |
3349 HWND dw_entryfield_password_new(char *text, ULONG id) | 3405 HWND dw_entryfield_password_new(char *text, ULONG id) |
3350 { | 3406 { |
3351 PFNWP *blah = malloc(sizeof(PFNWP)); | 3407 WindowData *blah = calloc(1, sizeof(WindowData)); |
3352 HWND tmp = WinCreateWindow(HWND_OBJECT, | 3408 HWND tmp = WinCreateWindow(HWND_OBJECT, |
3353 WC_ENTRYFIELD, | 3409 WC_ENTRYFIELD, |
3354 text, | 3410 text, |
3355 WS_VISIBLE | ES_MARGIN | ES_UNREADABLE | | 3411 WS_VISIBLE | ES_MARGIN | ES_UNREADABLE | |
3356 ES_AUTOSCROLL | WS_TABSTOP, | 3412 ES_AUTOSCROLL | WS_TABSTOP, |
3359 HWND_TOP, | 3415 HWND_TOP, |
3360 id, | 3416 id, |
3361 NULL, | 3417 NULL, |
3362 NULL); | 3418 NULL); |
3363 dw_window_set_font(tmp, DefaultFont); | 3419 dw_window_set_font(tmp, DefaultFont); |
3364 *blah = WinSubclassWindow(tmp, _entryproc); | 3420 blah->oldproc = WinSubclassWindow(tmp, _entryproc); |
3365 WinSetWindowPtr(tmp, QWP_USER, blah); | 3421 WinSetWindowPtr(tmp, QWP_USER, blah); |
3366 return tmp; | 3422 return tmp; |
3367 } | 3423 } |
3368 | 3424 |
3369 /* | 3425 /* |
3372 * text: The default text to be in the combpbox widget. | 3428 * text: The default text to be in the combpbox widget. |
3373 * id: An ID to be used with WinWindowFromID() or 0L. | 3429 * id: An ID to be used with WinWindowFromID() or 0L. |
3374 */ | 3430 */ |
3375 HWND dw_combobox_new(char *text, ULONG id) | 3431 HWND dw_combobox_new(char *text, ULONG id) |
3376 { | 3432 { |
3377 PFNWP *blah = malloc(sizeof(PFNWP)); | 3433 WindowData *blah = calloc(1, sizeof(WindowData)); |
3378 HWND tmp = WinCreateWindow(HWND_OBJECT, | 3434 HWND tmp = WinCreateWindow(HWND_OBJECT, |
3379 WC_COMBOBOX, | 3435 WC_COMBOBOX, |
3380 text, | 3436 text, |
3381 WS_VISIBLE | CBS_DROPDOWN | WS_GROUP, | 3437 WS_VISIBLE | CBS_DROPDOWN | WS_GROUP, |
3382 0,0,2000,1000, | 3438 0,0,2000,1000, |
3385 id, | 3441 id, |
3386 NULL, | 3442 NULL, |
3387 NULL); | 3443 NULL); |
3388 dw_window_set_font(tmp, DefaultFont); | 3444 dw_window_set_font(tmp, DefaultFont); |
3389 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); | 3445 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); |
3390 *blah = WinSubclassWindow(tmp, _comboproc); | 3446 blah->oldproc = WinSubclassWindow(tmp, _comboproc); |
3391 WinSetWindowPtr(tmp, QWP_USER, blah); | 3447 WinSetWindowPtr(tmp, QWP_USER, blah); |
3392 return tmp; | 3448 return tmp; |
3393 } | 3449 } |
3394 | 3450 |
3395 /* | 3451 /* |
6044 if(box) | 6100 if(box) |
6045 thisbox = WinQueryWindowPtr(box, QWP_USER); | 6101 thisbox = WinQueryWindowPtr(box, QWP_USER); |
6046 | 6102 |
6047 if(thisbox) | 6103 if(thisbox) |
6048 thisbox->defaultitem = defaultitem; | 6104 thisbox->defaultitem = defaultitem; |
6105 } | |
6106 | |
6107 /* | |
6108 * Sets window to click the default dialog item when an ENTER is pressed. | |
6109 * Parameters: | |
6110 * window: Window (widget) to look for the ENTER press. | |
6111 * next: Window (widget) to move to next (or click) | |
6112 */ | |
6113 void dw_window_click_default(HWND window, HWND next) | |
6114 { | |
6115 WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); | |
6116 char tmpbuf[100]; | |
6117 | |
6118 WinQueryClassName(window, 99, tmpbuf); | |
6119 | |
6120 /* These are the window classes which can | |
6121 * obtain input focus. | |
6122 */ | |
6123 if(strncmp(tmpbuf, "#6", 3) == 0 && blah) | |
6124 blah->clickdefault = next; | |
6049 } | 6125 } |
6050 | 6126 |
6051 /* | 6127 /* |
6052 * Returns some information about the current operating environment. | 6128 * Returns some information about the current operating environment. |
6053 * Parameters: | 6129 * Parameters: |