1 /* -------------- pictbox.c -------------- */
3 #include "dflat32/dflat.h"
10 unsigned char CharInWnd
[] = "ijڿÙÀÅôÁÂ";
12 unsigned char VectCvt
[3][11][2][4] = {
13 { /* --- first character in collision vector --- */
14 /* ( drawing Ä ) ( drawing ³ ) */
26 { /* --- middle character in collision vector --- */
27 /* ( drawing Ä ) ( drawing ³ ) */
39 { /* --- last character in collision vector --- */
40 /* ( drawing Ä ) ( drawing ³ ) */
54 /* -- compute whether character is first, middle, or last -- */
55 static int FindVector(DFWINDOW wnd
, DFRECT rc
, int x
, int y
)
58 VECT
*vc
= wnd
->VectorList
;
60 for (i
= 0; i
< wnd
->VectorCount
; i
++) {
61 if ((vc
+i
)->vt
== VECTOR
) {
63 /* --- skip the colliding vector --- */
64 if (rcc
.lf
== rc
.lf
&& rcc
.rt
== rc
.rt
&&
65 rcc
.tp
== rc
.tp
&& rc
.bt
== rcc
.bt
)
67 if (rcc
.tp
== rcc
.bt
) {
68 /* ---- horizontal vector,
69 see if character is in it --- */
70 if (rc
.lf
+x
>= rcc
.lf
&& rc
.lf
+x
<= rcc
.rt
&&
73 if (rc
.lf
+x
== rcc
.lf
)
75 else if (rc
.lf
+x
== rcc
.rt
)
82 /* ---- vertical vector,
83 see if character is in it --- */
84 if (rc
.tp
+y
>= rcc
.tp
&& rc
.tp
+y
<= rcc
.bt
&&
87 if (rc
.tp
+y
== rcc
.tp
)
89 else if (rc
.tp
+y
== rcc
.bt
)
100 static void PaintVector(DFWINDOW wnd
, DFRECT rc
)
105 static int cw
, fml
, vertvect
, coll
;
107 if (rc
.rt
== rc
.lf
) {
108 /* ------ vertical vector ------- */
114 /* ------ horizontal vector ------- */
120 for (i
= 0; i
< len
; i
++) {
127 ch
= videochar(GetClientLeft(wnd
)+rc
.lf
+xi
,
128 GetClientTop(wnd
)+rc
.tp
+yi
);
129 for (cw
= 0; cw
< sizeof(CharInWnd
); cw
++) {
130 if (ch
== CharInWnd
[cw
]) {
131 /* ---- hit another vector character ---- */
132 if ((coll
=FindVector(wnd
, rc
, xi
, yi
)) != -1) {
133 /* compute first/middle/last subscript */
140 newch
= VectCvt
[coll
][cw
][vertvect
][fml
];
144 PutWindowChar(wnd
, newch
, rc
.lf
+xi
, rc
.tp
+yi
);
148 static void PaintBar(DFWINDOW wnd
, DFRECT rc
, enum VectTypes vt
)
151 unsigned int tys
[] = {219, 178, 177, 176};
152 /* unsigned int tys[] = {'Û', '²', '±', '°'};
154 unsigned int nc
= tys
[vt
-1];
156 if (rc
.rt
== rc
.lf
) {
157 /* ------ vertical bar ------- */
162 /* ------ horizontal bar ------- */
167 for (i
= 0; i
< len
; i
++) {
173 PutWindowChar(wnd
, nc
, rc
.lf
+xi
, rc
.tp
+yi
);
177 static void PaintMsg(DFWINDOW wnd
)
180 VECT
*vc
= wnd
->VectorList
;
181 for (i
= 0; i
< wnd
->VectorCount
; i
++) {
182 if (vc
->vt
== VECTOR
)
183 PaintVector(wnd
, vc
->rc
);
185 PaintBar(wnd
, vc
->rc
, vc
->vt
);
190 static void DrawVectorMsg(DFWINDOW wnd
,PARAM p1
,enum VectTypes vt
)
194 wnd
->VectorList
= DFrealloc(wnd
->VectorList
,
195 sizeof(VECT
) * (wnd
->VectorCount
+ 1));
197 vc
.rc
= *(DFRECT
*)p1
;
198 *(((VECT
*)(wnd
->VectorList
))+wnd
->VectorCount
)=vc
;
203 static void DrawBoxMsg(DFWINDOW wnd
, PARAM p1
)
206 DFRECT rc
= *(DFRECT
*)p1
;
208 DfSendMessage(wnd
, DRAWVECTOR
, (PARAM
) &rc
, TRUE
);
211 DfSendMessage(wnd
, DRAWVECTOR
, (PARAM
) &rc
, FALSE
);
214 DfSendMessage(wnd
, DRAWVECTOR
, (PARAM
) &rc
, TRUE
);
217 DfSendMessage(wnd
, DRAWVECTOR
, (PARAM
) &rc
, FALSE
);
221 int PictureProc(DFWINDOW wnd
, DFMESSAGE msg
, PARAM p1
, PARAM p2
)
225 BaseWndProc(PICTUREBOX
, wnd
, msg
, p1
, p2
);
229 DrawVectorMsg(wnd
, p1
, VECTOR
);
235 DrawVectorMsg(wnd
, p1
, (enum VectTypes
)p2
);
238 if (wnd
->VectorList
!= NULL
)
239 free(wnd
->VectorList
);
244 return BaseWndProc(PICTUREBOX
, wnd
, msg
, p1
, p2
);
247 static DFRECT
PictureRect(int x
, int y
, int len
, int hv
)
253 /* ---- horizontal vector ---- */
256 /* ---- vertical vector ---- */
261 void DrawVector(DFWINDOW wnd
, int x
, int y
, int len
, int hv
)
263 DFRECT rc
= PictureRect(x
,y
,len
,hv
);
264 DfSendMessage(wnd
, DRAWVECTOR
, (PARAM
) &rc
, 0);
267 void DrawBox(DFWINDOW wnd
, int x
, int y
, int ht
, int wd
)
274 DfSendMessage(wnd
, DRAWBOX
, (PARAM
) &rc
, 0);
277 void DrawBar(DFWINDOW wnd
,enum VectTypes vt
,
278 int x
,int y
,int len
,int hv
)
280 DFRECT rc
= PictureRect(x
,y
,len
,hv
);
281 DfSendMessage(wnd
, DRAWBAR
, (PARAM
) &rc
, (PARAM
) vt
);