526
IUP / Re: IUP Linux and Windows
« on: January 09, 2012, 10:14:14 PM »
Here is the submenu.c example converted to ScriptBasic. It's too bad I can't show the multi-level menu in a screen capture.
C Version
ScriptBasic Version
C Version
ScriptBasic Version
Code: [Select]
' IupSubmenu: Example in ScriptBasic
' Creates a dialog with a menu with three submenus.
' One of the submenus has a submenu, which has another submenu.
IMPORT iup.bas
GLOBAL CONST IUP_CENTER = 0xFFFF
'"""***************************************************************************
* Function: *
* Item help callback *
* *
* Description: *
* Shows a message saying that only Help and Exit items performs an operation *
* *
* Value returned: *
* IUP_DEFAULT *
***************************************************************************"""
SUB item_help_cb
Iup::Message ("Warning", "Only Help and Exit items performs an operation")
END SUB
'"""***************************************************************************
* Function: *
* Item exit callback *
* *
* Description: *
* Exits the program *
* *
* Value returned: *
* IUP_DEFAULT *
***************************************************************************"""
SUB item_exit_cb
Iup::ExitLoop = TRUE
END SUB
' Main program
' Initializes IUP
Iup::Open()
' Program begin
' Creates a multiline
text = Iup::Text()
' Sets value of the text and turns on expand
Iup::SetAttributes(text, "VALUE = \"This text is here only to compose\", EXPAND = YES")
' Creates items of menu file
item_new = Iup::Item("New")
item_open = Iup::Item("Open")
item_close = Iup::Item("Close")
item_exit = Iup::Item("Exit", "item_exit_act")
' Creates items of menu edit
item_copy = Iup::Item("Copy")
item_paste = Iup::Item("Paste")
' Creates items for menu triangle
item_scalenus = Iup::Item("Scalenus")
item_isoceles = Iup::Item("Isoceles")
item_equilateral = Iup::Item("Equilateral")
' Create menu triangle
menu_triangle = Iup::Menu(item_equilateral, item_isoceles, item_scalenus)
' Creates submenu triangle
submenu_triangle = Iup::Submenu("Triangle", menu_triangle)
' Creates items for menu create
item_line = Iup::Item("Line")
item_circle = Iup::Item("Circle")
' Creates menu create
menu_create = Iup::Menu(item_line, item_circle, submenu_triangle)
' Creates submenu create
submenu_create = Iup::Submenu("Create", menu_create)
' Creates items of menu help
item_help = Iup::Item("Help", "item_help_act")
' Creates three menus
menu_file = Iup::Menu(item_new, item_open, item_close, Iup::Separator(), item_exit)
menu_edit = Iup::Menu(item_copy, item_paste, Iup::Separator(), submenu_create)
menu_help = Iup::Menu(item_help)
' Creates three submenus
submenu_file = Iup::Submenu("File", menu_file)
submenu_edit = Iup::Submenu("Edit", menu_edit)
submenu_help = Iup::Submenu("Help", menu_help)
' Creates main menu with file menu
menu = Iup::Menu(submenu_file, submenu_edit, submenu_help)
' Registers callbacks
Iup::SetCallback(item_help, "ACTION", ADDRESS(item_help_cb()))
Iup::SetCallback(item_exit, "ACTION", ADDRESS(item_exit_cb()))
' Associates handle "menu" with menu
Iup::SetHandle("menu", menu)
' Creates dialog with a text
dlg = Iup::Dialog(text)
' Sets title and size of the dialog and associates a menu to it
Iup::SetAttributes(dlg, "TITLE=\"IupSubmenu Example\", SIZE = QUARTERxEIGHTH, MENU = menu")
' Shows dialog in the center of the screen
Iup::ShowXY(dlg, IUP_CENTER, IUP_CENTER)
' Initializes IUP main loop
Iup::MainLoop()
' Finishes IUP
Iup::Close()
' Program finished successfully
END








