IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

Code: Select all

' IDrawCanavas.bas
' see also /inc/iup_draw.bi

#include once "inc/iup_draw.bi"

sub _init_ constructor
  IupOpen(0,0)
end sub

sub _exit_ destructor
  IupClose()
end sub


' redraw canvas (create DrawCanvas on the fly)
function canvas_action_cb cdecl (self as IHandle ptr) as integer
  ' create offscreen image 
  dim as IDrawCanvas ptr dc = iupDrawCreateCanvas(self) 
  if dc then
    dim as integer w,h
    ' get current size
    iupDrawGetSize(dc,@w,@h)
    if w<1 then w=1
    if h<1 then h=1
    
    dim as single rStep = 255.0 / w
    dim as single gStep = 255.0 / h
    ' black background
    iupDrawRectangle(dc,0,0,w-1,h-1, 0,0,0, IUP_DRAW_FILL)
    
    ' red hor. lines
    for x as integer= 0 to w-1 step 8
      iupDrawLine(dc, _
                  x,0,x,h-1, _
                  x*rStep,0,0, _
                  IUP_DRAW_STROKE)
    next
    ' green ver. lines
    for y as integer= 0 to h-1 step 8
      iupDrawLine(dc, _
                  0,y,w-1,y, _
                  0,y*gStep,0, _
                  IUP_DRAW_STROKE)
    next
    ' show the offscreen image 
    iupDrawFlush(dc)
    ' free the offscreen image
    iupDrawKillCanvas(dc)
  end if  
  return IUP_DEFAULT
end function


'
' main
'
dim as IHandle ptr canvas = IupCanvas(NULL)
IupSetCallback(canvas, "ACTION",@canvas_action_cb)

dim as IHandle ptr dialog=IupDialog(canvas)
IupSetAttribute(dialog, "RASTERSIZE", "320x240")
IupSetAttribute(dialog, "TITLE", "resize me ...")

IupShow(dialog)

IupMainLoop()
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by VANYA »

Good work Joshy!
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

VANYA wrote:Good work Joshy!
Thank you ;-)
Image

Code: Select all

#include once "inc/iup_draw.bi"
#include once "inc/iupimglib.bi"

dim as ubyte img_x_bits(...) = { _
  1,2,3,3,3,3,3,3,3,2,1, _
  2,1,2,3,3,3,3,3,2,1,2, _
  3,2,1,2,3,3,3,2,1,2,3, _
  3,3,2,1,2,3,2,1,2,3,3, _
  3,3,3,2,1,2,1,2,3,3,3, _
  3,3,3,3,2,1,2,3,3,3,3, _
  3,3,3,2,1,2,1,2,3,3,3, _
  3,3,2,1,2,3,2,1,2,3,3, _
  3,2,1,2,3,3,3,2,1,2,3, _
  2,1,2,3,3,3,3,3,2,1,2, _
  1,2,3,3,3,3,3,3,3,2,1}

sub _init_ constructor
  IupOpen(0,0)
  IupImageLibOpen()
end sub

sub _exit_ destructor
  IupClose()
end sub


' redraw canvas (create DrawCanvas on the fly)
function canvas_action_cb cdecl (self as IHandle ptr) as integer
  ' create offscreen image 
  dim as IDrawCanvas ptr dc = iupDrawCreateCanvas(self) 
  if dc then
    dim as integer w,h,imgw,imgh
    ' get current size
    iupDrawGetSize(dc,@w,@h)
    if w<1 then w=1
    if h<1 then h=1
    
    dim as single rStep = 255.0 / w
    dim as single gStep = 255.0 / h
    ' black background
    iupDrawRectangle(dc,0,0,w-1,h-1, 0,0,0, IUP_DRAW_FILL)
    
    ' red hor. lines
    for x as integer= 0 to w-1 step 8
      iupDrawLine(dc, _
                  x,0,x,h-1, _
                  x*rStep,0,0, _
                  IUP_DRAW_STROKE)
    next
    ' green ver. lines
    for y as integer= 0 to h-1 step 8
      iupDrawLine(dc, _
                  0,y,w-1,y, _
                  0,y*gStep,0, _
                  IUP_DRAW_STROKE)
    next
    
    ' draw text
    for i as integer=1 to 10
      iupDrawText(dc,"Times bold 12",13,rnd*w,rnd*h,rnd*255,rnd*255,rnd*255,"TIMES_BOLD_12")
    next  

    ' draw a user defined image 
    iupDrawImage(dc,"img_x",0, w\2-6,h\2-6,@imgw,@imgh)

    ' draw a predefined IUP image 
    iupDrawImage(dc,ImgNames(IUP_TECGRAF),0, 0,0,@imgw,@imgh)

    ' show the offscreen image 
    iupDrawFlush(dc)

    ' free the offscreen image
    iupDrawKillCanvas(dc)
  end if  

  return IUP_DEFAULT
