Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Support

Pages: 1 ... 34 35 [36] 37 38 ... 59
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
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

527
IUP / IUP Linux and Windows - Build 9
« on: January 09, 2012, 06:26:27 PM »
BUILD 9

This release allows assigning multiple callback functions to a single control.

Sure would be nice to hear some feedback from others that have given the ScriptBasic IUP environment a try.

I don't see the point of adding the extended IUP API (OpenGL, Matrix, Drawing, Embedded Browser, ...) binding to the project if no one is going to use the core IUP features.

This will be the last release of the core IUP extension module unless someone finds a problem with it.

Enjoy!



528
IUP / IUP Linux and Windows - Build 8
« on: January 07, 2012, 05:57:24 PM »
BUILD 8

This fixes a couple things with Iup::Image and a fix to integers in the argument passing macro. (thanks Armando)






529
IUP / Re: IUP Linux and Windows
« on: January 07, 2012, 04:35:10 PM »
Icon, menu and a cursor change to show with this dialog1.c example.

C Version

Code: [Select]
' IupDialog: Example in ScriptBasic
' Creates a dialog showing an icon, the "DEFAULTESC" attribute and a simple menu

IMPORT iup.bas

GLOBAL CONST IUP_CENTER = 0xFFFF

' defines icon's image
img = """
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,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,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,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,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,5,5,5,5,5,5,5,5,5,5,5,5,4,2,
1,3,5,5,6,6,6,6,6,6,5,5,6,6,5,5,6,6,5,5,6,6,6,6,6,6,6,5,5,5,4,2,
1,3,5,5,6,6,6,6,6,6,5,5,6,6,5,5,6,6,5,5,6,6,6,6,6,6,6,6,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,6,5,5,6,6,6,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,5,5,5,5,6,6,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,5,5,5,5,6,6,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,5,5,5,5,6,6,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,6,5,5,6,6,6,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,6,6,6,6,6,6,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,6,6,6,6,6,5,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,5,5,5,5,5,5,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,5,5,5,5,5,5,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,5,5,5,5,5,5,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,5,5,5,5,5,5,5,5,4,2,
1,3,5,5,5,5,6,6,5,5,5,5,6,6,5,5,6,6,5,5,6,6,5,5,5,5,5,5,5,5,4,2,
1,3,5,5,6,6,6,6,6,6,5,5,6,6,6,6,6,6,5,5,6,6,5,5,5,5,5,5,5,5,4,2,
1,3,5,5,6,6,6,6,6,6,5,5,5,6,6,6,6,5,5,5,6,6,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,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,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,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,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,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,5,5,5,5,5,5,5,5,5,5,5,5,4,2,
1,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
"""

SUB quit_cb
  Iup::ExitLoop = TRUE
END SUB

Iup::Open()

' Creating dialog's icon
icon = Iup::Image(32, 32, Iup::CreateImg(img))
Iup::SetAttribute(icon, "1", "255 255 255")
Iup::SetAttribute(icon, "2", "000 000 000")
Iup::SetAttribute(icon, "3", "226 226 226")
Iup::SetAttribute(icon, "4", "128 128 128")
Iup::SetAttribute(icon, "5", "192 192 192")
Iup::SetAttribute(icon, "6", "000 000 255")
Iup::SetHandle("icon", icon)

' Creating dialog's content
quit_bt = Iup::Button("Quit")
Iup::SetCallback(quit_bt, "ACTION", ADDRESS(quit_cb()))
Iup::SetHandle("quit", quit_bt)

' Creating dialog's menu
options = Iup::Menu(Iup::Item("Exit","quit_cb"))
submenu = Iup::Submenu("File", options)
menu = Iup::Menu(submenu)
Iup::SetHandle("menu", menu)

' Creating main dialog
dialog = Iup::Dialog(Iup::Vbox(quit_bt))
Iup::SetAttribute(dialog, "TITLE", "IupDialog")
Iup::SetAttribute(dialog, "MENU", "menu")
Iup::SetAttribute(dialog, "CURSOR", "CROSS")
Iup::SetAttribute(dialog, "ICON", "icon")
Iup::SetAttribute(dialog, "DEFAULTESC", "quit")

