summaryrefslogtreecommitdiffstats
path: root/views/controls/menu/menu_host_win.cc
blob: 5c2435d1dc0ca9d8b3588a56917787e76e231716 (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
// 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.

#include "views/controls/menu/menu_host_win.h"

#include "views/controls/menu/native_menu_host_delegate.h"

namespace views {

////////////////////////////////////////////////////////////////////////////////
// MenuHostWin, public:

MenuHostWin::MenuHostWin(internal::NativeMenuHostDelegate* delegate)
    : delegate_(delegate) {
}

MenuHostWin::~MenuHostWin() {
}

////////////////////////////////////////////////////////////////////////////////
// MenuHostWin, NativeMenuHost implementation:

void MenuHostWin::StartCapturing() {
  SetMouseCapture();
}

NativeWidget* MenuHostWin::AsNativeWidget() {
  return this;
}

////////////////////////////////////////////////////////////////////////////////
// MenuHostWin, WidgetWin overrides:

void MenuHostWin::OnDestroy() {
  delegate_->OnNativeMenuHostDestroy();
  WidgetWin::OnDestroy();
}

void MenuHostWin::OnCancelMode() {
  delegate_->OnNativeMenuHostCancelCapture();
  WidgetWin::OnCancelMode();
}

// TODO(beng): remove once MenuHost is-a Widget
RootView* MenuHostWin::CreateRootView() {
  return delegate_->CreateRootView();
}

// TODO(beng): remove once MenuHost is-a Widget
bool MenuHostWin::ShouldReleaseCaptureOnMouseReleased() const {
  return delegate_->ShouldReleaseCaptureOnMouseRelease();
}

////////////////////////////////////////////////////////////////////////////////
// NativeMenuHost, public:

// static
NativeMenuHost* NativeMenuHost::CreateNativeMenuHost(
    internal::NativeMenuHostDelegate* delegate) {
  return new MenuHostWin(delegate);
}

}  // namespace views