;;;
;;; test gui commands
;;;
;
call test_messagebox
call test_errordialogbox
call test_yesnobox
call test_inputbox
call test_passwordbox
call test_statusbox
call test_macrodialogbox
call test_listbox
call test_filenamebox
call test_dirnamebox
messagebox "finish all tests" "test"
end

;;;;;;;;;;;;;;;;
;;; messagebox
:test_messagebox
s = "メッセージボックス\nthis is basic test\n3 행"
strspecial s
messagebox s "メッセージボックス"
messagebox "finish messagebox test" "test messagebox"
return

;;;;;;;;;;;;;;;;
;;; error dialog
;;; - Dependence
;;;		messagebox
:test_errordialogbox
messagebox "Please push `continue` button in next window" "test errordialogbox"
this_line_is_error_push_continue
messagebox "finish error dialog test" "test error dialog"
return

;;;;;;;;;;;;;;;;
;;; yesnobox
;;; - Dependence
;;;		messagebox
:test_yesnobox
yes = 0
no = 0
while ((yes == 0) or (no == 0))
	yesnobox "push 是的(yes) or 没有(no)" "test yesnobox"
	if result == 1 yes = yes + 1
	if result == 0 no = no + 1
	sprintf "yes=%d no=%d" yes no
	messagebox inputstr "test yesnobox"
endwhile
sprintf "finish yesnobox test\nyes=%d no=%d" yes no
s = inputstr
strspecial s
messagebox s "test yesnobox"
return

;;;;;;;;;;;;;;;;
;;; inputbox
;;; - Dependence
;;;		messagebox
:test_inputbox
s = "default string"
match = 0
while match == 0
	inputbox "入力 `ok` to finish" "test inputbox" s
	s = inputstr
	sprintf "入力文字列 は `%s`" s
	messagebox inputstr "test inputbox"
	strmatch s "^ok$"
	match = result
endwhile
messagebox "finish inputbox test" "test inputbox"
return

;;;;;;;;;;;;;;;;
;;; passwordbox
;;; - Dependence
;;;		messagebox
:test_passwordbox
match = 0
while match == 0
	passwordbox "`password` と入力すると終了" "test passwordbox"
	s = inputstr
	sprintf "入力文字列 は `%s`" s
	messagebox inputstr "test inputbox"
	strmatch s "^password$"
	match = result
endwhile
messagebox "finish passwordbox test" "test passwordbox"
return

;;;;;;;;;;;;;;;;
;;; statusbox
;;; setdlgpos
;;; closesbox
;;; - Dependence
;;;		messagebox
:test_statusbox
call test_statusbox_centerwindow
;call test_statusbox_setdlgpos
return

; 表示されていない→表示する 時 センタリングされる
; 表示されている時 width=変化しない height=変化する(フィット) pos=変化しない
:test_statusbox_centerwindow
pause_time = 3
statusbox "statusbox message" "test statusbox"
pause pause_time
sprintf2 s "1 line1\n2 line2 \n3 line3\n4 long long long long long line"
strspecial s
statusbox s "test statusbox"
pause pause_time
closesbox
statusbox s "test statusbox"
pause pause_time
statusbox "statusbox message" "test statusbox"
pause pause_time
closesbox
statusbox "statusbox message" "test statusbox"
pause pause_time
closesbox
messagebox "finish statusbox centerwindow test" "test statusbox"
return

:test_statusbox_setdlgpos
pause_time = 1
last_val = 3
statusbox "statusbox message" "test statusbox"
pause pause_time
for i 1 last_val
	x = i*10
	y = i*10
	setdlgpos x y
	sprintf2 s "setdlgpos\ni=%d/%d\n(%d,%d)" i last_val x y
	strspecial s
	statusbox s "test statusbox/setdlgpos"
	pause pause_time
next
closesbox
s = "Please overwrap other window\nwait 5 sec\nbringupbox test"
strspecial s
setdlgpos 0 0
statusbox s "test statusbox"
pause 5
bringupbox
statusbox "bringupbox" "test statusbox"
pause 5
closesbox
setdlgpos -10000 0	  ; go center
messagebox "finish statusbox setdlgpos test" "test statusbox"
return

