G4C ; Muss in der ersten Zeile stehenbleiben!!!

; $VER: WBStartupControl v1.18 (28.02.2002)

; Grundeinstellungen
WINBIG -1 -1 200 192 ""
winsmall 0 11 320 256
WinType 11110001
varpath "wbscsetcolor/wbsprefs"

; Routinen
xroutine load
	extract #this guipath wbscpath
	assign WBSC: $wbscpath

	lvuse #this 1

	vers = v1.18
	date = 28.02.2002
	copy = ©2001/2002
	name = Nightshade
	prog = WBStartupControl
	mail = thenightshade@freenet.de

	c    = 1
	hide = 0

	COL1     = 2
	COL2     = 1
	DRAWMODE = SHADOW
	ALIGN    = CENTER
	TITLE    = "Programm Editor"

	def_col1  = $COL1
	def_col2  = $COL2
	def_draw  = $DRAWMODE
	def_align = $ALIGN
	def_title = $TITLE

	ttget :$prog

	col1  = $COL1
	col2  = $COL2
	draw  = $DRAWMODE
	gosub #this setting_title $ALIGN
	titxt = $TITLE

	old_col1 = $col1
	old_col2 = $col2

	setgad #this 10 hide

	gosub #this load_list
	gosub #this set_title 

	setwintitle #this "$prog $vers"

	guiload wbscsetcolor
	guiload wbsprefs
	GuiOpen #This
	guiwindow #this on

xroutine load_list
	ifexists file SYS:WBStartup/WBStarter
		lvchange SYS:WBStartup/WBStarter
		lvgo first
	endif

xroutine setting_title adjust
	if $adjust == LEFT
		mode = 1
	elseif $adjust == RIGHT
		mode = 2
	elseif $adjust == CENTER
		mode = 0
	endif
	oldmode = $mode

xroutine info about
	if $about = 1
		guiwindow #this wait
		setvar a "$prog $vers ($date)\n"
		appvar a "EmailWare $copy by $name\n"
		appvar a "Email: $mail"
		ezreq $a Super! ""
		guiwindow #this resume
		gosub #this setcursor
	elseif $about = 0
		info variable sel_prog
		guiwindow #this wait
		setvar a "Zeile: $($$lv.line + 1)/$$lv.total - Länge: $$VAR.LENGTH\n\n"
		appvar a "Gewählter Eintrag:\n$$lv.rec"
		ezreq $a "Fein!" ""
		guiwindow #this resume
	endif

xroutine setcursor
	if $hide = 1
		setattr #this/10 tipos 256
		setgad #this 10 on
	endif

xroutine addfile
	ifexists file ~$appfile
		guiwindow #this on
		flash
		stop
	endif
	extract appfile file file
	if $file != $prog
	and $file != WBStarter
		setvar icon $appfile
		appvar icon .info
			guiwindow #this wait
			mark sel_mode
			body = "Wie soll diese Datei ausgeführt werden?\n\n$appfile"
			ezreq $body WB|Cli|Asyn.|Mehr...|Abbrechen exe_mode
			if $exe_mode = 1
				ifexists file $icon
				andifexists file c:wbrun
					lvadd "WBRUN $appfile"
				else
					ifexists file ~$icon
						missed = $icon
						ifexists file ~C:WBRUN
							appvar missed \nC:WBRUN
						endif
					elseifexists file ~C:WBRUN
						missed = C:WBRUN
					endif
					ezreq "Kann folgene Datei(en) nicht finden:\n$missed\n\n$appfile\nanders gestarten?" Ja|Nein wb_fault
					if $wb_fault = 1
						goto sel_mode
					else
						goto stop
					endif
				endif
			elseif $exe_mode = 2
				lvadd $appfile
			elseif $exe_mode = 3
				lvadd "RUN <>NIL: $appfile"
			elseif $exe_mode = 4
				ezreq $body "Dos-Skript|ARexx-Skript|Anderes|Zurück" other
				if $other = 1
					lvadd "EXECUTE $appfile"
				elseif $other = 2
					lvadd "RX $appfile"
				elseif $other = 3
					myfile = ""
					reqfile 30 20 300 350 "Öffnen mit..." LOAD myfile #SYS:
					extract myfile file sel_file
					if $sel_file > ""
						lvadd "$myfile $appfile"
					else
						goto stop
					endif
				else
					goto sel_mode
				endif
			else
				goto stop
			endif
			lvgo last
			if $hide = 0
			and $exe_mode = 4
				setgad #this 2/6 hide
				setgad #this 2/6 off
				setgad #this 10 show
				redraw #this
				update #this 10 $$lv.rec
				hide = 1
			elseif $hide = 1
				update #this 10 $$lv.rec
			endif
	else
		flash
	endif
	mark stop
	guiwindow #this resume
	guiwindow #this on
	lvmove #$$lv.line
	return

