blob: 723f1ea1e16dabf6e10510c5d231d3eabcd03d3a [file] [log] [blame]
// Copyright (c) 2011 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.
#pragma once
#include <string>
#include "base/compiler_specific.h"
#include "base/string16.h"
#include "views/controls/button/text_button.h"
namespace views {
// A native themed class representing a checkbox. This class does not use
// platform specific objects to replicate the native platforms looks and feel.
class VIEWS_EXPORT Checkbox : public TextButtonBase {
static const char kViewClassName[];
explicit Checkbox(const string16& label);
virtual ~Checkbox();
// Sets a listener for this checkbox. Checkboxes aren't required to have them
// since their state can be read independently of them being toggled.
void set_listener(ButtonListener* listener) { listener_ = listener; }
// Sets/Gets whether or not the checkbox is checked.
virtual void SetChecked(bool checked);
bool checked() const { return checked_; }
// Overridden from View:
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual std::string GetClassName() const OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
// Overridden from Button:
virtual void NotifyClick(const views::Event& event) OVERRIDE;
// Overridden from TextButtonBase:
virtual gfx::NativeTheme::Part GetThemePart() const OVERRIDE;
virtual gfx::Rect GetThemePaintRect() const OVERRIDE;
virtual void GetExtraParams(
gfx::NativeTheme::ExtraParams* params) const OVERRIDE;
virtual gfx::Rect GetTextBounds() const OVERRIDE;
// True if the checkbox is checked.
bool checked_;
} // namespace views