OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef VIEWS_WIDGET_NATIVE_WIDGET_VIEWS_H_ | |
6 #define VIEWS_WIDGET_NATIVE_WIDGET_VIEWS_H_ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "base/message_loop.h" | |
13 #include "ui/base/ui_base_types.h" | |
14 #include "ui/gfx/transform.h" | |
15 #include "views/widget/native_widget_private.h" | |
16 #include "views/widget/widget.h" | |
17 | |
18 namespace views { | |
19 namespace desktop { | |
20 class DesktopWindowView; | |
21 } | |
22 | |
23 namespace internal { | |
24 class NativeWidgetView; | |
25 } | |
26 | |
27 //////////////////////////////////////////////////////////////////////////////// | |
28 // NativeWidgetViews | |
29 // | |
30 // A NativeWidget implementation that uses another View as its native widget. | |
31 // | |
32 class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate { | |
33 public: | |
34 explicit NativeWidgetViews(internal::NativeWidgetDelegate* delegate); | |
35 virtual ~NativeWidgetViews(); | |
36 | |
37 // TODO(beng): remove. | |
38 View* GetView(); | |
39 const View* GetView() const; | |
40 | |
41 // TODO(oshima): These will be moved to WM API. | |
42 void OnActivate(bool active); | |
43 bool OnKeyEvent(const KeyEvent& key_event); | |
44 | |
45 void set_delete_native_view(bool delete_native_view) { | |
46 delete_native_view_ = delete_native_view; | |
47 } | |
48 | |
49 internal::NativeWidgetDelegate* delegate() const { return delegate_; } | |
50 | |
51 protected: | |
52 friend class internal::NativeWidgetView; | |
53 | |
54 // Event handlers that subclass can implmenet custom behavior. | |
55 virtual void OnBoundsChanged(const gfx::Rect& new_bounds, | |
56 const gfx::Rect& old_bounds); | |
57 virtual bool OnMouseEvent(const MouseEvent& event); | |
58 | |
59 // Overridden from internal::NativeWidgetPrivate: | |
60 virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; | |
61 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; | |
62 virtual void UpdateFrameAfterFrameChange() OVERRIDE; | |
63 virtual bool ShouldUseNativeFrame() const OVERRIDE; | |
64 virtual void FrameTypeChanged() OVERRIDE; | |
65 virtual Widget* GetWidget() OVERRIDE; | |
66 virtual const Widget* GetWidget() const OVERRIDE; | |
67 virtual gfx::NativeView GetNativeView() const OVERRIDE; | |
68 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; | |
69 virtual Widget* GetTopLevelWidget() OVERRIDE; | |
70 virtual const ui::Compositor* GetCompositor() const OVERRIDE; | |
71 virtual ui::Compositor* GetCompositor() OVERRIDE; | |
72 virtual void CalculateOffsetToAncestorWithLayer( | |
73 gfx::Point* offset, | |
74 ui::Layer** layer_parent) OVERRIDE; | |
75 virtual void ReorderLayers() OVERRIDE; | |
76 virtual void ViewRemoved(View* view) OVERRIDE; | |
77 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; | |
78 virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE; | |
79 virtual TooltipManager* GetTooltipManager() const OVERRIDE; | |
80 virtual bool IsScreenReaderActive() const OVERRIDE; | |
81 virtual void SendNativeAccessibilityEvent( | |
82 View* view, | |
83 ui::AccessibilityTypes::Event event_type) OVERRIDE; | |
84 virtual void SetMouseCapture() OVERRIDE; | |
85 virtual void ReleaseMouseCapture() OVERRIDE; | |
86 virtual bool HasMouseCapture() const OVERRIDE; | |
87 virtual InputMethod* CreateInputMethod() OVERRIDE; | |
88 virtual void CenterWindow(const gfx::Size& size) OVERRIDE; | |
89 virtual void GetWindowPlacement( | |
90 gfx::Rect* bounds, | |
91 ui::WindowShowState* show_state) const OVERRIDE; | |
92 virtual void SetWindowTitle(const string16& title) OVERRIDE; | |
93 virtual void SetWindowIcons(const SkBitmap& window_icon, | |
94 const SkBitmap& app_icon) OVERRIDE; | |
95 virtual void SetAccessibleName(const string16& name) OVERRIDE; | |
96 virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; | |
97 virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; | |
98 virtual void BecomeModal() OVERRIDE; | |
99 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; | |
100 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; | |
101 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; | |
102 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | |
103 virtual void SetSize(const gfx::Size& size) OVERRIDE; | |
104 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; | |
105 virtual void MoveToTop() OVERRIDE; | |
106 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; | |
107 virtual void Close() OVERRIDE; | |
108 virtual void CloseNow() OVERRIDE; | |
109 virtual void EnableClose(bool enable) OVERRIDE; | |
110 virtual void Show() OVERRIDE; | |
111 virtual void Hide() OVERRIDE; | |
112 virtual void ShowMaximizedWithBounds( | |
113 const gfx::Rect& restored_bounds) OVERRIDE; | |
114 virtual void ShowWithWindowState(ui::WindowShowState window_state) OVERRIDE; | |
115 virtual bool IsVisible() const OVERRIDE; | |
116 virtual void Activate() OVERRIDE; | |
117 virtual void Deactivate() OVERRIDE; | |
118 virtual bool IsActive() const OVERRIDE; | |
119 virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE; | |
120 virtual void Maximize() OVERRIDE; | |
121 virtual void Minimize() OVERRIDE; | |
122 virtual bool IsMaximized() const OVERRIDE; | |
123 virtual bool IsMinimized() const OVERRIDE; | |
124 virtual void Restore() OVERRIDE; | |
125 virtual void SetFullscreen(bool fullscreen) OVERRIDE; | |
126 virtual bool IsFullscreen() const OVERRIDE; | |
127 virtual void SetOpacity(unsigned char opacity) OVERRIDE; | |
128 virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE; | |
129 virtual bool IsAccessibleWidget() const OVERRIDE; | |
130 virtual void RunShellDrag(View* view, | |
131 const ui::OSExchangeData& data, | |
132 int operation) OVERRIDE; | |
133 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; | |
134 virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; | |
135 virtual void ClearNativeFocus() OVERRIDE; | |
136 virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; | |
137 virtual bool ConvertPointFromAncestor( | |
138 const Widget* ancestor, gfx::Point* point) const OVERRIDE; | |
139 virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE; | |
140 virtual void SetInactiveRenderingDisabled(bool value) OVERRIDE; | |
141 | |
142 // Overridden from internal::InputMethodDelegate | |
143 virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE; | |
144 | |
145 private: | |
146 friend class desktop::DesktopWindowView; | |
147 | |
148 typedef std::map<const char*, void*> PropsMap; | |
149 | |
150 // These functions may return NULL during Widget destruction. | |
151 internal::NativeWidgetPrivate* GetParentNativeWidget(); | |
152 const internal::NativeWidgetPrivate* GetParentNativeWidget() const; | |
153 | |
154 bool HandleWindowOperation(const MouseEvent& event); | |
155 | |
156 internal::NativeWidgetDelegate* delegate_; | |
157 | |
158 // Parent Widget (can be NULL). | |
159 Widget* parent_; | |
160 | |
161 internal::NativeWidgetView* view_; | |
162 | |
163 bool active_; | |
164 | |
165 ui::WindowShowState window_state_; | |
166 | |
167 // Set when SetAlwaysOnTop is called, or keep_on_top is set during creation. | |
168 bool always_on_top_; | |
169 | |
170 // The following factory is used for calls to close the NativeWidgetViews | |
171 // instance. | |
172 base::WeakPtrFactory<NativeWidgetViews> close_widget_factory_; | |
173 | |
174 gfx::Rect restored_bounds_; | |
175 ui::Transform restored_transform_; | |
176 | |
177 // See class documentation for Widget in widget.h for a note about ownership. | |
178 Widget::InitParams::Ownership ownership_; | |
179 | |
180 bool delete_native_view_; | |
181 | |
182 // Map used by Set/GetNativeWindowProperty. | |
183 PropsMap props_map_; | |
184 | |
185 DISALLOW_COPY_AND_ASSIGN(NativeWidgetViews); | |
186 }; | |
187 | |
188 } // namespace views | |
189 | |
190 #endif // VIEWS_WIDGET_NATIVE_WIDGET_VIEWS_H_ | |
OLD | NEW |