2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef WEBCORE_PLATFORM_WIDGET_H_
27 #define WEBCORE_PLATFORM_WIDGET_H_
29 #include <wtf/Platform.h>
40 typedef struct HWND__* HWND;
44 typedef struct _GdkDrawable GdkDrawable;
55 class GraphicsContext;
59 class PlatformMouseEvent;
77 virtual IntSize sizeHint() const;
79 virtual void setEnabled(bool);
80 virtual bool isEnabled() const;
87 void resize(int, int);
88 void resize(const IntSize&);
91 void move(const IntPoint&);
93 virtual void paint(GraphicsContext*, const IntRect&);
94 virtual void invalidate();
95 virtual void invalidateRect(const IntRect&);
97 virtual void setFrameGeometry(const IntRect&);
98 virtual IntRect frameGeometry() const;
100 virtual int baselinePosition(int height) const; // relative to the top of the widget
102 bool hasFocus() const;
103 virtual void setFocus();
104 virtual void clearFocus();
105 virtual bool checksDescendantsForFocus() const;
107 virtual FocusPolicy focusPolicy() const;
109 const Font& font() const;
110 virtual void setFont(const Font&);
112 void setCursor(const Cursor&);
118 virtual void populate() {}
120 GraphicsContext* lockDrawingFocus();
121 void unlockDrawingFocus(GraphicsContext*);
122 void enableFlushDrawing();
123 void disableFlushDrawing();
125 void setIsSelected(bool);
127 void setClient(WidgetClient*);
128 WidgetClient* client() const;
130 virtual bool isFrameView() const;
133 void setContainingWindow(HWND);
134 HWND containingWindow() const;
136 void setParent(Widget*);
137 Widget* parent() const;
139 virtual void scrolled() const {};
141 bool capturingMouse() const;
142 void setCapturingMouse(bool);
143 Widget* capturingTarget();
144 Widget* capturingChild();
145 void setCapturingChild(Widget*);
147 void setFocused(bool);
148 Widget* focusedTarget();
149 Widget* focusedChild();
150 void setFocusedChild(Widget*);
151 void clearFocusFromDescendants();
153 IntRect convertToContainingWindow(const IntRect&) const;
154 IntPoint convertToContainingWindow(const IntPoint&) const;
155 IntPoint convertFromContainingWindow(const IntPoint&) const;
157 virtual IntPoint convertChildToSelf(const Widget*, const IntPoint&) const;
158 virtual IntPoint convertSelfToChild(const Widget*, const IntPoint&) const;
160 void setSuppressInvalidation(bool);
162 // These methods will be called on a widget while it is capturing the mouse.
163 virtual void handleMouseMoveEvent(const PlatformMouseEvent&) {};
164 virtual void handleMouseReleaseEvent(const PlatformMouseEvent&) {};
168 Widget(GdkDrawable* drawable);
169 virtual void setDrawable(GdkDrawable* drawable);
170 GdkDrawable* drawable() const;
174 QWidget* parentWidget() const;
175 virtual void setParentWidget(QWidget*);
178 void setQWidget(QWidget*);
182 Widget(NSView* view);
184 NSView* getView() const;
185 NSView* getOuterView() const;
186 void setView(NSView*);
188 void sendConsumedMouseUp();
190 static void beforeMouseDown(NSView*);
191 static void afterMouseDown(NSView*);
193 void addToSuperview(NSView* superview);
194 void removeFromSuperview();
196 static void setDeferFirstResponderChanges(bool);
203 } // namespace WebCore
205 #endif // WEBCORE_PLATFORM_WIDGET_H_