ScriptBasic

Extension Modules => Extension Modules => IUP => Topic started by: Support on November 03, 2011, 10:27:21 PM

Title: IUP Linux and Windows
Post by: Support on November 03, 2011, 10:27:21 PM
I'm glad that everyone is happy with GTK-Server but if you would have looked behind door #2, ...   ;)

The following is the status of the core IUP extension module. Functions that start with a * haven't been implemented yet. (stubs)

TODO List

IUP is an extensive library and wrapping it to work with ScriptBasic is going to take time. The SB macros help a lot but there is always something that crops up that puts the wagons in a circle.


System
Iup::Open
Iup::Close
Iup::Version
Iup::Load
Iup::LoadBuffer
Iup::SetLanguage
Iup::GetLanguage

Attribute
Iup::StoreAttribute
Iup::StoreGlobalAttribute
Iup::StoreAttributeId
Iup::StoreGlobalAttributeId
Iup::SetAttribute
Iup::SetGlobalAttribute
Iup::SetAttributeId
Iup::SetGlobalAttributeId
Iup::SetfAttribute
Iup::SetfAttributeId
Iup::SetfAttributeId2
Iup::SetAttributes
Iup::ResetAttribute
Iup::ResetGlobalAttribute
Iup::SetAtt
Iup::SetAttributeHandle
Iup::GetAttributeHandle
Iup::GetAttribute
Iup::GetAttributeId
Iup::GetAllAttributes
Iup::GetAttributes
Iup::GetFloat
Iup::GetFloatId
Iup::GetFloatId2
Iup::GetInt
Iup::GetInt2
* Iup::GetIntInt
Iup::GetIntId
Iup::GetIntId2
Iup::StoreGlobal
Iup::SetGlobal
Iup::GetGlobal

Events
GetEvent  (used internally)
Iup::MainLoop
Iup::MainLoopLevel
Iup::LoopStep
Iup::LoopStepWait
Iup::ExitLoop
Iup::Flush
Iup::GetCallback
Iup::SetCallback
* Iup::SetCallbacks
Iup::GetActionName
Iup::SetFunction
Iup::RecordInput
Iup::PlayInput

Layout
Iup::Create
Iup::Destroy
Iup::Map
Iup::Unmap
Iup::GetAllClasses
Iup::GetClassName
Iup::GetClassType
Iup::ClassMatch
Iup::GetClassAttributes
Iup::GetClassCallbacks
Iup::SaveClassAttributes
Iup::CopyClassAttributes
Iup::SetClassDefaultAttribute
Iup::Fill
Iup::Hbox
Iup::Vbox
Iup::Zbox
Iup::Radio
Iup::Normalizer
Iup::Cbox
Iup::Sbox
Iup::Split
Iup::Append
Iup::Detach
Iup::Insert
Iup::InsertTop
Iup::Reparent
Iup::GetParent
Iup::GetChild
Iup::GetChildPos
Iup::GetChildCount
Iup::GetNextChild
Iup::GetBrother
Iup::GetDialog
Iup::GetDialogChild
Iup::Refresh
Iup::RefreshChildren
Iup::Update
Iup::UpdateChildren
Iup::Redraw
Iup::ConvertXYToPos

Dialog
Iup::Dialog
Iup::Popup
Iup::Show
Iup::ShowXY
Iup::Hide
Iup::FileDlg
Iup::MessageDlg
Iup::ColorDlg
Iup::FontDlg
Iup::Alarm
Iup::GetFile
Iup::GetColor
* Iup::GetParam
Iup::GetText
* Iup::ListDialog
Iup::Message
Iup::LayoutDialog
Iup::ElementPropertiesDialog

Controls
Iup::Button
Iup::Canvas
Iup::Frame
Iup::Label
Iup::List
Iup::MultiLine
Iup::ProgressBar
Iup::Spin
Iup::Tabs
* Iup::Tabsv
Iup::Text
Iup::Toggle
Iup::Tree
Iup::Val

Resources
Iup::Image
Iup::ImageRGB
Iup::ImageRGBA
Iup::NextField
Iup::PreviousField
Iup::GetFocus
Iup::SetFocus
Iup::Item
Iup::Menu
* Iup::Menuv
Iup::Separator
Iup::Submenu
Iup::SetHandle
Iup::GetHandle
Iup::GetName
Iup::GetAllNames
Iup::GetAllDialogs
Iup::Clipboard
Iup::Timer
Iup::User
Iup::Help

Helper Functions
Iup::GetListText
Iup::Info


IUP Control Gallery (http://www.tecgraf.puc-rio.br/iup/en/gallery.html)

IUP Project Site (http://www.tecgraf.puc-rio.br/iup/)
Title: Re: IUP Linux and Windows
Post by: Support on December 07, 2011, 11:53:54 AM
Status Update

I have the controls and attribute IUP functions pretty much done. I'm working on the event section so callbacks call SB FUNCTION/SUB script routines to process events. There is still work to be done after events to allow passing multiple control IDs to a IUP function. (handled internally with IupAppend)

Won't be long now ...

P.S.

If you have any interest in this, now would be a good time to start reviewing the IUP API documentation (http://www.tecgraf.puc-rio.br/iup/).
Title: Re: IUP Linux and Windows
Post by: Support on December 16, 2011, 05:09:03 PM
I'm making progress and have a quick example to show. I hope to have a beta soon.

Code: [Select]
' MAIN

IMPORT iup.bas

SUB Btn1_clicked
  PRINT "BUTTON 1 Event\n"
END SUB

SUB Btn2_clicked
  PRINT "BUTTON 2 Event\n"
END SUB

SUB Btn3_clicked
  PRINT "BUTTON 3 Event\n"
END SUB

SUB Win_exit
  Iup::ExitLoop = TRUE
END SUB

Iup::Open()

win = Iup::Create("dialog")
Iup::SetAttributes(win, "TITLE=\"Test Dialog\", SIZE=300x200")
horzbox = Iup::Create("hbox")
Iup::SetAttributes(horzbox, "GAP=5")
btn1 = Iup::Create("button")
Iup::SetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")
btn2 = Iup::Create("button")
Iup::SetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")
btn3 = Iup::Create("button")
Iup::SetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")

Iup::Append(horzbox, btn1)
Iup::Append(horzbox, btn2)
Iup::Append(horzbox, btn3)
Iup::Append(win, horzbox)

Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))
Iup::SetCallback(btn1,"ACTION",ADDRESS(Btn1_clicked()))
Iup::SetCallback(btn2,"ACTION",ADDRESS(Btn2_clicked()))
Iup::SetCallback(btn3,"ACTION",ADDRESS(Btn3_clicked()))

Iup::Show(win)

Iup::MainLoop()

Iup::Close()

END

jrs@laptop:~/sb/test$ scriba puitest.sb
BUTTON 1 Event
BUTTON 2 Event
BUTTON 3 Event
jrs@laptop:~/sb/test$

Title: Re: IUP Linux and Windows
Post by: Support on December 17, 2011, 08:55:24 PM
I'm going to give this a try in Windows and if all goes well, I will release a work in progress beta that should allow you to create dialogs and play with controls. I still have some convenience features to add but it's getting pretty close to a version 1.0 release.
Title: Re: IUP Linux and Windows
Post by: Support on December 19, 2011, 12:32:47 AM
Here is a more meaningful example. It seems Peter's Thesaurus program has become the Hello World for Basic GUI toolkit integrators.  :D

Code: [Select]
IMPORT iup.bas

servers[0]="dict.org"
servers[1]="dict1.us.dict.org"
servers[2]="all.dict.org"

about="""This is a Demo
of the IUP GUI Binding
for Scriptbasic"""

' Initialize IUP
Iup::Open()

' Create main window

win = Iup::Create("dialog")
  Iup::SetAttributes(win, "TITLE=Thesaurus, SIZE=500x300")
  Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))

' Create container to house ALL GUI objects

vbox = Iup::Create("vbox")
  Iup::SetAttributes(vbox, "MARGIN=10x10")

' Create server panel

topBox = Iup::Create("hbox")
  Iup::SetAttributes(topBox, "GAP=10")
  Iup::Append(vbox, topBox)
