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

Side by Side Diff: chrome/browser/gtk/nine_box.h

Issue 524025: Alter NineBox so that it can accept a single sprite resource with insets that... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/gtk/nine_box.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_GTK_NINE_BOX_H_ 5 #ifndef CHROME_BROWSER_GTK_NINE_BOX_H_
6 #define CHROME_BROWSER_GTK_NINE_BOX_H_ 6 #define CHROME_BROWSER_GTK_NINE_BOX_H_
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 // A NineBox manages a set of source images representing a 3x3 grid, where 10 // A NineBox manages a set of source images representing a 3x3 grid, where
11 // non-corner images can be tiled to make a larger image. It's used to 11 // non-corner images can be tiled to make a larger image. It's used to
12 // use bitmaps for constructing image-based resizable widgets like buttons. 12 // use bitmaps for constructing image-based resizable widgets like buttons.
13 // 13 //
14 // If you want just a vertical image that stretches in height but is fixed 14 // If you want just a vertical image that stretches in height but is fixed
15 // in width, only pass in images for the left column (leave others NULL). 15 // in width, only pass in images for the left column (leave others NULL).
16 // Similarly, for a horizontal image that stretches in width but is fixed in 16 // Similarly, for a horizontal image that stretches in width but is fixed in
17 // height, only pass in images for the top row. 17 // height, only pass in images for the top row.
18 // 18 //
19 // TODO(port): add support for caching server-side pixmaps of prerendered 19 // TODO(port): add support for caching server-side pixmaps of prerendered
20 // nineboxes. 20 // nineboxes.
21 class NineBox { 21 class NineBox {
22 public: 22 public:
23 // Construct a NineBox with nine images. Images are specified using resource 23 // Construct a NineBox with nine images. Images are specified using resource
24 // ids that will be passed to the resource bundle. Use 0 for no image. 24 // ids that will be passed to the resource bundle. Use 0 for no image.
25 NineBox(int top_left, int top, int top_right, int left, int center, int right, 25 NineBox(int top_left, int top, int top_right, int left, int center, int right,
26 int bottom_left, int bottom, int bottom_right); 26 int bottom_left, int bottom, int bottom_right);
27
28 // Construct a NineBox from a single image and insets indicating the sizes
29 // of the edges and corners.
30 NineBox(int image, int top_margin, int bottom_margin, int left_margin,
31 int right_margin);
27 ~NineBox(); 32 ~NineBox();
28 33
29 // Render the NineBox to |dst|. 34 // Render the NineBox to |dst|.
30 // The images will be tiled to fit into the widget. 35 // The images will be tiled to fit into the widget.
31 void RenderToWidget(GtkWidget* dst) const; 36 void RenderToWidget(GtkWidget* dst) const;
32 37
33 // Render the top row of images to |dst| between |x1| and |x1| + |width|. 38 // Render the top row of images to |dst| between |x1| and |x1| + |width|.
34 // This is split from RenderToWidget so the toolbar can use it. 39 // This is split from RenderToWidget so the toolbar can use it.
35 void RenderTopCenterStrip(cairo_t* cr, int x, int y, int width) const; 40 void RenderTopCenterStrip(cairo_t* cr, int x, int y, int width) const;
36 41
37 // Change all pixels that are white in |images_| to have 0 opacity. 42 // Change all pixels that are white in |images_| to have 0 opacity.
38 void ChangeWhiteToTransparent(); 43 void ChangeWhiteToTransparent();
39 44
40 // Set the shape of |widget| to match that of the ninebox. Note that |widget| 45 // Set the shape of |widget| to match that of the ninebox. Note that |widget|
41 // must have its own window and be allocated. Also, currently only the top 46 // must have its own window and be allocated. Also, currently only the top
42 // three images are used. 47 // three images are used.
43 // TODO(estade): extend this function to use all 9 images (if it's ever 48 // TODO(estade): extend this function to use all 9 images (if it's ever
44 // needed). 49 // needed).
45 void ContourWidget(GtkWidget* widget) const; 50 void ContourWidget(GtkWidget* widget) const;
46 51
47 private: 52 private:
48 GdkPixbuf* images_[9]; 53 GdkPixbuf* images_[9];
54 bool unref_pixbufs_on_destroy_;
49 }; 55 };
50 56
51 #endif // CHROME_BROWSER_GTK_NINE_BOX_H_ 57 #endif // CHROME_BROWSER_GTK_NINE_BOX_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/gtk/nine_box.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698