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 CHROME_BROWSER_UI_VIEWS_FRAME_APP_PANEL_BROWSER_FRAME_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_APP_PANEL_BROWSER_FRAME_VIEW_H_ 7 #pragma once 8 9 #include "chrome/browser/ui/views/frame/browser_frame.h" 10 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" 11 #include "chrome/browser/ui/views/tab_icon_view.h" 12 #include "views/controls/button/button.h" 13 #include "views/window/non_client_view.h" 14 15 class BrowserView; 16 class TabContents; 17 namespace gfx { 18 class Font; 19 } 20 namespace views { 21 class ImageButton; 22 class ImageView; 23 } 24 // The frame view which is used for Application Panels. 25 // TODO(rafaelw): Refactor. This shares much duplicated code with 26 // OpaqueBrowserFrameView. 27 class AppPanelBrowserFrameView : public BrowserNonClientFrameView, 28 public views::ButtonListener, 29 public TabIconView::TabIconViewModel { 30 public: 31 // Constructs a non-client view for an BrowserFrame. 32 AppPanelBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view); 33 virtual ~AppPanelBrowserFrameView(); 34 35 // Overridden from BrowserNonClientFrameView: 36 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; 37 virtual int GetHorizontalTabStripVerticalOffset(bool restored) const OVERRIDE; 38 virtual void UpdateThrobber(bool running) OVERRIDE; 39 virtual gfx::Size GetMinimumSize() OVERRIDE; 40 41 protected: 42 // Overridden from views::NonClientFrameView: 43 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; 44 virtual bool AlwaysUseCustomFrame() const OVERRIDE; 45 virtual bool AlwaysUseNativeFrame() const OVERRIDE; 46 virtual gfx::Rect GetWindowBoundsForClientBounds( 47 const gfx::Rect& client_bounds) const OVERRIDE; 48 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; 49 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) 50 OVERRIDE; 51 virtual void EnableClose(bool enable) OVERRIDE; 52 virtual void ResetWindowControls() OVERRIDE; 53 virtual void UpdateWindowIcon() OVERRIDE; 54 55 // Overridden from views::View: 56 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 57 virtual void Layout() OVERRIDE; 58 59 // Overridden from views::ButtonListener: 60 virtual void ButtonPressed(views::Button* sender, const views::Event& event) 61 OVERRIDE; 62 63 // Overridden from TabIconView::TabIconViewModel: 64 virtual bool ShouldTabIconViewAnimate() const OVERRIDE; 65 virtual SkBitmap GetFaviconForTabIconView() OVERRIDE; 66 67 private: 68 // Returns the thickness of the border that makes up the window frame edges. 69 // This does not include any client edge. 70 int FrameBorderThickness() const; 71 72 // Returns the thickness of the entire nonclient left, right, and bottom 73 // borders, including both the window frame and any client edge. 74 int NonClientBorderThickness() const; 75 76 // Returns the height of the entire nonclient top border, including the window 77 // frame, any title area, and any connected client edge. 78 int NonClientTopBorderHeight() const; 79 80 // Returns the thickness of the nonclient portion of the 3D edge along the 81 // bottom of the titlebar. 82 int TitlebarBottomThickness() const; 83 84 // Returns the size of the titlebar icon. 85 int IconSize() const; 86 87 // Returns the bounds of the titlebar icon. 88 gfx::Rect IconBounds() const; 89 90 // Paint various sub-components of this view. The *FrameBorder() function 91 // also paints the background of the titlebar area, since the top frame border 92 // and titlebar background are a contiguous component. 93 void PaintRestoredFrameBorder(gfx::Canvas* canvas); 94 void PaintMaximizedFrameBorder(gfx::Canvas* canvas); 95 void PaintTitleBar(gfx::Canvas* canvas); 96 void PaintRestoredClientEdge(gfx::Canvas* canvas); 97 98 // Layout various sub-components of this view. 99 void LayoutWindowControls(); 100 void LayoutTitleBar(); 101 102 // Returns the bounds of the client area for the specified view size. 103 gfx::Rect CalculateClientAreaBounds(int width, int height) const; 104 105 // The layout rect of the title, if visible. 106 gfx::Rect title_bounds_; 107 108 // Window controls. 109 views::ImageButton* close_button_; 110 111 // The Window icon. 112 TabIconView* window_icon_; 113 114 // The frame that hosts this view. 115 BrowserFrame* frame_; 116 117 // The BrowserView hosted within this View. 118 BrowserView* browser_view_; 119 120 // The bounds of the ClientView. 121 gfx::Rect client_view_bounds_; 122 123 // The accessible name of this view. 124 std::wstring accessible_name_; 125 126 static void InitAppWindowResources(); 127 static gfx::Font* title_font_; 128 129 DISALLOW_COPY_AND_ASSIGN(AppPanelBrowserFrameView); 130 }; 131 132 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_APP_PANEL_BROWSER_FRAME_VIEW_H_ 133