| 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 #ifndef VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 5 #ifndef VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| 6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 : message_(m), | 53 : message_(m), |
| 54 key_(k), | 54 key_(k), |
| 55 repeat_count_(r), | 55 repeat_count_(r), |
| 56 flags_(f) { | 56 flags_(f) { |
| 57 } | 57 } |
| 58 unsigned int message() const { return message_; } | 58 unsigned int message() const { return message_; } |
| 59 wchar_t key() const { return key_; } | 59 wchar_t key() const { return key_; } |
| 60 int repeat_count() const { return repeat_count_; } | 60 int repeat_count() const { return repeat_count_; } |
| 61 unsigned int flags() const { return flags_; } | 61 unsigned int flags() const { return flags_; } |
| 62 #else | 62 #else |
| 63 explicit Keystroke(GdkEventKey* event) | 63 explicit Keystroke(const KeyEvent* event) |
| 64 : event_(*event) { | 64 : event_(event) { |
| 65 } | 65 } |
| 66 const GdkEventKey* event() const { return &event_; } | 66 const KeyEvent& key_event() const { return *event_;}; |
| 67 const GdkEventKey* event() const { return event_->native_event(); } |
| 67 #endif | 68 #endif |
| 68 app::KeyboardCode GetKeyboardCode() const; | 69 app::KeyboardCode GetKeyboardCode() const; |
| 69 bool IsControlHeld() const; | 70 bool IsControlHeld() const; |
| 70 bool IsShiftHeld() const; | 71 bool IsShiftHeld() const; |
| 71 | 72 |
| 72 private: | 73 private: |
| 73 #if defined(OS_WIN) | 74 #if defined(OS_WIN) |
| 74 unsigned int message_; | 75 unsigned int message_; |
| 75 wchar_t key_; | 76 wchar_t key_; |
| 76 int repeat_count_; | 77 int repeat_count_; |
| 77 unsigned int flags_; | 78 unsigned int flags_; |
| 78 #else | 79 #else |
| 79 GdkEventKey event_; | 80 const KeyEvent* event_; |
| 80 #endif | 81 #endif |
| 81 | 82 |
| 82 DISALLOW_COPY_AND_ASSIGN(Keystroke); | 83 DISALLOW_COPY_AND_ASSIGN(Keystroke); |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 // This defines the callback interface for other code to be notified of | 86 // This defines the callback interface for other code to be notified of |
| 86 // changes in the state of a text field. | 87 // changes in the state of a text field. |
| 87 class Controller { | 88 class Controller { |
| 88 public: | 89 public: |
| 89 // This method is called whenever the text in the field changes. | 90 // This method is called whenever the text in the field changes. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 void SetBackgroundColor(SkColor color); | 163 void SetBackgroundColor(SkColor color); |
| 163 | 164 |
| 164 // Gets/Sets whether the default background color should be used when painting | 165 // Gets/Sets whether the default background color should be used when painting |
| 165 // the Textfield. | 166 // the Textfield. |
| 166 bool use_default_background_color() const { | 167 bool use_default_background_color() const { |
| 167 return use_default_background_color_; | 168 return use_default_background_color_; |
| 168 } | 169 } |
| 169 void UseDefaultBackgroundColor(); | 170 void UseDefaultBackgroundColor(); |
| 170 | 171 |
| 171 // Gets/Sets the font used when rendering the text within the Textfield. | 172 // Gets/Sets the font used when rendering the text within the Textfield. |
| 172 gfx::Font font() const { return font_; } | 173 const gfx::Font& font() const { return font_; } |
| 173 void SetFont(const gfx::Font& font); | 174 void SetFont(const gfx::Font& font); |
| 174 | 175 |
| 175 // Sets the left and right margin (in pixels) within the text box. On Windows | 176 // Sets the left and right margin (in pixels) within the text box. On Windows |
| 176 // this is accomplished by packing the left and right margin into a single | 177 // this is accomplished by packing the left and right margin into a single |
| 177 // 32 bit number, so the left and right margins are effectively 16 bits. | 178 // 32 bit number, so the left and right margins are effectively 16 bits. |
| 178 void SetHorizontalMargins(int left, int right); | 179 void SetHorizontalMargins(int left, int right); |
| 179 | 180 |
| 180 // Sets the top and bottom margins (in pixels) within the textfield. | 181 // Sets the top and bottom margins (in pixels) within the textfield. |
| 181 // NOTE: in most cases height could be changed instead. | 182 // NOTE: in most cases height could be changed instead. |
| 182 void SetVerticalMargins(int top, int bottom); | 183 void SetVerticalMargins(int top, int bottom); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // been deleted during a window close. | 224 // been deleted during a window close. |
| 224 void SyncText(); | 225 void SyncText(); |
| 225 | 226 |
| 226 // Returns whether or not an IME is composing text. | 227 // Returns whether or not an IME is composing text. |
| 227 bool IsIMEComposing() const; | 228 bool IsIMEComposing() const; |
| 228 | 229 |
| 229 #ifdef UNIT_TEST | 230 #ifdef UNIT_TEST |
| 230 gfx::NativeView GetTestingHandle() const { | 231 gfx::NativeView GetTestingHandle() const { |
| 231 return native_wrapper_ ? native_wrapper_->GetTestingHandle() : NULL; | 232 return native_wrapper_ ? native_wrapper_->GetTestingHandle() : NULL; |
| 232 } | 233 } |
| 234 NativeTextfieldWrapper* native_wrapper() const { |
| 235 return native_wrapper_; |
| 236 } |
| 233 #endif | 237 #endif |
| 234 | 238 |
| 235 // Overridden from View: | 239 // Overridden from View: |
| 236 virtual void Layout(); | 240 virtual void Layout(); |
| 237 virtual gfx::Size GetPreferredSize(); | 241 virtual gfx::Size GetPreferredSize(); |
| 238 virtual bool IsFocusable() const; | 242 virtual bool IsFocusable() const; |
| 239 virtual void AboutToRequestFocusFromTabTraversal(bool reverse); | 243 virtual void AboutToRequestFocusFromTabTraversal(bool reverse); |
| 240 virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e); | 244 virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e); |
| 241 virtual void SetEnabled(bool enabled); | 245 virtual void SetEnabled(bool enabled); |
| 242 virtual void PaintFocusBorder(gfx::Canvas* canvas); | 246 virtual void PaintFocusBorder(gfx::Canvas* canvas); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 315 |
| 312 // Text to display when empty. | 316 // Text to display when empty. |
| 313 string16 text_to_display_when_empty_; | 317 string16 text_to_display_when_empty_; |
| 314 | 318 |
| 315 DISALLOW_COPY_AND_ASSIGN(Textfield); | 319 DISALLOW_COPY_AND_ASSIGN(Textfield); |
| 316 }; | 320 }; |
| 317 | 321 |
| 318 } // namespace views | 322 } // namespace views |
| 319 | 323 |
| 320 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 324 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| OLD | NEW |