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 UI_GFX_NATIVE_WIDGET_TYPES_H_ | 5 #ifndef UI_GFX_NATIVE_WIDGET_TYPES_H_ |
6 #define UI_GFX_NATIVE_WIDGET_TYPES_H_ | 6 #define UI_GFX_NATIVE_WIDGET_TYPES_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "ui/base/ui_export.h" | 10 #include "ui/base/ui_export.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 typedef struct _PangoFontDescription PangoFontDescription; | 71 typedef struct _PangoFontDescription PangoFontDescription; |
72 typedef struct _GdkCursor GdkCursor; | 72 typedef struct _GdkCursor GdkCursor; |
73 typedef struct _GdkPixbuf GdkPixbuf; | 73 typedef struct _GdkPixbuf GdkPixbuf; |
74 typedef struct _GdkRegion GdkRegion; | 74 typedef struct _GdkRegion GdkRegion; |
75 typedef struct _GtkWidget GtkWidget; | 75 typedef struct _GtkWidget GtkWidget; |
76 typedef struct _GtkWindow GtkWindow; | 76 typedef struct _GtkWindow GtkWindow; |
77 typedef struct _cairo cairo_t; | 77 typedef struct _cairo cairo_t; |
78 #endif | 78 #endif |
79 class SkBitmap; | 79 class SkBitmap; |
80 | 80 |
81 #if defined(USE_AURA) | |
sky
2011/08/24 22:29:34
Before class SkBitmap?
| |
82 #include "aura/window.h" | |
83 #endif | |
84 | |
81 namespace gfx { | 85 namespace gfx { |
82 | 86 |
87 #if defined(USE_AURA) | |
88 typedef aura::Window* NativeView; | |
89 typedef aura::Window* NativeWindow; | |
90 #elif defined(OS_WIN) | |
91 typedef HWND NativeView; | |
92 typedef HWND NativeWindow; | |
93 #elif defined(OS_MACOSX) | |
94 typedef NSView* NativeView; | |
95 typedef NSWindow* NativeWindow; | |
96 #elif defined(USE_WAYLAND) | |
97 typedef ui::WaylandWindow* NativeView; | |
98 typedef ui::WaylandWindow* NativeWindow; | |
99 #elif defined(USE_X11) | |
100 typedef GtkWidget* NativeView; | |
101 typedef GtkWindow* NativeWindow; | |
102 #endif | |
103 | |
83 #if defined(OS_WIN) | 104 #if defined(OS_WIN) |
84 typedef HFONT NativeFont; | 105 typedef HFONT NativeFont; |
85 typedef HWND NativeView; | |
86 typedef HWND NativeWindow; | |
87 typedef HWND NativeEditView; | 106 typedef HWND NativeEditView; |
88 typedef HDC NativeDrawingContext; | 107 typedef HDC NativeDrawingContext; |
89 typedef HCURSOR NativeCursor; | 108 typedef HCURSOR NativeCursor; |
90 typedef HMENU NativeMenu; | 109 typedef HMENU NativeMenu; |
91 typedef HRGN NativeRegion; | 110 typedef HRGN NativeRegion; |
92 typedef IAccessible* NativeViewAccessible; | 111 typedef IAccessible* NativeViewAccessible; |
93 #elif defined(OS_MACOSX) | 112 #elif defined(OS_MACOSX) |
94 typedef NSFont* NativeFont; | 113 typedef NSFont* NativeFont; |
95 typedef NSView* NativeView; | |
96 typedef NSWindow* NativeWindow; | |
97 typedef NSTextField* NativeEditView; | 114 typedef NSTextField* NativeEditView; |
98 typedef CGContext* NativeDrawingContext; | 115 typedef CGContext* NativeDrawingContext; |
99 typedef void* NativeCursor; | 116 typedef void* NativeCursor; |
100 typedef void* NativeMenu; | 117 typedef void* NativeMenu; |
101 typedef void* NativeViewAccessible; | 118 typedef void* NativeViewAccessible; |
102 #elif defined(USE_WAYLAND) | 119 #elif defined(USE_WAYLAND) |
103 typedef PangoFontDescription* NativeFont; | 120 typedef PangoFontDescription* NativeFont; |
104 typedef ui::WaylandWindow* NativeView; | |
105 typedef ui::WaylandWindow* NativeWindow; | |
106 typedef void* NativeEditView; | 121 typedef void* NativeEditView; |
107 typedef cairo_t* NativeDrawingContext; | 122 typedef cairo_t* NativeDrawingContext; |
108 typedef void* NativeCursor; | 123 typedef void* NativeCursor; |
109 typedef void* NativeMenu; | 124 typedef void* NativeMenu; |
110 // TODO(dnicoara) This should be replaced with a cairo region or maybe | 125 // TODO(dnicoara) This should be replaced with a cairo region or maybe |
111 // a Wayland specific region | 126 // a Wayland specific region |
112 typedef GdkRegion* NativeRegion; | 127 typedef GdkRegion* NativeRegion; |
113 typedef void* NativeViewAccessible; | 128 typedef void* NativeViewAccessible; |
114 #elif defined(USE_X11) | 129 #elif defined(USE_X11) |
115 typedef PangoFontDescription* NativeFont; | 130 typedef PangoFontDescription* NativeFont; |
116 typedef GtkWidget* NativeView; | |
117 typedef GtkWindow* NativeWindow; | |
118 typedef GtkWidget* NativeEditView; | 131 typedef GtkWidget* NativeEditView; |
119 typedef cairo_t* NativeDrawingContext; | 132 typedef cairo_t* NativeDrawingContext; |
120 typedef GdkCursor* NativeCursor; | 133 typedef GdkCursor* NativeCursor; |
121 typedef GtkWidget* NativeMenu; | 134 typedef GtkWidget* NativeMenu; |
122 typedef GdkRegion* NativeRegion; | 135 typedef GdkRegion* NativeRegion; |
123 typedef void* NativeViewAccessible; | 136 typedef void* NativeViewAccessible; |
124 #endif | 137 #endif |
125 | 138 |
126 #if defined(OS_MACOSX) | 139 #if defined(OS_MACOSX) |
127 typedef NSImage NativeImageType; | 140 typedef NSImage NativeImageType; |
128 #elif defined(TOOLKIT_GTK) | 141 #elif defined(TOOLKIT_GTK) |
129 typedef GdkPixbuf NativeImageType; | 142 typedef GdkPixbuf NativeImageType; |
130 #else | 143 #else |
131 typedef SkBitmap NativeImageType; | 144 typedef SkBitmap NativeImageType; |
132 #endif | 145 #endif |
133 typedef NativeImageType* NativeImage; | 146 typedef NativeImageType* NativeImage; |
134 | 147 |
135 // Note: for test_shell we're packing a pointer into the NativeViewId. So, if | 148 // Note: for test_shell we're packing a pointer into the NativeViewId. So, if |
136 // you make it a type which is smaller than a pointer, you have to fix | 149 // you make it a type which is smaller than a pointer, you have to fix |
137 // test_shell. | 150 // test_shell. |
138 // | 151 // |
139 // See comment at the top of the file for usage. | 152 // See comment at the top of the file for usage. |
140 typedef intptr_t NativeViewId; | 153 typedef intptr_t NativeViewId; |
141 | 154 |
142 #if defined(OS_WIN) | 155 #if defined(OS_WIN) && !defined(USE_AURA) |
143 // Convert a NativeViewId to a NativeView. | 156 // Convert a NativeViewId to a NativeView. |
144 // | 157 // |
145 // On Windows, we pass an HWND into the renderer. As stated above, the renderer | 158 // On Windows, we pass an HWND into the renderer. As stated above, the renderer |
146 // should not be performing operations on the view. | 159 // should not be performing operations on the view. |
147 static inline NativeView NativeViewFromId(NativeViewId id) { | 160 static inline NativeView NativeViewFromId(NativeViewId id) { |
148 return reinterpret_cast<NativeView>(id); | 161 return reinterpret_cast<NativeView>(id); |
149 } | 162 } |
150 #define NativeViewFromIdInBrowser(x) NativeViewFromId(x) | 163 #define NativeViewFromIdInBrowser(x) NativeViewFromId(x) |
151 #elif defined(OS_POSIX) | 164 #elif defined(OS_POSIX) || defined(USE_AURA) |
152 // On Mac and Linux, a NativeView is a pointer to an object, and is useless | 165 // On Mac and Linux, a NativeView is a pointer to an object, and is useless |
sky
2011/08/24 22:29:34
Update comment.
| |
153 // outside the process in which it was created. NativeViewFromId should only be | 166 // outside the process in which it was created. NativeViewFromId should only be |
154 // used inside the appropriate platform ifdef outside of the browser. | 167 // used inside the appropriate platform ifdef outside of the browser. |
155 // (NativeViewFromIdInBrowser can be used everywhere in the browser.) If your | 168 // (NativeViewFromIdInBrowser can be used everywhere in the browser.) If your |
156 // cross-platform design involves a call to NativeViewFromId from outside the | 169 // cross-platform design involves a call to NativeViewFromId from outside the |
157 // browser it will never work on Mac or Linux and is fundamentally broken. | 170 // browser it will never work on Mac or Linux and is fundamentally broken. |
158 | 171 |
159 // Please do not call this from outside the browser. It won't work; the name | 172 // Please do not call this from outside the browser. It won't work; the name |
160 // should give you a subtle hint. | 173 // should give you a subtle hint. |
161 static inline NativeView NativeViewFromIdInBrowser(NativeViewId id) { | 174 static inline NativeView NativeViewFromIdInBrowser(NativeViewId id) { |
162 return reinterpret_cast<NativeView>(id); | 175 return reinterpret_cast<NativeView>(id); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 typedef unsigned long AcceleratedWidget; | 214 typedef unsigned long AcceleratedWidget; |
202 const AcceleratedWidget kNullAcceleratedWidget = 0; | 215 const AcceleratedWidget kNullAcceleratedWidget = 0; |
203 #else | 216 #else |
204 typedef void* AcceleratedWidget; | 217 typedef void* AcceleratedWidget; |
205 const AcceleratedWidget kNullAcceleratedWidget = NULL; | 218 const AcceleratedWidget kNullAcceleratedWidget = NULL; |
206 #endif | 219 #endif |
207 | 220 |
208 } // namespace gfx | 221 } // namespace gfx |
209 | 222 |
210 #endif // UI_GFX_NATIVE_WIDGET_TYPES_H_ | 223 #endif // UI_GFX_NATIVE_WIDGET_TYPES_H_ |
OLD | NEW |