summaryrefslogtreecommitdiff
path: root/include/tk.h
blob: cff4aa5490c00e883697f186921f5a2f6114c064 (plain)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
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
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
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
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
/*
 * Here are some conventions about  our Tk widgets.
 *
 * When a widget is packed, its act geom record is
 * set so that act.{x,y} is the vector from the containing
 * widget's origin to the position of this widget.  The position
 * is the place just outside the top-left border.  The origin
 * is the place just inside the top-left border.
 * act.{width,height} gives the allocated dimensions inside
 * the border --- it will be the requested width or height
 * plus ipad{x,y} plus any filling done by the packer.
 *
 * The tkposn function returns the origin of its argument
 * widget, expressed in absolute screen coordinates.
 *
 * The actual drawing contents of the widget should be
 * drawn at an internal origin that is the widget's origin
 * plus the ipad vector.
 */

/*
 * event printing
 */
#pragma	varargck	type	"v"	int
#pragma	varargck	argpos	tkwreq	2

enum
{
	TKframe,		/* Widget type */
	TKlabel,
	TKcheckbutton,
	TKbutton,
	TKmenubutton,
	TKmenu,
	TKseparator,
	TKcascade,
	TKlistbox,
	TKscrollbar,
	TKtext,
	TKcanvas,
	TKentry,
	TKradiobutton,
	TKscale,
	TKpanel,
	TKchoicebutton,
	TKwidgets,

	TKsingle	= 0,	/* Select mode */
	TKbrowse,
	TKmultiple,
	TKextended,

	TKraised,		/* Relief */
	TKsunken,
	TKflat,
	TKgroove,
	TKridge,

	TkArepl		= 0,	/* Bind options */
	TkAadd,
	TkAsub,

	Tkvertical	= 0,	/* Scroll bar orientation */
	Tkhorizontal,

	Tkwrapnone	= 0,	/* Wrap mode */
	Tkwrapword,
	Tkwrapchar,

	TkDdelivered	= 0,	/* Event Delivery results */
	TkDbreak,
	TkDnone,

	TkLt = 0,		/* Comparison operators */
	TkLte,
	TkEq,
	TkGte,
	TkGt,
	TkNeq,

	
	OPTdist		= 0,	/* Distance; aux is offset of TkEnv* */
	OPTstab,		/* String->Constant table; aux is TkStab array */
	OPTtext,		/* Text string */
	OPTwinp,		/* Window Path to Tk ptr */
	OPTflag,		/* Option sets bitmask; aux is TkStab array*/
	OPTbmap,		/* Option specifies bitmap file */
	OPTbool,		/* Set to one if option present */
	OPTfont,		/* Env font */
	OPTfrac,		/* list of fixed point distances (count in aux) */
	OPTnnfrac,	/* non-negative fixed point distance */
	OPTctag,		/* Tag list for canvas item */
	OPTtabs,		/* Tab stops; aux is offset of TkEnv* */
	OPTcolr,		/* Colors; aux is index into colour table */
	OPTimag,		/* Image */
	OPTsize,		/* width/height; aux is offset of TkEnv* */
	OPTnndist,		/* Non-negative distance */
	OPTact,		/* actx or acty */
	OPTignore,	/* ignore this option */
	OPTsticky,	/* sticky (any comb. of chars n, s, e, w) */
	OPTlist,		/* list of text values */

	BoolX		= 0,
	BoolT,
	BoolF,

	Tkmaxitem	= 128,
	Tkminitem	= 32,
	Tkcvstextins	= 1024,
	Tkmaxdump	= 1024,
	Tkentryins	= 128,
	TkMaxmsgs	= 100,
	Tkshdelta	= 0x40,	/* color intensity delta for shading */

	Tkfpscalar	= 10000,	/* Fixed point scale factor */

	Tkdpi		= 100,	/* pixels per inch on an average display */

	Tksweep		= 64,	/* binds before a sweep */

	TkColcachesize = 128,	/* colours cached per context (display) */

	TkStatic	= 0,
	TkDynamic	= 1,

	TkRptclick		= 100,	/* granularity */
	TkRptpause	= 300,	/* autorepeat inital delay */
	TkRptinterval	= 100,	/* autorepeat interval */

	TkBlinkinterval	= 500
};

