]> Pileus Git - ~andy/gtk/blob - gtk/gtkrc.h
Add gtk_widget_modify_{fg,bg,text,base,font}.
[~andy/gtk] / gtk / gtkrc.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #ifndef __GTK_RC_H__
28 #define __GTK_RC_H__
29
30
31 #include <gtk/gtkstyle.h>
32 #include <gtk/gtkwidget.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /* __cplusplus */
37
38 #define GTK_TYPE_RC_STYLE              (gtk_rc_style_get_type ())
39 #define GTK_RC_STYLE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_RC_STYLE, GtkRcStyle))
40 #define GTK_RC_STYLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RC_STYLE, GtkRcStyleClass))
41 #define GTK_IS_RC_STYLE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_RC_STYLE))
42 #define GTK_IS_RC_STYLE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RC_STYLE))
43 #define GTK_RC_STYLE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RC_STYLE, GtkRcStyleClass))
44
45 typedef enum
46 {
47   GTK_RC_FG             = 1 << 0,
48   GTK_RC_BG             = 1 << 1,
49   GTK_RC_TEXT           = 1 << 2,
50   GTK_RC_BASE           = 1 << 3
51 } GtkRcFlags;
52
53 typedef struct _GtkRcStyleClass GtkRcStyleClass;
54
55 struct _GtkRcStyle
56 {
57   GObject parent_instance;
58
59   /*< public >*/
60   
61   gchar *name;
62   gchar *bg_pixmap_name[5];
63   PangoFontDescription *font_desc;
64
65   GtkRcFlags color_flags[5];
66   GdkColor   fg[5];
67   GdkColor   bg[5];
68   GdkColor   text[5];
69   GdkColor   base[5];
70
71   gint xthickness;
72   gint ythickness;
73
74   /*< private >*/
75   
76   /* list of RC style lists including this RC style */
77   GSList *rc_style_lists;
78 };
79
80 struct _GtkRcStyleClass
81 {
82   GObjectClass parent_class;
83
84   /* Create an empty RC style of the same type as this RC style.
85    * The default implementation, which does
86    * g_object_new (G_OBJECT_TYPE (style), NULL);
87    * should work in most cases.
88    */
89   GtkRcStyle *(*clone) (GtkRcStyle *rc_style);
90
91   /* Fill in engine specific parts of GtkRcStyle by parsing contents
92    * of brackets. Returns G_TOKEN_NONE if succesful, otherwise returns
93    * the token it expected but didn't get.
94    */
95   guint     (*parse)  (GtkRcStyle *rc_style, GScanner *scanner);
96   
97   /* Combine RC style data from src into dest. If overriden, this
98    * function should chain to the parent.
99    */
100   void      (*merge)  (GtkRcStyle *dest, GtkRcStyle *src);
101
102   /* Create an empty style suitable to this RC style
103    */
104   GtkStyle *(*create_style) (GtkRcStyle *rc_style);
105 };
106
107 void      gtk_rc_init                   (void);
108 void      gtk_rc_add_default_file    (const gchar *filename);
109 void      gtk_rc_set_default_files      (gchar **filenames);
110 gchar**   gtk_rc_get_default_files      (void);
111 void      gtk_rc_parse                  (const gchar *filename);
112 void      gtk_rc_parse_string           (const gchar *rc_string);
113 gboolean  gtk_rc_reparse_all            (void);
114 GtkStyle* gtk_rc_get_style              (GtkWidget   *widget);
115 void      gtk_rc_add_widget_name_style  (GtkRcStyle  *rc_style,
116                                          const gchar *pattern);
117 void      gtk_rc_add_widget_class_style (GtkRcStyle  *rc_style,
118                                          const gchar *pattern);
119 void      gtk_rc_add_class_style        (GtkRcStyle  *rc_style,
120                                          const gchar *pattern);
121
122 GType       gtk_rc_style_get_type   (void);
123 GtkRcStyle* gtk_rc_style_new        (void);
124 GtkRcStyle *gtk_rc_style_copy       (GtkRcStyle *orig);
125 void        gtk_rc_style_ref        (GtkRcStyle *rc_style);
126 void        gtk_rc_style_unref      (GtkRcStyle *rc_style);
127
128 /* Tell gtkrc to use a custom routine to load images specified in rc files instead of
129  *   the default xpm-only loader
130  */
131 typedef GdkPixmap*  (*GtkImageLoader)           (GdkWindow      *window,
132                                                  GdkColormap    *colormap,
133                                                  GdkBitmap     **mask,
134                                                  GdkColor       *transparent_color,
135                                                  const gchar    *filename);
136 void            gtk_rc_set_image_loader         (GtkImageLoader  loader);
137
138 GdkPixmap*      gtk_rc_load_image               (GdkColormap    *colormap,
139                                                  GdkColor       *transparent_color,
140                                                  const gchar    *filename);
141 gchar*          gtk_rc_find_pixmap_in_path      (GScanner       *scanner,
142                                                  const gchar    *pixmap_file);
143 gchar*          gtk_rc_find_module_in_path      (const gchar    *module_file);
144 gchar*          gtk_rc_get_theme_dir            (void);
145 gchar*          gtk_rc_get_module_dir           (void);
146
147 /* private functions/definitions */
148 typedef enum {
149   GTK_RC_TOKEN_INVALID = G_TOKEN_LAST,
150   GTK_RC_TOKEN_INCLUDE,
151   GTK_RC_TOKEN_NORMAL,
152   GTK_RC_TOKEN_ACTIVE,
153   GTK_RC_TOKEN_PRELIGHT,
154   GTK_RC_TOKEN_SELECTED,
155   GTK_RC_TOKEN_INSENSITIVE,
156   GTK_RC_TOKEN_FG,
157   GTK_RC_TOKEN_BG,
158   GTK_RC_TOKEN_TEXT,
159   GTK_RC_TOKEN_BASE,
160   GTK_RC_TOKEN_XTHICKNESS,
161   GTK_RC_TOKEN_YTHICKNESS,
162   GTK_RC_TOKEN_FONT,
163   GTK_RC_TOKEN_FONTSET,
164   GTK_RC_TOKEN_FONT_NAME,
165   GTK_RC_TOKEN_BG_PIXMAP,
166   GTK_RC_TOKEN_PIXMAP_PATH,
167   GTK_RC_TOKEN_STYLE,
168   GTK_RC_TOKEN_BINDING,
169   GTK_RC_TOKEN_BIND,
170   GTK_RC_TOKEN_WIDGET,
171   GTK_RC_TOKEN_WIDGET_CLASS,
172   GTK_RC_TOKEN_CLASS,
173   GTK_RC_TOKEN_LOWEST,
174   GTK_RC_TOKEN_GTK,
175   GTK_RC_TOKEN_APPLICATION,
176   GTK_RC_TOKEN_RC,
177   GTK_RC_TOKEN_HIGHEST,
178   GTK_RC_TOKEN_ENGINE,
179   GTK_RC_TOKEN_MODULE_PATH,
180   GTK_RC_TOKEN_LAST
181 } GtkRcTokenType;
182
183 guint   gtk_rc_parse_color      (GScanner            *scanner,
184                                  GdkColor            *color);
185 guint   gtk_rc_parse_state      (GScanner            *scanner,
186                                  GtkStateType        *state);
187 guint   gtk_rc_parse_priority   (GScanner            *scanner,
188                                  GtkPathPriorityType *priority);
189      
190 #ifdef G_OS_WIN32
191
192 gchar  *gtk_win32_get_installation_directory (void);
193
194 #endif
195
196
197 #ifdef __cplusplus
198 }
199 #endif /* __cplusplus */
200
201
202 #endif /* __GTK_RC_H__ */