OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "views/controls/tabbed_pane/native_tabbed_pane_win.h" | 5 #include "views/controls/tabbed_pane/native_tabbed_pane_win.h" |
6 | 6 |
7 #include <vssym32.h> | 7 #include <vssym32.h> |
8 | 8 |
9 #include "app/l10n_util_win.h" | 9 #include "app/l10n_util_win.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // | 188 // |
189 // Note that we don't follow the common convention for NativeControl | 189 // Note that we don't follow the common convention for NativeControl |
190 // subclasses and we don't pass the value returned from | 190 // subclasses and we don't pass the value returned from |
191 // NativeControl::GetAdditionalExStyle() as the dwExStyle parameter. Here is | 191 // NativeControl::GetAdditionalExStyle() as the dwExStyle parameter. Here is |
192 // why: on RTL locales, if we pass NativeControl::GetAdditionalExStyle() when | 192 // why: on RTL locales, if we pass NativeControl::GetAdditionalExStyle() when |
193 // we basically tell Windows to create our HWND with the WS_EX_LAYOUTRTL. If | 193 // we basically tell Windows to create our HWND with the WS_EX_LAYOUTRTL. If |
194 // we do that, then the HWND we create for |content_window_| below will | 194 // we do that, then the HWND we create for |content_window_| below will |
195 // inherit the WS_EX_LAYOUTRTL property and this will result in the contents | 195 // inherit the WS_EX_LAYOUTRTL property and this will result in the contents |
196 // being flipped, which is not what we want (because we handle mirroring in | 196 // being flipped, which is not what we want (because we handle mirroring in |
197 // views without the use of Windows' support for mirroring). Therefore, | 197 // views without the use of Windows' support for mirroring). Therefore, |
198 // we initially create our HWND without the aforementioned property and we | 198 // we initially create our HWND without WS_EX_LAYOUTRTL and we explicitly set |
199 // explicitly set this property our child is created. This way, on RTL | 199 // this property our child is created. This way, on RTL locales, our tabs |
200 // locales, our tabs will be nicely rendered from right to left (by virtue of | 200 // will be nicely rendered from right to left (by virtue of Windows doing the |
201 // Windows doing the right thing with the TabbedPane HWND) and each tab | 201 // right thing with the TabbedPane HWND) and each tab contents will use an |
202 // contents will use an RTL layout correctly (by virtue of the mirroring | 202 // RTL layout correctly (by virtue of the mirroring infrastructure in views |
203 // infrastructure in views doing the right thing with each View we put | 203 // doing the right thing with each View we put in the tab). |
204 // in the tab). | |
205 DWORD style = WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | WS_CLIPCHILDREN; | 204 DWORD style = WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | WS_CLIPCHILDREN; |
206 HWND tab_control = ::CreateWindowEx(0, | 205 HWND tab_control = ::CreateWindowEx(0, |
207 WC_TABCONTROL, | 206 WC_TABCONTROL, |
208 L"", | 207 L"", |
209 style, | 208 style, |
210 0, 0, width(), height(), | 209 0, 0, width(), height(), |
211 GetWidget()->GetNativeView(), NULL, NULL, | 210 GetWidget()->GetNativeView(), NULL, NULL, |
212 NULL); | 211 NULL); |
213 | 212 |
214 HFONT font = ResourceBundle::GetSharedInstance(). | 213 HFONT font = ResourceBundle::GetSharedInstance(). |
215 GetFont(ResourceBundle::BaseFont).hfont(); | 214 GetFont(ResourceBundle::BaseFont).hfont(); |
216 SendMessage(tab_control, WM_SETFONT, reinterpret_cast<WPARAM>(font), FALSE); | 215 SendMessage(tab_control, WM_SETFONT, reinterpret_cast<WPARAM>(font), FALSE); |
217 | 216 |
218 // Create the view container which is a child of the TabControl. | 217 // Create the view container which is a child of the TabControl. |
219 content_window_ = new WidgetWin(); | 218 content_window_ = new WidgetWin(); |
220 content_window_->Init(tab_control, gfx::Rect()); | 219 content_window_->Init(tab_control, gfx::Rect()); |
221 | 220 |
222 // Explicitly setting the WS_EX_LAYOUTRTL property for the HWND (see above | 221 // Explicitly setting the WS_EX_LAYOUTRTL property for the HWND (see above |
223 // for a thorough explanation regarding why we waited until |content_window_| | 222 // for why we waited until |content_window_| is created before we set this |
224 // if created before we set this property for the tabbed pane's HWND). | 223 // property for the tabbed pane's HWND). |
225 if (base::i18n::IsRTL()) | 224 if (base::i18n::IsRTL()) |
226 l10n_util::HWNDSetRTLLayout(tab_control); | 225 l10n_util::HWNDSetRTLLayout(tab_control); |
227 | 226 |
228 RootView* root_view = content_window_->GetRootView(); | 227 RootView* root_view = content_window_->GetRootView(); |
229 root_view->SetLayoutManager(new FillLayout()); | 228 root_view->SetLayoutManager(new FillLayout()); |
230 DWORD sys_color = ::GetSysColor(COLOR_3DHILIGHT); | 229 DWORD sys_color = ::GetSysColor(COLOR_3DHILIGHT); |
231 SkColor color = SkColorSetRGB(GetRValue(sys_color), GetGValue(sys_color), | 230 SkColor color = SkColorSetRGB(GetRValue(sys_color), GetGValue(sys_color), |
232 GetBValue(sys_color)); | 231 GetBValue(sys_color)); |
233 root_view->set_background(Background::CreateSolidBackground(color)); | 232 root_view->set_background(Background::CreateSolidBackground(color)); |
234 | 233 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 //////////////////////////////////////////////////////////////////////////////// | 325 //////////////////////////////////////////////////////////////////////////////// |
327 // NativeTabbedPaneWrapper, public: | 326 // NativeTabbedPaneWrapper, public: |
328 | 327 |
329 // static | 328 // static |
330 NativeTabbedPaneWrapper* NativeTabbedPaneWrapper::CreateNativeWrapper( | 329 NativeTabbedPaneWrapper* NativeTabbedPaneWrapper::CreateNativeWrapper( |
331 TabbedPane* tabbed_pane) { | 330 TabbedPane* tabbed_pane) { |
332 return new NativeTabbedPaneWin(tabbed_pane); | 331 return new NativeTabbedPaneWin(tabbed_pane); |
333 } | 332 } |
334 | 333 |
335 } // namespace views | 334 } // namespace views |
OLD | NEW |