xroutine next n
	lvgo #$$lv.line
	lvmove $n

xroutine line whereto
	if $whereto = down
		if $$lv.line < $($$lv.total - 1)
			lvgo next
			lvmove #$$lv.line
		else
			stop
		endif
	elseif $whereto = up
		if $$lv.line > 0
			lvgo prev
			lvmove #$$lv.line
		else
			stop
		endif
	endif

xroutine goto line
	if $line = top
		lvgo first
	elseif $line = bottom
		lvgo last
	endif
	lvmove #$$lv.line

xroutine set_title
	if $mode = 1
		set margin 5/10/2
		x = left
	elseif $mode = 2
		set margin 5/10/2
		x = right
	elseif $mode = 0
		set margin 5/0/2
		x = center
	endif
	gosub #this show_title $col1 $col2 $draw $x

xroutine show_title apen bpen drawmode xjustify
	setattr #this/100 title "$apen\/$bpen\/$drawmode\/$xjustify\/top/$titxt"
	redraw #this

xroutine if_button pressed
	if $pressed = save
		guiwindow #this wait
		ezreq "Liste sichern?" Jo|Nö save
			if $save = 1
				if $$lv.total > 0
					lvsave SYS:WBStartup/WBStarter
					copy WBSC:def_icon/WBStarter.info SYS:WBStartup/
					guiquit #this
				else
					flash
				endif
			endif
		guiwindow #this resume
	elseif $pressed = cancel
		gosub #this exit
	endif

xroutine quit
	guiwindow #this wait
	ezreq "$prog verlassen?" Weiter|Zurück ende
		if $ende = 1
			gosub #this exit
		else
			ifexists window ~#this
			andifexists file env:gui4cli/$prog
				guiopen #this
			endif
		endif
	guiwindow #this resume

xroutine exit
	guiquit wbsprefs
	guiquit #this
	guiquit wbscsetcolor
	assign WBSC: remove

xroutine click_in_lv
	opt = 0
	if $hide = 1
		update #this 10 $sel_prog
		gosub #this setcursor
		stop
	endif
	if $c = 1
		cutvar sel_prog copy line -1 newvar
		if $$lv.rec = $newvar
			++c
		endif
	elseif $c = 2
	and $sel_prog = $newvar
		gosub #this change_buttons
		--c
	else
		cutvar sel_prog copy line -1 newvar
		if $$lv.rec != $newvar
			gosub #this change_buttons
			--c
		endif
	endif

xroutine req_prog
	guiwindow #this wait
	newprog = ""
	reqfile 30 20 300 350 "Wähle Programm:" LOAD newprog #SYS:
	guiwindow #this resume
		if $newprog != ""
			appfile = $newprog
			gosub #this addfile
		endif

xroutine change_buttons
	hide = 1
	if $opt = 0
		update #this 10 $$lv.rec
	else
		update #this 10 ""
	endif
	setgad #this 2/6 hide
	setgad #this 2/6 off
	setgad #this 10 show
	redraw #this
	gosub #this setcursor

xroutine del
	guiwindow #this wait
	ezreq "Diesen Eintrag löschen?\n\n$$lv.rec" "Weg damit!|Bloß nich!" del
		if $del = 1
			lvdel -1
			lvmove #$$lv.line
		endif
	guiwindow #this resume

