IUP 3.11

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:

IUP 3.11

Post by D.J.Peters »

Latest version of IUP 3.11

download: fbIUP3.11.zip

(tested with fbc-1.0 win32)

Joshy
Last edited by D.J.Peters on Oct 03, 2017 4:40, edited 1 time in total.
jcfuller
Posts: 325
Joined: Sep 03, 2007 18:40

Re: IUP 3.11

Post by jcfuller »

Joshy,
Did you compile the Iup libraries?
If not which one did you download from the repository.

James
jcfuller
Posts: 325
Joined: Sep 03, 2007 18:40

Re: IUP 3.11

Post by jcfuller »

A big thanks to Joshy for his IUP library and includes.
I added an rc with an xp manifest:
Image


Now to get the 64 bit working. I tinkered and had it working sorta with 64bit dll's but ....

James

Code: Select all

'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'FreeBasic 1.0 32 bit IUP example using Joshy's library/include's
'I am not sure where I got this code but I like the structure much better than
' the package examples.
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#include once "inc/iup.bi"
'==============================================================================
'helper functions that make it easier to write and follow in my opinion
'------------------------------------------------------------------------------ 
Sub AddChild(ByVal parent As Ihandle Ptr, Byval child As Ihandle Ptr)
    IupAppend(parent,child)
    IupRefresh(parent)
End Sub
'==============================================================================
Function Create(Byval Value As String, Byval Attr As String,Byval Parent As Ihandle Ptr)As Ihandle Ptr
    var hWnd = IupCreate(Value)
    If hWnd Then
        If Len(Attr) Then
            IupSetAttributes(hWnd,Attr)
        End If
        If Parent Then
            AddChild(Parent,hWnd)
        End If    
    End If
    Function = hWnd
End Function
'==============================================================================
'fetch button callback
Function btnFetch_cb cdecl(byval handler As Ihandle Ptr) As Integer
    Dim szFile As zString * 256
    szFile = "*.txt"
    Select Case IupGetFile(szFile)
        Case 1
            IupMessage("New File",szFile)
        Case 0
            IupMessage("File already exists",szFile)
        Case -1
            IupMessage("IupFileDlg","Operation canceled")    
        Case -2
            IupMessage("IupFileDlg","Allocation error")
        Case -3
            IupMessage("IupFileDlg","Invalid parameter")
            
    End Select
    Function = IUP_DEFAULT
End Function
'==============================================================================
'Exit Button Callback
Function quit_cb cdecl(byval handler As Ihandle Ptr) As Integer
  Function = IUP_CLOSE
End Function
'==============================================================================
'About button callback
Function btnAbout_cb cdecl(byval handler As Ihandle Ptr) As Integer 
    Dim s As zString Ptr 
    s = IupVersion()
    IupMessage("IupVersion",(s))
    Function = IUP_DEFAULT
End Function

'==============================================================================
   If (IupOpen(0,0)) = IUP_ERROR Then
       Print "Initialize Failed"
       End 1
   End If  
   'Create Main Window
    var win = Create("dialog","TITLE=Thesaurus, SIZE=500x300",0)
    'create container to house ALL GUI objects
    var vbox = Create("vbox","MARGIN=10x10",0)
    'Create Server panel
     var topBox = Create("hbox", " GAP=10", vbox)
      var serverFrame = Create("frame", "TITLE=Servers, EXPAND=YES", topBox)
       var serverBox = Create("hbox", "GAP=5", serverFrame)
        var serverCombo = Create("list", "DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1", serverBox)
        var btnFetch = Create("button", "TITLE=Fetch, SIZE = 50x", serverBox)
        IupSetCallback(btnFetch, "ACTION", @btnFetch_cb)
    'Create control panel
      var controlFrame = Create("frame", "TITLE=Controls", topBox)
       var controlBox = Create("hbox", "Margin=6x6, GAP=5", controlFrame)
        var btnAbout = Create("button", "TITLE=About, SIZE = 50x", controlBox)
        var btnClear = Create("button", "TITLE=Clear, SIZE = 50x", controlBox)
        var btnExit = Create("button", "TITLE=Exit, SIZE = 50x", controlBox)
        'SETUP CALLBACK FOR EXIT BUTTON
        IupSetCallback(btnExit, "ACTION", @quit_cb)
        IupSetCallback(btnAbout, "ACTION", @btnAbout_cb)
    'Create dictionary panel
     var dictFrame = Create("frame", "TITLE=Dictionaries", vbox)
      var serverList = Create("list", "EXPAND=YES, VISIBLELINES=1", dictFrame)
    'Create text part
     var transFrame = Create("frame", "TITLE=Translation", vbox)
      var text = Create("text", "MULTILINE=YES, EXPAND=YES", transFrame)
    'Create entry and search button
     var bottomBox = Create("hbox", "GAP=10", vbox)
      var label = Create("label", "TITLE=Enter Word to Search For: , SIZE=x12", bottomBox)
      var entry = Create("text", " EXPAND=HORIZONTAL",bottomBox)
      var btnSearch = Create("button","TITLE=Search, SIZE=50x", bottomBox)
      var chkAll = Create("toggle", "TITLE=ALL, VALUE=ON,SIZE=x12", bottomBox)
      var chkUTF = Create("toggle", "TITLE=UTF-8, SIZE=x12", bottomBox)
    'Add the main GUI container to the Window
    AddChild(win, vbox)
    'Show the Window
    IupShow(win)
    IupSetFocus(btnFetch)
    IupMainLoop()
    IupClose()

