Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: views/controls/native_view_host.h

Issue 114059: Refactors HWNDView, NativeViewHostGtk and NativeViewHost so that they match t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/native_control_win.cc ('k') | views/controls/native_view_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef VIEWS_CONTROLS_NATIVE_VIEW_HOST_H_
6 #define VIEWS_CONTROLS_NATIVE_VIEW_HOST_H_
7
8 #include <string>
9
10 #include "views/view.h"
11
12 #include "base/gfx/native_widget_types.h"
13
14 namespace views {
15
16 // Base class for embedding native widgets in a view.
17 class NativeViewHost : public View {
18 public:
19 NativeViewHost();
20 virtual ~NativeViewHost();
21
22 void SetPreferredSize(const gfx::Size& size);
23 virtual gfx::Size GetPreferredSize();
24
25 // Overriden to invoke Layout.
26 virtual void VisibilityChanged(View* starting_from, bool is_visible);
27
28 // Invokes any of InstallClip, UninstallClip, ShowWidget or HideWidget
29 // depending upon what portion of the widget is view in the parent.
30 virtual void Layout();
31
32 // A NativeViewHost has an associated focus View so that the focus of the
33 // native control and of the View are kept in sync. In simple cases where the
34 // NativeViewHost directly wraps a native window as is, the associated view
35 // is this View. In other cases where the NativeViewHost is part of another
36 // view (such as TextField), the actual View is not the NativeViewHost and
37 // this method must be called to set that.
38 // This method must be called before Attach().
39 void SetAssociatedFocusView(View* view) { focus_view_ = view; }
40 View* associated_focus_view() { return focus_view_; }
41
42 void set_fast_resize(bool fast_resize) { fast_resize_ = fast_resize; }
43 bool fast_resize() const { return fast_resize_; }
44
45 // The embedded native view.
46 gfx::NativeView native_view() const { return native_view_; }
47
48 protected:
49 // Notification that our visible bounds relative to the root has changed.
50 // Invokes Layout to make sure the widget is positioned correctly.
51 virtual void VisibleBoundsInRootChanged();
52
53 // Sets the native view. Subclasses will typically invoke Layout after setting
54 // the widget.
55 void set_native_view(gfx::NativeView widget) { native_view_ = widget; }
56
57 // Installs a clip on the native widget.
58 virtual void InstallClip(int x, int y, int w, int h) = 0;
59
60 // Removes the clip installed on the native widget by way of InstallClip.
61 virtual void UninstallClip() = 0;
62
63 // Shows the widget at the specified position (relative to the parent widget).
64 virtual void ShowWidget(int x, int y, int w, int h) = 0;
65
66 // Hides the widget. NOTE: this may be invoked when the widget is already
67 // hidden.
68 virtual void HideWidget() = 0;
69
70 void set_installed_clip(bool installed_clip) {
71 installed_clip_ = installed_clip;
72 }
73 bool installed_clip() const { return installed_clip_; }
74
75 private:
76 gfx::NativeView native_view_;
77
78 // The preferred size of this View
79 gfx::Size preferred_size_;
80
81 // Have we installed a region on the HWND used to clip to only the visible
82 // portion of the HWND?
83 bool installed_clip_;
84
85 // Fast resizing will move the hwnd and clip its window region, this will
86 // result in white areas and will not resize the content (so scrollbars
87 // will be all wrong and content will flow offscreen). Only use this
88 // when you're doing extremely quick, high-framerate vertical resizes
89 // and don't care about accuracy. Make sure you do a real resize at the
90 // end. USE WITH CAUTION.
91 bool fast_resize_;
92
93 // The view that should be given focus when this NativeViewHost is focused.
94 View* focus_view_;
95
96 DISALLOW_COPY_AND_ASSIGN(NativeViewHost);
97 };
98
99 } // namespace views
100
101 #endif // VIEWS_CONTROLS_NATIVE_VIEW_HOST_H_
OLDNEW
« no previous file with comments | « views/controls/native_control_win.cc ('k') | views/controls/native_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698