1 /* this file contains definition for the screen */
3 #include <aros/oldprograms.h>
5 #include <exec/memory.h>
13 #include "gadgetdef.h"
18 #define GetExtens(gei) ((struct GadExtens *)gei->UserData)
19 extern struct GfxBase
* GfxBase
;
22 void SetBezMesh( int );
26 void GadgetSetVal(gad
)
30 struct PropInfo
*prop
;
33 if( !(gad
->GadgetType
& PROPGADGET
) ) {
37 if( !gad
->GadgetRender
) {
38 gad
->GadgetRender
= (APTR
) malloc(sizeof(struct Image
));
39 if( !gad
->GadgetRender
) {
40 OutErr("Not enough memory for gadgets");
45 if( !gad
->SpecialInfo
) {
46 static struct PropInfo dummyprop
= {
48 0x8000, 1, /* HorizPot = initial value */
49 0xff, 0, /* not really of interest */
53 gad
->SpecialInfo
= (APTR
) malloc(sizeof(struct PropInfo
));
54 if( !gad
->SpecialInfo
) {
55 OutErr("Not enough memory for gadgets");
59 *(struct PropInfo
*)gad
->SpecialInfo
= dummyprop
;
62 vp
= GetExtens( gad
);
66 prop
= (struct PropInfo
*) gad
->SpecialInfo
;
69 gadval
= (long)( (long)MAXPOT
*
70 ( vp
->curfval
- vp
->minfval
)/(vp
->maxfval
- vp
->minfval
));
71 prop
->HorizBody
= MAXPOT
/( 15 * 8 );
74 gadval
= ( (long)MAXPOT
*
75 ( (long) vp
->curival
- vp
->minival
))/(vp
->maxival
- vp
->minival
);
76 prop
->HorizBody
= MAXPOT
/( vp
->maxival
- vp
->minival
);
79 prop
->HorizPot
= gadval
;
84 void GadgetUpdate(gad
, exists
)
86 bool exists
; /* has the gadget already been displayed? */
94 if(!( gad
->GadgetType
& PROPGADGET
) ) {
98 vp
= GetExtens( gad
);
101 potvalue
= ((struct PropInfo
*) gad
->SpecialInfo
)->HorizPot
;
105 temp
= ( potvalue
* (vp
->maxfval
- vp
->minfval
))/ MAXPOT
109 sprintf(dbuff
,"%f ", temp
);
111 ftoa(temp
, dbuff
, sizeof(dbuff
)-4, 1);
116 temp
= (long)( potvalue
* (vp
->maxival
- vp
->minival
))/ MAXPOT
119 sprintf(dbuff
,"%-12d", (int)temp
);
124 it
= gad
->GadgetText
;
125 for( tx
= (char *)it
->IText
; *tx
&& *tx
!= '['; tx
++ ) {
129 return; /* something screwy */
131 tx
++; /* skip past opening bracket */
133 while( *tx
!= ']' ) {
139 tempx
= it
->LeftEdge
+ gad
->LeftEdge
;
140 tempy
= it
->TopEdge
+ gad
->TopEdge
+ 6; /*fudge factor for baseline*/
141 Move( CntrlWin
->RPort
, tempx
, tempy
);
142 SetAPen(CntrlWin
->RPort
,it
->FrontPen
);
143 Text( CntrlWin
->RPort
, it
->IText
, strlen(it
->IText
));
147 void SetHourGlass() {
148 SetPointer( SurfWin
, HourGlass
, 16, 16, MPtrXOffset
, MPtrYOffset
);
149 SetPointer( GadWin
, HourGlass
, 16, 16, MPtrXOffset
, MPtrYOffset
);
150 SetPointer( CntrlWin
, HourGlass
, 16, 16, MPtrXOffset
, MPtrYOffset
);
153 void ClearHourGlass() {
154 ClearPointer(SurfWin
);
155 ClearPointer(GadWin
);
156 ClearPointer(CntrlWin
);
159 void GadgetHandler(gadaddr
)
160 struct Gadget
*gadaddr
;
165 if( gadaddr
->UserData
) {
166 GadgetUpdate( gadaddr
, true );
167 curival
= ((struct GadExtens
*) gadaddr
->UserData
)->curival
;
168 curfval
= ((struct GadExtens
*) gadaddr
->UserData
)->curfval
;
171 switch( (enum GadgetName
) gadaddr
->GadgetID
) {
173 LightSrc
.x
= (float)curival
;
176 LightSrc
.y
= (float)curival
;
182 LightSrc
.z
= (float)curival
;
188 PtIntensity
= curfval
;
219 SetRotRange( curival
);
222 SetRotStart( curival
);
225 SetSecAng( curival
);
228 SetRevMesh( curival
);
231 SetBezMesh( curival
);
234 SetSurfDist( curival
);
245 ScreenToFront( SurfScrn
);
249 WindowToFront( CntrlWin
);