;;;;;;;;;;;;;;;;
;;; macrodialog box
;;; show
;;; - Dependence
;;;		messagebox
:test_macrodialogbox
call test_macrodialogbox_show
call test_macrodialogbox_move_resize
messagebox "finish macro dialogbox test" "test macro dialogbox"
return

:test_macrodialogbox_show
N = 5
intdim show_flag_list N
show_flag_list[0] = 1
show_flag_list[1] = -1
show_flag_list[2] = 1
show_flag_list[3] = 0
show_flag_list[4] = 1
for i 0 N-1
	show_flag = show_flag_list[i]
	show show_flag
	if show_flag < 0 then
	   s = "macro dialog box was hidden\ncheck task bar"
	elseif show_flag == 0 then
	   s = "macro dialog box was minimize\ncheck task bar"
	elseif show_flag > 0 then
	   s = "macro dialog box was shown\nmove this messagebox and check macro dialog box"
	endif
	sprintf "show %d\n%s" show_flag s
	s = inputstr
	strspecial s
	messagebox s "test macrodialog/show"
next
return

:test_macrodialogbox_move_resize
w = 15
sprintf "move and resize test\nwait %d sec" w
s = inputstr
strspecial s
messagebox s "test macro dialog"
pause w
messagebox "finish move and resize test" "test macro dialog/move and resize"
return

;;;;;;;;;;;;;;;;
;;; listbox
;;; - Dependence
;;;		messagebox
:test_listbox
N = 7
intdim done N
strdim strs N
strdim srcs N
for i 0 N-1
	done[i] = 0
next
srcs[0] = "本気の失敗には価値がある"
srcs[1] = "俺の敵は　だいたい俺です"
srcs[2] = "ちょっとだけ無理なことに挑戦してこーぜ"
srcs[3] = "リーダーというのはやはり安心と興奮を同時にくれる"
srcs[4] = "”止まる”も”進む”もコントロールするのはお前だ"
srcs[5] = "どっちが楽しいかで決めなさい。"
srcs[6] = "悩むなら、なってから悩みなさい"
done_all = 0
done_cancel = 0
prev = 0
while ((done_all == 0) or (done_cancel == 0))
	for i 0 N-1
		if done[i] == 0 then
			s = ""
		else
			s = "[selected]"
		endif
		sprintf2 s "%s %s" s srcs[i]
		strs[i] = s
	next
	if done_all == 0 then
		msg = "select one from list and `ok`"
		if done_cancel == 0 then
			strconcat msg " or `cancel`"
		endif
	else
		msg = "push `cancel`"
	endif
	listbox msg "test listbox" strs prev
	if result < 0 then
		done_cancel = 1
		continue
	endif
	prev = result
	if done[result] == 0 then
		done[result] = 1
	else
		done[result] = 0
	endif
	done_all = 1
	for i 0 N-1
		if done[i] == 0 then
			done_all = 0
			break
		endif
	next
endwhile
messagebox "finish listbox test" "test listbox"
return

;;;;;;;;;;;;;;;;
;;; filenamebox
;;; - Dependence
;;;		messagebox
:test_filenamebox
filenamebox "ファイルを選んでください(load)" 0 "c:\"
sprintf2 s "result %d inputstr %s" result inputstr
messagebox s "test fienamebox"
filenamebox "ファイルを選んでください(save)" 1 "c:\windows"
sprintf2 s "result %d inputstr %s" result inputstr
messagebox s "test fienamebox"
messagebox "finish filenaebox test" "test filenamebox"
return

;;;;;;;;;;;;;;;;
;;; dirnamebox
;;; - Dependence
;;;		messagebox
:test_dirnamebox
dirnamebox "whereディレクトリ" "c:\"
sprintf2 s "result %d inputstr %s" result inputstr
messagebox s "test fienamebox"
messagebox "finish dirnamebox test" "test dirnambox"
return


