annotate src/gui_w16.c @ 1815:97a73b6f2892 v7.2.113

updated for version 7.2-113
author vimboss
date Sat, 21 Feb 2009 21:04:20 +0000
parents 4d2585cf5950
children da6ec32d8d8f
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;
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
131 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
7
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,
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
491 int min_width, int min_height, int base_width, int base_height,
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
492 int direction)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 RECT workarea_rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 int win_width, win_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 int win_xpos, win_ypos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 WINDOWPLACEMENT wndpl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 /* try to keep window completely on screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 /* get size of the screen work area - use SM_CYFULLSCREEN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 * instead of SM_CYSCREEN so that we don't overlap the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 * taskbar if someone fires us up on Win95/NT */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 workarea_rect.left = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 workarea_rect.top = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 workarea_rect.right = GetSystemMetrics(SM_CXSCREEN);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 workarea_rect.bottom = GetSystemMetrics(SM_CYFULLSCREEN);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 /* get current posision of our window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 wndpl.length = sizeof(WINDOWPLACEMENT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 GetWindowPlacement(s_hwnd, &wndpl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 if (wndpl.showCmd == SW_SHOWNORMAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 win_xpos = wndpl.rcNormalPosition.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 win_ypos = wndpl.rcNormalPosition.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 win_xpos = workarea_rect.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 win_ypos = workarea_rect.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 /* compute the size of the outside of the window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 win_width = width + GetSystemMetrics(SM_CXFRAME) * 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 win_height = height + GetSystemMetrics(SM_CYFRAME) * 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 + GetSystemMetrics(SM_CYCAPTION)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 + gui_mswin_get_menu_height(FALSE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 /* if the window is going off the screen, move it on to the screen */
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
532 if ((direction & RESIZE_HOR) && win_xpos + win_width > workarea_rect.right)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 win_xpos = workarea_rect.right - win_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
535 if ((direction & RESIZE_HOR) && win_xpos < workarea_rect.left)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 win_xpos = workarea_rect.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
538 if ((direction & RESIZE_VERT)
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
539 && win_ypos + win_height > workarea_rect.bottom)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 win_ypos = workarea_rect.bottom - win_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 635
diff changeset
542 if ((direction & RESIZE_VERT) && win_ypos < workarea_rect.top)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 win_ypos = workarea_rect.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 /* set window position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 SetWindowPos(s_hwnd, NULL, win_xpos, win_ypos, win_width, win_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 SWP_NOZORDER | SWP_NOACTIVATE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 /* Menu may wrap differently now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 gui_mswin_get_menu_height(!gui.starting);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 gui_mch_set_scrollbar_thumb(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 scrollbar_T *sb,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 long val,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 long size,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 long max)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 sb->scroll_shift = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 while (max > 32767)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 max = (max + 1) >> 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 val >>= 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 size >>= 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 ++sb->scroll_shift;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 if (sb->scroll_shift > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 ++size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 SetScrollRange(sb->id, SB_CTL, 0, (int) max, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 SetScrollPos(sb->id, SB_CTL, (int) val, TRUE);
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 * Set the current text font.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 gui_mch_set_font(GuiFont font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 gui.currFont = font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 SelectFont(s_hdc, gui.currFont);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 * Set the current text foreground color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 gui_mch_set_fg_color(guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 gui.currFgColor = color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 SetTextColor(s_hdc, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 * Set the current text background color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 gui_mch_set_bg_color(guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 if (gui.currBgColor == color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 gui.currBgColor = color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 SetBkColor(s_hdc, gui.currBgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611
203
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
612 /*
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
613 * Set the current text special color.
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
614 */
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
615 void
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
616 gui_mch_set_sp_color(guicolor_T color)
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
617 {
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
618 /* TODO */
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
619 }
80000fb16feb updated for version 7.0060
vimboss
parents: 7
diff changeset
620
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 gui_mch_draw_string(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 int row,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 int col,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 char_u *text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 int len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 int flags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 #ifndef MSWIN16_FASTTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 static int *padding = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 static int pad_size = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 HPEN hpen, old_pen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 #ifndef MSWIN16_FASTTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 * 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
642 * (below where the bottom of the character should be). If we draw the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 * characters with a solid background, the top row of pixels in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 * character below will be overwritten. We can fix this by filling in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 * background ourselves, to the correct character proportions, and then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 * writing the character in transparent mode. Still have a problem when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 * the character is "_", which gets written on to the character below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 * New fix: set gui.char_ascent to -1. This shifts all characters up one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 * pixel in their slots, which fixes the problem with the bottom row of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 * pixels. We still need this code because otherwise the top row of pixels
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 * becomes a problem. - webb.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 HBRUSH hbr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 RECT rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 if (!(flags & DRAW_TRANSP))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 * Clear background first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 * Note: FillRect() excludes right and bottom of rectangle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 rc.left = FILL_X(col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 rc.top = FILL_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 int cell_len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 /* Compute the length in display cells. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 for (n = 0; n < len; n += MB_BYTE2LEN(text[n]))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 cell_len += (*mb_ptr2cells)(text + n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 rc.right = FILL_X(col + cell_len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 rc.right = FILL_X(col + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 rc.bottom = FILL_Y(row + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 hbr = CreateSolidBrush(gui.currBgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 FillRect(s_hdc, &rc, hbr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 DeleteBrush(hbr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 SetBkMode(s_hdc, TRANSPARENT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 * When drawing block cursor, prevent inverted character spilling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 * over character cell (can happen with bold/italic)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 if (flags & DRAW_CURSOR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 pcliprect = &rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 foptions = ETO_CLIPPED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 * Alternative: write the characters in opaque mode, since we have blocked
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 * bold or italic fonts.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 /* The OPAQUE mode and backcolour have already been set */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 /* The forecolor and font have already been set */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 #ifndef MSWIN16_FASTTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 if (pad_size != Columns || padding == NULL || padding[0] != gui.char_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 vim_free(padding);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 pad_size = Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 padding = (int *)alloc(pad_size * sizeof(int));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 if (padding != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 for (i = 0; i < pad_size; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 padding[i] = gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 * We have to provide the padding argument because italic and bold versions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 * of fixed-width fonts are often one pixel or so wider than their normal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 * versions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 * No check for DRAW_BOLD, Windows will have done it already.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 #ifndef MSWIN16_FASTTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), 0, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 (char *)text, len, padding);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 TextOut(s_hdc, TEXT_X(col), TEXT_Y(row), (char *)text, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 if (flags & DRAW_UNDERL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 hpen = CreatePen(PS_SOLID, 1, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 old_pen = SelectObject(s_hdc, hpen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 /* When p_linespace is 0, overwrite the bottom row of pixels.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 * Otherwise put the line just below the character. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 y = FILL_Y(row + 1) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 #ifndef MSWIN16_FASTTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 if (p_linespace > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 y -= p_linespace - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 MoveToEx(s_hdc, FILL_X(col), y, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 /* Note: LineTo() excludes the last pixel in the line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 LineTo(s_hdc, FILL_X(col + len), y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 DeleteObject(SelectObject(s_hdc, old_pen));
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 * Output routines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 /* Flush any output to the screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 gui_mch_flush(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 /* Is anything needed here? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 clear_rect(RECT *rcp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 /* Use trick for fast rect clear */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 ExtTextOut(s_hdc, 0, 0, ETO_CLIPPED | ETO_OPAQUE, rcp, NULL, 0, NULL);
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
635
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
769 void
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
770 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
771 {
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
772
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
773 *screen_w = GetSystemMetrics(SM_CXFULLSCREEN)
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
774 - GetSystemMetrics(SM_CXFRAME) * 2;
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
775 /* FIXME: dirty trick: Because the gui_get_base_height() doesn't include
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
776 * the menubar for MSwin, we subtract it from the screen height, so that
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
777 * the window size can be made to fit on the screen. */
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
778 *screen_h = GetSystemMetrics(SM_CYFULLSCREEN)
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
779 - GetSystemMetrics(SM_CYFRAME) * 2
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
780 #ifdef FEAT_MENU
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
781 - gui_mswin_get_menu_height(FALSE)
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
782 #endif
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
783 ;
23a639c430c5 updated for version 7.0184
vimboss
parents: 399
diff changeset
784 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 #if defined(FEAT_MENU) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 * Add a sub menu to the menu bar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 gui_mch_add_menu(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 int pos)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 menu->submenu_id = CreatePopupMenu();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 menu->id = s_menu_id++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 if (menu_is_menubar(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 InsertMenu((parent == NULL) ? s_menuBar : parent->submenu_id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 (UINT)pos, MF_POPUP | MF_STRING | MF_BYPOSITION,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 (UINT)menu->submenu_id, menu->name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 /* Fix window size if menu may have wrapped */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 if (parent == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 gui_mswin_get_menu_height(!gui.starting);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 gui_mch_show_popupmenu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 POINT mp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 (void)GetCursorPos((LPPOINT)&mp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 gui_mch_show_popupmenu_at(menu, (int)mp.x, (int)mp.y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 void
399
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
823 gui_make_popup(char_u *path_name, int mouse_pos)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 vimmenu_T *menu = gui_find_menu(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 if (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 /* Find the position of the current cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 DWORD temp_p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 POINT p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 temp_p = GetDCOrg(s_hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 p.x = LOWORD(temp_p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 p.y = HIWORD(temp_p);
399
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
835 if (mouse_pos)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 {
399
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
837 int mx, my;
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
838
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
839 gui_mch_getmouse(&mx, &my);
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
840 p.x += mx;
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
841 p.y += my;
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
842 }
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
843 else if (curwin != NULL)
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
844 {
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
845 p.x += TEXT_X(W_WINCOL(curwin) + curwin->w_wcol + 1);
797041cd1c66 updated for version 7.0105
vimboss
parents: 203
diff changeset
846 p.y += TEXT_Y(W_WINROW(curwin) + curwin->w_wrow + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 msg_scroll = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 gui_mch_show_popupmenu_at(menu, (int)p.x, (int)p.y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 * Add a menu item to a menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 gui_mch_add_menu_item(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 menu->id = s_menu_id++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 menu->submenu_id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 if (menu_is_toolbar(parent->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 TBBUTTON newtb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 vim_memset(&newtb, 0, sizeof(newtb));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 if (menu_is_separator(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 newtb.iBitmap = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 newtb.fsStyle = TBSTYLE_SEP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 if (menu->iconidx >= TOOLBAR_BITMAP_COUNT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 newtb.iBitmap = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 newtb.iBitmap = menu->iconidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 newtb.fsStyle = TBSTYLE_BUTTON;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 newtb.idCommand = menu->id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 newtb.fsState = TBSTATE_ENABLED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 SendMessage(s_toolbarhwnd, TB_INSERTBUTTON, (WPARAM)idx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 (LPARAM)&newtb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 menu->submenu_id = (HMENU)-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 InsertMenu(parent->submenu_id, (UINT)idx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 (menu_is_separator(menu->name) ? MF_SEPARATOR : MF_STRING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 | MF_BYPOSITION,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 (UINT)menu->id, menu->name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 * Destroy the machine specific menu widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 gui_mch_destroy_menu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 UINT i, j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 char pants[80]; /*<VN> hack*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 * is this a toolbar button?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 if (menu->submenu_id == (HMENU)-1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 int iButton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 iButton = SendMessage(s_toolbarhwnd, TB_COMMANDTOINDEX, (WPARAM)menu->id, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 SendMessage(s_toolbarhwnd, TB_DELETEBUTTON, (WPARAM)iButton, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 * negri: horrible API bug when running 16-bit programs under Win9x or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 * NT means that we can't use MF_BYCOMMAND for menu items which have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 * submenus, including the top-level headings. We have to find the menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 * item and use MF_BYPOSITION instead. :-p
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 if (menu->parent != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 && menu_is_popup(menu->parent->dname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 && menu->parent->submenu_id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 RemoveMenu(menu->parent->submenu_id, menu->id, MF_BYCOMMAND);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 else if (menu->submenu_id == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 RemoveMenu(s_menuBar, menu->id, MF_BYCOMMAND);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 else if (menu->parent != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 i = GetMenuItemCount(menu->parent->submenu_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 for (j = 0; j < i; ++j)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 GetMenuString(menu->parent->submenu_id, j,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 pants, 80, MF_BYPOSITION);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 if (strcmp(pants, menu->name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 RemoveMenu(menu->parent->submenu_id, j, MF_BYPOSITION);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 i = GetMenuItemCount(s_menuBar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 for (j = 0; j < i; ++j)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 GetMenuString(s_menuBar, j, pants, 80, MF_BYPOSITION);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 if (strcmp(pants, menu->name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 RemoveMenu(s_menuBar, j, MF_BYPOSITION);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 if (menu->submenu_id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 DestroyMenu(menu->submenu_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 DrawMenuBar(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 * Make a menu either grey or not grey.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 gui_mch_menu_grey(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 int grey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 * is this a toolbar button?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 if (menu->submenu_id == (HMENU)-1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 SendMessage(s_toolbarhwnd, TB_ENABLEBUTTON,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985 (WPARAM)menu->id, (LPARAM) MAKELONG((grey ? FALSE : TRUE), 0) );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 if (grey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 EnableMenuItem(s_menuBar, menu->id, MF_BYCOMMAND | MF_GRAYED);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 EnableMenuItem(s_menuBar, menu->id, MF_BYCOMMAND | MF_ENABLED);
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 #endif /*FEAT_MENU*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 /* define some macros used to make the dialogue creation more readable */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 #define add_string(s) strcpy((LPSTR)p, s); (LPSTR)p += (strlen((LPSTR)p) + 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 #define add_word(x) *p++ = (x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 #define add_byte(x) *((LPSTR)p)++ = (x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 #define add_long(x) *((LPDWORD)p)++ = (x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 * stuff for dialogs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 * The callback routine used by all the dialogs. Very simple. First,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 * acknowledges the INITDIALOG message so that Windows knows to do standard
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 * dialog stuff (Return = default, Esc = cancel....) Second, if a button is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 * pressed, return that button's ID - IDCANCEL (2), which is the button's
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 * number.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 static BOOL CALLBACK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 dialog_callback(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 UINT message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 WPARAM wParam,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 LPARAM lParam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 if (message == WM_INITDIALOG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 CenterWindow(hwnd, GetWindow(hwnd, GW_OWNER));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 /* Set focus to the dialog. Set the default button, if specified. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 (void)SetFocus(hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 if (dialog_default_button > IDCANCEL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 (void)SetFocus(GetDlgItem(hwnd, dialog_default_button));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 // if (dialog_default_button > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 // (void)SetFocus(GetDlgItem(hwnd, dialog_default_button + IDCANCEL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 if (message == WM_COMMAND)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 int button = LOWORD(wParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 /* Don't end the dialog if something was selected that was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 * not a button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 if (button >= DLG_NONBUTTON_CONTROL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 /* If the edit box exists, copy the string. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 if (s_textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 s_textfield, IOSIZE);
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 * Need to check for IDOK because if the user just hits Return to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 * accept the default value, some reason this is what we get.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 if (button == IDOK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 EndDialog(hwnd, dialog_default_button);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 EndDialog(hwnd, button - IDCANCEL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 if ((message == WM_SYSCOMMAND) && (wParam == SC_CLOSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 EndDialog(hwnd, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 * Create a dialog dynamically from the parameter strings.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 * type = type of dialog (question, alert, etc.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 * title = dialog title. may be NULL for default title.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 * message = text to display. Dialog sizes to accommodate it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 * buttons = '\n' separated list of button captions, default first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 * dfltbutton = number of default button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 * This routine returns 1 if the first button is pressed,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 * 2 for the second, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 * 0 indicates Esc was pressed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 * -1 for unexpected error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 * If stubbing out this fn, return 1.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 static const char_u dlg_icons[] = /* must match names in resource file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 IDR_VIM,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 IDR_VIM_ERROR,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 IDR_VIM_ALERT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 IDR_VIM_INFO,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 IDR_VIM_QUESTION
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 gui_mch_dialog(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 int type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 char_u *message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 char_u *buttons,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 int dfltbutton,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 char_u *textfield)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 FARPROC dp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 LPWORD p, pnumitems;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 int numButtons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 int *buttonWidths, *buttonPositions;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 int buttonYpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 int nchar, i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 DWORD lStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 int dlgwidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 int dlgheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 int editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 int horizWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 int msgheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 char_u *pstart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 char_u *pend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 char_u *tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 RECT rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 HWND hwnd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 HDC hdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 HFONT oldFont;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 TEXTMETRIC fontInfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 int fontHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 int textWidth, minButtonWidth, messageWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 int maxDialogWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 int vertical;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 int dlgPaddingX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 int dlgPaddingY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 HGLOBAL hglbDlgTemp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 #ifndef NO_CONSOLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 /* Don't output anything in silent mode ("ex -s") */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 if (silent_mode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 return dfltbutton; /* return default option */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 /* If there is no window yet, open it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 if (s_hwnd == NULL && gui_mch_init() == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 return dfltbutton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 if ((type < 0) || (type > VIM_LAST_TYPE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 /* allocate some memory for dialog template */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 /* TODO should compute this really*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 hglbDlgTemp = GlobalAlloc(GHND, DLG_ALLOC_SIZE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 if (hglbDlgTemp == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 p = (LPWORD) GlobalLock(hglbDlgTemp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 * make a copy of 'buttons' to fiddle with it. complier grizzles because
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 * vim_strsave() doesn't take a const arg (why not?), so cast away the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 * const.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 tbuffer = vim_strsave(buttons);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 if (tbuffer == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 --dfltbutton; /* Change from one-based to zero-based */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 /* Count buttons */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 numButtons = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 for (i = 0; tbuffer[i] != '\0'; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 if (tbuffer[i] == DLG_BUTTON_SEP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 numButtons++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 if (dfltbutton >= numButtons)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 dfltbutton = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 /* Allocate array to hold the width of each button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 buttonWidths = (int *) lalloc(numButtons * sizeof(int), TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 if (buttonWidths == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 /* Allocate array to hold the X position of each button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 buttonPositions = (int *) lalloc(numButtons * sizeof(int), TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 if (buttonPositions == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 * Calculate how big the dialog must be.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 hwnd = GetDesktopWindow();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 hdc = GetWindowDC(hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 dlgPaddingX = DLG_OLD_STYLE_PADDING_X;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 dlgPaddingY = DLG_OLD_STYLE_PADDING_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 GetTextMetrics(hdc, &fontInfo);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 fontHeight = fontInfo.tmHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 /* Minimum width for horizontal button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 minButtonWidth = GetTextWidth(hdc, "Cancel", 6);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 /* Maximum width of a dialog, if possible */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 GetWindowRect(s_hwnd, &rect);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 maxDialogWidth = rect.right - rect.left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 - GetSystemMetrics(SM_CXFRAME) * 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 if (maxDialogWidth < DLG_MIN_MAX_WIDTH)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 maxDialogWidth = DLG_MIN_MAX_WIDTH;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 /* Set dlgwidth to width of message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 pstart = message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 messageWidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 msgheight = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 if (pend == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 pend = pstart + STRLEN(pstart); /* Last line of message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 msgheight += fontHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 textWidth = GetTextWidth(hdc, pstart, pend - pstart);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 if (textWidth > messageWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 messageWidth = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 } while (*pend != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 dlgwidth = messageWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 /* Add width of icon to dlgwidth, and some space */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 dlgwidth += DLG_ICON_WIDTH + 3 * dlgPaddingX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 if (msgheight < DLG_ICON_HEIGHT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 msgheight = DLG_ICON_HEIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 * Check button names. A long one will make the dialog wider.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 if (!vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 // Place buttons horizontally if they fit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 horizWidth = dlgPaddingX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 pstart = tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 if (pend == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 pend = pstart + STRLEN(pstart); // Last button name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 textWidth = GetTextWidth(hdc, pstart, pend - pstart);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 if (textWidth < minButtonWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 textWidth = minButtonWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 textWidth += dlgPaddingX; /* Padding within button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 buttonWidths[i] = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 buttonPositions[i++] = horizWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 horizWidth += textWidth + dlgPaddingX; /* Pad between buttons */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 } while (*pend != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 if (horizWidth > maxDialogWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 vertical = TRUE; // Too wide to fit on the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 else if (horizWidth > dlgwidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 dlgwidth = horizWidth;
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 (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 // Stack buttons vertically.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 pstart = tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 if (pend == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 pend = pstart + STRLEN(pstart); // Last button name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 textWidth = GetTextWidth(hdc, pstart, pend - pstart);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 textWidth += dlgPaddingX; /* Padding within button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 textWidth += DLG_VERT_PADDING_X * 2; /* Padding around button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 if (textWidth > dlgwidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 dlgwidth = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 } while (*pend != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 if (dlgwidth < DLG_MIN_WIDTH)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 dlgwidth = DLG_MIN_WIDTH; /* Don't allow a really thin dialog!*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 /* start to fill in the dlgtemplate information. addressing by WORDs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 lStyle = DS_MODALFRAME | WS_CAPTION | WS_VISIBLE ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 add_long(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 pnumitems = p; /*save where the number of items must be stored*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 add_byte(0); // NumberOfItems(will change later)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 add_word(10); // x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 add_word(10); // y
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 add_word(PixelToDialogX(dlgwidth));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 // Dialog height.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 dlgheight = msgheight + 2 * dlgPaddingY +
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 DLG_VERT_PADDING_Y + 2 * fontHeight * numButtons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 dlgheight = msgheight + 3 * dlgPaddingY + 2 * fontHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 // Dialog needs to be taller if contains an edit box.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 editboxheight = fontHeight + dlgPaddingY + 4 * DLG_VERT_PADDING_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 dlgheight += editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 add_word(PixelToDialogY(dlgheight));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 add_byte(0); //menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 add_byte(0); //class
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 /* copy the title of the dialog */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 add_string(title ? title : ("Vim"VIM_VERSION_MEDIUM));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 buttonYpos = msgheight + 2 * dlgPaddingY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 buttonYpos += editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 pstart = tbuffer; //dflt_text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 horizWidth = (dlgwidth - horizWidth) / 2; /* Now it's X offset */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 for (i = 0; i < numButtons; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 /* get end of this button. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 for ( pend = pstart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 *pend && (*pend != DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 pend++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 if (*pend)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 *pend = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 * NOTE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 * setting the BS_DEFPUSHBUTTON style doesn't work because Windows sets
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 * the focus to the first tab-able button and in so doing makes that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 * the default!! Grrr. Workaround: Make the default button the only
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 * one with WS_TABSTOP style. Means user can't tab between buttons, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 * he/she can use arrow keys.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 * NOTE (Thore): Setting BS_DEFPUSHBUTTON works fine when it's the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 * first one, so I changed the correct button to be this style. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 * is necessary because when an edit box is added, we need a button to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 * be default. The edit box will be the default control, and when the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 * user presses enter from the edit box we want the default button to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 * be pressed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 p = add_dialog_element(p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 ((i == dfltbutton || dfltbutton < 0) && textfield != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 PixelToDialogX(DLG_VERT_PADDING_X),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 PixelToDialogY(buttonYpos /* TBK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 + 2 * fontHeight * i),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 PixelToDialogX(dlgwidth - 2 * DLG_VERT_PADDING_X),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 (WORD)(IDCANCEL + 1 + i), (BYTE)0x80, pstart);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 p = add_dialog_element(p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 ((i == dfltbutton || dfltbutton < 0) && textfield != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 PixelToDialogX(horizWidth + buttonPositions[i]),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 PixelToDialogY(buttonYpos), /* TBK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 PixelToDialogX(buttonWidths[i]),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 (WORD)(IDCANCEL + 1 + i), (BYTE)0x80, pstart);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 pstart = pend + 1; /*next button*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 *pnumitems += numButtons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 /* Vim icon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 p = add_dialog_element(p, SS_ICON,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 PixelToDialogX(dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 PixelToDialogY(dlgPaddingY),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 PixelToDialogX(DLG_ICON_WIDTH),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 PixelToDialogY(DLG_ICON_HEIGHT),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 DLG_NONBUTTON_CONTROL + 0, (BYTE)0x82,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 &dlg_icons[type]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 /* Dialog message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 p = add_dialog_element(p, SS_LEFT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 PixelToDialogX(2 * dlgPaddingX + DLG_ICON_WIDTH),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 PixelToDialogY(dlgPaddingY),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 (WORD)(PixelToDialogX(messageWidth) + 1),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 PixelToDialogY(msgheight),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 DLG_NONBUTTON_CONTROL + 1, (BYTE)0x82, message);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 /* Edit box */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 p = add_dialog_element(p, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP | WS_BORDER,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 PixelToDialogX(2 * dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 PixelToDialogY(2 * dlgPaddingY + msgheight),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 PixelToDialogX(dlgwidth - 4 * dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 PixelToDialogY(fontHeight + dlgPaddingY),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 DLG_NONBUTTON_CONTROL + 2, (BYTE)0x81, textfield);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 *pnumitems += 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 *pnumitems += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 SelectFont(hdc, oldFont);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 ReleaseDC(hwnd, hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 dp = MakeProcInstance((FARPROC)dialog_callback, s_hinst);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 /* Let the dialog_callback() function know which button to make default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 * 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
1419 * dialog_callback() if this dialog contains an edit box or not. We do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 * this by setting s_textfield if it does.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 dialog_default_button = DLG_NONBUTTON_CONTROL + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 s_textfield = textfield;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 dialog_default_button = IDCANCEL + 1 + dfltbutton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 s_textfield = NULL;
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 /*show the dialog box modally and get a return value*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 nchar = DialogBoxIndirect(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 s_hinst,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 (HGLOBAL) hglbDlgTemp,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 s_hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 (DLGPROC)dp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 FreeProcInstance( dp );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 GlobalUnlock(hglbDlgTemp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 GlobalFree(hglbDlgTemp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 vim_free(tbuffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 vim_free(buttonWidths);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 vim_free(buttonPositions);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 return nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 * Put a simple element (basic class) onto a dialog template in memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 * return a pointer to where the next item should be added.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 * parameters:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 * lStyle = additional style flags
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 * x,y = x & y positions IN DIALOG UNITS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 * w,h = width and height IN DIALOG UNITS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 * Id = ID used in messages
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 * clss = class ID, e.g 0x80 for a button, 0x82 for a static
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 * caption = usually text or resource name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 * TODO: use the length information noted here to enable the dialog creation
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 * routines to work out more exactly how much memory they need to alloc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466 static LPWORD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 add_dialog_element(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 LPWORD p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 DWORD lStyle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 WORD x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 WORD y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 WORD w,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 WORD h,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 WORD Id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 BYTE clss,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 const char *caption)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 lStyle = lStyle | WS_VISIBLE | WS_CHILD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 add_word(x);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 add_word(y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 add_word(w);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 add_word(h);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 add_word(Id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 add_long(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 add_byte(clss);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 if (((lStyle & SS_ICON) != 0) && (clss == 0x82))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 /* Use resource ID */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 add_byte(0xff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 add_byte(*caption);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 add_string(caption);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 add_byte(0); //# of extra bytes following
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 #undef add_byte
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 #undef add_string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 #undef add_long
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 #undef add_word
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 #endif /* FEAT_GUI_DIALOG */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 get_dialog_font_metrics(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 DWORD dlgFontSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 dlgFontSize = GetDialogBaseUnits(); /* fall back to big old system*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 s_dlgfntwidth = LOWORD(dlgFontSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 s_dlgfntheight = HIWORD(dlgFontSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 #if defined(FEAT_TOOLBAR) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 #include "gui_w3~1.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 * Create the toolbar, initially unpopulated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 * (just like the menu, there are no defaults, it's all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 * set up through menu.vim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 initialise_toolbar(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 s_toolbarhwnd = CreateToolbar(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 s_hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 WS_CHILD | WS_VISIBLE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 CMD_TB_BASE, /*<vn>*/
1201
4d2585cf5950 updated for version 7.1b
vimboss
parents: 811
diff changeset
1534 31, //number of images in initial bitmap
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 s_hinst,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 IDR_TOOLBAR1, // id of initial bitmap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 0 // initial number of buttons
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 gui_mch_show_toolbar(vim_strchr(p_go, GO_TOOLBAR) != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 #if defined(FEAT_OLE) || defined(FEAT_EVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 * Make the GUI window come to the foreground.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 gui_mch_set_foreground(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 if (IsIconic(s_hwnd))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 SendMessage(s_hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 SetActiveWindow(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 #endif