File: pmsg.c

package info (click to toggle)
treetool 2.0.2-1
  • links: PTS
  • area: non-free
  • in suites: potato
  • size: 3,460 kB
  • ctags: 2,692
  • sloc: ansic: 26,504; makefile: 212
file content (158 lines) | stat: -rw-r--r-- 2,385 bytes parent folder | download | duplicates (5)
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
#include <stdio.h>

#include <xview/xview.h>
#include <xview/panel.h>
#include "generic.h"

typedef struct {
	ltgenericd g;
	Panel_item t;	/* xview panel item */
	int (*do_events)();
	} ltpmsgd, *ltpmsg;

int tpmsg_right_side(t)
ltpmsg t;
{
	/* check type */
	if(t==NULL)
		return(0);
	if(titem_type(t)!=lt_pmsg)
		return(0);
	
	return(xv_get(t->t, XV_X)+xv_get(t->t, XV_WIDTH));
}

int tpmsg_bottom_side(t)
ltpmsg t;
{
	/* check type */
	if(t==NULL)
		return(0);
	if(titem_type(t)!=lt_pmsg)
		return(0);
	
	return(xv_get(t->t, XV_Y)+xv_get(t->t, XV_HEIGHT));
}

tpmsg tpmsg_new(parent, x,y,w,h,right,below, name)
tpanel parent;
int x,y,w,h;
titem right,below;
char *name;
{
	ltpmsg tmp;

	/* check types */
	if(parent==NULL)
		return(NULL);
	if(titem_type(parent)!=lt_panel)
		return(NULL);
	
	if(name==NULL)
		name="Message Item";
	
	tmp=(ltpmsg)titem_new(parent, lt_pmsg, sizeof(ltpmsgd));
	if(tmp==NULL)
		return(NULL);
	
	tmp->t=(Panel_item)xv_create(tpanel_xview(parent), PANEL_MESSAGE,
		PANEL_LABEL_STRING, name,
		PANEL_LAYOUT, PANEL_HORIZONTAL,
		XV_WIDTH, w,
		XV_HEIGHT, h,
		NULL);
	
	if(right!=NULL)
		x=tp_right_side(right);
	if(below!=NULL)
		y=tp_bottom_side(below);

	xv_set(tmp->t,
		XV_X, x,
		XV_Y, y,
		PANEL_CLIENT_DATA, tmp,
		NULL);

	tmp->do_events=NULL;

	return(tmp);
}

int tpmsg_free(t)
ltpmsg t;
{
	/* check type */
	if(t==NULL)
		return(0);
	if(titem_type(t)!=lt_pmsg)
		return(0);
	
	xv_destroy_safe(t->t);
	return(titem_free(t));
}

int tpmsg_enable(t)
ltpmsg t;
{
	/* check type */
	if(t==NULL)
		return(0);
	if(titem_type(t)!=lt_pmsg)
		return(0);
	
	xv_set(t->t, PANEL_INACTIVE, FALSE, NULL);
	return(1);
}

int tpmsg_disable(t)
ltpmsg t;
{
	/* check type */
	if(t==NULL)
		return(0);
	if(titem_type(t)!=lt_pmsg)
		return(0);
	
	xv_set(t->t, PANEL_INACTIVE, TRUE, NULL);
	return(1);
}

int tpmsg_change_message(t, s)
ltpmsg t;
char *s;
{
	/* check type */
	if(t==NULL)
		return(0);
	if(titem_type(t)!=lt_pmsg)
		return(0);
	
	xv_set(t->t, PANEL_LABEL_STRING, s, NULL);
	return(1);
}

int tpmsg_set_bold(t)
ltpmsg t;
{
	/* check type */
	if(t==NULL)
		return(0);
	if(titem_type(t)!=lt_pmsg)
		return(0);
	
	xv_set(t->t, PANEL_LABEL_BOLD, TRUE, NULL);
	return(1);
}

int tpmsg_set_nobold(t)
ltpmsg t;
{
	/* check type */
	if(t==NULL)
		return(0);
	if(titem_type(t)!=lt_pmsg)
		return(0);
	
	xv_set(t->t, PANEL_LABEL_BOLD, FALSE, NULL);
	return(1);
}