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

Unified Diff: chrome/browser/ui/gtk/nine_box.h

Issue 6099014: Move chrome/browser/gtk to chrome/browser/ui/gtk (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Move browser/gtk/ to browser/ui/gtk/, leave header stubs, update new header guards Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/menu_gtk.cc ('k') | chrome/browser/ui/gtk/nine_box.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/nine_box.h
diff --git a/chrome/browser/ui/gtk/nine_box.h b/chrome/browser/ui/gtk/nine_box.h
new file mode 100644
index 0000000000000000000000000000000000000000..f1121bc820adaa92fc217372e6dc96a8e4601d35
--- /dev/null
+++ b/chrome/browser/ui/gtk/nine_box.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_GTK_NINE_BOX_H_
+#define CHROME_BROWSER_UI_GTK_NINE_BOX_H_
+#pragma once
+
+#include <gtk/gtk.h>
+
+// A NineBox manages a set of source images representing a 3x3 grid, where
+// non-corner images can be tiled to make a larger image. It's used to
+// use bitmaps for constructing image-based resizable widgets like buttons.
+//
+// If you want just a vertical image that stretches in height but is fixed
+// in width, only pass in images for the left column (leave others NULL).
+// Similarly, for a horizontal image that stretches in width but is fixed in
+// height, only pass in images for the top row.
+//
+// TODO(port): add support for caching server-side pixmaps of prerendered
+// nineboxes.
+class NineBox {
+ public:
+ // Construct a NineBox with nine images. Images are specified using resource
+ // ids that will be passed to the resource bundle. Use 0 for no image.
+ NineBox(int top_left, int top, int top_right, int left, int center, int right,
+ int bottom_left, int bottom, int bottom_right);
+
+ // Construct a NineBox from a single image and insets indicating the sizes
+ // of the edges and corners.
+ NineBox(int image, int top_margin, int bottom_margin, int left_margin,
+ int right_margin);
+ ~NineBox();
+
+ // Render the NineBox to |dst|.
+ // The images will be tiled to fit into the widget.
+ void RenderToWidget(GtkWidget* dst) const;
+
+ // As above, but rendered partially transparent.
+ void RenderToWidgetWithOpacity(GtkWidget* dst, double opacity) const;
+
+ // Render the top row of images to |dst| between |x1| and |x1| + |width|.
+ // This is split from RenderToWidget so the toolbar can use it.
+ void RenderTopCenterStrip(cairo_t* cr, int x, int y, int width) const;
+
+ // Change all pixels that are white in |images_| to have 0 opacity.
+ void ChangeWhiteToTransparent();
+
+ // Set the shape of |widget| to match that of the ninebox. Note that |widget|
+ // must have its own window and be allocated. Also, currently only the top
+ // three images are used.
+ // TODO(estade): extend this function to use all 9 images (if it's ever
+ // needed).
+ void ContourWidget(GtkWidget* widget) const;
+
+ private:
+ GdkPixbuf* images_[9];
+ bool unref_pixbufs_on_destroy_;
+};
+
+#endif // CHROME_BROWSER_UI_GTK_NINE_BOX_H_
« no previous file with comments | « chrome/browser/ui/gtk/menu_gtk.cc ('k') | chrome/browser/ui/gtk/nine_box.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698