| Index: views/controls/native_control.cc
|
| ===================================================================
|
| --- views/controls/native_control.cc (revision 23672)
|
| +++ views/controls/native_control.cc (working copy)
|
| @@ -4,12 +4,15 @@
|
|
|
| #include "views/controls/native_control.h"
|
|
|
| -#include <algorithm>
|
| +#include <atlbase.h>
|
| +#include <atlapp.h>
|
| +#include <atlcrack.h>
|
| +#include <atlframe.h>
|
| +#include <atlmisc.h>
|
|
|
| #include "app/l10n_util_win.h"
|
| #include "base/logging.h"
|
| #include "base/win_util.h"
|
| -#include "base/window_impl.h"
|
| #include "views/background.h"
|
| #include "views/border.h"
|
| #include "views/controls/native/native_view_host.h"
|
| @@ -27,13 +30,16 @@
|
| // Maps to the NativeControl.
|
| static const wchar_t* const kNativeControlKey = L"__NATIVE_CONTROL__";
|
|
|
| -class NativeControlContainer : public base::WindowImpl {
|
| +class NativeControlContainer : public CWindowImpl<NativeControlContainer,
|
| + CWindow,
|
| + CWinTraits<WS_CHILD | WS_CLIPSIBLINGS |
|
| + WS_CLIPCHILDREN>> {
|
| public:
|
| +
|
| explicit NativeControlContainer(NativeControl* parent) : parent_(parent),
|
| control_(NULL) {
|
| - set_window_style(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
|
| - Init(parent->GetWidget()->GetNativeView(), gfx::Rect());
|
| - ShowWindow(hwnd(), SW_SHOW);
|
| + Create(parent->GetWidget()->GetNativeView());
|
| + ::ShowWindow(m_hWnd, SW_SHOW);
|
| }
|
|
|
| virtual ~NativeControlContainer() {
|
| @@ -41,7 +47,8 @@
|
|
|
| // NOTE: If you add a new message, be sure and verify parent_ is valid before
|
| // calling into parent_.
|
| - BEGIN_MSG_MAP_EX(NativeControlContainer);
|
| + DECLARE_FRAME_WND_CLASS(L"ChromeViewsNativeControlContainer", NULL);
|
| + BEGIN_MSG_MAP(NativeControlContainer);
|
| MSG_WM_CREATE(OnCreate);
|
| MSG_WM_ERASEBKGND(OnEraseBkgnd);
|
| MSG_WM_PAINT(OnPaint);
|
| @@ -72,7 +79,7 @@
|
| private:
|
|
|
| LRESULT OnCreate(LPCREATESTRUCT create_struct) {
|
| - control_ = parent_->CreateNativeControl(hwnd());
|
| + control_ = parent_->CreateNativeControl(m_hWnd);
|
|
|
| // We subclass the control hwnd so we get the WM_KEYDOWN messages.
|
| WNDPROC original_handler =
|
| @@ -81,7 +88,7 @@
|
| SetProp(control_, kHandlerKey, original_handler);
|
| SetProp(control_, kNativeControlKey , parent_);
|
|
|
| - ShowWindow(control_, SW_SHOW);
|
| + ::ShowWindow(control_, SW_SHOW);
|
| return 1;
|
| }
|
|
|
| @@ -91,12 +98,12 @@
|
|
|
| void OnPaint(HDC ignore) {
|
| PAINTSTRUCT ps;
|
| - HDC dc = BeginPaint(hwnd(), &ps);
|
| - EndPaint(hwnd(), &ps);
|
| + HDC dc = ::BeginPaint(*this, &ps);
|
| + ::EndPaint(*this, &ps);
|
| }
|
|
|
| void OnSize(int type, const CSize& sz) {
|
| - MoveWindow(control_, 0, 0, sz.cx, sz.cy, TRUE);
|
| + ::MoveWindow(control_, 0, 0, sz.cx, sz.cy, TRUE);
|
| }
|
|
|
| LRESULT OnCommand(UINT code, int id, HWND source) {
|
| @@ -167,7 +174,7 @@
|
| NativeControl::~NativeControl() {
|
| if (container_) {
|
| container_->ResetParent();
|
| - DestroyWindow(container_->hwnd());
|
| + ::DestroyWindow(*container_);
|
| }
|
| }
|
|
|
| @@ -179,15 +186,15 @@
|
|
|
| if (!container_ && IsVisible()) {
|
| container_ = new NativeControlContainer(this);
|
| - hwnd_view_->Attach(container_->hwnd());
|
| + hwnd_view_->Attach(*container_);
|
| if (!enabled_)
|
| EnableWindow(GetNativeControlHWND(), enabled_);
|
|
|
| // This message ensures that the focus border is shown.
|
| - SendMessage(container_->GetControl(),
|
| - WM_CHANGEUISTATE,
|
| - MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS),
|
| - 0);
|
| + ::SendMessage(container_->GetControl(),
|
| + WM_CHANGEUISTATE,
|
| + MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS),
|
| + 0);
|
| }
|
| }
|
|
|
| @@ -267,7 +274,7 @@
|
| void NativeControl::Focus() {
|
| if (container_) {
|
| DCHECK(container_->GetControl());
|
| - SetFocus(container_->GetControl());
|
| + ::SetFocus(container_->GetControl());
|
| }
|
| }
|
|
|
| @@ -288,7 +295,7 @@
|
| if (f != IsVisible()) {
|
| View::SetVisible(f);
|
| if (!f && container_) {
|
| - DestroyWindow(container_->hwnd());
|
| + ::DestroyWindow(*container_);
|
| } else if (f && !container_) {
|
| ValidateNativeControl();
|
| }
|
| @@ -312,13 +319,13 @@
|
| }
|
|
|
| void NativeControl::SetFixedWidth(int width, Alignment alignment) {
|
| - DCHECK_GT(width, 0);
|
| + DCHECK(width > 0);
|
| fixed_width_ = width;
|
| horizontal_alignment_ = alignment;
|
| }
|
|
|
| void NativeControl::SetFixedHeight(int height, Alignment alignment) {
|
| - DCHECK_GT(height, 0);
|
| + DCHECK(height > 0);
|
| fixed_height_ = height;
|
| vertical_alignment_ = alignment;
|
| }
|
|
|