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 <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
| 10 class ThemeProvider; |
| 11 |
10 // A NineBox manages a set of source images representing a 3x3 grid, where | 12 // 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 | 13 // 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. | 14 // use bitmaps for constructing image-based resizable widgets like buttons. |
13 // | 15 // |
14 // If you want just a vertical image that stretches in height but is fixed | 16 // 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). | 17 // 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 | 18 // Similarly, for a horizontal image that stretches in width but is fixed in |
17 // height, only pass in images for the top row. | 19 // height, only pass in images for the top row. |
18 // | 20 // |
19 // TODO(port): add support for caching server-side pixmaps of prerendered | 21 // TODO(port): add support for caching server-side pixmaps of prerendered |
20 // nineboxes. | 22 // nineboxes. |
21 class NineBox { | 23 class NineBox { |
22 public: | 24 public: |
23 // Construct a NineBox with nine images. Images are specified using resource | 25 // 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. | 26 // 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, | 27 NineBox(int top_left, int top, int top_right, int left, int center, int right, |
26 int bottom_left, int bottom, int bottom_right); | 28 int bottom_left, int bottom, int bottom_right); |
| 29 |
| 30 // Same as above, but use themed images. |
| 31 NineBox(ThemeProvider* theme_provider, |
| 32 int top_left, int top, int top_right, int left, int center, int right, |
| 33 int bottom_left, int bottom, int bottom_right); |
| 34 |
27 ~NineBox(); | 35 ~NineBox(); |
28 | 36 |
29 // Render the NineBox to |dst|. | 37 // Render the NineBox to |dst|. |
30 // The images will be tiled to fit into the widget. | 38 // The images will be tiled to fit into the widget. |
31 void RenderToWidget(GtkWidget* dst) const; | 39 void RenderToWidget(GtkWidget* dst) const; |
32 | 40 |
33 // Render the top row of images to |dst| between |x1| and |x1| + |width|. | 41 // 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. | 42 // This is split from RenderToWidget so the toolbar can use it. |
35 void RenderTopCenterStrip(cairo_t* cr, int x, int y, int width) const; | 43 void RenderTopCenterStrip(cairo_t* cr, int x, int y, int width) const; |
36 | 44 |
37 // Change all pixels that are white in |images_| to have 0 opacity. | 45 // Change all pixels that are white in |images_| to have 0 opacity. |
38 void ChangeWhiteToTransparent(); | 46 void ChangeWhiteToTransparent(); |
39 | 47 |
40 // Set the shape of |widget| to match that of the ninebox. Note that |widget| | 48 // 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 | 49 // must have its own window and be allocated. Also, currently only the top |
42 // three images are used. | 50 // three images are used. |
43 // TODO(estade): extend this function to use all 9 images (if it's ever | 51 // TODO(estade): extend this function to use all 9 images (if it's ever |
44 // needed). | 52 // needed). |
45 void ContourWidget(GtkWidget* widget) const; | 53 void ContourWidget(GtkWidget* widget) const; |
46 | 54 |
47 private: | 55 private: |
48 | 56 |
49 GdkPixbuf* images_[9]; | 57 GdkPixbuf* images_[9]; |
50 }; | 58 }; |
51 | 59 |
52 #endif // CHROME_BROWSER_GTK_NINE_BOX_H_ | 60 #endif // CHROME_BROWSER_GTK_NINE_BOX_H_ |
OLD | NEW |