serverFrame = Iup::Create("frame")
  Iup::SetAttributes(serverFrame, "TITLE=Servers, EXPAND=YES")
  Iup::Append(topBox, serverFrame)
serverBox = Iup::Create("hbox")
  Iup::SetAttributes(serverBox, "GAP=5")
  Iup::Append(serverFrame, serverBox)
serverCombo = Iup::Create("list")
  Iup::SetAttributes(serverCombo, "DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1")
  Iup::Append(serverBox, serverCombo)
  Iup::SetCallback(serverCombo, "ACTION", ADDRESS(serverCombo_selected()))
btnFetch = Iup::Create("button")
  Iup::SetAttributes(btnFetch, "TITLE=Fetch, SIZE = 50x")
  Iup::Append(serverBox, btnFetch)
  Iup::SetCallback(btnFetch, "ACTION", ADDRESS(btnFetch_clicked()))

' Create control panel

controlFrame = Iup::Create("frame")
  Iup::SetAttributes(controlFrame, "TITLE=Controls")
  Iup::Append(topBox, controlFrame)
controlBox = Iup::Create("hbox")
  Iup::SetAttributes(controlBox, "GAP=5")
  Iup::Append(controlFrame, controlBox)
btnAbout = Iup::Create("button")
  Iup::SetAttributes(btnAbout, "TITLE=About, SIZE = 50x")
  Iup::Append(controlBox, btnAbout)
  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))
btnClear = Iup::Create("button")
  Iup::SetAttributes(btnClear, "TITLE=Clear, SIZE = 50x")
  Iup::Append(controlBox, btnClear)
  Iup::SetCallback(btnClear, "ACTION", ADDRESS(btnClear_clicked()))
btnExit = Iup::Create("button")
  Iup::SetAttributes(btnExit, "TITLE=Exit, SIZE = 50x")
  Iup::Append(controlBox, btnExit)
  Iup::SetCallback(btnExit,"ACTION",ADDRESS(Win_exit()))

' Create dictionary panel

dictFrame = Iup::Create("frame")
  Iup::SetAttributes(dictFrame, "TITLE=Dictionaries")
  Iup::Append(vbox, dictFrame)
serverList = Iup::Create("list")
  Iup::SetAttributes(serverList, "EXPAND=YES, VISIBLELINES=1")
  Iup::Append(dictFrame, serverList)
  Iup::SetCallback(serverList, "ACTION", ADDRESS(serverList_selected()))

' Create text part

transFrame = IUP::Create("frame")
  Iup::SetAttributes(transFrame, "TITLE=Translation")
  Iup::Append(vbox, transFrame)
text = Iup::Create("text")
  Iup::SetAttributes(text, "MULTILINE=YES, EXPAND=YES")
  Iup::Append(transFrame, text)

' Create entry and search button

bottomBox = Iup::Create("hbox")
  Iup::SetAttributes(bottomBox, "GAP=10")
  Iup::Append(vbox, bottomBox)
label = Iup::Create("label")
  Iup::SetAttributes(label, "TITLE=\"Enter Word to Search For:\", SIZE=x12")
  Iup::Append(bottomBox, label)
entry = Iup::Create("text")
  Iup::SetAttributes(entry, "EXPAND=HORIZONTAL")
  Iup::Append(bottomBox, entry)
btnSearch = Iup::Create("button")
  Iup::SetAttributes(btnSearch,"TITLE=Search, SIZE=50x")
  Iup::Append(bottomBox, btnSearch)
  Iup::SetCallback(btnSearch, "ACTION", ADDRESS(btnSearch_clicked()))
chkAll = Iup::Create("toggle")
  Iup::SetAttributes(chkAll, "TITLE=ALL, SIZE=x12")
  Iup::Append(bottomBox, chkAll)
chkUTF = Iup::Create("toggle")
  Iup::SetAttributes(chkUTF, "TITLE=UTF-8, SIZE=x12")
  Iup::Append(bottomBox, chkUTF)

' Add the main GUI container to the Window

Iup::Append(win, vbox)

' Setup dialog defaults

Iup::Show(win)
Iup::SetFocus(btnFetch)
FOR i = 0 TO UBOUND(servers)
  Iup::SetAttribute(serverCombo, "APPENDITEM", servers[i])
NEXT
Iup::SetAttribute(serverCombo, "VALUE", "1")
Iup::Update(serverCombo)
server_selection = servers[0]

' Main processing loop

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

' Callback routines

SUB Win_exit
  Iup::ExitLoop = TRUE
END SUB

SUB btnAbout_clicked
  Iup::Message("ABOUT", about)
END SUB

SUB serverCombo_selected
  server_selection = Iup::GetListText()
END SUB

SUB serverList_selected
  whichDictionary = Iup::GetListText()
END SUB

SUB btnFetch_clicked
  LOCAL dat, total, count
  ON ERROR GOTO G_NetError
  OPEN server_selection & ":2628" FOR SOCKET AS #1
  PRINT#1,"SHOW DB\n"
  LINE INPUT#1, dat
  LINE INPUT#1, dat
  count = 0
  WHILE LEFT(dat, 1) <> "."
    LINE INPUT#1, dat
    IF LEFT(dat, 1) <> "." THEN total[count] = TRIM(dat)
    count+=1
  WEND
  PRINT#1,"QUIT\n"
  CLOSE(#1)
  FOR cnt = 0 TO count - 2
    Iup::SetAttribute(serverList, "APPENDITEM", total[cnt])
  NEXT
  Iup::SetAttribute(serverList, "VALUE", "1")
  Iup::Update(serverCombo)
  whichDictionary = total[0]
  EXIT SUB

  G_NetError:
  PRINT "Server ",server_selection," not available. (",ERROR,")\n"
END SUB

SUB btnClear_clicked
  Iup::ClearList(serverList)
  Iup::SetAttribute(text, "VALUE", "")
  Iup::SetAttribute(entry, "VALUE", "")
END SUB

SUB btnSearch_clicked
  LOCAL dict, dat, total, info
  IUP::SetAttribute(text, "VALUE","Fetching....")
  ON ERROR GOTO L_NetError
  dict = LEFT(whichDictionary, INSTR(whichDictionary, " "))
  OPEN server_selection & ":2628" FOR SOCKET AS 1
  IF Iup::GetAttribute(chkAll, "VALUE") THEN
    PRINT#1,"DEFINE * " & Iup::GetAttribute(entry,"VALUE") & "\n"
  ELSE
    PRINT#1,"DEFINE " & dict & " " & Iup::GetAttribute(entry,"VALUE") & "\n"
  END IF
  REPEAT
    LINE INPUT#1, dat
    IF LEFT(dat, 3) = "151" THEN
      total$ &= "------------------------------\r\n"
      total$ &= RIGHT(dat, LEN(dat) - LEN(Iup::GetAttribute(entry, "VALUE")) - LEN(dict))
      total$ &= "------------------------------\r\n"
      REPEAT
        LINE INPUT#1, info
        info = REPLACE(info, CHR(34), CHR(92) & CHR(34))
        IF LEFT(info, 1) <> "." THEN total &= TRIM(info) & "\n"
      UNTIL LEFT(info, 1) = "."
      total &= "\n"
    END IF
  UNTIL LEFT(dat, 3) = "250" OR VAL(LEFT(dat, 3)) > 499
  PRINT#1,"QUIT\n"
  CLOSE(#1)
  IF LEFT(dat, 3) = "552" THEN
    total = "No match found."
  ELSE IF LEFT(dat, 3) = "501" THEN
    total = "Select a dictionary first!"
  ELSE IF LEFT(dat, 3) = "550" THEN
    total = "Invalid database!"
  END IF
  Iup::SetAttribute(text, "VALUE", total)
EXIT SUB

L_NetError:
  dat[0] = "Could not lookup word! (" & ERROR & ")"
  Iup::SetAttribute(text, "VALUE", dat)
END SUB

Title: Re: IUP Linux and Windows
Post by: Support on December 20, 2011, 11:54:29 PM
I started working on controls that allow a variable number of child controls as arguments. Notice the difference between using Iup::Create("Hbox") and Iup::Hbox(child,child,...) in the two code blocks.  At this time I have limited the number of child controls to be passed as arguments to 16. I'm testing passing an array of control IDs as the first parameter which removes the 16 child control limit. So, if you have 16 or less child controls, pass them as arguments otherwise build an array and pass it as the first argument.

Code: [Select]
' Create control panel

controlFrame = Iup::Create("frame")
  Iup::SetAttributes(controlFrame, "TITLE=Controls")
  Iup::Append(topBox, controlFrame)
controlBox = Iup::Create("hbox")
  Iup::SetAttributes(controlBox, "GAP=5")
  Iup::Append(controlFrame, controlBox)
btnAbout = Iup::Create("button")
  Iup::SetAttributes(btnAbout, "TITLE=About, SIZE = 50x")
  Iup::Append(controlBox, btnAbout)
  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))
