/* Sample arexx client program for iX-Guide */
/* Miscellaneous graphics routines */

if show('p',"IXCL_2") then exit

if ~show('l', "rexxsupport.library") then
    addlib('rexxsupport.library',0,-30,0)

OPTIONS RESULTS

ADDRESS IXGUIDE
ADDCLIENT
portname='IXCL_2'
call openport(portname)
setport portname MISC
AllocRaster 3
if rc ~= 0 then exit
rp=result
Refresh rp
SetABPen rp 1 0
OpenFont 'times.font' 24; f1 = result
OpenFont 'times.font' 18; f2 = result
OpenFont 'topaz.font' 8; f3 = result

call LoadImage()

call GraphDemo()

shutdown=0

do until shutdown
 call waitpkt(portname)
 msg = getpkt(portname)
 
 if msg ~= '0000 0000'x then do
  cmd = getarg(msg)
  
  if cmd='MISC' then do
   a4=getarg(msg,1)
   
   if a4='QUIT' then
    shutdown=1
   
   if a4='NEWSCREEN' then do
    /* we need to reload picture */
    DisposePicture pobj
    call LoadImage()
    call GraphDemo()
    end
  
  end

  call reply(msg,0)
 end
end

DisposePicture pobj
CloseFont f1;CloseFont f2;CloseFont f3
FreeRaster rp
RemClient
call closeport(portname)
exit

LoadImage:
 NewPicture 'images/mainback.iff' 
 if rc ~= 0 then do
  say 'Cannot load mainback.iff !'
  CloseFont f1;CloseFont f2;CloseFont f3
  FreeRaster rp
  RemClient
  call closeport(portname)
 exit
 end
 pobj = result
 
 GetBitMap pobj; bm = result
 PWidth pobj; w = result
 PHeight pobj; h = result
 BltBitMapRP bm 0 0 rp 5 5 w h 192

return 0

GraphDemo:
 SetDrMd rp 0
 SetFont rp f1
 Move rp 5 25
 Text rp '"iX-Guide arexx graphics"'
 Move rp 55 50
 SetFont rp f2
 SetDrMd rp 1
 SetABPen rp 0 1
 Text rp '"You can have different"'
 Move rp 55 70
 Text rp '"fonts, colors, styles..."'
 SoftStyle rp 1
 SetFont rp f3
 SetABPen rp 1
 SetDrMd rp 0
 Move rp 10 90
 Text rp '"bold "';SoftStyle rp 2;Text rp '"underlined "';
 SoftStyle rp 4;Text rp 'italic'; 
 SoftStyle rp 0
 Move rp 30 100
 Text rp '"You can load datatype pictures"'
 Move rp 30 110
 Text rp '"like picture in this rectangle"'
 
 DrawEllipse rp 150 70 30 30 
 
return 0
