| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VIEWS_CONTROLS_HWND_VIEW_H_ | 5 #ifndef VIEWS_CONTROLS_HWND_VIEW_H_ |
| 6 #define VIEWS_CONTROLS_HWND_VIEW_H_ | 6 #define VIEWS_CONTROLS_HWND_VIEW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include "base/logging.h" |
| 9 | 9 #include "views/controls/native/native_view_host_wrapper.h" |
| 10 #include "views/controls/native_view_host.h" | |
| 11 | 10 |
| 12 namespace views { | 11 namespace views { |
| 13 | 12 |
| 14 ///////////////////////////////////////////////////////////////////////////// | 13 class NativeViewHost; |
| 15 // | 14 |
| 16 // HWNDView class | 15 // A Windows implementation of NativeViewHostWrapper |
| 17 // | 16 class NativeViewHostWin : public NativeViewHostWrapper { |
| 18 // The HWNDView class hosts a native window handle (HWND) sizing it | |
| 19 // according to the bounds of the view. This is useful whenever you need to | |
| 20 // show a UI control that has a HWND (e.g. a native windows Edit control) | |
| 21 // within thew View hierarchy and benefit from the sizing/layout. | |
| 22 // | |
| 23 ///////////////////////////////////////////////////////////////////////////// | |
| 24 // TODO: Rename this to NativeViewHostWin. | |
| 25 class HWNDView : public NativeViewHost { | |
| 26 public: | 17 public: |
| 27 HWNDView(); | 18 explicit NativeViewHostWin(NativeViewHost* host); |
| 28 virtual ~HWNDView(); | 19 virtual ~NativeViewHostWin(); |
| 29 | 20 |
| 30 // Attach a window handle to this View, making the window it represents | 21 // Overridden from NativeViewHostWrapper: |
| 31 // subject to sizing according to this View's parent container's Layout | 22 virtual void NativeViewAttached(); |
| 32 // Manager's sizing heuristics. | 23 virtual void NativeViewDetaching(); |
| 33 // | 24 virtual void AddedToWidget(); |
| 34 // This object should be added to the view hierarchy before calling this | 25 virtual void RemovedFromWidget(); |
| 35 // function, which will expect the parent to be valid. | |
| 36 void Attach(HWND hwnd); | |
| 37 | |
| 38 // Detach the attached window handle. It will no longer be updated | |
| 39 void Detach(); | |
| 40 | |
| 41 // TODO(sky): convert this to native_view(). | |
| 42 HWND GetHWND() const { return native_view(); } | |
| 43 | |
| 44 virtual void Paint(gfx::Canvas* canvas); | |
| 45 | |
| 46 // Overridden from View. | |
| 47 virtual std::string GetClassName() const; | |
| 48 | |
| 49 protected: | |
| 50 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); | |
| 51 | |
| 52 virtual void Focus(); | |
| 53 | |
| 54 // NativeHostView overrides. | |
| 55 virtual void InstallClip(int x, int y, int w, int h); | 26 virtual void InstallClip(int x, int y, int w, int h); |
| 27 virtual bool HasInstalledClip(); |
| 56 virtual void UninstallClip(); | 28 virtual void UninstallClip(); |
| 57 virtual void ShowWidget(int x, int y, int w, int h); | 29 virtual void ShowWidget(int x, int y, int w, int h); |
| 58 virtual void HideWidget(); | 30 virtual void HideWidget(); |
| 31 virtual void SetFocus(); |
| 59 | 32 |
| 60 private: | 33 private: |
| 61 DISALLOW_COPY_AND_ASSIGN(HWNDView); | 34 // Our associated NativeViewHost. |
| 35 NativeViewHost* host_; |
| 36 |
| 37 // Have we installed a region on the gfx::NativeView used to clip to only the |
| 38 // visible portion of the gfx::NativeView ? |
| 39 bool installed_clip_; |
| 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(NativeViewHostWin); |
| 62 }; | 42 }; |
| 63 | 43 |
| 64 } // namespace views | 44 } // namespace views |
| 65 | 45 |
| 66 #endif // VIEWS_CONTROLS_HWND_VIEW_H_ | 46 #endif // VIEWS_CONTROLS_HWND_VIEW_H_ |
| OLD | NEW |