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 #include "chrome/browser/chromeos/panels/panel_scroller_header.h" 6 7 #include "base/utf_string_conversions.h" 8 #include "chrome/browser/chromeos/panels/panel_scroller.h" 9 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/font.h" 12 13 PanelScrollerHeader::PanelScrollerHeader(PanelScroller* scroller) 14 : views::View(), 15 scroller_(scroller) { 16 } 17 18 PanelScrollerHeader::~PanelScrollerHeader() { 19 } 20 21 bool PanelScrollerHeader::OnMousePressed(const views::MouseEvent& event) { 22 return true; 23 } 24 25 bool PanelScrollerHeader::OnMouseDragged(const views::MouseEvent& event) { 26 return false; 27 } 28 29 void PanelScrollerHeader::OnMouseReleased(const views::MouseEvent& event) { 30 OnMouseCaptureLost(); 31 } 32 33 void PanelScrollerHeader::OnMouseCaptureLost() { 34 scroller_->HeaderClicked(this); 35 } 36 37 gfx::Size PanelScrollerHeader::GetPreferredSize() { 38 return gfx::Size(size().width(), 18); 39 } 40 41 void PanelScrollerHeader::OnPaint(gfx::Canvas* canvas) { 42 // TODO(brettw) fill this out with real styling. 43 canvas->FillRectInt(0xFFFFFFFF, 0, 0, size().width(), size().height()); 44 canvas->DrawLineInt(0xFFE6E6E6, 0, size().height() - 1, 45 size().width(), size().height() - 1); 46 47 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 48 gfx::Font font = 49 rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD); 50 int font_top = 1; 51 canvas->DrawStringInt(title_, font, 0xFF000000, 3, font_top, 52 size().width(), size().height() - font_top); 53 } 54