xroutine move it
	if $it = up
		if $$lv.line > 0
			new = $$lv.rec
			lvgo prev
			old = $$lv.rec
			lvput $new
			lvgo next
			lvput $old
			lvgo prev
			lvmove #$$lv.line
		else
			flash
		endif
	elseif $it = down
		if $$lv.line < $($$lv.total - 1)
			new = $$lv.rec
			lvgo next
			old = $$lv.rec
			lvput $new
			lvgo prev
			lvput $old
			lvgo next
			lvmove #$$lv.line
		else
			flash
		endif
	endif

xroutine edit
	if $commando > " "
	and $commando != $sel_prog
		if $opt = 1
			lvadd $commando
		elseif $opt = 2
			lvinsert -1 $commando
		elseif $opt = 0
			guiwindow #this wait
			ezreq "Änderung übernehmen?\n\n$commando" Übernehmen|Verwerfen change
				if $change = 1
					lvgo #$$lv.line
					lvput $commando
				endif
			guiwindow #this resume
		endif
	endif
	lvmove #$$lv.line
	hide = 0
	setgad #this 10 hide
	setgad #this 2/6 on
	setgad #this 2/6 show
	redraw #this

xroutine editline
	opt = 0
	gosub #this change_buttons

xroutine iconify
	iconify = yes
	setgad #this 50 on
	guiclose #this

; Menüs
xmenu Projekt "Liste laden..." "" "O"
	gosub #this load_list

xmenu Projekt BARLABEL "" ""

xmenu Projekt "Info" "" !
	gosub #this info 0

xmenu Projekt "Über" "" ?
	gosub #this info 1

xmenu Projekt BARLABEL "" ""

xmenu Projekt Ikonifizieren "" I
	gosub #this iconify

xmenu Projekt "Ende" "" E
	gosub #this quit

xmenu Einstellungen "Ändern..." "" P
guiopen wbsprefs

xmenu Einstellungen "BARLABEL" "" ""

xmenu Einstellungen "Vorgaben" "" R
	col1  = $def_col1
	col2  = $def_col2
	draw  = $def_draw
	titxt = $def_title
	gosub #this setting_title $ALIGN
	gosub #this set_title 

xmenu Einstellungen "BARLABEL" "" ""

xmenu Einstellungen "Laden..." "" L
	ttget :$prog
	col1  = $COL1
	col2  = $COL2
	draw  = $DRAWMODE
	titxt = $TITLE
	gosub #this setting_title $ALIGN
	gosub #this set_title

xmenu Einstellungen "Speichern..." "" S
	guiwindow #this wait
	ezreq "Einstellungen speichern?" JA|NEIN sp
	if $sp = 1
		ifexists file c:FileToTT
			delete env:.tooltypes
			delete t:tt
			tt = "«Icon by Nightshade»\n\n"
			appvar tt "COL1 = $col1\n"
			appvar tt "COL2 = $col2\n"
			appvar tt "DRAWMODE = $draw\n"
			appvar tt "ALIGN = $adjust\n"
			appvar tt "TITLE = $titxt"
			.tooltypes = $tt
			rename env:.tooltypes t:tt
			cli "c:filetott FROM t:tt TO WBSC:WBStartupControl"
		else
			flash
			ezreq "FileToTT ist nicht in C:" "Ups!" ""
		endif
	endif
	guiwindow #this resume
	guiwindow #this on


; Events
xOnLoad
	if $$G4C.VERSION != 385
		setvar a "Version Gui4Cli 3.8.5 wird zum\n"
		appvar a "fehlerfreien arbeiten benötigt!\n\n"
		appvar a "Das Update zum runterladen auf:\n"
		appvar a "http://users.hol.gr/~dck/gcmain.htm"
		ezreq $a "Abbrechen" ""
		guiquit #this
		stop
	else
		gosub #this load
	endif


xOnReload
	ifexists window ~#this
		setgad #this 50 off
		iconify = no
		guiopen #this
	endif
	guiwindow #this front
	guiwindow #this on


xonopen
	guiwindow #this on


xOnClose
	gosub #this iconify


xonquit
	gosub #this exit


xOnFail
	GuiQuit #This


xOnActive
	lvuse #this 1
	setscreentitle #this "$prog $vers ($date) - $copy $name ($mail)"
	gosub #this setcursor


; Tasten
xonkey 1
	if $$vankey.qual = 33024
		gosub #this goto bottom
	endif

