OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 void HandleInsertText(GtkTextBuffer* buffer, | 264 void HandleInsertText(GtkTextBuffer* buffer, |
265 GtkTextIter* location, | 265 GtkTextIter* location, |
266 const gchar* text, | 266 const gchar* text, |
267 gint len); | 267 gint len); |
268 | 268 |
269 static void HandleBackSpaceThunk(GtkTextView* text_view, gpointer self) { | 269 static void HandleBackSpaceThunk(GtkTextView* text_view, gpointer self) { |
270 reinterpret_cast<AutocompleteEditViewGtk*>(self)->HandleBackSpace(); | 270 reinterpret_cast<AutocompleteEditViewGtk*>(self)->HandleBackSpace(); |
271 } | 271 } |
272 void HandleBackSpace(); | 272 void HandleBackSpace(); |
273 | 273 |
| 274 static void HandleViewMoveFocusThunk(GtkWidget* widget, GtkDirectionType dir, |
| 275 gpointer self) { |
| 276 reinterpret_cast<AutocompleteEditViewGtk*>(self)-> |
| 277 HandleViewMoveFocus(widget); |
| 278 } |
| 279 void HandleViewMoveFocus(GtkWidget* widget); |
| 280 |
274 static void HandleCopyClipboardThunk(GtkTextView* text_view, gpointer self) { | 281 static void HandleCopyClipboardThunk(GtkTextView* text_view, gpointer self) { |
275 reinterpret_cast<AutocompleteEditViewGtk*>(self)->HandleCopyClipboard(); | 282 reinterpret_cast<AutocompleteEditViewGtk*>(self)->HandleCopyClipboard(); |
276 } | 283 } |
277 void HandleCopyClipboard(); | 284 void HandleCopyClipboard(); |
278 | 285 |
279 // Actual implementation of SelectAll(), but also provides control over | 286 // Actual implementation of SelectAll(), but also provides control over |
280 // whether the PRIMARY selection is set to the selected text (in SelectAll(), | 287 // whether the PRIMARY selection is set to the selected text (in SelectAll(), |
281 // it isn't, but we want set the selection when the user clicks in the entry). | 288 // it isn't, but we want set the selection when the user clicks in the entry). |
282 void SelectAllInternal(bool reversed, bool update_primary_selection); | 289 void SelectAllInternal(bool reversed, bool update_primary_selection); |
283 | 290 |
(...skipping 21 matching lines...) Expand all Loading... |
305 | 312 |
306 // Try to parse the current text as a URL and colorize the components. | 313 // Try to parse the current text as a URL and colorize the components. |
307 void EmphasizeURLComponents(); | 314 void EmphasizeURLComponents(); |
308 | 315 |
309 // Internally invoked whenever the text changes in some way. | 316 // Internally invoked whenever the text changes in some way. |
310 void TextChanged(); | 317 void TextChanged(); |
311 | 318 |
312 // Save |selected_text| as the PRIMARY X selection. | 319 // Save |selected_text| as the PRIMARY X selection. |
313 void SavePrimarySelection(const std::string& selected_text); | 320 void SavePrimarySelection(const std::string& selected_text); |
314 | 321 |
| 322 // Update the field with |text| and set the selection. |
| 323 void SetTextAndSelectedRange(const std::wstring& text, |
| 324 const CharRange& range); |
| 325 |
315 // The widget we expose, used for vertically centering the real text edit, | 326 // The widget we expose, used for vertically centering the real text edit, |
316 // since the height will change based on the font / font size, etc. | 327 // since the height will change based on the font / font size, etc. |
317 OwnedWidgetGtk alignment_; | 328 OwnedWidgetGtk alignment_; |
318 | 329 |
319 // The actual text entry which will be owned by the alignment_. | 330 // The actual text entry which will be owned by the alignment_. |
320 GtkWidget* text_view_; | 331 GtkWidget* text_view_; |
321 | 332 |
322 GtkTextTagTable* tag_table_; | 333 GtkTextTagTable* tag_table_; |
323 GtkTextBuffer* text_buffer_; | 334 GtkTextBuffer* text_buffer_; |
324 GtkTextTag* faded_text_tag_; | 335 GtkTextTag* faded_text_tag_; |
325 GtkTextTag* secure_scheme_tag_; | 336 GtkTextTag* secure_scheme_tag_; |
326 GtkTextTag* insecure_scheme_tag_; | 337 GtkTextTag* insecure_scheme_tag_; |
327 GtkTextTag* normal_text_tag_; | 338 GtkTextTag* normal_text_tag_; |
328 | 339 |
329 scoped_ptr<AutocompleteEditModel> model_; | 340 scoped_ptr<AutocompleteEditModel> model_; |
330 scoped_ptr<AutocompletePopupView> popup_view_; | 341 scoped_ptr<AutocompletePopupView> popup_view_; |
331 AutocompleteEditController* controller_; | 342 AutocompleteEditController* controller_; |
332 ToolbarModel* toolbar_model_; | 343 ToolbarModel* toolbar_model_; |
333 | 344 |
334 // The object that handles additional command functionality exposed on the | 345 // The object that handles additional command functionality exposed on the |
335 // edit, such as invoking the keyword editor. | 346 // edit, such as invoking the keyword editor. |
336 CommandUpdater* command_updater_; | 347 CommandUpdater* command_updater_; |
337 | 348 |
338 // When true, the location bar view is read only and also is has a slightly | 349 // When true, the location bar view is read only and also is has a slightly |
339 // different presentation (smaller font size). This is used for popups. | 350 // different presentation (smaller font size). This is used for popups. |
340 bool popup_window_mode_; | 351 bool popup_window_mode_; |
341 | 352 |
342 ToolbarModel::SecurityLevel scheme_security_level_; | 353 ToolbarModel::SecurityLevel scheme_security_level_; |
343 | 354 |
| 355 // Text and selection at the point where the user started using the |
| 356 // arrows to move around in the popup. |
| 357 std::wstring saved_temporary_text_; |
| 358 CharRange saved_temporary_selection_; |
| 359 |
344 // Tracking state before and after a possible change. | 360 // Tracking state before and after a possible change. |
345 std::wstring text_before_change_; | 361 std::wstring text_before_change_; |
346 CharRange sel_before_change_; | 362 CharRange sel_before_change_; |
347 | 363 |
348 // The most-recently-selected text from the entry. This is updated on-the-fly | 364 // The most-recently-selected text from the entry. This is updated on-the-fly |
349 // as the user selects text. It is used in cases where we need to make the | 365 // as the user selects text. It is used in cases where we need to make the |
350 // PRIMARY selection persist even after the user has unhighlighted the text in | 366 // PRIMARY selection persist even after the user has unhighlighted the text in |
351 // the view (e.g. when they highlight some text and then click to unhighlight | 367 // the view (e.g. when they highlight some text and then click to unhighlight |
352 // it, we pass this string to SavePrimarySelection()). | 368 // it, we pass this string to SavePrimarySelection()). |
353 std::string selected_text_; | 369 std::string selected_text_; |
(...skipping 18 matching lines...) Expand all Loading... |
372 // is released (we only do so if the view was initially unfocused). | 388 // is released (we only do so if the view was initially unfocused). |
373 bool text_view_focused_before_button_press_; | 389 bool text_view_focused_before_button_press_; |
374 | 390 |
375 #if !defined(TOOLKIT_VIEWS) | 391 #if !defined(TOOLKIT_VIEWS) |
376 // Supplies colors, et cetera. | 392 // Supplies colors, et cetera. |
377 GtkThemeProvider* theme_provider_; | 393 GtkThemeProvider* theme_provider_; |
378 | 394 |
379 NotificationRegistrar registrar_; | 395 NotificationRegistrar registrar_; |
380 #endif | 396 #endif |
381 | 397 |
| 398 // Indicates if Tab key was pressed. |
| 399 // |
| 400 // It's only used in the key press handler to detect a Tab key press event |
| 401 // during sync dispatch of "move-focus" signal. |
| 402 bool tab_was_pressed_; |
| 403 |
382 // If a character is inserted, store it in this variable so that it can | 404 // If a character is inserted, store it in this variable so that it can |
383 // be used later in "key-press-event" signal handler to determine if a Tab or | 405 // be used later in "key-press-event" signal handler to determine if a Tab or |
384 // Enter key event is handled by IME or not. | 406 // Enter key event is handled by IME or not. |
385 char char_inserted_; | 407 char char_inserted_; |
386 | 408 |
387 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); | 409 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk); |
388 }; | 410 }; |
389 | 411 |
390 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ | 412 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_VIEW_GTK_H_ |
OLD | NEW |