annotate src/gui_w16.c @ 517:594f25e4a806 v7.0144

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