jcfuller
Posts: 325
Joined: Sep 03, 2007 18:40

Re: IUP 3.11

Post by jcfuller »

It would be nice to have 64 bit libraries built with gcc 4.9.1
I do not code for 32bit any more as I don't own a 32bit OS; Windows or Linux.
One of the most popular(?) packages that I primarily use is the TDM-GCC compiler package.
Code::Blocks and prepackged wxWidgets is built with it
I am also using more and more this package gcc 4.9.1 from a Microsoft employee:

http://nuwen.net/mingw.html

A lot of nice included tools.

James
ike
Posts: 387
Joined: Jan 17, 2011 18:59

Re: IUP 3.11

Post by ike »

So, scintilla is included now?

How it is working with FB code? Syntax coloring and folding?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.11

Post by D.J.Peters »

I don't support IUP only FLTK.

Joshy
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: IUP 3.11

Post by TJF »

ike wrote:So, scintilla is included now?

How it is working with FB code? Syntax coloring and folding?
I made some adaptions regarding multi line comments and keywords in them, see http://www.freebasic.net/forum/viewtopi ... 5&p=191754. They're upstream since 2013, October. It's not perfect, but it work fine for me.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.11

Post by D.J.Peters »

ike wrote:So, scintilla is included now?
Yes, http://webserver2.tecgraf.puc-rio.br/iu ... tilla.html

but you have to use the IUP dynamic libs *.dll or *.so
FreeBASIC can't link the included static lib "iup_scintilla.a"

In case of windows you can delete your fbIUP3.11 folder and download the dynamic version of IUP.
download: fbIUP3.11win32.zip

Joshy

Code: Select all

#include once "inc/iup_scintilla.bi"

IupOpen(0,0)
IupScintillaOpen()

var sci = IupScintilla()
IupSetAttributes( sci,"EXPAND = YES")
var dlg = IupDialog(sci)
IupSetAttributes( dlg, "TITLE = IupDialog, RASTERSIZE = 640x480" )
IupShow(dlg)
IupMainLoop()

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

Re: IUP 3.11

Post by D.J.Peters »

simple test of: IupSetAttribute(ih, "LEXERLANGUAGE", "freebasic")

Joshy
Image

Code: Select all

#include once "inc/iup_scintilla.bi"


IupOpen(0,0)
IupScintillaOpen()

var ih = IupScintilla()
IupSetAttribute(ih, "LEXERLANGUAGE", "freebasic")

IupSetAttribute(ih, "KEYWORDS0", "dim if print then var")

IupSetAttribute(ih, "STYLEFONT32", "Consolas")
IupSetAttribute(ih, "STYLEFONTSIZE32", "11")

' some styles
IupSetAttribute(ih, "STYLEFGCOLOR1", "0 160 0")    ' comment
IupSetAttribute(ih, "STYLEFGCOLOR2", "0 160 160")  ' number
IupSetAttribute(ih, "STYLEFGCOLOR3", "0 0 160")    ' keywords
IupSetAttribute(ih, "STYLEFGCOLOR4", "160 0 0")    ' string
IupSetAttribute(ih, "STYLEFGCOLOR6", "255 128 0")  ' operator
IupSetAttribute(ih, "STYLEFGCOLOR7", "128 128 0")  ' preprocessor 
IupSetAttribute(ih, "STYLEFGCOLOR19", "128 128 128")  ' block comment

IupSetAttribute(ih, "MARGINWIDTH0", "50")
IupSetAttribute(ih, "MARGINSENSITIVE1", "YES")

IupSetAttributes(ih,"EXPAND = YES")

IupSetAttribute(ih, "VALUE",  !"' comment\nvar number = 123\nprint \"hello world\"\n#if 0\n nothing\n#endif\n/' block comment '/\n\if number >= 10 then print \">=10\"")