#define TKSTRUCTALIGN	4
#define TKI2F(i)	((i)*Tkfpscalar)
extern	int TKF2I(int);
/*#define TKF2I(f)	(((f) + Tkfpscalar/2)/Tkfpscalar)*/
#define IAUX(i)		((void*)i)
#define AUXI(i)		((int)i)
#define TKKEY(i)	((i)&0xFFFF)

typedef struct Tk Tk;
typedef struct TkCol TkCol;
typedef struct TkCtxt TkCtxt;
typedef struct TkEnv TkEnv;
typedef struct TkName TkName;
typedef struct TkTtabstop TkTtabstop;
typedef struct TkOptab TkOptab;
typedef struct TkOption TkOption;
typedef struct TkStab TkStab;
typedef struct TkTop TkTop;
typedef struct TkGeom TkGeom;
typedef struct TkMethod TkMethod;
typedef struct TkAction TkAction;
typedef struct TkWin TkWin;
typedef struct TkCmdtab TkCmdtab;
typedef struct TkMouse TkMouse;
typedef struct TkVar TkVar;
typedef struct TkMsg TkMsg;
typedef struct TkEbind TkEbind;
typedef struct TkImg TkImg;
typedef struct TkPanelimage TkPanelimage;
typedef struct TkWinfo TkWinfo;
typedef struct TkCursor TkCursor;
typedef struct TkGrid TkGrid;
typedef struct TkGridbeam TkGridbeam;
typedef struct TkGridcell TkGridcell;

struct TkImg
{
	TkTop*	top;
	int	ref;
	int	type;
	int	w;
	int	h;
	TkEnv*	env;
	Image*	img;
	TkImg*	link;
	TkName*	name;
	char *cursor;
};

struct TkCursor
{
	int	def;
	Point	p;
	Image*	bit;
	TkImg*	img;
};

struct TkEbind
{
	int	event;
	char*	cmd;
};

struct TkMsg
{
	TkVar*	var;
	TkMsg*	link;
	char	msg[TKSTRUCTALIGN];
};

enum
{
	TkVchan		= 1,
	TkVstring,
};

struct TkVar
{
	int	type;
	TkVar*	link;
	void*	value;
	char	name[TKSTRUCTALIGN];
};

struct TkPanelimage
{
	void*		image;		/* Image paired with Draw_Image: see lookupimage in libinterp/draw.c */
	int			ref;
	TkPanelimage*	link;
};

struct TkMouse
{
	int		x;
	int		y;
	int		b;
};

struct TkCmdtab
{
	char*		name;
	char*		(*fn)(Tk*, char*, char**);
};

struct TkWinfo
{
	Tk*		w;
	Rectangle	r;
};

struct TkAction
{
	int		event;
	int		type;
	char*		arg;
	TkAction*	link;
};

struct TkStab
{
	char*		val;
	int		con;
};

struct TkOption
{
	char*		o;
	int		type;
	int		offset;
	void*		aux;
};

struct TkOptab
{
	void*		ptr;
	TkOption*	optab;	
};

enum
{
	/* Widget Control Bits */
	Tktop		= (1<<0),
	Tkbottom	= (1<<1),
	Tkleft		= (1<<2),
	Tkright		= (1<<3),
	Tkside		= Tktop|Tkbottom|Tkleft|Tkright,
	Tkfillx		= (1<<4),
	Tkfilly		= (1<<5),
	Tkfill		= Tkfillx|Tkfilly,
	Tkexpand	= (1<<6),
	Tkrefresh	= (1<<7),
	Tknoprop	= (1<<8),
	Tkbaseline 	= (1<<10),
	Tknumeric	= (1<<11),

	Tknorth		= (1<<10),
	Tkeast		= (1<<11),
	Tksouth		= (1<<12),
	Tkwest		= (1<<13),
	Tkcenter		= 0,
	Tkanchor	= Tknorth|Tkeast|Tksouth|Tkwest,
	Tksuspended	= (1<<14),		/* window suspended pending resize */

