func mainui() { dlg := iup.Dialog( iup.Attr("TITLE", "Iup Hello World"), "RASTERSIZE=400x300", iup.Hbox( "MARGIN=5x5,GAP=5", iup.Vbox( iup.Label( "EXPAND=HORIZONTAL,ALIGNMENT=ACENTER,FONTSIZE=12", iup.Attr("TITLE", "Welcome to GO-IUP"), ), iup.Label( "EXPAND=YES,ALIGNMENT=ACENTER:ACENTER,WORDWRAP=YES", iup.Attr("TITLE", fmt.Sprintf("%s\nVersion: %s\n\n%s\nVersion: %s", iup.IupName, iup.IupVersion, iup.Name, iup.Version)), ), ), iup.Vbox( iup.Button( "TITLE=OK", "SIZE=50x", func(arg *iup.ButtonAction) { arg.Return = iup.CLOSE }, ), iup.Button( "TITLE=About", "SIZE=50x", func(arg *iup.ButtonAction) { iup.Message("About", "GO-IUP\[email protected] 2011-2012") }, ), ), ), ) defer dlg.Destroy() dlg.Show() iup.MainLoop() }
func (pad *Notepad) init() *Notepad { iup.Menu( iup.SubMenu("TITLE=File", iup.Menu( iup.Item( iup.Attr("TITLE", "New\tCtrl+N"), iup.Attr("TIP", "New File"), func(arg *iup.ItemAction) { pad.NewFile() }, func(arg *iup.ItemHighlight) { pad.ShowStatus(arg.Sender) }, ), iup.Item( iup.Attr("TITLE", "Open\tCtrl+O"), iup.Attr("TIP", "Open File"), func(arg *iup.ItemAction) { runtime.GC() pad.Open() }, func(arg *iup.ItemHighlight) { pad.ShowStatus(arg.Sender) }, ), iup.Item( iup.Attr("TITLE", "Save\tCtrl+S"), iup.Attr("TIP", "Save File"), func(arg *iup.ItemAction) { pad.Save() }, func(arg *iup.ItemHighlight) { pad.ShowStatus(arg.Sender) }, ), iup.Item( iup.Attr("TITLE", "SaveAs"), iup.Attr("TIP", "Save File As..."), func(arg *iup.ItemAction) { pad.SaveAS() }, func(arg *iup.ItemHighlight) { pad.ShowStatus(arg.Sender) }, ), iup.Separator(), iup.Item( iup.Attr("TITLE", "Quit"), iup.Attr("TIP", "Exit Application"), func(arg *iup.ItemAction) { pad.CheckModify() arg.Return = iup.CLOSE }, func(arg *iup.ItemHighlight) { pad.ShowStatus(arg.Sender) }, ), ), ), iup.SubMenu("TITLE=Help", iup.Menu( iup.Item( iup.Attr("TITLE", "About"), iup.Attr("TIP", "About Notepad"), func(arg *iup.ItemAction) { iup.Message("About", "\tNotepad 1.0\n\n\[email protected] 2012\t") }, func(arg *iup.ItemHighlight) { pad.ShowStatus(arg.Sender) }, ), ), ), ).SetName("main_menu") pad.edit = iup.Text( "EXPAND=YES", "MULTILINE=YES", "WORDWRAP=YES", "TABSIZE=4", "NAME=text", func(arg *iup.ValueChanged) { pad.SetModify() }, func(arg *iup.TextCaret) { pad.sts2.SetAttribute("TITLE", fmt.Sprintf("Lin:%d Col:%d ", arg.Lin, arg.Col)) }, func(arg *iup.CommonKeyAny) { key := iup.KeyState(arg.Key) if !key.IsCtrl() { return } switch key.Key() { case 'N': pad.NewFile() case 'O': pad.Open() case 'S': pad.Save() default: return } }, ) pad.sts1 = iup.Label( "TITLE=Ready", "EXPAND=HORIZONTAL", "SIZE=50x", ) pad.sts2 = iup.Label( "TITLE=\"Lin:1 Col:1\"", "EXPAND=NO", "SIZE=60x", ) pad.dlg = iup.Dialog( iup.Attrs( "MENU", "main_menu", "TITLE", "Notepad", "SHRINK", "YES", "SIZE", "300x200", ), iup.Vbox( pad.edit, iup.Hbox( pad.sts1, iup.Fill(), pad.sts2, ), ), func(arg *iup.DialogClose) { pad.CheckModify() arg.Return = iup.CLOSE }, ) return pad }