OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_WINDOW_WINDOW_H_ | 5 #ifndef VIEWS_WINDOW_WINDOW_H_ |
6 #define VIEWS_WINDOW_WINDOW_H_ | 6 #define VIEWS_WINDOW_WINDOW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
10 #include "views/widget/widget.h" | 10 #include "views/widget/widget.h" |
11 #include "views/window/native_window_delegate.h" | 11 #include "views/window/native_window_delegate.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 class Font; | |
15 class Rect; | 14 class Rect; |
16 class Size; | 15 class Size; |
17 } // namespace gfx | 16 } // namespace gfx |
18 | 17 |
19 namespace views { | 18 namespace views { |
20 | 19 |
21 class NativeWindow; | 20 class NativeWindow; |
22 class Widget; | 21 class Widget; |
23 class WindowDelegate; | 22 class WindowDelegate; |
24 | 23 |
(...skipping 18 matching lines...) Expand all Loading... |
43 Window(); | 42 Window(); |
44 virtual ~Window(); | 43 virtual ~Window(); |
45 | 44 |
46 // Creates an instance of an object implementing this interface. | 45 // Creates an instance of an object implementing this interface. |
47 // TODO(beng): create a version of this function that takes a NativeView, for | 46 // TODO(beng): create a version of this function that takes a NativeView, for |
48 // constrained windows. | 47 // constrained windows. |
49 static Window* CreateChromeWindow(gfx::NativeWindow parent, | 48 static Window* CreateChromeWindow(gfx::NativeWindow parent, |
50 const gfx::Rect& bounds, | 49 const gfx::Rect& bounds, |
51 WindowDelegate* window_delegate); | 50 WindowDelegate* window_delegate); |
52 | 51 |
53 // Returns the preferred size of the contents view of this window based on | |
54 // its localized size data. The width in cols is held in a localized string | |
55 // resource identified by |col_resource_id|, the height in the same fashion. | |
56 // TODO(beng): This should eventually live somewhere else, probably closer to | |
57 // ClientView. | |
58 static int GetLocalizedContentsWidth(int col_resource_id); | |
59 static int GetLocalizedContentsHeight(int row_resource_id); | |
60 static gfx::Size GetLocalizedContentsSize(int col_resource_id, | |
61 int row_resource_id); | |
62 | |
63 // Initializes the window. Must be called before any post-configuration | 52 // Initializes the window. Must be called before any post-configuration |
64 // operations are performed. | 53 // operations are performed. |
65 void InitWindow(const InitParams& params); | 54 void InitWindow(const InitParams& params); |
66 | 55 |
67 // Overridden from Widget: | 56 // Overridden from Widget: |
68 virtual void Show() OVERRIDE; | |
69 virtual Window* AsWindow() OVERRIDE; | 57 virtual Window* AsWindow() OVERRIDE; |
70 virtual const Window* AsWindow() const OVERRIDE; | 58 virtual const Window* AsWindow() const OVERRIDE; |
71 | 59 |
72 WindowDelegate* window_delegate() { | 60 WindowDelegate* window_delegate() { |
73 return const_cast<WindowDelegate*>( | 61 return const_cast<WindowDelegate*>( |
74 const_cast<const Window*>(this)->window_delegate()); | 62 const_cast<const Window*>(this)->window_delegate()); |
75 } | 63 } |
76 const WindowDelegate* window_delegate() const { | 64 const WindowDelegate* window_delegate() const { |
77 return reinterpret_cast<WindowDelegate*>(widget_delegate()); | 65 return reinterpret_cast<WindowDelegate*>(widget_delegate()); |
78 } | 66 } |
79 | 67 |
80 NativeWindow* native_window() { return native_window_; } | 68 NativeWindow* native_window() { return native_window_; } |
81 | 69 |
82 protected: | 70 protected: |
83 // Overridden from NativeWindowDelegate: | 71 // Overridden from NativeWindowDelegate: |
84 virtual bool IsModal() const OVERRIDE; | |
85 virtual bool IsDialogBox() const OVERRIDE; | |
86 virtual void OnNativeWindowCreated(const gfx::Rect& bounds) OVERRIDE; | |
87 virtual internal::NativeWidgetDelegate* AsNativeWidgetDelegate() OVERRIDE; | 72 virtual internal::NativeWidgetDelegate* AsNativeWidgetDelegate() OVERRIDE; |
88 | 73 |
89 private: | 74 private: |
90 // Sizes and positions the window just after it is created. | |
91 void SetInitialBounds(const gfx::Rect& bounds); | |
92 | |
93 NativeWindow* native_window_; | 75 NativeWindow* native_window_; |
94 | 76 |
95 // The saved maximized state for this window. See note in SetInitialBounds | |
96 // that explains why we save this. | |
97 bool saved_maximized_state_; | |
98 | |
99 // The smallest size the window can be. | |
100 gfx::Size minimum_size_; | |
101 | |
102 DISALLOW_COPY_AND_ASSIGN(Window); | 77 DISALLOW_COPY_AND_ASSIGN(Window); |
103 }; | 78 }; |
104 | 79 |
105 } // namespace views | 80 } // namespace views |
106 | 81 |
107 #endif // #ifndef VIEWS_WINDOW_WINDOW_H_ | 82 #endif // #ifndef VIEWS_WINDOW_WINDOW_H_ |
OLD | NEW |