	Tkgridpack	= (1<<17),		/* temporary flag marking addition to grid */
	Tkgridremove	= (1<<18),		/* marked for removal from grid */
	Tktakefocus	= (1<<19),
	Tktransparent		= (1<<20),	/* Doesn't entirely obscure its background */
	Tkwindow	= (1<<21),	/* Top level window */
	Tkactive		= (1<<22),	/* Pointer is over active object */
	Tkactivated	= (1<<23),	/* Button pressed etc.. */
	Tkdisabled	= (1<<24),	/* Button is not accepting events */
	Tkmapped	= (1<<25),	/* Mapped onto display */
	Tknograb		= (1<<26),
	Tkdestroy		= (1<<27),	/* Marked for death */
	Tksetwidth	= (1<<28),
	Tksetheight	= (1<<29),
	Tksubsub	= (1<<30),
	Tkswept		= (1<<31),

	/* Supported Event Types 		*/
	/*
	 * Bits 0-15 are keyboard characters
	 * but duplicated by other events, as we can distinguish
	 * key events from others with the TkKey bit.
	 * N.B. make sure that this distinction *is* made;
	 * i.e.
	 *	if (event & TkButton1P)
	 *   is no longer sufficient to test for button1 down.
	 *
	 * 	if (!(event & TkKey) && (event & TkButton1P))
	 *   would be better.
	 */
	TkButton1P	= (1<<0),
	TkButton1R	= (1<<1),
	TkButton2P	= (1<<2),
	TkButton2R	= (1<<3),
	TkButton3P	= (1<<4),
	TkButton3R	= (1<<5),
	TkButton4P	= (1<<6),
	TkButton4R	= (1<<7),
	TkButton5P	= (1<<8),
	TkButton5R	= (1<<9),
	TkButton6P	= (1<<10),
	TkButton6R	= (1<<11),
	/*
	 * 12-15 reserved for more buttons.
	 */
	TkExtn1		= (1<<16),
	TkExtn2		= (1<<17),
	TkTakefocus	= (1<<18),
	/*
	 * 19-20 currently free
	 */
	TkDestroy		= (1<< 21),
	TkEnter		= (1<<22),
	TkLeave		= (1<<23),
	TkMotion	= (1<<24),
	TkMap		= (1<<25),
	TkUnmap		= (1<<26),
	TkKey		= (1<<27),
	TkFocusin	= (1<<28),
	TkFocusout	= (1<<29),
	TkConfigure	= (1<<30),
	TkDouble	= (1<<31),
	TkEmouse	= TkButton1P|TkButton1R|TkButton2P|TkButton2R|
			TkButton3P|TkButton3R|
			TkButton4P|TkButton4R|
			TkButton5P|TkButton5R|
			TkButton6P|TkButton6R|TkMotion,
	TkEpress	= TkButton1P|TkButton2P|TkButton3P|
			TkButton4P|TkButton5P|TkButton6P,
	TkErelease	= TkButton1R|TkButton2R|TkButton3R|
					TkButton4R|TkButton5R|TkButton6R,
	TkExtns	= TkExtn1|TkExtn2,
	TkAllEvents	= ~0,

	TkCforegnd	= 0,
	TkCbackgnd,			/* group of 3 */
	TkCbackgndlght,
	TkCbackgnddark,
	TkCselect,
	TkCselectbgnd,			/* group of 3 */
	TkCselectbgndlght,
	TkCselectbgnddark,
	TkCselectfgnd,
	TkCactivebgnd,		/* group of 3 */
	TkCactivebgndlght,
	TkCactivebgnddark,
	TkCactivefgnd,
	TkCdisablefgnd,
	TkChighlightfgnd,
	TkCfill,
	TkCtransparent,

	TkNcolor,

	TkSameshade	= 0,		/* relative shade for tkgshade() and tkrgbashade()*/
	TkLightshade,
	TkDarkshade
};


struct TkEnv
{
	int		ref;
	TkTop*		top;			/* Owner */
	ulong		set;
	ulong		colors[TkNcolor];	/* OPTcolr */
	Font*		font;			/* Font description */
	int		wzero;			/* Width of "0" in pixel */
};

struct TkGeom
{
	int		x;
	int		y;
	int		width;
	int		height;
};

struct TkGridbeam {
	int		equalise;
	int		minsize;
	int		maxsize;
	int		weight;
	int		pad;
	int		act;
	char*	name;
};

struct TkGridcell {
	Tk*		tk;
	Point		span;
};

struct TkGrid {
	TkGridcell**	cells;		/* 2D array of cells, y major, x minor */
	Point			dim;		/* dimensions of table */
	TkGridbeam*	rows;
	TkGridbeam*	cols;
	Point			origin;	/* top left point grid was rendered at */
};