btnClear = Iup::Create("button")
  Iup::SetAttributes(btnClear, "TITLE=Clear, SIZE = 50x")
  Iup::Append(controlBox, btnClear)
  Iup::SetCallback(btnClear, "ACTION", ADDRESS(btnClear_clicked()))
btnExit = Iup::Create("button")
  Iup::SetAttributes(btnExit, "TITLE=Exit, SIZE = 50x")
  Iup::Append(controlBox, btnExit)
  Iup::SetCallback(btnExit,"ACTION",ADDRESS(Win_exit()))

Code: [Select]
' Create control panel

btnAbout = Iup::Create("button")
  Iup::SetAttributes(btnAbout, "TITLE=About, SIZE = 50x")
  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))
btnClear = Iup::Create("button")
  Iup::SetAttributes(btnClear, "TITLE=Clear, SIZE = 50x")
  Iup::SetCallback(btnClear, "ACTION", ADDRESS(btnClear_clicked()))
btnExit = Iup::Create("button")
  Iup::SetAttributes(btnExit, "TITLE=Exit, SIZE = 50x")
  Iup::SetCallback(btnExit,"ACTION",ADDRESS(Win_exit()))
controlFrame = Iup::Create("frame")
  Iup::SetAttributes(controlFrame, "TITLE=Controls")
  Iup::Append(topBox, controlFrame)
controlBox = Iup::Hbox(btnAbout, btnClear, btnExit)
  Iup::SetAttributes(controlBox, "GAP=5")
  Iup::Append(controlFrame, controlBox)
Title: Re: IUP Linux and Windows
Post by: Support on December 22, 2011, 01:13:55 PM
BUILD 1

I was able to get a Windows version of the IUP.DLL compiled today. It only contains the core IUP library. (what's defined in iup.h) Check out the iup.bas INCLUDE module file for a list of the functions.

FYI The same ScriptBasic C interface program for IUP and dictionary example I created on Linux 64 compiled/ran untouched under Windows XP. I would say that pretty much defines what portability means.  8)

If you don't have a copy of ScriptBasic for Windows, here is the runtime for the MinGW32-TDM compiled version.  

ScriptBasic 3.0 Windows 32 bit (http://www.scriptbasic.org/download/3.0/SB30-win32bin.zip)

Note The IUP extension module in the zip is based on Armando's first pass at IUP for SB. Replace them with the download attached.
Title: Re: IUP Linux and Windows
Post by: Support on December 23, 2011, 01:26:50 PM
BUILD 2

I have added / fixed a few things so here is a new build.


Windows - Iup::Info
C:\SB3\test>sb3 iupinfo.sb
SYSTEMLANGUAGE: English (United States)
DRIVER: Win32
SYSTEM: WinXP
SYSTEMLOCALE: 1252  (ANSI - Latin I)
COMPUTERNAME: JRS-C997F91780C
USERNAME: John
MONITORSINFO: 0 0 1280 800

SCREENSIZE: 1280x766
SCREENDEPTH: 32
VIRTUALSCREEN: 0 0 1280 800
DLGFGCOLOR:   0   0   0
DLGBGCOLOR: 236 233 216
DEFAULTFONT: Tahoma,  8
DEFAULTFONTSIZE: 8
TXTFGCOLOR:   0   0   0
TXTBGCOLOR: 255 255 255
C:\SB3\test>

Linux - Iup::Info
jrs@laptop:~/sb/test$ scriba iupinfo.sb
SYSTEMLANGUAGE: en-us
DRIVER: GTK
SYSTEM: Linux
SYSTEMLOCALE: UTF-8
COMPUTERNAME: laptop
USERNAME: jrs
MONITORSINFO: 0 0 1280 800

SCREENSIZE: 1280x749
SCREENDEPTH: 24
VIRTUALSCREEN: 0 0 1280 800
DLGFGCOLOR:   0   0   0
DLGBGCOLOR: 220 218 213
DEFAULTFONT: Ubuntu 11
DEFAULTFONTSIZE: 11
TXTFGCOLOR:   0   0   0
TXTBGCOLOR: 255 255 255
jrs@laptop:~/sb/test$


Code: [Select]
IMPORT iup.bas
IUP::Open()

IUP::Info(INFO)

PRINT "SYSTEMLANGUAGE: ",INFO{"SYSTEMLANGUAGE"},"\n"
PRINT "DRIVER: ",INFO{"DRIVER"},"\n"
PRINT "SYSTEM: ",INFO{"SYSTEM"},"\n"
PRINT "SYSTEMLOCALE: ",INFO{"SYSTEMLOCALE"},"\n"
PRINT "COMPUTERNAME: ",INFO{"COMPUTERNAME"},"\n"
PRINT "USERNAME: ", INFO{"USERNAME"},"\n"
PRINT "MONITORSINFO: ",INFO{"MONITORSINFO"},"\n"
PRINT "SCREENSIZE: ",INFO{"SCREENSIZE"},"\n"
PRINT "SCREENDEPTH: ",INFO{"SCREENDEPTH"},"\n"
PRINT "VIRTUALSCREEN: ",INFO{"VIRTUALSCREEN"},"\n"
PRINT "DLGFGCOLOR: ",INFO{"DLGFGCOLOR"},"\n"
PRINT "DLGBGCOLOR: ",INFO{"DLGBGCOLOR"},"\n"
PRINT "DEFAULTFONT: ",INFO{"DEFAULTFONT"},"\n"
PRINT "DEFAULTFONTSIZE: ",INFO{"DEFAULTFONTSIZE"},"\n"
PRINT "TXTFGCOLOR: ",INFO{"TXTFGCOLOR"},"\n"
PRINT "TXTBGCOLOR: ",INFO{"TXTBGCOLOR"},"\n"
Title: Re: IUP Linux and Windows
Post by: Support on December 23, 2011, 10:11:20 PM
BUILD 3

I thought I would give some of the other IUP functions a try so I substituted the Iup::Create() calls with their control equivalent. I like the Iup::Create() method better. It allows me to use Iup::SetAttributes() to define the control properties and not force me to use specific attributes on the create. For example, Iup::Button() requires you pass the title and action class on create. Using Iup::Create("button"), I set attributes and callbacks with two functions and I'm done. Why should I be forced to set control actions if i have no plans to define a callback for it?

The other issue is passing a NULL for optional arguments. The Iup::Dialog() has and option for passing one child or a NULL. The main purpose is to return a handle for the dialog. I'm not sure why Iup::Dialog() only allows one child when Hbox & Vbox allow as many children as you wish. At this time, the control create main purpose is to return a handle. Use Iup::Append() in a loop to load up a parent with the kids.

Here is the modified dictionary program using IUP control creation functions rather that the generic Iup::Create() function. Build 3 handles the NULL issues internally.

I think the best thing to do is solve the null argument issue as it keeps cropping up as I move forward. The next update will have this resolved so the SB IUP API follows the original as best as possible. I could pass a "NULL" and convert it to a C NULL internally.


Code: [Select]
IMPORT iup.bas

servers[0]="dict.org"
servers[1]="dict1.us.dict.org"
servers[2]="all.dict.org"

about="""This is a Demo
of the IUP GUI Binding
for Scriptbasic"""

' Initialize IUP
Iup::Open()

' Create main window

win = Iup::Dialog()
  Iup::SetAttributes(win, "TITLE=Thesaurus, SIZE=500x300")
  Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))

' Create container to house ALL GUI objects

