| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. |
| 4 |
| 5 #include "views/window/window.h" |
| 6 |
| 7 #include "app/gfx/font.h" |
| 8 #include "app/l10n_util.h" |
| 9 #include "app/resource_bundle.h" |
| 10 #include "base/gfx/size.h" |
| 11 #include "base/string_util.h" |
| 12 |
| 13 namespace views { |
| 14 |
| 15 // static |
| 16 int Window::GetLocalizedContentsWidth(int col_resource_id) { |
| 17 double chars = 0; |
| 18 StringToDouble(WideToUTF8(l10n_util::GetString(col_resource_id)), &chars); |
| 19 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 20 gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); |
| 21 int width = font.GetExpectedTextWidth(static_cast<int>(chars)); |
| 22 DCHECK(width > 0); |
| 23 return width; |
| 24 } |
| 25 |
| 26 // static |
| 27 int Window::GetLocalizedContentsHeight(int row_resource_id) { |
| 28 double lines = 0; |
| 29 StringToDouble(WideToUTF8(l10n_util::GetString(row_resource_id)), &lines); |
| 30 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 31 gfx::Font font = rb.GetFont(ResourceBundle::BaseFont); |
| 32 int height = static_cast<int>(font.height() * lines); |
| 33 DCHECK(height > 0); |
| 34 return height; |
| 35 } |
| 36 |
| 37 // static |
| 38 gfx::Size Window::GetLocalizedContentsSize(int col_resource_id, |
| 39 int row_resource_id) { |
| 40 return gfx::Size(GetLocalizedContentsWidth(col_resource_id), |
| 41 GetLocalizedContentsHeight(row_resource_id)); |
| 42 } |
| 43 |
| 44 } // namespace views |
| OLD | NEW |