G4C

; Shows the use of RESIZE Attributes
; ---------------------------------------------------------------
; The gui consists of a cycler & 2 buttons at the top, which we 
; want to remain the same height and only their width resizable
; and a listview which we want to resize as much as the window..

; This is the default setting and it is set with the "ATTR"
; gadget modifiers. 

; The cycler will change these settings with the "SETATTR" command
; to various others.. the above however looks best.
; ----------------------------------------------------------------

WINBIG 97 38 278 154 Resize.gc
WinType 11110001

xOnLoad
	GuiOpen #This

xOnClose
	GuiQuit #This

; ---------------------------------------------------------------
; The Listview
; ---------------------------------------------------------------

XLISTVIEW 0 14 277 140 "" filename "" 0 DIR
	gadid 1
	gadfont #mono 8 000  ; dirlvs look better in monospaced font..

	; If left as above, this listview would resize and reposition
	; proportionally to the change in window size. We change this
	; behaviour with the ATTR gadget modifier below, which will 
	; cause : Left & top to stay the same (since they're 0's) and
	; Width & Height to be resized by adding the full width that
	; the window resized by (since they're 2's)
	Attr RESIZE 0022

; ---------------------------------------------------------------
; The "Par" & "Vol" Buttons
; These control the above Listview and are resized proportionally
; width-wise, but stay the same height-wise.
; ---------------------------------------------------------------

XBUTTON 170 0 53 14 "Par"
	gadid 2
	ATTR  RESIZE 1010		; resize Left & Width relatively
	lvuse #this 1
	lvdir parent

XBUTTON 224 0 53 14 "Vol"
	gadid 3
	ATTR  RESIZE 1010		; resize Left & Width relatively
	lvuse #this 1
	lvdir Disks

; ---------------------------------------------------------------
; Resize mode Cycler
; This cycler will change the resizing mode of each gadget in
; this gui, by using the "SETATTR" command, which does exactly
; what "ATTR" does but dynamically, ie while the gui is running.
; ---------------------------------------------------------------

XCYCLER 0 0 169 14 "" mode
	CSTR "Controlled"    CONTROLLED	; controlled resizing
	CSTR "Normal"  		NORMAL		; normal (relative) resizing
	CSTR "None"          NONE        ; no resizing

	gadid 4
	ATTR  RESIZE 0010		; resize Width only, relatively

	if $mode = CONTROLLED	
	; this is the default setting
		setattr #this/1 RESIZE  0022
		setattr #this/2 RESIZE  1010
		setattr #this/3 RESIZE  1010
		setattr #this/4 RESIZE  0010

	elseif $mode = NORMAL	
	; normal resize (like if you did not declare any Attr/Setattr)
		setattr #this/1 RESIZE  1111
		setattr #this/2 RESIZE  1111
		setattr #this/3 RESIZE  1111
		setattr #this/4 RESIZE  1111

	else
	; no resize..
		setattr #this/1 RESIZE  0000
		setattr #this/2 RESIZE  0000
		setattr #this/3 RESIZE  0000
		setattr #this/4 RESIZE  0000

	endif