Iup::ShowXY(dialog, IUP_CENTER, IUP_CENTER)
Iup::MainLoop()
Iup::Close()
END


530
IUP / Re: IUP Linux and Windows
« on: January 07, 2012, 01:27:45 PM »
Here is the filedlg.c example in ScriptBasic.

C Version

Code: [Select]
' IupFileDlg Example in ScriptBasic
' Shows a typical file-saving dialog.

IMPORT iup.bas

GLOBAL CONST IUP_CENTER = 0xFFFF

Iup::Open()
Iup::SetLanguage("ENGLISH")

filedlg = Iup::FileDlg()

Iup::SetAttributes(filedlg, "DIALOGTYPE = SAVE, TITLE = \"File Save\"")
Iup::SetAttributes(filedlg, "FILTER = \"*.sb\", FILTERINFO = \"ScriptBasic Files\"")

Iup::Popup(filedlg, IUP_CENTER, IUP_CENTER)

response = Iup::GetInt(filedlg, "STATUS")
IF response = 1 THEN Iup::Message("New file",Iup::GetAttribute(filedlg, "VALUE"))
IF response = 0 THEN Iup::Message("File already exists",Iup::GetAttribute(filedlg, "VALUE"))
IF response = -1 THEN Iup::Message("IupFileDlg","Operation Canceled")

Iup::Destroy(filedlg)
Iup::Close()
END


531
IUP / Re: IUP Linux and Windows
« on: January 06, 2012, 10:41:46 PM »
Here is the button.c example converted to ScriptBasic.

C Version

Code: [Select]
'"""**************************************************************************
 *                             IupButton example                             *
 *   Description : Creates four buttons. The first uses images, the second   *
 *                 turns the first on and off, the third exits the           *
 *                 application and the last does nothing                     *
 **************************************************************************"""

IMPORT iup.bas

' Defines released button's image
pixmap_release = """
       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,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2,
       1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2,
       1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2,
       1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
       2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
"""

' Defines pressed button's image
pixmap_press = """
       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,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,4,4,3,3,3,3,3,2,2,
       1,1,3,3,3,3,4,4,4,4,3,3,3,3,2,2,
       1,1,3,3,3,3,4,4,4,4,3,3,3,3,2,2,
       1,1,3,3,3,3,3,4,4,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
       2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
"""

' Defines inactive button's image
pixmap_inactive = """
       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,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2,
       1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2,
       1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2,
       1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
       1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
       2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