end function


'
' main
'
dim as IHandle ptr canvas = IupCanvas(NULL)
IupSetCallback(canvas, "ACTION",@canvas_action_cb)
dim as IHandle ptr img_x = IupImage ( 11, 11, @img_x_bits(0) )
IupSetHandle ( "img_x", img_x )
IupSetAttribute ( img_x, "1", "0 1 0")
IupSetAttribute ( img_x, "2", "255 0 0")
IupSetAttribute ( img_x, "3", "0 0 0")

dim as IHandle ptr dialog=IupDialog(canvas)
IupSetAttribute(dialog, "RASTERSIZE", "320x240")
IupSetAttribute(dialog, "TITLE", "resize me ...")

IupShow(dialog)

IupMainLoop()
Last edited by D.J.Peters on Oct 03, 2017 5:10, edited 1 time in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

I added a more complete demo "PPlot_demo.bas" with PDF export also.

Joshy
Image
Image
Image
Image
Image
Image
Last edited by D.J.Peters on Nov 29, 2012 10:59, edited 2 times in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

IUP with FreeBASIC gfx.

Joshy
Image

Code: Select all

' IUPfbGFX.bas

#include once "inc/iup.bi"

sub _init_ constructor
  IupOpen(0,0)
end sub

sub _exit_ destructor
  IupClose()
end sub


#define IUPRGB(r,g,b) ((cuint(b) shl 16) or (cuint(g) shl 8) or cuint(r) Or &hFF000000)
#define IUPRGBA(r,g,b,a) ((cuint(a) shl 24) or (cuint(b) shl 16) or (cuint(g) shl 8) Or cuint(r))

'
' main
'
screenres 1,1,32,,-1
dim as ubyte ptr pImg = imagecreate(100,100,0)
circle pImg,(50,50),50,IUPRGB(255,255,  0),,,,F
circle pImg,(25,30),12,IUPRGB(255,255,255),,,,F
circle pImg,(75,30),12,IUPRGB(255,255,255),,,,F
circle pImg,(25,30), 7,IUPRGB(  0,  0,  0),,,,F
circle pImg,(75,30), 7,IUPRGB(  0,  0,  0),,,,F
circle pImg,(50,50),28,IUPRGB(  0,  0,  0),1.57*2,1.57*4

' named iup image from fbgfx image
IupSetHandle ("img", IupImageRGBA( 100, 100, pImg+32 ))
' iup makes a copy so we can destroy the original buffer
imagedestroy(pImg)
' dialog with image label
IupShow(IupDialog(IupSetAttributes(IupLabel(NULL), "IMAGE=img")))

IupMainLoop()
Last edited by D.J.Peters on Oct 03, 2017 5:08, edited 1 time in total.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by VANYA »

IUP with FreeBASIC gfx.
A more complete demo with pdf export also.
good, thank you
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

simple pplot example

Joshy

Code: Select all

#ifndef IUP_DLL
#define IUP_DLL
#endif

#include once "inc/iup_pplot.bi"

sub _init_ constructor
  IupOpen(0,0)
  IupPPlotOpen()
end sub

sub _exit_ destructor
  IupClose()
end sub

'
' main
'

