File indexing completed on 2025-01-17 09:56:12
0001
0002
0003
0004
0005
0006
0007 #ifndef _TTKTHEME
0008 #define _TTKTHEME
0009
0010 #ifdef __cplusplus
0011 extern "C" {
0012 #endif
0013
0014 #ifndef MODULE_SCOPE
0015 # ifdef __cplusplus
0016 # define MODULE_SCOPE extern "C"
0017 # else
0018 # define MODULE_SCOPE extern
0019 # endif
0020 #endif
0021
0022 #define TTKAPI MODULE_SCOPE
0023
0024
0025 #define TTK_VERSION TK_VERSION
0026 #define TTK_PATCH_LEVEL TK_PATCH_LEVEL
0027
0028
0029
0030
0031 #define DEFAULT_FONT "TkDefaultFont"
0032 #ifdef MAC_OSX_TK
0033 #define DEFAULT_BACKGROUND "systemTextBackgroundColor"
0034 #define DEFAULT_FOREGROUND "systemTextColor"
0035 #else
0036 #define DEFAULT_BACKGROUND "#d9d9d9"
0037 #define DEFAULT_FOREGROUND "black"
0038 #endif
0039
0040
0041
0042
0043
0044 typedef unsigned int Ttk_State;
0045
0046 #define TTK_STATE_ACTIVE (1<<0)
0047 #define TTK_STATE_DISABLED (1<<1)
0048 #define TTK_STATE_FOCUS (1<<2)
0049 #define TTK_STATE_PRESSED (1<<3)
0050 #define TTK_STATE_SELECTED (1<<4)
0051 #define TTK_STATE_BACKGROUND (1<<5)
0052 #define TTK_STATE_ALTERNATE (1<<6)
0053 #define TTK_STATE_INVALID (1<<7)
0054 #define TTK_STATE_READONLY (1<<8)
0055 #define TTK_STATE_HOVER (1<<9)
0056 #define TTK_STATE_USER6 (1<<10)
0057 #define TTK_STATE_USER5 (1<<11)
0058 #define TTK_STATE_USER4 (1<<12)
0059 #define TTK_STATE_USER3 (1<<13)
0060 #define TTK_STATE_USER2 (1<<14)
0061 #define TTK_STATE_USER1 (1<<15)
0062
0063
0064
0065
0066 typedef struct
0067 {
0068 unsigned int onbits;
0069 unsigned int offbits;
0070 } Ttk_StateSpec;
0071
0072 #define Ttk_StateMatches(state, spec) \
0073 (((state) & ((spec)->onbits|(spec)->offbits)) == (spec)->onbits)
0074
0075 #define Ttk_ModifyState(state, spec) \
0076 (((state) & ~(spec)->offbits) | (spec)->onbits)
0077
0078 TTKAPI int Ttk_GetStateSpecFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_StateSpec *);
0079 TTKAPI Tcl_Obj *Ttk_NewStateSpecObj(unsigned int onbits,unsigned int offbits);
0080
0081
0082
0083
0084 typedef Tcl_Obj *Ttk_StateMap;
0085
0086 TTKAPI Ttk_StateMap Ttk_GetStateMapFromObj(Tcl_Interp *, Tcl_Obj *);
0087 TTKAPI Tcl_Obj *Ttk_StateMapLookup(Tcl_Interp*, Ttk_StateMap, Ttk_State);
0088
0089
0090
0091
0092 typedef struct
0093 {
0094 int index;
0095 unsigned int onBits;
0096 unsigned int offBits;
0097 } Ttk_StateTable;
0098
0099 TTKAPI int Ttk_StateTableLookup(Ttk_StateTable map[], Ttk_State);
0100
0101
0102
0103
0104
0105 typedef struct
0106 {
0107 short left;
0108 short top;
0109 short right;
0110 short bottom;
0111 } Ttk_Padding;
0112
0113 TTKAPI int Ttk_GetPaddingFromObj(Tcl_Interp*,Tk_Window,Tcl_Obj*,Ttk_Padding*);
0114 TTKAPI int Ttk_GetBorderFromObj(Tcl_Interp*,Tcl_Obj*,Ttk_Padding*);
0115
0116 TTKAPI Ttk_Padding Ttk_MakePadding(short l, short t, short r, short b);
0117 TTKAPI Ttk_Padding Ttk_UniformPadding(short borderWidth);
0118 TTKAPI Ttk_Padding Ttk_AddPadding(Ttk_Padding, Ttk_Padding);
0119 TTKAPI Ttk_Padding Ttk_RelievePadding(Ttk_Padding, int relief, int n);
0120
0121 #define Ttk_PaddingWidth(p) ((p).left + (p).right)
0122 #define Ttk_PaddingHeight(p) ((p).top + (p).bottom)
0123
0124 #define Ttk_SetMargins(tkwin, pad) \
0125 Tk_SetInternalBorderEx(tkwin, pad.left, pad.right, pad.top, pad.bottom)
0126
0127
0128
0129
0130
0131 typedef struct
0132 {
0133 int x;
0134 int y;
0135 int width;
0136 int height;
0137 } Ttk_Box;
0138
0139 TTKAPI Ttk_Box Ttk_MakeBox(int x, int y, int width, int height);
0140 TTKAPI int Ttk_BoxContains(Ttk_Box, int x, int y);
0141
0142 #define Ttk_WinBox(tkwin) Ttk_MakeBox(0,0,Tk_Width(tkwin),Tk_Height(tkwin))
0143
0144
0145
0146
0147 typedef enum {
0148 TTK_SIDE_LEFT, TTK_SIDE_TOP, TTK_SIDE_RIGHT, TTK_SIDE_BOTTOM
0149 } Ttk_Side;
0150
0151 typedef unsigned int Ttk_Sticky;
0152
0153
0154
0155
0156 #define TTK_STICK_W (0x1)
0157 #define TTK_STICK_E (0x2)
0158 #define TTK_STICK_N (0x4)
0159 #define TTK_STICK_S (0x8)
0160
0161
0162
0163
0164 #define TTK_FILL_X (0x3)
0165 #define TTK_FILL_Y (0xC)
0166 #define TTK_FILL_BOTH (0xF)
0167
0168 TTKAPI int Ttk_GetStickyFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_Sticky *);
0169 TTKAPI Tcl_Obj *Ttk_NewStickyObj(Ttk_Sticky);
0170
0171
0172
0173
0174
0175 typedef unsigned int Ttk_PositionSpec;
0176
0177 #define TTK_PACK_LEFT (0x10)
0178 #define TTK_PACK_RIGHT (0x20)
0179 #define TTK_PACK_TOP (0x40)
0180 #define TTK_PACK_BOTTOM (0x80)
0181 #define TTK_EXPAND (0x100)
0182 #define TTK_BORDER (0x200)
0183 #define TTK_UNIT (0x400)
0184
0185
0186
0187
0188 #define _TTK_CHILDREN (0x1000)
0189 #define _TTK_LAYOUT_END (0x2000)
0190 #define _TTK_LAYOUT (0x4000)
0191
0192 #define _TTK_MASK_STICK (0x0F)
0193 #define _TTK_MASK_PACK (0xF0)
0194
0195 TTKAPI Ttk_Box Ttk_PackBox(Ttk_Box *cavity, int w, int h, Ttk_Side side);
0196 TTKAPI Ttk_Box Ttk_StickBox(Ttk_Box parcel, int w, int h, Ttk_Sticky sticky);
0197 TTKAPI Ttk_Box Ttk_AnchorBox(Ttk_Box parcel, int w, int h, Tk_Anchor anchor);
0198 TTKAPI Ttk_Box Ttk_PadBox(Ttk_Box b, Ttk_Padding p);
0199 TTKAPI Ttk_Box Ttk_ExpandBox(Ttk_Box b, Ttk_Padding p);
0200 TTKAPI Ttk_Box Ttk_PlaceBox(Ttk_Box *cavity, int w,int h, Ttk_Side,Ttk_Sticky);
0201 TTKAPI Ttk_Box Ttk_PositionBox(Ttk_Box *cavity, int w, int h, Ttk_PositionSpec);
0202
0203
0204
0205
0206 MODULE_SCOPE void Ttk_StylePkgInit(Tcl_Interp *);
0207
0208 typedef struct Ttk_Theme_ *Ttk_Theme;
0209 typedef struct Ttk_ElementClass_ Ttk_ElementClass;
0210 typedef struct Ttk_Layout_ *Ttk_Layout;
0211 typedef struct Ttk_LayoutNode_ *Ttk_Element;
0212 typedef struct Ttk_Style_ *Ttk_Style;
0213
0214 TTKAPI Ttk_Theme Ttk_GetTheme(Tcl_Interp *interp, const char *name);
0215 TTKAPI Ttk_Theme Ttk_GetDefaultTheme(Tcl_Interp *interp);
0216 TTKAPI Ttk_Theme Ttk_GetCurrentTheme(Tcl_Interp *interp);
0217
0218 TTKAPI Ttk_Theme Ttk_CreateTheme(
0219 Tcl_Interp *interp, const char *name, Ttk_Theme parent);
0220
0221 typedef int (Ttk_ThemeEnabledProc)(Ttk_Theme theme, void *clientData);
0222 MODULE_SCOPE void Ttk_SetThemeEnabledProc(Ttk_Theme, Ttk_ThemeEnabledProc, void *);
0223
0224 MODULE_SCOPE int Ttk_UseTheme(Tcl_Interp *, Ttk_Theme);
0225
0226 typedef void (Ttk_CleanupProc)(void *clientData);
0227 TTKAPI void Ttk_RegisterCleanup(
0228 Tcl_Interp *interp, void *deleteData, Ttk_CleanupProc *cleanupProc);
0229
0230
0231
0232
0233
0234 enum TTKStyleVersion2 { TK_STYLE_VERSION_2 = 2 };
0235
0236 typedef void (Ttk_ElementSizeProc)(void *clientData, void *elementRecord,
0237 Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding*);
0238 typedef void (Ttk_ElementDrawProc)(void *clientData, void *elementRecord,
0239 Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state);
0240
0241 typedef struct Ttk_ElementOptionSpec
0242 {
0243 const char *optionName;
0244 Tk_OptionType type;
0245 int offset;
0246 const char *defaultValue;
0247 } Ttk_ElementOptionSpec;
0248
0249 #define TK_OPTION_ANY TK_OPTION_STRING
0250
0251 typedef struct Ttk_ElementSpec {
0252 enum TTKStyleVersion2 version;
0253 size_t elementSize;
0254 Ttk_ElementOptionSpec *options;
0255 Ttk_ElementSizeProc *size;
0256 Ttk_ElementDrawProc *draw;
0257 } Ttk_ElementSpec;
0258
0259 TTKAPI Ttk_ElementClass *Ttk_RegisterElement(
0260 Tcl_Interp *interp, Ttk_Theme theme, const char *elementName,
0261 Ttk_ElementSpec *, void *clientData);
0262
0263 typedef int (*Ttk_ElementFactory)
0264 (Tcl_Interp *, void *clientData,
0265 Ttk_Theme, const char *elementName, int objc, Tcl_Obj *const objv[]);
0266
0267 TTKAPI int Ttk_RegisterElementFactory(
0268 Tcl_Interp *, const char *name, Ttk_ElementFactory, void *clientData);
0269
0270
0271
0272
0273
0274
0275 typedef struct {
0276 Tcl_Obj *unused;
0277 } NullElement;
0278
0279 MODULE_SCOPE void TtkNullElementSize
0280 (void *, void *, Tk_Window, int *, int *, Ttk_Padding *);
0281 MODULE_SCOPE void TtkNullElementDraw
0282 (void *, void *, Tk_Window, Drawable, Ttk_Box, Ttk_State);
0283 MODULE_SCOPE Ttk_ElementOptionSpec TtkNullElementOptions[];
0284 MODULE_SCOPE Ttk_ElementSpec ttkNullElementSpec;
0285
0286
0287
0288
0289 typedef struct {
0290 const char * elementName;
0291 unsigned opcode;
0292 } TTKLayoutInstruction, *Ttk_LayoutSpec;
0293
0294 #define TTK_BEGIN_LAYOUT_TABLE(name) \
0295 static TTKLayoutInstruction name[] = {
0296 #define TTK_LAYOUT(name, content) \
0297 { name, _TTK_CHILDREN|_TTK_LAYOUT }, \
0298 content \
0299 { 0, _TTK_LAYOUT_END },
0300 #define TTK_GROUP(name, flags, children) \
0301 { name, flags | _TTK_CHILDREN }, \
0302 children \
0303 { 0, _TTK_LAYOUT_END },
0304 #define TTK_NODE(name, flags) { name, flags },
0305 #define TTK_END_LAYOUT_TABLE { 0, _TTK_LAYOUT | _TTK_LAYOUT_END } };
0306
0307 #define TTK_BEGIN_LAYOUT(name) static TTKLayoutInstruction name[] = {
0308 #define TTK_END_LAYOUT { 0, _TTK_LAYOUT_END } };
0309
0310 TTKAPI void Ttk_RegisterLayout(
0311 Ttk_Theme theme, const char *className, Ttk_LayoutSpec layoutSpec);
0312
0313 TTKAPI void Ttk_RegisterLayouts(
0314 Ttk_Theme theme, Ttk_LayoutSpec layoutTable);
0315
0316
0317
0318
0319
0320 MODULE_SCOPE Ttk_Layout Ttk_CreateLayout(
0321 Tcl_Interp *, Ttk_Theme, const char *name,
0322 void *recordPtr, Tk_OptionTable, Tk_Window tkwin);
0323
0324 MODULE_SCOPE Ttk_Layout Ttk_CreateSublayout(
0325 Tcl_Interp *, Ttk_Theme, Ttk_Layout, const char *name, Tk_OptionTable);
0326
0327 MODULE_SCOPE void Ttk_FreeLayout(Ttk_Layout);
0328
0329 MODULE_SCOPE void Ttk_LayoutSize(Ttk_Layout,Ttk_State,int *widthPtr,int *heightPtr);
0330 MODULE_SCOPE void Ttk_PlaceLayout(Ttk_Layout, Ttk_State, Ttk_Box);
0331 MODULE_SCOPE void Ttk_DrawLayout(Ttk_Layout, Ttk_State, Drawable);
0332
0333 MODULE_SCOPE void Ttk_RebindSublayout(Ttk_Layout, void *recordPtr);
0334
0335 MODULE_SCOPE Ttk_Element Ttk_IdentifyElement(Ttk_Layout, int x, int y);
0336 MODULE_SCOPE Ttk_Element Ttk_FindElement(Ttk_Layout, const char *nodeName);
0337
0338 MODULE_SCOPE const char *Ttk_ElementName(Ttk_Element);
0339 MODULE_SCOPE Ttk_Box Ttk_ElementParcel(Ttk_Element);
0340
0341 MODULE_SCOPE Ttk_Box Ttk_ClientRegion(Ttk_Layout, const char *elementName);
0342
0343 MODULE_SCOPE Ttk_Box Ttk_LayoutNodeInternalParcel(Ttk_Layout,Ttk_Element);
0344 MODULE_SCOPE Ttk_Padding Ttk_LayoutNodeInternalPadding(Ttk_Layout,Ttk_Element);
0345 MODULE_SCOPE void Ttk_LayoutNodeReqSize(Ttk_Layout, Ttk_Element, int *w, int *h);
0346
0347 MODULE_SCOPE void Ttk_PlaceElement(Ttk_Layout, Ttk_Element, Ttk_Box);
0348 MODULE_SCOPE void Ttk_ChangeElementState(Ttk_Element,unsigned set,unsigned clr);
0349
0350 MODULE_SCOPE Tcl_Obj *Ttk_QueryOption(Ttk_Layout, const char *, Ttk_State);
0351
0352 TTKAPI Ttk_Style Ttk_LayoutStyle(Ttk_Layout);
0353 TTKAPI Tcl_Obj *Ttk_StyleDefault(Ttk_Style, const char *optionName);
0354 TTKAPI Tcl_Obj *Ttk_StyleMap(Ttk_Style, const char *optionName, Ttk_State);
0355
0356
0357
0358
0359
0360
0361 typedef struct Ttk_ResourceCache_ *Ttk_ResourceCache;
0362 MODULE_SCOPE Ttk_ResourceCache Ttk_CreateResourceCache(Tcl_Interp *);
0363 MODULE_SCOPE void Ttk_FreeResourceCache(Ttk_ResourceCache);
0364
0365 MODULE_SCOPE Ttk_ResourceCache Ttk_GetResourceCache(Tcl_Interp*);
0366 MODULE_SCOPE Tcl_Obj *Ttk_UseFont(Ttk_ResourceCache, Tk_Window, Tcl_Obj *);
0367 MODULE_SCOPE Tcl_Obj *Ttk_UseColor(Ttk_ResourceCache, Tk_Window, Tcl_Obj *);
0368 MODULE_SCOPE Tcl_Obj *Ttk_UseBorder(Ttk_ResourceCache, Tk_Window, Tcl_Obj *);
0369 MODULE_SCOPE Tk_Image Ttk_UseImage(Ttk_ResourceCache, Tk_Window, Tcl_Obj *);
0370
0371 MODULE_SCOPE void Ttk_RegisterNamedColor(Ttk_ResourceCache, const char *, XColor *);
0372
0373
0374
0375
0376
0377 typedef struct TtkImageSpec Ttk_ImageSpec;
0378 TTKAPI Ttk_ImageSpec *TtkGetImageSpec(Tcl_Interp *, Tk_Window, Tcl_Obj *);
0379 TTKAPI Ttk_ImageSpec *TtkGetImageSpecEx(Tcl_Interp *, Tk_Window, Tcl_Obj *,
0380 Tk_ImageChangedProc *, ClientData);
0381 TTKAPI void TtkFreeImageSpec(Ttk_ImageSpec *);
0382 TTKAPI Tk_Image TtkSelectImage(Ttk_ImageSpec *, Ttk_State);
0383
0384
0385
0386
0387
0388 typedef enum
0389 {
0390 TTK_BUTTON_DEFAULT_NORMAL,
0391 TTK_BUTTON_DEFAULT_ACTIVE,
0392 TTK_BUTTON_DEFAULT_DISABLED
0393 } Ttk_ButtonDefaultState;
0394
0395 TTKAPI int Ttk_GetButtonDefaultStateFromObj(Tcl_Interp *, Tcl_Obj *, int *);
0396
0397 typedef enum
0398 {
0399 TTK_COMPOUND_NONE,
0400 TTK_COMPOUND_TEXT,
0401 TTK_COMPOUND_IMAGE,
0402 TTK_COMPOUND_CENTER,
0403 TTK_COMPOUND_TOP,
0404 TTK_COMPOUND_BOTTOM,
0405 TTK_COMPOUND_LEFT,
0406 TTK_COMPOUND_RIGHT
0407 } Ttk_Compound;
0408
0409 TTKAPI int Ttk_GetCompoundFromObj(Tcl_Interp *, Tcl_Obj *, int *);
0410
0411 typedef enum {
0412 TTK_ORIENT_HORIZONTAL,
0413 TTK_ORIENT_VERTICAL
0414 } Ttk_Orient;
0415
0416
0417
0418
0419
0420 typedef struct TtkEnsemble {
0421 const char *name;
0422 Tcl_ObjCmdProc *command;
0423 const struct TtkEnsemble *ensemble;
0424 } Ttk_Ensemble;
0425
0426 MODULE_SCOPE int Ttk_InvokeEnsemble(
0427 const Ttk_Ensemble *commands, int cmdIndex,
0428 void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
0429
0430 MODULE_SCOPE int TtkEnumerateHashTable(Tcl_Interp *, Tcl_HashTable *);
0431
0432
0433
0434
0435
0436 #include "ttkDecls.h"
0437
0438
0439
0440
0441
0442 typedef enum { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT } ArrowDirection;
0443 MODULE_SCOPE void TtkArrowSize(int h, ArrowDirection, int *widthPtr, int *heightPtr);
0444 MODULE_SCOPE void TtkDrawArrow(Display *, Drawable, GC, Ttk_Box, ArrowDirection);
0445 MODULE_SCOPE void TtkFillArrow(Display *, Drawable, GC, Ttk_Box, ArrowDirection);
0446
0447 #ifdef __cplusplus
0448 }
0449 #endif
0450 #endif