summaryrefslogtreecommitdiffstats
path: root/chrome/views/native_button.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/views/native_button.cc')
-rw-r--r--chrome/views/native_button.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/chrome/views/native_button.cc b/chrome/views/native_button.cc
index bbee9e9..00aea52 100644
--- a/chrome/views/native_button.cc
+++ b/chrome/views/native_button.cc
@@ -12,6 +12,8 @@
namespace views {
+const char NativeButton::kViewClassName[] = "chrome/views/NativeButton";
+
NativeButton::NativeButton(const std::wstring& label)
: enforce_dlu_min_size_(true) {
Init(label, false);
@@ -25,6 +27,10 @@ NativeButton::NativeButton(const std::wstring& label, bool is_default)
NativeButton::~NativeButton() {
}
+std::string NativeButton::GetClassName() const {
+ return kViewClassName;
+}
+
void NativeButton::SetListener(Listener *l) {
listener_ = l;
}
@@ -116,6 +122,18 @@ void NativeButton::ConfigureNativeButton(HWND hwnd) {
::SetWindowText(hwnd, label_.c_str());
}
+void NativeButton::SetDefaultButton(bool is_default_button) {
+ if (is_default_button == is_default_)
+ return;
+ is_default_ = is_default_button;
+ if (is_default_button)
+ AddAccelerator(Accelerator(VK_RETURN, false, false, false));
+ else
+ RemoveAccelerator(Accelerator(VK_RETURN, false, false, false));
+ SendMessage(GetNativeControlHWND(), BM_SETSTYLE,
+ is_default_button ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON, true);
+}
+
bool NativeButton::AcceleratorPressed(const Accelerator& accelerator) {
if (enabled_) {
Clicked();