1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright (c) 2010 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.
#include "chrome/browser/views/tabs/side_tab.h"
#include "app/gfx/canvas.h"
#include "app/resource_bundle.h"
namespace {
const int kVerticalTabHeight = 27;
const int kTextPadding = 4;
const int kFavIconHeight = 16;
};
// static
gfx::Font* SideTab::font_ = NULL;
////////////////////////////////////////////////////////////////////////////////
// SideTab, public:
SideTab::SideTab(SideTabModel* model) : model_(model) {
InitClass();
}
SideTab::~SideTab() {
}
////////////////////////////////////////////////////////////////////////////////
// SideTab, views::View overrides:
void SideTab::Layout() {
// TODO(beng):
}
void SideTab::Paint(gfx::Canvas* canvas) {
canvas->FillRectInt(model_->IsSelected(this) ? SK_ColorBLUE : SK_ColorRED,
0, 0, width(), height());
gfx::Rect text_rect = GetLocalBounds(false);
text_rect.Inset(kTextPadding, kTextPadding, kTextPadding, kTextPadding);
canvas->DrawStringInt(model_->GetTitle(this), *font_, SK_ColorBLACK,
text_rect.x(), text_rect.y(), text_rect.width(),
text_rect.height());
}
gfx::Size SideTab::GetPreferredSize() {
const int kTabHeight = std::max(font_->height() + 2 * kTextPadding,
kFavIconHeight + 2 * kTextPadding);
return gfx::Size(0, kTabHeight);
}
////////////////////////////////////////////////////////////////////////////////
// SideTab, private:
// static
void SideTab::InitClass() {
static bool initialized = false;
if (!initialized) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont));
initialized = true;
}
}
|