#! ../wafe --f
# small example script to demonstrate the Layout widget 
# Gustaf Neumann  March 10, 1993

set Layout {vertical {
	space = (height label1/3)
	$space <+inf -100%>
	horizontal {
		$space <+inf -100%>
		title
		$space <+inf -100%>
        }
	$space <+inf -100%>
	horizontal {
		$space <-100%>
		vertical {
			$space <-100%>
			label2
			$space <+inf -100%>
		}
		$space <+inf -100%>
		vertical {
			$space <-100%>
			button1
			$space <-100%>
			button2
			$space <-100%>
			button3
			$space <+inf -100%>
		}
		$space <+inf -100%>
        }
	$space <+inf -100%>
	horizontal {
		$space <-100%>
		label1
		$space <+inf -100%>
		fname
		$space <+inf -100%>
		quit
		$space <-100%>
        }
	$space <+inf -100%>
  }}

mergeResources topLevel \
	*Text*editType edit \
	*Text*background white \
	*.background gainsboro \
	*Label.borderWidth 0 \
        *l.layout $Layout

layout l topLevel
  label title l label "Snap Portion of Screen" \
	font -adobe-helvetica-bold-r-normal--18-180-75-75-p-103-iso8859-1
  label label1 l label "Output Filename:"
  label label2 l label "Output Format:"
  asciiText fname l string ttt
  command button1 l label "Embedded Postscript" callback \
	{exec xsnap -xwd | xwdtopnm | ppmtopgm | pgmtops > [ext eps]}
  command button2 l label "X Pixmap" callback \
	{exec xsnap -xpm > [ext xpm]}
  command button3 l label "X Window Dump" callback \
	{exec xsnap -xwd > [ext xwd]}
  command quit l label Quit callback quit

realize

proc ext {ext} {
  set fn [gV fname string];
  if [regexp "\." $fn] then {return $fn} else {return $fn.$ext}
}
action fname override "<Key>Return: no-op()";
