Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: views/window/non_client_view.h

Issue 8552005: views: Move views/window/ to ui/views/window directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/window/native_frame_view.cc ('k') | views/window/non_client_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef VIEWS_WINDOW_NON_CLIENT_VIEW_H_ 5 #ifndef VIEWS_WINDOW_NON_CLIENT_VIEW_H_
6 #define VIEWS_WINDOW_NON_CLIENT_VIEW_H_ 6 #define VIEWS_WINDOW_NON_CLIENT_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include "views/view.h" 9 #include "ui/views/window/non_client_view.h"
10 #include "views/window/client_view.h" 10 // TODO(tfarina): remove this file once all includes have been updated.
11 11
12 namespace gfx { 12 #endif // VIEWS_WINDOW_NON_CLIENT_VIEW_H_
13 class Path;
14 }
15
16 namespace views {
17
18 ////////////////////////////////////////////////////////////////////////////////
19 // NonClientFrameView
20 //
21 // An object that subclasses NonClientFrameView is a View that renders and
22 // responds to events within the frame portions of the non-client area of a
23 // window. This view does _not_ contain the ClientView, but rather is a sibling
24 // of it.
25 class VIEWS_EXPORT NonClientFrameView : public View {
26 public:
27 // Internal class name.
28 static const char kViewClassName[];
29 // Various edges of the frame border have a 1 px shadow along their edges; in
30 // a few cases we shift elements based on this amount for visual appeal.
31 static const int kFrameShadowThickness;
32 // In restored mode, we draw a 1 px edge around the content area inside the
33 // frame border.
34 static const int kClientEdgeThickness;
35
36 // Sets whether the window should be rendered as active regardless of the
37 // actual active state. Used when bubbles become active to make their parent
38 // appear active. A value of true makes the window render as active always,
39 // false gives normal behavior.
40 void SetInactiveRenderingDisabled(bool disable);
41
42 // Returns the bounds (in this View's parent's coordinates) that the client
43 // view should be laid out within.
44 virtual gfx::Rect GetBoundsForClientView() const = 0;
45
46 virtual gfx::Rect GetWindowBoundsForClientBounds(
47 const gfx::Rect& client_bounds) const = 0;
48
49 // This function must ask the ClientView to do a hittest. We don't do this in
50 // the parent NonClientView because that makes it more difficult to calculate
51 // hittests for regions that are partially obscured by the ClientView, e.g.
52 // HTSYSMENU.
53 virtual int NonClientHitTest(const gfx::Point& point) = 0;
54 virtual void GetWindowMask(const gfx::Size& size,
55 gfx::Path* window_mask) = 0;
56 virtual void EnableClose(bool enable) = 0;
57 virtual void ResetWindowControls() = 0;
58 virtual void UpdateWindowIcon() = 0;
59
60 // Overridden from View:
61 virtual bool HitTest(const gfx::Point& l) const OVERRIDE;
62 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
63 virtual std::string GetClassName() const OVERRIDE;
64
65 protected:
66 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
67
68 NonClientFrameView() : paint_as_active_(false) {}
69
70 // Helper for non-client view implementations to determine which area of the
71 // window border the specified |point| falls within. The other parameters are
72 // the size of the sizing edges, and whether or not the window can be
73 // resized.
74 int GetHTComponentForFrame(const gfx::Point& point,
75 int top_resize_border_height,
76 int resize_border_thickness,
77 int top_resize_corner_height,
78 int resize_corner_width,
79 bool can_resize);
80
81 // Used to determine if the frame should be painted as active. Keyed off the
82 // window's actual active state and the override, see
83 // SetInactiveRenderingDisabled() above.
84 bool ShouldPaintAsActive() const;
85
86 // Invoked from SetInactiveRenderingDisabled(). This implementation invokes
87 // SchedulesPaint as necessary.
88 virtual void ShouldPaintAsActiveChanged();
89
90 private:
91 // True when the non-client view should always be rendered as if the window
92 // were active, regardless of whether or not the top level window actually
93 // is active.
94 bool paint_as_active_;
95 };
96
97 ////////////////////////////////////////////////////////////////////////////////
98 // NonClientView
99 //
100 // The NonClientView is the logical root of all Views contained within a
101 // Window, except for the RootView which is its parent and of which it is the
102 // sole child. The NonClientView has two children, the NonClientFrameView which
103 // is responsible for painting and responding to events from the non-client
104 // portions of the window, and the ClientView, which is responsible for the
105 // same for the client area of the window:
106 //
107 // +- views::Window ------------------------------------+
108 // | +- views::RootView ------------------------------+ |
109 // | | +- views::NonClientView ---------------------+ | |
110 // | | | +- views::NonClientFrameView subclas ---+ | | |
111 // | | | | | | | |
112 // | | | | << all painting and event receiving >> | | | |
113 // | | | | << of the non-client areas of a >> | | | |
114 // | | | | << views::Window. >> | | | |
115 // | | | | | | | |
116 // | | | +----------------------------------------+ | | |
117 // | | | +- views::ClientView or subclass --------+ | | |
118 // | | | | | | | |
119 // | | | | << all painting and event receiving >> | | | |
120 // | | | | << of the client areas of a >> | | | |
121 // | | | | << views::Window. >> | | | |
122 // | | | | | | | |
123 // | | | +----------------------------------------+ | | |
124 // | | +--------------------------------------------+ | |
125 // | +------------------------------------------------+ |
126 // +----------------------------------------------------+
127 //
128 // The NonClientFrameView and ClientView are siblings because due to theme
129 // changes the NonClientFrameView may be replaced with different
130 // implementations (e.g. during the switch from DWM/Aero-Glass to Vista Basic/
131 // Classic rendering).
132 //
133 class VIEWS_EXPORT NonClientView : public View {
134 public:
135 // Internal class name.
136 static const char kViewClassName[];
137
138 NonClientView();
139 virtual ~NonClientView();
140
141 // Returns the current NonClientFrameView instance, or NULL if
142 // it does not exist.
143 NonClientFrameView* frame_view() const { return frame_view_.get(); }
144
145 // Replaces the current NonClientFrameView (if any) with the specified one.
146 void SetFrameView(NonClientFrameView* frame_view);
147
148 // Returns true if the ClientView determines that the containing window can be
149 // closed, false otherwise.
150 bool CanClose();
151
152 // Called by the containing Window when it is closed.
153 void WindowClosing();
154
155 // Changes the frame from native to custom depending on the value of
156 // |use_native_frame|.
157 void UpdateFrame();
158
159 // Prevents the window from being rendered as deactivated when |disable| is
160 // true, until called with |disable| false. Used when a sub-window is to be
161 // shown that shouldn't visually de-activate the window.
162 // Subclasses can override this to perform additional actions when this value
163 // changes.
164 void SetInactiveRenderingDisabled(bool disable);
165
166 // Returns the bounds of the window required to display the content area at
167 // the specified bounds.
168 gfx::Rect GetWindowBoundsForClientBounds(const gfx::Rect client_bounds) const;
169
170 // Determines the windows HT* code when the mouse cursor is at the
171 // specified point, in window coordinates.
172 int NonClientHitTest(const gfx::Point& point);
173
174 // Returns a mask to be used to clip the top level window for the given
175 // size. This is used to create the non-rectangular window shape.
176 void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask);
177
178 // Toggles the enable state for the Close button (and the Close menu item in
179 // the system menu).
180 void EnableClose(bool enable);
181
182 // Tells the window controls as rendered by the NonClientView to reset
183 // themselves to a normal state. This happens in situations where the
184 // containing window does not receive a normal sequences of messages that
185 // would lead to the controls returning to this normal state naturally, e.g.
186 // when the window is maximized, minimized or restored.
187 void ResetWindowControls();
188
189 // Tells the NonClientView to invalidate the NonClientFrameView's window icon.
190 void UpdateWindowIcon();
191
192 // Get/Set client_view property.
193 ClientView* client_view() const { return client_view_; }
194 void set_client_view(ClientView* client_view) {
195 client_view_ = client_view;
196 }
197
198 // Layout just the frame view. This is necessary on Windows when non-client
199 // metrics such as the position of the window controls changes independently
200 // of a window resize message.
201 void LayoutFrameView();
202
203 // Set the accessible name of this view.
204 void SetAccessibleName(const string16& name);
205
206 // NonClientView, View overrides:
207 virtual gfx::Size GetPreferredSize() OVERRIDE;
208 virtual gfx::Size GetMinimumSize() OVERRIDE;
209 virtual void Layout() OVERRIDE;
210 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
211 virtual std::string GetClassName() const OVERRIDE;
212
213 virtual views::View* GetEventHandlerForPoint(const gfx::Point& point)
214 OVERRIDE;
215
216 protected:
217 // NonClientView, View overrides:
218 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child)
219 OVERRIDE;
220
221 private:
222 // A ClientView object or subclass, responsible for sizing the contents view
223 // of the window, hit testing and perhaps other tasks depending on the
224 // implementation.
225 ClientView* client_view_;
226
227 // The NonClientFrameView that renders the non-client portions of the window.
228 // This object is not owned by the view hierarchy because it can be replaced
229 // dynamically as the system settings change.
230 scoped_ptr<NonClientFrameView> frame_view_;
231
232 // The accessible name of this view.
233 string16 accessible_name_;
234
235 DISALLOW_COPY_AND_ASSIGN(NonClientView);
236 };
237
238 } // namespace views
239
240 #endif // #ifndef VIEWS_WINDOW_NON_CLIENT_VIEW_H_
OLDNEW
« no previous file with comments | « views/window/native_frame_view.cc ('k') | views/window/non_client_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698