xonkey 2
	if $$vankey.qual = 33024
	or $$vankey.qual = 33536
		gosub #this line down
	endif

xonkey 3
	if $$vankey.qual = 33024
	or $$vankey.qual = 33536
		gosub #this move down
	endif

xonkey 4
	if $$vankey.qual = 33024
	or $$vankey.qual = 33536
		gosub #this next -5
	endif

xonkey 5
	if $$vankey.qual = 33024
		gosub #this next -256
	endif

xonkey 6
	if $$vankey.qual = 33024
	or $$vankey.qual = 33536
		gosub #this next 5
	endif

xonkey 7
	if $$vankey.qual = 33024
		gosub #this goto top
	endif

xonkey 8
	if $$vankey.qual = 33024
	or $$vankey.qual = 33536
		gosub #this line up
	endif

xonkey 9
	if $$vankey.qual = 33024
	or $$vankey.qual = 33536
		gosub #this move up
	endif

xonkey 0
	if $$vankey.qual = 33024
		opt = 2
		gosub #this change_buttons
	endif

xonkey /
	if $$vankey.qual = 33024
		gosub #this info 0
	endif

xonkey .
	if $$vankey.qual = 33024
		gosub #this del
	endif

xonkey #13
	if $$vankey.qual = 33024
		gosub #this editline
	elseif $$vankey.qual = 32768
		gosub #this if_button save
	endif

xonkey #27
	gosub #this if_button cancel

xonkey #32
	opt = 1
	gosub #this req_prog

xonkey #127
	gosub #this del


; AppIcon
xappicon 550 180 :WBStartupControl "Fütter mich!" appfile off
	if $appfile = ""
		setgad #this 50 off
		iconify = no
		guiopen #this
	else
		extract appfile file file
		ifexists file ~$appfile
		and $file != $prog
		and $file != WBStarter
			flash
		else
			gosub #this addfile
			if $exe_mode != 0
			and $exe_mode = 4
				guiopen #this
			endif
		endif
	endif
	gadid 50


; AppWindow
xappwindow appfile
	gosub #this addfile


; GUI
box -1 -1 0 0 out button
box -1 165 186 21 in button
attr resize 0210


xtextbox -1 10 186 148 "" ""
	attr resize 0022
	attr tbox 0/0/0/ridge/in
		gadfont times.font 13 000
			gadid 100


XLISTVIEW 15 20 170 115 "" "sel_prog" "" 0 show
	attr resize 0022
	gosub #this click_in_lv
		gadfont courier.font 10 000
			gadid 1


XBUTTON 15 135 35 15 "_NEU"
	opt = 1
	gosub #this req_prog
		attr resize 0200
		gadfont helvetica.font 9 001
		gadid 2

XBUTTON 53 135 35 15 "_EIN"
	opt = 2
	gosub #this change_buttons
		attr resize 0200
		gadfont helvetica.font 9 001
		gadid 3

XBUTTON 91 135 35 15 "_LÖS"
	gosub #this del
		attr resize 0200
		gadfont helvetica.font 9 001
		gadid 4

XBUTTON 132 135 25 15 "/\"
	gosub #this move up
		attr resize 2200
		gadfont helvetica.font 9 010
		gadid 5

XBUTTON 160 135 25 15 "\/"
	gosub #this move down
		attr resize 2200
		gadfont helvetica.font 9 010
		gadid 6

XBUTTON 10 168 89 15 "_Speichern"
	attr resize 1210
	gosub #this if_button save
		gadfont topaz.font 8 010

XBUTTON 101 168 89 15 "_Abbrechen"
	attr resize 1210
	gosub #this if_button cancel
		gadfont topaz.font 8 001

xtextin -1 134 170 17 "" commando "" 256
	attr resize 0220
	gosub #this edit
		gadfont courier.font 10 000
			gadid 10

;-+-+-+-+-+-+-+-+-+-+-+-+-
	newfile wbscsetcolor
;-+-+-+-+-+-+-+-+-+-+-+-+-

WINBIG -1 -1 220 100 "Wähle eine Farbe:"
WinType 11010000
WinFont topaz.font 8 000
varpath "wbsprefs"

