1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* vim:expandtab:shiftwidth=4:tabstop=4:
4
/* ***** BEGIN LICENSE BLOCK *****
5
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
7
* The contents of this file are subject to the Mozilla Public License Version
8
* 1.1 (the "License"); you may not use this file except in compliance with
9
* the License. You may obtain a copy of the License at
10
* http://www.mozilla.org/MPL/
12
* Software distributed under the License is distributed on an "AS IS" basis,
13
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14
* for the specific language governing rights and limitations under the
17
* The Original Code mozilla.org code.
19
* The Initial Developer of the Original Code Christopher Blizzard
20
* <blizzard@mozilla.org>. Portions created by the Initial Developer
21
* are Copyright (C) 2001 the Initial Developer. All Rights Reserved.
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 __nsWindow_h__
41
#include "nsCommonWidget.h"
43
#include "mozcontainer.h"
44
#include "mozdrawingarea.h"
45
#include "nsWeakReference.h"
47
#include "nsIDragService.h"
53
#include <gtk/gtkwindow.h>
56
#include "nsIAccessNode.h"
57
#include "nsIAccessible.h"
61
#include <gtk/gtkimmulticontext.h>
65
class nsWindow : public nsCommonWidget, public nsSupportsWeakReference {
70
static void ReleaseGlobals();
72
NS_DECL_ISUPPORTS_INHERITED
75
NS_IMETHOD Create(nsIWidget *aParent,
77
EVENT_CALLBACK aHandleEventFunction,
78
nsIDeviceContext *aContext,
79
nsIAppShell *aAppShell,
81
nsWidgetInitData *aInitData);
82
NS_IMETHOD Create(nsNativeWidget aParent,
84
EVENT_CALLBACK aHandleEventFunction,
85
nsIDeviceContext *aContext,
86
nsIAppShell *aAppShell,
88
nsWidgetInitData *aInitData);
89
NS_IMETHOD Destroy(void);
90
NS_IMETHOD SetModal(PRBool aModal);
91
NS_IMETHOD IsVisible(PRBool & aState);
92
NS_IMETHOD ConstrainPosition(PRBool aAllowSlop,
95
NS_IMETHOD Move(PRInt32 aX,
97
NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
100
NS_IMETHOD SetSizeMode(PRInt32 aMode);
101
NS_IMETHOD Enable(PRBool aState);
102
NS_IMETHOD SetFocus(PRBool aRaise = PR_FALSE);
103
NS_IMETHOD GetScreenBounds(nsRect &aRect);
104
NS_IMETHOD SetForegroundColor(const nscolor &aColor);
105
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
106
virtual nsIFontMetrics* GetFont(void);
107
NS_IMETHOD SetFont(const nsFont &aFont);
108
NS_IMETHOD SetCursor(nsCursor aCursor);
109
NS_IMETHOD Validate();
110
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
111
NS_IMETHOD Invalidate(const nsRect &aRect,
112
PRBool aIsSynchronous);
113
NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion,
114
PRBool aIsSynchronous);
116
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
117
NS_IMETHOD Scroll(PRInt32 aDx,
120
NS_IMETHOD ScrollWidgets(PRInt32 aDx,
122
NS_IMETHOD ScrollRect(nsRect &aSrcRect,
125
virtual void* GetNativeData(PRUint32 aDataType);
126
NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle);
127
NS_IMETHOD SetTitle(const nsString& aTitle);
128
NS_IMETHOD SetIcon(const nsAString& aIconSpec);
129
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar);
130
NS_IMETHOD ShowMenuBar(PRBool aShow);
131
NS_IMETHOD WidgetToScreen(const nsRect& aOldRect,
133
NS_IMETHOD ScreenToWidget(const nsRect& aOldRect,
135
NS_IMETHOD BeginResizingChildren(void);
136
NS_IMETHOD EndResizingChildren(void);
137
NS_IMETHOD EnableDragDrop(PRBool aEnable);
138
virtual void ConvertToDeviceCoordinates(nscoord &aX,
140
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData);
141
NS_IMETHOD CaptureMouse(PRBool aCapture);
142
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
144
PRBool aConsumeRollupEvent);
145
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
146
NS_IMETHOD HideWindowChrome(PRBool aShouldHide);
150
gint ConvertBorderStyles(nsBorderStyle aStyle);
153
gboolean OnExposeEvent(GtkWidget *aWidget,
154
GdkEventExpose *aEvent);
155
gboolean OnConfigureEvent(GtkWidget *aWidget,
156
GdkEventConfigure *aEvent);
157
void OnSizeAllocate(GtkWidget *aWidget,
158
GtkAllocation *aAllocation);
159
void OnDeleteEvent(GtkWidget *aWidget,
160
GdkEventAny *aEvent);
161
void OnEnterNotifyEvent(GtkWidget *aWidget,
162
GdkEventCrossing *aEvent);
163
void OnLeaveNotifyEvent(GtkWidget *aWidget,
164
GdkEventCrossing *aEvent);
165
void OnMotionNotifyEvent(GtkWidget *aWidget,
166
GdkEventMotion *aEvent);
167
void OnButtonPressEvent(GtkWidget *aWidget,
168
GdkEventButton *aEvent);
169
void OnButtonReleaseEvent(GtkWidget *aWidget,
170
GdkEventButton *aEvent);
171
void OnContainerFocusInEvent(GtkWidget *aWidget,
172
GdkEventFocus *aEvent);
173
void OnContainerFocusOutEvent(GtkWidget *aWidget,
174
GdkEventFocus *aEvent);
175
gboolean OnKeyPressEvent(GtkWidget *aWidget,
176
GdkEventKey *aEvent);
177
gboolean OnKeyReleaseEvent(GtkWidget *aWidget,
178
GdkEventKey *aEvent);
179
void OnScrollEvent(GtkWidget *aWidget,
180
GdkEventScroll *aEvent);
181
void OnVisibilityNotifyEvent(GtkWidget *aWidget,
182
GdkEventVisibility *aEvent);
183
void OnWindowStateEvent(GtkWidget *aWidget,
184
GdkEventWindowState *aEvent);
185
gboolean OnDragMotionEvent(GtkWidget *aWidget,
186
GdkDragContext *aDragContext,
191
void OnDragLeaveEvent(GtkWidget * aWidget,
192
GdkDragContext *aDragContext,
195
gboolean OnDragDropEvent(GtkWidget *aWidget,
196
GdkDragContext *aDragContext,
201
void OnDragDataReceivedEvent(GtkWidget *aWidget,
202
GdkDragContext *aDragContext,
205
GtkSelectionData*aSelectionData,
209
void OnDragLeave(void);
210
void OnDragEnter(nscoord aX, nscoord aY);
213
nsresult NativeCreate(nsIWidget *aParent,
214
nsNativeWidget aNativeParent,
216
EVENT_CALLBACK aHandleEventFunction,
217
nsIDeviceContext *aContext,
218
nsIAppShell *aAppShell,
219
nsIToolkit *aToolkit,
220
nsWidgetInitData *aInitData);
222
void NativeResize(PRInt32 aWidth,
226
void NativeResize(PRInt32 aX,
232
void NativeShow (PRBool aAction);
234
void EnsureGrabs (void);
235
void GrabPointer (void);
236
void GrabKeyboard (void);
237
void ReleaseGrabs (void);
240
PluginType_NONE = 0, /* do not have any plugin */
241
PluginType_XEMBED, /* the plugin support xembed */
242
PluginType_NONXEMBED /* the plugin does not support xembed */
245
void SetPluginType(PluginType aPluginType);
246
void SetNonXEmbedPluginFocus(void);
247
void LoseNonXEmbedPluginFocus(void);
249
Window mOldFocusWindow;
251
static guint32 mLastButtonPressTime;
254
void IMEDestroyContext (void);
255
void IMESetFocus (void);
256
void IMELoseFocus (void);
257
void IMEComposeStart (void);
258
void IMEComposeText (const PRUnichar *aText,
260
const gchar *aPreeditString,
261
const PangoAttrList *aFeedback);
262
void IMEComposeEnd (void);
263
GtkIMContext* IMEGetContext (void);
264
void IMECreateContext (void);
265
PRBool IMEFilterEvent (GdkEventKey *aEvent);
267
GtkIMContext *mIMContext;
268
PRBool mComposingText;
273
void GetToplevelWidget(GtkWidget **aWidget);
274
void GetContainerWindow(nsWindow **aWindow);
275
void *SetupPluginPort(void);
276
nsresult SetWindowIconList(const nsCStringArray &aIconList);
277
void SetDefaultIcon(void);
280
MozContainer *mContainer;
281
MozDrawingarea *mDrawingarea;
283
GtkWindowGroup *mWindowGroup;
285
PRUint32 mContainerGotFocus : 1,
286
mContainerLostFocus : 1,
287
mContainerBlockFocus : 1,
290
mRetryPointerGrab : 1,
291
mActivatePending : 1,
292
mRetryKeyboardGrab : 1;
293
GtkWindow *mTransientParent;
295
PluginType mPluginType;
298
nsCOMPtr<nsIAccessible> mRootAccessible;
299
void CreateRootAccessible();
300
void GetRootAccessible(nsIAccessible** aAccessible);
301
void DispatchActivateEvent(void);
302
void DispatchDeactivateEvent(void);
303
NS_IMETHOD_(PRBool) DispatchAccessibleEvent(nsIAccessible** aAccessible);
307
static GdkCursor *gsGtkCursorCache[eCursorCount];
309
// all of our DND stuff
310
// this is the last window that had a drag event happen on it.
311
static nsWindow *mLastDragMotionWindow;
312
void InitDragEvent (nsMouseEvent &aEvent);
313
void UpdateDragStatus (nsMouseEvent &aEvent,
314
GdkDragContext *aDragContext,
315
nsIDragService *aDragService);
317
// this is everything we need to be able to fire motion events
319
GtkWidget *mDragMotionWidget;
320
GdkDragContext *mDragMotionContext;
323
guint mDragMotionTime;
324
guint mDragMotionTimerID;
325
nsCOMPtr<nsITimer> mDragLeaveTimer;
327
static PRBool sIsDraggingOutOf;
329
static PRBool DragInProgress(void);
331
void ResetDragMotionTimer (GtkWidget *aWidget,
332
GdkDragContext *aDragContext,
336
void FireDragMotionTimer (void);
337
void FireDragLeaveTimer (void);
338
static guint DragMotionTimerCallback (gpointer aClosure);
339
static void DragLeaveTimerCallback (nsITimer *aTimer, void *aClosure);
343
class nsChildWindow : public nsWindow {
349
#endif /* __nsWindow_h__ */