theme.h

Go to the documentation of this file.
00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
00002 
00003 /* Metacity Theme Rendering */
00004 
00005 /* 
00006  * Copyright (C) 2001 Havoc Pennington
00007  * 
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License as
00010  * published by the Free Software Foundation; either version 2 of the
00011  * License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00021  * 02111-1307, USA.
00022  */
00023 
00024 #ifndef META_THEME_H
00025 #define META_THEME_H
00026 
00027 #include "boxes.h"
00028 #include "gradient.h"
00029 #include "common.h"
00030 #include <gtk/gtkrc.h>
00031 
00032 typedef struct _MetaFrameStyle MetaFrameStyle;
00033 typedef struct _MetaFrameStyleSet MetaFrameStyleSet;
00034 typedef struct _MetaDrawOp MetaDrawOp;
00035 typedef struct _MetaDrawOpList MetaDrawOpList;
00036 typedef struct _MetaGradientSpec MetaGradientSpec;
00037 typedef struct _MetaAlphaGradientSpec MetaAlphaGradientSpec; 
00038 typedef struct _MetaColorSpec MetaColorSpec;
00039 typedef struct _MetaFrameLayout MetaFrameLayout;
00040 typedef struct _MetaButtonSpace MetaButtonSpace;
00041 typedef struct _MetaFrameGeometry MetaFrameGeometry;
00042 typedef struct _MetaTheme MetaTheme;
00043 typedef struct _MetaPositionExprEnv MetaPositionExprEnv;
00044 typedef struct _MetaDrawInfo MetaDrawInfo;
00045 
00046 #define META_THEME_ERROR (g_quark_from_static_string ("meta-theme-error"))
00047 
00048 typedef enum
00049 {
00050   META_THEME_ERROR_FRAME_GEOMETRY,
00051   META_THEME_ERROR_BAD_CHARACTER,
00052   META_THEME_ERROR_BAD_PARENS,
00053   META_THEME_ERROR_UNKNOWN_VARIABLE,
00054   META_THEME_ERROR_DIVIDE_BY_ZERO,
00055   META_THEME_ERROR_MOD_ON_FLOAT,
00056   META_THEME_ERROR_FAILED
00057 } MetaThemeError;
00058 
00066 typedef enum
00067 {
00068   META_BUTTON_SIZING_ASPECT,
00069   META_BUTTON_SIZING_FIXED,
00070   META_BUTTON_SIZING_LAST
00071 } MetaButtonSizing;
00072 
00083 struct _MetaFrameLayout
00084 {
00086   int refcount;
00087   
00089   int left_width;
00091   int right_width;
00093   int bottom_height;
00094   
00098   GtkBorder title_border;
00099 
00101   int title_vertical_pad;
00102   
00104   int right_titlebar_edge;
00106   int left_titlebar_edge;
00107   
00115   MetaButtonSizing button_sizing;
00116 
00122   double button_aspect;
00123   
00125   int button_width;
00126 
00128   int button_height;
00129 
00131   GtkBorder button_border;
00132 
00134   double title_scale;
00135   
00137   guint has_title : 1;
00138 
00140   guint hide_buttons : 1;
00141 
00143   guint top_left_corner_rounded_radius;
00145   guint top_right_corner_rounded_radius;
00147   guint bottom_left_corner_rounded_radius;
00149   guint bottom_right_corner_rounded_radius;
00150 };
00151 
00158 struct _MetaButtonSpace
00159 {
00161   GdkRectangle visible;
00163   GdkRectangle clickable;
00164 };
00165 
00169 struct _MetaFrameGeometry
00170 {
00171   int left_width;
00172   int right_width;
00173   int top_height;
00174   int bottom_height;
00175 
00176   int width;
00177   int height;  
00178 
00179   GdkRectangle title_rect;
00180 
00181   int left_titlebar_edge;
00182   int right_titlebar_edge;
00183   int top_titlebar_edge;
00184   int bottom_titlebar_edge;
00185 
00186   /* used for a memset hack */
00187 #define ADDRESS_OF_BUTTON_RECTS(fgeom) (((char*)(fgeom)) + G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
00188 #define LENGTH_OF_BUTTON_RECTS (G_STRUCT_OFFSET (MetaFrameGeometry, right_right_background) + sizeof (GdkRectangle) - G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
00189   
00190   /* The button rects (if changed adjust memset hack) */
00191   MetaButtonSpace close_rect;
00192   MetaButtonSpace max_rect;
00193   MetaButtonSpace min_rect;
00194   MetaButtonSpace menu_rect;
00195   MetaButtonSpace shade_rect;
00196   MetaButtonSpace above_rect;
00197   MetaButtonSpace stick_rect;
00198   MetaButtonSpace unshade_rect;
00199   MetaButtonSpace unabove_rect;
00200   MetaButtonSpace unstick_rect;
00201 
00202 #define MAX_MIDDLE_BACKGROUNDS (MAX_BUTTONS_PER_CORNER - 2)
00203   GdkRectangle left_left_background;
00204   GdkRectangle left_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS];
00205   GdkRectangle left_right_background;
00206   GdkRectangle right_left_background;
00207   GdkRectangle right_middle_backgrounds[MAX_MIDDLE_BACKGROUNDS];
00208   GdkRectangle right_right_background;
00209   /* End of button rects (if changed adjust memset hack) */
00210   
00211   /* Round corners */
00212   guint top_left_corner_rounded_radius;
00213   guint top_right_corner_rounded_radius;
00214   guint bottom_left_corner_rounded_radius;
00215   guint bottom_right_corner_rounded_radius;
00216 };
00217 
00218 typedef enum
00219 {
00220   META_IMAGE_FILL_SCALE, /* default, needs to be all-bits-zero for g_new0 */
00221   META_IMAGE_FILL_TILE
00222 } MetaImageFillType;
00223 
00224 typedef enum
00225 {
00226   META_COLOR_SPEC_BASIC,
00227   META_COLOR_SPEC_GTK,
00228   META_COLOR_SPEC_BLEND,
00229   META_COLOR_SPEC_SHADE
00230 } MetaColorSpecType;
00231 
00232 typedef enum
00233 {
00234   META_GTK_COLOR_FG,
00235   META_GTK_COLOR_BG,
00236   META_GTK_COLOR_LIGHT,
00237   META_GTK_COLOR_DARK,
00238   META_GTK_COLOR_MID,
00239   META_GTK_COLOR_TEXT,
00240   META_GTK_COLOR_BASE,
00241   META_GTK_COLOR_TEXT_AA,
00242   META_GTK_COLOR_LAST
00243 } MetaGtkColorComponent;
00244 
00245 struct _MetaColorSpec
00246 {
00247   MetaColorSpecType type;
00248   union
00249   {
00250     struct {
00251       GdkColor color;
00252     } basic;
00253     struct {
00254       MetaGtkColorComponent component;
00255       GtkStateType state;
00256     } gtk;
00257     struct {
00258       MetaColorSpec *foreground;
00259       MetaColorSpec *background;
00260       double alpha;
00261 
00262       GdkColor color;
00263     } blend;
00264     struct {
00265       MetaColorSpec *base;
00266       double factor;
00267 
00268       GdkColor color;
00269     } shade;
00270   } data;
00271 };
00272 
00273 struct _MetaGradientSpec
00274 {
00275   MetaGradientType type;
00276   GSList *color_specs;
00277 };
00278 
00279 struct _MetaAlphaGradientSpec
00280 {
00281   MetaGradientType type;
00282   unsigned char *alphas;
00283   int n_alphas;
00284 };
00285 
00286 struct _MetaDrawInfo
00287 {
00288   GdkPixbuf   *mini_icon;
00289   GdkPixbuf   *icon;
00290   PangoLayout *title_layout;
00291   int title_layout_width;
00292   int title_layout_height;
00293   const MetaFrameGeometry *fgeom;
00294 };
00295 
00299 typedef enum
00300 {
00302   META_DRAW_LINE,
00304   META_DRAW_RECTANGLE,
00306   META_DRAW_ARC,
00307 
00309   META_DRAW_CLIP,
00310   
00311   /* Texture thingies */
00312 
00314   META_DRAW_TINT,
00315   META_DRAW_GRADIENT,
00316   META_DRAW_IMAGE,
00317   
00319   META_DRAW_GTK_ARROW,
00320   META_DRAW_GTK_BOX,
00321   META_DRAW_GTK_VLINE,
00322 
00324   META_DRAW_ICON,
00326   META_DRAW_TITLE,
00328   META_DRAW_OP_LIST,
00330   META_DRAW_TILE
00331 } MetaDrawType;
00332 
00333 typedef enum
00334 {
00335   POS_TOKEN_INT,
00336   POS_TOKEN_DOUBLE,
00337   POS_TOKEN_OPERATOR,
00338   POS_TOKEN_VARIABLE,
00339   POS_TOKEN_OPEN_PAREN,
00340   POS_TOKEN_CLOSE_PAREN
00341 } PosTokenType;
00342 
00343 typedef enum
00344 {
00345   POS_OP_NONE,
00346   POS_OP_ADD,
00347   POS_OP_SUBTRACT,
00348   POS_OP_MULTIPLY,
00349   POS_OP_DIVIDE,
00350   POS_OP_MOD,
00351   POS_OP_MAX,
00352   POS_OP_MIN
00353 } PosOperatorType;
00354 
00360 typedef struct
00361 {
00362   PosTokenType type;
00363 
00364   union
00365   {
00366     struct {
00367       int val;
00368     } i;
00369 
00370     struct {
00371       double val;
00372     } d;
00373 
00374     struct {
00375       PosOperatorType op;
00376     } o;
00377 
00378     struct {
00379       char *name;
00380       GQuark name_quark;
00381     } v;
00382 
00383   } d;
00384 } PosToken;
00385 
00396 typedef struct _MetaDrawSpec
00397 {
00402   int value;
00403   
00405   PosToken *tokens;
00406 
00408   int n_tokens;
00409 
00411   gboolean constant : 1;
00412 } MetaDrawSpec;
00413 
00417 struct _MetaDrawOp
00418 {
00419   MetaDrawType type;
00420 
00421   /* Positions are strings because they can be expressions */
00422   union
00423   {
00424     struct {
00425       MetaColorSpec *color_spec;
00426       int dash_on_length;
00427       int dash_off_length;
00428       int width;
00429       MetaDrawSpec *x1;
00430       MetaDrawSpec *y1;
00431       MetaDrawSpec *x2;
00432       MetaDrawSpec *y2;
00433     } line;
00434 
00435     struct {
00436       MetaColorSpec *color_spec;
00437       gboolean filled;
00438       MetaDrawSpec *x;
00439       MetaDrawSpec *y;
00440       MetaDrawSpec *width;
00441       MetaDrawSpec *height;
00442     } rectangle;
00443 
00444     struct {
00445       MetaColorSpec *color_spec;
00446       gboolean filled;
00447       MetaDrawSpec *x;
00448       MetaDrawSpec *y;
00449       MetaDrawSpec *width;
00450       MetaDrawSpec *height;
00451       double start_angle;
00452       double extent_angle;
00453     } arc;
00454 
00455     struct {
00456       MetaDrawSpec *x;
00457       MetaDrawSpec *y;
00458       MetaDrawSpec *width;
00459       MetaDrawSpec *height;
00460     } clip;
00461     
00462     struct {
00463       MetaColorSpec *color_spec;
00464       MetaAlphaGradientSpec *alpha_spec;
00465       MetaDrawSpec *x;
00466       MetaDrawSpec *y;
00467       MetaDrawSpec *width;
00468       MetaDrawSpec *height;
00469     } tint;
00470 
00471     struct {
00472       MetaGradientSpec *gradient_spec;
00473       MetaAlphaGradientSpec *alpha_spec;
00474       MetaDrawSpec *x;
00475       MetaDrawSpec *y;
00476       MetaDrawSpec *width;
00477       MetaDrawSpec *height;
00478     } gradient;
00479 
00480     struct {
00481       MetaColorSpec *colorize_spec;
00482       MetaAlphaGradientSpec *alpha_spec;
00483       GdkPixbuf *pixbuf;
00484       MetaDrawSpec *x;
00485       MetaDrawSpec *y;
00486       MetaDrawSpec *width;
00487       MetaDrawSpec *height;
00488 
00489       guint32 colorize_cache_pixel;
00490       GdkPixbuf *colorize_cache_pixbuf;
00491       MetaImageFillType fill_type;
00492       unsigned int vertical_stripes : 1;
00493       unsigned int horizontal_stripes : 1;
00494     } image;
00495     
00496     struct {
00497       GtkStateType state;
00498       GtkShadowType shadow;
00499       GtkArrowType arrow;
00500       gboolean filled;
00501 
00502       MetaDrawSpec *x;
00503       MetaDrawSpec *y;
00504       MetaDrawSpec *width;
00505       MetaDrawSpec *height;
00506     } gtk_arrow;
00507 
00508     struct {
00509       GtkStateType state;
00510       GtkShadowType shadow;
00511       MetaDrawSpec *x;
00512       MetaDrawSpec *y;
00513       MetaDrawSpec *width;
00514       MetaDrawSpec *height;
00515     } gtk_box;
00516 
00517     struct {
00518       GtkStateType state;
00519       MetaDrawSpec *x;
00520       MetaDrawSpec *y1;
00521       MetaDrawSpec *y2;  
00522     } gtk_vline;
00523 
00524     struct {
00525       MetaAlphaGradientSpec *alpha_spec;
00526       MetaDrawSpec *x;
00527       MetaDrawSpec *y;
00528       MetaDrawSpec *width;
00529       MetaDrawSpec *height;
00530       MetaImageFillType fill_type;
00531     } icon;
00532 
00533     struct {
00534       MetaColorSpec *color_spec;
00535       MetaDrawSpec *x;
00536       MetaDrawSpec *y;
00537     } title;
00538 
00539     struct {
00540       MetaDrawOpList *op_list;
00541       MetaDrawSpec *x;
00542       MetaDrawSpec *y;
00543       MetaDrawSpec *width;
00544       MetaDrawSpec *height;
00545     } op_list;
00546 
00547     struct {
00548       MetaDrawOpList *op_list;
00549       MetaDrawSpec *x;
00550       MetaDrawSpec *y;
00551       MetaDrawSpec *width;
00552       MetaDrawSpec *height;
00553       MetaDrawSpec *tile_xoffset;
00554       MetaDrawSpec *tile_yoffset;
00555       MetaDrawSpec *tile_width;
00556       MetaDrawSpec *tile_height;
00557     } tile;
00558     
00559   } data;
00560 };
00561 
00570 struct _MetaDrawOpList
00571 {
00572   int refcount;
00573   MetaDrawOp **ops;
00574   int n_ops;
00575   int n_allocated;
00576 };
00577 
00578 typedef enum
00579 {
00580   META_BUTTON_STATE_NORMAL,
00581   META_BUTTON_STATE_PRESSED,
00582   META_BUTTON_STATE_PRELIGHT,
00583   META_BUTTON_STATE_LAST
00584 } MetaButtonState;
00585 
00586 typedef enum
00587 {
00588   /* Ordered so that background is drawn first */
00589   META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND,
00590   META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND,
00591   META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND,
00592   META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND,
00593   META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND,
00594   META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND,
00595   META_BUTTON_TYPE_CLOSE,
00596   META_BUTTON_TYPE_MAXIMIZE,
00597   META_BUTTON_TYPE_MINIMIZE,
00598   META_BUTTON_TYPE_MENU,
00599   META_BUTTON_TYPE_SHADE,
00600   META_BUTTON_TYPE_ABOVE,
00601   META_BUTTON_TYPE_STICK,
00602   META_BUTTON_TYPE_UNSHADE,
00603   META_BUTTON_TYPE_UNABOVE,
00604   META_BUTTON_TYPE_UNSTICK,
00605   META_BUTTON_TYPE_LAST
00606 } MetaButtonType;
00607 
00608 typedef enum
00609 {
00610   META_MENU_ICON_TYPE_CLOSE,
00611   META_MENU_ICON_TYPE_MAXIMIZE,
00612   META_MENU_ICON_TYPE_UNMAXIMIZE,
00613   META_MENU_ICON_TYPE_MINIMIZE,
00614   META_MENU_ICON_TYPE_LAST
00615 } MetaMenuIconType;
00616 
00617 typedef enum
00618 {
00619   /* Listed in the order in which the textures are drawn.
00620    * (though this only matters for overlaps of course.)
00621    * Buttons are drawn after the frame textures.
00622    *
00623    * On the corners, horizontal pieces are arbitrarily given the
00624    * corner area:
00625    *
00626    *   =====                 |====
00627    *   |                     |
00628    *   |       rather than   |
00629    *
00630    */
00631   
00632   /* entire frame */
00633   META_FRAME_PIECE_ENTIRE_BACKGROUND,
00634   /* entire titlebar background */
00635   META_FRAME_PIECE_TITLEBAR,
00636   /* portion of the titlebar background inside the titlebar
00637    * background edges
00638    */
00639   META_FRAME_PIECE_TITLEBAR_MIDDLE,
00640   /* left end of titlebar */
00641   META_FRAME_PIECE_LEFT_TITLEBAR_EDGE,
00642   /* right end of titlebar */
00643   META_FRAME_PIECE_RIGHT_TITLEBAR_EDGE,
00644   /* top edge of titlebar */
00645   META_FRAME_PIECE_TOP_TITLEBAR_EDGE,
00646   /* bottom edge of titlebar */
00647   META_FRAME_PIECE_BOTTOM_TITLEBAR_EDGE,
00648   /* render over title background (text area) */
00649   META_FRAME_PIECE_TITLE,
00650   /* left edge of the frame */
00651   META_FRAME_PIECE_LEFT_EDGE,
00652   /* right edge of the frame */
00653   META_FRAME_PIECE_RIGHT_EDGE,
00654   /* bottom edge of the frame */
00655   META_FRAME_PIECE_BOTTOM_EDGE,
00656   /* place over entire frame, after drawing everything else */
00657   META_FRAME_PIECE_OVERLAY,
00658   /* Used to get size of the enum */
00659   META_FRAME_PIECE_LAST
00660 } MetaFramePiece;
00661 
00662 #define N_GTK_STATES 5
00663 
00669 struct _MetaFrameStyle
00670 {
00672   int refcount;
00677   MetaFrameStyle *parent;
00679   MetaDrawOpList *buttons[META_BUTTON_TYPE_LAST][META_BUTTON_STATE_LAST];
00681   MetaDrawOpList *pieces[META_FRAME_PIECE_LAST];
00686   MetaFrameLayout *layout;
00691   MetaColorSpec *window_background_color;
00695   guint8 window_background_alpha;
00696 };
00697 
00698 /* Kinds of frame...
00699  * 
00700  *  normal ->   noresize / vert only / horz only / both
00701  *              focused / unfocused
00702  *  max    ->   focused / unfocused
00703  *  shaded ->   focused / unfocused
00704  *  max/shaded -> focused / unfocused
00705  *
00706  *  so 4 states with 8 sub-states in one, 2 sub-states in the other 3,
00707  *  meaning 14 total
00708  *
00709  * 14 window states times 7 or 8 window types. Except some
00710  * window types never get a frame so that narrows it down a bit.
00711  * 
00712  */
00713 typedef enum
00714 {
00715   META_FRAME_STATE_NORMAL,
00716   META_FRAME_STATE_MAXIMIZED,
00717   META_FRAME_STATE_SHADED,
00718   META_FRAME_STATE_MAXIMIZED_AND_SHADED,
00719   META_FRAME_STATE_LAST
00720 } MetaFrameState;
00721 
00722 typedef enum
00723 {
00724   META_FRAME_RESIZE_NONE,
00725   META_FRAME_RESIZE_VERTICAL,
00726   META_FRAME_RESIZE_HORIZONTAL,
00727   META_FRAME_RESIZE_BOTH,
00728   META_FRAME_RESIZE_LAST
00729 } MetaFrameResize;
00730 
00731 typedef enum
00732 {
00733   META_FRAME_FOCUS_NO,
00734   META_FRAME_FOCUS_YES,
00735   META_FRAME_FOCUS_LAST
00736 } MetaFrameFocus;
00737 
00749 struct _MetaFrameStyleSet
00750 {
00751   int refcount;
00752   MetaFrameStyleSet *parent;
00753   MetaFrameStyle *normal_styles[META_FRAME_RESIZE_LAST][META_FRAME_FOCUS_LAST];
00754   MetaFrameStyle *maximized_styles[META_FRAME_FOCUS_LAST];
00755   MetaFrameStyle *shaded_styles[META_FRAME_RESIZE_LAST][META_FRAME_FOCUS_LAST];
00756   MetaFrameStyle *maximized_and_shaded_styles[META_FRAME_FOCUS_LAST];
00757 };
00758 
00765 struct _MetaTheme
00766 {
00768   char *name;
00770   char *dirname;
00775   char *filename;
00777   char *readable_name;
00779   char *author;
00781   char *copyright;
00783   char *date;
00785   char *description;
00790   guint format_version;
00791 
00793   GHashTable *integer_constants;
00795   GHashTable *float_constants;
00800   GHashTable *color_constants;
00801   GHashTable *images_by_filename;
00802   GHashTable *layouts_by_name;
00803   GHashTable *draw_op_lists_by_name;
00804   GHashTable *styles_by_name;
00805   GHashTable *style_sets_by_name;
00806   MetaFrameStyleSet *style_sets_by_type[META_FRAME_TYPE_LAST];
00807 
00808   GdkPixbuf *fallback_icon, *fallback_mini_icon;
00809 
00810   GQuark quark_width;
00811   GQuark quark_height;
00812   GQuark quark_object_width;
00813   GQuark quark_object_height;
00814   GQuark quark_left_width;
00815   GQuark quark_right_width;
00816   GQuark quark_top_height;
00817   GQuark quark_bottom_height;
00818   GQuark quark_mini_icon_width;
00819   GQuark quark_mini_icon_height;
00820   GQuark quark_icon_width;
00821   GQuark quark_icon_height;
00822   GQuark quark_title_width;
00823   GQuark quark_title_height;
00824 };
00825 
00826 struct _MetaPositionExprEnv
00827 {
00828   MetaRectangle rect;
00829   /* size of an object being drawn, if it has a natural size */
00830   int object_width;
00831   int object_height;
00832   /* global object sizes, always available */
00833   int left_width;
00834   int right_width;
00835   int top_height;
00836   int bottom_height;
00837   int title_width;
00838   int title_height;
00839   int mini_icon_width;
00840   int mini_icon_height;
00841   int icon_width;
00842   int icon_height;
00843   /* Theme so we can look up constants */
00844   MetaTheme *theme;
00845 };
00846 
00847 MetaFrameLayout* meta_frame_layout_new           (void);
00848 MetaFrameLayout* meta_frame_layout_copy          (const MetaFrameLayout *src);
00849 void             meta_frame_layout_ref           (MetaFrameLayout       *layout);
00850 void             meta_frame_layout_unref         (MetaFrameLayout       *layout);
00851 void             meta_frame_layout_get_borders   (const MetaFrameLayout *layout,
00852                                                   int                    text_height,
00853                                                   MetaFrameFlags         flags,
00854                                                   int                   *top_height,
00855                                                   int                   *bottom_height,
00856                                                   int                   *left_width,
00857                                                   int                   *right_width);
00858 void             meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
00859                                                   int                     text_height,
00860                                                   MetaFrameFlags          flags,
00861                                                   int                     client_width,
00862                                                   int                     client_height,
00863                                                   const MetaButtonLayout *button_layout,
00864                                                   MetaFrameGeometry      *fgeom,
00865                                                   MetaTheme              *theme);
00866 
00867 gboolean         meta_frame_layout_validate      (const MetaFrameLayout *layout,
00868                                                   GError               **error);
00869 
00870 gboolean meta_parse_position_expression (MetaDrawSpec               *spec,
00871                                          const MetaPositionExprEnv  *env,
00872                                          int                        *x_return,
00873                                          int                        *y_return,
00874                                          GError                    **err);
00875 gboolean meta_parse_size_expression     (MetaDrawSpec               *spec,
00876                                          const MetaPositionExprEnv  *env,
00877                                          int                        *val_return,
00878                                          GError                    **err);
00879 
00880 MetaDrawSpec* meta_draw_spec_new (MetaTheme  *theme,
00881                                   const char *expr,
00882                                   GError    **error);
00883 void          meta_draw_spec_free (MetaDrawSpec *spec);
00884 
00885 MetaColorSpec* meta_color_spec_new             (MetaColorSpecType  type);
00886 MetaColorSpec* meta_color_spec_new_from_string (const char        *str,
00887                                                 GError           **err);
00888 MetaColorSpec* meta_color_spec_new_gtk         (MetaGtkColorComponent component,
00889                                                 GtkStateType          state);
00890 void           meta_color_spec_free            (MetaColorSpec     *spec);
00891 void           meta_color_spec_render          (MetaColorSpec     *spec,
00892                                                 GtkWidget         *widget,
00893                                                 GdkColor          *color);
00894 
00895 
00896 MetaDrawOp*    meta_draw_op_new  (MetaDrawType        type);
00897 void           meta_draw_op_free (MetaDrawOp          *op);
00898 void           meta_draw_op_draw (const MetaDrawOp    *op,
00899                                   GtkWidget           *widget,
00900                                   GdkDrawable         *drawable,
00901                                   const GdkRectangle  *clip,
00902                                   const MetaDrawInfo  *info,
00903                                   /* logical region being drawn */
00904                                   MetaRectangle        logical_region);
00905 
00906 MetaDrawOpList* meta_draw_op_list_new   (int                   n_preallocs);
00907 void            meta_draw_op_list_ref   (MetaDrawOpList       *op_list);
00908 void            meta_draw_op_list_unref (MetaDrawOpList       *op_list);
00909 void            meta_draw_op_list_draw  (const MetaDrawOpList *op_list,
00910                                          GtkWidget            *widget,
00911                                          GdkDrawable          *drawable,
00912                                          const GdkRectangle   *clip,
00913                                          const MetaDrawInfo   *info,
00914                                          MetaRectangle         rect);
00915 void           meta_draw_op_list_append (MetaDrawOpList       *op_list,
00916                                          MetaDrawOp           *op);
00917 gboolean       meta_draw_op_list_validate (MetaDrawOpList    *op_list,
00918                                            GError           **error);
00919 gboolean       meta_draw_op_list_contains (MetaDrawOpList    *op_list,
00920                                            MetaDrawOpList    *child);
00921 
00922 MetaGradientSpec* meta_gradient_spec_new    (MetaGradientType        type);
00923 void              meta_gradient_spec_free   (MetaGradientSpec       *desc);
00924 GdkPixbuf*        meta_gradient_spec_render (const MetaGradientSpec *desc,
00925                                              GtkWidget              *widget,
00926                                              int                     width,
00927                                              int                     height);
00928 gboolean          meta_gradient_spec_validate (MetaGradientSpec     *spec,
00929                                                GError              **error);
00930 
00931 MetaAlphaGradientSpec* meta_alpha_gradient_spec_new  (MetaGradientType       type,
00932                                                       int                    n_alphas);
00933 void                   meta_alpha_gradient_spec_free (MetaAlphaGradientSpec *spec);
00934 
00935 
00936 MetaFrameStyle* meta_frame_style_new   (MetaFrameStyle *parent);
00937 void            meta_frame_style_ref   (MetaFrameStyle *style);
00938 void            meta_frame_style_unref (MetaFrameStyle *style);
00939 
00940 void meta_frame_style_draw (MetaFrameStyle          *style,
00941                             GtkWidget               *widget,
00942                             GdkDrawable             *drawable,
00943                             int                      x_offset,
00944                             int                      y_offset,
00945                             const GdkRectangle      *clip,
00946                             const MetaFrameGeometry *fgeom,
00947                             int                      client_width,
00948                             int                      client_height,
00949                             PangoLayout             *title_layout,
00950                             int                      text_height,
00951                             MetaButtonState          button_states[META_BUTTON_TYPE_LAST],
00952                             GdkPixbuf               *mini_icon,
00953                             GdkPixbuf               *icon);
00954 
00955 
00956 gboolean       meta_frame_style_validate (MetaFrameStyle    *style,
00957                                           guint              current_theme_version,
00958                                           GError           **error);
00959 
00960 MetaFrameStyleSet* meta_frame_style_set_new   (MetaFrameStyleSet *parent);
00961 void               meta_frame_style_set_ref   (MetaFrameStyleSet *style_set);
00962 void               meta_frame_style_set_unref (MetaFrameStyleSet *style_set);
00963 
00964 gboolean       meta_frame_style_set_validate  (MetaFrameStyleSet *style_set,
00965                                                GError           **error);
00966 
00967 MetaTheme* meta_theme_get_current (void);
00968 void       meta_theme_set_current (const char *name,
00969                                    gboolean    force_reload);
00970 
00971 MetaTheme* meta_theme_new      (void);
00972 void       meta_theme_free     (MetaTheme *theme);
00973 gboolean   meta_theme_validate (MetaTheme *theme,
00974                                 GError   **error);
00975 GdkPixbuf* meta_theme_load_image (MetaTheme  *theme,
00976                                   const char *filename,
00977                                   guint       size_of_theme_icons,
00978                                   GError    **error);
00979 
00980 MetaFrameStyle* meta_theme_get_frame_style (MetaTheme     *theme,
00981                                             MetaFrameType  type,
00982                                             MetaFrameFlags flags);
00983 
00984 double meta_theme_get_title_scale (MetaTheme     *theme,
00985                                    MetaFrameType  type,
00986                                    MetaFrameFlags flags);
00987 
00988 void meta_theme_draw_frame (MetaTheme              *theme,
00989                             GtkWidget              *widget,
00990                             GdkDrawable            *drawable,
00991                             const GdkRectangle     *clip,
00992                             int                     x_offset,
00993                             int                     y_offset,
00994                             MetaFrameType           type,
00995                             MetaFrameFlags          flags,
00996                             int                     client_width,
00997                             int                     client_height,
00998                             PangoLayout            *title_layout,
00999                             int                     text_height,
01000                             const MetaButtonLayout *button_layout,
01001                             MetaButtonState         button_states[META_BUTTON_TYPE_LAST],
01002                             GdkPixbuf              *mini_icon,
01003                             GdkPixbuf              *icon);
01004 
01005 void meta_theme_get_frame_borders (MetaTheme         *theme,
01006                                    MetaFrameType      type,
01007                                    int                text_height,
01008                                    MetaFrameFlags     flags,
01009                                    int               *top_height,
01010                                    int               *bottom_height,
01011                                    int               *left_width,
01012                                    int               *right_width);
01013 void meta_theme_calc_geometry (MetaTheme              *theme,
01014                                MetaFrameType           type,
01015                                int                     text_height,
01016                                MetaFrameFlags          flags,
01017                                int                     client_width,
01018                                int                     client_height,
01019                                const MetaButtonLayout *button_layout,
01020                                MetaFrameGeometry      *fgeom);
01021                                    
01022 MetaFrameLayout*   meta_theme_lookup_layout       (MetaTheme         *theme,
01023                                                    const char        *name);
01024 void               meta_theme_insert_layout       (MetaTheme         *theme,
01025                                                    const char        *name,
01026                                                    MetaFrameLayout   *layout);
01027 MetaDrawOpList*    meta_theme_lookup_draw_op_list (MetaTheme         *theme,
01028                                                    const char        *name);
01029 void               meta_theme_insert_draw_op_list (MetaTheme         *theme,
01030                                                    const char        *name,
01031                                                    MetaDrawOpList    *op_list);
01032 MetaFrameStyle*    meta_theme_lookup_style        (MetaTheme         *theme,
01033                                                    const char        *name);
01034 void               meta_theme_insert_style        (MetaTheme         *theme,
01035                                                    const char        *name,
01036                                                    MetaFrameStyle    *style);
01037 MetaFrameStyleSet* meta_theme_lookup_style_set    (MetaTheme         *theme,
01038                                                    const char        *name);
01039 void               meta_theme_insert_style_set    (MetaTheme         *theme,
01040                                                    const char        *name,
01041                                                    MetaFrameStyleSet *style_set);
01042 gboolean meta_theme_define_int_constant   (MetaTheme   *theme,
01043                                            const char  *name,
01044                                            int          value,
01045                                            GError     **error);
01046 gboolean meta_theme_lookup_int_constant   (MetaTheme   *theme,
01047                                            const char  *name,
01048                                            int         *value);
01049 gboolean meta_theme_define_float_constant (MetaTheme   *theme,
01050                                            const char  *name,
01051                                            double       value,
01052                                            GError     **error);
01053 gboolean meta_theme_lookup_float_constant (MetaTheme   *theme,
01054                                            const char  *name,
01055                                            double      *value);
01056 
01057 gboolean meta_theme_define_color_constant (MetaTheme   *theme,
01058                                            const char  *name,
01059                                            const char  *value,
01060                                            GError     **error);
01061 gboolean meta_theme_lookup_color_constant (MetaTheme   *theme,
01062                                            const char  *name,
01063                                            char       **value);
01064 
01065 gboolean     meta_theme_replace_constants     (MetaTheme    *theme,
01066                                                PosToken     *tokens,
01067                                                int           n_tokens,
01068                                                GError      **err);
01069 
01070 /* random stuff */
01071 
01072 PangoFontDescription* meta_gtk_widget_get_font_desc        (GtkWidget            *widget,
01073                                                             double                scale,
01074                                                             const PangoFontDescription *override);
01075 int                   meta_pango_font_desc_get_text_height (const PangoFontDescription *font_desc,
01076                                                             PangoContext         *context);
01077 
01078 
01079 /* Enum converters */
01080 MetaGtkColorComponent meta_color_component_from_string (const char            *str);
01081 const char*           meta_color_component_to_string   (MetaGtkColorComponent  component);
01082 MetaButtonState       meta_button_state_from_string    (const char            *str);
01083 const char*           meta_button_state_to_string      (MetaButtonState        state);
01084 MetaButtonType        meta_button_type_from_string     (const char            *str,
01085                                                         MetaTheme             *theme);
01086 const char*           meta_button_type_to_string       (MetaButtonType         type);
01087 MetaFramePiece        meta_frame_piece_from_string     (const char            *str);
01088 const char*           meta_frame_piece_to_string       (MetaFramePiece         piece);
01089 MetaFrameState        meta_frame_state_from_string     (const char            *str);
01090 const char*           meta_frame_state_to_string       (MetaFrameState         state);
01091 MetaFrameResize       meta_frame_resize_from_string    (const char            *str);
01092 const char*           meta_frame_resize_to_string      (MetaFrameResize        resize);
01093 MetaFrameFocus        meta_frame_focus_from_string     (const char            *str);
01094 const char*           meta_frame_focus_to_string       (MetaFrameFocus         focus);
01095 MetaFrameType         meta_frame_type_from_string      (const char            *str);
01096 const char*           meta_frame_type_to_string        (MetaFrameType          type);
01097 MetaGradientType      meta_gradient_type_from_string   (const char            *str);
01098 const char*           meta_gradient_type_to_string     (MetaGradientType       type);
01099 GtkStateType          meta_gtk_state_from_string       (const char            *str);
01100 const char*           meta_gtk_state_to_string         (GtkStateType           state);
01101 GtkShadowType         meta_gtk_shadow_from_string      (const char            *str);
01102 const char*           meta_gtk_shadow_to_string        (GtkShadowType          shadow);
01103 GtkArrowType          meta_gtk_arrow_from_string       (const char            *str);
01104 const char*           meta_gtk_arrow_to_string         (GtkArrowType           arrow);
01105 MetaImageFillType     meta_image_fill_type_from_string (const char            *str);
01106 const char*           meta_image_fill_type_to_string   (MetaImageFillType      fill_type);
01107 
01108 guint meta_theme_earliest_version_with_button (MetaButtonType type);
01109 
01110 
01111 #define META_THEME_ALLOWS(theme, feature) (theme->format_version >= feature)
01112 
01113 /* What version of the theme file format were various features introduced in? */
01114 #define META_THEME_SHADE_STICK_ABOVE_BUTTONS 2
01115 #define META_THEME_UBIQUITOUS_CONSTANTS 2
01116 #define META_THEME_VARIED_ROUND_CORNERS 2
01117 #define META_THEME_IMAGES_FROM_ICON_THEMES 2
01118 #define META_THEME_UNRESIZABLE_SHADED_STYLES 2
01119 #define META_THEME_DEGREES_IN_ARCS 2
01120 #define META_THEME_HIDDEN_BUTTONS 2
01121 #define META_THEME_COLOR_CONSTANTS 2
01122 #define META_THEME_FRAME_BACKGROUNDS 2
01123 
01124 #endif

Generated on Sat Aug 23 22:04:19 2008 for metacity by  doxygen 1.5.5