1 |
root |
1.1 |
#include <Defines.h> /* off */ |
2 |
|
|
#include <global.h> |
3 |
|
|
#include <debug.h> |
4 |
|
|
#include <Cnv.h> |
5 |
|
|
#include <CrFaceP.h> |
6 |
|
|
#include <CrUtil.h> |
7 |
|
|
|
8 |
|
|
/********************************************************************** |
9 |
|
|
* resources |
10 |
|
|
**********************************************************************/ |
11 |
|
|
|
12 |
|
|
#define Offset(field) XtOffsetOf(CrFaceRec,crFace.field) |
13 |
|
|
static XtResource resources[] = { |
14 |
|
|
{ XtNobject,XtCObject,XtRPointer,sizeof(XtPointer), /* caddr_t ??? */ |
15 |
|
|
Offset(ob),XtRPointer,NULL }, |
16 |
|
|
{ XtNadjust,XtCAdjust,XtRBool,sizeof(Boolean), |
17 |
|
|
Offset(adjust),XtRString,"true" }, |
18 |
|
|
}; |
19 |
|
|
#undef Offset |
20 |
|
|
|
21 |
|
|
static void ClassInitialize(); |
22 |
|
|
static void Initialize(Widget req,Widget new,Arg args[],Cardinal *num); |
23 |
|
|
static void Destroy(Widget w); |
24 |
|
|
static void Resize(Widget w); |
25 |
|
|
static void Redisplay(Widget w,XEvent *event,Region region); |
26 |
|
|
static Boolean SetValues(Widget cur,Widget req,Widget new, |
27 |
|
|
Arg args[],Cardinal *num); |
28 |
|
|
|
29 |
|
|
/********************************************************************** |
30 |
|
|
* class structure |
31 |
|
|
**********************************************************************/ |
32 |
|
|
|
33 |
|
|
CrFaceClassRec crFaceClassRec = { |
34 |
|
|
{ /****** Core ******/ |
35 |
|
|
/* superclass */ (WidgetClass) &widgetClassRec, |
36 |
|
|
/* class_name */ "CrFace", |
37 |
|
|
/* widget_size */ sizeof(CrFaceRec) , |
38 |
|
|
/* class_initialize */ ClassInitialize , |
39 |
|
|
/* class_part_initialize */ NULL , |
40 |
|
|
/* class_inited */ FALSE , |
41 |
|
|
/* initialize */ Initialize, |
42 |
|
|
/* initialize_hook */ NULL, |
43 |
|
|
/* realize */ XtInheritRealize, |
44 |
|
|
/* actions */ NULL, |
45 |
|
|
/* num_actions */ 0 , |
46 |
|
|
/* resources */ resources, |
47 |
|
|
/* num_resources */ XtNumber(resources), |
48 |
|
|
/* xrm_class */ NULLQUARK, |
49 |
|
|
/* compress_motion */ TRUE, |
50 |
|
|
/* compress_exposure */ TRUE, |
51 |
|
|
/* compress_enterleave */ TRUE, |
52 |
|
|
/* visible_interest */ FALSE, |
53 |
|
|
/* destroy */ Destroy, |
54 |
|
|
/* resize */ Resize, |
55 |
|
|
/* expose */ Redisplay, |
56 |
|
|
/* set_values */ SetValues, |
57 |
|
|
/* set_values_hook */ NULL, |
58 |
|
|
/* set_values_almost */ XtInheritSetValuesAlmost, |
59 |
|
|
/* get_values_hook */ NULL, |
60 |
|
|
/* accept_focus */ NULL, |
61 |
|
|
/* version */ XtVersion, |
62 |
|
|
/* callback_private */ NULL, |
63 |
|
|
/* tm_table */ NULL, |
64 |
|
|
/* query_geometry */ XtInheritQueryGeometry, |
65 |
|
|
/* display_accelerator */ XtInheritDisplayAccelerator, |
66 |
|
|
/* extension */ NULL |
67 |
|
|
}, |
68 |
|
|
{ /****** CrFace ******/ |
69 |
|
|
/* empty */ 0, |
70 |
|
|
} |
71 |
|
|
}; |
72 |
|
|
|
73 |
|
|
WidgetClass crFaceWidgetClass = (WidgetClass)&crFaceClassRec; |
74 |
|
|
|
75 |
|
|
/********************************************************************** |
76 |
|
|
* privates |
77 |
|
|
**********************************************************************/ |
78 |
|
|
|
79 |
|
|
static int DrawObject(Widget wd, int x, int y, object * tmp) |
80 |
|
|
{ |
81 |
|
|
CrFaceWidget w = (CrFaceWidget)wd; |
82 |
|
|
|
83 |
|
|
if (!tmp) |
84 |
|
|
tmp = &empty_archetype->clone; |
85 |
|
|
|
86 |
|
|
DrawPartObject(wd, w->crFace.gc, tmp, x * FontSize, y * FontSize); |
87 |
|
|
return (0); |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
static void GetConst(Widget w,int *minx,int *miny,int *maxx,int *maxy) |
91 |
|
|
{ |
92 |
|
|
#if 0 |
93 |
|
|
archetype *at; |
94 |
|
|
CrFaceWidget self = (CrFaceWidget)w; |
95 |
|
|
|
96 |
|
|
if(self->crFace.ob == NULL) return; |
97 |
|
|
*minx = 0, *miny = 0, *maxx = 0, *maxy = 0; |
98 |
|
|
for (at = self->crFace.ob->arch; at; at = at->more) { |
99 |
|
|
if (*maxx < at->clone.x) *maxx = at->clone.x; |
100 |
|
|
if (*maxy < at->clone.y) *maxy = at->clone.x; |
101 |
|
|
if (*minx > at->clone.x) *minx = at->clone.x; |
102 |
|
|
if (*miny > at->clone.y) *miny = at->clone.y; |
103 |
|
|
} |
104 |
|
|
#else |
105 |
|
|
object *obj; |
106 |
|
|
CrFaceWidget self = (CrFaceWidget)w; |
107 |
|
|
|
108 |
|
|
if(self->crFace.ob == NULL) return; |
109 |
|
|
*minx = 0, *miny = 0, *maxx = 0, *maxy = 0; |
110 |
|
|
for (obj = self->crFace.ob; obj; obj = obj->more) { |
111 |
|
|
if (*maxx < obj->x) *maxx = obj->x; |
112 |
|
|
if (*maxy < obj->y) *maxy = obj->y; |
113 |
|
|
if (*minx > obj->x) *minx = obj->x; |
114 |
|
|
if (*miny > obj->y) *miny = obj->y; |
115 |
|
|
} |
116 |
|
|
#endif |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
static void GetSize(Widget w,Dimension *width,Dimension *height) |
120 |
|
|
{ |
121 |
|
|
CrFaceWidget self = (CrFaceWidget)w; |
122 |
|
|
int minx, miny, maxx,maxy; |
123 |
|
|
|
124 |
|
|
if(!self->crFace.ob) return; |
125 |
|
|
GetConst(w,&minx,&miny,&maxx,&maxy); |
126 |
|
|
*width = (maxx - minx + 1) * FontSize; |
127 |
|
|
*height = (maxy - miny + 1) * FontSize; |
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
/********************************************************************** |
131 |
|
|
* members |
132 |
|
|
**********************************************************************/ |
133 |
|
|
|
134 |
|
|
static void ClassInitialize() |
135 |
|
|
{ |
136 |
|
|
debug0 ("ClassInitialize()\n"); |
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
static void Initialize(Widget req,Widget new,Arg args[],Cardinal *num) |
140 |
|
|
{ |
141 |
|
|
CrFaceWidget w = (CrFaceWidget)new; |
142 |
|
|
|
143 |
|
|
/* NULLed allowed */ |
144 |
|
|
if(w->crFace.ob == NULL) |
145 |
|
|
w->core.width = 1; |
146 |
|
|
|
147 |
|
|
if(w->core.width < 10) w->core.width = 96; |
148 |
|
|
if(w->core.height < 10) w->core.height = 48; |
149 |
|
|
|
150 |
|
|
if(w->crFace.adjust) GetSize(new,&(w->core.width),&(w->core.height)); |
151 |
|
|
w->crFace.gc = GCCreate (new); |
152 |
|
|
debug0 ("CrFace-Initialize()\n"); |
153 |
|
|
} |
154 |
|
|
|
155 |
|
|
static void Destroy(Widget w) |
156 |
|
|
{ |
157 |
|
|
debug("Destroy()\n"); |
158 |
|
|
} |
159 |
|
|
|
160 |
|
|
static void Resize(Widget w) |
161 |
|
|
{ |
162 |
|
|
debug("Resize()\n"); |
163 |
|
|
} |
164 |
|
|
|
165 |
|
|
|
166 |
|
|
static void Redisplay(Widget w,XEvent *event,Region region) |
167 |
|
|
{ |
168 |
|
|
#if 0 |
169 |
|
|
CrFaceWidget self = (CrFaceWidget)w; |
170 |
|
|
archetype *at; |
171 |
|
|
int minx = 0, miny = 0, maxx = 0,maxy; |
172 |
|
|
|
173 |
|
|
debug("Redisplay()\n"); |
174 |
|
|
if(self->crFace.ob == NULL) { |
175 |
|
|
XClearWindow(XtDisplay(w),XtWindow(w)); |
176 |
|
|
return; |
177 |
|
|
} |
178 |
|
|
|
179 |
|
|
GetConst(w,&minx,&miny,&maxx,&maxy); |
180 |
|
|
for (at = self->crFace.ob->arch;at; at = at->more) { |
181 |
|
|
DrawObject (w, |
182 |
|
|
at->clone.x - minx, |
183 |
|
|
at->clone.y - miny, |
184 |
|
|
&at->clone); |
185 |
|
|
} |
186 |
|
|
#else |
187 |
|
|
CrFaceWidget self = (CrFaceWidget)w; |
188 |
|
|
object *obj; |
189 |
|
|
int minx = 0, miny = 0, maxx = 0,maxy; |
190 |
|
|
int x,y; |
191 |
|
|
|
192 |
|
|
if (event->xexpose.count!=0) return; |
193 |
|
|
debug("Redisplay()\n"); |
194 |
|
|
if(self->crFace.ob == NULL) { |
195 |
|
|
XClearWindow(XtDisplay(w),XtWindow(w)); |
196 |
|
|
return; |
197 |
|
|
} else { |
198 |
|
|
GetConst(w,&minx,&miny,&maxx,&maxy); |
199 |
|
|
x = self->crFace.ob->x - minx; |
200 |
|
|
y = self->crFace.ob->y - miny; |
201 |
|
|
for (obj = self->crFace.ob;obj; obj = obj->more) { |
202 |
|
|
DrawObject (w, |
203 |
|
|
obj->x - minx - x, |
204 |
|
|
obj->y - miny - y, |
205 |
|
|
obj); |
206 |
|
|
} |
207 |
|
|
} |
208 |
|
|
#endif |
209 |
|
|
} |
210 |
|
|
|
211 |
|
|
static Boolean SetValues(Widget cur,Widget req,Widget new, |
212 |
|
|
Arg args[],Cardinal *num) |
213 |
|
|
{ |
214 |
|
|
CrFaceWidget w = (CrFaceWidget)new; |
215 |
|
|
debug("SetValues()\n"); |
216 |
|
|
if(w->crFace.adjust) GetSize(new,&(w->core.width),&(w->core.height)); |
217 |
|
|
|
218 |
|
|
if(w->crFace.ob) { /* object selected */ |
219 |
|
|
if(w->crFace.ob->head) w->crFace.ob = w->crFace.ob->head; |
220 |
|
|
} |
221 |
|
|
return True; |
222 |
|
|
} |
223 |
|
|
|
224 |
|
|
/*** end of CrFace.c ***/ |
225 |
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
|