vbox = Iup::Vbox()
  Iup::SetAttributes(vbox, "MARGIN=10x10")

' Create server panel

topBox = Iup::Hbox()
  Iup::SetAttributes(topBox, "GAP=10")
  Iup::Append(vbox, topBox)
serverFrame = Iup::Frame()
  Iup::SetAttributes(serverFrame, "TITLE=Servers, EXPAND=YES")
  Iup::Append(topBox, serverFrame)
serverBox = Iup::Hbox()
  Iup::SetAttributes(serverBox, "GAP=5")
  Iup::Append(serverFrame, serverBox)
serverCombo = Iup::List("ACTION")
  Iup::SetAttributes(serverCombo, "DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1")
  Iup::Append(serverBox, serverCombo)
  Iup::SetCallback(serverCombo, "ACTION", ADDRESS(serverCombo_selected()))
btnFetch = Iup::Button("Fetch","ACTION")
  Iup::SetAttributes(btnFetch, "SIZE = 50x")
  Iup::Append(serverBox, btnFetch)
  Iup::SetCallback(btnFetch, "ACTION", ADDRESS(btnFetch_clicked()))

' Create control panel

btnAbout = Iup::Button("About","ACTION")
  Iup::SetAttributes(btnAbout, "SIZE = 50x")
  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))
btnClear = Iup::Button("Clear","ACTION")
  Iup::SetAttributes(btnClear, "SIZE = 50x")
  Iup::SetCallback(btnClear, "ACTION", ADDRESS(btnClear_clicked()))
btnExit = Iup::Button("Exit","ACTION")
  Iup::SetAttributes(btnExit, "SIZE = 50x")
  Iup::SetCallback(btnExit,"ACTION",ADDRESS(Win_exit()))
controlFrame = Iup::Frame()
  Iup::SetAttributes(controlFrame, "TITLE=Controls")
  Iup::Append(topBox, controlFrame)
controlBox = Iup::Hbox(btnAbout, btnClear, btnExit)
  Iup::SetAttributes(controlBox, "GAP=5")
  Iup::Append(controlFrame, controlBox)

' Create dictionary panel

dictFrame = Iup::Frame()
  Iup::SetAttributes(dictFrame, "TITLE=Dictionaries")
  Iup::Append(vbox, dictFrame)
serverList = Iup::List("ACTION")
  Iup::SetAttributes(serverList, "EXPAND=YES, VISIBLELINES=1")
  Iup::Append(dictFrame, serverList)
  Iup::SetCallback(serverList, "ACTION", ADDRESS(serverList_selected()))

' Create text part

transFrame = IUP::Frame()
  Iup::SetAttributes(transFrame, "TITLE=Translation")
  Iup::Append(vbox, transFrame)
text = Iup::Text("ACTION")
  Iup::SetAttributes(text, "MULTILINE=YES, EXPAND=YES")
  Iup::Append(transFrame, text)

' Create entry and search button

bottomBox = Iup::Hbox()
  Iup::SetAttributes(bottomBox, "GAP=10")
  Iup::Append(vbox, bottomBox)
label = Iup::Label("Enter Word to Search For:")
  Iup::SetAttributes(label, "SIZE=x12")
  Iup::Append(bottomBox, label)
entry = Iup::Text("ACTION")
  Iup::SetAttributes(entry, "EXPAND=HORIZONTAL")
  Iup::Append(bottomBox, entry)
btnSearch = Iup::Button("Search","ACTION")
  Iup::SetAttributes(btnSearch,"SIZE=50x")
  Iup::Append(bottomBox, btnSearch)
  Iup::SetCallback(btnSearch, "ACTION", ADDRESS(btnSearch_clicked()))
chkAll = Iup::Toggle("ALL","ACTION")
  Iup::SetAttributes(chkAll, "SIZE=x12")
  Iup::Append(bottomBox, chkAll)
chkUTF = Iup::Toggle("UTF-8","ACTION")
  Iup::SetAttributes(chkUTF, "SIZE=x12")
  Iup::Append(bottomBox, chkUTF)

' Add the main GUI container to the Window

Iup::Append(win, vbox)

' Setup dialog defaults


Iup::Show(win)
Iup::SetFocus(btnFetch)
FOR i = 0 TO UBOUND(servers)
  Iup::SetAttribute(serverCombo, "APPENDITEM", servers[i])
NEXT
Iup::SetAttribute(serverCombo, "VALUE", "1")
Iup::Update(serverCombo)
server_selection = servers[0]

' Main processing loop

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

' Callback routines

SUB Win_exit
  Iup::ExitLoop = TRUE
END SUB

SUB btnAbout_clicked
  Iup::Message("ABOUT", about)
END SUB

SUB serverCombo_selected
  server_selection = Iup::GetListText()
END SUB

SUB serverList_selected
  whichDictionary = Iup::GetListText()
END SUB

SUB btnFetch_clicked
  LOCAL dat, total, count
  ON ERROR GOTO G_NetError
  OPEN server_selection & ":2628" FOR SOCKET AS #1
  PRINT#1,"SHOW DB\n"
  LINE INPUT#1, dat
  LINE INPUT#1, dat
  count = 0
  WHILE LEFT(dat, 1) <> "."
    LINE INPUT#1, dat
    IF LEFT(dat, 1) <> "." THEN total[count] = TRIM(dat)
    count+=1
  WEND
  PRINT#1,"QUIT\n"
  CLOSE(#1)
  FOR cnt = 0 TO count - 2
    Iup::SetAttribute(serverList, "APPENDITEM", total[cnt])
  NEXT
  Iup::SetAttribute(serverList, "VALUE", "1")
  Iup::Update(serverCombo)
  whichDictionary = total[0]
  EXIT SUB

  G_NetError:
  PRINT "Server ",server_selection," not available. (",ERROR,")\n"
END SUB

SUB btnClear_clicked
  Iup::ClearList(serverList)
  Iup::SetAttribute(text, "VALUE", "")
  Iup::SetAttribute(entry, "VALUE", "")
END SUB

SUB btnSearch_clicked
  LOCAL dict, dat, total, info
  IUP::SetAttribute(text, "VALUE","Fetching....")
  ON ERROR GOTO L_NetError
  dict = LEFT(whichDictionary, INSTR(whichDictionary, " "))
  OPEN server_selection & ":2628" FOR SOCKET AS 1
  IF Iup::GetAttribute(chkAll, "VALUE") THEN
    PRINT#1,"DEFINE * " & Iup::GetAttribute(entry,"VALUE") & "\n"
  ELSE
    PRINT#1,"DEFINE " & dict & " " & Iup::GetAttribute(entry,"VALUE") & "\n"
  END IF
  REPEAT
    LINE INPUT#1, dat
    IF LEFT(dat, 3) = "151" THEN
      total$ &= "------------------------------\r\n"
      total$ &= RIGHT(dat, LEN(dat) - LEN(Iup::GetAttribute(entry, "VALUE")) - LEN(dict))
      total$ &= "------------------------------\r\n"
      REPEAT
        LINE INPUT#1, info
        info = REPLACE(info, CHR(34), CHR(92) & CHR(34))
        IF LEFT(info, 1) <> "." THEN total &= TRIM(info) & "\n"
      UNTIL LEFT(info, 1) = "."
      total &= "\n"
    END IF
  UNTIL LEFT(dat, 3) = "250" OR VAL(LEFT(dat, 3)) > 499
  PRINT#1,"QUIT\n"
  CLOSE(#1)
  IF LEFT(dat, 3) = "552" THEN
    total = "No match found."
  ELSE IF LEFT(dat, 3) = "501" THEN
    total = "Select a dictionary first!"
  ELSE IF LEFT(dat, 3) = "550" THEN
    total = "Invalid database!"
  END IF
  Iup::SetAttribute(text, "VALUE", total)
EXIT SUB

L_NetError:
  dat[0] = "Could not lookup word! (" & ERROR & ")"
  Iup::SetAttribute(text, "VALUE", dat)
END SUB

Title: Re: IUP Linux and Windows
Post by: Support on December 23, 2011, 11:31:55 PM
I solved my NULL problem. The SB macro for argument processing allows optional parameters if you enclose them with [] brackets. As luck would have it, a NULL argument is passed to the IupButton() as required.

Ihandle* IupButton(const char *title, const char *action);

Quote
title: Text to be shown to the user. It can be NULL. It will set the TITLE attribute.
action: Name of the action generated when the button is selected. It can be NULL.

Code: [Select]
besFUNCTION(PuiButton)
  Ihandle *ih;
  const char *title, *action;

  besARGUMENTS("[z][z]")
    &title, &action
  besARGEND

  ih = IupButton(title, action);
  besRETURN_POINTER(ih);
besEND

I can now pass what I want as the API intended.

btnAbout = Iup::Button()
  Iup::SetAttributes(btnAbout, "TITLE=About, SIZE = 50x")
  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))