' plot
dim as IHandle ptr plot = IupPPlot()
IupSetAttribute(plot, "GRID", "YES")
dim as single theFac = 1.0/(100*100*100)
IupPPlotBegin(plot, 0)
for i as integer=-100 to 100 step 10
  dim as single x = i '+50
  dim as single y = theFac*i*i*i
  IupPPlotAdd(plot, x, y)
next
IupPPlotEnd(plot)


' dialog
dim as IHandle ptr dlg = IupDialog(plot)
IupSetAttributes(dlg, "RASTERSIZE=320x240" )
IupSetAttribute(dlg, "TITLE", "resize me ...")
IupShow(dlg)

IupMainLoop()
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

I got Webbrowser.bas working on linux too. :-)
It use Webkit as backend.

Joshy
Image
Last edited by D.J.Peters on Oct 03, 2017 5:07, edited 1 time in total.
Coolman
Posts: 294
Joined: Nov 05, 2010 15:09

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by Coolman »

Beau boulot. Freebasic + FB debugger + wxFBE editor + Iup or wx + Gui designer = rad, la solution gagnante pour un developpement multiplateforme windows et linux. il faudrait creer un package freebasic d'installation complet qui reunit tous ces outils. il ne resterait plus a freebasic que la generation d'exe 64 bit pour etre un environnement complet de developpement...

Goog job. Freebasic + FB debugger + wxFBE editor + Iup ou wx + Gui designer = rad. the winning solution for Windows and Linux development platform. should create a full installation package freebasic which brings together all these tools. there would not be a freebasic the generation of 64 bit exe to be a complete environment for developing ...
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

Menu with images.

Joshy
Image

Code: Select all

' SimpleMenu2.bas

#include once "inc/iup.bi"
#include once "inc/iupimglib.bi"

sub _init_ constructor
  IupOpen(0,0)
  IupImageLibOpen()
end sub

sub _exit_ destructor
  IupClose()
end sub


function mnuFileExit cdecl (ih as Ihandle ptr) as integer
  ? "mnuFileExit"
  return IUP_CLOSE
end function



dim as IHandle ptr MyMenu = _
IupMenu( _
  IupSubmenu("&File", _
             IupMenu( _
                     IupSetAttributes(IupItem(!"&New\tCtrl+N"     ,"mnuFileNew"    ),"IMAGE=IUP_FileNew"     ), _
                     IupSetAttributes(IupItem(!"&Open ...\tCtrl+O","mnuFileOpen"   ),"IMAGE=IUP_FileOpen"    ), _
                     IupSeparator(), _
                     IupSetAttributes(IupItem(!"&Save\tCtrl+S"    ,"mnuFileSave"   ),"IMAGE=IUP_FileSave"    ), _
                     IupSetAttributes(IupItem("Save &all","mnuFileSaveAll"),"IMAGE=IUP_FileSaveAll" ), _
                     IupSeparator(), _
                     IupSetAttributes(IupItem("&Close"    ,"mnuFileClose"   ),"IMAGE=IUP_FileClose"    ), _
                     IupSetAttributes(IupItem("Close a&ll","mnuFileCloseAll"),"IMAGE=IUP_FileCloseAll" ), _
                     IupSeparator(), _
                     IupSetAttributes(IupItem("E&xit"    ,"mnuFileExit"   ),"IMAGE=IUP_ActionCancel"), _
                     NULL) _ 
             ), _
    IupSubmenu("&Edit", _
             IupMenu( _
                     IupSetAttributes(IupItem(!"&Undo\tCtrl+U","mnuEditUndo"   ),"IMAGE=IUP_EditUndo"    ), _
                     IupSetAttributes(IupItem(!"&Redo\tCtrl+Z","mnuEditRedo"   ),"IMAGE=IUP_EditRedo"    ), _
                     IupSeparator(), _
                     IupSetAttributes(IupItem(!"&Cut\tCtrl+X"     ,"mnuEditCut"    ),"IMAGE=IUP_EditCut"     ), _
                     IupSeparator(), _
                     IupSetAttributes(IupItem(!"Co&py\tCtrl+C"    ,"mnuEditCopy"   ),"IMAGE=IUP_EditCopy"    ), _
                     IupSetAttributes(IupItem(!"&Paste\tCtrl+V"   ,"mnuEditPaste"  ),"IMAGE=IUP_EditPaste"   ), _
                     NULL) _ 
             ), _
  NULL)