"""

GLOBAL CONST IUP_BUTTON1 = "1"
GLOBAL CONST IUP_CENTER = 65535


'"""***************************************************************************
 * Function:                                                                  *
 * On off button callback                                                     *
 *                                                                            *
 * Description:                                                               *
 * Callback called when the on/off button is activated. Turns the button with *
 * image on and off                                                           *
 *                                                                            *
 * Parameters received:                                                       *
 * self - element identifier                                                  *
 *                                                                            *
 * Value returned:                                                            *
 * IUP_DEFAULT                                                                *
 ***************************************************************************"""
SUB btn_on_off_cb

  ' Recovers "btn_image" handle
  btn_image = Iup::GetHandle( "btn_image" )

  ' If the button with with image is active...
  IF Iup::GetAttribute( btn_image, "ACTIVE" ) = "YES" THEN

    ' Deactivates the button with image
    Iup::SetAttribute( btn_image, "ACTIVE","NO" )

  ' else it is inactive
  ELSE
    ' Activates the button with image
    Iup::SetAttribute( btn_image, "ACTIVE", "YES" )
  END IF

  ' Executed function successfully
END SUB


'"""***************************************************************************
 * Function:                                                                  *
 * Button with image button callback                                          *
 *                                                                            *
 * Description:                                                               *
 * Callback called when the image button is pressed or released. Shows a      *
 * message saying if the button was pressed or released                       *
 *                                                                            *
 * Parameters received:                                                       *
 * self - identifies the canvas that activated the function’s execution.      *
 * b    - identifies the activated mouse button:                              *
 *                                                                            *
 * IUP_BUTTON1 left mouse button (button 1)                                   *
 * IUP_BUTTON2 middle mouse button (button 2)                                 *
 * IUP_BUTTON3 right mouse button (button 3)                                  *
 *                                                                            *
 * e     - indicates the state of the button:                                 *
 *                                                                            *
 * 0 mouse button was released                                                *
 * 1 mouse button was pressed                                                 *
 *                                                                            *
 * Value returned:                                                            *
 * IUP_DEFAULT                                                                *
 ***************************************************************************"""
SUB btn_image_button_cb

  ' If the left button changed its state...
  IF CHR(Iup::GetBtnPressed()) = IUP_BUTTON1 THEN

    ' Recovers "text" handle
    text = Iup::GetHandle( "text" )

    ' If the button was pressed...
    IF Iup::GetBtnState() = 1 THEN

      ' Sets text's value
      Iup::SetAttribute( text, "VALUE", "Red button pressed" )

    ' else the button was released
    ELSE

      ' Sets text's value
      Iup::SetAttribute( text, "VALUE", "Red button released" )
    END IF
  END IF

' Executed function successfully
END SUB


'"""***************************************************************************
 * Function:                                                                  *
 * Exit button callback                                                       *
 *                                                                            *
 * Description:                                                               *
 * Callback called when exit button is activated. Exits the program           *
 *                                                                            *
 * Parameters received:                                                       *
 * self - element identifier                                                  *
 *                                                                            *
 * Value returned:                                                            *
 * IUP_DEFAULT                                                                *
 ***************************************************************************"""
SUB btn_exit_cb

  ' Exits the program
  Iup::ExitLoop = TRUE

END SUB

'"""***************************************************************************
 * Main function                                                              *
 ***************************************************************************"""

  ' Initializes IUP
  Iup::Open()

  ' Creates a text
  text = Iup::Text()
  Iup::SetAttribute(text,"SIZE","100x")

  ' Turns on read-only mode
  Iup::SetAttribute( text, "READONLY", "YES")

  ' Associates text with handle "text"
  Iup::SetHandle ( "text", text )

  ' Defines released button's image size
  img_release = Iup::Image(16, 16, Iup::CreateImg(pixmap_release))

  ' Defines released button's image colors
  Iup::SetAttribute( img_release, "1", "215 215 215" )
  Iup::SetAttribute( img_release, "2", "40 40 40" )
  Iup::SetAttribute( img_release, "3", "30 50 210" )
  Iup::SetAttribute( img_release, "4", "240 0 0" )

  ' Associates img_release with handle "img_release"
  Iup::SetHandle( "img_release", img_release)

  ' Defines pressed button's image size
  img_press = Iup::Image( 16, 16, Iup::CreateImg(pixmap_press))

  ' Defines pressed button's image colors
  Iup::SetAttribute( img_press, "1", "40 40 40" )
  Iup::SetAttribute( img_press, "2", "215 215 215" )
  Iup::SetAttribute( img_press, "3", "0 20 180" )
  Iup::SetAttribute( img_press, "4", "210 0 0" )

  ' Associates img_press with handle "img_press"
  Iup::SetHandle ( "img_press", img_press )

  ' Defines inactive button's image size
  img_inactive = Iup::Image( 16, 16, Iup::CreateImg(pixmap_inactive))

  ' Defines inactive button's image colors
  Iup::SetAttribute( img_inactive, "1", "215 215 215" )
  Iup::SetAttribute( img_inactive, "2", "40 40 40" )
  Iup::SetAttribute( img_inactive, "3", "100 100 100" )
  Iup::SetAttribute( img_inactive, "4", "200 200 200" )

  ' Associates img_inactive with handle "img_inactive"
  Iup::SetHandle ("img_inactive", img_inactive )

  ' Creates a button
  btn_image = Iup::Button( "Button with image", "btn_image")

  ' Sets released, pressed and inactive button images
  Iup::SetAttribute( btn_image, "IMAGE", "img_release" )
  Iup::SetAttribute( btn_image, "IMPRESS", "img_press" )
  Iup::SetAttribute( btn_image, "IMINACTIVE", "img_inactive" )

  ' Associates button callback with action bti_button_act
  Iup::SetAttribute( btn_image, "BUTTON_CB", "btn_image_button")

  ' Associates btn_image with handle "btn_image"
  Iup::SetHandle( "btn_image", btn_image )

  ' Creates a button
  btn_big = Iup::Button( "Big useless button" )

  ' Sets big button size
  Iup::SetAttribute( btn_big, "SIZE", "EIGHTHxEIGHTH" )

  ' Creates a button entitled Exit associated with action exit_act
  btn_exit = Iup::Button( "Exit", "btn_exit")

  ' Creates a button entitled on/off associated with action onoff_act
  btn_on_off = Iup::Button( "on/off", "btn_on_off")

  ' Creates dialog with the four buttons and the text
  dlg = Iup::Dialog _
        ( _
          Iup::Vbox _
          ( _
            Iup::Hbox _
            ( _
              btn_image, _
              btn_on_off, _
              btn_exit), _
            text, _
            btn_big))


  ' Sets dialogs title to IupButton turns resize, maximize, minimize and menubox off
  Iup::SetAttributes( dlg, "EXPAND = YES, TITLE = IupButton, RESIZE = YES" )
  Iup::SetAttributes( dlg, "MENUBOX = NO, MAXBOX = NO, MINBOX = NO" )

  ' Registers callbacks
  Iup::SetCallback( btn_exit, "ACTION", ADDRESS( btn_exit_cb() ))
  Iup::SetCallback( btn_on_off, "ACTION", ADDRESS( btn_on_off_cb() ))
  Iup::SetCallback( btn_image, "BUTTON_CB", ADDRESS( btn_image_button_cb() ))

  ' Shows dialog on 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


532
IUP / IUP Linux and Windows - Build 7
« on: January 04, 2012, 05:15:33 PM »
BUILD 7

  • Iup::SetAtt - now supports multiple attribute pairs and setting the handle name if provided.
  • Iup::Createp - now supports appending children to containers.


So far I have been able to eliminate NULL as a argument to terminate parameter lists. With optional parameter support and knowing how many arguments were passed to the interface module, (SB API) the need for a NULL argument as a list terminator dissipated.

533
IUP / Re: IUP Linux and Windows
« on: January 04, 2012, 12:53:59 PM »
I'm in the process of converting the C examples on the IUP project site.

C Version


ScriptBasic Version
Code: [Select]
' Iup Alarm: Example in SB
' Shows a dialog similar to the one shown when you exit a program without saving.

IMPORT iup.bas

' Initializes IUP
  Iup::Open()

' Executes IupAlarm
  response = Iup::Alarm ("IupAlarm Example", "File not saved! Save it now?", "Yes", "No", "Cancel")

' Shows a message for each selected button
  IF response = 1 THEN Iup::Message ("Save file", "File saved successfully - leaving program")
  IF response = 2 THEN Iup::Message ("Save file", "File not saved - leaving program anyway")
  IF response = 3 THEN Iup::Message ("Save file", "Operation canceled")
 
' Finishes IUP
  Iup::Close()

' Program finished successfully
  END








534
IUP / Re: IUP Linux and Windows
« on: January 03, 2012, 06:19:05 PM »
One of my goals with the ScriptBasic IUP binding was to be able to use to output of the IUP dialog layout tool (see attached) to generate screen code I could use. Currently the dialog layout tool only generates C, Lua and LED source code. The  C output was close enough that with a few tweaks, I could get it to run in SB.

Original C output
Code: [Select]
/*   Generated by IupLayoutDialog export to C.   */

#include <stdlib.h>
#include <iup.h>

Ihandle* create_dialog_iupdict2(void)
{
  Ihandle* containers[10];

  containers[4] = IupSetAtt(NULL, IupCreatep("hbox",
      IupSetAtt(NULL, IupCreate("list"),
        "EXPAND", "HORIZONTAL",
        "SIZE", "120x",
        "VALUE", "1",
        "DROPDOWN", "YES",
        NULL),
      IupSetAtt(NULL, IupCreate("button"),
        "SIZE", "50x",
        "TITLE", "Fetch",
        NULL),
      NULL),
    "GAP", "5",
    NULL);

  containers[3] = IupSetAtt(NULL, IupCreatep("frame",
      containers[4],
      NULL),
    "TITLE", "Servers",
    NULL);

  containers[6] = IupSetAtt(NULL, IupCreatep("hbox",
      IupSetAtt(NULL, IupCreate("button"),
        "SIZE", "50x",
        "TITLE", "About",
        NULL),
      IupSetAtt(NULL, IupCreate("button"),
        "SIZE", "50x",
        "TITLE", "Clear",
        NULL),
      IupSetAtt(NULL, IupCreate("button"),
        "SIZE", "50x",
        "TITLE", "Exit",
        NULL),
      NULL),
    "GAP", "5",
    NULL);

  containers[5] = IupSetAtt(NULL, IupCreatep("frame",
      containers[6],
      NULL),
    "TITLE", "Controls",
    NULL);

  containers[2] = IupSetAtt(NULL, IupCreatep("hbox",
      containers[3],
      containers[5],
      NULL),
    "GAP", "10",
    NULL);

  containers[7] = IupSetAtt(NULL, IupCreatep("frame",
      IupSetAtt(NULL, IupCreate("list"),
        "EXPAND", "YES",
        "VISIBLELINES", "1",
        NULL),
      NULL),
    "TITLE", "Dictionaries",
    NULL);

  containers[8] = IupSetAtt(NULL, IupCreatep("frame",
      IupSetAtt(NULL, IupCreate("text"),
        "EXPAND", "YES",
        "MULTILINE", "YES",
        NULL),
      NULL),
    "TITLE", "Translation",
    NULL);

  containers[9] = IupSetAtt(NULL, IupCreatep("hbox",
      IupSetAtt(NULL, IupCreate("label"),
        "SIZE", "x12",
        "TITLE", "Enter Word to Search For:",
        NULL),
      IupSetAtt(NULL, IupCreate("text"),
        "EXPAND", "HORIZONTAL",
        NULL),
      IupSetAtt(NULL, IupCreate("button"),
        "SIZE", "50x",
        "TITLE", "Search",
        NULL),
      IupSetAtt(NULL, IupCreate("toggle"),
        "SIZE", "x12",
        "TITLE", "ALL",
        NULL),
      IupSetAtt(NULL, IupCreate("toggle"),
        "SIZE", "x12",
        "TITLE", "UTF-8",
        NULL),
      NULL),
    "GAP", "10",
    NULL);

  containers[1] = IupSetAtt(NULL, IupCreatep("vbox",
      containers[2],
      containers[7],
      containers[8],
      containers[9],
      NULL),
    "MARGIN", "10x10",
    NULL);

  containers[0] = IupSetAtt(NULL, IupCreatep("dialog",
      containers[1],
      NULL),
    "TITLE", "Thesaurus",
    "RASTERSIZE", "875x638",
    NULL);

  return containers[0];
}

Converted to ScriptBasic
Code: [Select]
IMPORT iup.bas

Iup::Open()

  containers[4] = Iup::SetAtt("", Iup::Createp("hbox", _
      Iup::SetAtt("", Iup::Create("list"), _
        "EXPAND", "HORIZONTAL", _
        "SIZE", "120x", _
        "VALUE", "1", _
        "DROPDOWN", "YES"), _
      Iup::SetAtt("", Iup::Create("button"), _
        "SIZE", "50x", _
        "TITLE", "Fetch")), _
    "GAP", "5")

  containers[3] = Iup::SetAtt("", Iup::Createp("frame", _
      containers[4]), _
    "TITLE", "Servers")

  containers[6] = Iup::SetAtt("", Iup::Createp("hbox", _
      Iup::SetAtt("", Iup::Create("button"), _
        "SIZE", "50x", _
        "TITLE", "About"), _
      Iup::SetAtt("", Iup::Create("button"), _
        "SIZE", "50x", _
        "TITLE", "Clear"), _
      Iup::SetAtt("", Iup::Create("button"), _
        "SIZE", "50x", _
        "TITLE", "Exit")), _
    "GAP", "5")

  containers[5] = Iup::SetAtt("", Iup::Createp("frame", _
      containers[6]), _
    "TITLE", "Controls")

  containers[2] = Iup::SetAtt("", Iup::Createp("hbox", _
      containers[3], _
      containers[5]), _
    "GAP", "10")

  containers[7] = Iup::SetAtt("", Iup::Createp("frame", _
      Iup::SetAtt("", Iup::Create("list"), _
        "EXPAND", "YES", _
        "VISIBLELINES", "1")), _
    "TITLE", "Dictionaries")

  containers[8] = Iup::SetAtt("", Iup::Createp("frame", _
      Iup::SetAtt("", Iup::Create("text"), _
        "EXPAND", "YES", _
        "MULTILINE", "YES")), _
    "TITLE", "Translation")

  containers[9] = Iup::SetAtt("", Iup::Createp("hbox", _
      Iup::SetAtt("", Iup::Create("label"), _
        "SIZE", "x12", _
        "TITLE", "Enter Word to Search For:"), _
      Iup::SetAtt("", Iup::Create("text"), _
        "EXPAND", "HORIZONTAL"), _
      Iup::SetAtt("", Iup::Create("button"), _
        "SIZE", "50x", _
        "TITLE", "Search"), _
      Iup::SetAtt("", Iup::Create("toggle"), _
        "SIZE", "x12", _
        "TITLE", "ALL"), _
      Iup::SetAtt("", Iup::Create("toggle"), _
        "SIZE", "x12", _
        "TITLE", "UTF-8")), _
    "GAP", "10")

  containers[1] = Iup::SetAtt("", Iup::Createp("vbox", _
      containers[2], _
      containers[7], _
      containers[8], _
      containers[9]), _
    "MARGIN", "10x10")

  containers[0] = Iup::SetAtt("", Iup::Createp("dialog", _
      containers[1]), _
    "TITLE", "Thesaurus", _
    "RASTERSIZE", "875x638")
    Iup::SetCallback(containers[0],"CLOSE_CB",ADDRESS(Win_exit()))

Iup::Show(containers[0])

Iup::MainLoop()
Iup::Close()
END

SUB Win_exit
  Iup::ExitLoop = TRUE
END SUB

535
IUP / Re: IUP Linux and Windows
« on: January 02, 2012, 02:37:07 PM »
Who will be the first one (other than me) to post an example of IUP working with ScriptBasic on either Windows or Linux?

Based on the number of downloads and views of this thread, I'm willing to bet someone gave it a try.

If you're not a member of the forum, (what are you waiting for?) send me your code to post. (support@scriptbasic.org)


536
IUP / Re: IUP Linux and Windows - Build 6
« on: December 31, 2011, 03:57:17 PM »
BUILD 6

As promised, here are the list functions returned in a ScriptBasic array. (see previous post)

Iup::GetAllAttributes
Iup::GetAllClasses
Iup::GetClassAttributes
Iup::GetClassCallbacks
Iup::GetAllNames
Iup::GetAllDialogs

537
IUP / Re: IUP Linux and Windows
« on: December 29, 2011, 11:49:35 PM »
I was able to get the IUP functions that return lists (C string arrays) to return in a ScriptBasic array. Note that I didn't initialize the variable I passed to the Iup::GetAllNames() function and it returned as a populated SB array. That's another one off the TODO list. I'll post BUILD 6 after a bit more testing of other list baring functions.

Quote
int IupGetAllNames(char** names, int max_n);

Returns the names of all interface elements that have an associated name using IupSetHandle or using LED.

Code: [Select]
num_names = Iup::GetAllNames(names, 0)

FOR x = 0 TO num_names-1
  PRINT names[x],"\n"
NEXT x
PRINT "Number of Names: ",num_names,"\n"

jrs@laptop:~/sb/test$ scriba iupdict.sb
IMGPAPER
IMGCOLLAPSED
Servers  <-- Me
Fetch  <-- Me
IMGEXPANDED
Window  <-- Me
IupSpinDownImage
IUP About  <-- Me
IMGBLANK
IMGLEAF
IupSpinUpImage
Number of Names: 11
jrs@laptop:~/sb/test$


Quote
int IupGetAllClasses(char** names, int max_n);


Returns the names of all registered classes.


jrs@laptop:~/sb/test$ scriba iupdict.sb
dialog
radio
vbox
imagergb
label
tree
sbox
messagedlg
list
fill
image
imagergba
canvas
split
text
submenu
spin
fontdlg
tabs
hbox
val
menu
clipboard
item
frame
timer
multiline
user
normalizer
cbox
button
filedlg
spinbox
colordlg
zbox
separator
toggle
progressbar
Number of Names: 38
jrs@laptop:~/sb/test$


538
General Discussions / Installing ScriptBasic
« on: December 29, 2011, 12:22:06 PM »
If you are new to ScriptBasic and would like to give it a try, here are a few helpful tips to get you up and going with the Basic.

The following is based on using runtime versions of ScriptBasic.

Windows

1. Download the SB3 Windows 32 runtime.
2. Install it in a subdirectory of your choice. (I normally install SB in C:\scriptbasic)
3. Add C:\scriptbasic\bin to your search path
4. Create your scriba.conf file. (binary format)

This is a bare bones text version of scriba.conf I use.

scriba.conf.txt
Code: [Select]
dll ".dll"
module "c:\\scriptbasic\\modules\\"
include "c:\\scriptbasic\\include\\"
maxinclude 100
preproc (
  internal (
    dbg "c:\\scriptbasic\\modules\\dbg.dll"
    )
)
maxstep 0
maxlocalstep 0
maxlevel 3000
maxmem 0

To compile the ScriptBasic configuration file to a binary format, do the following at the console command line.

scriba -k scriba.conf.txt

This will create the binary version of your scriba.conf in your WINDOWS / WINXP system directory.
Hint: Move the binary version to the C:\scriptbasic\bin directory where you edited the text version and the binary will be created there from then on.

5. Download the latest IUP for Windows ZIP and put the iup.dll in the modules directory and the iup.bas in the include directory.

That should get you going with ScriptBasic.

I will post a Linux ScriptBasic install summary soon.


    

539
IUP / Re: IUP Linux and Windows
« on: December 28, 2011, 08:54:48 PM »
I was playing around with the IUP control attributes and noticed the FLAT attribute for buttons. With this attribute set to YES, the button looks like a label until you mouse over it.






I'm looking forward to finishing this up and becoming a SB user again. I have a deeper appreciation for all the hard work Peter Verhas put into ScriptBasic after creating this extension module. It didn't hit me how extensive the IUP API was until I already lost site of shore.  :o

540
IUP / Re: IUP Linux and Windows - Build 5
« on: December 26, 2011, 07:20:04 PM »
BUILD 5

I was able to get functions that supported a varying number of child controls working internally in C. (IUP Variadic functions) This version will allow the traditional nesting of functions you see commonly in C IUP examples.

Ihandle* IupButton(const char *title, const char *action);  // Support for optional arguments
Iup::Button()
Iup::Button("Button Title")
Iup::Button("Button Title", "ACTION")

Ihandle* IupHbox(Ihandle *child, ...);
Iup::Hbox()
Iup::Hbox(but1, but2, but3)  // Support for multiple children

Code: [Select]
IMPORT iup.bas

Iup::Open()

win = Iup::SetAttributes(Iup::Dialog( _
         Iup::Hbox( _
            Iup::SetAttributes(Iup::Button("Portable"),"EXPAND=HORIZONTAL"), _
            Iup::SetAttributes(Iup::Button("User"),"EXPAND=HORIZONTAL"), _
            Iup::SetAttributes(Iup::Button("Interface"),"EXPAND=HORIZONTAL") _
                  ) _
                                     ),"TITLE=IUP, SIZE=200x40")


Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))

Iup::Show(win)

Iup::MainLoop()
Iup::Close()
END

SUB Win_exit
  Iup::ExitLoop = TRUE
END SUB



Pages: 1 ... 34 35 [36] 37 38 ... 59