summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-27 18:07:25 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-27 18:07:25 +0000
commit474fd5de43001aef8d6be15747d86a67a8eea87d (patch)
tree770024efda0dd3e822b8cf3d7da3286e992bffc2
parent0a6ead2b5ced309e4dccc927de06a4bd7e7a190d (diff)
downloadchromium_src-474fd5de43001aef8d6be15747d86a67a8eea87d.zip
chromium_src-474fd5de43001aef8d6be15747d86a67a8eea87d.tar.gz
chromium_src-474fd5de43001aef8d6be15747d86a67a8eea87d.tar.bz2
Fix clipping by using the correct window styles for native buttons.
Also ensure unhandled messages get handled by DefWindowProc of the containing WidgetWin. http://crbug.com/9216 Review URL: http://codereview.chromium.org/42629 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12671 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/views/controls/button/native_button_win.cc38
-rw-r--r--chrome/views/controls/button/native_button_win.h14
-rw-r--r--chrome/views/controls/native_control_win.cc14
-rw-r--r--chrome/views/controls/native_control_win.h7
-rw-r--r--chrome/views/widget/widget_win.cc6
5 files changed, 40 insertions, 39 deletions
diff --git a/chrome/views/controls/button/native_button_win.cc b/chrome/views/controls/button/native_button_win.cc
index 648da78..61d3b58 100644
--- a/chrome/views/controls/button/native_button_win.cc
+++ b/chrome/views/controls/button/native_button_win.cc
@@ -74,14 +74,14 @@ gfx::Size NativeButtonWin::GetPreferredSize() {
////////////////////////////////////////////////////////////////////////////////
// NativeButtonWin, NativeControlWin overrides:
-LRESULT NativeButtonWin::ProcessMessage(UINT message,
- WPARAM w_param,
- LPARAM l_param) {
+bool NativeButtonWin::ProcessMessage(UINT message, WPARAM w_param,
+ LPARAM l_param, LRESULT* result) {
if (message == WM_COMMAND && HIWORD(w_param) == BN_CLICKED) {
native_button_->ButtonPressed();
- return 0;
+ *result = 0;
+ return true;
}
- return NativeControlWin::ProcessMessage(message, w_param, l_param);
+ return NativeControlWin::ProcessMessage(message, w_param, l_param, result);
}
bool NativeButtonWin::OnKeyDown(int vkey) {
@@ -96,7 +96,7 @@ bool NativeButtonWin::NotifyOnKeyDown() const {
}
void NativeButtonWin::CreateNativeControl() {
- DWORD flags = WS_CHILD | BS_PUSHBUTTON;
+ DWORD flags = WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_PUSHBUTTON;
if (native_button_->is_default())
flags |= BS_DEFPUSHBUTTON;
HWND control_hwnd = CreateWindowEx(GetAdditionalExStyle(), L"BUTTON", L"",
@@ -162,27 +162,24 @@ bool NativeCheckboxWin::OnKeyDown(int vkey) {
////////////////////////////////////////////////////////////////////////////////
// NativeCheckboxWin, NativeButtonWin overrides:
-LRESULT NativeCheckboxWin::ProcessMessage(UINT message,
- WPARAM w_param,
- LPARAM l_param) {
+bool NativeCheckboxWin::ProcessMessage(UINT message, WPARAM w_param,
+ LPARAM l_param, LRESULT* result) {
if (message == WM_COMMAND && HIWORD(w_param) == BN_CLICKED) {
checkbox_->SetChecked(!checkbox_->checked());
// Fall through to the NativeButtonWin's handler, which will send the
// clicked notification to the listener...
}
- return NativeButtonWin::ProcessMessage(message, w_param, l_param);
+ return NativeButtonWin::ProcessMessage(message, w_param, l_param, result);
}
////////////////////////////////////////////////////////////////////////////////
// NativeCheckboxWin, protected:
void NativeCheckboxWin::CreateNativeControl() {
- HWND control_hwnd = CreateWindowEx(WS_EX_TRANSPARENT | GetAdditionalExStyle(),
- L"BUTTON", L"",
- WS_CHILD | BS_CHECKBOX | WS_VISIBLE,
- 0, 0, width(), height(),
- GetWidget()->GetNativeView(), NULL, NULL,
- NULL);
+ HWND control_hwnd = CreateWindowEx(
+ WS_EX_TRANSPARENT | GetAdditionalExStyle(), L"BUTTON", L"",
+ WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_CHECKBOX,
+ 0, 0, width(), height(), GetWidget()->GetNativeView(), NULL, NULL, NULL);
NativeControlCreated(control_hwnd);
}
@@ -205,11 +202,10 @@ NativeRadioButtonWin::~NativeRadioButtonWin() {
// NativeRadioButtonWin, NativeCheckboxWin overrides:
void NativeRadioButtonWin::CreateNativeControl() {
- HWND control_hwnd = CreateWindowEx(GetAdditionalExStyle(), L"BUTTON",
- L"", WS_CHILD | BS_RADIOBUTTON,
- 0, 0, width(), height(),
- GetWidget()->GetNativeView(), NULL, NULL,
- NULL);
+ HWND control_hwnd = CreateWindowEx(
+ GetAdditionalExStyle(), L"BUTTON",
+ L"", WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | BS_RADIOBUTTON,
+ 0, 0, width(), height(), GetWidget()->GetNativeView(), NULL, NULL, NULL);
NativeControlCreated(control_hwnd);
}
diff --git a/chrome/views/controls/button/native_button_win.h b/chrome/views/controls/button/native_button_win.h
index 5a9044b..0a1a572 100644
--- a/chrome/views/controls/button/native_button_win.h
+++ b/chrome/views/controls/button/native_button_win.h
@@ -29,9 +29,10 @@ class NativeButtonWin : public NativeControlWin,
virtual gfx::Size GetPreferredSize();
// Overridden from NativeControlWin:
- virtual LRESULT ProcessMessage(UINT message,
- WPARAM w_param,
- LPARAM l_param);
+ virtual bool ProcessMessage(UINT message,
+ WPARAM w_param,
+ LPARAM l_param,
+ LRESULT* result);
virtual bool OnKeyDown(int vkey);
protected:
@@ -65,9 +66,10 @@ class NativeCheckboxWin : public NativeButtonWin {
// Overridden from NativeControlWin:
virtual void SetFocus();
- virtual LRESULT ProcessMessage(UINT message,
- WPARAM w_param,
- LPARAM l_param);
+ virtual bool ProcessMessage(UINT message,
+ WPARAM w_param,
+ LPARAM l_param,
+ LRESULT* result);
protected:
virtual void CreateNativeControl();
diff --git a/chrome/views/controls/native_control_win.cc b/chrome/views/controls/native_control_win.cc
index 827f509..eb172e9 100644
--- a/chrome/views/controls/native_control_win.cc
+++ b/chrome/views/controls/native_control_win.cc
@@ -37,18 +37,20 @@ NativeControlWin::~NativeControlWin() {
}
}
-LRESULT NativeControlWin::ProcessMessage(UINT message, WPARAM w_param,
- LPARAM l_param) {
+bool NativeControlWin::ProcessMessage(UINT message, WPARAM w_param,
+ LPARAM l_param, LRESULT* result) {
switch (message) {
case WM_CONTEXTMENU:
ShowContextMenu(gfx::Point(LOWORD(l_param), HIWORD(l_param)));
- break;
+ *result = 0;
+ return true;
case WM_CTLCOLORBTN:
case WM_CTLCOLORSTATIC:
- return GetControlColor(message, reinterpret_cast<HDC>(w_param),
- GetHWND());
+ *result = GetControlColor(message, reinterpret_cast<HDC>(w_param),
+ GetHWND());
+ return true;
}
- return 0;
+ return false;
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/views/controls/native_control_win.h b/chrome/views/controls/native_control_win.h
index 02b89a2..0ba80eb 100644
--- a/chrome/views/controls/native_control_win.h
+++ b/chrome/views/controls/native_control_win.h
@@ -21,9 +21,12 @@ class NativeControlWin : public HWNDView {
// created by an object derived from NativeControlWin. Derived classes MUST
// call _this_ version of the function if they override it and do not handle
// all of the messages listed in widget_win.cc ProcessNativeControlWinMessage.
- virtual LRESULT ProcessMessage(UINT message,
+ // Returns true if the message was handled, with a valid result in |result|.
+ // Returns false if the message was not handled.
+ virtual bool ProcessMessage(UINT message,
WPARAM w_param,
- LPARAM l_param);
+ LPARAM l_param,
+ LRESULT* result);
// Called by our subclassed window procedure when a WM_KEYDOWN message is
// received by the HWND created by an object derived from NativeControlWin.
diff --git a/chrome/views/widget/widget_win.cc b/chrome/views/widget/widget_win.cc
index 985ebe1..2db81e4 100644
--- a/chrome/views/widget/widget_win.cc
+++ b/chrome/views/widget/widget_win.cc
@@ -963,10 +963,8 @@ bool ProcessNativeControlMessage(UINT message,
HWND control_hwnd = GetControlHWNDForMessage(message, w_param, l_param);
if (IsWindow(control_hwnd)) {
NativeControlWin* wrapper = GetNativeControlWinForHWND(control_hwnd);
- if (wrapper) {
- *l_result = wrapper->ProcessMessage(message, w_param, l_param);
- return true;
- }
+ if (wrapper)
+ return wrapper->ProcessMessage(message, w_param, l_param, l_result);
}
return false;