1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/*
* Copyright © 2004 Joe English
*
* ttk::separator and ttk::sizegrip widgets.
*/
#include "tkInt.h"
#include "ttkTheme.h"
#include "ttkWidget.h"
/* +++ Separator widget record:
*/
typedef struct
{
Tcl_Obj *orientObj;
int orient;
} SeparatorPart;
typedef struct
{
WidgetCore core;
SeparatorPart separator;
} Separator;
static const Tk_OptionSpec SeparatorOptionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
offsetof(Separator,separator.orientObj),
offsetof(Separator,separator.orient),
0, ttkOrientStrings, STYLE_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
/*
* GetLayout hook --
* Choose layout based on -orient option.
*/
static Ttk_Layout SeparatorGetLayout(
Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
{
Separator *sep = (Separator *)recordPtr;
return TtkWidgetGetOrientedLayout(
interp, theme, recordPtr, sep->separator.orientObj);
}
/*
* Widget commands:
*/
static const Ttk_Ensemble SeparatorCommands[] = {
{ "cget", TtkWidgetCgetCommand,0 },
{ "configure", TtkWidgetConfigureCommand,0 },
{ "identify", TtkWidgetIdentifyCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
{ "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
/*
* Widget specification:
*/
static const WidgetSpec SeparatorWidgetSpec =
{
"TSeparator", /* className */
sizeof(Separator), /* recordSize */
SeparatorOptionSpecs, /* optionSpecs */
SeparatorCommands, /* subcommands */
TtkNullInitialize, /* initializeProc */
TtkNullCleanup, /* cleanupProc */
TtkCoreConfigure, /* configureProc */
TtkNullPostConfigure, /* postConfigureProc */
SeparatorGetLayout, /* getLayoutProc */
TtkWidgetSize, /* sizeProc */
TtkWidgetDoLayout, /* layoutProc */
TtkWidgetDisplay /* displayProc */
};
TTK_BEGIN_LAYOUT(SeparatorLayout)
TTK_NODE("Separator.separator", TTK_FILL_BOTH)
TTK_END_LAYOUT
/* +++ Sizegrip widget:
* Has no options or methods other than the standard ones.
*/
static const Tk_OptionSpec SizegripOptionSpecs[] = {
WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
static const Ttk_Ensemble SizegripCommands[] = {
{ "cget", TtkWidgetCgetCommand,0 },
{ "configure", TtkWidgetConfigureCommand,0 },
{ "identify", TtkWidgetIdentifyCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
{ "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
static const WidgetSpec SizegripWidgetSpec =
{
"TSizegrip", /* className */
sizeof(WidgetCore), /* recordSize */
SizegripOptionSpecs, /* optionSpecs */
SizegripCommands, /* subcommands */
TtkNullInitialize, /* initializeProc */
TtkNullCleanup, /* cleanupProc */
TtkCoreConfigure, /* configureProc */
TtkNullPostConfigure, /* postConfigureProc */
TtkWidgetGetLayout, /* getLayoutProc */
TtkWidgetSize, /* sizeProc */
TtkWidgetDoLayout, /* layoutProc */
TtkWidgetDisplay /* displayProc */
};
TTK_BEGIN_LAYOUT(SizegripLayout)
TTK_NODE("Sizegrip.sizegrip", TTK_PACK_BOTTOM|TTK_STICK_S|TTK_STICK_E)
TTK_END_LAYOUT
/* +++ Initialization:
*/
MODULE_SCOPE void
TtkSeparator_Init(Tcl_Interp *interp)
{
Ttk_Theme theme = Ttk_GetDefaultTheme(interp);
Ttk_RegisterLayout(theme, "TSeparator", SeparatorLayout);
Ttk_RegisterLayout(theme, "TSizegrip", SizegripLayout);
RegisterWidget(interp, "ttk::separator", &SeparatorWidgetSpec);
RegisterWidget(interp, "ttk::sizegrip", &SizegripWidgetSpec);
}
/*EOF*/
|