| OLD | NEW |
| 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/controls/button/native_button.h" | 5 #include "views/controls/button/native_button.h" |
| 6 | 6 |
| 7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
| 8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
| 9 #include "views/screen.h" | 9 #include "views/screen.h" |
| 10 #endif | 10 #endif |
| 11 | 11 |
| 12 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
| 13 #include "base/i18n/rtl.h" |
| 13 #include "base/keyboard_codes.h" | 14 #include "base/keyboard_codes.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "views/controls/native/native_view_host.h" | 16 #include "views/controls/native/native_view_host.h" |
| 16 | 17 |
| 17 namespace views { | 18 namespace views { |
| 18 | 19 |
| 19 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 20 // The min size in DLUs comes from | 21 // The min size in DLUs comes from |
| 21 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/c
h14e.asp | 22 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/c
h14e.asp |
| 22 static const int kMinWidthDLUs = 50; | 23 static const int kMinWidthDLUs = 50; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // is right-to-left, Windows does not render text for the button using a | 65 // is right-to-left, Windows does not render text for the button using a |
| 65 // right-to-left context (perhaps because the parent HWND is not flipped). | 66 // right-to-left context (perhaps because the parent HWND is not flipped). |
| 66 // The result is that RTL strings containing punctuation marks are not | 67 // The result is that RTL strings containing punctuation marks are not |
| 67 // displayed properly. For example, the string "...ABC" (where A, B and C are | 68 // displayed properly. For example, the string "...ABC" (where A, B and C are |
| 68 // Hebrew characters) is displayed as "ABC..." which is incorrect. | 69 // Hebrew characters) is displayed as "ABC..." which is incorrect. |
| 69 // | 70 // |
| 70 // In order to overcome this problem, we mark the localized Hebrew strings as | 71 // In order to overcome this problem, we mark the localized Hebrew strings as |
| 71 // RTL strings explicitly (using the appropriate Unicode formatting) so that | 72 // RTL strings explicitly (using the appropriate Unicode formatting) so that |
| 72 // Windows displays the text correctly regardless of the HWND hierarchy. | 73 // Windows displays the text correctly regardless of the HWND hierarchy. |
| 73 std::wstring localized_label; | 74 std::wstring localized_label; |
| 74 if (l10n_util::AdjustStringForLocaleDirection(label_, &localized_label)) | 75 if (base::i18n::AdjustStringForLocaleDirection(label_, &localized_label)) |
| 75 label_ = localized_label; | 76 label_ = localized_label; |
| 76 | 77 |
| 77 if (native_wrapper_) | 78 if (native_wrapper_) |
| 78 native_wrapper_->UpdateLabel(); | 79 native_wrapper_->UpdateLabel(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 void NativeButton::SetIsDefault(bool is_default) { | 82 void NativeButton::SetIsDefault(bool is_default) { |
| 82 if (is_default == is_default_) | 83 if (is_default == is_default_) |
| 83 return; | 84 return; |
| 84 if (is_default) | 85 if (is_default) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 native_wrapper->UpdateEnabled(); | 212 native_wrapper->UpdateEnabled(); |
| 212 return native_wrapper; | 213 return native_wrapper; |
| 213 } | 214 } |
| 214 | 215 |
| 215 void NativeButton::InitBorder() { | 216 void NativeButton::InitBorder() { |
| 216 set_border(Border::CreateEmptyBorder(0, kButtonBorderHWidth, 0, | 217 set_border(Border::CreateEmptyBorder(0, kButtonBorderHWidth, 0, |
| 217 kButtonBorderHWidth)); | 218 kButtonBorderHWidth)); |
| 218 } | 219 } |
| 219 | 220 |
| 220 } // namespace views | 221 } // namespace views |
| OLD | NEW |