| 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 "base/gfx/gtk_util.h" | 5 #include "base/gfx/gtk_util.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <gtk/gtk.h> |
| 8 | 9 |
| 9 #include "base/gfx/rect.h" | 10 #include "base/gfx/rect.h" |
| 10 #include "skia/include/SkBitmap.h" | 11 #include "skia/include/SkBitmap.h" |
| 11 | 12 |
| 12 namespace gfx { | 13 namespace gfx { |
| 13 | 14 |
| 14 void SubtractRectanglesFromRegion(GdkRegion* region, | 15 void SubtractRectanglesFromRegion(GdkRegion* region, |
| 15 const std::vector<gfx::Rect>& cutouts) { | 16 const std::vector<gfx::Rect>& cutouts) { |
| 16 for (size_t i = 0; i < cutouts.size(); ++i) { | 17 for (size_t i = 0; i < cutouts.size(); ++i) { |
| 17 GdkRectangle rect = cutouts[i].ToGdkRectangle(); | 18 GdkRectangle rect = cutouts[i].ToGdkRectangle(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 true, // There is an alpha channel. | 54 true, // There is an alpha channel. |
| 54 8, | 55 8, |
| 55 width, height, stride, &FreePixels, data); | 56 width, height, stride, &FreePixels, data); |
| 56 | 57 |
| 57 // Assume ownership of pixbuf. | 58 // Assume ownership of pixbuf. |
| 58 g_object_ref_sink(pixbuf); | 59 g_object_ref_sink(pixbuf); |
| 59 bitmap->unlockPixels(); | 60 bitmap->unlockPixels(); |
| 60 return pixbuf; | 61 return pixbuf; |
| 61 } | 62 } |
| 62 | 63 |
| 64 GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, |
| 65 int top, int bottom, int left, int right) { |
| 66 // Use a GtkEventBox to get the background painted. However, we can't just |
| 67 // use a container border, since it won't paint there. Use an alignment |
| 68 // inside to get the sizes exactly of how we want the border painted. |
| 69 GtkWidget* ebox = gtk_event_box_new(); |
| 70 gtk_widget_modify_bg(ebox, GTK_STATE_NORMAL, color); |
| 71 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); |
| 72 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), top, bottom, left, right); |
| 73 gtk_container_add(GTK_CONTAINER(alignment), child); |
| 74 gtk_container_add(GTK_CONTAINER(ebox), alignment); |
| 75 return ebox; |
| 76 } |
| 77 |
| 63 } // namespace gfx | 78 } // namespace gfx |
| OLD | NEW |