1 #ifndef _MYSTYLE_ 2 #define _MYSTYLE_ 3 4 #include "../libAfterImage/afterimage.h" 5 #include "font.h" 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 /*********************************************************************** 12 * 13 * afterstep style include file 14 * 15 ***********************************************************************/ 16 17 struct ScreenInfo; 18 struct ASImage; 19 struct ASGradient; 20 21 #include "myicon.h" 22 23 /* 24 * see comment to style_config in mystyle.c before changing this structure 25 * 26 * text_type 0: normal text 27 * text_type 1: 3d effect #1 28 * text_type 2: 3d effect #2 29 */ 30 31 typedef struct MyStyle 32 { 33 unsigned long magic; 34 35 ASHashTable *owner; 36 37 ASFlagType set_flags; /* == (user_flags | inherit_flags) */ 38 ASFlagType user_flags; /* options the user set */ 39 ASFlagType inherit_flags; /* inherited options */ 40 41 ASFlagType flags; /* options that consist of flags only */ 42 char *name; 43 int text_style; 44 MyFont font; 45 ColorPair colors; 46 ColorPair relief; 47 int texture_type; 48 icon_t back_icon; /* background pixmap */ 49 ASGradient gradient; /* background gradient */ 50 ARGB32 tint; 51 int slice_x_start, slice_x_end, slice_y_start, slice_y_end; 52 int blur_x, blur_y; 53 54 struct MyStyle *overlay; 55 int overlay_type; 56 57 }MyStyle; 58 59 /* 60 * values < 16 are sequential control codes 61 * values >= 16 are bit flags 62 */ 63 enum /* MyStyle options */ 64 { 65 F_ERROR = 0, /* error condition */ 66 F_DONE = 1, /* done parsing body */ 67 F_INHERIT = 2, /* inherit from another style */ 68 F_FONT = (1 << 4), 69 F_FORECOLOR = (1 << 5), 70 F_BACKCOLOR = (1 << 6), 71 F_SLICE = (1 << 7), 72 F_BACKGRADIENT = (1 << 8), 73 F_BACKPIXMAP = (1 << 9), 74 F_TEXTSTYLE = (1 << 10), 75 F_DRAWTEXTBACKGROUND = (1 << 11), 76 F_BACKMULTIGRADIENT = (1 << 12), 77 F_BACKTRANSPIXMAP = (1 << 13), /* should never be set unless F_BACKPIXMAP is set!! */ 78 F_EXTERNAL_BACKPIX = (1 << 14), /* indicates that pixmap has been created by some other application and should not be freed */ 79 F_EXTERNAL_BACKMASK = (1 << 15), 80 F_TRANSPARENT = (1 << 16), /* if set MyStyle is transparent, and everything that is drawn with it, 81 * must be updated on background changes */ 82 83 F_OVERLAY = (1 << 17), 84 F_BLUR = (1 << 18) 85 }; 86 87 #define TransparentMS(style) (get_flags((style)->set_flags, F_TRANSPARENT)) 88 89 90 enum /* texture types */ 91 { 92 TEXTURE_SOLID = 0, 93 94 TEXTURE_GRADIENT_START, 95 TEXTURE_GRADIENT = TEXTURE_GRADIENT_START, 96 TEXTURE_HGRADIENT, 97 TEXTURE_HCGRADIENT, 98 TEXTURE_VGRADIENT, 99 TEXTURE_VCGRADIENT, 100 TEXTURE_OLD_GRADIENT_END = TEXTURE_VCGRADIENT, 101 TEXTURE_GRADIENT_TL2BR, /* 6 */ 102 TEXTURE_GRADIENT_BL2TR, 103 TEXTURE_GRADIENT_T2B, 104 TEXTURE_GRADIENT_L2R, /* 9 */ 105 TEXTURE_GRADIENT_END = TEXTURE_GRADIENT_L2R, 106 107 TEXTURE_TEXTURED_START = 125, 108 TEXTURE_SHAPED_SCALED_PIXMAP = TEXTURE_TEXTURED_START, 109 TEXTURE_SHAPED_PIXMAP, 110 TEXTURE_SCALED_PIXMAP = 127, 111 TEXTURE_PIXMAP, 112 TEXTURE_TRANSPARENT = 129, /* tninted really */ 113 TEXTURE_TRANSPIXMAP = 130, /* 130-145 represent different 114 blending methods from libAfterImage */ 115 TEXTURE_TRANSPIXMAP_ALLANON = TEXTURE_TRANSPIXMAP, 116 TEXTURE_TRANSPIXMAP_ALPHA, 117 TEXTURE_TRANSPIXMAP_TINT, 118 TEXTURE_TRANSPIXMAP_ADD, 119 TEXTURE_TRANSPIXMAP_SUB, 120 TEXTURE_TRANSPIXMAP_DIFF, 121 TEXTURE_TRANSPIXMAP_DARKEN, 122 TEXTURE_TRANSPIXMAP_LIGHTEN, 123 TEXTURE_TRANSPIXMAP_SCREEN, 124 TEXTURE_TRANSPIXMAP_OVERLAY, 125 TEXTURE_TRANSPIXMAP_HUE, 126 TEXTURE_TRANSPIXMAP_SATURATE, 127 TEXTURE_TRANSPIXMAP_VALUE, 128 TEXTURE_TRANSPIXMAP_COLORIZE, 129 TEXTURE_TRANSPIXMAP_DISSIPATE, 130 131 TEXTURE_TRANSPIXMAP_END = 148, 132 133 TEXTURE_TRANSPARENT_TWOWAY = 149, /* tinted both ways - lightened or darkened */ 134 135 TEXTURE_SCALED_TRANSPIXMAP = 150, 136 TEXTURE_SCALED_TPM_ALLANON = TEXTURE_SCALED_TRANSPIXMAP, 137 TEXTURE_SCALED_TPM_ALPHA, 138 TEXTURE_SCALED_TPM_TINT, 139 TEXTURE_SCALED_TPM_ADD, 140 TEXTURE_SCALED_TPM_SUB, 141 TEXTURE_SCALED_TPM_DIFF, 142 TEXTURE_SCALED_TPM_DARKEN, 143 TEXTURE_SCALED_TPM_LIGHTEN, 144 TEXTURE_SCALED_TPM_SCREEN, 145 TEXTURE_SCALED_TPM_OVERLAY, 146 TEXTURE_SCALED_TPM_HUE, 147 TEXTURE_SCALED_TPM_SATURATE, 148 TEXTURE_SCALED_TPM_VALUE, 149 TEXTURE_SCALED_TPM_COLORIZE, 150 TEXTURE_SCALED_TPM_DISSIPATE, 151 TEXTURE_SCALED_TRANSPIXMAP_END = 168, 152 TEXTURE_TEXTURED_END = TEXTURE_SCALED_TRANSPIXMAP_END, 153 154 TEXTURE_BUILTIN = 255 155 }; 156 157 158 ARGB32 GetShadow (ARGB32); 159 ARGB32 GetHilite (ARGB32); 160 ARGB32 GetAverage (ARGB32 foreground, ARGB32 background); 161 162 /* serice functions */ 163 GC CreateTintGC (Drawable d, unsigned long tintColor, int function); 164 165 /* just a nice error printing function */ 166 void mystyle_error (char *format, char *name, char *text2); 167 168 merge_scanlines_func mystyle_translate_texture_type( int texture_type ); 169 170 int mystyle_translate_grad_type( int type ); 171 ASImage *mystyle_draw_text_image( MyStyle *style, const char *text, unsigned long encoding ); 172 unsigned int mystyle_get_font_height( MyStyle *style ); 173 void mystyle_get_text_size (MyStyle * style, const char *text, unsigned int *width, unsigned int *height ); 174 175 void mystyle_list_fix_styles (ASHashTable *list); 176 void mystyle_fix_styles (void); 177 178 179 ASImage *mystyle_make_image( MyStyle * style, int root_x, int root_y, int width, int height, int flip ); 180 ASImage *mystyle_crop_image(MyStyle * style, int root_x, int root_y, int crop_x, int crop_y, int width, int height, int scale_width, int scale_height, int flip ); 181 182 183 MyStyle *mystyle_list_new (struct ASHashTable *list, char *name); 184 MyStyle *mystyle_new_with_name (char *name); 185 186 void mystyle_list_destroy_all( ASHashTable **plist ); 187 void mystyle_destroy_all(); 188 189 void mystyle_merge_font( MyStyle *style, MyFont *font, Bool override); 190 void mystyle_merge_styles (MyStyle * parent, MyStyle * child, Bool override, Bool copy); 191 192 MyStyle *mystyle_list_find (struct ASHashTable *list, const char *name); 193 MyStyle *mystyle_list_find_or_default (struct ASHashTable *list, const char *name); 194 195 MyStyle *mystyle_find (const char *name); 196 MyStyle *mystyle_find_or_default (const char *name); 197 198 void mystyle_free_back_icon( MyStyle *style ); 199 200 201 void mystyle_parse_set_style (char *text, FILE * fd, char **style, int *junk2); 202 int mystyle_parse_old_gradient (int type, ARGB32 c1, ARGB32 c2, ASGradient *gradient); 203 void mystyle_inherit_font (MyStyle * style, struct MyFont * font); 204 void mystyle_merge_colors (MyStyle * style, int type, char *fore, char *back, char *gradient, char *pixmap); 205 206 void set_func_arg (char *text, FILE * fd, char **value, int *junk); 207 ASImageBevel *mystyle_make_bevel (MyStyle *style, ASImageBevel *bevel, int hilite, Bool reverse); 208 209 struct ASImage *grab_root_asimage( struct ScreenInfo *scr, Window target, Bool screenshot ); 210 211 extern MyStyle *mystyle_first; 212 213 #ifdef __cplusplus 214 } 215 #endif 216 217 218 #endif /* _MYSTYLE_ */ 219