' menu event handler
IupSetFunction("mnuFileExit"   ,@mnuFileExit)
' ...

' create a named menu handle for the dialog
IupSetHandle("MyMenu", MyMenu)

dim as IHandle ptr clientregion = IupHBox(IupSetAttributes(IupCanvas(NULL),"RASTERSIZE=640x480"),NULL)


dim as IHandle ptr dlg = IupDialog(clientregion)
IupSetAttribute(dlg, "TITLE", "MenuImages")
' add the menu to the dialog via named handle
IupSetAttribute(dlg, "MENU", "MyMenu")

IupShow(dlg)
IupMainLoop()
Last edited by D.J.Peters on Oct 03, 2017 5:08, edited 1 time in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

Workaround for the missing Toolbar

Joshy
Image

Code: Select all

' Buttonbar.bas

#include once "inc/iup.bi"
#include once "inc/iupimglib.bi"

sub _init_ constructor
  IupOpen(0,0)
  IupImageLibOpen()
end sub

sub _exit_ destructor
  IupClose()
end sub


function FileExit cdecl (ih as Ihandle ptr) as integer
  ? "FileExit"
  return IUP_CLOSE
end function

#define TOOLBUTTON(e_,i_) IupSetAttributes(IupButton(NULL,e_),"FLAT=YES,IMAGE=" & i_)
#define TOOLSEPERATOR IupSetAttributes(IupButton(NULL,NULL),"ACTIVE=NO,FLAT=YES")

dim as IHandle ptr ToolBar = IupHBox(TOOLBUTTON("toolFileExit","IUP_ActionCancel"), _
                                  TOOLSEPERATOR, _
                                  TOOLBUTTON("toolFileNew","IUP_FileNew"), _
                                  TOOLBUTTON("toolFileOpen","IUP_FileOpen"), _
                                  TOOLBUTTON("toolFileSave","IUP_FileSave"), _
                                  TOOLBUTTON("toolFileClose","IUP_FileClose"), _
                                  TOOLSEPERATOR, _
                                  TOOLBUTTON("toolEditUndo","IUP_EditUndo"), _
                                  TOOLBUTTON("toolEditRedo","IUP_EditRedo"), _
                                  TOOLSEPERATOR, _
                                  TOOLBUTTON("toolEditCut","IUP_EditCut"), _
                                  TOOLBUTTON("toolEditCopy","IUP_EditCopy"), _
                                  TOOLBUTTON("toolEditPaste","IUP_EditPaste"), _
                                  NULL)
' event handler
IupSetFunction("toolFileExit",@FileExit)
' ...

dim as IHandle ptr clientregion = IupVBox(ToolBar,IupSetAttributes(IupCanvas(NULL),"RASTERSIZE=640x480"),NULL)


dim as IHandle ptr dlg = IupDialog(clientregion)
IupSetAttribute(dlg, "TITLE", "Buttonbar")
IupShow(dlg)
IupMainLoop()
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

Hello VANYA
can you download the current fbIUPWindows.zip version and execute "buildall.bat" on your box ?
(before you extract the archive delete any old fbIUPWindows folder first)

I removed the most of the DLL's from the package and "buildalldll.bat"
only iup.dll, iupole.dll and iupweb.dll is include for the Webbrowser ActiveX control.

The pplot.bas and pplot_demo.bas use libgcc_s_dw2-1.dll (only 100KB) all other examples should run without any DLL.

Thank you

Joshy
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by VANYA »

D.J.Peters wrote:Hello VANYA
can you download the current fbIUPWindows.zip version and execute "buildall.bat" on your box ?
(before you extract the archive delete any old fbIUPWindows folder first)

I removed the most of the DLL's from the package and "buildalldll.bat"
only iup.dll, iupole.dll and iupweb.dll is include for the Webbrowser ActiveX control.

The pplot.bas and pplot_demo.bas use libgcc_s_dw2-1.dll (only 100KB) all other examples should run without any DLL.

