summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/options/options_group_view.h
blob: d40239d7e54293858fb2f4e5df0805717d01cc48 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) 2006-2008 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_VIEWS_OPTIONS_OPTIONS_GROUP_VIEW_H__
#define CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_GROUP_VIEW_H__

#include "chrome/views/view.h"

namespace ChromeViews {
class Label;
class Separator;
};

///////////////////////////////////////////////////////////////////////////////
// OptionsGroupView
//
//  A helper View that gathers related options into groups with a title and
//  optional description.
//
class OptionsGroupView : public ChromeViews::View {
 public:
  OptionsGroupView(ChromeViews::View* contents,
                   const std::wstring& title,
                   const std::wstring& description,
                   bool show_separator);
  virtual ~OptionsGroupView() {}

  // Sets the group as being highlighted to attract attention.
  void SetHighlighted(bool highlighted);

  // Retrieves the width of the ContentsView. Used to help size wrapping items.
  int GetContentsWidth() const;

  class ContentsView : public ChromeViews::View {
   public:
    virtual ~ContentsView() {}

    // ChromeViews::View overrides:
    virtual void DidChangeBounds(const CRect& prev_bounds,
                                 const CRect& next_bounds) {
      Layout();
    }

   private:
    DISALLOW_EVIL_CONSTRUCTORS(ContentsView);
  };

 protected:
  // ChromeViews::View overrides:
  virtual void Paint(ChromeCanvas* canvas);
  virtual void ViewHierarchyChanged(bool is_add,
                                    ChromeViews::View* parent,
                                    ChromeViews::View* child);

 private:
  void Init();

  ChromeViews::View* contents_;
  ChromeViews::Label* title_label_;
  ChromeViews::Label* description_label_;
  ChromeViews::Separator* separator_;

  // True if we should show a separator line below the contents of this
  // section.
  bool show_separator_;

  // True if this section should have a highlighted treatment to draw the
  // user's attention.
  bool highlighted_;

  DISALLOW_EVIL_CONSTRUCTORS(OptionsGroupView);
};

#endif  // #ifndef CHROME_BROWSER_VIEWS_OPTIONS_OPTIONS_GROUP_VIEW_H__