btnAbout = Iup::Button("About")
  Iup::SetAttributes(btnAbout, "SIZE = 50x")
  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))

btnAbout = Iup::Button("About","ACTION")
  Iup::SetAttributes(btnAbout, "SIZE = 50x")
  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))

This worked.

btnAbout = Iup::Button("","ACTION")
  Iup::SetAttributes(btnAbout, "TITLE=About, SIZE = 50x")
  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))

This didn't.  :(

btnAbout = Iup::Button(,"ACTION")
  Iup::SetAttributes(btnAbout, "TITLE=About, SIZE = 50x")
  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))

By enabling the optional argument feature in the SB API, it seems to produce the desired results. I thought at first that I needed to pass a NULL from the SB script but I can't find a good reason to at this point. In the above example, who is going to set the second action argument without setting the title as well?  Skipping optional arguments with a NULL placeholder doesn't seem to be what the author intended. IMHO
Title: Re: IUP Linux and Windows
Post by: Support on December 25, 2011, 12:47:00 AM
I think I solved the optional parameters and NULL passing issues I was having. Global attribute functions were the only offender for the most part with needing to pass a NULL for a control handle to make the function use a global attribute. I created a new set of global attribute functions and handled the NULL handle pointer internally.



I rewrote the dictionary program to show optional arguments, embedding IUP functions within themselves and multiple children with Vbox & Hbox.

Code: [Select]
IMPORT iup.bas

servers[0]="dict.org"
servers[1]="dict1.us.dict.org"
servers[2]="all.dict.org"

about="""This is a Demo
of the IUP GUI Binding
for Scriptbasic"""

' Initialize IUP
Iup::Open()

' Create main window

win = Iup::SetAttributes(Iup::Dialog(), "TITLE=Thesaurus, SIZE=500x300")
  Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))

' Create server panel

serverCombo = Iup::SetAttributes(Iup::List(), "DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1")
  Iup::SetCallback(serverCombo, "ACTION", ADDRESS(serverCombo_selected()))
btnFetch = Iup::SetAttributes(Iup::Button(), "TITLE=Fetch, SIZE=50x")
  Iup::SetCallback(btnFetch, "ACTION", ADDRESS(btnFetch_clicked()))
serverFrame = Iup::SetAttributes(Iup::Frame(), "TITLE=Servers, EXPAND=YES")
serverBox = Iup::SetAttributes(Iup::Hbox(serverCombo, btnFetch), "GAP=5")
  Iup::Append(serverFrame, serverBox)
topBox = Iup::SetAttributes(Iup::Hbox(serverFrame), "GAP=10")

' Create control panel

btnAbout = Iup::SetAttributes(Iup::Button(), "TITLE=About, SIZE=50x")
  Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))
btnClear = Iup::SetAttributes(Iup::Button(), "TITLE=Clear, SIZE=50x")
  Iup::SetCallback(btnClear, "ACTION", ADDRESS(btnClear_clicked()))
btnExit = Iup::SetAttributes(Iup::Button(), "TITLE=Exit, SIZE=50x")
  Iup::SetCallback(btnExit,"ACTION",ADDRESS(Win_exit()))
controlFrame = Iup::SetAttributes(Iup::Frame(), "TITLE=Controls")
  Iup::Append(topBox, controlFrame)
controlBox = Iup::SetAttributes(Iup::Hbox(btnAbout, btnClear, btnExit), "GAP=5")
  Iup::Append(controlFrame, controlBox)

' Create dictionary panel

dictFrame = Iup::SetAttributes(Iup::Frame(), "TITLE=Dictionaries")
serverList = Iup::SetAttributes(Iup::List(), "EXPAND=YES, VISIBLELINES=1")
  Iup::Append(dictFrame, serverList)
  Iup::SetCallback(serverList, "ACTION", ADDRESS(serverList_selected()))

' Create text part

transFrame = Iup::SetAttributes(IUP::Frame(), "TITLE=Translation")
text =   Iup::SetAttributes(Iup::Text(), "MULTILINE=YES, EXPAND=YES")
  Iup::Append(transFrame, text)

' Create entry and search button

label = Iup::SetAttributes(Iup::Label("Enter Word to Search For:"), "SIZE=x12")
entry = Iup::SetAttributes(Iup::Text(), "EXPAND=HORIZONTAL")
btnSearch = Iup::SetAttributes(Iup::Button(),"TITLE=Search, SIZE=50x")
  Iup::SetCallback(btnSearch, "ACTION", ADDRESS(btnSearch_clicked()))
chkAll = Iup::SetAttributes(Iup::Toggle(), "TITLE=ALL, SIZE=x12")
chkUTF = Iup::SetAttributes(Iup::Toggle(), "TITLE=UTF-8, SIZE=x12")
bottomBox = Iup::SetAttributes(Iup::Hbox(label, entry, btnSearch, chkAll, chkUTF), "GAP=10")

' Create container to house ALL GUI objects and add it to the main dialog
vbox = Iup::SetAttributes(Iup::Vbox(topBox, dictFrame, transFrame, bottomBox), "MARGIN=10x10")
Iup::Append(win, vbox)

' Setup dialog defaults

Iup::Show(win)
Iup::SetFocus(btnFetch)
FOR i = 0 TO UBOUND(servers)
  Iup::SetAttribute(serverCombo, "APPENDITEM", servers[i])
NEXT
Iup::SetAttribute(serverCombo, "VALUE", "1")
Iup::Update(serverCombo)
server_selection = servers[0]

' Main processing loop

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

' Callback routines

SUB Win_exit
  Iup::ExitLoop = TRUE
END SUB

SUB btnAbout_clicked
  Iup::Message("ABOUT", about)
END SUB

SUB serverCombo_selected
  server_selection = Iup::GetListText()
END SUB

SUB serverList_selected
  whichDictionary = Iup::GetListText()
END SUB