struct Tk
{
	int		type;		/* Widget type */
	TkName*		name;		/* Hierarchy name */
	Tk*		siblings;	/* Link to descendents */
	Tk*		master;		/* Pack owner */
	Tk*		slave;		/* Packer slaves */
	Tk*		next;		/* Link for packer slaves */
	Tk*		parent;		/* Window is sub of canvas or text */
	Tk*		depth;		/* Window depth when mapped */
	void		(*geom)(Tk*, int, int, int, int);		/* Geometry change notify function */
	void		(*destroyed)(Tk*);		/* Destroy notify function */
	int		flag;		/* Misc flags. */
	TkEnv*		env;		/* Colors & fonts */
	TkAction*	binds;		/* Binding of current events */

	TkGeom		req;		/* Requested size and position */
	TkGeom		act;		/* Actual size and position */
	int		relief;		/* 3D border type */
	int		borderwidth;	/* 3D border size */
	int		highlightwidth;
	Point		pad;		/* outside frame padding */
	Point		ipad;		/* inside frame padding */
	Rectangle	dirty;	/* dirty rectangle, relative to widget */
	TkGrid*	grid;		/* children are packed in a grid */

//	char		obj[TKSTRUCTALIGN];
};

struct TkWin
{
	Image*	image;
	Tk*		next;
	Point		act;
	Point		req;
	void*	di;		/* !=H if it's been set externally */
	int		changed;	/* requested rect has changed since request sent */
	int		reqid;	/* id of request most recently sent out; replies to earlier requests are ignored */

	/* menu specific members */
	Tk*		slave;
	char*		postcmd;
	char*		cascade;
	int			freeonunmap;
	char			*cbname;		/* name of choicebutton that posted this */

	Point			delta;
	int			speed;
	int			waiting;
};

struct TkMethod
{
	char*		name;
	TkCmdtab*	cmd;
	void		(*free)(Tk*);
	char*	(*draw)(Tk*, Point);
	void		(*geom)(Tk*);
	void		(*getimgs)(Tk*, Image**, Image**);

	void		(*focusorder)(Tk*);	/* add any focusable descendants to the focus order */
	void		(*dirtychild)(Tk*);		/* Child notifies parent to redraw */
	Point		(*relpos)(Tk*);
	Tk*		(*deliver)(Tk*, int, void*);
	void		(*see)(Tk*, Rectangle*, Point*);
	Tk*		(*inwindow)(Tk*, Point*);
	void		(*varchanged)(Tk*, char*, char*);
	int		ncmd;
};

struct TkName
{
	TkName*		link;
	void*		obj;		/* Name for ... */
	union {
		TkAction*	binds;
	}prop;				/* Properties for ... */
	int		ref;
	char		name[TKSTRUCTALIGN];
};

struct TkTtabstop
{
	int		pos;
	int		justify;
	TkTtabstop*	next;
};

struct TkCol
{
	ulong	rgba;
	Image*	i;
	TkCol*	forw;
};

struct TkCtxt
{
	void*	lock;
	Display*	display;
	int		ncol;
	TkCol*	chead;
	TkCol*	ctail;
	Image*	i;			/* temporary image for drawing buttons, etc */
	Image*	ia;			/* as above, but with an alpha channel */
	Tk*		tkkeygrab;

	int		focused;
	Tk*		mfocus;
	Tk*		mgrab;
	Tk*		entered;
	TkMouse	mstate;

	Tk*		tkmenu;
	void*	extn;
};

struct TkTop
{
	void*	dd;	/* really Draw_Display */
	void*	wreq;	/* really chan of string */
	void*	di;		/* really Draw_Image* */
	void*	wmctxt;	/* really Draw_Wmcontext */
	Rectangle	screenr;	/* XXX sleazy equiv to Draw_Rect, but what else? */

	/* Private from here on */
	TkCtxt*		ctxt;
	Display*	display;
	Tk*		root;			/* list of all objects, linked by siblings; first object is "." */
	Tk*		windows;
	Tk**		focusorder;
	int		nfocus;
	TkEnv*		env;
	TkTop*		link;
	TkVar*		vars;
	TkImg*		imgs;
	TkPanelimage*	panelimages;
	TkAction*	binds[TKwidgets];
	int		debug;
	int		execdepth;
	char		focused;
	char		dirty;
	char		noupdate;
	char*	err;
	char		errcmd[32];
	char		errx[32];
};