Thank you

Joshy
I tried, everything is fine compiles and runs under Windows. Well done!

Under Linux (Ubuntu) I have some examples (matrix, dial, etc.) does not work even though all compiles without error. When working in the terminal output error:
Segmentation fault (core dumped)


------------------
(program exited with code: 139)
Press return to continue


Maybe something is not installed in the system... I don't know anything about Linux :(
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

VANYA wrote:I tried, everything is fine compiles and runs under Windows. Well done!
good to know :-)
I was talking about windows only the linux package isn't up to date now. (may be on monday)

Thank you

Joshy
Drago
Posts: 116
Joined: Aug 10, 2005 13:15

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by Drago »

Hoi Joshy,

great work... matrix is working :)

If I try buildall.bat all compiles fine exept ImageFormats.bas

Code: Select all

e:\FreeBasic\fbc -w all "ImageFormats.bas" iup.rc (im Verzeichnis: E:\FreeBASIC\IUP)
lib/win32//libim.a(im_image.o):im_image.cpp:(.text+0xbd8): undefined reference to `__gxx_personality_sj0'
lib/win32//libim.a(im_image.o):im_image.cpp:(.text+0xbee): undefined reference to `_Unwind_SjLj_Register'
lib/win32//libim.a(im_image.o):im_image.cpp:(.text+0xc16): undefined reference to `_Unwind_SjLj_Unregister'
lib/win32//libim.a(im_image.o):im_image.cpp:(.text+0xd33): undefined reference to `_Unwind_SjLj_Resume'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xcae): undefined reference to `__gxx_personality_sj0'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xcc4): undefined reference to `_Unwind_SjLj_Register'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xd4d): undefined reference to `_Unwind_SjLj_Unregister'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xd8c): undefined reference to `_Unwind_SjLj_Resume'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xda8): undefined reference to `__gxx_personality_sj0'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xdbe): undefined reference to `_Unwind_SjLj_Register'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xe60): undefined reference to `_Unwind_SjLj_Unregister'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xe9b): undefined reference to `_Unwind_SjLj_Resume'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xebe): undefined reference to `__gxx_personality_sj0'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xed4): undefined reference to `_Unwind_SjLj_Register'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xf64): undefined reference to `_Unwind_SjLj_Unregister'
lib/win32//libim.a(im_file.o):im_file.cpp:(.text+0xfa3): undefined reference to `_Unwind_SjLj_Resume'
lib/win32//libim.a(im_attrib.o):im_attrib.cpp:(.text+0x61e): undefined reference to `__gxx_personality_sj0'
lib/win32//libim.a(im_attrib.o):im_attrib.cpp:(.text+0x634): undefined reference to `_Unwind_SjLj_Register'
lib/win32//libim.a(im_attrib.o):im_attrib.cpp:(.text+0x6d6): undefined reference to `_Unwind_SjLj_Unregister'
lib/win32//libim.a(im_attrib.o):im_attrib.cpp:(.text+0x709): undefined reference to `_Unwind_SjLj_Resume'
lib/win32//libim.a(im_attrib.o):im_attrib.cpp:(.text+0x768): undefined reference to `__gxx_personality_sj0'
lib/win32//libim.a(im_attrib.o):im_attrib.cpp:(.text+0x77e): undefined reference to `_Unwind_SjLj_Register'
lib/win32//libim.a(im_attrib.o):im_attrib.cpp:(.text+0x8ce): undefined reference to `_Unwind_SjLj_Unregister'
lib/win32//libim.a(im_attrib.o):im_attrib.cpp:(.text+0x916): undefined reference to `_Unwind_SjLj_Resume'
lib/win32//libim.a(im_attrib.o):im_attrib.cpp:(.text+0x933): undefined reference to `_Unwind_SjLj_Resume'
Kompilierung fehlgeschlagen.

E:\FreeBASIC>fbc -version
FreeBASIC Compiler - Version 0.24.0 (04-25-2012) for win32
Copyright (C) 2004-2012 The FreeBASIC development team.
standalone, objinfo: disabled

Grüße
Post Reply