SUB btnFetch_clicked
  LOCAL dat, total, count
  ON ERROR GOTO G_NetError
  OPEN server_selection & ":2628" FOR SOCKET AS #1
  PRINT#1,"SHOW DB\n"
  LINE INPUT#1, dat
  LINE INPUT#1, dat
  count = 0
  WHILE LEFT(dat, 1) <> "."
    LINE INPUT#1, dat
    IF LEFT(dat, 1) <> "." THEN total[count] = TRIM(dat)
    count+=1
  WEND
  PRINT#1,"QUIT\n"
  CLOSE(#1)
  FOR cnt = 0 TO count - 2
    Iup::SetAttribute(serverList, "APPENDITEM", total[cnt])
  NEXT
  Iup::SetAttribute(serverList, "VALUE", "1")
  Iup::Update(serverCombo)
  whichDictionary = total[0]
  EXIT SUB

  G_NetError:
  PRINT "Server ",server_selection," not available. (",ERROR,")\n"
END SUB

SUB btnClear_clicked
  Iup::ClearList(serverList)
  Iup::SetAttribute(text, "VALUE", "")
  Iup::SetAttribute(entry, "VALUE", "")
END SUB

SUB btnSearch_clicked
  LOCAL dict, dat, total, info
  IUP::SetAttribute(text, "VALUE","Fetching....")
  ON ERROR GOTO L_NetError
  dict = LEFT(whichDictionary, INSTR(whichDictionary, " "))
  OPEN server_selection & ":2628" FOR SOCKET AS 1
  IF Iup::GetAttribute(chkAll, "VALUE") THEN
    PRINT#1,"DEFINE * " & Iup::GetAttribute(entry,"VALUE") & "\n"
  ELSE
    PRINT#1,"DEFINE " & dict & " " & Iup::GetAttribute(entry,"VALUE") & "\n"
  END IF
  REPEAT
    LINE INPUT#1, dat
    IF LEFT(dat, 3) = "151" THEN
      total$ &= "------------------------------\r\n"
      total$ &= RIGHT(dat, LEN(dat) - LEN(Iup::GetAttribute(entry, "VALUE")) - LEN(dict))
      total$ &= "------------------------------\r\n"
      REPEAT
        LINE INPUT#1, info
        info = REPLACE(info, CHR(34), CHR(92) & CHR(34))
        IF LEFT(info, 1) <> "." THEN total &= TRIM(info) & "\n"
      UNTIL LEFT(info, 1) = "."
      total &= "\n"
    END IF
  UNTIL LEFT(dat, 3) = "250" OR VAL(LEFT(dat, 3)) > 499
  PRINT#1,"QUIT\n"
  CLOSE(#1)
  IF LEFT(dat, 3) = "552" THEN
    total = "No match found."
  ELSE IF LEFT(dat, 3) = "501" THEN
    total = "Select a dictionary first!"
  ELSE IF LEFT(dat, 3) = "550" THEN
    total = "Invalid database!"
  END IF
  Iup::SetAttribute(text, "VALUE", total)
EXIT SUB

L_NetError:
  dat[0] = "Could not lookup word! (" & ERROR & ")"
  Iup::SetAttribute(text, "VALUE", dat)
END SUB

I'll upload a new set of files tomorrow.

Title: Re: IUP Linux and Windows
Post by: Support on December 25, 2011, 10:58:47 AM
BUILD 4

I have attached the latest IUP bindings for ScriptBasic Windows 32 and Linux 64. I feel that this version of the library is usable to start creating applications.

Your feedback is appreciated!
Title: Re: IUP Linux and Windows - Build 5
Post by: Support 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


Title: Re: IUP Linux and Windows
Post by: Support 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.

(http://files.allbasic.info/ScriptBasic/flat_s1.png)

(http://files.allbasic.info/ScriptBasic/flat_s2.png)


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
Title: Re: IUP Linux and Windows
Post by: Support 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$

Title: Re: IUP Linux and Windows - Build 6
Post by: Support 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
Title: Re: IUP Linux and Windows
Post by: Support 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)

Title: Re: IUP Linux and Windows
Post by: Support 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
Title: Re: IUP Linux and Windows
Post by: Support 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 (http://www.tecgraf.puc-rio.br/iup/examples/C/alarm.c)


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

(http://files.allbasic.info/ScriptBasic/IUP/alarm_1.png)

(http://files.allbasic.info/ScriptBasic/IUP/alarm_2.png)

(http://files.allbasic.info/ScriptBasic/IUP/alarm_3.png)

(http://files.allbasic.info/ScriptBasic/IUP/alarm_4.png)
Title: IUP Linux and Windows - Build 7
Post by: Support on January 04, 2012, 05:15:33 PM
BUILD 7



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.
Title: Re: IUP Linux and Windows
Post by: Support on January 06, 2012, 10:41:46 PM
Here is the button.c example converted to ScriptBasic.

C Version (http://www.tecgraf.puc-rio.br/iup/examples/C/button.c)

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

(http://files.allbasic.info/ScriptBasic/IUP/Button.png)
Title: Re: IUP Linux and Windows
Post by: Support on January 07, 2012, 01:27:45 PM
Here is the filedlg.c example in ScriptBasic.

C Version (http://www.tecgraf.puc-rio.br/iup/examples/C/filedlg.c)

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

Title: Re: IUP Linux and Windows
Post by: Support on January 07, 2012, 04:35:10 PM
Icon, menu and a cursor change to show with this dialog1.c example.

C Version (http://www.tecgraf.puc-rio.br/iup/examples/C/dialog1.c)

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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,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

(http://files.allbasic.info/ScriptBasic/IUP/dialog1.png)
Title: IUP Linux and Windows - Build 8
Post by: Support 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)

(http://files.allbasic.info/ScriptBasic/IUP/button_win.png)

(http://files.allbasic.info/ScriptBasic/IUP/filedlg_win.png)

(http://files.allbasic.info/ScriptBasic/IUP/dialog1_win.png)
Title: IUP Linux and Windows - Build 9
Post by: Support 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!


Title: Re: IUP Linux and Windows
Post by: Support 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 (http://www.tecgraf.puc-rio.br/iup/examples/C/submenu.c)

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
Title: Re: IUP Linux and Windows
Post by: Support on January 10, 2012, 08:56:29 AM
Thanks Ron for giving SB/IUP a try. I don't have the 'DOS' box/console issue with Linux if I insert the #! /usr/bin/scriba as the first line of the script or compile the application to C. The CIO Windows extension module has a Detach() (http://www.scriptbasic.org/docs/cio/mod_cio_6.html) function to kill the DOS box and run your application as a GUI program. I'm looking at adding a new command line switch for scriba to disable the console on startup.

Thanks for the menu screen shots! I'm trying to convert the C examples on the IUP site to help get folks going with IUP.

Are you running Windows 2000? If your running XP or greater, you should be seeing the current themed windows and controls with the IUP interface.

Title: Re: IUP Linux and Windows
Post by: Support on January 10, 2012, 12:58:16 PM
Quote
-If you can't get the dos window to close maybe you can get it to minimize as a work around?

You may be able to get rid of the console window start/close flash (using CIO::Detach) by setting the application to start minimized. (shortcut properties)

Update

The minimize trick solves the console flash issue but I was unable to get IUP to force the window to it's normal state under program control. (had to click on it in the taskbar)
Title: Re: IUP Linux and Windows
Post by: Support on January 10, 2012, 04:18:54 PM
I'm working on creating a scribaw for Windows that doesn't create a console window.

I'll post it to the downloads section when it's done.

Title: Re: IUP Linux and Windows
Post by: Support on January 13, 2012, 07:52:59 PM
Here is the IUP sample.c converted to ScriptBasic.

C Version (http://www.tecgraf.puc-rio.br/iup/examples/C/sample.c)

Code: [Select]
' IUP sample.sb

IMPORT iup.bas

GLOBAL CONST IUP_CENTER = 0xFFFF
GLOBAL CONST IUP_TITLE = "TITLE"
GLOBAL CONST IUP_VALUE = "VALUE"
GLOBAL CONST IUP_SIZE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,2,2,2,2
,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
"""

SUB init_dialog

  img = Iup::Image(32,32, Iup::CreateImg(img_bits1))
  Iup::SetHandle ("img1", img)
  Iup::SetAttribute (img, "0", "0 0 0")
  Iup::SetAttribute (img, "1", "BGCOLOR")
  Iup::SetAttribute (img, "2", "255 0 0")

  img = Iup::Image(32,32, Iup::CreateImg(img_bits2))
  Iup::SetHandle ("img2", img)
  Iup::SetAttribute (img, "0", "0 0 0")
  Iup::SetAttribute (img, "1", "0 255 0")
  Iup::SetAttribute (img, "2", "BGCOLOR")
  Iup::SetAttribute (img, "3", "255 0 0")

  mnu = Iup::Menu( _
  Iup::Submenu("IupSubmenu 1",Iup::Menu( _
      Iup::SetAttributes(Iup::Item("IupItem 1 Checked"), "VALUE=ON"), _
      Iup::Separator(), _
      Iup::SetAttributes(Iup::Item("IupItem 2 Disabled"), "ACTIVE=NO"))), _
    Iup::Item("IupItem 3"), _
    Iup::Item("IupItem 4"))
  Iup::SetHandle("mnu",mnu)

  _frm_1 = Iup::Frame( _
    Iup::Vbox( _
      Iup::Button("Button Text"), _
      Iup::SetAttributes(Iup::Button(), "IMAGE=img1"), _
      Iup::SetAttributes(Iup::Button(), "IMAGE=img1,IMPRESS=img2")))
  Iup::SetAttribute(_frm_1,IUP_TITLE,"IupButton")

  _frm_2 = Iup::Frame( _
    Iup::Vbox( _
      Iup::Label("Label Text"), _
      Iup::SetAttributes(Iup::Label(""), "SEPARATOR=HORIZONTAL"), _
      Iup::SetAttributes(Iup::Label(""), "IMAGE=img1")))
  Iup::SetAttribute(_frm_2,IUP_TITLE,"IupLabel")

  _frm_3 = Iup::Frame( _
    Iup::Vbox( _
      Iup::SetAttributes(Iup::Toggle("Toggle Text"), "VALUE=ON"), _
      Iup::SetAttributes(Iup::Toggle(""), "IMAGE=img1,IMPRESS=img2"), _
      Iup::SetAttributes(Iup::Frame(Iup::Radio(Iup::Vbox( _
        Iup::Toggle("Toggle Text"), _
        Iup::Toggle("Toggle Text")))), "TITLE=IupRadio")))
  Iup::SetAttribute(_frm_3,IUP_TITLE,"IupToggle")

  _text_1 = Iup::Text()
  Iup::SetAttribute(_text_1,IUP_VALUE,"IupText Text")
  Iup::SetAttribute(_text_1,IUP_SIZE,"80x")

  _ml_1 = Iup::MultiLine()
  Iup::SetAttribute(_ml_1,IUP_VALUE,"IupMultiline Text\nSecond Line\nThird Line")
  Iup::SetAttribute(_ml_1,IUP_EXPAND,"YES")
  Iup::SetAttribute(_ml_1,IUP_SIZE,"80x60")

  _frm_4 = Iup::Frame(Iup::Vbox( _
    _text_1, _
    _ml_1))
  Iup::SetAttribute(_frm_4,IUP_TITLE,"IupText/IupMultiline")

  _list_1 = Iup::List()
  Iup::SetAttribute(_list_1,IUP_EXPAND,"YES")
  Iup::SetAttribute(_list_1,IUP_VALUE,"1")
  Iup::SetAttribute(_list_1,"1","Item 1 Text")
  Iup::SetAttribute(_list_1,"2","Item 2 Text")
  Iup::SetAttribute(_list_1,"3","Item 3 Text")

  _list_2 = Iup::List()
  Iup::SetAttribute(_list_2,IUP_DROPDOWN,"YES")
  Iup::SetAttribute(_list_2,IUP_EXPAND,"YES")
  Iup::SetAttribute(_list_2,IUP_VALUE,"2")
  Iup::SetAttribute(_list_2,"1","Item 1 Text")
  Iup::SetAttribute(_list_2,"2","Item 2 Text")
  Iup::SetAttribute(_list_2,"3","Item 3 Text")

  _list_3 = Iup::List()
  Iup::SetAttribute(_list_3,"EDITBOX","YES")
  Iup::SetAttribute(_list_3,IUP_EXPAND,"YES")
  Iup::SetAttribute(_list_3,IUP_VALUE,"3")
  Iup::SetAttribute(_list_3,"1","Item 1 Text")
  Iup::SetAttribute(_list_3,"2","Item 2 Text")
  Iup::SetAttribute(_list_3,"3","Item 3 Text")

  _frm_5 =  Iup::Frame(Iup::Vbox( _
      _list_1, _
      _list_2, _
      _list_3))
  Iup::SetAttribute(_frm_5,IUP_TITLE,"IupList")

  _hbox_1 = Iup::Hbox( _
    _frm_1, _
    _frm_2, _
    _frm_3, _
    _frm_4, _
    _frm_5)

  _cnv_1 = Iup::Canvas()
  Iup::SetAttribute(_cnv_1,IUP_POSX,"0.0")
  Iup::SetAttribute(_cnv_1,IUP_POSY,"0.0")
  Iup::SetAttribute(_cnv_1,IUP_BGCOLOR,"128 255 0")

  _vbox_1 = Iup::Vbox( _
    _hbox_1, _
    _cnv_1)
  Iup::SetAttribute(_vbox_1,IUP_MARGIN,"5x5")
  Iup::SetAttribute(_vbox_1,IUP_ALIGNMENT,"ARIGHT")
  Iup::SetAttribute(_vbox_1,IUP_GAP,"5")

  dlg = Iup::Dialog(_vbox_1)
  Iup::SetHandle("dlg",dlg)
  Iup::SetAttribute(dlg,IUP_MENU,"mnu")
  Iup::SetAttribute(dlg,IUP_TITLE,"IupDialog Title")

END SUB

' MAIN

  Iup::Open()
  init_dialog()
  Iup::Show(Iup::GetHandle("dlg"))
  Iup::MainLoop()
  Iup::Close()
 
  END
Title: Re: IUP Linux and Windows
Post by: Support on January 14, 2012, 02:17:50 PM
Here is the tabs.c IUP C example converted to ScriptBasic. I think Gtk (Linux) does a better job of vertical tabs.

C Version (http://www.tecgraf.puc-rio.br/iup/examples/C/tabs.c)

Code: [Select]
' Iup::Tabs: Example in ScriptBasic
' Creates a Iup::Tabs control.

IMPORT iup.bas

GLOBAL CONST IUP_CENTER = 0xFFFF

Iup::Open()

vbox1 = Iup::Vbox(Iup::Label("Inside Tab A"), Iup::Button("Button A", ""))
vbox2 = Iup::Vbox(Iup::Label("Inside Tab B"), Iup::Button("Button B", ""))

Iup::SetAttribute(vbox1, "TABTITLE", "Tab A")
Iup::SetAttribute(vbox2, "TABTITLE", "Tab B")

tabs1 = Iup::Tabs(vbox1, vbox2)

vbox1 = Iup::Vbox(Iup::Label("Inside Tab C"), Iup::Button("Button C", ""))
vbox2 = Iup::Vbox(Iup::Label("Inside Tab D"), Iup::Button("Button D", ""))

Iup::SetAttribute(vbox1, "TABTITLE", "Tab C")
Iup::SetAttribute(vbox2, "TABTITLE", "Tab D")

tabs2 = Iup::Tabs(vbox1, vbox2)
Iup::SetAttribute(tabs2, "TABTYPE", "LEFT")

box = Iup::Hbox(tabs1, tabs2)
Iup::SetAttribute(box, "MARGIN", "10x10")
Iup::SetAttribute(box, "GAP", "10")

dlg = Iup::Dialog(box)
Iup::SetAttribute(dlg, "TITLE", "IupTabs")
Iup::SetAttribute(dlg, "SIZE", "200x80")

Iup::ShowXY (dlg, IUP_CENTER, IUP_CENTER)
Iup::MainLoop ()
Iup::Close ()

END

(http://files.allbasic.info/ScriptBasic/IUP/IupTabs_Linux.png)

(http://files.allbasic.info/ScriptBasic/IUP/IupTabs_WiinXP.png)
Title: Re: IUP Linux and Windows
Post by: Support on January 17, 2012, 03:18:07 PM
I have been working on adding the additional controls and the CD (canvas draw library (http://www.tecgraf.puc-rio.br/cd/)) to the ScriptBasic IUP binding. This should add some interesting features to the SciptBasic language offering.

(http://files.allbasic.info/ScriptBasic/IUP/ColorDlg.png)

(http://files.allbasic.info/ScriptBasic/IUP/IupFontDlg.png)


Dials

(http://files.allbasic.info/ScriptBasic/IUP/dialcir.png)

(http://files.allbasic.info/ScriptBasic/IUP/dialhorz.png)

(http://files.allbasic.info/ScriptBasic/IUP/dialvert.png)
Title: Re: IUP Linux and Windows
Post by: Support on January 17, 2012, 05:43:30 PM
Here is the matrix.c example converted to ScriptBasic.

C Version (http://www.tecgraf.puc-rio.br/iup/examples/C/matrix.c)

Code: [Select]
IMPORT iup.bas

GLOBAL CONST IUP_CENTER = 0xFFFF

FUNCTION create_mat
  mat = Iup::Matrix()
 
  Iup::SetAttribute(mat,"NUMCOL","20")
  Iup::SetAttribute(mat,"NUMLIN","30")
 
  Iup::SetAttribute(mat,"NUMCOL_VISIBLE","2")
  Iup::SetAttribute(mat,"NUMLIN_VISIBLE","3")
 
  Iup::SetAttribute(mat,"0:0","Inflation")
  Iup::SetAttribute(mat,"1:0","Medicine")
  Iup::SetAttribute(mat,"2:0","Food")
  Iup::SetAttribute(mat,"3:0","Energy")
  Iup::SetAttribute(mat,"0:1","January 2000")
  Iup::SetAttribute(mat,"0:2","February 2000")
  Iup::SetAttribute(mat,"1:1","5.6")
  Iup::SetAttribute(mat,"2:1","2.2")
  Iup::SetAttribute(mat,"3:1","7.2")
  Iup::SetAttribute(mat,"1:2","4.5")
  Iup::SetAttribute(mat,"2:2","8.1")
  Iup::SetAttribute(mat,"3:2","3.4")
  Iup::SetAttribute(mat,"RESIZEMATRIX","YES")
  Iup::SetAttribute(mat,"MARKMODE","LINCOL")
  Iup::SetAttribute(mat,"MULTIPLE","YES")
  Iup::SetAttribute(mat,"AREA","NOT_CONTINUOUS")

  create_mat = mat
END FUNCTION


' Main program

  Iup::Open()       
  Iup::ControlsOpen()

  dlg = Iup::Dialog(create_mat())
  Iup::SetAttribute(dlg, "TITLE", "IupMatrix")
  Iup::ShowXY(dlg,IUP_CENTER,IUP_CENTER)
  Iup::MainLoop ()
  Iup::Close () 
END

(http://files.allbasic.info/ScriptBasic/IUP/IupMatrix.png)
Title: IUP Linux and Windows - Build 10
Post by: Support on January 18, 2012, 07:43:49 PM
BUILD 10

This release includes the additional IUP controls, cd (canvas draw) with OpenGL support. I will be exposing the cd functions in the next release under its own module cd:: in the iup.bas import file.

Quote
CD is a platform-independent graphics library. Its drivers are implemented in several platforms, some use portable code, others use native graphics libraries, such as Microsoft Windows (GDI and GDI+) and X-Windows (XLIB).

The library contains functions to support both vector and image applications, and the visualization surface can be either a canvas or a more abstract surface, such as Clipboard, Metafile, PS, and so on.

Furthermore, the list of parameters of the CD primitive functions contains only the geometrical descriptions of the objects (line, circle, text, etc.). Where these objects should appear and what is the their color, thickness, etc. are defined as current state variables stored in the visualization surfaces. That is, the library is visualization-surface oriented, meaning that all attributes are stored in each visualization surface.

 I setup a Ubuntu 11.10 32 bit instance on Amazon and compiled a SB IUP extension module for 32 bit Linux. I haven't tested it yet but it compiled fine. I have to setup a vnc remote desktop with my EC2 instance and haven't had time to do that yet. If someone running a 32 version of Ubuntu can give this a quick try, it would be appreciated. If you need a 32 bit Linux runtime version of ScriptBasic, you can get it HERE (http://www.scriptbasic.org/forum/index.php/topic,217.msg619.html#msg619).

You may have noticed there is no Windows version of Build 10. I have to rebuild my Windows IUP setup and with the little interest on that platform, Windows can wait until I get around to it. There are so many versions of Basic for Windows, it's hard for me to justify investing much time to that platform.
Title: Re: IUP Linux and Windows
Post by: Support on January 19, 2012, 11:08:53 AM
It may seem slow going with getting the ScriptBasic IUP binding done but I'm taking my time to make sure the interface remains a natural extension to the language keeping it's typeless high level functionality intact. The cd graphics side of this is going to be a lot of fun based on what I have read so far in the IUP CD documentation. The IM (Image Representation, Storage, Capture and Processing) part of the IUP binding is the last installment to complete.

I hope the OS X native driver is released soon. Gtk on the Mac is a temporary solution IMO.

 
Title: Re: IUP Linux and Windows
Post by: Support on January 26, 2012, 10:19:38 PM
ScriptBasic does graphics! Here is a quick test of the CD (Canvas Draw) API in action.

Code: [Select]
IMPORT iup.bas

Iup::Open()

ican = Iup::Canvas()
Iup::SetAttribute(ican, "RASTERSIZE", "800x600")
Iup::SetAttribute(ican, "BORDER", "NO")

dlg = Iup::Dialog(Iup::Vbox(ican))
Iup::SetAttribute(dlg, "TITLE", "Mandelbrot Set")

Iup::Map(dlg)

ccan = CD::CreateCanvas(CD::ContextIup(), ican)

Iup::Show(dlg)

przelx = 3 / 800
przely = 2 / 600

FOR x = 1 TO 800
  FOR y = 1 TO 600
    a = 0
    b = 0
    c = 0
    x2 = (przelx * x) - 2
    y2 = (przely * y) - 1
    petla:
    a2 = a * a - b * b
    b2 = 2 * a * b
    a = a2 + x2
    b = b2 + y2
    z = a * a + b * b
    IF z < 4 AND c < 255 THEN
      c = c + 1
      GOTO petla
    END IF
    IF c = 255 THEN
      pixclr = CD::EncodeColor(0, 0, 0)
    ELSE
      g = 255 - c
      pixclr = CD::EncodeColor(g, g, g)
      ' Color version
      ' pixclr = (g+64) * g * (g+16)
    END IF
    CD::CanvasPixel(ccan, x, y, pixclr)
  NEXT y
NEXT x

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

Title: Re: IUP Linux and Windows
Post by: Support on January 27, 2012, 10:45:57 AM
I hope to get BUILD 11 out this weekend for Linux (32/64) and Windows 32.

You could create a VirtualBox on your Windows PC and run Ubuntu 32 in it for testing and experimentation. Ubuntu has a dual boot option that uses a portion of your NTFS Windows file system so you don't need to partition your disk. If your PC is new enough and can boot off a USB drive, that is another great way to run Linux as a secondary OS.

Title: Re: IUP Linux and Windows
Post by: Support on January 29, 2012, 09:07:13 AM
The graphics will be available in build 11. The build 10 release just enabled additional controls. (matrix, dial, color select, ...)

It won't be long. The CD API is pretty extensive and wrapping / testing it takes time.

To find out what IUP functions are enabled in the SB IUP extension module, look at the iup.bas include file.

I hope to get a SB version of the IUP docs on the SB wiki when I finish the interface code.
Title: Re: IUP Linux and Windows
Post by: Support on February 21, 2012, 07:50:38 AM
Sorry Ron for the delay with BUILD 11. No snags with IUP/CD, only with real life commitments.

I will try to have something up this week.

Title: Re: IUP Linux and Windows
Post by: Support on October 18, 2012, 06:47:14 PM
I now have Windows 7 64 bit installed and will be picking back up with the IUP project on both Windows and Linux platforms in 64 bit only.

Stay Tuned!
Title: Re: IUP Linux and Windows
Post by: Kirkkaf on November 22, 2012, 08:35:21 AM
I am happy to see ScriptBasic supports Canvas Draw.

Kirk
Title: Re: IUP Linux and Windows
Post by: Support on November 22, 2012, 10:13:36 AM
I have very little of the IUP CD API wrapped at the moment for the SB extension module. The CD (Canvas Draw) API is HUGE and is going to take some time to add it's features to the SB IUP extension module. I need to finish the core IUP callback interface first.

Title: Re: IUP Linux and Windows
Post by: Kirkkaf on November 22, 2012, 10:24:07 AM
I am looking for a GUI with graphical functionality for a project I have been planning, so I will keep a look out on this thread. 
Title: Re: IUP Linux and Windows
Post by: Support on November 22, 2012, 11:44:02 AM
If you have a C background, I would be happy to turn over the CD part of the extension module for you to wrap. I have a lot going with little help from the community.
Title: Re: IUP Linux and Windows
Post by: Kirkkaf on November 23, 2012, 04:33:04 AM
Unfortunately my C skills are lacking, my background is from Python, so I may not be of any use for the time being.
Title: Re: IUP Linux and Windows
Post by: Support on November 23, 2012, 04:52:57 AM
You should feel right at home as AIR (Armando - SB guru dev) is a Python fan as well.