︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
|
}
}
/*------------------------------------------------------------------------
* +++ State tables for FrameControlElements.
*/
static Ttk_StateTable checkbutton_statemap[] = { /* see also SF#1865898 */
static const Ttk_StateTable checkbutton_statemap[] = { /* see also SF#1865898 */
{ DFCS_BUTTON3STATE|DFCS_CHECKED|DFCS_INACTIVE,
TTK_STATE_ALTERNATE|TTK_STATE_DISABLED, 0 },
{ DFCS_BUTTON3STATE|DFCS_CHECKED|DFCS_PUSHED,
TTK_STATE_ALTERNATE|TTK_STATE_PRESSED, 0 },
{ DFCS_BUTTON3STATE|DFCS_CHECKED|DFCS_HOT,
TTK_STATE_ALTERNATE|TTK_STATE_ACTIVE, 0 },
{ DFCS_BUTTON3STATE|DFCS_CHECKED,
TTK_STATE_ALTERNATE, 0 },
{ DFCS_CHECKED|DFCS_INACTIVE, TTK_STATE_SELECTED|TTK_STATE_DISABLED, 0 },
{ DFCS_CHECKED|DFCS_PUSHED, TTK_STATE_SELECTED|TTK_STATE_PRESSED, 0 },
{ DFCS_CHECKED|DFCS_HOT, TTK_STATE_SELECTED|TTK_STATE_ACTIVE, 0 },
{ DFCS_CHECKED, TTK_STATE_SELECTED, 0 },
{ DFCS_INACTIVE, TTK_STATE_DISABLED, 0 },
{ DFCS_PUSHED, TTK_STATE_PRESSED, 0 },
{ DFCS_HOT, TTK_STATE_ACTIVE, 0 },
{ 0, 0, 0 },
};
static Ttk_StateTable pushbutton_statemap[] = {
static const Ttk_StateTable pushbutton_statemap[] = {
{ DFCS_INACTIVE, TTK_STATE_DISABLED, 0 },
{ DFCS_PUSHED, TTK_STATE_PRESSED, 0 },
{ DFCS_HOT, TTK_STATE_ACTIVE, 0 },
{ 0, 0, 0 }
};
static Ttk_StateTable arrow_statemap[] = {
static const Ttk_StateTable arrow_statemap[] = {
{ DFCS_INACTIVE, TTK_STATE_DISABLED, 0 },
{ DFCS_PUSHED | DFCS_FLAT, TTK_STATE_PRESSED, 0 },
{ 0, 0, 0 }
};
/*------------------------------------------------------------------------
* +++ FrameControlElement --
* General-purpose element for things drawn with DrawFrameControl
*/
typedef struct {
const char *name; /* element name */
int classId; /* class id for DrawFrameControl */
int partId; /* part id for DrawFrameControl */
int cxId; /* system metric ids for width/height... */
int cyId; /* ... or size if FIXEDSIZE bit set */
Ttk_StateTable *stateMap; /* map Tk states to Win32 flags */
const Ttk_StateTable *stateMap; /* map Tk states to Win32 flags */
Ttk_Padding margins; /* additional placement padding */
} FrameControlElementData;
#define _FIXEDSIZE 0x80000000L
#define _HALFMETRIC 0x40000000L
#define FIXEDSIZE(id) (id|_FIXEDSIZE)
#define HALFMETRIC(id) (id|_HALFMETRIC)
#define GETMETRIC(m) \
((m) & _FIXEDSIZE ? (int)((m) & ~_FIXEDSIZE) : GetSystemMetrics((m)&0x0fffffff))
static FrameControlElementData FrameControlElements[] = {
static const FrameControlElementData FrameControlElements[] = {
{ "Checkbutton.indicator",
DFC_BUTTON, DFCS_BUTTONCHECK, FIXEDSIZE(13), FIXEDSIZE(13),
checkbutton_statemap, {0,0,4,0} },
{ "Radiobutton.indicator",
DFC_BUTTON, DFCS_BUTTONRADIO, FIXEDSIZE(13), FIXEDSIZE(13),
checkbutton_statemap, {0,0,4,0} },
{ "uparrow",
|
︙ | | |
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
-
+
-
+
|
DrawFrameControl(hdc, &rc,
elementData->classId,
elementData->partId|Ttk_StateTableLookup(elementData->stateMap, state));
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
static Ttk_ElementSpec FrameControlElementSpec = {
static const Ttk_ElementSpec FrameControlElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
FrameControlElementSize,
FrameControlElementDraw
};
/*----------------------------------------------------------------------
* +++ Border element implementation.
*/
typedef struct {
Tcl_Obj *reliefObj;
} BorderElement;
static Ttk_ElementOptionSpec BorderElementOptions[] = {
static const Ttk_ElementOptionSpec BorderElementOptions[] = {
{ "-relief",TK_OPTION_RELIEF, offsetof(BorderElement,reliefObj), "flat" },
{NULL, 0, 0, NULL}
};
static void BorderElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
︙ | | |
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
-
+
-
+
|
UINT xFlags = (relief == TK_RELIEF_SOLID) ? BF_FLAT : 0;
hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawEdge(hdc, &rc, ReliefToEdge(relief), BF_RECT | xFlags);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
}
static Ttk_ElementSpec BorderElementSpec = {
static const Ttk_ElementSpec BorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BorderElement),
BorderElementOptions,
BorderElementSize,
BorderElementDraw
};
/*
* Entry field borders:
* Sunken border; also fill with window color.
*/
typedef struct {
Tcl_Obj *backgroundObj;
} FieldElement;
static Ttk_ElementOptionSpec FieldElementOptions[] = {
static const Ttk_ElementOptionSpec FieldElementOptions[] = {
{ "-fieldbackground", TK_OPTION_BORDER,
offsetof(FieldElement,backgroundObj), "white" },
{ NULL, 0, 0, NULL }
};
static void FieldElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
|
︙ | | |
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
-
+
-
+
|
tkwin, d, bg, b.x, b.y, b.width, b.height, 0, TK_RELIEF_FLAT);
hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawEdge(hdc, &rc, EDGE_SUNKEN, BF_RECT);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
static Ttk_ElementSpec FieldElementSpec = {
static const Ttk_ElementSpec FieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
FieldElementSize,
FieldElementDraw
};
/*------------------------------------------------------------------------
* +++ Button borders.
* Drawn with DrawFrameControl instead of DrawEdge;
* Also draw default indicator and focus ring.
*/
typedef struct {
Tcl_Obj *reliefObj;
Tcl_Obj *highlightColorObj;
Tcl_Obj *defaultStateObj;
} ButtonBorderElement;
static Ttk_ElementOptionSpec ButtonBorderElementOptions[] = {
static const Ttk_ElementOptionSpec ButtonBorderElementOptions[] = {
{ "-relief",TK_OPTION_RELIEF,
offsetof(ButtonBorderElement,reliefObj), "flat" },
{ "-highlightcolor",TK_OPTION_COLOR,
offsetof(ButtonBorderElement,highlightColorObj), "black" },
{ "-default", TK_OPTION_ANY,
offsetof(ButtonBorderElement,defaultStateObj), "disabled" },
{NULL, 0, 0, NULL}
|
︙ | | |
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
-
+
|
short int borderWidth = 3; /* @@@ Use GetSystemMetrics?*/
rc = BoxToRect(Ttk_PadBox(b, Ttk_UniformPadding(borderWidth)));
DrawFocusRect(hdc, &rc);
}
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
static Ttk_ElementSpec ButtonBorderElementSpec = {
static const Ttk_ElementSpec ButtonBorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ButtonBorderElement),
ButtonBorderElementOptions,
ButtonBorderElementSize,
ButtonBorderElementDraw
};
|
︙ | | |
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
-
+
-
+
|
TkWinDCState dcState;
HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawFocusRect(hdc, &rc);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
}
static Ttk_ElementSpec FocusElementSpec = {
static const Ttk_ElementSpec FocusElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
FocusElementSize,
FocusElementDraw
};
/* FillFocusElement --
* Draws a focus ring filled with the selection color
*/
typedef struct {
Tcl_Obj *fillColorObj;
} FillFocusElement;
static Ttk_ElementOptionSpec FillFocusElementOptions[] = {
static const Ttk_ElementOptionSpec FillFocusElementOptions[] = {
{ "-focusfill", TK_OPTION_COLOR,
offsetof(FillFocusElement,fillColorObj), "white" },
{NULL, 0, 0, NULL}
};
/* @@@ FIX THIS */
static void FillFocusElementDraw(
|
︙ | | |
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
-
+
|
Drawable d, Ttk_Box b, unsigned int state)
{
if (state & TTK_STATE_READONLY) {
FillFocusElementDraw(clientData, elementRecord, tkwin, d, b, state);
}
}
static Ttk_ElementSpec ComboboxFocusElementSpec = {
static const Ttk_ElementSpec ComboboxFocusElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FillFocusElement),
FillFocusElementOptions,
FocusElementSize,
ComboboxFocusElementDraw
};
|
︙ | | |
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
-
+
-
+
|
PatBlt(hdc, b.x, b.y, b.width, b.height, PATCOPY);
SetBkColor(hdc, oldbk);
SetTextColor(hdc, oldtxt);
SelectObject(hdc, hbr);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
static Ttk_ElementSpec TroughElementSpec = {
static const Ttk_ElementSpec TroughElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
TtkNullElementSize,
TroughElementDraw
};
/*------------------------------------------------------------------------
* +++ Thumb element.
*/
typedef struct {
Tcl_Obj *orientObj;
} ThumbElement;
static Ttk_ElementOptionSpec ThumbElementOptions[] = {
static const Ttk_ElementOptionSpec ThumbElementOptions[] = {
{ "-orient", TK_OPTION_ANY, offsetof(ThumbElement,orientObj),"horizontal"},
{ NULL, 0, 0, NULL }
};
static void ThumbElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
︙ | | |
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
-
+
-
+
|
return;
hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_MIDDLE);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
static Ttk_ElementSpec ThumbElementSpec = {
static const Ttk_ElementSpec ThumbElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ThumbElement),
ThumbElementOptions,
ThumbElementSize,
ThumbElementDraw
};
/* ----------------------------------------------------------------------
* The slider element is the shaped thumb used in the slider widget.
* Windows likes to call this a trackbar.
*/
typedef struct {
Tcl_Obj *orientObj; /* orientation of the slider widget */
} SliderElement;
static Ttk_ElementOptionSpec SliderElementOptions[] = {
static const Ttk_ElementOptionSpec SliderElementOptions[] = {
{ "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj),
"horizontal" },
{ NULL, 0, 0, NULL }
};
static void SliderElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
|
︙ | | |
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
|
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
|
-
+
|
HDC hdc;
hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_MIDDLE);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
static Ttk_ElementSpec SliderElementSpec = {
static const Ttk_ElementSpec SliderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SliderElement),
SliderElementOptions,
SliderElementSize,
SliderElementDraw
};
|
︙ | | |
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
|
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
|
-
+
|
RECT rc = BoxToRect(b);
TkWinDCState dcState;
HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_SOFT);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
static Ttk_ElementSpec ClientElementSpec = {
static const Ttk_ElementSpec ClientElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
ClientElementSize,
ClientElementDraw
};
|
︙ | | |
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
|
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
|
-
+
|
/* ---------------------------------------------------------------------- */
MODULE_SCOPE
int TtkWinTheme_Init(Tcl_Interp *interp, HWND hwnd)
{
Ttk_Theme themePtr, parentPtr;
FrameControlElementData *fce = FrameControlElements;
const FrameControlElementData *fce = FrameControlElements;
parentPtr = Ttk_GetTheme(interp, "alt");
themePtr = Ttk_CreateTheme(interp, "winnative", parentPtr);
if (!themePtr) {
return TCL_ERROR;
}
|
︙ | | |
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
|
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
|
-
+
|
Ttk_RegisterElementSpec(themePtr, "Scrollbar.trough", &TroughElementSpec,
TroughClientDataInit(interp));
Ttk_RegisterElementSpec(themePtr, "client", &ClientElementSpec, NULL);
for (fce = FrameControlElements; fce->name != 0; ++fce) {
Ttk_RegisterElementSpec(themePtr, fce->name,
&FrameControlElementSpec, fce);
&FrameControlElementSpec, (void *)fce);
}
Ttk_RegisterLayouts(themePtr, LayoutTable);
Tcl_PkgProvide(interp, "ttk::theme::winnative", TTK_VERSION);
return TCL_OK;
}
|