#define TKobj(t, p)	((t*)((p)+1))
//#define TKobj(t, p)	((t*)(p->obj))
#define OPTION(p, t, o)	(*(t*)((char*)p + o))

/* Command entry points */
extern	char*	tkbind(TkTop*, char*, char**);
extern	char*	tkbutton(TkTop*, char*, char**);
extern	char*	tkcanvas(TkTop*, char*, char**);
extern	char*	tkcheckbutton(TkTop*, char*, char**);
extern	char*	tkchoicebutton(TkTop*, char*, char**);
extern	char*	tkcursorcmd(TkTop*, char*, char**);
extern	char*	tkdestroy(TkTop*, char*, char**);
extern	char*	tkentry(TkTop*, char*, char**);
extern	char*	tkfocus(TkTop*, char*, char**);
extern	char*	tkframe(TkTop*, char*, char**);
extern	char*	tkgrab(TkTop*, char*, char**);
extern	char*	tkgrid(TkTop*, char*, char**);
extern	char*	tkimage(TkTop*, char*, char**);
extern	char*	tklabel(TkTop*, char*, char**);
extern	char*	tklistbox(TkTop*, char*, char**);
extern	char*	tklower(TkTop*, char*, char**);
extern	char*	tkmenu(TkTop*, char*, char**);
extern	char*	tkmenubutton(TkTop*, char*, char**);
extern	char*	tkpack(TkTop*, char*, char**);
extern	char*	tkpanel(TkTop*, char*, char**);
extern	char*	tkputs(TkTop*, char*, char**);
extern	char*	tkradiobutton(TkTop*, char*, char**);
extern	char*	tkraise(TkTop*, char*, char**);
extern	char*	tkscale(TkTop*, char*, char**);
extern	char*	tkscrollbar(TkTop*, char*, char**);
extern	char*	tksend(TkTop*, char*, char**);
extern	char*	tktext(TkTop*, char*, char**);
extern	char*	tkupdatecmd(TkTop*, char*, char**);
extern	char*	tkvariable(TkTop*, char*, char**);
extern	char*	tkwinfo(TkTop*, char*, char**);

extern	TkMethod	*tkmethod[];

/* Errors - xdata.c*/
extern	char	TkNomem[];
extern	char 	TkBadop[];
extern	char 	TkOparg[];
extern	char 	TkBadvl[];
extern	char 	TkBadwp[];
extern	char 	TkNotop[];
extern	char	TkDupli[];
extern	char	TkNotpk[];
extern	char	TkBadcm[];
extern	char	TkIstop[];
extern	char	TkBadbm[];
extern	char	TkBadft[];
extern	char	TkBadit[];
extern	char	TkBadtg[];
extern	char	TkFewpt[];
extern	char	TkBadsq[];
extern	char	TkBadix[];
extern	char	TkNotwm[];
extern	char	TkWpack[];
extern	char	TkBadvr[];
extern	char	TkNotvt[];
extern	char	TkMovfw[];
extern	char	TkBadsl[];
extern	char	TkSyntx[];
extern	char TkRecur[];
extern	char TkDepth[];
extern	char TkNomaster[];
extern	char TkNotgrid[];
extern	char TkIsgrid[];
extern	char TkBadgridcell[];
extern	char TkBadspan[];
extern	char TkBadcursor[];

/* Option tables - xdata.c */
extern	TkStab	tkanchor[];
extern	TkStab	tkbool[];
extern	TkStab	tkcolortab[];
extern	TkStab	tkjustify[];
extern	TkStab	tkorient[];
extern	TkStab	tkrelief[];
extern	TkStab	tktabjust[];
extern	TkStab	tkwrap[];
extern	TkOption	tkgeneric[];
extern	TkOption	tktop[];
extern	TkOption	tktopdbg[];

/* panel.c */
extern	void		tkgetpanelimage(Tk*, Image**, Image**);
extern	void		tksetpanelimage(Tk *tk, Image*, Image*);

/* General - colrs.c */
extern	void		tksetenvcolours(TkEnv*);

