G4C

;       ClipView.gc
; --------------------------------------------------------
; How to use the ClipBoard capabilities.
; This gui will show you whatever is in the given clipboard 
; unit. Also you can load/save clips.

; -- The ATTR RESIZE commands are to tell the gui how to
;    resize itself..
; --------------------------------------------------------

WINBIG 110 40 437 164 'Clipboard Viewer'
WinType 11110001
ResInfo 8 640 256 ; my screen size & font height..

xOnLoad
	unit = 0        ; our default clipboard unit
	GuiOpen ClipView.gc

xOnClose
	GuiQuit ClipView.gc

; --------------------------------------------------------
;       Change the clipboard unit
; --------------------------------------------------------

XBUTTON 297 0 20 14 ">"
	attr resize 0000
	++unit
	gosub clipview.gc changeunit

XBUTTON 216 0 20 14 "<"
	attr resize 0000
	--unit
	gosub clipview.gc changeunit

XTEXTIN 237 0 59 14 "" unit '0' 10
	attr resize 0000
	gadid 2
	gosub clipview.gc changeunit

xRoutine ChangeUnit
	; make sure the unit is 0-255
	if $unit > 255
	   unit = 0
	elseif $unit < 0
	   unit = 255
	endif
	; load the given clip..
	lvuse clipview.gc 1
	lvchange "CLIPS:$unit"
	update clipview.gc 2 $unit

; --------------------------------------------------------
;       Load a file into the current clipboard unit
; --------------------------------------------------------

XBUTTON 0 0 70 14 "Load.."
	attr resize 0000
	ReqFile  -1 -1 300 -30 'Choose file :' LOAD filename ''
	if $filename > ''
	   lvuse clipview.gc 1
	   lvchange $filename
	   ; now save it so as to write it to the clipboard
	   lvsave 'CLIPS:$unit'
	endif

; --------------------------------------------------------
;       Save the current clipboard unit as a file
; --------------------------------------------------------

XBUTTON 72 0 70 14 "Save.."
	attr resize 0000
	ReqFile  -1 -1 300 -30 'Save as file :' SAVE savename ''
	if $savename > ' '
	   ifexists file $savename
	      ezreq 'File $savename exists.\nOverwrite ?' Overwrite|CANCEL choice
	      if $choice = 0
	         stop
	      endif
	   endif
	   lvsave $savename
	endif

; --------------------------------------------------------
;       Clear the current clipboard unit
; --------------------------------------------------------

XBUTTON 144 0 70 14 "Clear"
	attr resize 0000
	lvuse clipview.gc 1
	lvclear
	; update the clipboard
	lvsave 'CLIPS:$unit'

; --------------------------------------------------------
;       The listview
; --------------------------------------------------------

XLISTVIEW 0 15 436 148 "" clipline CLIPS:0 10 NUM
	attr resize 0022
	gadid 1




