summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/status/status_area_button.cc
blob: cf52779216641f7f09d0262f01c00927b39f2801 (plain)
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
// Copyright (c) 2009 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/chromeos/status/status_area_button.h"

#include "app/gfx/canvas.h"
#include "app/resource_bundle.h"
#include "gfx/skbitmap_operations.h"
#include "grit/theme_resources.h"
#include "views/border.h"
#include "views/view.h"

namespace chromeos {

////////////////////////////////////////////////////////////////////////////////
// StatusAreaButton

StatusAreaButton::StatusAreaButton(views::ViewMenuDelegate* menu_delegate)
    : MenuButton(NULL, std::wstring(), menu_delegate, false) {
  set_border(NULL);
  SetShowHighlighted(true);
}

void StatusAreaButton::Paint(gfx::Canvas* canvas, bool for_drag) {
  if (state() == BS_PUSHED) {
    DrawPressed(canvas);
  }
  DrawIcon(canvas);
}

gfx::Size StatusAreaButton::GetPreferredSize() {
  // icons are 24x24
  static const int kIconWidth = 24;
  static const int kIconHeight = 24;
  gfx::Insets insets = GetInsets();
  gfx::Size prefsize(kIconWidth + insets.width(),
                     kIconHeight + insets.height());
  return prefsize;
}

void StatusAreaButton::DrawIcon(gfx::Canvas* canvas) {
  canvas->DrawBitmapInt(icon(), 0, 0);
}

}  // namespace chromeos