/* General - ebind.c */
extern	void		tkcmdbind(Tk*, int, char*, void*);
extern	TkCtxt*		tkdeldepth(Tk*);
extern	char*		tkdestroy(TkTop*, char*, char**);
extern	char*		tkbindings(TkTop*, Tk*, TkEbind*, int);
extern	int		tkseqparse(char*);
extern	void		tksetkeyfocus(TkTop*, Tk*, int);
extern	void		tksetglobalfocus(TkTop*, int);

/* General - image.c */
extern	TkImg*		tkname2img(TkTop*, char*);
extern	void		tkimgput(TkImg*);
extern	void		tksizeimage(Tk*, TkImg*);
extern	TkImg*		tkauximage(TkTop*, char*, uchar*, int, int, Rectangle, int);

/* choicebuttons - menus.c */
extern	Tk*		tkfindchoicemenu(Tk*);

/* General - packr.c */
extern	void		tkdelpack(Tk*);
extern	void		tkappendpack(Tk*, Tk*, int);
extern	void		tkpackqit(Tk*);
extern	void		tkrunpack(TkTop*);
extern	void		tksetslavereq(Tk*, TkGeom);
extern	int		tkisslave(Tk*, Tk*);

/* General - grids.c */
extern	int		tkgridder(Tk*);
extern	void		tkgriddelslave(Tk*);
extern	char*	tkpropagate(TkTop*, char*);
extern	void		tkfreegrid(TkGrid*);

/* General - parse.c */
extern	char*		tkconflist(TkOptab*, char**);
extern	char*		tkskip(char*, char*);
extern	char*		tkword(TkTop*, char*, char*, char*, int*);
extern	char*		tkxyparse(Tk*, char**, Point*);
extern	char*		tkparse(TkTop*, char*, TkOptab*, TkName**);
extern	TkName*		tkmkname(char*);
extern	char*		tkgencget(TkOptab*, char*, char**, TkTop*);
extern	char*		tkparsecolor(char*, ulong*);

/* General - utils.c */
extern	Image*		tkgc(TkEnv*, int);
extern	Image*		tkgshade(TkEnv*, int, int);
extern	Image*		tkcolor(TkCtxt*, ulong);
extern	void			tkclear(Image*, Rectangle);
extern	TkEnv*		tknewenv(TkTop*);
extern	TkEnv*		tkdefaultenv(TkTop*);
extern	void		tkputenv(TkEnv*);
extern	TkEnv*		tkdupenv(TkEnv**);
extern	Tk*		tknewobj(TkTop*, int, int);
extern	void		tkfreebind(TkAction*);
extern	void		tkfreename(TkName*);
extern	void		tkfreeobj(Tk*);
extern	char*		tkaddchild(TkTop*, Tk*, TkName**);
extern	Tk*		tklook(TkTop*, char*, int);
extern	void		tktextsdraw(Image*, Rectangle, TkEnv*, int);
extern	void		tkbox(Image*, Rectangle, int, Image*);
extern	void		tkbevel(Image*, Point, int, int, int, Image*, Image*);
extern	void		tkdrawrelief(Image*, Tk*, Point, int, int);
extern	Point		tkstringsize(Tk*, char*);
extern	char*		tkdrawstring(Tk*, Image*, Point, char*, int, Image *, int);
extern	int		tkeventfmt(Fmt*);
extern	Tk*		tkdeliver(Tk*, int, void*);
extern	int		tksubdeliver(Tk*, TkAction*, int, void*, int);
extern	void		tkcancel(TkAction**, int);
extern	char*		tkaction(TkAction**, int, int, char*, int);
extern	char*		tkitem(char*, char*);
extern	int		tkismapped(Tk*);
extern	Point		tkposn(Tk*);
extern	Point		tkscrn2local(Tk*, Point);
extern	int		tkvisiblerect(Tk *tk, Rectangle *rr);
extern	Point		tkanchorpoint(Rectangle, Point, int);
extern	char*		tkfrac(char**, int*, TkEnv*);
extern	char*		tkfracword(TkTop*, char**, int*, TkEnv*);
extern	char*		tkfprint(char*, int);
extern	char*		tkvalue(char**, char*, ...);
extern	void		tkdirty(Tk *);
extern	void		tksorttable(void);
extern	char*		tkexec(TkTop*, char*, char**);
extern	int		tkeventfmt(Fmt*);
extern	void		tkerr(TkTop*, char*);
extern	char*	tkerrstr(TkTop*, char*);
extern	char*	tkcursorswitch(TkTop*, Image*, TkImg*);
extern	void		tkcursorset(TkTop*, Point);
extern	char*	tksetmgrab(TkTop*, Tk*);
extern	int 		tkinsidepoly(Point*, int, int, Point);
extern	int		tklinehit(Point*, int, int, Point);
extern	int		tkiswordchar(int);
extern	int		tkhaskeyfocus(Tk*);
extern	Rectangle	tkrect(Tk*, int);
extern	int		tkchanhastype(ulong, int);
extern	int		tkhasalpha(TkEnv*, int);
extern	void		tksettransparent(Tk*, int);
extern	ulong	tkrgba(int, int, int, int);
extern	ulong	tkrgbashade(ulong, int);
extern	void		tkrgbavals(ulong, int*, int*, int*, int*);
extern	void		tkrepeat(Tk*, void(*)(Tk*, void*, int), void*, int, int);
extern	void		tkcancelrepeat(Tk*);
extern	void		tkblink(Tk*, void(*)(Tk*, int));
extern	void		tkblinkreset(Tk*);
extern	char*	tkname(Tk*);