xonopen type
	guiwindow wbsprefs wait
	set margins 5/10/2
	info PALETTE #this/1
	if $type = 1
		pen = $pen1
	else
		pen = $pen2
	endif
	oldpen = $pen
	update #this 1 $oldpen

xonclose
	if $type = 1
	and $pen != $oldpen
		pen1 = $pen
		changearg wbsprefs 100 4 $pen1
		partredraw wbsprefs 100 50 20 17
	elseif $type = 2
	and $pen != $oldpen
		pen2 = $pen
		changearg wbsprefs 101 4 $pen2
		partredraw wbsprefs 100 70 20 17
	endif
	guiwindow wbsprefs resume

box -1 -1 0 0 out button

XPALETTE 10 10 200 80
	pen = $$COLOR.NUM
	guiclose #this
	gadid 1

;-+-+-+-+-+-+-+-+-+-+-+-+-
	newfile wbsprefs
;-+-+-+-+-+-+-+-+-+-+-+-+-

WINBIG -1 -1 224 180 Einstellungen
WinType 01010000
winfont times.font 13 000
varpath "WBStartupControl/wbscsetcolor"

xonopen
	guiwindow WBStartupControl wait

	update #this 1 $titxt

	pen1 = $col1
	pen2 = $col2

	changearg #this 100 4 $pen1
	changearg #this 101 4 $pen2

	partredraw #this 100 50 20 17
	partredraw #this 100 70 20 17

	gosub #this set_style
	gosub #this set_xjust


xonclose
	guiwindow WBStartupControl resume


xroutine set_style
	docase $draw
	  case = PLAIN
				update #this 2 0
				break
	  case = SHADOW
				update #this 2 1
				break
	  case = OUTLINE
				update #this 2 2
				break
	endcase

xroutine set_xjust
	docase $mode
	  case = 1
				update #this 3 0
				break
	  case = 0
				update #this 3 1
				break
	  case = 2
				update #this 3 2
				break
	endcase


xOnClose
	GuiQuit #This


box -1 -1 0 0 out button
box -1 6 212 141 in button
box -1 42 198 2 in ridge
box -1 92 198 2 in ridge
box -1 153 210 21 in button


xtextbox 100 50 20 17 "" ""
	attr title "1/0/Plain/lside/middle/Normal:"
	attr tbox 2/1/0/button/in

xtextbox 100 70 20 17 "" ""
	attr title "1/0/Plain/lside/middle/Schatten:"
	attr tbox 2/1/0/button/in


XTEXTIN 75 18 130 19 "" "newtitle" "" 32
	attr title "1/0/Plain/lside/middle/Titelzeile:"
	gadid 1


XBUTTON 125 50 60 17 "Andere"
		guiopen wbscsetcolor 1

XBUTTON 125 70 60 17 "Andere"
		guiopen wbscsetcolor 2


SQUARE 103 53 13 10 1 FILL
	gadid 100

SQUARE 103 73 13 10 1 FILL
	gadid 101


XCYCLER 100 100 85 17 "" "newdraw"
CSTR Ohne      PLAIN
CSTR Schatten  SHADOW
CSTR Umrandung OUTLINE
	attr title "1/0/Plain/lside/middle/Text Stil:"
	gadtitle left
		gadid 2

XCYCLER 100 120 85 17 "" "align"
CSTR Links     1
CSTR Zentriert 0
CSTR Rechts    2
	attr title "1/0/Plain/lside/middle/Ausrichtung:"
	gadtitle left
		gadid 3


XBUTTON 10 156 102 15 "Ü_bernehmen"
gadfont topaz.font 8 010

guiclose #this

col1 = $pen1
col2 = $pen2

ifexists variable newtitle
	titxt = $newtitle
else
	titxt = $TITLE
endif

ifexists variable newdraw
	draw = $newdraw
else
	draw = $DRAWMODE
endif

ifexists variable align
	mode = $align
else
	mode = $oldmode
endif

gosub WBStartupControl set_title

XBUTTON 114 156 100 15 "_Verwerfen"
gadfont topaz.font 8 001

pen1 = $col1
pen2 = $col2

delvar newtitle
delvar newdraw
delvar newadjust

guiclose #this
