• Welcome to Jose's Read Only Forum 2023.
 

Iup And Pbcc

Started by James C. Fuller, January 06, 2016, 03:03:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

James C. Fuller

I am continuing the Iup/PBCC discussion here as some of the inquiries deal with topics not allowed there (other BASIC's)

I first encountered Iup while learning/testing FreeBasic. I believe the original PowerBASIC demo I posted was a ported FreeBasic one.
Iup supports both 32/64 Windows and Linux  with libraries for several vc and gcc versions. I am not at all familiar with the Lua integration.

I next looked at it for use with my bc9Basic project.
I did not like the format of the included "c" demos:

  /* Creates dialog with the three frames */
  dialog = IupDialog
  (
    IupVbox
    (
      fr1,
      fr2,
      fr3,
      NULL
    )
  );


so I used the Create/AddChild format of my original PowerBASIC posting.
While recommending this method to Roland on the Oxygen Basic forum he countered with my demo in LED. That lead me to study LED and come to the conclusion that LED is far superior for basic gui data input forms than anything I had encountered previously.
Iup too has the best layout format for sizable dialogs. It is the only one where there is no flashing of frame's. There are items lacking like a List view but Iup is still in active development.

Another feature for me with bc9Basic is the "ledc" utility which converts an LED script to "c" source which can be compiled separately and then linked to your app.
You could put a number of them in a library and just link the library.

There is also IupLoadBuffer where you pass an LED script as a string. Could be created dynamically, stored in code, or stored as a string resource.

Many different approaches.

James

James C. Fuller

PBCC Iup issues.
I have run into an issue with Pbcc and Iup That I cannot resolve.
To try and find the problem I only declare the procedures that are used.

I used the same dynamic loading with my bc9Basic using tiny c, Pelles c, gcc, and vc on Win7 64 as a 32 bit app, and all produce the correct results.

The only thing I can point at is my declaration of varargs on IupMenu?

José,
  Do you see any problems with my translations?


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'iup menu.c -> Pbcc menu.bas
' I left the console visible so I could check returned values with ?
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#COMPILE EXE
'#CONSOLE OFF
#DIM ALL
'Use José's Include Files
'#INCLUDE ONCE "windows.inc"
'#Include Once "PbLib610.bas"
'Make sure you compile the rc file first.
'#RESOURCE RES,"IUPTEST.RES"
'#include "iup.bi"
MACRO NULL = 0
MACRO IHANDLE = DWORD
MACRO StringzPtr = DWORD
MACRO VoidPtr = DWORD
MACRO Icallback = DWORD
%IUP_CLOSE = -3
%IUP_ERROR = 1


$DLLNAME = "iup.dll"
'==============================================================================
'int       IupOpen          (int *argc, char ***argv);
Declare Function IupOpen cdecl Import  $DLLNAME Alias  "IupOpen" (BYVAL DWORD,BYVAL DWORD)AS LONG
'------------------------------------------------------------------------------
'Ihandle*  IupItem       (const char* title, const char* action);
Declare Function IupItem cdecl Import  $DLLNAME Alias "IupItem"(Byref StringZ,Byref StringZ) As Ihandle
'------------------------------------------------------------------------------
'void      IupSetAttribute   (Ihandle* ih, const char* name, const char* value);
Declare Sub IupSetAttribute cdecl Import  $DLLNAME Alias "IupSetAttribute"(Byval Ihandle,Byref Stringz,Byref Stringz)
'------------------------------------------------------------------------------
'Icallback IupSetCallback (Ihandle* ih, const char *name, Icallback func);
Declare Function IupSetCallback cdecl Import  $DLLNAME Alias "IupSetCallback"(Byval Ihandle,Byref Stringz,Byval Icallback) As Icallback
'------------------------------------------------------------------------------
'Ihandle*  IupSeparator  (void);
Declare Function IupSeparator cdecl Import  $DLLNAME Alias "IupSeparator"() As Ihandle
'------------------------------------------------------------------------------
'Ihandle*  IupMenu       (Ihandle* child,...);
Declare Function IupMenu cdecl Import  $DLLNAME Alias "IupMenu"(Byval Ihandle, OPT _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _                                                                                                                                                                                               
                                                                Byval Ihandle _
                                                                ) As Ihandle
'------------------------------------------------------------------------------
'Ihandle*  IupSubmenu    (const char* title, Ihandle* child);
Declare Function IupSubmenu cdecl Import  $DLLNAME Alias "IupSubmenu"(Byref StringZ,Byval Ihandle) As Ihandle
'------------------------------------------------------------------------------
'Ihandle*  IupSetHandle    (const char *name, Ihandle* ih);
Declare Function IupSetHandle cdecl Import  $DLLNAME Alias "IupSetHandle"(Byref Stringz,Byval Ihandle) As Ihandle
'------------------------------------------------------------------------------
'Ihandle*  IupDialog     (Ihandle* child);
Declare Function IupDialog cdecl Import  $DLLNAME Alias "IupDialog"(Byval Ihandle) As Ihandle
'------------------------------------------------------------------------------
'Ihandle*  IupCanvas     (const char* action);
Declare Function IupCanvas cdecl Import  $DLLNAME Alias "IupCanvas"(Byref StringZ) As Ihandle
'------------------------------------------------------------------------------
'int       IupShow          (Ihandle* ih);
Declare Function IupShow cdecl Import  $DLLNAME Alias "IupShow"(Byval Ihandle) As Long
'------------------------------------------------------------------------------
'int       IupMainLoop      (void);
Declare Function IupMainLoop cdecl Import  $DLLNAME Alias "IupMainLoop"() As Long
'------------------------------------------------------------------------------
'void      IupClose         (void);
DECLARE SUB IupClose cdecl Import  $DLLNAME Alias "IupClose"()

'==============================================================================
FUNCTION exit_cb()cdecl AS LONG
  FUNCTION = %IUP_CLOSE
END FUNCTION

Function PbMain()
    Dim rv AS long
    Local dlg,menu,item_save, item_open, item_undo, item_exit, file_menu, _
          sub1_menu As Ihandle

    rv = IupOpen(0,0)
   
    IF rv = %IUP_ERROR THEN
        'MsgBox("Initialize Failed")
        ? "Initialize Failed"
        EXIT FUNCTION
    END IF
    item_open = IupItem ("Open", "")
    IupSetAttribute(item_open, "KEY", "O")
   
    item_save = IupItem ("Save", "")
    IupSetAttribute(item_save, "KEY", "S")
   
    item_undo = IupItem ("Undo", "")
    IupSetAttribute(item_undo, "KEY", "U")
    IupSetAttribute(item_undo, "ACTIVE", "NO")
   
    item_exit = IupItem ("Exit", "")
    IupSetAttribute(item_exit, "KEY", "x")
    IupSetCallback(item_exit, "ACTION", CODEPTR(exit_cb))

    file_menu = IupMenu(item_open, _
                      item_save, _
                      IupSeparator(), _
                      item_undo, _
                      item_exit, _
                      NULL)

    ? "file_menu -> ";file_menu       
    sub1_menu = IupSubmenu("File", file_menu)
    ? "sub1_menu -> ";sub1_menu
    menu = IupMenu(sub1_menu, NULL)
    ? "menu      -> "; menu
    IupSetHandle("mymenu", menu)
    dlg = IupDialog(IupCanvas(""))
    IupSetAttribute(dlg, "MENU", "mymenu")
    IupSetAttribute(dlg, "TITLE", "IupMenu")
    IupSetAttribute(dlg, "SIZE", "QUARTERxQUARTER")
   
    IupShow(dlg)
    IupMainLoop()
    IupClose()
     
End Function



James

James C. Fuller

Ok, I found the culprit.
It appears Pb does not create/pass literal strings the same way "c" does.


'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'iup menu.c -> Pbcc menu.bas
' The IupSetAttribute procedure was the problem.
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#COMPILE EXE
#CONSOLE OFF
#DIM ALL
'Use José's Include Files
'#INCLUDE ONCE "windows.inc"
'#Include Once "PbLib610.bas"
'Make sure you compile the rc file first.
'#RESOURCE RES,"IUPTEST.RES"
'#include "iup.bi"
MACRO NULL = 0
MACRO IHANDLE = DWORD
MACRO StringzPtr = DWORD
MACRO VoidPtr = DWORD
MACRO Icallback = DWORD
%IUP_CLOSE = -3
%IUP_ERROR = 1


$DLLNAME = "iup.dll"
'==============================================================================
'int       IupOpen          (int *argc, char ***argv);
Declare Function IupOpen cdecl Import  $DLLNAME Alias  "IupOpen" (BYVAL DWORD,BYVAL DWORD)AS LONG
'------------------------------------------------------------------------------
'Ihandle*  IupItem       (const char* title, const char* action);
Declare Function IupItem cdecl Import  $DLLNAME Alias "IupItem"(Byref StringZ,Byref StringZ) As Ihandle
'------------------------------------------------------------------------------
'void      IupSetAttribute   (Ihandle* ih, const char* name, const char* value);
Declare Sub IupSetAttribute cdecl Import  $DLLNAME Alias "IupSetAttribute"(Byval Ihandle,Byref Stringz,Byref Stringz)
'------------------------------------------------------------------------------
'void      IupSetStrAttribute(Ihandle* ih, const char* name, const char* value);
Declare Sub IupSetStrAttribute cdecl Import  $DLLNAME Alias "IupSetStrAttribute"(Byval Ihandle,Byref Stringz,Byref Stringz)
'------------------------------------------------------------------------------
'Ihandle*  IupSetAttributes (Ihandle* ih, const char *str);
Declare Function IupSetAttributes cdecl Import  $DLLNAME Alias "IupSetAttributes"(Byval Ihandle,Byref Stringz) As Ihandle
'------------------------------------------------------------------------------
'Icallback IupSetCallback (Ihandle* ih, const char *name, Icallback func);
Declare Function IupSetCallback cdecl Import  $DLLNAME Alias "IupSetCallback"(Byval Ihandle,Byref Stringz,Byval Icallback) As Icallback
'------------------------------------------------------------------------------
'Ihandle*  IupSeparator  (void);
Declare Function IupSeparator cdecl Import  $DLLNAME Alias "IupSeparator"() As Ihandle
'------------------------------------------------------------------------------
'Ihandle*  IupMenu       (Ihandle* child,...);
Declare Function IupMenu cdecl Import  $DLLNAME Alias "IupMenu"(Byval Ihandle, OPT _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _
                                                                Byval Ihandle, _                                                                                                                                                                                               
                                                                Byval Ihandle _
                                                                ) As Ihandle

'------------------------------------------------------------------------------
'Ihandle*  IupSubmenu    (const char* title, Ihandle* child);
Declare Function IupSubmenu cdecl Import  $DLLNAME Alias "IupSubmenu"(Byref StringZ,Byval Ihandle) As Ihandle
'------------------------------------------------------------------------------
'Ihandle*  IupSetHandle    (const char *name, Ihandle* ih);
Declare Function IupSetHandle cdecl Import  $DLLNAME Alias "IupSetHandle"(Byref Stringz,Byval Ihandle) As Ihandle
'------------------------------------------------------------------------------
'Ihandle*  IupDialog     (Ihandle* child);
Declare Function IupDialog cdecl Import  $DLLNAME Alias "IupDialog"(Byval Ihandle) As Ihandle
'------------------------------------------------------------------------------
'Ihandle*  IupCanvas     (const char* action);
Declare Function IupCanvas cdecl Import  $DLLNAME Alias "IupCanvas"(Byref StringZ) As Ihandle
'------------------------------------------------------------------------------
'int       IupShow          (Ihandle* ih);
Declare Function IupShow cdecl Import  $DLLNAME Alias "IupShow"(Byval Ihandle) As Long
'------------------------------------------------------------------------------
'int       IupMainLoop      (void);
Declare Function IupMainLoop cdecl Import  $DLLNAME Alias "IupMainLoop"() As Long
'------------------------------------------------------------------------------
'void      IupClose         (void);
DECLARE SUB IupClose cdecl Import  $DLLNAME Alias "IupClose"()

'==============================================================================
FUNCTION exit_cb()cdecl AS LONG
  FUNCTION = %IUP_CLOSE
END FUNCTION
'==============================================================================
Function PbMain()
    Dim rv AS long
    Local dlg,menu,item_save, item_open, item_undo, item_exit, file_menu, _
          sub1_menu As Ihandle

    rv = IupOpen(0,0)
   
    IF rv = %IUP_ERROR THEN
        'MsgBox("Initialize Failed")
        ? "Initialize Failed"
        EXIT FUNCTION
    END IF
    item_open = IupItem ("Open", "")
    IupSetAttribute(item_open, "KEY", "O")
   
    item_save = IupItem ("Save", "")
    IupSetAttribute(item_save, "KEY", "S")
   
    item_undo = IupItem ("Undo", "")
    IupSetAttribute(item_undo, "KEY", "U")
    IupSetAttribute(item_undo, "ACTIVE", "NO")
   
    item_exit = IupItem ("Exit", "")
    IupSetAttribute(item_exit, "KEY", "x")
    IupSetCallback(item_exit, "ACTION", CODEPTR(exit_cb))

    file_menu = IupMenu(item_open, _
                      item_save, _
                      IupSeparator(), _
                      item_undo, _
                      item_exit, _
                      NULL)

     
    sub1_menu = IupSubmenu("File", file_menu)
    menu = IupMenu(sub1_menu, NULL)
    IupSetHandle("mymenu", menu)
    dlg = IupDialog(IupCanvas(""))
    'Use IupSetAttributes
    IupSetAttributes(dlg, "TITLE=IupMenu,SIZE=QUARTERxQUARTER,MENU=mymenu")
    'or IupSetStrAttribute instead of IupSetAttribute
    'IupSetStrAttribute(dlg, "TITLE","IupMenu")
    'IupSetStrAttribute(dlg, "SIZE", "QUARTERxQUARTER")
    'IupSetStrAttribute(dlg, "MENU", "mymenu")
    IupShow(dlg)
    IupMainLoop()
    IupClose()
     
End Function



All fixed.

James

James C. Fuller

Quote from: Dean Gwilliam on January 06, 2016, 04:04:34 PM
James
Thank you very much for taking the trouble to provide some background re how you came to use Iup and what you think of it. It helps. I'm always on the lookout for good UI toolkits and from what you say it sounds well worth a look.

Dean,
  You are very welcome.
The more I work with Iup the more I like it.

James