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 #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 <gdk-pixbuf/gdk-pixbuf.h> | 8 #include <gdk-pixbuf/gdk-pixbuf.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 |
| 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 |
| 17 // height, only pass in images for the top row. |
| 18 // |
14 // TODO(port): add support for caching server-side pixmaps of prerendered | 19 // TODO(port): add support for caching server-side pixmaps of prerendered |
15 // nineboxes. | 20 // nineboxes. |
16 class NineBox { | 21 class NineBox { |
17 public: | 22 public: |
18 // Construct a NineBox with nine images. NULL images are allowed. | 23 // Construct a NineBox with nine images. NULL images are allowed. |
19 // Takes ownership of each image, but not the |images| array. | 24 // Takes ownership of each image, but not the |images| array. |
20 NineBox(GdkPixbuf* images[9]); | 25 NineBox(GdkPixbuf* images[9]); |
21 ~NineBox(); | 26 ~NineBox(); |
22 | 27 |
23 // Render the NineBox to dst. | 28 // Render the NineBox to dst. |
24 // Expects dst to already be the proper size. | 29 // Expects dst to already be the proper size. |
25 void RenderToPixbuf(GdkPixbuf* dst); | 30 void RenderToPixbuf(GdkPixbuf* dst); |
26 | 31 |
27 // Render the top row of images to dst between x1 and x2. | 32 // Render the top row of images to dst between x1 and x2. |
28 // This is split from RenderToPixbuf so the toolbar can use it. | 33 // This is split from RenderToPixbuf so the toolbar can use it. |
29 void RenderTopCenterStrip(GdkPixbuf* dst, int x1, int x2); | 34 void RenderTopCenterStrip(GdkPixbuf* dst, int x1, int x2); |
30 | 35 |
31 private: | 36 private: |
32 // Repeatedly stamp src across dst. | 37 // Repeatedly stamp src across dst. |
33 void TileImage(GdkPixbuf* src, GdkPixbuf* dst, | 38 void TileImage(GdkPixbuf* src, GdkPixbuf* dst, |
34 int x1, int y1, int x2, int y2); | 39 int x1, int y1, int x2, int y2); |
35 | 40 |
36 GdkPixbuf* images_[9]; | 41 GdkPixbuf* images_[9]; |
37 }; | 42 }; |
38 | 43 |
39 #endif // CHROME_BROWSER_GTK_NINE_BOX_H_ | 44 #endif // CHROME_BROWSER_GTK_NINE_BOX_H_ |
OLD | NEW |