summaryrefslogtreecommitdiffstats
path: root/views/widget/native_widget_view.h
blob: 61fa8a778c11a9a83f5cd6d2c218d55a3b492cd5 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// 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.

#ifndef VIEWS_WIDGET_NATIVE_WIDGET_VIEW_H_
#define VIEWS_WIDGET_NATIVE_WIDGET_VIEW_H_
#pragma once

#include "views/view.h"
#include "views/widget/native_widget_delegate.h"
#include "views/widget/native_widget_views.h"

namespace ui {
enum TouchStatus;
}

namespace views {
class NativeWidgetViews;

namespace internal {

////////////////////////////////////////////////////////////////////////////////
// NativeWidgetView
//
// This class represents the View that is the "native view" for a
// NativeWidgetViews. It is the View that is a member of the parent Widget's
// View hierarchy. It is responsible for receiving relevant events from that
// hierarchy and forwarding them to its NativeWidgetViews' delegate's hierarchy.
//
class NativeWidgetView : public View {
 public:
  static const char kViewClassName[];

  explicit NativeWidgetView(NativeWidgetViews* native_widget);
  virtual ~NativeWidgetView();

  Widget* GetAssociatedWidget();

  void set_delete_native_widget(bool delete_native_widget) {
    delete_native_widget_ = delete_native_widget;
  }

  // Overridden from View:
  virtual void SchedulePaintInternal(const gfx::Rect& r) OVERRIDE;
  virtual void MarkLayerDirty() OVERRIDE;
  virtual void CalculateOffsetToAncestorWithLayer(gfx::Point* offset,
                                                  View** ancestor) OVERRIDE;

 private:
  // Overridden from View:
  virtual void ViewHierarchyChanged(bool is_add,
                                    View* parent,
                                    View* child) OVERRIDE;
  virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
  virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
  virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
  virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
  virtual void OnMouseCaptureLost() OVERRIDE;
  virtual void OnMouseMoved(const MouseEvent& event) OVERRIDE;
  virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE;
  virtual void OnMouseExited(const MouseEvent& event) OVERRIDE;
  virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE;
  virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE;
  virtual bool OnKeyReleased(const KeyEvent& event) OVERRIDE;
  virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE;
  virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE;
  virtual void OnFocus() OVERRIDE;
  virtual void OnBlur() OVERRIDE;
  virtual std::string GetClassName() const OVERRIDE;
  virtual void MoveLayerToParent(ui::Layer* parent_layer,
                                 const gfx::Point& point) OVERRIDE;
  virtual void DestroyLayerRecurse() OVERRIDE;
  virtual void UpdateLayerBounds(const gfx::Point& offset) OVERRIDE;
  virtual void PaintToLayer(const gfx::Rect& dirty_rect) OVERRIDE;
  virtual void PaintComposite() OVERRIDE;

  internal::NativeWidgetDelegate* delegate() {
    return native_widget_->delegate();
  }

  NativeWidgetViews* native_widget_;

  // Have we sent OnNativeWidgetCreated?
  bool sent_create_;

  bool delete_native_widget_;

  DISALLOW_COPY_AND_ASSIGN(NativeWidgetView);
};

}  // namespace internal
}  // namespace views

#endif  // VIEWS_WIDGET_NATIVE_WIDGET_VIEW_H_