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/button/native_button.h" | 5 #include "views/controls/button/native_button.h" |
6 | 6 |
7 #if defined(OS_LINUX) | |
8 #include <gdk/gdkkeysyms.h> | |
9 #include "views/screen.h" | |
10 #endif | |
11 | |
12 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
13 #include "base/keyboard_codes.h" | 8 #include "base/keyboard_codes.h" |
14 #include "base/logging.h" | 9 #include "base/logging.h" |
15 #include "views/controls/native/native_view_host.h" | 10 #include "views/controls/native/native_view_host.h" |
16 | 11 |
| 12 #if defined(OS_WIN) |
| 13 #include "gfx/platform_font_win.h" |
| 14 #elif defined(OS_LINUX) |
| 15 #include <gdk/gdkkeysyms.h> |
| 16 #include "views/screen.h" |
| 17 #endif |
| 18 |
| 19 |
17 namespace views { | 20 namespace views { |
18 | 21 |
19 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
20 // The min size in DLUs comes from | 23 // The min size in DLUs comes from |
21 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/c
h14e.asp | 24 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/c
h14e.asp |
22 static const int kMinWidthDLUs = 50; | 25 static const int kMinWidthDLUs = 50; |
23 static const int kMinHeightDLUs = 14; | 26 static const int kMinHeightDLUs = 14; |
24 | 27 |
25 // Horizontal padding (on each side). | 28 // Horizontal padding (on each side). |
26 static const int kButtonBorderHWidth = 8; | 29 static const int kButtonBorderHWidth = 8; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 140 |
138 // Add in the border size. (Do this before clamping the minimum size in case | 141 // Add in the border size. (Do this before clamping the minimum size in case |
139 // that clamping causes an increase in size that would include the borders. | 142 // that clamping causes an increase in size that would include the borders. |
140 gfx::Insets border = GetInsets(); | 143 gfx::Insets border = GetInsets(); |
141 sz.set_width(sz.width() + border.left() + border.right()); | 144 sz.set_width(sz.width() + border.left() + border.right()); |
142 sz.set_height(sz.height() + border.top() + border.bottom()); | 145 sz.set_height(sz.height() + border.top() + border.bottom()); |
143 | 146 |
144 #if defined(OS_WIN) | 147 #if defined(OS_WIN) |
145 // Clamp the size returned to at least the minimum size. | 148 // Clamp the size returned to at least the minimum size. |
146 if (!ignore_minimum_size_) { | 149 if (!ignore_minimum_size_) { |
147 sz.set_width(std::max(sz.width(), | 150 gfx::PlatformFontWin* platform_font = |
148 font_.horizontal_dlus_to_pixels(kMinWidthDLUs))); | 151 static_cast<gfx::PlatformFontWin*>(font_.platform_font()); |
149 sz.set_height(std::max(sz.height(), | 152 sz.set_width(std::max( |
150 font_.vertical_dlus_to_pixels(kMinHeightDLUs))); | 153 sz.width(), |
| 154 platform_font->horizontal_dlus_to_pixels(kMinWidthDLUs))); |
| 155 sz.set_height(std::max( |
| 156 sz.height(), |
| 157 platform_font->vertical_dlus_to_pixels(kMinHeightDLUs))); |
151 } | 158 } |
152 // GTK returns a meaningful preferred size so that we don't need to adjust | 159 // GTK returns a meaningful preferred size so that we don't need to adjust |
153 // the preferred size as we do on windows. | 160 // the preferred size as we do on windows. |
154 #endif | 161 #endif |
155 | 162 |
156 return sz; | 163 return sz; |
157 } | 164 } |
158 | 165 |
159 void NativeButton::Layout() { | 166 void NativeButton::Layout() { |
160 if (native_wrapper_) { | 167 if (native_wrapper_) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 native_wrapper->UpdateEnabled(); | 232 native_wrapper->UpdateEnabled(); |
226 return native_wrapper; | 233 return native_wrapper; |
227 } | 234 } |
228 | 235 |
229 void NativeButton::InitBorder() { | 236 void NativeButton::InitBorder() { |
230 set_border(Border::CreateEmptyBorder(0, kButtonBorderHWidth, 0, | 237 set_border(Border::CreateEmptyBorder(0, kButtonBorderHWidth, 0, |
231 kButtonBorderHWidth)); | 238 kButtonBorderHWidth)); |
232 } | 239 } |
233 | 240 |
234 } // namespace views | 241 } // namespace views |
OLD | NEW |