# IupDialog: Example
#   Creates a dialog showing an icon, the "DEFAULTESC" attribute and a simple menu

module dialog1_

using IUP

export
	dialog1

include("../src/libiup_h.jl")

#------------------------example html/examples/C/dialog1.c ----------------------------------
function dialog1()
	IupOpen()	#Initializes IUP

	# Creating dialog's icon
	img = icon_img()
	icon = IupImage(32, 32, img)
	IupSetAttribute (icon, "1", "255 255 255")
	IupSetAttribute (icon, "2", "000 000 000")
	IupSetAttribute (icon, "3", "226 226 226")
	IupSetAttribute (icon, "4", "128 128 128")
	IupSetAttribute (icon, "5", "192 192 192")
	IupSetAttribute (icon, "6", "000 000 255")
	IupSetHandle ("icon", icon)

	# Creating dialog's content
	quit_bt = IupButton("Quit")
	IupSetCallback(quit_bt, "ACTION", cfunction(quit_cb, Int, (),))
	IupSetHandle("quit", quit_bt)

	# Creating dialog's menu
	options = IupMenu(IupItem("Exit","quit_cb"))
	submenu = IupSubmenu("File", options)
	menu = IupMenu(submenu)
	IupSetHandle("menu", menu)

	# Creating main dialog
	dialog = IupDialog(IupVbox(quit_bt))
	IupSetAttribute(dialog, "TITLE", "IupDialog")
	IupSetAttribute(dialog, "MENU", "menu")
	IupSetAttribute(dialog, "CURSOR", "CROSS")
	IupSetAttribute(dialog, "ICON", "icon")
	IupSetAttribute(dialog, "DEFAULTESC", "quit")


	IupShowXY(dialog,IUP_CENTER,IUP_CENTER)

	IupMainLoop()                               # Initializes IUP main loop
	IupClose()                                  # And close it when ready
end

function quit_cb()
	return IUP_CLOSE
end

# defines icon's image
function icon_img()
	img = uint8([
	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
	1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,
	1,3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,2,
	1,3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,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