/* General - windw.c */
extern	TkCtxt*		tknewctxt(Display*);
extern	void		tkfreectxt(TkCtxt*);
extern	void		tkfreecolcache(TkCtxt*);
extern	Image*		tkitmp(TkEnv*, Point, int);
extern	void		tkgeomchg(Tk*, TkGeom*, int);
extern	Tk*		tkinwindow(Tk*, Point, int);
extern	Tk*		tkfindfocus(TkTop*, int, int, int);
extern	char*		tkdrawslaves(Tk*, Point, int*);
extern	char*		tkupdate(TkTop*);
extern	int		tkischild(Tk*, Tk*);
extern	void		tksetbits(Tk*, int);
extern	char*		tkmap(Tk*);
extern	void		tkunmap(Tk*);
extern	void		tkmoveresize(Tk*, int, int, int, int);
extern	int		tkupdatewinsize(Tk*);
extern	void		tkmovewin(Tk*, Point);
extern	Image*		tkimageof(Tk*);
extern	void		tktopopt(Tk*, char*);
extern	void		tkdirtyfocusorder(TkTop*);
extern	void		tkbuildfocusorder(TkTop*);
extern	void		tksortfocusorder(TkWinfo*, int);
extern	void		tkappendfocusorder(Tk*);
extern	void		tksee(Tk*, Rectangle, Point);
extern	char*	tkseecmd(TkTop*, char*, char**);

/* Style specific extensions - extns.c */
extern	int		tkextndeliver(Tk*, TkAction*, int, void*);
extern	void		tkextnfreeobj(Tk*);
extern	int		tkextnnewctxt(TkCtxt*);
extern	void		tkextnfreectxt(TkCtxt*);
extern	char*	tkextnparseseq(char*, char*, int*);

/* External to libtk */
extern	void		tkenterleave(TkTop*);
extern	void		tksetwinimage(Tk*, Image*);
extern	void		tkdestroywinimage(Tk*);
extern	void		tkfreevar(TkTop*, char*, int);
extern	TkVar*		tkmkvar(TkTop*, char*, int);
extern	int		tktolimbo(void*, char*);
extern	void		tkwreq(TkTop*, char*, ...);
extern	void		tkdelpanelimage(TkTop*, Image*);

extern	TkMethod		framemethod;
extern	TkMethod		labelmethod;
extern	TkMethod		checkbuttonmethod;
extern	TkMethod		buttonmethod;
extern	TkMethod		menubuttonmethod;
extern	TkMethod		menumethod;
extern	TkMethod		separatormethod;
extern	TkMethod		cascademethod;
extern	TkMethod		listboxmethod;
extern	TkMethod		scrollbarmethod;
extern	TkMethod		textmethod;
extern	TkMethod		canvasmethod;
extern	TkMethod		entrymethod;
extern	TkMethod		radiobuttonmethod;
extern	TkMethod		scalemethod;
extern	TkMethod		panelmethod;
extern	TkMethod		choicebuttonmethod;