Author Topic: bc9 / IUP  (Read 6669 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
bc9 / IUP
« on: January 09, 2013, 09:47:54 PM »
Here is James C. Fuller's bc9 (BCX fork) and the IUP Hello World. The goal with this thread is to mirror the effort that was done for BaCon under Linux with bc9 under Window and Linux.

Windows XP



Code: [Select]
#include <iup.h>

IupOpen(NULL,NULL)
IupShow(IupDialog(IupLabel("Hello World!")))
IupMainLoop()
IupClose()

C:\bc9>bc9 iup_hello.bas
BCX-32: BASIC to C/C++ Translator by Kevin Diggins (c) 1999-2012
BCX-32 Version 9.0.0.7 (2012/03/23)
[Lines In: 6] [Lines Out: 179] [Statements: 5] [Time: 0.11 sec's]
BCX translated iup_hello.bas to iup_hello.C For a C Compiler

C:\bc9>gcc iup_hello.C -I\iupwin\iup\include -L\iupwin\iup -liup -o iup_hello.exe

C:\bc9>iup_hello

Linux 64 bit



E:\bc9>bc9 iup_hello.bas -nix
BCX-32: BASIC to C/C++ Translator by Kevin Diggins (c) 1999-2012
BCX-32 Version 9.0.0.7 (2012/03/23)
[Lines In: 6] [Lines Out: 102] [Statements: 5] [Time: 0.11 sec's]
BCX translated iup_hello.bas to iup_hello.C For a C Compiler

E:\bc9>

jrs@laptop:~/B4A/bc9$ gcc iup_hello.C -I/usr/include/iup -liup -o iup_hello
jrs@laptop:~/B4A/bc9$ ./iup_hello
« Last Edit: January 09, 2013, 10:12:44 PM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: bc9 / IUP
« Reply #1 on: January 10, 2013, 07:23:03 AM »
This is the iup_buttons demo for Windows and Linux using bc9.

Code: [Select]
' bc9 IUP Button Example

#include <iup.h>

DIM AS Ihandle PTR win, horzbox, btn1, btn2, btn3

SUB Btn1_clicked
  PRINT "BUTTON 1 Event"
END SUB

SUB Btn2_clicked
  PRINT "BUTTON 2 Event"
END SUB

SUB Btn3_clicked
  PRINT "BUTTON 3 Event"
END SUB

IupOpen(NULL,NULL)
win = IupCreate("dialog")
IupSetAttributes(win, E"TITLE=\qTest Dialog\q, SIZE=300x")
horzbox = IupCreate("hbox")
IupSetAttributes(horzbox, "GAP=5")
btn1 = IupCreate("button")
IupSetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")
btn2 = IupCreate("button")
IupSetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")
btn3 = IupCreate("button")
IupSetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")
IupAppend(horzbox, btn1)
IupAppend(horzbox, btn2)
IupAppend(horzbox, btn3)
IupAppend(win, horzbox)
IupSetCallback(btn1, "ACTION", (Icallback)Btn1_clicked)
IupSetCallback(btn2, "ACTION", (Icallback)Btn2_clicked)
IupSetCallback(btn3, "ACTION", (Icallback)Btn3_clicked)
IupShow(win)
IupMainLoop()
IupClose()



Note: Will try to get XP themes working with bc9. (James, any direction with this?)

E:\bc9>bc9 iup_buttons.bas
BCX-32: BASIC to C/C++ Translator by Kevin Diggins (c) 1999-2012
BCX-32 Version 9.0.0.7 (2012/03/23)
[Lines In: 41] [Lines Out: 227] [Statements: 36] [Time: 0.14 sec's]
BCX translated iup_buttons.bas to iup_buttons.C For a C Compiler

E:\bc9>gcc iup_buttons.C -IC:/iupwin/iup/include -LC:/iupwin/iup -liup -o iup_buttons.exe

E:\bc9>iup_buttons
BUTTON 1 Event
BUTTON 2 Event
BUTTON 3 Event

E:\bc9>bc9 iup_buttons.bas -nix
BCX-32: BASIC to C/C++ Translator by Kevin Diggins (c) 1999-2012
BCX-32 Version 9.0.0.7 (2012/03/23)
[Lines In: 41] [Lines Out: 150] [Statements: 36] [Time: 0.15 sec's]
BCX translated iup_buttons.bas to iup_buttons.C For a C Compiler

E:\bc9>



jrs@laptop:~/B4A/bc9$ gcc iup_buttons.C -I/usr/include/iup -liup -o iup_buttons
jrs@laptop:~/B4A/bc9$ ./iup_buttons
BUTTON 1 Event
BUTTON 2 Event
BUTTON 3 Event
jrs@laptop:~/B4A/bc9$

I updated the source with the bc9 method of embedding escape characters (\q = double quote) into a string.

IupSetAttributes(win, E"TITLE=\qTest Dialog\q, SIZE=300x")

I was able to get XP theme support working with a .manafest file. I would prefer this was included in the bc9 build.

« Last Edit: January 10, 2013, 10:21:26 AM by JRS »