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 CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // offsets. Since GtkTextIters are invalid after the buffer is changed, we | 57 // offsets. Since GtkTextIters are invalid after the buffer is changed, we |
58 // work in character offsets (not bytes). | 58 // work in character offsets (not bytes). |
59 struct CharRange { | 59 struct CharRange { |
60 CharRange() : cp_min(0), cp_max(0) { } | 60 CharRange() : cp_min(0), cp_max(0) { } |
61 CharRange(int n, int x) : cp_min(n), cp_max(x) { } | 61 CharRange(int n, int x) : cp_min(n), cp_max(x) { } |
62 | 62 |
63 // Returns the start/end of the selection. | 63 // Returns the start/end of the selection. |
64 int selection_min() const { return std::min(cp_min, cp_max); } | 64 int selection_min() const { return std::min(cp_min, cp_max); } |
65 int selection_max() const { return std::max(cp_min, cp_max); } | 65 int selection_max() const { return std::max(cp_min, cp_max); } |
66 | 66 |
| 67 // Returns true if the range is empty. |
| 68 bool empty() const { return cp_min == cp_max; } |
| 69 |
67 // Work in integers to match the gint GTK APIs. | 70 // Work in integers to match the gint GTK APIs. |
68 int cp_min; // For a selection: Represents the start. | 71 int cp_min; // For a selection: Represents the start. |
69 int cp_max; // For a selection: Represents the end (insert position). | 72 int cp_max; // For a selection: Represents the end (insert position). |
70 }; | 73 }; |
71 | 74 |
72 AutocompleteEditViewGtk(AutocompleteEditController* controller, | 75 AutocompleteEditViewGtk(AutocompleteEditController* controller, |
73 ToolbarModel* toolbar_model, | 76 ToolbarModel* toolbar_model, |
74 Profile* profile, | 77 Profile* profile, |
75 CommandUpdater* command_updater, | 78 CommandUpdater* command_updater, |
76 bool popup_window_mode, | 79 bool popup_window_mode, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 virtual void AnimationCanceled(const ui::Animation* animation); | 181 virtual void AnimationCanceled(const ui::Animation* animation); |
179 | 182 |
180 // Sets the colors of the text view according to the theme. | 183 // Sets the colors of the text view according to the theme. |
181 void SetBaseColor(); | 184 void SetBaseColor(); |
182 // Sets the colors of the instant suggestion view according to the theme and | 185 // Sets the colors of the instant suggestion view according to the theme and |
183 // the animation state. | 186 // the animation state. |
184 void UpdateInstantViewColors(); | 187 void UpdateInstantViewColors(); |
185 | 188 |
186 bool CommitInstantSuggestion(); | 189 bool CommitInstantSuggestion(); |
187 | 190 |
188 // Used by LocationBarViewGtk to inform AutocompleteEditViewGtk if the tab to | |
189 // search should be enabled or not. See the comment of |enable_tab_to_search_| | |
190 // for details. | |
191 void set_enable_tab_to_search(bool enable) { | |
192 enable_tab_to_search_ = enable; | |
193 } | |
194 | |
195 GtkWidget* text_view() { | 191 GtkWidget* text_view() { |
196 return text_view_; | 192 return text_view_; |
197 } | 193 } |
198 | 194 |
199 private: | 195 private: |
200 CHROMEG_CALLBACK_0(AutocompleteEditViewGtk, void, HandleBeginUserAction, | 196 CHROMEG_CALLBACK_0(AutocompleteEditViewGtk, void, HandleBeginUserAction, |
201 GtkTextBuffer*); | 197 GtkTextBuffer*); |
202 CHROMEG_CALLBACK_0(AutocompleteEditViewGtk, void, HandleEndUserAction, | 198 CHROMEG_CALLBACK_0(AutocompleteEditViewGtk, void, HandleEndUserAction, |
203 GtkTextBuffer*); | 199 GtkTextBuffer*); |
204 CHROMEG_CALLBACK_2(AutocompleteEditViewGtk, void, HandleMarkSet, | 200 CHROMEG_CALLBACK_2(AutocompleteEditViewGtk, void, HandleMarkSet, |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 // Indicates whether the IME changed the text. It's possible for the IME to | 484 // Indicates whether the IME changed the text. It's possible for the IME to |
489 // handle a key event but not change the text contents (e.g., when pressing | 485 // handle a key event but not change the text contents (e.g., when pressing |
490 // shift+del with no selection). | 486 // shift+del with no selection). |
491 bool text_changed_; | 487 bool text_changed_; |
492 | 488 |
493 // Contains the character range that should have a strikethrough (used for | 489 // Contains the character range that should have a strikethrough (used for |
494 // insecure schemes). If the range is size one or less, no strikethrough | 490 // insecure schemes). If the range is size one or less, no strikethrough |
495 // is needed. | 491 // is needed. |
496 CharRange strikethrough_; | 492 CharRange strikethrough_; |
497 | 493 |
498 // Indicate if the tab to search should be enabled or not. It's true by | |
499 // default and will only be set to false if the location bar view is not able | |
500 // to show the tab to search hint. | |
501 bool enable_tab_to_search_; | |
502 | |
503 // Indicates if the selected text is suggested text or not. If the selection | 494 // Indicates if the selected text is suggested text or not. If the selection |
504 // is not suggested text, that means the user manually made the selection. | 495 // is not suggested text, that means the user manually made the selection. |
505 bool selection_suggested_; | 496 bool selection_suggested_; |
506 | 497 |
507 // Was delete pressed? | 498 // Was delete pressed? |
508 bool delete_was_pressed_; | 499 bool delete_was_pressed_; |
509 | 500 |
510 // Was the delete key pressed with an empty selection at the end of the edit? | 501 // Was the delete key pressed with an empty selection at the end of the edit? |
511 bool delete_at_end_pressed_; | 502 bool delete_at_end_pressed_; |
512 | 503 |
(...skipping 24 matching lines...) Expand all Loading... |
537 GtkSignalRegistrar signals_; | 528 GtkSignalRegistrar signals_; |
538 | 529 |
539 #if defined(TOOLKIT_VIEWS) | 530 #if defined(TOOLKIT_VIEWS) |
540 scoped_ptr<AccessibleWidgetHelper> accessible_widget_helper_; | 531 scoped_ptr<AccessibleWidgetHelper> accessible_widget_helper_; |
541 #endif | 532 #endif |
542 | 533 |
543 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); | 534 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); |
544 }; | 535 }; |
545 | 536 |
546 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 537 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
OLD | NEW |