CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / widget / src / windows / nsWindowDefs.h
blob1dc97098a80422682f7116f487b574a07474972c
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Mozilla Foundation.
19 * Portions created by the Initial Developer are Copyright (C) 2009
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Jim Mathies <jmathies@mozilla.com>.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef WindowDefs_h__
40 #define WindowDefs_h__
43 * nsWindowDefs - nsWindow related definitions, consts, and macros.
46 #include "nsBaseWidget.h"
47 #include "nsdefs.h"
48 #include "resource.h"
50 /**************************************************************
52 * SECTION: defines
54 **************************************************************/
56 // A magic APP message that can be sent to quit, sort of like a QUERYENDSESSION/ENDSESSION,
57 // but without the query.
58 #define MOZ_WM_APP_QUIT (WM_APP+0x0300)
60 // GetWindowsVersion constants
61 #define WIN2K_VERSION 0x500
62 #define WINXP_VERSION 0x501
63 #define WIN2K3_VERSION 0x502
64 #define VISTA_VERSION 0x600
65 #define WIN7_VERSION 0x601
67 #ifndef WM_THEMECHANGED
68 #define WM_THEMECHANGED 0x031A
69 #endif
71 #ifndef WM_GETOBJECT
72 #define WM_GETOBJECT 0x03d
73 #endif
75 #ifndef PBT_APMRESUMEAUTOMATIC
76 #define PBT_APMRESUMEAUTOMATIC 0x0012
77 #endif
79 #ifndef WM_MOUSEHWHEEL
80 #define WM_MOUSEHWHEEL 0x020E
81 #endif
83 #ifndef WM_MOUSELEAVE
84 #define WM_MOUSELEAVE 0x02A3
85 #endif
87 #ifndef SPI_GETWHEELSCROLLCHARS
88 #define SPI_GETWHEELSCROLLCHARS 0x006C
89 #endif
91 #ifndef MAPVK_VSC_TO_VK
92 #define MAPVK_VK_TO_VSC 0
93 #define MAPVK_VSC_TO_VK 1
94 #define MAPVK_VK_TO_CHAR 2
95 #endif
97 // ConstrainPosition window positioning slop value
98 #define kWindowPositionSlop 20
100 // Origin of the system context menu when displayed in full screen mode
101 #define MOZ_SYSCONTEXT_X_POS 20
102 #define MOZ_SYSCONTEXT_Y_POS 20
104 // Drop shadow window style
105 #define CS_XP_DROPSHADOW 0x00020000
107 // Don't put more than this many rects in the dirty region, just fluff
108 // out to the bounding-box if there are more
109 #define MAX_RECTS_IN_REGION 100
111 // App Command messages for IntelliMouse and Natural Keyboard Pro
112 // These messages are not included in Visual C++ 6.0, but are in 7.0+
113 #ifndef WM_APPCOMMAND
114 #define WM_APPCOMMAND 0x0319
115 #endif
117 #define FAPPCOMMAND_MASK 0xF000
119 #ifndef WM_GETTITLEBARINFOEX
120 #define WM_GETTITLEBARINFOEX 0x033F
121 #endif
123 #ifndef CCHILDREN_TITLEBAR
124 #define CCHILDREN_TITLEBAR 5
125 #endif
127 #ifndef APPCOMMAND_BROWSER_BACKWARD
128 #define APPCOMMAND_BROWSER_BACKWARD 1
129 #define APPCOMMAND_BROWSER_FORWARD 2
130 #define APPCOMMAND_BROWSER_REFRESH 3
131 #define APPCOMMAND_BROWSER_STOP 4
132 #define APPCOMMAND_BROWSER_SEARCH 5
133 #define APPCOMMAND_BROWSER_FAVORITES 6
134 #define APPCOMMAND_BROWSER_HOME 7
137 * Additional commands currently not in use.
139 *#define APPCOMMAND_VOLUME_MUTE 8
140 *#define APPCOMMAND_VOLUME_DOWN 9
141 *#define APPCOMMAND_VOLUME_UP 10
142 *#define APPCOMMAND_MEDIA_NEXTTRACK 11
143 *#define APPCOMMAND_MEDIA_PREVIOUSTRACK 12
144 *#define APPCOMMAND_MEDIA_STOP 13
145 *#define APPCOMMAND_MEDIA_PLAY_PAUSE 14
146 *#define APPCOMMAND_LAUNCH_MAIL 15
147 *#define APPCOMMAND_LAUNCH_MEDIA_SELECT 16
148 *#define APPCOMMAND_LAUNCH_APP1 17
149 *#define APPCOMMAND_LAUNCH_APP2 18
150 *#define APPCOMMAND_BASS_DOWN 19
151 *#define APPCOMMAND_BASS_BOOST 20
152 *#define APPCOMMAND_BASS_UP 21
153 *#define APPCOMMAND_TREBLE_DOWN 22
154 *#define APPCOMMAND_TREBLE_UP 23
155 *#define FAPPCOMMAND_MOUSE 0x8000
156 *#define FAPPCOMMAND_KEY 0
157 *#define FAPPCOMMAND_OEM 0x1000
160 #define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK))
163 *#define GET_DEVICE_LPARAM(lParam) ((WORD)(HIWORD(lParam) & FAPPCOMMAND_MASK))
164 *#define GET_MOUSEORKEY_LPARAM GET_DEVICE_LPARAM
165 *#define GET_FLAGS_LPARAM(lParam) (LOWORD(lParam))
166 *#define GET_KEYSTATE_LPARAM(lParam) GET_FLAGS_LPARAM(lParam)
168 #endif // #ifndef APPCOMMAND_BROWSER_BACKWARD
170 #if defined(WINCE)
171 #ifndef RDW_NOINTERNALPAINT
172 #define RDW_NOINTERNALPAINT 0
173 #endif
174 #ifndef ERROR
175 #define ERROR 0
176 #endif
177 #endif // defined(WINCE)
179 //Tablet PC Mouse Input Source
180 #if !defined(WINCE)
181 #define TABLET_INK_SIGNATURE 0xFFFFFF00
182 #define TABLET_INK_CHECK 0xFF515700
183 #define TABLET_INK_TOUCH 0x00000080
184 #define MOUSE_INPUT_SOURCE() GetMouseInputSource()
185 #else
186 #define MOUSE_INPUT_SOURCE() nsIDOMNSMouseEvent::MOZ_SOURCE_MOUSE
187 #endif
189 /**************************************************************
191 * SECTION: enums
193 **************************************************************/
195 // nsWindow::sCanQuit
196 typedef enum
198 TRI_UNKNOWN = -1,
199 TRI_FALSE = 0,
200 TRI_TRUE = 1
201 } TriStateBool;
203 /**************************************************************
205 * SECTION: constants
207 **************************************************************/
210 * Native windows class names
212 * ::: IMPORTANT :::
214 * External apps and drivers depend on window class names.
215 * For example, changing the window classes could break
216 * touchpad scrolling or screen readers.
218 const PRUint32 kMaxClassNameLength = 40;
219 const char kClassNameHidden[] = "MozillaHiddenWindowClass";
220 const char kClassNameGeneral[] = "MozillaWindowClass";
221 const char kClassNameDialog[] = "MozillaDialogClass";
222 const char kClassNameDropShadow[] = "MozillaDropShadowWindowClass";
223 const char kClassNameTemp[] = "MozillaTempWindowClass";
225 static const PRUint32 sModifierKeyMap[][3] = {
226 { nsIWidget::CAPS_LOCK, VK_CAPITAL, 0 },
227 { nsIWidget::NUM_LOCK, VK_NUMLOCK, 0 },
228 { nsIWidget::SHIFT_L, VK_SHIFT, VK_LSHIFT },
229 { nsIWidget::SHIFT_R, VK_SHIFT, VK_RSHIFT },
230 { nsIWidget::CTRL_L, VK_CONTROL, VK_LCONTROL },
231 { nsIWidget::CTRL_R, VK_CONTROL, VK_RCONTROL },
232 { nsIWidget::ALT_L, VK_MENU, VK_LMENU },
233 { nsIWidget::ALT_R, VK_MENU, VK_RMENU }
236 /**************************************************************
238 * SECTION: structs
240 **************************************************************/
242 // Used in OnKeyDown
243 struct nsAlternativeCharCode; // defined in nsGUIEvent.h
244 struct nsFakeCharMessage {
245 UINT mCharCode;
246 UINT mScanCode;
249 // Used in char processing
250 struct nsModifierKeyState {
251 PRBool mIsShiftDown;
252 PRBool mIsControlDown;
253 PRBool mIsAltDown;
255 nsModifierKeyState();
256 nsModifierKeyState(PRBool aIsShiftDown, PRBool aIsControlDown,
257 PRBool aIsAltDown) :
258 mIsShiftDown(aIsShiftDown), mIsControlDown(aIsControlDown),
259 mIsAltDown(aIsAltDown)
264 // Used for synthesizing events
265 struct KeyPair {
266 PRUint8 mGeneral;
267 PRUint8 mSpecific;
268 KeyPair(PRUint32 aGeneral, PRUint32 aSpecific)
269 : mGeneral(PRUint8(aGeneral)), mSpecific(PRUint8(aSpecific)) {}
272 #ifndef TITLEBARINFOEX
273 struct TITLEBARINFOEX
275 DWORD cbSize;
276 RECT rcTitleBar;
277 DWORD rgstate[CCHILDREN_TITLEBAR + 1];
278 RECT rgrect[CCHILDREN_TITLEBAR + 1];
280 #endif
282 /**************************************************************
284 * SECTION: macros
286 **************************************************************/
288 #define NSRGB_2_COLOREF(color) \
289 RGB(NS_GET_R(color),NS_GET_G(color),NS_GET_B(color))
290 #define COLOREF_2_NSRGB(color) \
291 NS_RGB(GetRValue(color), GetGValue(color), GetBValue(color))
293 #define VERIFY_WINDOW_STYLE(s) \
294 NS_ASSERTION(((s) & (WS_CHILD | WS_POPUP)) != (WS_CHILD | WS_POPUP), \
295 "WS_POPUP and WS_CHILD are mutually exclusive")
297 #endif /* WindowDefs_h__ */