GClock Rexx Widget (based on Rexx Scroller widget)
==================================================
Title: GClock
Refresh rate: 30000ms (30 secs)
Graph options: everything unchecked
Scroller graph: ignored
Bitmap: clipped


Scroller script:
================
/* GClock */
signal on error name TrapErr
signal on syntax name TrapErr
signal on failure name TrapErr
signal on halt name TrapErr

Call RxFuncAdd 'GdLoadFuncs', 'rexxgd', 'GdLoadFuncs'
Call GdLoadFuncs

/* Custom values ------------------------------ */
width = 75
height = 28
fonti = 'e:\psfonts\georgiaz.ttf'
font = 'e:\psfonts\verdanab.ttf'
smsize = 6
bgsize = 14
iconpath = 'e:\xworkplace\xcicons\'
/* End ---------------------------------------- */

if scrlr.user = '' then scrlr.user = 0

im_out = gdImageCreate(width, height)
white = gdImageColorAllocate(im_out, 255, 255, 255)
Call gdImageColorTransparent im_out, white
im_in = gdImageCreateFromPng(iconpath'clockbg_a.png')

if im_in = '' then
	exit
else
	call gdImageCopy im_out, im_in, 0, 0, 0, 0, width, height

black = gdImageColorAllocate(im_out, 50, 50, 38)
dgrey = gdImageColorAllocate(im_out, 110, 110, 100)

/* Get the date, the weekday, the hour */
parse value date() with day mth year
scrlr.tooltip = date()
weekday = date('W')
parse value time() with hh ':' mm ':' .
hour = hh':'mm

/* FreeType Antialiased Text - hour */
err = gdImageStringTTF(, brect., black, fonti, bgsize, 0, 0, 0, hour)
if err \= '' then exit

hl = brect.8 - brect.2 + 1
hr = brect.6 - brect.4 + 1
h = max(hl, hr)

wu = brect.5 - brect.7 + 1
wl = brect.3 - brect.1 + 1
w = max(wu, wl)

xshift = trunc((width - w) / 2)
yshift = trunc((height - h) * (2/ 3)) - 4

if (xshift < 0)|(yshift < 0) then exit

err = gdImageStringTTF(im_out, brect., dgrey, fonti, bgsize, 0, xshift+1, yshift+2, hour)
if err \= '' then exit
err = gdImageStringTTF(im_out, brect., black, fonti, bgsize, 0, xshift, yshift, hour)
if err \= '' then exit

/* FreeType Antialiased Text - weekday */
err = gdImageStringTTF(, brect., black, font, smsize, 0, 0, 0, weekday)
if err \= '' then exit

hl = brect.2 - brect.8 + 1
hr = brect.4 - brect.6 + 1
h = max(hl, hr)

wu = brect.5 - brect.7 + 1
wl = brect.3 - brect.1 + 1
w = max(wu, wl)

xshift = trunc((width - w) / 2)
yshift = h - 2

err = gdImageStringTTF(im_out, brect., dgrey, font, smsize, 0, xshift+1, yshift+1, weekday)
if err \= '' then exit
err = gdImageStringTTF(im_out, brect., black, font, smsize, 0, xshift, yshift, weekday)
if err \= '' then exit

/* FreeType Antialiased Text - month */
err = gdImageStringTTF(, brect., black, font, smsize, 1.5707963, 0, 0, mth)
if err \= '' then exit

wu = brect.5 - brect.7 + 1
wl = brect.3 - brect.1 + 1
w = max(wu, wl)

xshift = width - 4
yshift = height - 2

err = gdImageStringTTF(im_out, brect., dgrey, font, smsize, 1.5707963, xshift+1, yshift+1, mth)
if err \= '' then exit
err = gdImageStringTTF(im_out, brect., black, font, smsize, 1.5707963, xshift, yshift, mth)
if err \= '' then exit

/* FreeType Antialiased Text - day */
err = gdImageStringTTF(, brect., black, font, smsize, 0, 0, 0, day)
if err \= '' then exit

wu = brect.5 - brect.7 + 1
wl = brect.3 - brect.1 + 1
w = max(wu, wl)

xshift = width - w - 3
yshift = h - 2

err = gdImageStringTTF(im_out, brect., dgrey, font, smsize, 0, xshift+1, yshift+1, day)
if err \= '' then exit
err = gdImageStringTTF(im_out, brect., black, font, smsize, 0, xshift, yshift, day)
if err \= '' then exit

/* Write PNG */
Call gdImagePng im_out, iconpath'clockout.png'
Call gdImageDestroy im_out
If im_in \= 0 Then Call gdImageDestroy im_in

/* Cvt PNG 2 BMP */
pict = iconpath'clockout'
'del 'pict'*.bmp & png2bmp.exe -O 'pict'.bmp 'pict'.png & copy 'pict'.bmp 'pict'1.bmp'

if scrlr.user = 0 then do
	scrlr.bitmap = pict'.bmp'
	scrlr.user = 1
end; else do
	scrlr.bitmap = pict'1.bmp'
	scrlr.user = 0
end

exit

TrapErr:
    nl = '0D0A'x
    ErrMsg = 'An error occurred in the script. See below for details:'
    ErrMsg = ErrMsg || nl || nl
    ErrMsg = ErrMsg || 'Error: ' || rc || nl
    ErrMsg = ErrMsg || 'Description: ' ErrorText(rc) || nl
    ErrMsg = ErrMsg || 'Condition: ' Condition('C') || nl
    ErrMsg = ErrMsg || 'Line: ' SIGL || nl
    ErrMsg = ErrMsg || 'Code: ' SourceLine(SIGL)
    ErrMsg = ErrMsg || nl || nl
    ErrMsg = ErrMsg || 'Please send this info to <criguada@libero.it>' || nl
    ErrMsg = ErrMsg || nl || nl
    ErrMsg = ErrMsg || 'The program will now simulate another error, '
    ErrMsg = ErrMsg || 'so that your script will stop running.'
    rc = RxMessageBox(ErrMsg, 'Script error', 'OK', 'ERROR')
    rc = 1/0
    exit




Double click script:
====================
/* Clock settings notebook */
if RxFuncQuery('SysLoadFuncs') then do
	call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
	call SysLoadFuncs
end
  
call SysSetObjectData '<WP_CLOCK>', 'OPEN=SETTINGS'
