annotate src/gui_w16.c @ 2545:298d8d6e69be vim73

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