icon_label_bubble_view.h revision 4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7
1// Copyright (c) 2010 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_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_ 6#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_ 7#pragma once 8 9#include <string> 10 11#include "gfx/size.h" 12#include "views/painter.h" 13#include "views/view.h" 14 15namespace gfx { 16class Canvas; 17class Font; 18} 19namespace views { 20class ImageView; 21class Label; 22} 23 24class SkBitmap; 25 26// View used to draw a bubble to the left of the address, containing an icon and 27// a label. We use this as a base for the classes that handle the EV bubble and 28// tab-to-search UI. 29class IconLabelBubbleView : public views::View { 30 public: 31 IconLabelBubbleView(const int background_images[], 32 int contained_image, 33 const SkColor& color); 34 virtual ~IconLabelBubbleView(); 35 36 void SetFont(const gfx::Font& font); 37 void SetLabel(const std::wstring& label); 38 void SetImage(const SkBitmap& bitmap); 39 void SetItemPadding(int padding) { item_padding_ = padding; } 40 41 virtual void Paint(gfx::Canvas* canvas); 42 virtual gfx::Size GetPreferredSize(); 43 virtual void Layout(); 44 45 protected: 46 void SetElideInMiddle(bool elide_in_middle); 47 gfx::Size GetNonLabelSize(); 48 49 private: 50 int GetNonLabelWidth(); 51 52 // For painting the background. 53 views::HorizontalPainter background_painter_; 54 55 // The contents of the bubble. 56 views::ImageView* image_; 57 views::Label* label_; 58 59 int item_padding_; 60 61 DISALLOW_IMPLICIT_CONSTRUCTORS(IconLabelBubbleView); 62}; 63 64#endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ICON_LABEL_BUBBLE_VIEW_H_ 65