var dlg = IupDialog(ih)
IupSetAttributes( dlg, "TITLE = IupDialog, RASTERSIZE = 640x480" )
IupShow(dlg)
IupMainLoop()

IupClose()
Last edited by D.J.Peters on Oct 03, 2017 4:39, edited 1 time in total.
ike
Posts: 387
Joined: Jan 17, 2011 18:59

Re: IUP 3.11

Post by ike »

Thank You

Syntx coloring is OK, but for some reason it doesnot fold?

Code: Select all

#include "crt/stdlib.bi"
#include "crt/stdio.bi"
#include "crt/string.bi"

#include once "inc/iup_scintilla.bi"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function marginclick_cb cdecl(byval self as Ihandle ptr, byval margin as integer, byval line_ as integer, byval status as zstring ptr) as integer
  printf(!"MARGINCLICK_CB(Margin: %d, Line: %d, Status:%s)\n", margin, line_, status)
  printf(!"Fold Level = %s\n", IupGetAttributeId(self, "FOLDLEVEL", line_))
  IupSetfAttribute(self, "FOLDTOGGLE", "%d", line_)
  return IUP_DEFAULT
end function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function hotspotclick_cb cdecl(byval self as Ihandle ptr, byval pos_ as integer, byval line_ as integer, byval col as integer, byval status as zstring ptr) as integer
  dim text as zstring ptr = IupGetAttributeId(self, "LINE", line_)
  printf(!"HOTSPOTCLICK_CB (Pos: %d, Line: %d, Col: %d, Status:%s)\n", pos_, line_, col, status)
  printf(!"    line text = %s\n", text)
  return IUP_DEFAULT
end function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function caret_cb cdecl (byval self as Ihandle ptr, byval lin as integer, byval col as integer, byval pos_ as integer) as integer
  printf(!"CARET_CB = lin: %d, col: %d, pos_: %d\n", lin, col, pos_)
  printf(!"%s\n", IupGetAttribute(self, "LINEVALUE"))
  return IUP_DEFAULT
end function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function valuechanged_cb cdecl(byval self as Ihandle ptr) as integer
  printf(!"VALUECHANGED_CB\n")
  return IUP_DEFAULT
end function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function action_cb cdecl (byval self as Ihandle ptr, byval insert as integer, byval pos_ as integer, byval length as integer, byval text as zstring ptr) as integer
  printf(!"ACTION = insert: %d, pos_: %d, lenght:%d, text: %s\n", insert, pos_, length, text)
  return IUP_IGNORE
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function button_cb cdecl(byval self as Ihandle ptr, byval button as integer, byval pressed as integer, byval x as integer, byval y as integer, byval status as zstring ptr) as integer
  printf(!"BUTTON_CB = button: %d, pressed: %d, x: %d, y: %d, status: %s\n", button, pressed, x, y, status)
  return IUP_DEFAULT
end function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function motion_cb cdecl(byval self as Ihandle ptr, byval x as integer, byval y as integer, byval status as zstring ptr) as integer
  printf(!"MOTION_CB = x: %d, y: %d, status: %s\n", x, y, status)
  return IUP_DEFAULT
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub set_attribs (byval ih as Ihandle ptr)
'IupSetAttribute(ih, "CLEARALL", "")
IupSetAttribute(ih, "LEXERLANGUAGE", "freebasic")

IupSetAttribute(ih, "KEYWORDS0", "dim if print then var integer long ulong ulongint longint string zstring wstring short ushort ubyte double single unsigned signed")
IupSetAttribute(ih, "KEYWORDS1", "sub function declare dim end type union as ptr enum if elseif then select case default break goto return for while do continue sizeof typeof new delete property namespace operator this cast using andalso orelse xor or and not cdecl byval byref ")
IupSetAttribute(ih, "KEYWORDS2", "integer long ulong ulongint longint string zstring wstring short ushort ubyte double single unsigned signed")
  
IupSetAttribute(ih, "STYLEFONT32", "Courier New")
IupSetAttribute(ih, "STYLEFONTSIZE32", "12")

