summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/drop_shadow_label.h
blob: 21ed7ebe3ba36e6f7c1f22d49258fadb43641810 (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
47
48
49
50
51
52
53
54
55
// 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.

#ifndef CHROME_BROWSER_CHROMEOS_DROP_SHADOW_LABEL_H_
#define CHROME_BROWSER_CHROMEOS_DROP_SHADOW_LABEL_H_

#include "gfx/font.h"
#include "views/controls/label.h"

namespace chromeos {

/////////////////////////////////////////////////////////////////////////////
//
// DropShadowLabel class
//
// A drop shadow label is a view subclass that can display a string
// with a drop shadow.
//
/////////////////////////////////////////////////////////////////////////////
class DropShadowLabel : public views::Label  {
 public:
  DropShadowLabel();

  // Sets the size of the drop shadow drawn under the text.
  // Defaults to two.  Note that this is a really simplistic drop
  // shadow -- it gets more expensive to draw the larger it gets,
  // since it simply draws more copies of the string.  For instance,
  // for a value of two, the string is draw seven times.  In general,
  // it is drawn three extra times for each increment of |size|.
  void SetDropShadowSize(int size);

  // Return the size of the drop shadow in pixels.
  int drop_shadow_size() const { return drop_shadow_size_; }

  // Overridden to paint the text differently from the base class.
  virtual void PaintText(gfx::Canvas* canvas,
                         const std::wstring& text,
                         const gfx::Rect& text_bounds,
                         int flags);

 protected:
  virtual gfx::Size GetTextSize() const;

 private:
  void Init();

  int drop_shadow_size_;

  DISALLOW_COPY_AND_ASSIGN(DropShadowLabel);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_DROP_SHADOW_LABEL_H_