| 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 #include "views/window/window_win.h" | 5 #include "views/window/window_win.h" |
| 6 | 6 |
| 7 #include <shellapi.h> | 7 #include <shellapi.h> |
| 8 | 8 |
| 9 #include "app/gfx/canvas_paint.h" | 9 #include "app/gfx/canvas_paint.h" |
| 10 #include "app/gfx/font.h" | 10 #include "app/gfx/font.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 // Now that we've updated the frame, we'll want to restore our saved placement | 225 // Now that we've updated the frame, we'll want to restore our saved placement |
| 226 // since the display should have settled down and we can be properly rendered. | 226 // since the display should have settled down and we can be properly rendered. |
| 227 SetWindowPlacement(GetNativeView(), &saved_window_placement); | 227 SetWindowPlacement(GetNativeView(), &saved_window_placement); |
| 228 | 228 |
| 229 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want | 229 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
| 230 // to notify our children too, since we can have MDI child windows who need to | 230 // to notify our children too, since we can have MDI child windows who need to |
| 231 // update their appearance. | 231 // update their appearance. |
| 232 EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL); | 232 EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL); |
| 233 } | 233 } |
| 234 | 234 |
| 235 // static | |
| 236 int Window::GetLocalizedContentsWidth(int col_resource_id) { | |
| 237 double chars = _wtof(l10n_util::GetString(col_resource_id).c_str()); | |
| 238 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 239 gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); | |
| 240 int width = font.GetExpectedTextWidth(static_cast<int>(chars)); | |
| 241 DCHECK(width > 0); | |
| 242 return width; | |
| 243 } | |
| 244 | |
| 245 // static | |
| 246 int Window::GetLocalizedContentsHeight(int row_resource_id) { | |
| 247 double lines = _wtof(l10n_util::GetString(row_resource_id).c_str()); | |
| 248 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 249 gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); | |
| 250 int height = static_cast<int>(font.height() * lines); | |
| 251 DCHECK(height > 0); | |
| 252 return height; | |
| 253 } | |
| 254 | |
| 255 // static | |
| 256 gfx::Size Window::GetLocalizedContentsSize(int col_resource_id, | |
| 257 int row_resource_id) { | |
| 258 return gfx::Size(GetLocalizedContentsWidth(col_resource_id), | |
| 259 GetLocalizedContentsHeight(row_resource_id)); | |
| 260 } | |
| 261 | |
| 262 //////////////////////////////////////////////////////////////////////////////// | 235 //////////////////////////////////////////////////////////////////////////////// |
| 263 // WindowWin, Window implementation: | 236 // WindowWin, Window implementation: |
| 264 | 237 |
| 265 void WindowWin::Show() { | 238 void WindowWin::Show() { |
| 266 int show_state = GetShowState(); | 239 int show_state = GetShowState(); |
| 267 if (saved_maximized_state_) | 240 if (saved_maximized_state_) |
| 268 show_state = SW_SHOWMAXIMIZED; | 241 show_state = SW_SHOWMAXIMIZED; |
| 269 Show(show_state); | 242 Show(show_state); |
| 270 } | 243 } |
| 271 | 244 |
| (...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 } | 1402 } |
| 1430 return TRUE; | 1403 return TRUE; |
| 1431 } | 1404 } |
| 1432 } // namespace | 1405 } // namespace |
| 1433 | 1406 |
| 1434 void Window::CloseAllSecondaryWindows() { | 1407 void Window::CloseAllSecondaryWindows() { |
| 1435 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0); | 1408 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0); |
| 1436 } | 1409 } |
| 1437 | 1410 |
| 1438 } // namespace views | 1411 } // namespace views |
| OLD | NEW |