Mercurial > dwindows
comparison win/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 | abbda3db3a3c |
children | bd642d04d7c6 |
comparison
equal
deleted
inserted
replaced
2230:7575eefcf881 | 2231:4d2619f31ebd |
---|---|
3797 return CallWindowProc(cinfo->cinfo.pOldProc, hWnd, msg, mp1, mp2); | 3797 return CallWindowProc(cinfo->cinfo.pOldProc, hWnd, msg, mp1, mp2); |
3798 } | 3798 } |
3799 return ret; | 3799 return ret; |
3800 } | 3800 } |
3801 | 3801 |
3802 #ifdef RICHEDIT | |
3803 #define ENTRY_CUT 60901 | |
3804 #define ENTRY_COPY 60902 | |
3805 #define ENTRY_PASTE 60903 | |
3806 #define ENTRY_DELETE 60904 | |
3807 #define ENTRY_UNDO 60905 | |
3808 #define ENTRY_SALL 60906 | |
3809 | |
3810 | |
3811 /* Special WM_NOTIFY handler for Rich Edit controls, to implement the context menu. */ | |
3812 LRESULT CALLBACK _richeditwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | |
3813 { | |
3814 switch(msg) | |
3815 { | |
3816 case WM_CONTEXTMENU: | |
3817 { | |
3818 HMENUI hwndMenu = dw_menu_new(0L); | |
3819 long x, y; | |
3820 unsigned long style = 0L; | |
3821 | |
3822 /* When readonly, disable: Undo, Cut, Paste, Delete */ | |
3823 if(GetWindowLongPtr(hWnd, GWL_STYLE) & ES_READONLY) | |
3824 style = DW_MIS_DISABLED; | |
3825 | |
3826 dw_menu_append_item(hwndMenu, "Undo", ENTRY_UNDO, style, TRUE, -1, 0L); | |
3827 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, -1, 0L); | |
3828 dw_menu_append_item(hwndMenu, "Cut", ENTRY_CUT, style, TRUE, -1, 0L); | |
3829 dw_menu_append_item(hwndMenu, "Copy", ENTRY_COPY, 0L, TRUE, -1, 0L); | |
3830 dw_menu_append_item(hwndMenu, "Paste", ENTRY_PASTE, style, TRUE, -1, 0L); | |
3831 dw_menu_append_item(hwndMenu, "Delete", ENTRY_DELETE, style, TRUE, -1, 0L); | |
3832 dw_menu_append_item(hwndMenu, "", 0L, 0L, TRUE, -1, 0L); | |
3833 dw_menu_append_item(hwndMenu, "Select All", ENTRY_SALL, 0L, TRUE, -1, 0L); | |
3834 | |
3835 dw_pointer_query_pos(&x, &y); | |
3836 dw_menu_popup(&hwndMenu, hWnd, x, y); | |
3837 return TRUE; | |
3838 } | |
3839 break; | |
3840 case WM_COMMAND: | |
3841 { | |
3842 if(HIWORD(mp1) == 0) | |
3843 { | |
3844 switch(LOWORD(mp1)) | |
3845 { | |
3846 case ENTRY_CUT: | |
3847 SendMessage(hWnd, WM_CUT, 0, 0); | |
3848 break; | |
3849 case ENTRY_COPY: | |
3850 SendMessage(hWnd, WM_COPY, 0, 0); | |
3851 break; | |
3852 case ENTRY_PASTE: | |
3853 SendMessage(hWnd, WM_PASTE, 0, 0); | |
3854 break; | |
3855 case ENTRY_DELETE: | |
3856 SendMessage(hWnd, WM_CLEAR, 0, 0); | |
3857 break; | |
3858 case ENTRY_UNDO: | |
3859 SendMessage(hWnd, EM_UNDO, 0, 0); | |
3860 break; | |
3861 case ENTRY_SALL: | |
3862 SendMessage(hWnd, EM_SETSEL, 0, (LPARAM)-1); | |
3863 break; | |
3864 } | |
3865 } | |
3866 } | |
3867 break; | |
3868 } | |
3869 return _simplewndproc(hWnd, msg, mp1, mp2); | |
3870 } | |
3871 #endif | |
3872 | |
3873 | |
3802 LRESULT CALLBACK _treewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | 3874 LRESULT CALLBACK _treewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) |
3803 { | 3875 { |
3804 #ifdef AEROGLASS | 3876 #ifdef AEROGLASS |
3805 if(msg == WM_THEMECHANGED) | 3877 if(msg == WM_THEMECHANGED) |
3806 { | 3878 { |
6425 id = tempid; | 6497 id = tempid; |
6426 | 6498 |
6427 if(tempid > 65500) | 6499 if(tempid > 65500) |
6428 tempid = 61000; | 6500 tempid = 61000; |
6429 } | 6501 } |
6502 /* Special internal case - 60001 to 60999 reserved for DW internal use */ | |
6503 else if(id > 60000 && id < 61000 && check == -1) | |
6504 { | |
6505 check = 0; | |
6506 } | |
6430 /* Second pool is larger for more static windows */ | 6507 /* Second pool is larger for more static windows */ |
6431 else if(!id || id >= 30000) | 6508 else if(!id || id >= 30000) |
6432 { | 6509 { |
6433 static ULONG menuid = 30000; | 6510 static ULONG menuid = 30000; |
6434 | 6511 |
6888 { | 6965 { |
6889 DestroyWindow(tmp); | 6966 DestroyWindow(tmp); |
6890 return NULL; | 6967 return NULL; |
6891 } | 6968 } |
6892 | 6969 |
6970 #ifdef RICHEDIT | |
6971 if(hrichedit || hmsftedit) | |
6972 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _richeditwndproc); | |
6973 else | |
6974 #endif | |
6893 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc); | 6975 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc); |
6894 cinfo->cinfo.fore = cinfo->cinfo.back = -1; | 6976 cinfo->cinfo.fore = cinfo->cinfo.back = -1; |
6895 cinfo->odd = cinfo->even = DW_RGB_TRANSPARENT; | 6977 cinfo->odd = cinfo->even = DW_RGB_TRANSPARENT; |
6896 | 6978 |
6897 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); | 6979 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); |