Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1637)

Side by Side Diff: chrome/browser/ui/gtk/gtk_util.cc

Issue 9390038: Move automation/ui_controls to ui/ui_controls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win_aura fix, sync Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/gtk/gtk_util.h" 5 #include "chrome/browser/ui/gtk/gtk_util.h"
6 6
7 #include <cairo/cairo.h> 7 #include <cairo/cairo.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cstdarg> 10 #include <cstdarg>
(...skipping 18 matching lines...) Expand all
29 #include "chrome/browser/ui/gtk/theme_service_gtk.h" 29 #include "chrome/browser/ui/gtk/theme_service_gtk.h"
30 #include "content/public/browser/render_view_host.h" 30 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
32 #include "content/public/common/renderer_preferences.h" 32 #include "content/public/common/renderer_preferences.h"
33 #include "googleurl/src/gurl.h" 33 #include "googleurl/src/gurl.h"
34 #include "grit/theme_resources.h" 34 #include "grit/theme_resources.h"
35 #include "grit/theme_resources_standard.h" 35 #include "grit/theme_resources_standard.h"
36 #include "ui/base/events.h" 36 #include "ui/base/events.h"
37 #include "ui/base/gtk/gtk_compat.h" 37 #include "ui/base/gtk/gtk_compat.h"
38 #include "ui/base/gtk/gtk_hig_constants.h" 38 #include "ui/base/gtk/gtk_hig_constants.h"
39 #include "ui/base/gtk/gtk_screen_util.h"
39 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
40 #include "ui/base/resource/resource_bundle.h" 41 #include "ui/base/resource/resource_bundle.h"
41 #include "ui/base/text/text_elider.h" 42 #include "ui/base/text/text_elider.h"
42 #include "ui/base/x/x11_util.h" 43 #include "ui/base/x/x11_util.h"
43 #include "ui/gfx/gtk_util.h" 44 #include "ui/gfx/gtk_util.h"
44 #include "ui/gfx/image/cairo_cached_surface.h" 45 #include "ui/gfx/image/cairo_cached_surface.h"
45 #include "ui/gfx/image/image.h" 46 #include "ui/gfx/image/image.h"
46 47
47 #if defined(OS_CHROMEOS) 48 #if defined(OS_CHROMEOS)
48 #include "chrome/browser/chromeos/frame/browser_view.h" 49 #include "chrome/browser/chromeos/frame/browser_view.h"
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 pango_font_description_set_absolute_size(font_desc, 538 pango_font_description_set_absolute_size(font_desc,
538 PANGO_SCALE * size_pixels); 539 PANGO_SCALE * size_pixels);
539 gtk_widget_modify_font(widget, font_desc); 540 gtk_widget_modify_font(widget, font_desc);
540 pango_font_description_free(font_desc); 541 pango_font_description_free(font_desc);
541 } 542 }
542 543
543 void UndoForceFontSize(GtkWidget* widget) { 544 void UndoForceFontSize(GtkWidget* widget) {
544 gtk_widget_modify_font(widget, NULL); 545 gtk_widget_modify_font(widget, NULL);
545 } 546 }
546 547
547 gfx::Point GetWidgetScreenPosition(GtkWidget* widget) {
548 GdkWindow* window = gtk_widget_get_window(widget);
549
550 if (!window) {
551 NOTREACHED() << "Must only be called on realized widgets.";
552 return gfx::Point(0, 0);
553 }
554
555 gint x, y;
556 gdk_window_get_origin(window, &x, &y);
557
558 if (!gtk_widget_get_has_window(widget)) {
559 GtkAllocation allocation;
560 gtk_widget_get_allocation(widget, &allocation);
561 x += allocation.x;
562 y += allocation.y;
563 }
564
565 return gfx::Point(x, y);
566 }
567
568 gfx::Rect GetWidgetScreenBounds(GtkWidget* widget) {
569 gfx::Point position = GetWidgetScreenPosition(widget);
570
571 GtkAllocation allocation;
572 gtk_widget_get_allocation(widget, &allocation);
573
574 return gfx::Rect(position.x(), position.y(),
575 allocation.width, allocation.height);
576 }
577
578 gfx::Size GetWidgetSize(GtkWidget* widget) { 548 gfx::Size GetWidgetSize(GtkWidget* widget) {
579 GtkRequisition size; 549 GtkRequisition size;
580 gtk_widget_size_request(widget, &size); 550 gtk_widget_size_request(widget, &size);
581 return gfx::Size(size.width, size.height); 551 return gfx::Size(size.width, size.height);
582 } 552 }
583 553
584 void ConvertWidgetPointToScreen(GtkWidget* widget, gfx::Point* p) { 554 void ConvertWidgetPointToScreen(GtkWidget* widget, gfx::Point* p) {
585 DCHECK(widget); 555 DCHECK(widget);
586 DCHECK(p); 556 DCHECK(p);
587 557
588 gfx::Point position = GetWidgetScreenPosition(widget); 558 gfx::Point position = ui::GetWidgetScreenPosition(widget);
589 p->SetPoint(p->x() + position.x(), p->y() + position.y()); 559 p->SetPoint(p->x() + position.x(), p->y() + position.y());
590 } 560 }
591 561
592 GtkWidget* CenterWidgetInHBox(GtkWidget* hbox, GtkWidget* widget, 562 GtkWidget* CenterWidgetInHBox(GtkWidget* hbox, GtkWidget* widget,
593 bool pack_at_end, int padding) { 563 bool pack_at_end, int padding) {
594 GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0); 564 GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0);
595 gtk_box_pack_start(GTK_BOX(centering_vbox), widget, TRUE, FALSE, 0); 565 gtk_box_pack_start(GTK_BOX(centering_vbox), widget, TRUE, FALSE, 0);
596 if (pack_at_end) 566 if (pack_at_end)
597 gtk_box_pack_end(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding); 567 gtk_box_pack_end(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding);
598 else 568 else
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 1292
1323 void DoCopy(BrowserWindow* window) { 1293 void DoCopy(BrowserWindow* window) {
1324 DoCutCopyPaste(window, &RenderWidgetHost::Copy, "copy-clipboard"); 1294 DoCutCopyPaste(window, &RenderWidgetHost::Copy, "copy-clipboard");
1325 } 1295 }
1326 1296
1327 void DoPaste(BrowserWindow* window) { 1297 void DoPaste(BrowserWindow* window) {
1328 DoCutCopyPaste(window, &RenderWidgetHost::Paste, "paste-clipboard"); 1298 DoCutCopyPaste(window, &RenderWidgetHost::Paste, "paste-clipboard");
1329 } 1299 }
1330 1300
1331 } // namespace gtk_util 1301 } // namespace gtk_util
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/gtk_util.h ('k') | chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698