annotate src/gui_w16.c @ 5697:c2098c3095e7

Updated runtime files.
author Bram Moolenaar <bram@vim.org>
date Sat, 08 Mar 2014 18:38:28 +0100
parents 04736b4030ec
children 286fd54c7ae3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * GUI support by Robert Webb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * gui_w16.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 * GUI support for Microsoft Windows 3.1x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 * George V. Reilly <george@reilly.org> wrote the original Win32 GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 * Robert Webb reworked it to use the existing GUI stuff and added menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 * scrollbars, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 * Vince Negri then butchered the code to get it compiling for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 * 16-bit windows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3314
2e4539dc2de7 updated for version 7.3.424
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
24 /* Win16 doesn't use the "W" methods. */
2e4539dc2de7 updated for version 7.3.424
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
25 #define pDispatchMessage DispatchMessage
2e4539dc2de7 updated for version 7.3.424
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
26 #define pGetMessage GetMessage
2e4539dc2de7 updated for version 7.3.424
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
27 #define pIsDialogMessage IsDialogMessage
2e4539dc2de7 updated for version 7.3.424
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
28 #define pPeekMessage PeekMessage
2e4539dc2de7 updated for version 7.3.424
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
29
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 * Include the common stuff for MS-Windows GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 #include "gui_w48.c"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 #include "guiw16rc.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 /* Undocumented Windows Message - not even defined in some SDK headers */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 #define WM_EXITSIZEMOVE 0x0232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 # define CMD_TB_BASE (99)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 # include <vimtbar.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 #ifdef PROTO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 # define WINAPI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 #define HANDLE_WM_DROPFILES(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 ((fn)((hwnd), (HDROP)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 /* Local variables: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 static UINT s_menu_id = 100;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 #define VIM_NAME "vim"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 #define VIM_CLASS "Vim"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 #define DLG_ALLOC_SIZE 16 * 1024
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 * stuff for dialogs, menus, tearoffs etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 static BOOL CALLBACK dialog_callback(HWND, UINT, WPARAM, LPARAM);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 static LPWORD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 add_dialog_element(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 LPWORD p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 DWORD lStyle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 WORD x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 WORD y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 WORD w,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 WORD h,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 WORD Id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 BYTE clss,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 const char *caption);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 static int dialog_default_button = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 static void get_dialog_font_metrics(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 static void initialise_toolbar(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 * Figure out how high the menu bar is at the moment.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 gui_mswin_get_menu_height(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 int fix_window) /* If TRUE, resize window if menu height changed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 static int old_menu_height = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 int num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 int menu_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 if (gui.menu_is_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 num = GetMenuItemCount(s_menuBar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 num = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 if (num == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 menu_height = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 else if (gui.starting)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 menu_height = GetSystemMetrics(SM_CYMENU);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 RECT r1, r2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 int frameht = GetSystemMetrics(SM_CYFRAME);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 int capht = GetSystemMetrics(SM_CYCAPTION);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 /* get window rect of s_hwnd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 * get client rect of s_hwnd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 * get cap height
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 * subtract from window rect, the sum of client height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 * (if not maximized)frame thickness, and caption height.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 GetWindowRect(s_hwnd, &r1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 GetClientRect(s_hwnd, &r2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 menu_height = r1.bottom - r1.top - (r2.bottom-r2.top +
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 2 * frameht * (!IsZoomed(s_hwnd)) + capht);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 if (fix_window && menu_height != old_menu_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 old_menu_height = menu_height;
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
137 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 return menu_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 #endif /*FEAT_MENU*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 * Even though we have _DuringSizing() which makes the rubber band a valid
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 * size, we need this for when the user maximises the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 * TODO: Doesn't seem to adjust the width though for some reason.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 static BOOL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 _OnWindowPosChanging(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 LPWINDOWPOS lpwpos)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 if (!IsIconic(hwnd) && !(lpwpos->flags & SWP_NOSIZE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 gui_mswin_get_valid_dimensions(lpwpos->cx, lpwpos->cy,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 &lpwpos->cx, &lpwpos->cy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 static LRESULT CALLBACK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 _WndProc(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 UINT uMsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 WPARAM wParam,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 LPARAM lParam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 TRACE("WndProc: hwnd = %08x, msg = %x, wParam = %x, lParam = %x\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 hwnd, uMsg, wParam, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 HandleMouseHide(uMsg, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 s_uMsg = uMsg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 s_wParam = wParam;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 s_lParam = lParam;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 switch (uMsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 HANDLE_MSG(hwnd, WM_DEADCHAR, _OnDeadChar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 HANDLE_MSG(hwnd, WM_SYSDEADCHAR, _OnDeadChar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 /* HANDLE_MSG(hwnd, WM_ACTIVATE, _OnActivate); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 HANDLE_MSG(hwnd, WM_CHAR, _OnChar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 HANDLE_MSG(hwnd, WM_CLOSE, _OnClose);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 /* HANDLE_MSG(hwnd, WM_COMMAND, _OnCommand); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 HANDLE_MSG(hwnd, WM_DESTROY, _OnDestroy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 HANDLE_MSG(hwnd, WM_DROPFILES, _OnDropFiles);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 HANDLE_MSG(hwnd, WM_HSCROLL, _OnScroll);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 HANDLE_MSG(hwnd, WM_KILLFOCUS, _OnKillFocus);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 HANDLE_MSG(hwnd, WM_COMMAND, _OnMenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 /* HANDLE_MSG(hwnd, WM_MOVE, _OnMove); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 /* HANDLE_MSG(hwnd, WM_NCACTIVATE, _OnNCActivate); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 HANDLE_MSG(hwnd, WM_SETFOCUS, _OnSetFocus);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 HANDLE_MSG(hwnd, WM_SIZE, _OnSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 /* HANDLE_MSG(hwnd, WM_SYSCOMMAND, _OnSysCommand); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 /* HANDLE_MSG(hwnd, WM_SYSKEYDOWN, _OnAltKey); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 HANDLE_MSG(hwnd, WM_VSCROLL, _OnScroll);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGING, _OnWindowPosChanging);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 HANDLE_MSG(hwnd, WM_ACTIVATEAPP, _OnActivateApp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 case WM_QUERYENDSESSION: /* System wants to go down. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 gui_shell_closed(); /* Will exit when no changed buffers. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 return FALSE; /* Do NOT allow system to go down. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 case WM_ENDSESSION:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 if (wParam) /* system only really goes down when wParam is TRUE */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 _OnEndSession();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 case WM_SYSCHAR:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 * if 'winaltkeys' is "no", or it's "menu" and it's not a menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 * shortcut key, handle like a typed ALT key, otherwise call Windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 * ALT key handling.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 if ( !gui.menu_is_active
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 || p_wak[0] == 'n'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 || (p_wak[0] == 'm' && !gui_is_menu_shortcut((int)wParam))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 return HANDLE_WM_SYSCHAR((hwnd), (wParam), (lParam), (_OnSysChar));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 return MyWindowProc(hwnd, uMsg, wParam, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 case WM_SYSKEYUP:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 /* Only when menu is active, ALT key is used for that. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 if (gui.menu_is_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 return MyWindowProc(hwnd, uMsg, wParam, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 #if defined(MENUHINTS) && defined(FEAT_MENU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 case WM_MENUSELECT:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 if (((UINT) LOWORD(lParam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 & (0xffff ^ (MF_MOUSESELECT + MF_BITMAP + MF_POPUP)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 == MF_HILITE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 && (State & CMDLINE) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 UINT idButton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 vimmenu_T *pMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 idButton = (UINT)LOWORD(wParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 pMenu = gui_mswin_find_menu(root_menu, idButton);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 if (pMenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 idx = MENU_INDEX_TIP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 msg_clr_cmdline();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 if (pMenu->strings[idx])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 msg(pMenu->strings[idx]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 msg("");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 setcursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 case WM_NCHITTEST:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 LRESULT result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 int xPos = GET_X_LPARAM(lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 result = MyWindowProc(hwnd, uMsg, wParam, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 if (result == HTCLIENT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 gui_mch_get_winpos(&x, &y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 xPos -= x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 if (xPos < 48) /*<VN> TODO should use system metric?*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 return HTBOTTOMLEFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 return HTBOTTOMRIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 return result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 /* break; */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 #ifdef MSWIN_FIND_REPLACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 if (uMsg == s_findrep_msg && s_findrep_msg != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 _OnFindRepl();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 return MyWindowProc(hwnd, uMsg, wParam, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 return 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 * End of call-back routines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 * Parse the GUI related command-line arguments. Any arguments used are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 * deleted from argv, and *argc is decremented accordingly. This is called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 * when vim is started, whether or not the GUI has been started.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 gui_mch_prepare(int *argc, char **argv)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 /* No special args for win16 GUI at the moment. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 * Initialise the GUI. Create all the windows, set up all the call-backs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 * etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 gui_mch_init(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 const char szVimWndClass[] = VIM_CLASS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 const char szTextAreaClass[] = "VimTextArea";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 WNDCLASS wndclass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 #ifdef WIN16_3DLOOK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 Ctl3dRegister(s_hinst);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 Ctl3dAutoSubclass(s_hinst);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 /* Display any pending error messages */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 display_errors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 gui.scrollbar_width = GetSystemMetrics(SM_CXVSCROLL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 gui.scrollbar_height = GetSystemMetrics(SM_CYHSCROLL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 gui.menu_height = 0; /* Windows takes care of this */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 gui.border_width = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 gui.currBgColor = INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 if (GetClassInfo(s_hinst, szVimWndClass, &wndclass) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 wndclass.style = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 wndclass.lpfnWndProc = _WndProc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 wndclass.cbClsExtra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 wndclass.cbWndExtra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 wndclass.hInstance = s_hinst;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 wndclass.hIcon = LoadIcon(wndclass.hInstance, MAKEINTRESOURCE(IDR_VIM));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 wndclass.hbrBackground = s_brush;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 wndclass.lpszMenuName = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 wndclass.lpszClassName = szVimWndClass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 if ((
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 #ifdef GLOBAL_IME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 atom =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 RegisterClass(&wndclass)) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 s_hwnd = CreateWindow(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 szVimWndClass, "Vim MSWindows GUI",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 WS_OVERLAPPEDWINDOW,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 100, /* Any value will do */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 100, /* Any value will do */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 NULL, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 s_hinst, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 if (s_hwnd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 #ifdef GLOBAL_IME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 global_ime_init(atom, s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 /* Create the text area window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 if (GetClassInfo(s_hinst, szTextAreaClass, &wndclass) == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 wndclass.style = CS_OWNDC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 wndclass.lpfnWndProc = _TextAreaWndProc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 wndclass.cbClsExtra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 wndclass.cbWndExtra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 wndclass.hInstance = s_hinst;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 wndclass.hIcon = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 wndclass.hbrBackground = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 wndclass.lpszMenuName = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 wndclass.lpszClassName = szTextAreaClass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 if (RegisterClass(&wndclass) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 s_textArea = CreateWindow(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 szTextAreaClass, "Vim text area",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 WS_CHILD | WS_VISIBLE, 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 100, /* Any value will do for now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 100, /* Any value will do for now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 s_hwnd, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 s_hinst, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 if (s_textArea == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 s_menuBar = CreateMenu();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 s_hdc = GetDC(s_textArea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 #ifdef MSWIN16_FASTTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 SetBkMode(s_hdc, OPAQUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 DragAcceptFiles(s_hwnd, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 /* Do we need to bother with this? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 /* m_fMouseAvail = GetSystemMetrics(SM_MOUSEPRESENT); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 /* Get background/foreground colors from the system */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 gui_mch_def_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 /* Get the colors from the "Normal" group (set in syntax.c or in a vimrc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 * file) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 set_normal_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 * Check that none of the colors are the same as the background color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 * Then store the current values as the defaults.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 gui_check_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 gui.def_norm_pixel = gui.norm_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 gui.def_back_pixel = gui.back_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 /* Get the colors for the highlight groups (gui_check_colors() might have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 * changed them) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 highlight_gui_started();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 * Start out by adding the configured border width into the border offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 gui.border_offset = gui.border_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 * compute a couple of metrics used for the dialogs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 get_dialog_font_metrics();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 * Create the toolbar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 initialise_toolbar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 #ifdef MSWIN_FIND_REPLACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 * Initialise the dialog box stuff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 s_findrep_msg = RegisterWindowMessage(FINDMSGSTRING);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 /* Initialise the struct */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 s_findrep_struct.lStructSize = sizeof(s_findrep_struct);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 s_findrep_struct.lpstrFindWhat = alloc(MSWIN_FR_BUFSIZE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 s_findrep_struct.lpstrFindWhat[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 s_findrep_struct.lpstrReplaceWith = alloc(MSWIN_FR_BUFSIZE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 s_findrep_struct.lpstrReplaceWith[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 * Set the size of the window to the given width and height in pixels.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 gui_mch_set_shellsize(int width, int height,
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
497 int min_width, int min_height, int base_width, int base_height,
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
498 int direction)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 RECT workarea_rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 int win_width, win_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 int win_xpos, win_ypos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 WINDOWPLACEMENT wndpl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 /* try to keep window completely on screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 /* get size of the screen work area - use SM_CYFULLSCREEN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 * instead of SM_CYSCREEN so that we don't overlap the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 * taskbar if someone fires us up on Win95/NT */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 workarea_rect.left = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 workarea_rect.top = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 workarea_rect.right = GetSystemMetrics(SM_CXSCREEN);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 workarea_rect.bottom = GetSystemMetrics(SM_CYFULLSCREEN);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3927
diff changeset
514 /* get current position of our window */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 wndpl.length = sizeof(WINDOWPLACEMENT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 GetWindowPlacement(s_hwnd, &wndpl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 if (wndpl.showCmd == SW_SHOWNORMAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 win_xpos = wndpl.rcNormalPosition.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 win_ypos = wndpl.rcNormalPosition.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 win_xpos = workarea_rect.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 win_ypos = workarea_rect.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 /* compute the size of the outside of the window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 win_width = width + GetSystemMetrics(SM_CXFRAME) * 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 win_height = height + GetSystemMetrics(SM_CYFRAME) * 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 + GetSystemMetrics(SM_CYCAPTION)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 + gui_mswin_get_menu_height(FALSE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 /* if the window is going off the screen, move it on to the screen */
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
538 if ((direction & RESIZE_HOR) && win_xpos + win_width > workarea_rect.right)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 win_xpos = workarea_rect.right - win_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
541 if ((direction & RESIZE_HOR) && win_xpos < workarea_rect.left)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 win_xpos = workarea_rect.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
544 if ((direction & RESIZE_VERT)
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
545 && win_ypos + win_height > workarea_rect.bottom)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 win_ypos = workarea_rect.bottom - win_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
548 if ((direction & RESIZE_VERT) && win_ypos < workarea_rect.top)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 win_ypos = workarea_rect.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 /* set window position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 SetWindowPos(s_hwnd, NULL, win_xpos, win_ypos, win_width, win_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 SWP_NOZORDER | SWP_NOACTIVATE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 /* Menu may wrap differently now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 gui_mswin_get_menu_height(!gui.starting);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 gui_mch_set_scrollbar_thumb(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 scrollbar_T *sb,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 long val,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 long size,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 long max)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 sb->scroll_shift = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 while (max > 32767)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 max = (max + 1) >> 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 val >>= 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 size >>= 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 ++sb->scroll_shift;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 if (sb->scroll_shift > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 ++size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 SetScrollRange(sb->id, SB_CTL, 0, (int) max, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 SetScrollPos(sb->id, SB_CTL, (int) val, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 * Set the current text font.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 gui_mch_set_font(GuiFont font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 gui.currFont = font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 SelectFont(s_hdc, gui.currFont);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 * Set the current text foreground color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 gui_mch_set_fg_color(guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 gui.currFgColor = color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 SetTextColor(s_hdc, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 * Set the current text background color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 gui_mch_set_bg_color(guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 if (gui.currBgColor == color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 gui.currBgColor = color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 SetBkColor(s_hdc, gui.currBgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617
203
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
618 /*
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
619 * Set the current text special color.
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
620 */
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
621 void
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
622 gui_mch_set_sp_color(guicolor_T color)
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
623 {
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
624 /* TODO */
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
625 }
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
626
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 gui_mch_draw_string(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 int row,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 int col,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 char_u *text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 int len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 int flags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 #ifndef MSWIN16_FASTTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 static int *padding = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 static int pad_size = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 HPEN hpen, old_pen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 #ifndef MSWIN16_FASTTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 * Italic and bold text seems to have an extra row of pixels at the bottom
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 * (below where the bottom of the character should be). If we draw the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 * characters with a solid background, the top row of pixels in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 * character below will be overwritten. We can fix this by filling in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 * background ourselves, to the correct character proportions, and then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 * writing the character in transparent mode. Still have a problem when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 * the character is "_", which gets written on to the character below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 * New fix: set gui.char_ascent to -1. This shifts all characters up one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 * pixel in their slots, which fixes the problem with the bottom row of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 * pixels. We still need this code because otherwise the top row of pixels
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 * becomes a problem. - webb.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 HBRUSH hbr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 RECT rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 if (!(flags & DRAW_TRANSP))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 * Clear background first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 * Note: FillRect() excludes right and bottom of rectangle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 rc.left = FILL_X(col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 rc.top = FILL_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 /* Compute the length in display cells. */
2338
da6ec32d8d8f Added strwidth() and strchars() functions.
Bram Moolenaar <bram@vim.org>
parents: 1201
diff changeset
674 rc.right = FILL_X(col + mb_string2cells(text, len));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 rc.right = FILL_X(col + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 rc.bottom = FILL_Y(row + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 hbr = CreateSolidBrush(gui.currBgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 FillRect(s_hdc, &rc, hbr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 DeleteBrush(hbr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 SetBkMode(s_hdc, TRANSPARENT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 * When drawing block cursor, prevent inverted character spilling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 * over character cell (can happen with bold/italic)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 if (flags & DRAW_CURSOR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 pcliprect = &rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 foptions = ETO_CLIPPED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 * Alternative: write the characters in opaque mode, since we have blocked
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 * bold or italic fonts.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 /* The OPAQUE mode and backcolour have already been set */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 /* The forecolor and font have already been set */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 #ifndef MSWIN16_FASTTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 if (pad_size != Columns || padding == NULL || padding[0] != gui.char_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 vim_free(padding);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 pad_size = Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 padding = (int *)alloc(pad_size * sizeof(int));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 if (padding != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 for (i = 0; i < pad_size; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 padding[i] = gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 * We have to provide the padding argument because italic and bold versions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 * of fixed-width fonts are often one pixel or so wider than their normal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 * versions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 * No check for DRAW_BOLD, Windows will have done it already.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 #ifndef MSWIN16_FASTTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), 0, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 (char *)text, len, padding);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 TextOut(s_hdc, TEXT_X(col), TEXT_Y(row), (char *)text, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 if (flags & DRAW_UNDERL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 hpen = CreatePen(PS_SOLID, 1, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 old_pen = SelectObject(s_hdc, hpen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 /* When p_linespace is 0, overwrite the bottom row of pixels.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 * Otherwise put the line just below the character. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 y = FILL_Y(row + 1) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 #ifndef MSWIN16_FASTTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 if (p_linespace > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 y -= p_linespace - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 MoveToEx(s_hdc, FILL_X(col), y, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 /* Note: LineTo() excludes the last pixel in the line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 LineTo(s_hdc, FILL_X(col + len), y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 DeleteObject(SelectObject(s_hdc, old_pen));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 * Output routines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 /* Flush any output to the screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 gui_mch_flush(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 /* Is anything needed here? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 clear_rect(RECT *rcp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 /* Use trick for fast rect clear */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 ExtTextOut(s_hdc, 0, 0, ETO_CLIPPED | ETO_OPAQUE, rcp, NULL, 0, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770
635
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
771 void
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
772 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
773 {
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
774
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
775 *screen_w = GetSystemMetrics(SM_CXFULLSCREEN)
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
776 - GetSystemMetrics(SM_CXFRAME) * 2;
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
777 /* FIXME: dirty trick: Because the gui_get_base_height() doesn't include
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
778 * the menubar for MSwin, we subtract it from the screen height, so that
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
779 * the window size can be made to fit on the screen. */
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
780 *screen_h = GetSystemMetrics(SM_CYFULLSCREEN)
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
781 - GetSystemMetrics(SM_CYFRAME) * 2
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
782 #ifdef FEAT_MENU
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
783 - gui_mswin_get_menu_height(FALSE)
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
784 #endif
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
785 ;
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
786 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 #if defined(FEAT_MENU) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 * Add a sub menu to the menu bar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 gui_mch_add_menu(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 int pos)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 menu->submenu_id = CreatePopupMenu();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 menu->id = s_menu_id++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 if (menu_is_menubar(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 InsertMenu((parent == NULL) ? s_menuBar : parent->submenu_id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 (UINT)pos, MF_POPUP | MF_STRING | MF_BYPOSITION,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 (UINT)menu->submenu_id, menu->name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 /* Fix window size if menu may have wrapped */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 if (parent == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 gui_mswin_get_menu_height(!gui.starting);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 gui_mch_show_popupmenu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 POINT mp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 (void)GetCursorPos((LPPOINT)&mp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 gui_mch_show_popupmenu_at(menu, (int)mp.x, (int)mp.y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 void
399
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
825 gui_make_popup(char_u *path_name, int mouse_pos)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 vimmenu_T *menu = gui_find_menu(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 if (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 /* Find the position of the current cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 DWORD temp_p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 POINT p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 temp_p = GetDCOrg(s_hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 p.x = LOWORD(temp_p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 p.y = HIWORD(temp_p);
399
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
837 if (mouse_pos)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 {
399
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
839 int mx, my;
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
840
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
841 gui_mch_getmouse(&mx, &my);
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
842 p.x += mx;
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
843 p.y += my;
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
844 }
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
845 else if (curwin != NULL)
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
846 {
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
847 p.x += TEXT_X(W_WINCOL(curwin) + curwin->w_wcol + 1);
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
848 p.y += TEXT_Y(W_WINROW(curwin) + curwin->w_wrow + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 msg_scroll = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 gui_mch_show_popupmenu_at(menu, (int)p.x, (int)p.y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 * Add a menu item to a menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 gui_mch_add_menu_item(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 menu->id = s_menu_id++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 menu->submenu_id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 if (menu_is_toolbar(parent->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 TBBUTTON newtb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 vim_memset(&newtb, 0, sizeof(newtb));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 if (menu_is_separator(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 newtb.iBitmap = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 newtb.fsStyle = TBSTYLE_SEP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 if (menu->iconidx >= TOOLBAR_BITMAP_COUNT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 newtb.iBitmap = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 newtb.iBitmap = menu->iconidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 newtb.fsStyle = TBSTYLE_BUTTON;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 newtb.idCommand = menu->id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 newtb.fsState = TBSTATE_ENABLED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 SendMessage(s_toolbarhwnd, TB_INSERTBUTTON, (WPARAM)idx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 (LPARAM)&newtb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 menu->submenu_id = (HMENU)-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 InsertMenu(parent->submenu_id, (UINT)idx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 (menu_is_separator(menu->name) ? MF_SEPARATOR : MF_STRING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 | MF_BYPOSITION,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 (UINT)menu->id, menu->name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 * Destroy the machine specific menu widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 gui_mch_destroy_menu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 UINT i, j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 char pants[80]; /*<VN> hack*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 * is this a toolbar button?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 if (menu->submenu_id == (HMENU)-1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 int iButton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 iButton = SendMessage(s_toolbarhwnd, TB_COMMANDTOINDEX, (WPARAM)menu->id, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 SendMessage(s_toolbarhwnd, TB_DELETEBUTTON, (WPARAM)iButton, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 * negri: horrible API bug when running 16-bit programs under Win9x or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 * NT means that we can't use MF_BYCOMMAND for menu items which have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 * submenus, including the top-level headings. We have to find the menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 * item and use MF_BYPOSITION instead. :-p
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 if (menu->parent != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 && menu_is_popup(menu->parent->dname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 && menu->parent->submenu_id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 RemoveMenu(menu->parent->submenu_id, menu->id, MF_BYCOMMAND);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 else if (menu->submenu_id == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 RemoveMenu(s_menuBar, menu->id, MF_BYCOMMAND);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 else if (menu->parent != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 i = GetMenuItemCount(menu->parent->submenu_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 for (j = 0; j < i; ++j)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 GetMenuString(menu->parent->submenu_id, j,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 pants, 80, MF_BYPOSITION);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 if (strcmp(pants, menu->name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 RemoveMenu(menu->parent->submenu_id, j, MF_BYPOSITION);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 i = GetMenuItemCount(s_menuBar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 for (j = 0; j < i; ++j)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 GetMenuString(s_menuBar, j, pants, 80, MF_BYPOSITION);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 if (strcmp(pants, menu->name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 RemoveMenu(s_menuBar, j, MF_BYPOSITION);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 if (menu->submenu_id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 DestroyMenu(menu->submenu_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 DrawMenuBar(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 * Make a menu either grey or not grey.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 gui_mch_menu_grey(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 int grey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 * is this a toolbar button?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 if (menu->submenu_id == (HMENU)-1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 SendMessage(s_toolbarhwnd, TB_ENABLEBUTTON,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 (WPARAM)menu->id, (LPARAM) MAKELONG((grey ? FALSE : TRUE), 0) );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 if (grey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 EnableMenuItem(s_menuBar, menu->id, MF_BYCOMMAND | MF_GRAYED);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 EnableMenuItem(s_menuBar, menu->id, MF_BYCOMMAND | MF_ENABLED);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 #endif /*FEAT_MENU*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 /* define some macros used to make the dialogue creation more readable */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 #define add_string(s) strcpy((LPSTR)p, s); (LPSTR)p += (strlen((LPSTR)p) + 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 #define add_word(x) *p++ = (x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 #define add_byte(x) *((LPSTR)p)++ = (x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 #define add_long(x) *((LPDWORD)p)++ = (x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 * stuff for dialogs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 * The callback routine used by all the dialogs. Very simple. First,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 * acknowledges the INITDIALOG message so that Windows knows to do standard
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 * dialog stuff (Return = default, Esc = cancel....) Second, if a button is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 * pressed, return that button's ID - IDCANCEL (2), which is the button's
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 * number.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 static BOOL CALLBACK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 dialog_callback(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 UINT message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 WPARAM wParam,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 LPARAM lParam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 if (message == WM_INITDIALOG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 CenterWindow(hwnd, GetWindow(hwnd, GW_OWNER));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 /* Set focus to the dialog. Set the default button, if specified. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 (void)SetFocus(hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 if (dialog_default_button > IDCANCEL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 (void)SetFocus(GetDlgItem(hwnd, dialog_default_button));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 // if (dialog_default_button > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 // (void)SetFocus(GetDlgItem(hwnd, dialog_default_button + IDCANCEL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 if (message == WM_COMMAND)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 int button = LOWORD(wParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 /* Don't end the dialog if something was selected that was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 * not a button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 if (button >= DLG_NONBUTTON_CONTROL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 /* If the edit box exists, copy the string. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 if (s_textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 s_textfield, IOSIZE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 * Need to check for IDOK because if the user just hits Return to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 * accept the default value, some reason this is what we get.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 if (button == IDOK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 EndDialog(hwnd, dialog_default_button);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 EndDialog(hwnd, button - IDCANCEL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 if ((message == WM_SYSCOMMAND) && (wParam == SC_CLOSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 EndDialog(hwnd, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 * Create a dialog dynamically from the parameter strings.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 * type = type of dialog (question, alert, etc.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 * title = dialog title. may be NULL for default title.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 * message = text to display. Dialog sizes to accommodate it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 * buttons = '\n' separated list of button captions, default first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 * dfltbutton = number of default button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 * This routine returns 1 if the first button is pressed,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 * 2 for the second, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 * 0 indicates Esc was pressed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 * -1 for unexpected error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 * If stubbing out this fn, return 1.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 static const char_u dlg_icons[] = /* must match names in resource file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 IDR_VIM,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 IDR_VIM_ERROR,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 IDR_VIM_ALERT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 IDR_VIM_INFO,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 IDR_VIM_QUESTION
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 gui_mch_dialog(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 int type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 char_u *message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 char_u *buttons,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 int dfltbutton,
2684
951641b8784d updated for version 7.3.102
Bram Moolenaar <bram@vim.org>
parents: 2338
diff changeset
1107 char_u *textfield,
951641b8784d updated for version 7.3.102
Bram Moolenaar <bram@vim.org>
parents: 2338
diff changeset
1108 int ex_cmd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 FARPROC dp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 LPWORD p, pnumitems;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 int numButtons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 int *buttonWidths, *buttonPositions;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 int buttonYpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 int nchar, i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 DWORD lStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 int dlgwidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 int dlgheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 int editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 int horizWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 int msgheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 char_u *pstart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 char_u *pend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 char_u *tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 RECT rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 HWND hwnd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 HDC hdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 HFONT oldFont;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 TEXTMETRIC fontInfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 int fontHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 int textWidth, minButtonWidth, messageWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 int maxDialogWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 int vertical;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 int dlgPaddingX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 int dlgPaddingY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 HGLOBAL hglbDlgTemp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 #ifndef NO_CONSOLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 /* Don't output anything in silent mode ("ex -s") */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 if (silent_mode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 return dfltbutton; /* return default option */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 /* If there is no window yet, open it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 if (s_hwnd == NULL && gui_mch_init() == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 return dfltbutton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 if ((type < 0) || (type > VIM_LAST_TYPE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 /* allocate some memory for dialog template */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 /* TODO should compute this really*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 hglbDlgTemp = GlobalAlloc(GHND, DLG_ALLOC_SIZE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 if (hglbDlgTemp == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 p = (LPWORD) GlobalLock(hglbDlgTemp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 /*
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 3927
diff changeset
1164 * make a copy of 'buttons' to fiddle with it. compiler grizzles because
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 * vim_strsave() doesn't take a const arg (why not?), so cast away the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 * const.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 tbuffer = vim_strsave(buttons);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 if (tbuffer == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 --dfltbutton; /* Change from one-based to zero-based */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 /* Count buttons */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 numButtons = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 for (i = 0; tbuffer[i] != '\0'; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 if (tbuffer[i] == DLG_BUTTON_SEP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 numButtons++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 if (dfltbutton >= numButtons)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 dfltbutton = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 /* Allocate array to hold the width of each button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 buttonWidths = (int *) lalloc(numButtons * sizeof(int), TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 if (buttonWidths == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 /* Allocate array to hold the X position of each button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 buttonPositions = (int *) lalloc(numButtons * sizeof(int), TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 if (buttonPositions == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 * Calculate how big the dialog must be.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 hwnd = GetDesktopWindow();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 hdc = GetWindowDC(hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 dlgPaddingX = DLG_OLD_STYLE_PADDING_X;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 dlgPaddingY = DLG_OLD_STYLE_PADDING_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 GetTextMetrics(hdc, &fontInfo);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 fontHeight = fontInfo.tmHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 /* Minimum width for horizontal button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 minButtonWidth = GetTextWidth(hdc, "Cancel", 6);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 /* Maximum width of a dialog, if possible */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 GetWindowRect(s_hwnd, &rect);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 maxDialogWidth = rect.right - rect.left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 - GetSystemMetrics(SM_CXFRAME) * 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 if (maxDialogWidth < DLG_MIN_MAX_WIDTH)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 maxDialogWidth = DLG_MIN_MAX_WIDTH;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 /* Set dlgwidth to width of message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 pstart = message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 messageWidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 msgheight = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 if (pend == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 pend = pstart + STRLEN(pstart); /* Last line of message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 msgheight += fontHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 textWidth = GetTextWidth(hdc, pstart, pend - pstart);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 if (textWidth > messageWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 messageWidth = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 } while (*pend != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 dlgwidth = messageWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 /* Add width of icon to dlgwidth, and some space */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 dlgwidth += DLG_ICON_WIDTH + 3 * dlgPaddingX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 if (msgheight < DLG_ICON_HEIGHT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 msgheight = DLG_ICON_HEIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 * Check button names. A long one will make the dialog wider.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 if (!vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 // Place buttons horizontally if they fit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 horizWidth = dlgPaddingX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 pstart = tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 if (pend == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 pend = pstart + STRLEN(pstart); // Last button name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 textWidth = GetTextWidth(hdc, pstart, pend - pstart);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 if (textWidth < minButtonWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 textWidth = minButtonWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 textWidth += dlgPaddingX; /* Padding within button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 buttonWidths[i] = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 buttonPositions[i++] = horizWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 horizWidth += textWidth + dlgPaddingX; /* Pad between buttons */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 } while (*pend != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 if (horizWidth > maxDialogWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 vertical = TRUE; // Too wide to fit on the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 else if (horizWidth > dlgwidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 dlgwidth = horizWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 // Stack buttons vertically.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 pstart = tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 if (pend == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 pend = pstart + STRLEN(pstart); // Last button name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 textWidth = GetTextWidth(hdc, pstart, pend - pstart);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 textWidth += dlgPaddingX; /* Padding within button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 textWidth += DLG_VERT_PADDING_X * 2; /* Padding around button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 if (textWidth > dlgwidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 dlgwidth = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 } while (*pend != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 if (dlgwidth < DLG_MIN_WIDTH)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 dlgwidth = DLG_MIN_WIDTH; /* Don't allow a really thin dialog!*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 /* start to fill in the dlgtemplate information. addressing by WORDs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 lStyle = DS_MODALFRAME | WS_CAPTION | WS_VISIBLE ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 add_long(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 pnumitems = p; /*save where the number of items must be stored*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 add_byte(0); // NumberOfItems(will change later)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 add_word(10); // x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 add_word(10); // y
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 add_word(PixelToDialogX(dlgwidth));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 // Dialog height.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 dlgheight = msgheight + 2 * dlgPaddingY +
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 DLG_VERT_PADDING_Y + 2 * fontHeight * numButtons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 dlgheight = msgheight + 3 * dlgPaddingY + 2 * fontHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 // Dialog needs to be taller if contains an edit box.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 editboxheight = fontHeight + dlgPaddingY + 4 * DLG_VERT_PADDING_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 dlgheight += editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 add_word(PixelToDialogY(dlgheight));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 add_byte(0); //menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 add_byte(0); //class
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 /* copy the title of the dialog */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 add_string(title ? title : ("Vim"VIM_VERSION_MEDIUM));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 buttonYpos = msgheight + 2 * dlgPaddingY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 buttonYpos += editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 pstart = tbuffer; //dflt_text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 horizWidth = (dlgwidth - horizWidth) / 2; /* Now it's X offset */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 for (i = 0; i < numButtons; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 /* get end of this button. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 for ( pend = pstart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 *pend && (*pend != DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 pend++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 if (*pend)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 *pend = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 * NOTE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 * setting the BS_DEFPUSHBUTTON style doesn't work because Windows sets
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 * the focus to the first tab-able button and in so doing makes that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 * the default!! Grrr. Workaround: Make the default button the only
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 * one with WS_TABSTOP style. Means user can't tab between buttons, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 * he/she can use arrow keys.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 * NOTE (Thore): Setting BS_DEFPUSHBUTTON works fine when it's the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 * first one, so I changed the correct button to be this style. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 * is necessary because when an edit box is added, we need a button to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 * be default. The edit box will be the default control, and when the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 * user presses enter from the edit box we want the default button to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 * be pressed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 p = add_dialog_element(p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 ((i == dfltbutton || dfltbutton < 0) && textfield != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 PixelToDialogX(DLG_VERT_PADDING_X),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 PixelToDialogY(buttonYpos /* TBK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 + 2 * fontHeight * i),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 PixelToDialogX(dlgwidth - 2 * DLG_VERT_PADDING_X),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 (WORD)(IDCANCEL + 1 + i), (BYTE)0x80, pstart);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 p = add_dialog_element(p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 ((i == dfltbutton || dfltbutton < 0) && textfield != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 PixelToDialogX(horizWidth + buttonPositions[i]),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 PixelToDialogY(buttonYpos), /* TBK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 PixelToDialogX(buttonWidths[i]),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 (WORD)(IDCANCEL + 1 + i), (BYTE)0x80, pstart);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 pstart = pend + 1; /*next button*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 *pnumitems += numButtons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 /* Vim icon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 p = add_dialog_element(p, SS_ICON,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 PixelToDialogX(dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 PixelToDialogY(dlgPaddingY),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 PixelToDialogX(DLG_ICON_WIDTH),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 PixelToDialogY(DLG_ICON_HEIGHT),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 DLG_NONBUTTON_CONTROL + 0, (BYTE)0x82,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 &dlg_icons[type]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 /* Dialog message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 p = add_dialog_element(p, SS_LEFT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 PixelToDialogX(2 * dlgPaddingX + DLG_ICON_WIDTH),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 PixelToDialogY(dlgPaddingY),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 (WORD)(PixelToDialogX(messageWidth) + 1),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 PixelToDialogY(msgheight),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 DLG_NONBUTTON_CONTROL + 1, (BYTE)0x82, message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 /* Edit box */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 p = add_dialog_element(p, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP | WS_BORDER,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 PixelToDialogX(2 * dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 PixelToDialogY(2 * dlgPaddingY + msgheight),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 PixelToDialogX(dlgwidth - 4 * dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 PixelToDialogY(fontHeight + dlgPaddingY),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 DLG_NONBUTTON_CONTROL + 2, (BYTE)0x81, textfield);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 *pnumitems += 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 *pnumitems += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415 SelectFont(hdc, oldFont);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 ReleaseDC(hwnd, hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 dp = MakeProcInstance((FARPROC)dialog_callback, s_hinst);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 /* Let the dialog_callback() function know which button to make default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 * If we have an edit box, make that the default. We also need to tell
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 * dialog_callback() if this dialog contains an edit box or not. We do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 * this by setting s_textfield if it does.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 dialog_default_button = DLG_NONBUTTON_CONTROL + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 s_textfield = textfield;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 dialog_default_button = IDCANCEL + 1 + dfltbutton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 s_textfield = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 /*show the dialog box modally and get a return value*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 nchar = DialogBoxIndirect(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 s_hinst,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 (HGLOBAL) hglbDlgTemp,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 s_hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 (DLGPROC)dp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 FreeProcInstance( dp );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 GlobalUnlock(hglbDlgTemp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 GlobalFree(hglbDlgTemp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 vim_free(tbuffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 vim_free(buttonWidths);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 vim_free(buttonPositions);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 return nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 * Put a simple element (basic class) onto a dialog template in memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 * return a pointer to where the next item should be added.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 * parameters:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 * lStyle = additional style flags
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 * x,y = x & y positions IN DIALOG UNITS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 * w,h = width and height IN DIALOG UNITS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 * Id = ID used in messages
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 * clss = class ID, e.g 0x80 for a button, 0x82 for a static
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 * caption = usually text or resource name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466 * TODO: use the length information noted here to enable the dialog creation
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 * routines to work out more exactly how much memory they need to alloc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 static LPWORD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 add_dialog_element(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 LPWORD p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 DWORD lStyle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 WORD x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 WORD y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 WORD w,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 WORD h,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 WORD Id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 BYTE clss,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 const char *caption)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 lStyle = lStyle | WS_VISIBLE | WS_CHILD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 add_word(x);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 add_word(y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 add_word(w);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 add_word(h);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 add_word(Id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 add_long(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 add_byte(clss);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 if (((lStyle & SS_ICON) != 0) && (clss == 0x82))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 /* Use resource ID */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 add_byte(0xff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 add_byte(*caption);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 add_string(caption);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 add_byte(0); //# of extra bytes following
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 #undef add_byte
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 #undef add_string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 #undef add_long
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 #undef add_word
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 #endif /* FEAT_GUI_DIALOG */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 get_dialog_font_metrics(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 DWORD dlgFontSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 dlgFontSize = GetDialogBaseUnits(); /* fall back to big old system*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 s_dlgfntwidth = LOWORD(dlgFontSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 s_dlgfntheight = HIWORD(dlgFontSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 #if defined(FEAT_TOOLBAR) || defined(PROTO)
3927
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3314
diff changeset
1524
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3314
diff changeset
1525 /* cproto fails on missing include files */
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3314
diff changeset
1526 #ifndef PROTO
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3314
diff changeset
1527 # include "gui_w3~1.h"
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3314
diff changeset
1528 #endif
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3314
diff changeset
1529
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 * Create the toolbar, initially unpopulated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 * (just like the menu, there are no defaults, it's all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 * set up through menu.vim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 initialise_toolbar(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 s_toolbarhwnd = CreateToolbar(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 s_hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 WS_CHILD | WS_VISIBLE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 CMD_TB_BASE, /*<vn>*/
1201
4d2585cf5950 updated for version 7.1b
vimboss
parents: 811
diff changeset
1542 31, //number of images in initial bitmap
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 s_hinst,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 IDR_TOOLBAR1, // id of initial bitmap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 0 // initial number of buttons
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 gui_mch_show_toolbar(vim_strchr(p_go, GO_TOOLBAR) != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 #if defined(FEAT_OLE) || defined(FEAT_EVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 * Make the GUI window come to the foreground.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558 gui_mch_set_foreground(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1559 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1560 if (IsIconic(s_hwnd))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1561 SendMessage(s_hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1562 SetActiveWindow(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1564 #endif