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

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

Issue 149102: Fix a crash that happens when changing themes. (Closed)
Patch Set: Created 11 years, 5 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
« no previous file with comments | « chrome/browser/gtk/browser_window_gtk.cc ('k') | 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 #include "chrome/common/notification_observer.h"
11 #include "chrome/common/notification_registrar.h"
12 #include "chrome/common/notification_type.h"
13
10 class ThemeProvider; 14 class ThemeProvider;
11 15
12 // A NineBox manages a set of source images representing a 3x3 grid, where 16 // A NineBox manages a set of source images representing a 3x3 grid, where
13 // non-corner images can be tiled to make a larger image. It's used to 17 // non-corner images can be tiled to make a larger image. It's used to
14 // use bitmaps for constructing image-based resizable widgets like buttons. 18 // use bitmaps for constructing image-based resizable widgets like buttons.
15 // 19 //
16 // If you want just a vertical image that stretches in height but is fixed 20 // If you want just a vertical image that stretches in height but is fixed
17 // in width, only pass in images for the left column (leave others NULL). 21 // in width, only pass in images for the left column (leave others NULL).
18 // Similarly, for a horizontal image that stretches in width but is fixed in 22 // Similarly, for a horizontal image that stretches in width but is fixed in
19 // height, only pass in images for the top row. 23 // height, only pass in images for the top row.
20 // 24 //
21 // TODO(port): add support for caching server-side pixmaps of prerendered 25 // TODO(port): add support for caching server-side pixmaps of prerendered
22 // nineboxes. 26 // nineboxes.
23 class NineBox { 27 class NineBox : public NotificationObserver {
24 public: 28 public:
25 // Construct a NineBox with nine images. Images are specified using resource 29 // Construct a NineBox with nine images. Images are specified using resource
26 // ids that will be passed to the resource bundle. Use 0 for no image. 30 // ids that will be passed to the resource bundle. Use 0 for no image.
27 NineBox(int top_left, int top, int top_right, int left, int center, int right, 31 NineBox(int top_left, int top, int top_right, int left, int center, int right,
28 int bottom_left, int bottom, int bottom_right); 32 int bottom_left, int bottom, int bottom_right);
29 33
30 // Same as above, but use themed images. 34 // Same as above, but use themed images.
31 NineBox(ThemeProvider* theme_provider, 35 NineBox(ThemeProvider* theme_provider,
32 int top_left, int top, int top_right, int left, int center, int right, 36 int top_left, int top, int top_right, int left, int center, int right,
33 int bottom_left, int bottom, int bottom_right); 37 int bottom_left, int bottom, int bottom_right);
(...skipping 11 matching lines...) Expand all
45 // Change all pixels that are white in |images_| to have 0 opacity. 49 // Change all pixels that are white in |images_| to have 0 opacity.
46 void ChangeWhiteToTransparent(); 50 void ChangeWhiteToTransparent();
47 51
48 // Set the shape of |widget| to match that of the ninebox. Note that |widget| 52 // Set the shape of |widget| to match that of the ninebox. Note that |widget|
49 // must have its own window and be allocated. Also, currently only the top 53 // must have its own window and be allocated. Also, currently only the top
50 // three images are used. 54 // three images are used.
51 // TODO(estade): extend this function to use all 9 images (if it's ever 55 // TODO(estade): extend this function to use all 9 images (if it's ever
52 // needed). 56 // needed).
53 void ContourWidget(GtkWidget* widget) const; 57 void ContourWidget(GtkWidget* widget) const;
54 58
59 // Provide NotificationObserver implementation.
60 virtual void Observe(NotificationType type,
61 const NotificationSource& source,
62 const NotificationDetails& details);
55 private: 63 private:
56 GdkPixbuf* images_[9]; 64 GdkPixbuf* images_[9];
65
66 // We need to remember the image ids that the user passes in and the theme
67 // provider so we can reload images if the user changes theme.
68 int image_ids_[9];
69 ThemeProvider* theme_provider_;
70
71 // Used to listen for theme change notifications.
72 NotificationRegistrar registrar_;
57 }; 73 };
58 74
59 #endif // CHROME_BROWSER_GTK_NINE_BOX_H_ 75 #endif // CHROME_BROWSER_GTK_NINE_BOX_H_
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_window_gtk.cc ('k') | chrome/browser/gtk/nine_box.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698