Mercurial > dwindows
comparison os2/dw.c @ 2231:4d2619f31ebd
Win: Subclass richtext controls and port the OS/2 MLE context menu code to it.
OS/2: Add missing Delete menu item from the MLE context menu. Reorder the menu
and disable menu items instead of removing them from the menu completely.
This is consistent with how these menus behave on Windows, and has the benefit
of the menu items always being in the same place. ENTRY_DELETE handlers may
need to be added to the special Unicode edit handler functions.
The OS/2 code has not been tested yet, follow up commits may be needed.
Menu identifiers 60001 to 60999 are now reserved for internal DW use.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 03 Jan 2021 16:03:00 +0000 |
parents | a3f105431028 |
children | 155caabaa12b |
comparison
equal
deleted
inserted
replaced
2230:7575eefcf881 | 2231:4d2619f31ebd |
---|---|
2238 } | 2238 } |
2239 else | 2239 else |
2240 WinSetFocus(HWND_DESKTOP, handle); | 2240 WinSetFocus(HWND_DESKTOP, handle); |
2241 } | 2241 } |
2242 | 2242 |
2243 #define ENTRY_CUT 60901 | 2243 #define ENTRY_CUT 60901 |
2244 #define ENTRY_COPY 60902 | 2244 #define ENTRY_COPY 60902 |
2245 #define ENTRY_PASTE 60903 | 2245 #define ENTRY_PASTE 60903 |
2246 #define ENTRY_UNDO 60904 | 2246 #define ENTRY_DELETE 60904 |
2247 #define ENTRY_SALL 60905 | 2247 #define ENTRY_UNDO 60905 |
2248 #define ENTRY_SALL 60906 | |
2248 | 2249 |
2249 #ifdef UNICODE | 2250 #ifdef UNICODE |
2250 void _combine_text(HWND handle, USHORT pos1, char *text, char *pastetext) | 2251 void _combine_text(HWND handle, USHORT pos1, char *text, char *pastetext) |
2251 { | 2252 { |
2252 char *combined = calloc((text ? strlen(text) : 0) + strlen(pastetext) + 1, 1); | 2253 char *combined = calloc((text ? strlen(text) : 0) + strlen(pastetext) + 1, 1); |
2390 #endif | 2391 #endif |
2391 case WM_CONTEXTMENU: | 2392 case WM_CONTEXTMENU: |
2392 { | 2393 { |
2393 HMENUI hwndMenu = dw_menu_new(0L); | 2394 HMENUI hwndMenu = dw_menu_new(0L); |
2394 long x, y; | 2395 long x, y; |
2395 | 2396 unsigned long style = 0L; |
2396 if(strncmp(tmpbuf, "#10", 4)==0 && !WinSendMsg(hWnd, MLM_QUERYREADONLY, 0, 0)) | 2397 |
2397 { | 2398 if(strncmp(tmpbuf, "#10", 4)==0 && WinSendMsg(hWnd, MLM_QUERYREADONLY, 0, 0)) |
2398 dw_menu_append_item(hwndMenu, "Undo", ENTRY_UNDO, 0L, TRUE, -1, 0L); | 2399 style = DW_MIS_DISABLED; |
2399 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, -1, 0L); | 2400 dw_menu_append_item(hwndMenu, "Undo", ENTRY_UNDO, style, TRUE, -1, 0L); |
2400 } | 2401 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, -1, 0L); |
2402 if(strncmp(tmpbuf, "#10", 4)!=0 && dw_window_get_data(hWnd, "_dw_disabled")) | |
2403 style = DW_MIS_DISABLED; | |
2404 dw_menu_append_item(hwndMenu, "Cut", ENTRY_CUT, style, TRUE, -1, 0L); | |
2401 dw_menu_append_item(hwndMenu, "Copy", ENTRY_COPY, 0L, TRUE, -1, 0L); | 2405 dw_menu_append_item(hwndMenu, "Copy", ENTRY_COPY, 0L, TRUE, -1, 0L); |
2402 if((strncmp(tmpbuf, "#10", 4)!=0 && !dw_window_get_data(hWnd, "_dw_disabled")) || (strncmp(tmpbuf, "#10", 4)==0 && !WinSendMsg(hWnd, MLM_QUERYREADONLY, 0, 0))) | 2406 dw_menu_append_item(hwndMenu, "Paste", ENTRY_PASTE, style, TRUE, -1, 0L); |
2403 { | 2407 dw_menu_append_item(hwndMenu, "Delete", ENTRY_DELETE, style, TRUE, -1, 0L); |
2404 dw_menu_append_item(hwndMenu, "Cut", ENTRY_CUT, 0L, TRUE, -1, 0L); | |
2405 dw_menu_append_item(hwndMenu, "Paste", ENTRY_PASTE, 0L, TRUE, -1, 0L); | |
2406 } | |
2407 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, -1, 0L); | 2408 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, -1, 0L); |
2408 dw_menu_append_item(hwndMenu, "Select All", ENTRY_SALL, 0L, TRUE, -1, 0L); | 2409 dw_menu_append_item(hwndMenu, "Select All", ENTRY_SALL, 0L, TRUE, -1, 0L); |
2409 | 2410 |
2410 WinSetFocus(HWND_DESKTOP, hWnd); | 2411 WinSetFocus(HWND_DESKTOP, hWnd); |
2411 dw_pointer_query_pos(&x, &y); | 2412 dw_pointer_query_pos(&x, &y); |
2425 return WinSendMsg(hWnd, MLM_CUT, 0, 0); | 2426 return WinSendMsg(hWnd, MLM_CUT, 0, 0); |
2426 case ENTRY_COPY: | 2427 case ENTRY_COPY: |
2427 return WinSendMsg(hWnd, MLM_COPY, 0, 0); | 2428 return WinSendMsg(hWnd, MLM_COPY, 0, 0); |
2428 case ENTRY_PASTE: | 2429 case ENTRY_PASTE: |
2429 return WinSendMsg(hWnd, MLM_PASTE, 0, 0); | 2430 return WinSendMsg(hWnd, MLM_PASTE, 0, 0); |
2431 case ENTRY_DELETE: | |
2432 return WinSendMsg(hWnd, MLM_DELETE, 0, 0); | |
2430 case ENTRY_UNDO: | 2433 case ENTRY_UNDO: |
2431 return WinSendMsg(hWnd, MLM_UNDO, 0, 0); | 2434 return WinSendMsg(hWnd, MLM_UNDO, 0, 0); |
2432 case ENTRY_SALL: | 2435 case ENTRY_SALL: |
2433 { | 2436 { |
2434 ULONG len = (ULONG)WinSendMsg(hWnd, MLM_QUERYTEXTLENGTH, 0, 0); | 2437 ULONG len = (ULONG)WinSendMsg(hWnd, MLM_QUERYTEXTLENGTH, 0, 0); |
6084 id = tempid; | 6087 id = tempid; |
6085 | 6088 |
6086 if(tempid > 65500) | 6089 if(tempid > 65500) |
6087 tempid = 61000; | 6090 tempid = 61000; |
6088 } | 6091 } |
6089 /* Special internal case */ | 6092 /* Special internal case - 60001 to 60999 reserved for DW internal use */ |
6090 else if(id > 60000 && check == -1) | 6093 else if(id > 60000 && id < 61000 && check == -1) |
6091 { | 6094 { |
6092 check = 0; | 6095 check = 0; |
6093 } | 6096 } |
6094 /* Second pool is larger for more static windows */ | 6097 /* Second pool is larger for more static windows */ |
6095 else if(!id || id >= 30000) | 6098 else if(!id || id >= 30000) |