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 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" | 5 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 const GURL url(match.destination_url); | 363 const GURL url(match.destination_url); |
364 std::wstring keyword; | 364 std::wstring keyword; |
365 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword); | 365 const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword); |
366 edit_view_->OpenURL(url, disposition, match.transition, GURL(), line, | 366 edit_view_->OpenURL(url, disposition, match.transition, GURL(), line, |
367 is_keyword_hint ? std::wstring() : keyword); | 367 is_keyword_hint ? std::wstring() : keyword); |
368 } | 368 } |
369 | 369 |
370 gboolean AutocompletePopupViewGtk::HandleMotion(GtkWidget* widget, | 370 gboolean AutocompletePopupViewGtk::HandleMotion(GtkWidget* widget, |
371 GdkEventMotion* event) { | 371 GdkEventMotion* event) { |
372 // TODO(deanm): Windows has a bunch of complicated logic here. | 372 // TODO(deanm): Windows has a bunch of complicated logic here. |
373 size_t line = LineFromY(event->y); | 373 size_t line = LineFromY(static_cast<int>(event->y)); |
374 // There is both a hovered and selected line, hovered just means your mouse | 374 // There is both a hovered and selected line, hovered just means your mouse |
375 // is over it, but selected is what's showing in the location edit. | 375 // is over it, but selected is what's showing in the location edit. |
376 model_->SetHoveredLine(line); | 376 model_->SetHoveredLine(line); |
377 // Select the line if the user has the left mouse button down. | 377 // Select the line if the user has the left mouse button down. |
378 if (event->state & GDK_BUTTON1_MASK) | 378 if (event->state & GDK_BUTTON1_MASK) |
379 model_->SetSelectedLine(line, false); | 379 model_->SetSelectedLine(line, false); |
380 return TRUE; | 380 return TRUE; |
381 } | 381 } |
382 | 382 |
383 gboolean AutocompletePopupViewGtk::HandleButtonPress(GtkWidget* widget, | 383 gboolean AutocompletePopupViewGtk::HandleButtonPress(GtkWidget* widget, |
384 GdkEventButton* event) { | 384 GdkEventButton* event) { |
385 // Very similar to HandleMotion. | 385 // Very similar to HandleMotion. |
386 size_t line = LineFromY(event->y); | 386 size_t line = LineFromY(static_cast<int>(event->y)); |
387 model_->SetHoveredLine(line); | 387 model_->SetHoveredLine(line); |
388 if (event->button == 1) | 388 if (event->button == 1) |
389 model_->SetSelectedLine(line, false); | 389 model_->SetSelectedLine(line, false); |
390 return TRUE; | 390 return TRUE; |
391 } | 391 } |
392 | 392 |
393 gboolean AutocompletePopupViewGtk::HandleButtonRelease(GtkWidget* widget, | 393 gboolean AutocompletePopupViewGtk::HandleButtonRelease(GtkWidget* widget, |
394 GdkEventButton* event) { | 394 GdkEventButton* event) { |
395 size_t line = LineFromY(event->y); | 395 size_t line = LineFromY(static_cast<int>(event->y)); |
396 switch (event->button) { | 396 switch (event->button) { |
397 case 1: // Left click. | 397 case 1: // Left click. |
398 AcceptLine(line, CURRENT_TAB); | 398 AcceptLine(line, CURRENT_TAB); |
399 break; | 399 break; |
400 case 2: // Middle click. | 400 case 2: // Middle click. |
401 AcceptLine(line, NEW_BACKGROUND_TAB); | 401 AcceptLine(line, NEW_BACKGROUND_TAB); |
402 break; | 402 break; |
403 default: | 403 default: |
404 // Don't open the result. | 404 // Don't open the result. |
405 break; | 405 break; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 // Draw the icon for this result. | 452 // Draw the icon for this result. |
453 DrawFullPixbuf(drawable, gc, IconForMatch(match, is_selected), | 453 DrawFullPixbuf(drawable, gc, IconForMatch(match, is_selected), |
454 icon_start_x, line_rect.y() + kIconTopPadding); | 454 icon_start_x, line_rect.y() + kIconTopPadding); |
455 | 455 |
456 // Draw the results text vertically centered in the results space. | 456 // Draw the results text vertically centered in the results space. |
457 // First draw the contents / url, but don't let it take up the whole width | 457 // First draw the contents / url, but don't let it take up the whole width |
458 // if there is also a description to be shown. | 458 // if there is also a description to be shown. |
459 bool has_description = !match.description.empty(); | 459 bool has_description = !match.description.empty(); |
460 int text_width = window_rect.width() - (kIconAreaWidth + kRightPadding); | 460 int text_width = window_rect.width() - (kIconAreaWidth + kRightPadding); |
461 int allocated_content_width = has_description ? | 461 int allocated_content_width = has_description ? |
462 text_width * kContentWidthPercentage : text_width; | 462 static_cast<int>(text_width * kContentWidthPercentage) : text_width; |
463 pango_layout_set_width(layout_, allocated_content_width * PANGO_SCALE); | 463 pango_layout_set_width(layout_, allocated_content_width * PANGO_SCALE); |
464 | 464 |
465 // Note: We force to URL to LTR for all text directions. | 465 // Note: We force to URL to LTR for all text directions. |
466 SetupLayoutForMatch(layout_, match.contents, match.contents_class, | 466 SetupLayoutForMatch(layout_, match.contents, match.contents_class, |
467 &kContentTextColor, std::string()); | 467 &kContentTextColor, std::string()); |
468 | 468 |
469 int actual_content_width, actual_content_height; | 469 int actual_content_width, actual_content_height; |
470 pango_layout_get_size(layout_, | 470 pango_layout_get_size(layout_, |
471 &actual_content_width, &actual_content_height); | 471 &actual_content_width, &actual_content_height); |
472 actual_content_width /= PANGO_SCALE; | 472 actual_content_width /= PANGO_SCALE; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 // static | 506 // static |
507 AutocompletePopupView* AutocompletePopupView::CreatePopupView( | 507 AutocompletePopupView* AutocompletePopupView::CreatePopupView( |
508 const gfx::Font& font, | 508 const gfx::Font& font, |
509 AutocompleteEditView* edit_view, | 509 AutocompleteEditView* edit_view, |
510 AutocompleteEditModel* edit_model, | 510 AutocompleteEditModel* edit_model, |
511 Profile* profile, | 511 Profile* profile, |
512 AutocompletePopupPositioner* popup_positioner) { | 512 AutocompletePopupPositioner* popup_positioner) { |
513 return new AutocompletePopupViewGtk(edit_view, edit_model, profile, | 513 return new AutocompletePopupViewGtk(edit_view, edit_model, profile, |
514 popup_positioner); | 514 popup_positioner); |
515 } | 515 } |
OLD | NEW |