' some styles
'IupSetAttribute(ih, "STYLECLEARALL", "Yes")  /' sets all styles to have the same attributes as 32 '/
IupSetAttribute(ih, "STYLEFGCOLOR1", "0 160 0")    ' comment
IupSetAttribute(ih, "STYLEFGCOLOR2", "0 160 160")  ' number
IupSetAttribute(ih, "STYLEFGCOLOR3", "0 0 160")    ' keywords
IupSetAttribute(ih, "STYLEFGCOLOR4", "160 0 0")    ' string
IupSetAttribute(ih, "STYLEFGCOLOR5", "0 128 128")     '' 
IupSetAttribute(ih, "STYLEFGCOLOR6", "255 128 0")  ' operator
IupSetAttribute(ih, "STYLEFGCOLOR7", "128 128 0")  ' preprocessor 
IupSetAttribute(ih, "STYLEFGCOLOR9", "205 149 12")     '' Preprocessor block 
IupSetAttribute(ih, "STYLEFGCOLOR10", "0 197 205")       '' Keywords1
IupSetAttribute(ih, "STYLEFGCOLOR11", "0 255 0")    '' Keywords2

IupSetAttribute(ih, "STYLEFGCOLOR19", "128 128 128")  ' block comment
IupSetAttribute(ih, "STYLEBOLD10", "YES") '???

IupSetAttribute(ih, "STYLEHOTSPOT4", "YES")
IupSetAttribute(ih, "STYLEHOTSPOT11", "YES")

IupSetAttribute(ih, "MARGINWIDTH0", "50")
IupSetAttribute(ih, "MARGINSENSITIVE1", "YES")
IupSetAttribute(ih, "EXPAND", "YES")

if (1) then  
    IupSetAttribute(ih, "PROPERTY", "fold=1")
    IupSetAttribute(ih, "PROPERTY", "fold.compact=0")
    IupSetAttribute(ih, "PROPERTY", "fold.comment=1")
    IupSetAttribute(ih, "PROPERTY", "fold.preprocessor=1")

    IupSetAttribute(ih, "MARGINWIDTH1", "20")
    IupSetAttribute(ih, "MARGINTYPE1",  "SYMBOL")
    IupSetAttribute(ih, "MARGINMASKFOLDERS1",  "Yes")

    IupSetAttribute(ih, "MARKERDEFINE", "FOLDER=PLUS")
    IupSetAttribute(ih, "MARKERDEFINE", "FOLDEROPEN=MINUS")
    IupSetAttribute(ih, "MARKERDEFINE", "FOLDEREND=EMPTY")
    IupSetAttribute(ih, "MARKERDEFINE", "FOLDERMIDTAIL=EMPTY")
    IupSetAttribute(ih, "MARKERDEFINE", "FOLDEROPENMID=EMPTY")
    IupSetAttribute(ih, "MARKERDEFINE", "FOLDERSUB=EMPTY")
    IupSetAttribute(ih, "MARKERDEFINE", "FOLDERTAIL=EMPTY")
    IupSetAttribute(ih, "FOLDFLAGS", "LINEAFTER_CONTRACTED")
    IupSetAttribute(ih, "MARGINSENSITIVE1", "YES")
end if

IupSetAttribute(ih, "VALUE",  !"' comment\nvar number = 123\nprint \"hello world\"\n#if 0\n nothing\n#endif\n/' block comment '/\n\if number >= 10 then print \">=10\"\n sub mmm\nnumber = 7\nend sub")

IupSetCallback(ih, "MARGINCLICK_CB", cast(icallback, @marginclick_cb))
IupSetCallback(ih, "HOTSPOTCLICK_CB", cast(icallback, @hotspotclick_cb))
IupSetCallback(ih, "CARET_CB", cast(icallback,@caret_cb))
IupSetCallback(ih, "VALUECHANGED_CB", cast(icallback,@valuechanged_cb))
IupSetCallback(ih, "ACTION", cast(icallback,@action_cb))
'IupSetCallback(ih, "BUTTON_CB", cast(icallback, @button_cb))
'IupSetCallback(ih, "MOTION_CB", cast(icallback, @motion_cb))
end sub
sub print_info (byval ih as Ihandle ptr)
printf(!"Number of chars in this text: %s\n", IupGetAttribute(ih, "COUNT"))
printf(!"Number of lines in this text: %s\n", IupGetAttribute(ih, "LINECOUNT"))
printf(!"%s\n", IupGetAttribute(ih, "LINEVALUE"))
end sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''MAIN'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
IupOpen(0,0)
IupScintillaOpen()

var ih = IupScintilla()
set_attribs(ih)
var dlg = IupDialog(ih)
IupSetAttributes( dlg, "TITLE = IupDialog, RASTERSIZE = 640x480" )
IupShow(dlg)

print_info(ih)

IupMainLoop()
IupClose()
 
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: IUP 3.11

Post by TJF »

Folding should work for those blocks
  • FUNCTION
  • SUB
  • ENUM
  • TYPE
  • UNION
  • PROPERTY
  • CONSTRUCTOR
  • DESTRUCTOR
when the feature is enabled: option fold=true. (I don't know how to deal with Scintilla option under IUP.)
Post Reply