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