Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: views/window/window.cc

Issue 279004: Made sync code build and pass unit tests on OS X. (Closed)
Patch Set: Fixed uninitialized var error. Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« chrome/chrome.gyp ('K') | « views/window/window.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 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 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "views/window/window.h" 5 #include "views/window/window.h"
6 6
7 #include "app/gfx/font.h" 7 #include "app/gfx/font.h"
8 #include "app/l10n_util.h" 8 #include "app/gfx/font_util.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/gfx/size.h" 10 #include "base/gfx/size.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "views/widget/widget.h" 12 #include "views/widget/widget.h"
13 13
14 namespace views { 14 namespace views {
15 15
16 // static 16 // static
17 int Window::GetLocalizedContentsWidthForFont(int col_resource_id,
18 const gfx::Font& font) {
19 double chars = 0;
20 StringToDouble(WideToUTF8(l10n_util::GetString(col_resource_id)), &chars);
21 int width = font.GetExpectedTextWidth(static_cast<int>(chars));
22 DCHECK(width > 0);
23 return width;
24 }
25
26 // static
27 int Window::GetLocalizedContentsWidth(int col_resource_id) { 17 int Window::GetLocalizedContentsWidth(int col_resource_id) {
28 return GetLocalizedContentsWidthForFont(col_resource_id, 18 return gfx::GetLocalizedContentsWidthForFont(col_resource_id,
29 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont)); 19 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont));
30 } 20 }
31 21
32 // static 22 // static
33 int Window::GetLocalizedContentsHeightForFont(int row_resource_id,
34 const gfx::Font& font) {
35 double lines = 0;
36 StringToDouble(WideToUTF8(l10n_util::GetString(row_resource_id)), &lines);
37 int height = static_cast<int>(font.height() * lines);
38 DCHECK(height > 0);
39 return height;
40 }
41
42 // static
43 int Window::GetLocalizedContentsHeight(int row_resource_id) { 23 int Window::GetLocalizedContentsHeight(int row_resource_id) {
44 return GetLocalizedContentsHeightForFont(row_resource_id, 24 return gfx::GetLocalizedContentsHeightForFont(row_resource_id,
45 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont)); 25 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont));
46 } 26 }
47 27
48 gfx::Size Window::GetLocalizedContentsSizeForFont(int col_resource_id,
49 int row_resource_id,
50 const gfx::Font& font) {
51 return gfx::Size(GetLocalizedContentsWidthForFont(col_resource_id, font),
52 GetLocalizedContentsHeightForFont(row_resource_id, font));
53 }
54
55 // static 28 // static
56 gfx::Size Window::GetLocalizedContentsSize(int col_resource_id, 29 gfx::Size Window::GetLocalizedContentsSize(int col_resource_id,
57 int row_resource_id) { 30 int row_resource_id) {
58 return gfx::Size(GetLocalizedContentsWidth(col_resource_id), 31 return gfx::Size(GetLocalizedContentsWidth(col_resource_id),
59 GetLocalizedContentsHeight(row_resource_id)); 32 GetLocalizedContentsHeight(row_resource_id));
60 } 33 }
61 34
62 // static 35 // static
63 void Window::CloseSecondaryWidget(Widget* widget) { 36 void Window::CloseSecondaryWidget(Widget* widget) {
64 if (!widget) 37 if (!widget)
65 return; 38 return;
66 39
67 // Close widget if it's identified as a secondary window. 40 // Close widget if it's identified as a secondary window.
68 Window* window = widget->GetWindow(); 41 Window* window = widget->GetWindow();
69 if (window) { 42 if (window) {
70 if (!window->IsAppWindow()) 43 if (!window->IsAppWindow())
71 window->Close(); 44 window->Close();
72 } else { 45 } else {
73 // If it's not a Window, then close it anyway since it probably is 46 // If it's not a Window, then close it anyway since it probably is
74 // secondary. 47 // secondary.
75 widget->Close(); 48 widget->Close();
76 } 49 }
77 } 50 }
78 51
79 } // namespace views 52 } // namespace views
OLDNEW
« chrome/chrome.gyp ('K') | « views/window/window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698