summaryrefslogtreecommitdiff
path: root/libtk/label.h
blob: 7824ecece51164df7ca4f69a2f43e3475bf58141 (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
typedef struct TkLabel TkLabel;

/*
 * widgets that use the label code:
 *	label
 *	checkbutton
 *	button
 *	menubutton
 *	separator
 *	cascade
 *	radiobutton
 */

struct TkLabel
{
	char*		text;		/* Label value */
	Image*		bitmap;		/* Bitmap to display */
	TkImg*		img;
	int			justify;
	int			anchor;
//	int			flags;		/* justify/anchor */
	int		w;
	int		h;
	int		textheight;

	/* button fields */
	char*		command;	/* Command to execute at invoke */
	char*		value;		/* Variable value in radio button */
	char*		offvalue;		/* Off value for check button */
	char*		variable;		/* Variable name in radio button */
	int		ul;
	int		check;		/* check/radiobutton/choicebutton state */
	int		indicator;		/* -indicatoron setting */
	char*		menu;

	char**	values;
	int nvalues;
	/* current value of choicebutton is represented by check */
};

/* Layout constants */
enum {
	Textpadx	= 3,
	Textpady	= 0,
	Bitpadx	= 0,	/* Bitmap padding in labels */
	Bitpady	= 0,
	CheckButton	= 10,
	CheckButtonBW	= 1,
	ButtonBorder	= 4,
	CheckSpace = CheckButton + 2*CheckButtonBW + 2*ButtonBorder,
};

extern	TkOption	tkbutopts[];
extern	TkOption	tkradopts[];
extern	TkOption	tkcbopts[];

/* label.c */
extern	void		tksizelabel(Tk*);
extern	char*	tkdrawlabel(Tk*, Point);
extern	void		tkfreelabel(Tk*);
extern	void		tklabelgetimgs(Tk*, Image**, Image**);
extern	char*	tksetvar(TkTop*, char*, char*);

/* buton.c */
extern	Tk*	tkmkbutton(TkTop*, int);
extern	void	tksizebutton(Tk*);
extern	char*	tkdrawbutton(Tk*, Point);
extern	char*	tkbuttoninvoke(Tk*, char*, char**);
extern	char*	tkradioinvoke(Tk*, char*, char**);
extern	void		tkfreebutton(Tk*);

/* support for menus */
extern	int		tklabelmargin(Tk*);
extern	int		tkbuttonmargin(Tk*);