\ ---------------------------------------------------
\ SimpleBorder.f
\ ---------------------------------------------------
{  TBG.f and CSG.f Version 1.0
   Text Boolean Gadgets and String/Integer gadget creation helper.

   by Marc Lupien,  Montreal, Canada.
   June of 1988
   CIS user no. 71550,640
}
{ 
These words allocate and define Borders and coordinates pairs.

For use with words StringGadget, IntegerGadget and
   TextBoolGadget.
}
\ ---------------------------------------------------

Find GDefault_F not
Iftrue
  include GDefault.f
Ifend

Find SimpleBorder_f not
Iftrue
cr ." loading SimpleBorder.f..." cr  decimal

anew SimpleBorder_f

\ create appropriate PairData

	Create SimpleBdPdTight	\ tight around the select box
	5 w,	\ 5 pairs defined
	paABS w,	-1 w,	paABS w,	-1 w,
	paWidth+ w,	 0 w,	paABS w,	-1 w,
	paWidth+ w,	 0 w,	paHeight+ w,	 0 w,
	paABS w,	-1 w,	paHeight+ w,	 0 w,
	paABS w,	-1 w,	paABS w,	-1 w,

	Create SimpleBdPdSlack	\ slack around the select box
	5 w,	\ 5 pairs defined
	paABS w,	-3 w,	paABS w,	-2 w,
	paWidth+ w,	 3 w,	paABS w,	-2 w,
	paWidth+ w,	 3 w,	paHeight+ w,	 1 w,
	paABS w,	-3 w,	paHeight+ w,	 1 w,
	paABS w,	-3 w,	paABS w,	-2 w,

\ very simple box.  Nice for 320x200 or 640x400.

: SimpleBorder  ( Gadget -- Gadget )
	1 needed ?exec		\ check stack depth and exec state
	0 locals| bdStruct Gstruct |
	myFrontPen AllotBorder to bdStruct
	bdStruct Gstruct  +ggGadgetRender R!
	bdStruct
	   Gstruct STRGADGET?
		if   SimpleBdPdSlack	  \ slack around string gadget
		else SimpleBdPdTight then \ tight around other types
	   Gstruct AllotPairs
	Gstruct ; immediate

Ifend

