summaryrefslogtreecommitdiffstats
path: root/generic/ttk/ttkWidget.h
diff options
context:
space:
mode:
authorhobbs <hobbs>2006-10-31 01:42:25 (GMT)
committerhobbs <hobbs>2006-10-31 01:42:25 (GMT)
commit397a2c9832bf618f26be267501cf49ab06a562ec (patch)
tree61d5e957eccfcba57b0dd27ebc73db085385834e /generic/ttk/ttkWidget.h
parent18d330543869e240c2bd12fc9fbb8d5027f5cad6 (diff)
downloadtk-397a2c9832bf618f26be267501cf49ab06a562ec.zip
tk-397a2c9832bf618f26be267501cf49ab06a562ec.tar.gz
tk-397a2c9832bf618f26be267501cf49ab06a562ec.tar.bz2
* doc/ttk_Geometry.3, doc/ttk_Theme.3, doc/ttk_button.n:
* doc/ttk_checkbutton.n, doc/ttk_combobox.n, doc/ttk_dialog.n: * doc/ttk_entry.n, doc/ttk_frame.n, doc/ttk_image.n: * doc/ttk_intro.n, doc/ttk_label.n, doc/ttk_labelframe.n: * doc/ttk_menubutton.n, doc/ttk_notebook.n, doc/ttk_panedwindow.n: * doc/ttk_progressbar.n, doc/ttk_radiobutton.n, doc/ttk_scrollbar.n: * doc/ttk_separator.n, doc/ttk_sizegrip.n, doc/ttk_style.n: * doc/ttk_treeview.n, doc/ttk_widget.n,: * generic/ttk/ttk.decls, generic/ttk/ttkBlink.c: * generic/ttk/ttkButton.c, generic/ttk/ttkCache.c: * generic/ttk/ttkClamTheme.c, generic/ttk/ttkClassicTheme.c: * generic/ttk/ttkDecls.h, generic/ttk/ttkDefaultTheme.c: * generic/ttk/ttkElements.c, generic/ttk/ttkEntry.c: * generic/ttk/ttkFrame.c, generic/ttk/ttkImage.c: * generic/ttk/ttkInit.c, generic/ttk/ttkLabel.c: * generic/ttk/ttkLayout.c, generic/ttk/ttkManager.c: * generic/ttk/ttkManager.h, generic/ttk/ttkNotebook.c: * generic/ttk/ttkPanedwindow.c, generic/ttk/ttkProgress.c: * generic/ttk/ttkScale.c, generic/ttk/ttkScroll.c: * generic/ttk/ttkScrollbar.c, generic/ttk/ttkSeparator.c: * generic/ttk/ttkSquare.c, generic/ttk/ttkState.c: * generic/ttk/ttkStubInit.c, generic/ttk/ttkStubLib.c: * generic/ttk/ttkTagSet.c, generic/ttk/ttkTheme.c: * generic/ttk/ttkTheme.h, generic/ttk/ttkThemeInt.h: * generic/ttk/ttkTrace.c, generic/ttk/ttkTrack.c: * generic/ttk/ttkTreeview.c, generic/ttk/ttkWidget.c: * generic/ttk/ttkWidget.h: * library/demos/ttk_demo.tcl, library/demos/ttk_iconlib.tcl: * library/demos/ttk_repeater.tcl: * library/ttk/altTheme.tcl, library/ttk/aquaTheme.tcl: * library/ttk/button.tcl, library/ttk/clamTheme.tcl: * library/ttk/classicTheme.tcl, library/ttk/combobox.tcl: * library/ttk/cursors.tcl, library/ttk/defaults.tcl: * library/ttk/dialog.tcl, library/ttk/entry.tcl: * library/ttk/fonts.tcl, library/ttk/icons.tcl: * library/ttk/keynav.tcl, library/ttk/menubutton.tcl: * library/ttk/notebook.tcl, library/ttk/panedwindow.tcl: * library/ttk/progress.tcl, library/ttk/scale.tcl: * library/ttk/scrollbar.tcl, library/ttk/sizegrip.tcl: * library/ttk/treeview.tcl, library/ttk/ttk.tcl: * library/ttk/utils.tcl, library/ttk/winTheme.tcl: * library/ttk/xpTheme.tcl: * macosx/ttkMacOSXTheme.c: * tests/ttk/all.tcl, tests/ttk/bwidget.test, tests/ttk/combobox.test: * tests/ttk/entry.test, tests/ttk/image.test: * tests/ttk/labelframe.test, tests/ttk/layout.test: * tests/ttk/misc.test, tests/ttk/notebook.test: * tests/ttk/panedwindow.test, tests/ttk/progressbar.test: * tests/ttk/scrollbar.test, tests/ttk/treetags.test: * tests/ttk/treeview.test, tests/ttk/ttk.test, tests/ttk/validate.test: * win/ttkWinMonitor.c, win/ttkWinTheme.c, win/ttkWinXPTheme.c: First import of Ttk themed Tk widgets as branched from tile 0.7.8 * generic/tkInt.h, generic/tkWindow.c: add Ttk_Init call, copy tk classic widgets to ::tk namespace. * library/tk.tcl: add source of ttk/ttk.tcl, define $::ttk::library. * unix/Makefile.in, win/Makefile.in: add Ttk build bits * win/configure, win/configure.in: check for uxtheme.h (XP theme).
Diffstat (limited to 'generic/ttk/ttkWidget.h')
-rw-r--r--generic/ttk/ttkWidget.h269
1 files changed, 269 insertions, 0 deletions
diff --git a/generic/ttk/ttkWidget.h b/generic/ttk/ttkWidget.h
new file mode 100644
index 0000000..aa749ee
--- /dev/null
+++ b/generic/ttk/ttkWidget.h
@@ -0,0 +1,269 @@
+/* $Id: ttkWidget.h,v 1.1 2006/10/31 01:42:26 hobbs Exp $
+ * Copyright (c) 2003, Joe English
+ *
+ * Helper routines for widget implementations.
+ *
+ * Require: ttkTheme.h.
+ */
+
+#ifndef WIDGET_H
+#define WIDGET_H 1
+
+/* State flags for 'flags' field.
+ * @@@ todo: distinguish:
+ * need reconfigure, need redisplay, redisplay pending
+ */
+#define WIDGET_DESTROYED 0x0001
+#define REDISPLAY_PENDING 0x0002 /* scheduled call to RedisplayWidget */
+#define WIDGET_REALIZED 0x0010 /* set at first ConfigureNotify */
+#define CURSOR_ON 0x0020 /* See BlinkCursor() */
+#define WIDGET_USER_FLAG 0x0100 /* 0x0100 - 0x8000 for user flags */
+
+/*
+ * Bit fields for OptionSpec 'mask' field:
+ */
+#define READONLY_OPTION 0x1
+#define STYLE_CHANGED 0x2
+#define GEOMETRY_CHANGED 0x4
+
+/*
+ * Core widget elements
+ */
+typedef struct WidgetSpec_ WidgetSpec; /* Forward */
+
+typedef struct
+{
+ Tk_Window tkwin; /* Window associated with widget */
+ Tcl_Interp *interp; /* Interpreter associated with widget. */
+ WidgetSpec *widgetSpec; /* Widget class hooks */
+ Tcl_Command widgetCmd; /* Token for widget command. */
+ Tk_OptionTable optionTable; /* Option table */
+ Ttk_Layout layout; /* Widget layout */
+
+ /*
+ * Storage for resources:
+ */
+ Tcl_Obj *takeFocusPtr; /* Storage for -takefocus option */
+ Tcl_Obj *cursorObj; /* Storage for -cursor option */
+ Tcl_Obj *styleObj; /* Name of currently-applied style */
+ Tcl_Obj *classObj; /* Class name (readonly option) */
+
+ Ttk_State state; /* Current widget state */
+ unsigned int flags; /* internal flags, see above */
+
+} WidgetCore;
+
+/*
+ * Subcommand specifications:
+ */
+typedef int (*WidgetSubcommandProc)(
+ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr);
+typedef struct {
+ const char *name;
+ WidgetSubcommandProc command;
+} WidgetCommandSpec;
+
+extern int WidgetEnsembleCommand( /* Run an ensemble command */
+ WidgetCommandSpec *commands, int cmdIndex,
+ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr);
+
+/*
+ * Widget specifications:
+ */
+struct WidgetSpec_
+{
+ const char *className; /* Widget class name */
+ size_t recordSize; /* #bytes in widget record */
+ Tk_OptionSpec *optionSpecs; /* Option specifications */
+ WidgetCommandSpec *commands; /* Widget instance subcommands */
+
+ /*
+ * Hooks:
+ */
+ int (*initializeProc)(Tcl_Interp *, void *recordPtr);
+ void (*cleanupProc)(void *recordPtr);
+ int (*configureProc)(Tcl_Interp *, void *recordPtr, int flags);
+ int (*postConfigureProc)(Tcl_Interp *, void *recordPtr, int flags);
+ Ttk_Layout (*getLayoutProc)(Tcl_Interp *,Ttk_Theme, void *recordPtr);
+ int (*sizeProc)(void *recordPtr, int *widthPtr, int *heightPtr);
+ void (*layoutProc)(void *recordPtr);
+ void (*displayProc)(void *recordPtr, Drawable d);
+};
+
+/*
+ * Common factors for widget implementations:
+ */
+extern int NullInitialize(Tcl_Interp *, void *);
+extern int NullPostConfigure(Tcl_Interp *, void *, int);
+extern void NullCleanup(void *recordPtr);
+extern Ttk_Layout WidgetGetLayout(Tcl_Interp *, Ttk_Theme, void *recordPtr);
+extern Ttk_Layout WidgetGetOrientedLayout(
+ Tcl_Interp *, Ttk_Theme, void *recordPtr, Tcl_Obj *orientObj);
+extern int WidgetSize(void *recordPtr, int *w, int *h);
+extern void WidgetDoLayout(void *recordPtr);
+extern void WidgetDisplay(void *recordPtr, Drawable);
+
+extern int CoreConfigure(Tcl_Interp*, void *, int mask);
+
+/* Commands present in all widgets:
+ */
+extern int WidgetConfigureCommand(Tcl_Interp *, int, Tcl_Obj*const[], void *);
+extern int WidgetCgetCommand(Tcl_Interp *, int, Tcl_Obj*const[], void *);
+extern int WidgetInstateCommand(Tcl_Interp *, int, Tcl_Obj*const[], void *);
+extern int WidgetStateCommand(Tcl_Interp *, int, Tcl_Obj*const[], void *);
+
+/* Common widget commands:
+ */
+extern int WidgetIdentifyCommand(Tcl_Interp *, int, Tcl_Obj*const[], void *);
+
+extern int WidgetConstructorObjCmd(ClientData,Tcl_Interp*,int,Tcl_Obj*CONST[]);
+
+#define RegisterWidget(interp, name, specPtr) \
+ Tcl_CreateObjCommand(interp, name, \
+ WidgetConstructorObjCmd, (ClientData)specPtr,NULL)
+
+/* WIDGET_TAKES_FOCUS --
+ * Add this to the OptionSpecs table of widgets that
+ * take keyboard focus during traversal to override
+ * CoreOptionSpec's -takefocus default value:
+ */
+#define WIDGET_TAKES_FOCUS \
+ {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", \
+ "ttk::takefocus", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 }
+
+/* WIDGET_INHERIT_OPTIONS(baseOptionSpecs) --
+ * Add this at the end of an OptionSpecs table to inherit
+ * the options from 'baseOptionSpecs'.
+ */
+#define WIDGET_INHERIT_OPTIONS(baseOptionSpecs) \
+ {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0, (ClientData)baseOptionSpecs, 0}
+
+/*
+ * Useful routines for use inside widget implementations:
+ */
+extern int WidgetDestroyed(WidgetCore *);
+#define WidgetDestroyed(corePtr) ((corePtr)->flags & WIDGET_DESTROYED)
+
+extern void WidgetChangeState(WidgetCore *,
+ unsigned int setBits, unsigned int clearBits);
+
+extern void TtkRedisplayWidget(WidgetCore *);
+extern void TtkResizeWidget(WidgetCore *);
+
+extern void TrackElementState(WidgetCore *);
+extern void BlinkCursor(WidgetCore *);
+
+/*
+ * -state option values (compatibility)
+ */
+extern void CheckStateOption(WidgetCore *, Tcl_Obj *);
+
+/*
+ * Variable traces:
+ */
+typedef void (*Ttk_TraceProc)(void *recordPtr, const char *value);
+typedef struct TtkTraceHandle_ Ttk_TraceHandle;
+
+extern Ttk_TraceHandle *Ttk_TraceVariable(
+ Tcl_Interp*, Tcl_Obj *varnameObj, Ttk_TraceProc callback, void *clientData);
+extern void Ttk_UntraceVariable(Ttk_TraceHandle *);
+extern int Ttk_FireTrace(Ttk_TraceHandle *);
+
+/*
+ * Utility routines for managing -image option:
+ */
+extern int GetImageList(
+ Tcl_Interp *, WidgetCore *, Tcl_Obj *imageOption, Tk_Image **imageListPtr);
+extern void FreeImageList(Tk_Image *);
+
+/*
+ * Virtual events:
+ */
+extern void SendVirtualEvent(Tk_Window tgtWin, const char *eventName);
+
+/*
+ * Helper routines for data accessor commands:
+ */
+extern int EnumerateOptions(
+ Tcl_Interp *, void *recordPtr, Tk_OptionSpec *, Tk_OptionTable, Tk_Window);
+extern int GetOptionValue(
+ Tcl_Interp *, void *recordPtr, Tcl_Obj *optName, Tk_OptionTable, Tk_Window);
+
+/*
+ * Helper routines for scrolling widgets (see scroll.c).
+ */
+typedef struct {
+ int first; /* First visible item */
+ int last; /* Last visible item */
+ int total; /* Total #items */
+ char *scrollCmd; /* Widget option */
+} Scrollable;
+
+typedef struct ScrollHandleRec *ScrollHandle;
+
+extern ScrollHandle CreateScrollHandle(WidgetCore *, Scrollable *);
+extern void FreeScrollHandle(ScrollHandle);
+
+extern int ScrollviewCommand(
+ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], ScrollHandle);
+
+extern void ScrollTo(ScrollHandle, int newFirst);
+extern void Scrolled(ScrollHandle, int first, int last, int total);
+extern void ScrollbarUpdateRequired(ScrollHandle);
+
+/*
+ * Tag sets (work in progress, half-baked)
+ */
+
+typedef struct TtkTag *Ttk_Tag;
+typedef struct TtkTagTable *Ttk_TagTable;
+
+extern Ttk_TagTable Ttk_CreateTagTable(Tk_OptionTable, int tagRecSize);
+extern void Ttk_DeleteTagTable(Ttk_TagTable);
+
+extern Ttk_Tag Ttk_GetTag(Ttk_TagTable, const char *tagName);
+extern Ttk_Tag Ttk_GetTagFromObj(Ttk_TagTable, Tcl_Obj *);
+
+extern Tcl_Obj **Ttk_TagRecord(Ttk_Tag);
+
+extern int Ttk_GetTagListFromObj(
+ Tcl_Interp *interp, Ttk_TagTable, Tcl_Obj *objPtr,
+ int *nTags_rtn, void **taglist_rtn);
+
+extern void Ttk_FreeTagList(void **taglist);
+
+
+/*
+ * Useful widget base classes:
+ */
+extern Tk_OptionSpec CoreOptionSpecs[];
+
+/*
+ * String tables for widget resource specifications:
+ */
+
+extern const char *TTKOrientStrings[];
+extern const char *TTKCompoundStrings[];
+extern const char *TTKDefaultStrings[];
+
+/*
+ * ... other option types...
+ */
+extern int TtkGetLabelAnchorFromObj(Tcl_Interp*,Tcl_Obj*,Ttk_PositionSpec *);
+
+/*
+ * Package initialiation routines:
+ */
+extern void RegisterElements(Tcl_Interp *);
+
+#if defined(__WIN32__)
+#define Ttk_PlatformInit Ttk_WinPlatformInit
+extern int Ttk_WinPlatformInit(Tcl_Interp *);
+#elif defined(MAC_OSX_TK)
+#define Ttk_PlatformInit Ttk_MacPlatformInit
+extern int Ttk_MacPlatformInit(Tcl_Interp *);
+#else
+#define Ttk_PlatformInit(interp) /* TTK_X11PlatformInit() */
+#endif
+
+#endif /* WIDGET_H */