diff options
24 files changed, 896 insertions, 799 deletions
diff --git a/views/window/client_view.cc b/ui/views/window/client_view.cc index 560983b..560983b 100644 --- a/views/window/client_view.cc +++ b/ui/views/window/client_view.cc diff --git a/ui/views/window/client_view.h b/ui/views/window/client_view.h new file mode 100644 index 0000000..4b809f2 --- /dev/null +++ b/ui/views/window/client_view.h @@ -0,0 +1,89 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_WINDOW_CLIENT_VIEW_H_ +#define UI_VIEWS_WINDOW_CLIENT_VIEW_H_ +#pragma once + +#include "views/view.h" + +namespace views { + +class DialogClientView; +class Widget; + +/////////////////////////////////////////////////////////////////////////////// +// ClientView +// +// A ClientView is a View subclass that is used to occupy the "client area" +// of a widget. It provides basic information to the widget that contains it +// such as non-client hit testing information, sizing etc. Sub-classes of +// ClientView are used to create more elaborate contents, e.g. +// "DialogClientView". +class VIEWS_EXPORT ClientView : public View { + public: + // Internal class name + static const char kViewClassName[]; + + // Constructs a ClientView object for the specified widget with the specified + // contents. Since this object is created during the process of creating + // |widget|, |contents_view| must be valid if you want the initial size of + // the widget to be based on |contents_view|'s preferred size. + ClientView(Widget* widget, View* contents_view); + virtual ~ClientView() {} + + // Manual RTTI ftw. + virtual DialogClientView* AsDialogClientView(); + virtual const DialogClientView* AsDialogClientView() const; + + // Returns true to signal that the Widget can be closed. Specialized + // ClientView subclasses can override this default behavior to allow the + // close to be blocked until the user corrects mistakes, accepts a warning + // dialog, etc. + virtual bool CanClose(); + + // Notification that the widget is closing. + virtual void WidgetClosing(); + + // Tests to see if the specified point (in view coordinates) is within the + // bounds of this view. If so, it returns HTCLIENT in this default + // implementation. If it is outside the bounds of this view, this must return + // HTNOWHERE to tell the caller to do further processing to determine where + // in the non-client area it is (if it is). + // Subclasses of ClientView can extend this logic by overriding this method + // to detect if regions within the client area count as parts of the "non- + // client" area. A good example of this is the size box at the bottom right + // corner of resizable dialog boxes. + virtual int NonClientHitTest(const gfx::Point& point); + + // Overridden from View: + virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual void Layout() OVERRIDE; + virtual std::string GetClassName() const OVERRIDE; + + protected: + // Overridden from View: + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; + virtual void ViewHierarchyChanged(bool is_add, + View* parent, + View* child) OVERRIDE; + + // Accessors for private data members. + View* contents_view() const { return contents_view_; } + void set_contents_view(View* contents_view) { + contents_view_ = contents_view; + } + + private: + // The Widget that hosts this ClientView. + Widget* widget_; + + // The View that this ClientView contains. + View* contents_view_; +}; + +} // namespace views + +#endif // UI_VIEWS_WINDOW_CLIENT_VIEW_H_ diff --git a/views/window/custom_frame_view.cc b/ui/views/window/custom_frame_view.cc index 989f3c55..989f3c55 100644 --- a/views/window/custom_frame_view.cc +++ b/ui/views/window/custom_frame_view.cc diff --git a/ui/views/window/custom_frame_view.h b/ui/views/window/custom_frame_view.h new file mode 100644 index 0000000..8a04dd4 --- /dev/null +++ b/ui/views/window/custom_frame_view.h @@ -0,0 +1,127 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ +#define UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ +#pragma once + +#include "views/controls/button/image_button.h" +#include "views/widget/widget.h" +#include "views/window/non_client_view.h" + +namespace gfx { +class Canvas; +class Font; +class Size; +class Path; +class Point; +} + +namespace views { + +/////////////////////////////////////////////////////////////////////////////// +// +// CustomFrameView +// +// A ChromeView that provides the non client frame for Windows. This means +// rendering the non-standard window caption, border, and controls. +// +//////////////////////////////////////////////////////////////////////////////// +class CustomFrameView : public NonClientFrameView, + public ButtonListener { + public: + explicit CustomFrameView(Widget* frame); + virtual ~CustomFrameView(); + + // Overridden from NonClientFrameView: + virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; + virtual gfx::Rect GetWindowBoundsForClientBounds( + const gfx::Rect& client_bounds) const OVERRIDE; + virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; + virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) + OVERRIDE; + virtual void EnableClose(bool enable) OVERRIDE; + virtual void ResetWindowControls() OVERRIDE; + virtual void UpdateWindowIcon() OVERRIDE; + + // View overrides: + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; + virtual void Layout() OVERRIDE; + virtual gfx::Size GetPreferredSize() OVERRIDE; + + // ButtonListener implementation: + virtual void ButtonPressed(Button* sender, const views::Event& event) + OVERRIDE; + + private: + // Returns the thickness of the border that makes up the window frame edges. + // This does not include any client edge. + int FrameBorderThickness() const; + + // Returns the thickness of the entire nonclient left, right, and bottom + // borders, including both the window frame and any client edge. + int NonClientBorderThickness() const; + + // Returns the height of the entire nonclient top border, including the window + // frame, any title area, and any connected client edge. + int NonClientTopBorderHeight() const; + + // Returns the y-coordinate of the caption buttons. + int CaptionButtonY() const; + + // Returns the thickness of the nonclient portion of the 3D edge along the + // bottom of the titlebar. + int TitlebarBottomThickness() const; + + // Returns the size of the titlebar icon. This is used even when the icon is + // not shown, e.g. to set the titlebar height. + int IconSize() const; + + // Returns the bounds of the titlebar icon (or where the icon would be if + // there was one). + gfx::Rect IconBounds() const; + + // Returns true if the client edge should be drawn. This is true if + // the window delegate wants a client edge and we are not maxmized. + bool ShouldShowClientEdge() const; + + // Paint various sub-components of this view. + void PaintRestoredFrameBorder(gfx::Canvas* canvas); + void PaintMaximizedFrameBorder(gfx::Canvas* canvas); + void PaintTitleBar(gfx::Canvas* canvas); + void PaintRestoredClientEdge(gfx::Canvas* canvas); + + // Layout various sub-components of this view. + void LayoutWindowControls(); + void LayoutTitleBar(); + void LayoutClientView(); + + // The bounds of the client view, in this view's coordinates. + gfx::Rect client_view_bounds_; + + // The layout rect of the title, if visible. + gfx::Rect title_bounds_; + + // Window controls. + ImageButton* close_button_; + ImageButton* restore_button_; + ImageButton* maximize_button_; + ImageButton* minimize_button_; + ImageButton* window_icon_; + bool should_show_minmax_buttons_; + bool should_show_client_edge_; + + // The window that owns this view. + Widget* frame_; + + // Initialize various static resources. + static void InitClass(); + static gfx::Font* title_font_; + + DISALLOW_COPY_AND_ASSIGN(CustomFrameView); +}; + +} // namespace views + +#endif // UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ diff --git a/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc index f0abe6f..f0abe6f 100644 --- a/views/window/dialog_client_view.cc +++ b/ui/views/window/dialog_client_view.cc diff --git a/ui/views/window/dialog_client_view.h b/ui/views/window/dialog_client_view.h new file mode 100644 index 0000000..093815b --- /dev/null +++ b/ui/views/window/dialog_client_view.h @@ -0,0 +1,170 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ +#define UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ +#pragma once + +#include "ui/gfx/font.h" +#include "views/focus/focus_manager.h" +#include "views/controls/button/button.h" +#include "views/window/client_view.h" + +namespace views { + +class DialogDelegate; +class NativeTextButton; +class Widget; +namespace internal { +class RootView; +} + +/////////////////////////////////////////////////////////////////////////////// +// DialogClientView +// +// This ClientView subclass provides the content of a typical dialog box, +// including a strip of buttons at the bottom right of the window, default +// accelerator handlers for accept and cancel, and the ability for the +// embedded contents view to provide extra UI to be shown in the row of +// buttons. +// +// DialogClientView also provides the ability to set an arbitrary view that is +// positioned beneath the buttons. +// +class VIEWS_EXPORT DialogClientView : public ClientView, + public ButtonListener, + public FocusChangeListener { + public: + DialogClientView(Widget* widget, View* contents_view); + virtual ~DialogClientView(); + + // Adds the dialog buttons required by the supplied DialogDelegate to the + // view. + void ShowDialogButtons(); + + // Updates the enabled state and label of the buttons required by the + // supplied DialogDelegate + void UpdateDialogButtons(); + + // Accept the changes made in the window that contains this ClientView. + void AcceptWindow(); + + // Cancel the changes made in the window that contains this ClientView. + void CancelWindow(); + + // Accessors in case the user wishes to adjust these buttons. + NativeTextButton* ok_button() const { return ok_button_; } + NativeTextButton* cancel_button() const { return cancel_button_; } + + // Sets the view that is positioned along the bottom of the buttons. The + // bottom view is positioned beneath the buttons at the full width of the + // dialog. If there is an existing bottom view it is removed and deleted. + void SetBottomView(View* bottom_view); + + // Overridden from View: + virtual void NativeViewHierarchyChanged( + bool attached, + gfx::NativeView native_view, + internal::RootView* root_view) OVERRIDE; + + // Overridden from ClientView: + virtual bool CanClose() OVERRIDE; + virtual void WidgetClosing() OVERRIDE; + virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; + virtual DialogClientView* AsDialogClientView() OVERRIDE; + virtual const DialogClientView* AsDialogClientView() const OVERRIDE; + + // FocusChangeListener implementation: + virtual void OnWillChangeFocus(View* focused_before, + View* focused_now) OVERRIDE; + virtual void OnDidChangeFocus(View* focused_before, + View* focused_now) OVERRIDE; + + protected: + // View overrides: + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; + virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; + virtual void Layout() OVERRIDE; + virtual void ViewHierarchyChanged(bool is_add, View* parent, + View* child) OVERRIDE; + virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; + + // ButtonListener implementation: + virtual void ButtonPressed(Button* sender, + const views::Event& event) OVERRIDE; + + private: + // Paint the size box in the bottom right corner of the window if it is + // resizable. + void PaintSizeBox(gfx::Canvas* canvas); + + // Returns the width of the specified dialog button using the correct font. + int GetButtonWidth(int button) const; + int GetButtonsHeight() const; + + // Position and size various sub-views. + void LayoutDialogButtons(); + void LayoutContentsView(); + + // Makes the specified button the default button. + void SetDefaultButton(NativeTextButton* button); + + bool has_dialog_buttons() const { return ok_button_ || cancel_button_; } + + // Create and add the extra view, if supplied by the delegate. + void CreateExtraView(); + + // Returns the DialogDelegate for the window. + DialogDelegate* GetDialogDelegate() const; + + // Closes the widget. + void Close(); + + // Updates focus listener. + void UpdateFocusListener(); + + static void InitClass(); + + // The dialog buttons. + NativeTextButton* ok_button_; + NativeTextButton* cancel_button_; + + // The button that is currently the default button if any. + NativeTextButton* default_button_; + + // The button-level extra view, NULL unless the dialog delegate supplies one. + View* extra_view_; + + // See description of DialogDelegate::GetSizeExtraViewHeightToButtons for + // details on this. + bool size_extra_view_height_to_buttons_; + + // The layout rect of the size box, when visible. + gfx::Rect size_box_bounds_; + + // True if we've notified the delegate the window is closing and the delegate + // allosed the close. In some situations it's possible to get two closes (see + // http://crbug.com/71940). This is used to avoid notifying the delegate + // twice, which can have bad consequences. + bool notified_delegate_; + + // true if focus listener is added. + bool listening_to_focus_; + + // When ancestor gets changed focus manager gets changed as well. + FocusManager* saved_focus_manager_; + + // View positioned along the bottom, beneath the buttons. + View* bottom_view_; + + // Static resource initialization + static gfx::Font* dialog_button_font_; + + DISALLOW_COPY_AND_ASSIGN(DialogClientView); +}; + +} // namespace views + +#endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ diff --git a/views/window/dialog_delegate.cc b/ui/views/window/dialog_delegate.cc index fc24f90..fc24f90 100644 --- a/views/window/dialog_delegate.cc +++ b/ui/views/window/dialog_delegate.cc diff --git a/ui/views/window/dialog_delegate.h b/ui/views/window/dialog_delegate.h new file mode 100644 index 0000000..75b9d5f --- /dev/null +++ b/ui/views/window/dialog_delegate.h @@ -0,0 +1,128 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ +#define UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ +#pragma once + +#include "base/string16.h" +#include "ui/base/accessibility/accessibility_types.h" +#include "ui/base/ui_base_types.h" +#include "views/widget/widget_delegate.h" +#include "views/window/dialog_client_view.h" + +namespace views { + +class View; + +/////////////////////////////////////////////////////////////////////////////// +// +// DialogDelegate +// +// DialogDelegate is an interface implemented by objects that wish to show a +// dialog box Window. The window that is displayed uses this interface to +// determine how it should be displayed and notify the delegate object of +// certain events. +// +/////////////////////////////////////////////////////////////////////////////// +class VIEWS_EXPORT DialogDelegate : public WidgetDelegate { + public: + virtual DialogDelegate* AsDialogDelegate(); + + // Returns a mask specifying which of the available DialogButtons are visible + // for the dialog. Note: If an OK button is provided, you should provide a + // CANCEL button. A dialog box with just an OK button is frowned upon and + // considered a very special case, so if you're planning on including one, + // you should reconsider, or beng says there will be stabbings. + // + // To use the extra button you need to override GetDialogButtons() + virtual int GetDialogButtons() const; + + // Returns the default dialog button. This should not be a mask as only + // one button should ever be the default button. Return + // ui::DIALOG_BUTTON_NONE if there is no default. Default + // behavior is to return ui::DIALOG_BUTTON_OK or + // ui::DIALOG_BUTTON_CANCEL (in that order) if they are + // present, ui::DIALOG_BUTTON_NONE otherwise. + virtual int GetDefaultDialogButton() const; + + // Returns the label of the specified dialog button. + virtual string16 GetDialogButtonLabel(ui::DialogButton button) const; + + // Returns whether the specified dialog button is enabled. + virtual bool IsDialogButtonEnabled(ui::DialogButton button) const; + + // Returns whether the specified dialog button is visible. + virtual bool IsDialogButtonVisible(ui::DialogButton button) const; + + // Returns whether accelerators are enabled on the button. This is invoked + // when an accelerator is pressed, not at construction time. This + // returns true. + virtual bool AreAcceleratorsEnabled(ui::DialogButton button); + + // Override this function if with a view which will be shown in the same + // row as the OK and CANCEL buttons but flush to the left and extending + // up to the buttons. + virtual View* GetExtraView(); + + // Returns whether the height of the extra view should be at least as tall as + // the buttons. The default (false) is to give the extra view it's preferred + // height. By returning true the height becomes + // max(extra_view preferred height, buttons preferred height). + virtual bool GetSizeExtraViewHeightToButtons(); + + // For Dialog boxes, if there is a "Cancel" button, this is called when the + // user presses the "Cancel" button or the Close button on the window or + // in the system menu, or presses the Esc key. This function should return + // true if the window can be closed after it returns, or false if it must + // remain open. + virtual bool Cancel(); + + // For Dialog boxes, this is called when the user presses the "OK" button, + // or the Enter key. Can also be called on Esc key or close button + // presses if there is no "Cancel" button. This function should return + // true if the window can be closed after it returns, or false if it must + // remain open. If |window_closing| is true, it means that this handler is + // being called because the window is being closed (e.g. by Window::Close) + // and there is no Cancel handler, so Accept is being called instead. + virtual bool Accept(bool window_closing); + virtual bool Accept(); + + // Overridden from WindowDelegate: + virtual View* GetInitiallyFocusedView() OVERRIDE; + virtual ClientView* CreateClientView(Widget* widget) OVERRIDE; + + // Called when the window has been closed. + virtual void OnClose() {} + + // A helper for accessing the DialogClientView object contained by this + // delegate's Window. + const DialogClientView* GetDialogClientView() const; + DialogClientView* GetDialogClientView(); + + protected: + // Overridden from WindowDelegate: + virtual ui::AccessibilityTypes::Role GetAccessibleWindowRole() const OVERRIDE; +}; + +// A DialogDelegate implementation that is-a View. Used to override GetWidget() +// to call View's GetWidget() for the common case where a DialogDelegate +// implementation is-a View. +class VIEWS_EXPORT DialogDelegateView : public DialogDelegate, + public View { + public: + DialogDelegateView(); + virtual ~DialogDelegateView(); + + // Overridden from DialogDelegate: + virtual Widget* GetWidget() OVERRIDE; + virtual const Widget* GetWidget() const OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(DialogDelegateView); +}; + +} // namespace views + +#endif // UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ diff --git a/views/window/native_frame_view.cc b/ui/views/window/native_frame_view.cc index 8cb7dfd..8cb7dfd 100644 --- a/views/window/native_frame_view.cc +++ b/ui/views/window/native_frame_view.cc diff --git a/ui/views/window/native_frame_view.h b/ui/views/window/native_frame_view.h new file mode 100644 index 0000000..de7f8ae --- /dev/null +++ b/ui/views/window/native_frame_view.h @@ -0,0 +1,48 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_WINDOW_NATIVE_FRAME_VIEW_H_ +#define UI_VIEWS_WINDOW_NATIVE_FRAME_VIEW_H_ +#pragma once + +#include "views/window/non_client_view.h" + +namespace views { + +class Widget; + +class VIEWS_EXPORT NativeFrameView : public NonClientFrameView { + public: + explicit NativeFrameView(Widget* frame); + virtual ~NativeFrameView(); + + // NonClientFrameView overrides: + virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; + virtual gfx::Rect GetWindowBoundsForClientBounds( + const gfx::Rect& client_bounds) const OVERRIDE; + virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; + virtual void GetWindowMask(const gfx::Size& size, + gfx::Path* window_mask) OVERRIDE; + virtual void EnableClose(bool enable) OVERRIDE; + virtual void ResetWindowControls() OVERRIDE; + virtual void UpdateWindowIcon() OVERRIDE; + + // View overrides: + + // Returns the client size. On Windows, this is the expected behavior for + // native frames (see |NativeWidgetWin::WidgetSizeIsClientSize()|), while + // other platforms currently always return client bounds from + // |GetWindowBoundsForClientBounds()|. + virtual gfx::Size GetPreferredSize() OVERRIDE; + + private: + // Our containing frame. + Widget* frame_; + + DISALLOW_COPY_AND_ASSIGN(NativeFrameView); +}; + +} // namespace views + +#endif // UI_VIEWS_WINDOW_NATIVE_FRAME_VIEW_H_ diff --git a/views/window/non_client_view.cc b/ui/views/window/non_client_view.cc index be1cdac..be1cdac 100644 --- a/views/window/non_client_view.cc +++ b/ui/views/window/non_client_view.cc diff --git a/ui/views/window/non_client_view.h b/ui/views/window/non_client_view.h new file mode 100644 index 0000000..db2ab9b --- /dev/null +++ b/ui/views/window/non_client_view.h @@ -0,0 +1,240 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_WINDOW_NON_CLIENT_VIEW_H_ +#define UI_VIEWS_WINDOW_NON_CLIENT_VIEW_H_ +#pragma once + +#include "views/view.h" +#include "views/window/client_view.h" + +namespace gfx { +class Path; +} + +namespace views { + +//////////////////////////////////////////////////////////////////////////////// +// NonClientFrameView +// +// An object that subclasses NonClientFrameView is a View that renders and +// responds to events within the frame portions of the non-client area of a +// window. This view does _not_ contain the ClientView, but rather is a sibling +// of it. +class VIEWS_EXPORT NonClientFrameView : public View { + public: + // Internal class name. + static const char kViewClassName[]; + // Various edges of the frame border have a 1 px shadow along their edges; in + // a few cases we shift elements based on this amount for visual appeal. + static const int kFrameShadowThickness; + // In restored mode, we draw a 1 px edge around the content area inside the + // frame border. + static const int kClientEdgeThickness; + + // Sets whether the window should be rendered as active regardless of the + // actual active state. Used when bubbles become active to make their parent + // appear active. A value of true makes the window render as active always, + // false gives normal behavior. + void SetInactiveRenderingDisabled(bool disable); + + // Returns the bounds (in this View's parent's coordinates) that the client + // view should be laid out within. + virtual gfx::Rect GetBoundsForClientView() const = 0; + + virtual gfx::Rect GetWindowBoundsForClientBounds( + const gfx::Rect& client_bounds) const = 0; + + // This function must ask the ClientView to do a hittest. We don't do this in + // the parent NonClientView because that makes it more difficult to calculate + // hittests for regions that are partially obscured by the ClientView, e.g. + // HTSYSMENU. + virtual int NonClientHitTest(const gfx::Point& point) = 0; + virtual void GetWindowMask(const gfx::Size& size, + gfx::Path* window_mask) = 0; + virtual void EnableClose(bool enable) = 0; + virtual void ResetWindowControls() = 0; + virtual void UpdateWindowIcon() = 0; + + // Overridden from View: + virtual bool HitTest(const gfx::Point& l) const OVERRIDE; + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual std::string GetClassName() const OVERRIDE; + + protected: + virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; + + NonClientFrameView() : paint_as_active_(false) {} + + // Helper for non-client view implementations to determine which area of the + // window border the specified |point| falls within. The other parameters are + // the size of the sizing edges, and whether or not the window can be + // resized. + int GetHTComponentForFrame(const gfx::Point& point, + int top_resize_border_height, + int resize_border_thickness, + int top_resize_corner_height, + int resize_corner_width, + bool can_resize); + + // Used to determine if the frame should be painted as active. Keyed off the + // window's actual active state and the override, see + // SetInactiveRenderingDisabled() above. + bool ShouldPaintAsActive() const; + + // Invoked from SetInactiveRenderingDisabled(). This implementation invokes + // SchedulesPaint as necessary. + virtual void ShouldPaintAsActiveChanged(); + + private: + // True when the non-client view should always be rendered as if the window + // were active, regardless of whether or not the top level window actually + // is active. + bool paint_as_active_; +}; + +//////////////////////////////////////////////////////////////////////////////// +// NonClientView +// +// The NonClientView is the logical root of all Views contained within a +// Window, except for the RootView which is its parent and of which it is the +// sole child. The NonClientView has two children, the NonClientFrameView which +// is responsible for painting and responding to events from the non-client +// portions of the window, and the ClientView, which is responsible for the +// same for the client area of the window: +// +// +- views::Window ------------------------------------+ +// | +- views::RootView ------------------------------+ | +// | | +- views::NonClientView ---------------------+ | | +// | | | +- views::NonClientFrameView subclas ---+ | | | +// | | | | | | | | +// | | | | << all painting and event receiving >> | | | | +// | | | | << of the non-client areas of a >> | | | | +// | | | | << views::Window. >> | | | | +// | | | | | | | | +// | | | +----------------------------------------+ | | | +// | | | +- views::ClientView or subclass --------+ | | | +// | | | | | | | | +// | | | | << all painting and event receiving >> | | | | +// | | | | << of the client areas of a >> | | | | +// | | | | << views::Window. >> | | | | +// | | | | | | | | +// | | | +----------------------------------------+ | | | +// | | +--------------------------------------------+ | | +// | +------------------------------------------------+ | +// +----------------------------------------------------+ +// +// The NonClientFrameView and ClientView are siblings because due to theme +// changes the NonClientFrameView may be replaced with different +// implementations (e.g. during the switch from DWM/Aero-Glass to Vista Basic/ +// Classic rendering). +// +class VIEWS_EXPORT NonClientView : public View { + public: + // Internal class name. + static const char kViewClassName[]; + + NonClientView(); + virtual ~NonClientView(); + + // Returns the current NonClientFrameView instance, or NULL if + // it does not exist. + NonClientFrameView* frame_view() const { return frame_view_.get(); } + + // Replaces the current NonClientFrameView (if any) with the specified one. + void SetFrameView(NonClientFrameView* frame_view); + + // Returns true if the ClientView determines that the containing window can be + // closed, false otherwise. + bool CanClose(); + + // Called by the containing Window when it is closed. + void WindowClosing(); + + // Changes the frame from native to custom depending on the value of + // |use_native_frame|. + void UpdateFrame(); + + // Prevents the window from being rendered as deactivated when |disable| is + // true, until called with |disable| false. Used when a sub-window is to be + // shown that shouldn't visually de-activate the window. + // Subclasses can override this to perform additional actions when this value + // changes. + void SetInactiveRenderingDisabled(bool disable); + + // Returns the bounds of the window required to display the content area at + // the specified bounds. + gfx::Rect GetWindowBoundsForClientBounds(const gfx::Rect client_bounds) const; + + // Determines the windows HT* code when the mouse cursor is at the + // specified point, in window coordinates. + int NonClientHitTest(const gfx::Point& point); + + // Returns a mask to be used to clip the top level window for the given + // size. This is used to create the non-rectangular window shape. + void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); + + // Toggles the enable state for the Close button (and the Close menu item in + // the system menu). + void EnableClose(bool enable); + + // Tells the window controls as rendered by the NonClientView to reset + // themselves to a normal state. This happens in situations where the + // containing window does not receive a normal sequences of messages that + // would lead to the controls returning to this normal state naturally, e.g. + // when the window is maximized, minimized or restored. + void ResetWindowControls(); + + // Tells the NonClientView to invalidate the NonClientFrameView's window icon. + void UpdateWindowIcon(); + + // Get/Set client_view property. + ClientView* client_view() const { return client_view_; } + void set_client_view(ClientView* client_view) { + client_view_ = client_view; + } + + // Layout just the frame view. This is necessary on Windows when non-client + // metrics such as the position of the window controls changes independently + // of a window resize message. + void LayoutFrameView(); + + // Set the accessible name of this view. + void SetAccessibleName(const string16& name); + + // NonClientView, View overrides: + virtual gfx::Size GetPreferredSize() OVERRIDE; + virtual gfx::Size GetMinimumSize() OVERRIDE; + virtual void Layout() OVERRIDE; + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; + virtual std::string GetClassName() const OVERRIDE; + + virtual views::View* GetEventHandlerForPoint(const gfx::Point& point) + OVERRIDE; + + protected: + // NonClientView, View overrides: + virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child) + OVERRIDE; + + private: + // A ClientView object or subclass, responsible for sizing the contents view + // of the window, hit testing and perhaps other tasks depending on the + // implementation. + ClientView* client_view_; + + // The NonClientFrameView that renders the non-client portions of the window. + // This object is not owned by the view hierarchy because it can be replaced + // dynamically as the system settings change. + scoped_ptr<NonClientFrameView> frame_view_; + + // The accessible name of this view. + string16 accessible_name_; + + DISALLOW_COPY_AND_ASSIGN(NonClientView); +}; + +} // namespace views + +#endif // UI_VIEWS_WINDOW_NON_CLIENT_VIEW_H_ diff --git a/ui/views/window/window_resources.h b/ui/views/window/window_resources.h new file mode 100644 index 0000000..14afc43 --- /dev/null +++ b/ui/views/window/window_resources.h @@ -0,0 +1,32 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_WINDOW_WINDOW_RESOURCES_H_ +#define UI_VIEWS_WINDOW_WINDOW_RESOURCES_H_ +#pragma once + +class SkBitmap; + +namespace views { + +typedef int FramePartBitmap; + +/////////////////////////////////////////////////////////////////////////////// +// WindowResources +// +// An interface implemented by an object providing bitmaps to render the +// contents of a window frame. The Window may swap in different +// implementations of this interface to render different modes. The definition +// of FramePartBitmap depends on the implementation. +// +class WindowResources { + public: + virtual ~WindowResources() {} + + virtual SkBitmap* GetPartBitmap(FramePartBitmap part) const = 0; +}; + +} // namespace views + +#endif // UI_VIEWS_WINDOW_WINDOW_RESOURCES_H_ diff --git a/views/window/window_shape.cc b/ui/views/window/window_shape.cc index 6f88ea4..869ec21 100644 --- a/views/window/window_shape.cc +++ b/ui/views/window/window_shape.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/ui/views/window/window_shape.h b/ui/views/window/window_shape.h new file mode 100644 index 0000000..6db3add --- /dev/null +++ b/ui/views/window/window_shape.h @@ -0,0 +1,25 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_WINDOW_WINDOW_SHAPE_H_ +#define UI_VIEWS_WINDOW_WINDOW_SHAPE_H_ +#pragma once + +#include "views/views_export.h" + +namespace gfx { +class Size; +class Path; +} + +namespace views { + +// Sets the window mask to a style that most likely matches +// ui/resources/window_* +VIEWS_EXPORT void GetDefaultWindowMask(const gfx::Size& size, + gfx::Path* window_mask); + +} // namespace views + +#endif // UI_VIEWS_WINDOW_WINDOW_SHAPE_H_ diff --git a/views/views.gyp b/views/views.gyp index 6f4da62..148904f9 100644 --- a/views/views.gyp +++ b/views/views.gyp @@ -398,21 +398,21 @@ 'widget/widget_delegate.h', 'widget/window_manager.cc', 'widget/window_manager.h', - 'window/client_view.cc', - 'window/client_view.h', - 'window/custom_frame_view.cc', - 'window/custom_frame_view.h', - 'window/dialog_client_view.cc', - 'window/dialog_client_view.h', - 'window/dialog_delegate.cc', - 'window/dialog_delegate.h', - 'window/native_frame_view.cc', - 'window/native_frame_view.h', - 'window/non_client_view.cc', - 'window/non_client_view.h', - 'window/window_resources.h', - 'window/window_shape.cc', - 'window/window_shape.h', + '../ui/views/window/client_view.cc', + '../ui/views/window/client_view.h', + '../ui/views/window/custom_frame_view.cc', + '../ui/views/window/window/custom_frame_view.h', + '../ui/views/window/dialog_client_view.cc', + '../ui/views/window/window/dialog_client_view.h', + '../ui/views/window/dialog_delegate.cc', + '../ui/views/window/dialog_delegate.h', + '../ui/views/window/native_frame_view.cc', + '../ui/views/window/native_frame_view.h', + '../ui/views/window/non_client_view.cc', + '../ui/views/window/non_client_view.h', + '../ui/views/window/window_resources.h', + '../ui/views/window/window_shape.cc', + '../ui/views/window/window_shape.h', ], 'include_dirs': [ '../third_party/wtl/include', diff --git a/views/window/client_view.h b/views/window/client_view.h index 4cd6f14..b4da46b 100644 --- a/views/window/client_view.h +++ b/views/window/client_view.h @@ -6,84 +6,7 @@ #define VIEWS_WINDOW_CLIENT_VIEW_H_ #pragma once -#include "views/view.h" +#include "ui/views/window/client_view.h" +// TODO(tfarina): remove this file once all includes have been updated. -namespace views { - -class DialogClientView; -class Widget; - -/////////////////////////////////////////////////////////////////////////////// -// ClientView -// -// A ClientView is a View subclass that is used to occupy the "client area" -// of a widget. It provides basic information to the widget that contains it -// such as non-client hit testing information, sizing etc. Sub-classes of -// ClientView are used to create more elaborate contents, e.g. -// "DialogClientView". -class VIEWS_EXPORT ClientView : public View { - public: - // Internal class name - static const char kViewClassName[]; - - // Constructs a ClientView object for the specified widget with the specified - // contents. Since this object is created during the process of creating - // |widget|, |contents_view| must be valid if you want the initial size of - // the widget to be based on |contents_view|'s preferred size. - ClientView(Widget* widget, View* contents_view); - virtual ~ClientView() {} - - // Manual RTTI ftw. - virtual DialogClientView* AsDialogClientView(); - virtual const DialogClientView* AsDialogClientView() const; - - // Returns true to signal that the Widget can be closed. Specialized - // ClientView subclasses can override this default behavior to allow the - // close to be blocked until the user corrects mistakes, accepts a warning - // dialog, etc. - virtual bool CanClose(); - - // Notification that the widget is closing. - virtual void WidgetClosing(); - - // Tests to see if the specified point (in view coordinates) is within the - // bounds of this view. If so, it returns HTCLIENT in this default - // implementation. If it is outside the bounds of this view, this must return - // HTNOWHERE to tell the caller to do further processing to determine where - // in the non-client area it is (if it is). - // Subclasses of ClientView can extend this logic by overriding this method - // to detect if regions within the client area count as parts of the "non- - // client" area. A good example of this is the size box at the bottom right - // corner of resizable dialog boxes. - virtual int NonClientHitTest(const gfx::Point& point); - - // Overridden from View: - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void Layout() OVERRIDE; - virtual std::string GetClassName() const OVERRIDE; - - protected: - // Overridden from View: - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; - virtual void ViewHierarchyChanged(bool is_add, - View* parent, - View* child) OVERRIDE; - - // Accessors for private data members. - View* contents_view() const { return contents_view_; } - void set_contents_view(View* contents_view) { - contents_view_ = contents_view; - } - - private: - // The Widget that hosts this ClientView. - Widget* widget_; - - // The View that this ClientView contains. - View* contents_view_; -}; - -} // namespace views - -#endif // #ifndef VIEWS_WINDOW_CLIENT_VIEW_H_ +#endif // VIEWS_WINDOW_CLIENT_VIEW_H_ diff --git a/views/window/custom_frame_view.h b/views/window/custom_frame_view.h index ec479a4..c853829 100644 --- a/views/window/custom_frame_view.h +++ b/views/window/custom_frame_view.h @@ -6,122 +6,7 @@ #define VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ #pragma once -#include "views/controls/button/image_button.h" -#include "views/widget/widget.h" -#include "views/window/non_client_view.h" - -namespace gfx { -class Canvas; -class Font; -class Size; -class Path; -class Point; -} - -namespace views { - -/////////////////////////////////////////////////////////////////////////////// -// -// CustomFrameView -// -// A ChromeView that provides the non client frame for Windows. This means -// rendering the non-standard window caption, border, and controls. -// -//////////////////////////////////////////////////////////////////////////////// -class CustomFrameView : public NonClientFrameView, - public ButtonListener { - public: - explicit CustomFrameView(Widget* frame); - virtual ~CustomFrameView(); - - // Overridden from NonClientFrameView: - virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; - virtual gfx::Rect GetWindowBoundsForClientBounds( - const gfx::Rect& client_bounds) const OVERRIDE; - virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; - virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) - OVERRIDE; - virtual void EnableClose(bool enable) OVERRIDE; - virtual void ResetWindowControls() OVERRIDE; - virtual void UpdateWindowIcon() OVERRIDE; - - // View overrides: - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - virtual void Layout() OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; - - // ButtonListener implementation: - virtual void ButtonPressed(Button* sender, const views::Event& event) - OVERRIDE; - - private: - // Returns the thickness of the border that makes up the window frame edges. - // This does not include any client edge. - int FrameBorderThickness() const; - - // Returns the thickness of the entire nonclient left, right, and bottom - // borders, including both the window frame and any client edge. - int NonClientBorderThickness() const; - - // Returns the height of the entire nonclient top border, including the window - // frame, any title area, and any connected client edge. - int NonClientTopBorderHeight() const; - - // Returns the y-coordinate of the caption buttons. - int CaptionButtonY() const; - - // Returns the thickness of the nonclient portion of the 3D edge along the - // bottom of the titlebar. - int TitlebarBottomThickness() const; - - // Returns the size of the titlebar icon. This is used even when the icon is - // not shown, e.g. to set the titlebar height. - int IconSize() const; - - // Returns the bounds of the titlebar icon (or where the icon would be if - // there was one). - gfx::Rect IconBounds() const; - - // Returns true if the client edge should be drawn. This is true if - // the window delegate wants a client edge and we are not maxmized. - bool ShouldShowClientEdge() const; - - // Paint various sub-components of this view. - void PaintRestoredFrameBorder(gfx::Canvas* canvas); - void PaintMaximizedFrameBorder(gfx::Canvas* canvas); - void PaintTitleBar(gfx::Canvas* canvas); - void PaintRestoredClientEdge(gfx::Canvas* canvas); - - // Layout various sub-components of this view. - void LayoutWindowControls(); - void LayoutTitleBar(); - void LayoutClientView(); - - // The bounds of the client view, in this view's coordinates. - gfx::Rect client_view_bounds_; - - // The layout rect of the title, if visible. - gfx::Rect title_bounds_; - - // Window controls. - ImageButton* close_button_; - ImageButton* restore_button_; - ImageButton* maximize_button_; - ImageButton* minimize_button_; - ImageButton* window_icon_; - bool should_show_minmax_buttons_; - bool should_show_client_edge_; - - // The window that owns this view. - Widget* frame_; - - // Initialize various static resources. - static void InitClass(); - static gfx::Font* title_font_; - - DISALLOW_COPY_AND_ASSIGN(CustomFrameView); -}; - -} // namespace views +#include "ui/views/window/custom_frame_view.h" +// TODO(tfarina): remove this file once all includes have been updated. #endif // VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ diff --git a/views/window/dialog_client_view.h b/views/window/dialog_client_view.h index 379c8f0..8f34b34 100644 --- a/views/window/dialog_client_view.h +++ b/views/window/dialog_client_view.h @@ -6,165 +6,7 @@ #define VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ #pragma once -#include "ui/gfx/font.h" -#include "views/focus/focus_manager.h" -#include "views/controls/button/button.h" -#include "views/window/client_view.h" +#include "ui/views/window/dialog_client_view.h" +// TODO(tfarina): remove this file once all includes have been updated. -namespace views { - -class DialogDelegate; -class NativeTextButton; -class Widget; -namespace internal { -class RootView; -} - -/////////////////////////////////////////////////////////////////////////////// -// DialogClientView -// -// This ClientView subclass provides the content of a typical dialog box, -// including a strip of buttons at the bottom right of the window, default -// accelerator handlers for accept and cancel, and the ability for the -// embedded contents view to provide extra UI to be shown in the row of -// buttons. -// -// DialogClientView also provides the ability to set an arbitrary view that is -// positioned beneath the buttons. -// -class VIEWS_EXPORT DialogClientView : public ClientView, - public ButtonListener, - public FocusChangeListener { - public: - DialogClientView(Widget* widget, View* contents_view); - virtual ~DialogClientView(); - - // Adds the dialog buttons required by the supplied DialogDelegate to the - // view. - void ShowDialogButtons(); - - // Updates the enabled state and label of the buttons required by the - // supplied DialogDelegate - void UpdateDialogButtons(); - - // Accept the changes made in the window that contains this ClientView. - void AcceptWindow(); - - // Cancel the changes made in the window that contains this ClientView. - void CancelWindow(); - - // Accessors in case the user wishes to adjust these buttons. - NativeTextButton* ok_button() const { return ok_button_; } - NativeTextButton* cancel_button() const { return cancel_button_; } - - // Sets the view that is positioned along the bottom of the buttons. The - // bottom view is positioned beneath the buttons at the full width of the - // dialog. If there is an existing bottom view it is removed and deleted. - void SetBottomView(View* bottom_view); - - // Overridden from View: - virtual void NativeViewHierarchyChanged( - bool attached, - gfx::NativeView native_view, - internal::RootView* root_view) OVERRIDE; - - // Overridden from ClientView: - virtual bool CanClose() OVERRIDE; - virtual void WidgetClosing() OVERRIDE; - virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; - virtual DialogClientView* AsDialogClientView() OVERRIDE; - virtual const DialogClientView* AsDialogClientView() const OVERRIDE; - - // FocusChangeListener implementation: - virtual void OnWillChangeFocus(View* focused_before, - View* focused_now) OVERRIDE; - virtual void OnDidChangeFocus(View* focused_before, - View* focused_now) OVERRIDE; - - protected: - // View overrides: - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; - virtual void Layout() OVERRIDE; - virtual void ViewHierarchyChanged(bool is_add, View* parent, - View* child) OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; - - // ButtonListener implementation: - virtual void ButtonPressed(Button* sender, - const views::Event& event) OVERRIDE; - - private: - // Paint the size box in the bottom right corner of the window if it is - // resizable. - void PaintSizeBox(gfx::Canvas* canvas); - - // Returns the width of the specified dialog button using the correct font. - int GetButtonWidth(int button) const; - int GetButtonsHeight() const; - - // Position and size various sub-views. - void LayoutDialogButtons(); - void LayoutContentsView(); - - // Makes the specified button the default button. - void SetDefaultButton(NativeTextButton* button); - - bool has_dialog_buttons() const { return ok_button_ || cancel_button_; } - - // Create and add the extra view, if supplied by the delegate. - void CreateExtraView(); - - // Returns the DialogDelegate for the window. - DialogDelegate* GetDialogDelegate() const; - - // Closes the widget. - void Close(); - - // Updates focus listener. - void UpdateFocusListener(); - - static void InitClass(); - - // The dialog buttons. - NativeTextButton* ok_button_; - NativeTextButton* cancel_button_; - - // The button that is currently the default button if any. - NativeTextButton* default_button_; - - // The button-level extra view, NULL unless the dialog delegate supplies one. - View* extra_view_; - - // See description of DialogDelegate::GetSizeExtraViewHeightToButtons for - // details on this. - bool size_extra_view_height_to_buttons_; - - // The layout rect of the size box, when visible. - gfx::Rect size_box_bounds_; - - // True if we've notified the delegate the window is closing and the delegate - // allosed the close. In some situations it's possible to get two closes (see - // http://crbug.com/71940). This is used to avoid notifying the delegate - // twice, which can have bad consequences. - bool notified_delegate_; - - // true if focus listener is added. - bool listening_to_focus_; - - // When ancestor gets changed focus manager gets changed as well. - FocusManager* saved_focus_manager_; - - // View positioned along the bottom, beneath the buttons. - View* bottom_view_; - - // Static resource initialization - static gfx::Font* dialog_button_font_; - - DISALLOW_COPY_AND_ASSIGN(DialogClientView); -}; - -} // namespace views - -#endif // #ifndef VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ +#endif // VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ diff --git a/views/window/dialog_delegate.h b/views/window/dialog_delegate.h index dc38c00..fc9dbca 100644 --- a/views/window/dialog_delegate.h +++ b/views/window/dialog_delegate.h @@ -6,123 +6,7 @@ #define VIEWS_WINDOW_DIALOG_DELEGATE_H_ #pragma once -#include "base/string16.h" -#include "ui/base/accessibility/accessibility_types.h" -#include "ui/base/ui_base_types.h" -#include "views/widget/widget_delegate.h" -#include "views/window/dialog_client_view.h" - -namespace views { - -class View; - -/////////////////////////////////////////////////////////////////////////////// -// -// DialogDelegate -// -// DialogDelegate is an interface implemented by objects that wish to show a -// dialog box Window. The window that is displayed uses this interface to -// determine how it should be displayed and notify the delegate object of -// certain events. -// -/////////////////////////////////////////////////////////////////////////////// -class VIEWS_EXPORT DialogDelegate : public WidgetDelegate { - public: - virtual DialogDelegate* AsDialogDelegate(); - - // Returns a mask specifying which of the available DialogButtons are visible - // for the dialog. Note: If an OK button is provided, you should provide a - // CANCEL button. A dialog box with just an OK button is frowned upon and - // considered a very special case, so if you're planning on including one, - // you should reconsider, or beng says there will be stabbings. - // - // To use the extra button you need to override GetDialogButtons() - virtual int GetDialogButtons() const; - - // Returns the default dialog button. This should not be a mask as only - // one button should ever be the default button. Return - // ui::DIALOG_BUTTON_NONE if there is no default. Default - // behavior is to return ui::DIALOG_BUTTON_OK or - // ui::DIALOG_BUTTON_CANCEL (in that order) if they are - // present, ui::DIALOG_BUTTON_NONE otherwise. - virtual int GetDefaultDialogButton() const; - - // Returns the label of the specified dialog button. - virtual string16 GetDialogButtonLabel(ui::DialogButton button) const; - - // Returns whether the specified dialog button is enabled. - virtual bool IsDialogButtonEnabled(ui::DialogButton button) const; - - // Returns whether the specified dialog button is visible. - virtual bool IsDialogButtonVisible(ui::DialogButton button) const; - - // Returns whether accelerators are enabled on the button. This is invoked - // when an accelerator is pressed, not at construction time. This - // returns true. - virtual bool AreAcceleratorsEnabled(ui::DialogButton button); - - // Override this function if with a view which will be shown in the same - // row as the OK and CANCEL buttons but flush to the left and extending - // up to the buttons. - virtual View* GetExtraView(); - - // Returns whether the height of the extra view should be at least as tall as - // the buttons. The default (false) is to give the extra view it's preferred - // height. By returning true the height becomes - // max(extra_view preferred height, buttons preferred height). - virtual bool GetSizeExtraViewHeightToButtons(); - - // For Dialog boxes, if there is a "Cancel" button, this is called when the - // user presses the "Cancel" button or the Close button on the window or - // in the system menu, or presses the Esc key. This function should return - // true if the window can be closed after it returns, or false if it must - // remain open. - virtual bool Cancel(); - - // For Dialog boxes, this is called when the user presses the "OK" button, - // or the Enter key. Can also be called on Esc key or close button - // presses if there is no "Cancel" button. This function should return - // true if the window can be closed after it returns, or false if it must - // remain open. If |window_closing| is true, it means that this handler is - // being called because the window is being closed (e.g. by Window::Close) - // and there is no Cancel handler, so Accept is being called instead. - virtual bool Accept(bool window_closing); - virtual bool Accept(); - - // Overridden from WindowDelegate: - virtual View* GetInitiallyFocusedView() OVERRIDE; - virtual ClientView* CreateClientView(Widget* widget) OVERRIDE; - - // Called when the window has been closed. - virtual void OnClose() {} - - // A helper for accessing the DialogClientView object contained by this - // delegate's Window. - const DialogClientView* GetDialogClientView() const; - DialogClientView* GetDialogClientView(); - - protected: - // Overridden from WindowDelegate: - virtual ui::AccessibilityTypes::Role GetAccessibleWindowRole() const OVERRIDE; -}; - -// A DialogDelegate implementation that is-a View. Used to override GetWidget() -// to call View's GetWidget() for the common case where a DialogDelegate -// implementation is-a View. -class VIEWS_EXPORT DialogDelegateView : public DialogDelegate, - public View { - public: - DialogDelegateView(); - virtual ~DialogDelegateView(); - - // Overridden from DialogDelegate: - virtual Widget* GetWidget() OVERRIDE; - virtual const Widget* GetWidget() const OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(DialogDelegateView); -}; - -} // namespace views +#include "ui/views/window/dialog_delegate.h" +// TODO(tfarina): remove this file once all includes have been updated. #endif // VIEWS_WINDOW_DIALOG_DELEGATE_H_ diff --git a/views/window/native_frame_view.h b/views/window/native_frame_view.h index 2073def..0228a2c 100644 --- a/views/window/native_frame_view.h +++ b/views/window/native_frame_view.h @@ -6,43 +6,7 @@ #define VIEWS_WINDOW_NATIVE_FRAME_VIEW_H_ #pragma once -#include "views/window/non_client_view.h" +#include "ui/views/window/native_frame_view.h" +// TODO(tfarina): remove this file once all includes have been updated. -namespace views { - -class Widget; - -class VIEWS_EXPORT NativeFrameView : public NonClientFrameView { - public: - explicit NativeFrameView(Widget* frame); - virtual ~NativeFrameView(); - - // NonClientFrameView overrides: - virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; - virtual gfx::Rect GetWindowBoundsForClientBounds( - const gfx::Rect& client_bounds) const OVERRIDE; - virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; - virtual void GetWindowMask(const gfx::Size& size, - gfx::Path* window_mask) OVERRIDE; - virtual void EnableClose(bool enable) OVERRIDE; - virtual void ResetWindowControls() OVERRIDE; - virtual void UpdateWindowIcon() OVERRIDE; - - // View overrides: - - // Returns the client size. On Windows, this is the expected behavior for - // native frames (see |NativeWidgetWin::WidgetSizeIsClientSize()|), while - // other platforms currently always return client bounds from - // |GetWindowBoundsForClientBounds()|. - virtual gfx::Size GetPreferredSize() OVERRIDE; - - private: - // Our containing frame. - Widget* frame_; - - DISALLOW_COPY_AND_ASSIGN(NativeFrameView); -}; - -} // namespace views - -#endif // #ifndef VIEWS_WINDOW_NATIVE_FRAME_VIEW_H_ +#endif // VIEWS_WINDOW_NATIVE_FRAME_VIEW_H_ diff --git a/views/window/non_client_view.h b/views/window/non_client_view.h index 2cc717b..d6bb585 100644 --- a/views/window/non_client_view.h +++ b/views/window/non_client_view.h @@ -6,235 +6,7 @@ #define VIEWS_WINDOW_NON_CLIENT_VIEW_H_ #pragma once -#include "views/view.h" -#include "views/window/client_view.h" +#include "ui/views/window/non_client_view.h" +// TODO(tfarina): remove this file once all includes have been updated. -namespace gfx { -class Path; -} - -namespace views { - -//////////////////////////////////////////////////////////////////////////////// -// NonClientFrameView -// -// An object that subclasses NonClientFrameView is a View that renders and -// responds to events within the frame portions of the non-client area of a -// window. This view does _not_ contain the ClientView, but rather is a sibling -// of it. -class VIEWS_EXPORT NonClientFrameView : public View { - public: - // Internal class name. - static const char kViewClassName[]; - // Various edges of the frame border have a 1 px shadow along their edges; in - // a few cases we shift elements based on this amount for visual appeal. - static const int kFrameShadowThickness; - // In restored mode, we draw a 1 px edge around the content area inside the - // frame border. - static const int kClientEdgeThickness; - - // Sets whether the window should be rendered as active regardless of the - // actual active state. Used when bubbles become active to make their parent - // appear active. A value of true makes the window render as active always, - // false gives normal behavior. - void SetInactiveRenderingDisabled(bool disable); - - // Returns the bounds (in this View's parent's coordinates) that the client - // view should be laid out within. - virtual gfx::Rect GetBoundsForClientView() const = 0; - - virtual gfx::Rect GetWindowBoundsForClientBounds( - const gfx::Rect& client_bounds) const = 0; - - // This function must ask the ClientView to do a hittest. We don't do this in - // the parent NonClientView because that makes it more difficult to calculate - // hittests for regions that are partially obscured by the ClientView, e.g. - // HTSYSMENU. - virtual int NonClientHitTest(const gfx::Point& point) = 0; - virtual void GetWindowMask(const gfx::Size& size, - gfx::Path* window_mask) = 0; - virtual void EnableClose(bool enable) = 0; - virtual void ResetWindowControls() = 0; - virtual void UpdateWindowIcon() = 0; - - // Overridden from View: - virtual bool HitTest(const gfx::Point& l) const OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual std::string GetClassName() const OVERRIDE; - - protected: - virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; - - NonClientFrameView() : paint_as_active_(false) {} - - // Helper for non-client view implementations to determine which area of the - // window border the specified |point| falls within. The other parameters are - // the size of the sizing edges, and whether or not the window can be - // resized. - int GetHTComponentForFrame(const gfx::Point& point, - int top_resize_border_height, - int resize_border_thickness, - int top_resize_corner_height, - int resize_corner_width, - bool can_resize); - - // Used to determine if the frame should be painted as active. Keyed off the - // window's actual active state and the override, see - // SetInactiveRenderingDisabled() above. - bool ShouldPaintAsActive() const; - - // Invoked from SetInactiveRenderingDisabled(). This implementation invokes - // SchedulesPaint as necessary. - virtual void ShouldPaintAsActiveChanged(); - - private: - // True when the non-client view should always be rendered as if the window - // were active, regardless of whether or not the top level window actually - // is active. - bool paint_as_active_; -}; - -//////////////////////////////////////////////////////////////////////////////// -// NonClientView -// -// The NonClientView is the logical root of all Views contained within a -// Window, except for the RootView which is its parent and of which it is the -// sole child. The NonClientView has two children, the NonClientFrameView which -// is responsible for painting and responding to events from the non-client -// portions of the window, and the ClientView, which is responsible for the -// same for the client area of the window: -// -// +- views::Window ------------------------------------+ -// | +- views::RootView ------------------------------+ | -// | | +- views::NonClientView ---------------------+ | | -// | | | +- views::NonClientFrameView subclas ---+ | | | -// | | | | | | | | -// | | | | << all painting and event receiving >> | | | | -// | | | | << of the non-client areas of a >> | | | | -// | | | | << views::Window. >> | | | | -// | | | | | | | | -// | | | +----------------------------------------+ | | | -// | | | +- views::ClientView or subclass --------+ | | | -// | | | | | | | | -// | | | | << all painting and event receiving >> | | | | -// | | | | << of the client areas of a >> | | | | -// | | | | << views::Window. >> | | | | -// | | | | | | | | -// | | | +----------------------------------------+ | | | -// | | +--------------------------------------------+ | | -// | +------------------------------------------------+ | -// +----------------------------------------------------+ -// -// The NonClientFrameView and ClientView are siblings because due to theme -// changes the NonClientFrameView may be replaced with different -// implementations (e.g. during the switch from DWM/Aero-Glass to Vista Basic/ -// Classic rendering). -// -class VIEWS_EXPORT NonClientView : public View { - public: - // Internal class name. - static const char kViewClassName[]; - - NonClientView(); - virtual ~NonClientView(); - - // Returns the current NonClientFrameView instance, or NULL if - // it does not exist. - NonClientFrameView* frame_view() const { return frame_view_.get(); } - - // Replaces the current NonClientFrameView (if any) with the specified one. - void SetFrameView(NonClientFrameView* frame_view); - - // Returns true if the ClientView determines that the containing window can be - // closed, false otherwise. - bool CanClose(); - - // Called by the containing Window when it is closed. - void WindowClosing(); - - // Changes the frame from native to custom depending on the value of - // |use_native_frame|. - void UpdateFrame(); - - // Prevents the window from being rendered as deactivated when |disable| is - // true, until called with |disable| false. Used when a sub-window is to be - // shown that shouldn't visually de-activate the window. - // Subclasses can override this to perform additional actions when this value - // changes. - void SetInactiveRenderingDisabled(bool disable); - - // Returns the bounds of the window required to display the content area at - // the specified bounds. - gfx::Rect GetWindowBoundsForClientBounds(const gfx::Rect client_bounds) const; - - // Determines the windows HT* code when the mouse cursor is at the - // specified point, in window coordinates. - int NonClientHitTest(const gfx::Point& point); - - // Returns a mask to be used to clip the top level window for the given - // size. This is used to create the non-rectangular window shape. - void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); - - // Toggles the enable state for the Close button (and the Close menu item in - // the system menu). - void EnableClose(bool enable); - - // Tells the window controls as rendered by the NonClientView to reset - // themselves to a normal state. This happens in situations where the - // containing window does not receive a normal sequences of messages that - // would lead to the controls returning to this normal state naturally, e.g. - // when the window is maximized, minimized or restored. - void ResetWindowControls(); - - // Tells the NonClientView to invalidate the NonClientFrameView's window icon. - void UpdateWindowIcon(); - - // Get/Set client_view property. - ClientView* client_view() const { return client_view_; } - void set_client_view(ClientView* client_view) { - client_view_ = client_view; - } - - // Layout just the frame view. This is necessary on Windows when non-client - // metrics such as the position of the window controls changes independently - // of a window resize message. - void LayoutFrameView(); - - // Set the accessible name of this view. - void SetAccessibleName(const string16& name); - - // NonClientView, View overrides: - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual gfx::Size GetMinimumSize() OVERRIDE; - virtual void Layout() OVERRIDE; - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; - virtual std::string GetClassName() const OVERRIDE; - - virtual views::View* GetEventHandlerForPoint(const gfx::Point& point) - OVERRIDE; - - protected: - // NonClientView, View overrides: - virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child) - OVERRIDE; - - private: - // A ClientView object or subclass, responsible for sizing the contents view - // of the window, hit testing and perhaps other tasks depending on the - // implementation. - ClientView* client_view_; - - // The NonClientFrameView that renders the non-client portions of the window. - // This object is not owned by the view hierarchy because it can be replaced - // dynamically as the system settings change. - scoped_ptr<NonClientFrameView> frame_view_; - - // The accessible name of this view. - string16 accessible_name_; - - DISALLOW_COPY_AND_ASSIGN(NonClientView); -}; - -} // namespace views - -#endif // #ifndef VIEWS_WINDOW_NON_CLIENT_VIEW_H_ +#endif // VIEWS_WINDOW_NON_CLIENT_VIEW_H_ diff --git a/views/window/window_resources.h b/views/window/window_resources.h index 4ce4112..58caebc 100644 --- a/views/window/window_resources.h +++ b/views/window/window_resources.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,26 +6,7 @@ #define VIEWS_WINDOW_WINDOW_RESOURCES_H_ #pragma once -class SkBitmap; - -namespace views { - -typedef int FramePartBitmap; - -/////////////////////////////////////////////////////////////////////////////// -// WindowResources -// -// An interface implemented by an object providing bitmaps to render the -// contents of a window frame. The Window may swap in different -// implementations of this interface to render different modes. The definition -// of FramePartBitmap depends on the implementation. -// -class WindowResources { - public: - virtual ~WindowResources() { } - virtual SkBitmap* GetPartBitmap(FramePartBitmap part) const = 0; -}; - -} // namespace views +#include "ui/views/window/window_resources.h" +// TODO(tfarina): remove this file once all includes have been updated. #endif // VIEWS_WINDOW_WINDOW_RESOURCES_H_ diff --git a/views/window/window_shape.h b/views/window/window_shape.h index d3ee7b6..feeedc0 100644 --- a/views/window/window_shape.h +++ b/views/window/window_shape.h @@ -6,20 +6,7 @@ #define VIEWS_WINDOW_WINDOW_SHAPE_H_ #pragma once -#include "views/views_export.h" - -namespace gfx { -class Size; -class Path; -} - -namespace views { - -// Sets the window mask to a style that most likely matches -// ui/resources/window_* -VIEWS_EXPORT void GetDefaultWindowMask(const gfx::Size& size, - gfx::Path* window_mask); - -} // namespace views +#include "ui/views/window/window_shape.h" +// TODO(tfarina): remove this file once all includes have been updated. #endif // VIEWS_WINDOW_WINDOW_SHAPE_H_ |