Oxygen Basic

Programming => Example Code => General => Topic started by: Arnold on March 28, 2015, 11:10:19 AM

Title: Question about IUP
Post by: Arnold on March 28, 2015, 11:10:19 AM
Hi Charles,

I am trying to run some Iup Examples with OxygenBasic, using as much of the original syntax as possible. Some work, some do not.

Am I doing something wrong with this example?

Code: OxygenBasic
  1. /*  IupGetColor: Example in C
  2.     Creates a predefined color selection dialog. The user receives the color in the RGB format.
  3. */
  4.  
  5. $ filename "getcolor.exe"
  6. 'include "$\inc\rtl32.inc"
  7. include "$\inc\console.inc"
  8.  
  9. includepath "iup\"
  10.  
  11. extern lib "iup\iup.dll" cdecl      
  12. include "iup.h"
  13. end extern
  14.  
  15. extern cdecl
  16. #define EXIT_SUCCESS 0
  17.  
  18. int main(int argc, char **argv)
  19. {
  20.   unsigned byte r, g, b;        'char
  21.  
  22.   IupOpen(&argc, &argv);
  23.  
  24.   if(IupGetColor(100, 100, &r, &g, &b)) then
  25.     print("RGB = " r ", " g ", " b) : waitkey()
  26.   end if
  27.  
  28.   IupClose();
  29.   return EXIT_SUCCESS;
  30. }
  31.  
  32. main(0,0)
  33.  

The dialog opens, but I always get 0,0,0 no matter what I try. Is there a way to get the contents of r,g,b?

Roland
Title: Re: Question about IUP
Post by: JRS on March 28, 2015, 11:21:54 AM
Code: C
  1.  IupControlsOpen ();
  2.  

Title: Re: Question about IUP
Post by: Arnold on March 28, 2015, 02:57:51 PM
This I tried at first. To do this I need some dlls of the cd library. But then I get a messagebox: IupControlsOpen() and the dialog does not open. Therefore I thought IupControlsOpen would not be necessary.

Code: OxygenBasic
  1. /*  IupGetColor: Example in C
  2.     Creates a predefined color selection dialog. The user receives the color in the RGB format.
  3. */
  4.  
  5. $ filename "getcolor.exe"
  6. 'include "$\inc\rtl32.inc"
  7. include "$\inc\console.inc"
  8.  
  9. includepath "iup\"
  10.  
  11. extern lib "iup\iup.dll" cdecl      
  12. include "iup.h"
  13. end extern
  14.  
  15. extern lib "iup\iupcontrols.dll" cdecl
  16. extern lib "iup\iupcd.dll" cdecl
  17. extern lib "iup\cd.dll" cdecl
  18. extern lib "iup\freetype6.dll" cdecl
  19. extern lib "iup\zlib1.dll" cdecl
  20. include "iupcontrols.h"  
  21. end extern
  22.  
  23. extern cdecl
  24. #define EXIT_SUCCESS 0
  25.  
  26.  
  27. int main(int argc, char **argv)
  28. {
  29.   unsigned byte r, g, b;     'char
  30.  
  31.   IupOpen(&argc, &argv);
  32.   IupControlsOpen ();
  33.  
  34.   if(IupGetColor(100, 100, &r, &g, &b)) then
  35.     print("RGB = " r ", " g ", " b) : waitkey()
  36.   end if
  37.  
  38.   IupClose();
  39.   return EXIT_SUCCESS;
  40. }
  41.  
  42. main(0,0)
  43.  
Title: Re: Question about IUP
Post by: Charles Pegge on March 28, 2015, 06:27:23 PM
Hi Roland,

I am not familiar with IUP but I recommend one of John's examples as a good starting point, for a GUI frame at least:  projectsb\IUP\jfdemo1.o2bas (thesaurus)

Peter's pwdemo1, in the same folder, with its own self-contained header, demonstrates some graphics. No extra DLLs required. PS: uncomment cdecl in the extern statement.

I dont think one would normally use IUP with a console, except for diagnostics.
Title: Re: Question about IUP
Post by: Arnold on May 21, 2015, 03:34:05 PM
Hi Charles,

may I ask for your help?

The basic principle of the Iup toolkit is rather simple: create a dialog with some controls, add some attributes to the controls and create some callbacks in cdecl for the events. Although I have managed to run many of the Iup test cases with OxygenBasic I am not sure if I could do some things better.

For setting the attributes I use IupSetStrAttribute (old IupStoreAttribute) because IupSetAttribute does not always work correctly. The declarations is:

iup.h:
void      IupSetAttribute   (Ihandle* ih, const char* name, const char* value);

void    IupSetStrAttribute(Ihandle* ih, const char* name, const char* value);
void     IupStoreAttribute(Ihandle* ih, const char* name, const char* value); ' old form

in iup.inc I used:
! IupSetAttribute   (sys ih, string name, string value)

! IupSetStrAttribute (sys ih, string name, string value)
! IupStoreAttribute  (sys ih, string name, string value)   ' old form

Although the arguments for IupSetAttribute and IupSetStrAttribute seem to be of the same type there must be a difference. The help file indicates:

IupSetAttribute can store only constant strings (like "Title", "30", etc) or application pointers.
IupSetStrAttribute (old IupStoreAttribute) can only store strings. The given string value will be duplicated internally.

I managed to do a lot with IupSetStrAttribute (old IupStoreAttribute) but it would be nice if I could get IupSetAttribute to work too. I suppose that some other functions should be adapted also because they internally call IupSetAttribute. Should I use a different type for IupSetAttribute? Maybe I can create a helper function like this?

! IupSetAttribute_ alias "IupSetAttribute" (sys ih, string name, string(?) value)

sub IupSetAttribute(...
  what to do?
end sub

This is a small example (intended to run in the folder OxygenBasic\ProjectB\Iup) which shows the difference:

Code: [Select]
include "$/inc/console.inc"

typedef sys Icallback

includepath "iup\"     
extern lib "IUP/iup.dll" cdecl     

#define IUP_DEFAULT   -2
#define IUP_CENTER    0xFFFF  /* 65535 */

! IupOpen          (sys argc,argv) as int
! IupClose         ()
! IupMainLoop      () as int
! IupShowXY        (sys ih, int x, int y) as int
! IupSetAttribute   (sys ih, string name, string value)
! IupStoreAttribute(sys ih, string name, string value)
! IupSetFunction(string name, Icallback func) as Icallback
! IupSetCallback (sys ih, string name, Icallback func) as Icallback
! IupCanvas     (string action) as sys
! IupDialog     (sys child) as sys

end extern

extern cdecl       


static int idle_count = 0

function idle()
  print "IDLE_ACTION( count = "  idle_count ")" & cr
  idle_count++

//  if (idle_count == 10000)
//    return IUP_IGNORE

  return IUP_DEFAULT
end function

function motion_cb(sys ih) as int callback
  print "MOTION_CB()" & cr
  if (idle_count > 15000) then
    IupSetFunction ("IDLE_ACTION", NULL)
  end if
  return IUP_DEFAULT
end function

sub IdleTest()

  sys dlg, canvas

  canvas = IupCanvas(NULL)
  IupSetCallback(canvas, "MOTION_CB", @motion_cb)
 
  dlg = IupDialog(canvas)
  IupSetAttribute(dlg, "TITLE", "Idle Test")
  IupSetAttribute(dlg, "RASTERSIZE", "500x500")
'  IupStoreAttribute(dlg, "TITLE", "Idle Test")
'  IupStoreAttribute(dlg, "RASTERSIZE", "500x500")

  IupShowXY(dlg, IUP_CENTER, IUP_CENTER)

  IupSetFunction ("IDLE_ACTION", @idle)
end sub


sub main()

  IupOpen(0,0)
  IdleTest()
  IupMainLoop()
  IupClose()

end sub

main()


With IupSetAttribute the title of the dialog shows "RASTERSIZE" wich should be "Idle Test". But how should I construct and use IupSetAttribute with a pointer to "value"?

Roland
Title: Re: Question about IUP
Post by: JRS on May 21, 2015, 06:10:06 PM
Hi Arnold,

I have found that languages that link dynamically via a a DLL/SO directly to IUP require the str/store method. Script BASIC is linked to IUP via its extension module API interface. This is why the SB and DLLC version get away using the applications strings rather than having to store a copy for IUP. Other than that, everything else should be the same.
Title: Re: Question about IUP
Post by: Charles Pegge on May 22, 2015, 12:15:11 AM
Hi Roland,

I am not at all familiar with IUP. John is the expert :)

But I agree that you can pass in-going string params wherever char* is specified.

This is because bstrings contain char*, and strings reference bstrings.

The actual format of a bstring is:

offset
-04  byte count NB
  00  characters
  NB  null characters (terminator)

(Of course, the called IUP function has no knowledge of a bstring structure, so using such params to return info to the caller should be used with caution.)

I would advise, however that you specify char* in the prototype declarations, rather than string, for precise representation.

I hope this helps.



PS:

In your example, I do not see any corruption of the title: "Idle Test"

Both SetAttribute and StoreAttribute work as expected

Oxygen DLL Update (200k)
http://www.oxygenbasic.org/o2zips/Oxygen.zip
Title: Re: Question about IUP
Post by: JRS on May 22, 2015, 08:33:24 AM
Quote from: Charles
I am not at all familiar with IUP. John is the expert.

I admit to spending more time with IUP then most in our BASIC circle but far from being an expert. I think we both can agree that IUP is a great cross platform native GUI open source library. Just the fact it's actively being developed and supported says a lot.

Title: Re: Question about IUP
Post by: Arnold on May 22, 2015, 10:48:04 AM
Hi Charles,

many thanks for the update. This really saved me some headaches. I tried IupSetAttribute with some more examples and it now works as expected. And I will follow your advice to use char* instead of string in the prototype declarations.

BTW I noticed that you added a folder \tests in the latest OxygenBasic.zip. Was this done intentionally?

Roland
Title: Re: Question about IUP
Post by: JRS on May 22, 2015, 10:55:18 AM
Quote
BTW I noticed that you added a folder \tests in the latest OxygenBasic.zip. Was this done intentionally?

Maybe Charles is planting a new IUP garden.  :)
Title: Re: Question about IUP
Post by: Charles Pegge on May 22, 2015, 10:00:01 PM

The new tests directory is a place for any code that is experimental, or that checks Oxygen's functionality. It makes sense to keep them separate from the other examples.
Title: Re: Question about IUP
Post by: Arnold on May 26, 2015, 11:46:02 PM
Hi Charles,

may I ask for your helping hand one more time? I have a problem with variadic functions using char *format, ... and although I tried a lot I do not find a solution which certainly does exist.

I try to run a demo with the IupScanf dialog (not recommended by the author, but shows the principle). This is the code of scanf.o2bas intended to run in ProjectsB/Iup:

Code: [Select]

includepath "iup\"     
extern lib "IUP/iup.dll" cdecl
     
! IupOpen      (sys argc,argv) as int
! IupClose     ()
! IupMessage   (char *title, char *msg)
! IupMessagef  (char *title, char *format, ...)
! IupScanf     (char *format, ...) as int

end extern

/*
includepath "iup/"     
extern lib "IUP/iup.dll" cdecl     
include "iup.h"
*/

extern cdecl       


% lf   = chr(10)    '\n' ??
% crlf = chr(13,10)

sub ScanfTest()

  int result
  int integr = 12
  float real = 0.001f    ' 1e-3f
  char text[300]="This is a vector of characters"
  char *fmt =
'  {
'   "IupScanf Example\n"  &
'   "Text: %300.5%s\n"    & 
'   "Real: %20.10%g\n"    & 
'   "Integer: %20.10%d\n"
'  }

   "IupScanf Example\nText: %300.5%s\nReal: %20.10%g\nInteger: %20.10%d\n"
'   "IupScanf Example" lf "Text: %300.5%s" lf "Real: %20.10%g" lf "Integer: %20.10%d" lf
   
' does not work? 
  IupMessagef("Before IupScanf","Text: %s" lf "Real: %f" lf "Integer: %d" ,
                  text, real, integr )

' does not work?
  result = IupScanf(fmt, text, &real, &integr)

  if result = -1 then
    IupMessage("IupScanf","Operation canceled")
  else
'    IupMessagef("IupScanf","Text: %s\nReal: %f\nInteger: %d\nFields read successfully: %d",text,real,integr,result)
    IupMessagef("IupScanf","Text: %s" lf "Real: %f" lf "Integer: %d" lf "Fields read successfully: %d",
                  text,real,integr,result)
  end if
end sub


sub main()

  IupOpen(0,0)
  ScanfTest()
  IupClose()

end sub

main()


IupMessagef and IupScanf somehow work and somehow wrong. IupMessagef seems to do some formating but does not show values, only the text vector. IupScanf does not show the dialog, but it also does not return an error (-1). Must I use different types with the arguments? Should the format string be adapted in some way?

If I try to use iup.h directly I get a strange error message (line points to int result):

ERROR:  direct void type not usable: ihandle: _retval
WORD:   [
LINE:   27
FILE:   main source
PASS:   1

Does this message refer somehow to IupMessagef or IupScanf too? If IupScanf with char *format, ... could be used, then a more powerful dialog IupGetParam would probably work too. I think almost all of the functions in the Iup library should work then.

I have attached the source code of iup_scanf.c (implementation of IupScanf). Unfortunately I do not know enough of the C language to decide how I should treat e.g "\n" or how to treat the pointers and types of the values in OxygenBasic.

Roland


.
Title: Re: Question about IUP
Post by: Arnold on May 26, 2015, 11:49:02 PM
I noticed that you added a nice demo using iupgl.dll. With me iupgl.dll did not work (because I forgot "extern cdecl"). By reading the code I also noticed that the appendix "as sys callback" might not be mandatory and could be omitted. But this must be checked. And if it is possible to use the header files directly I will do this in the examples provided with Iup3.14 too.
Title: Re: Question about IUP
Post by: JRS on May 26, 2015, 11:54:45 PM
Roland,

Great to see that you got theming working.

I'm really happy you have taken an interest in IUP and O2. I believe your efforts will set the standard on Windows using IUP.
Title: Re: Question about IUP
Post by: Charles Pegge on May 27, 2015, 06:26:10 AM
Hi Roland,

It expects a byval double.

You can pass a double directly, or explicitly convert the float to a double

Code: OxygenBasic
  1.    IupMessagef("Before IupScanf" , "Text: %s" lf "Real: %f" lf "Integer: %d", text,convert double real,integr)
  2.  

PS: Yes, o2 will accept IUP headers undoctored :)
Title: Re: Question about IUP
Post by: JRS on May 27, 2015, 09:23:41 AM
Quote
PS: Yes, o2 will accept IUP headers undoctored.

One of the best features in O2. IMHO
Title: Re: Question about IUP
Post by: JRS on May 27, 2015, 11:30:59 PM
Roland,

I wanted to mention another IUP effort I have going on the BASM Forum (http://www.basic-compiler.com/forum/index.php?topic=16.0). It works on BASM Windows and Linux. (32 bit only)

John
Title: Re: Question about IUP
Post by: Arnold on May 28, 2015, 02:20:14 PM
Hi John,

thank you for the link. Until recently I was not aware that there exist so many flavours of basic. But for the moment I will try to learn and use OxygenBasic. The Iup library is one activity to achieve this.

Roland
Title: Re: Question about IUP
Post by: Arnold on May 28, 2015, 02:24:46 PM
Hi Charles,

thank you for the IupMessagef solution. It is important to know that the C modifiers must be respected in some way in OxygenBasic too.

Nevertheless IupScanf does not fire and I do not know what I am doing wrong. There should be an input dialog with the fields for editing. I assume that IupScanf expects a pointer to a C string ending with zero, followed by some pointers to the fields containing the (formatted) values. The count of the sequence \n in the format string is one more than the fields.

Instead of using
! IupScanf     (char *format, ...) as int
I tried
! IupScanf     (sys *list) as int

and tried to build an array of pointers (also tried using a type). But my efforts are in vain:

Code: OxygenBasic
  1. includepath "iup\"      
  2. extern lib "IUP/iup.dll" cdecl
  3.      
  4. ! IupOpen      (sys argc,argv) as int
  5. ! IupClose     ()
  6. ! IupMessage   (char *title, char *msg)
  7. ! IupMessagef  (char *title, char *format, ...)
  8. '! IupScanf     (char *format, ...) as int
  9. ! IupScanf     (sys *list) as int
  10. end extern
  11.  
  12.  
  13. extern cdecl      
  14.  
  15. 'indexbase 0
  16.  
  17. % lf   = chr(10)    '\n' ??
  18. % crlf = chr(13,10)
  19.  
  20.  
  21.   int result
  22.   bstring text = nuls 300
  23.   text ="This is a vector of characters" & chr(0)
  24.  
  25.   bstring fmt = nuls 100
  26.   bstring  fmt =
  27.     "IupScanf Example\n"  &
  28.     "Text: %300.5%s\n" & chr(0)  
  29.  
  30.  
  31. sys f at strptr fmt : print f lf cast char f
  32. sys t at strptr text: print t lf cast char t
  33.  
  34. dim p(2) => (f,t)
  35.  
  36.  
  37.   IupOpen(0,0)
  38.   result = IupScanf(@p)
  39.  
  40.   if result = -1 then
  41.     IupMessage("IupScanf","Operation canceled")
  42.   else
  43.     print "success"
  44. '    IupMessagef("IupScanf","Text: %s\nFields read successfully: %d",text, result)
  45.  end if
  46.  
  47.   IupClose()
  48.  

I only get a result of -1 or a crash of the program. I think there is a solution, but I do not find the missing point. Perhaps it is necessary to use assembly?

Roland
Title: Re: Question about IUP
Post by: JRS on May 28, 2015, 04:53:16 PM
IupScanf

Quote
It is recommended that new applications use the IupGetParam dialog instead.

FYI: Be happy,  variadic functions are out of reach in the interpretive world. Some saving grace is that there are IUP variadic functions that are convenience wrappers to non-variadic functions. I emulate most of the variadic functionality with control creation with the IupCreate() and IupAppend() under the SB covers in the extension module. There as a few variadic functions I have no immediate solution for. Most are obscure functions and not core IUP.
Title: Re: Question about IUP
Post by: Charles Pegge on May 29, 2015, 01:45:31 AM
Hi Roland, John,

Both IupScanf and IupGetParam appear to be dud. And I have checked that the parameters were passed correctly.

Code: OxygenBasic
  1.  
  2. includepath "$\inc\"
  3. % filename  "z.exe"
  4. 'include     "RTL32.inc"
  5. 'include     "console.inc"
  6. 'include      "minwin.inc"
  7.  
  8.  
  9. includepath "iup\"      
  10. extern lib "IUP/iup.dll" cdecl
  11. include "iup.h"
  12.      
  13. extern cdecl      
  14.  
  15.  
  16.   IupOpen(null,null)
  17.  
  18.  
  19.   'SCANF TEST
  20.  ===========
  21.  
  22.   int result
  23.   string sdat=nuls 300
  24.   int    idat
  25.   double fdat
  26.   result = IupScanf("IupScanf Example\n Text:%300.5%s",strptr sdat,null)
  27.   print sdat
  28.  
  29.  
  30.   'GETPARAM TEST
  31.  ==============
  32.  
  33.   int pboolean = 1;
  34.   int pinteger = 3456;
  35.   float preal = 3.543f;
  36.   int pinteger2 = 192;
  37.   float preal2 = 0.5f;
  38.   float pangle = 90;
  39.   char pstring[100] = "string text";
  40.   char pfont[100] = "Courier, 24";
  41.   char pcolor[100] = "255 0 128";
  42.   int plist = 2, poptions = 1;
  43.   char pstring2[200] = "second text\nsecond line";
  44.   char file_name[500] = "test.jpg";
  45.  
  46.   sys param_action=0
  47.   'itr !
  48.  
  49.   if not (IupGetParam("Title", param_action, 0,
  50.  
  51.                    "Bt %u[, MyCancel, Help!]\n"+
  52.                    "Boolean: %b[No,Yes]\n"+
  53.                    "Integer: %i\n"+
  54.                    "Real 1: %r\n"+
  55.                    "Sep1 %t\n"+
  56.                    "Integer: %i[0,255]\n"+
  57.                    "Real 2: %r[-1.5,1.5,0.05]\n"+
  58.                    "Sep2 %t\n"+
  59.                    "Angle: %a[0,360]\n"+
  60.                    "String: %s\n"+
  61.                    "Options: %o|item0|item1|item2|\n" +
  62.                    "List: %l|item0|item1|item2|item3|item4|item5|item6|\n" +
  63.                    "File: %f[OPEN|*.bmp;*.jpg|CURRENT|NO|NO]\n"+
  64.                    "Color: %c{Color Tip}\n"+
  65.                    "Font: %n\n"+
  66.                    "Sep3 %t\n"+
  67.                    "Multiline: %m\n",
  68.                    &pboolean, &pinteger, &preal, &pinteger2, &preal2, &pangle, pstring,
  69.                    &poptions, &plist, file_name, pcolor, pfont, pstring2, NULL))
  70.  
  71.   end if
  72.  
  73.   print pinteger
  74.   IupClose()
  75.  
Title: Re: Question about IUP
Post by: JRS on May 29, 2015, 02:40:35 AM
Charles & Roland,

I have passed on your findings to the IUP SourceForge peer support mailing list asking Antonio (IUP author) to verify on his end.
Title: Re: Question about IUP
Post by: JRS on May 29, 2015, 10:52:00 AM
Quote from: Antonio
But what is the bug? IupGetparam is widely used around here.

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

Code: C
  1. /* IupScanf: Example in C
  2.    Shows a dialog with three fields to be filled.
  3.    One receives a string, the other receives a real number and
  4.    the last receives an integer number.
  5. */
  6.  
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <iup.h>
  10.  
  11. int main(int argc, char **argv)
  12. {
  13.   int ret;
  14.   int integer = 12;
  15.   float real = 1e-3f;
  16.   char text[300]="This is a vector of characters";
  17.   char *fmt =
  18.   {
  19.    "IupScanf Example\n"
  20.    "Text: %300.5%s\n"
  21.    "Real: %20.10%g\n"
  22.    "Integer: %3.10%d\n"
  23.   };
  24.  
  25.   IupOpen(&argc, &argv);
  26.  
  27.   IupSetLanguage("ENGLISH");
  28.  
  29.   ret = IupScanf(fmt, text, &real, &integer);
  30.   if (ret == -1)
  31.     IupMessage("IupScanf","Operation canceled");
  32.   else
  33.     IupMessagef("IupScanf","Text: %s\nReal: %f\nInteger: %d\nFields read successfully: %d",text,real,integer,ret);
  34.  
  35.   IupClose();
  36.  
  37.   return EXIT_SUCCESS;
  38.  
  39. }
  40.  
Title: Re: Question about IUP
Post by: Arnold on May 30, 2015, 08:43:57 AM
Hi Charles, hi John,

thank you for the help and investigation. For me it is an important finding, that there must be paid some attention when using formatted floats with the Iup library. As there are so many things which work without problem - and there is still a lot to examine - I am optimistic that IupScanf and IupGetParam will work finally too.

Roland
Title: Re: Question about IUP
Post by: Charles Pegge on May 30, 2015, 11:58:23 PM
Got it!

Each format line must terminate with chr(10)

Function ReplaceBN() provided to replace all "\n" with chr(10)

Code: OxygenBasic
  1. 'THESE DIALOGS DO NOT SHOW
  2.  
  3. includepath "$\inc\"
  4. % filename  "z.exe"
  5. 'include     "RTL32.inc"
  6. 'include     "console.inc"
  7. 'include      "minwin.inc"
  8.  
  9.  
  10. includepath "iup\"      
  11. extern lib "IUP/iup.dll" cdecl
  12. include "iup.h"
  13.      
  14. extern cdecl      
  15.  
  16. function ReplaceBN(char*fmt) as string
  17. ========================================
  18.   string s=fmt
  19.   do
  20.     i=instr(s,"\n")
  21.     if i then
  22.       s=left(s,i-1)+chr(10)+mid(s,i+2)
  23.     else
  24.       exit do
  25.     end if
  26.   end do
  27.   return s
  28. end function
  29.  
  30.  
  31. function main(sys argc,argv) as sys
  32. ===================================
  33.  
  34.   IupOpen(null,null)
  35.  'IupSetLanguage("ENGLISH");
  36.  
  37.  
  38.   'SCANF TEST
  39.  ===========
  40.  
  41.   int ret;
  42.   int integer = 12;
  43.   float real  = 1e-3f;
  44.   string text = "This is a vector of characters";
  45.  
  46.   string fmt= _
  47.   "IupScanf Example\n"+
  48.   "Text: %300.5%s\n"+
  49.   "Real: %20.10%g\n"+
  50.   "Integer: %3.10%d\n"
  51.  
  52.  
  53.   fmt = replaceBN fmt
  54.  
  55.  
  56.   ret = IupScanf(fmt, text, &real, &integer);
  57.   if (ret == -1)
  58.     IupMessage("IupScanf","Operation canceled");
  59.   else
  60.     IupMessagef("IupScanf","Text: %s\nReal: %f\nInteger: %d\nFields read successfully: %d",text,real,integer,ret);
  61.   end if
  62.  
  63.  
  64.   'GETPARAM TEST
  65.  ==============
  66.  
  67.   int pboolean = 1;
  68.   int pinteger = 3456;
  69.   float preal = 3.543f;
  70.   int pinteger2 = 192;
  71.   float preal2 = 0.5f;
  72.   float pangle = 90;
  73.   char pstring[100] = "string text";
  74.   char pfont[100] = "Courier, 24";
  75.   char pcolor[100] = "255 0 128";
  76.   int plist = 2, poptions = 1;
  77.   char pstring2[200] = "second text\nsecond line";
  78.   char file_name[500] = "test.jpg";
  79.  
  80.   sys param_action=0
  81.   'itr !
  82.  
  83.   if not (IupGetParam("Title", param_action, 0,
  84.                    replaceBN (
  85.                    "Bt %u[, MyCancel, Help!]\n"+
  86.                    "Boolean: %b[No,Yes]\n"+
  87.                    "Integer: %i\n"+
  88.                    "Real 1: %r\n"+
  89.                    "Sep1 %t\n"+
  90.                    "Integer: %i[0,255]\n"+
  91.                    "Real 2: %r[-1.5,1.5,0.05]\n"+
  92.                    "Sep2 %t\n"+
  93.                    "Angle: %a[0,360]\n"+
  94.                    "String: %s\n"+
  95.                    "Options: %o|item0|item1|item2|\n" +
  96.                    "List: %l|item0|item1|item2|item3|item4|item5|item6|\n" +
  97.                    "File: %f[OPEN|*.bmp;*.jpg|CURRENT|NO|NO]\n"+
  98.                    "Color: %c{Color Tip}\n"+
  99.                    "Font: %n\n"+
  100.                    "Sep3 %t\n"+
  101.                    "Multiline: %m\n"),
  102.                    &pboolean, &pinteger, &preal, &pinteger2, &preal2, &pangle, pstring,
  103.                    &poptions, &plist, file_name, pcolor, pfont, pstring2, NULL))
  104.   end if
  105.  
  106.   IupClose()
  107. end function
  108.  
  109. main null,null
  110.  
Title: Re: Question about IUP
Post by: JRS on May 31, 2015, 01:21:14 AM
Good catch Charles!

Title: Re: Question about IUP
Post by: Arnold on May 31, 2015, 01:36:18 AM
Hi Charles,

this is really, really cool. I knew there was a small mistake in my logic, but sometimes it is not so easy to find the needle in the haystack. To retrieve the final results now is rather easy e.g. with IupScanf:

Code: OxygenBasic
  1.  
  2. .....
  3. % lf=chr(10)
  4. .....
  5.   ret = IupScanf(fmt, strptr text, &real, &integer);
  6.   if (ret == -1)
  7.     IupMessage("IupScanf","Operation canceled");
  8.   else
  9.     IupMessagef("IupScanf","Text: %s" lf "Real: %lf" lf "Integer: %d" lf "Fields read successfully: %d",text,double(real),integer,ret);
  10.   end if
  11.  
  12.  
  13.   IupClose()
  14. end function
  15.  
  16. main null,null
  17.  
  18.  

I am really happy and I am convinced that the remaining functions of the Iup Library will work ok too.

Roland
Title: Re: Question about IUP
Post by: Arnold on May 31, 2015, 03:19:28 AM
Best of all: your function ReplaceBN can be used for formatted output. The code for IupScanf would then be:

Code: OxygenBasic
  1. includepath "$\inc\"
  2. % filename  "z.exe"
  3. 'include     "RTL32.inc"
  4. 'include     "console.inc"
  5. 'include      "minwin.inc"
  6.  
  7.  
  8. includepath "iup\"      
  9. extern lib "IUP/iup.dll" cdecl
  10. include "iup.h"
  11.      
  12. extern cdecl
  13.      
  14.  
  15. function ReplaceBN(char*fmt) as string
  16. ========================================
  17.   string s=fmt
  18.   do
  19.     i=instr(s,"\n")
  20.     if i then
  21.       s=left(s,i-1)+chr(10)+mid(s,i+2)
  22.     else
  23.       exit do
  24.     end if
  25.   end do
  26.   return s
  27. end function
  28.  
  29.  
  30. function main(sys argc,argv) as sys
  31. ===================================
  32.  
  33.   IupOpen(null,null)
  34.  
  35.  
  36.   'SCANF TEST
  37.  ===========
  38.  
  39.   int ret;
  40.   int integr = 12;
  41.   double real  = 0.001;
  42.   char text[300] = "This is a vector of characters";
  43.          
  44.   string fmt= _
  45.   "IupScanf Example\n"+
  46.   "Text: %300.5%s\n"+
  47.   "Real: %20.10%lf\n"+
  48.   "Integer: %20.10%d\n"
  49.  
  50.  
  51.   fmt = replaceBN fmt
  52.  
  53.  
  54.   ret = IupScanf(fmt,  @text, &real, &integr);
  55.   if (ret == -1)
  56.     IupMessage("IupScanf","Operation canceled");
  57.   else
  58.     IupMessagef("IupScanf", replaceBN("Text: %s\nReal: %f\nInteger: %d\nFields read successfully: %d"),text,real,integr,ret);
  59.   end if
  60.  
  61.  
  62.   IupClose()
  63. end function
  64.  
  65. main null,null
  66.  
  67.  

The use of replaceBN will be useful for some more Iup functions.

Edit:

I used for the variable text char[300] again to prevent a crash of the program.
Title: Re: Question about IUP
Post by: JRS on May 31, 2015, 09:16:11 PM
I didn't know O2 would let you end a line with a ;

Title: Re: Question about IUP
Post by: Arnold on May 31, 2015, 10:27:50 PM
Yes Oxygenbasic is very flexible in some cases. But you must be careful: ';' is treated as a comment. To use it as a separator one must use #separator semicolon before. (See Oxygen Help file).
Title: Re: Question about IUP
Post by: Arnold on June 18, 2015, 12:11:27 AM
Hi Charles,

trying to use iup.h directly I encounter some problems. What is the difference between these two examples:

This code shows the correct result:

Code: OxygenBasic
  1. 'getcolor1.o2bas
  2.  
  3. include "$/inc/console.inc"
  4.  
  5. includepath "iup\"      
  6. extern lib "IUP/iup.dll" cdecl
  7. 'include "iup.h"  
  8.  
  9. ! IupOpen          (sys argc,argv) as int
  10. ! IupGetColor(int x, int y, byte* r, byte* g, byte* b) as int    
  11. ! IupClose         ()
  12.  
  13. end extern
  14.  
  15. extern cdecl
  16.  
  17.  
  18. sub GetColorTest()
  19.   byte r = 10, g = 100, b = 25
  20.   if IupGetColor(100, 100, &r, &g, &b) then
  21.     print "RGB = "  r  ","  g  ","  b  " Hex=["  hex(r)  ","  hex(g)  ","  hex(b)  "]" &
  22.              cr &"Enter ..."  & cr
  23.   end if
  24. end sub
  25.  
  26.  
  27. sub main()
  28.  
  29.   IupOpen(0,0)
  30.   GetColorTest()
  31.  
  32.   IupClose()
  33.  
  34. end sub
  35.  
  36. main()
  37.  
  38. waitkey()
  39.  
  40.  
  41.  
  42.   IupOpen(0,0)
  43.  
  44.   byte r = 10, g = 100, b = 25
  45.   int result=IupGetColor(100, 100, &r, &g, &b)
  46.   if result then
  47.     print "RGB = "  r  ","  g  ","  b  " Hex=["  hex(r)  ","  hex(g)  ","  hex(b)  "]" &
  48.              cr &"Enter ..."  & cr
  49.   end if
  50.   IupClose()
  51.  
  52.  
  53. waitkey()
  54.  

Following the same code with using iup.h. It does either not work at all or does not change the values of r,g,b. What should I do differently?

Roland

Code: [Select]
'getcolor2.o2bas

include "$/inc/console.inc"

includepath "iup\"     
extern lib "IUP/iup.dll" cdecl
include "iup.h"

'int       IupOpen          (int *argc, char ***argv);
'void      IupClose         (void);
'int  IupGetColor(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b);

end extern
     
extern cdecl       
/*
' will not work at all
sub GetColorTest()
  byte r = 10, g = 100, b = 25
  if IupGetColor(100, 100, &r, &g, &b) then
    print "RGB = "  r  ","  g  ","  b  " Hex=["  hex(r)  ","  hex(g)  ","  hex(b)  "]" &
             cr &"Enter ..."  & cr
  end if
end sub


sub main()

  IupOpen(0,0)
  GetColorTest()

  IupClose()

end sub

main()

waitkey()
*/

' returns false result
  IupOpen(0,0)

  byte r = 10, g = 100, b = 25
  int result=IupGetColor(100, 100, &r, &g, &b)
  if result then
    print "RGB = "  r  ","  g  ","  b  " Hex=["  hex(r)  ","  hex(g)  ","  hex(b)  "]" &
             cr &"Enter ..."  & cr
  end if
  IupClose()

 
waitkey()
Title: Re: Question about IUP
Post by: Charles Pegge on June 18, 2015, 12:47:39 AM
Hi Roland,

char is understood as a string, and byte is understood as an integer.

Here's the byval solution :)

Code: OxygenBasic
  1. 'getcolor2.o2bas
  2.  
  3. include "$/inc/console.inc"
  4.  
  5.   includepath "iup\"      
  6.   extern lib "IUP/iup.dll" cdecl
  7.   include "iup.h"
  8.   extern cdecl      
  9.  
  10.   IupOpen(null,null)
  11.  
  12.   byte r = 10, g = 100, b = 25
  13.   int result=IupGetColor(100, 100, byval &r, byval &g, byval &b)
  14.   if result then
  15.     print "RGB = "  r  ","  g  ","  b  " Hex=["  hex(r)  ","  hex(g)  ","  hex(b)  "]" &
  16.              cr &"Enter ..."  & cr
  17.   end if
  18.   IupClose()
  19.  
  20.  
  21. waitkey()
  22.  
Title: Re: Question about IUP
Post by: Arnold on June 18, 2015, 02:17:32 AM
Hi Charles,

thank you for this solution. This will solve some more functions which use unsigned char*. And it seems I must deal a little bit more with byval and byref.

Roland
Title: Re: Question about IUP
Post by: Arnold on June 18, 2015, 02:48:06 AM
And
typedef sys iHandle*
solved my second problem. I think I will now start seriously with using iup.h directly.

Roland

Code: OxygenBasic
  1. 'getcolor2.o2bas
  2. include "$/inc/console.inc"
  3.  
  4.   includepath "iup\"      
  5.   extern lib "IUP/iup.dll" cdecl
  6.   include "iup.h"
  7.   extern cdecl      
  8.  
  9. typedef sys iHandle*
  10.  
  11. sub GetColorTest()
  12.   byte r = 10, g = 100, b = 25
  13.   if IupGetColor(100, 100, byval &r, byval &g, byval &b) then
  14.     print "RGB = "  r  ","  g  ","  b  " Hex=["  hex(r)  ","  hex(g)  ","  hex(b)  "]" &
  15.              cr &"Enter ..."  & cr
  16.   end if
  17. end sub
  18.  
  19. sub main()
  20.  
  21.   IupOpen(0,0)
  22.   GetColorTest()
  23.  
  24.   IupClose()
  25.  
  26. end sub
  27.  
  28. main()
  29.  
  30. waitkey()
  31.  
Title: Re: Question about IUP
Post by: Arnold on July 04, 2015, 01:03:12 AM
Hi Charles,

I noticed that you updated the Iup.dll to version 3.14 but still use the include files of version 3.06. In case you wish to update these files too the include files are added in the attached zip file. These are the original files of the Iup toolkit using the unix style of end line characters (LF). I have added two extra files (Iup_draw.h and Iup_key.h) which can be used for some more Iup api functions.

Also added are two demos (tabs.o2bas, zbox.o2bas) which use LED files. These are simple text files which can be used for creating dialogs and controls. The callback events are then handled in the main .o2bas files. Using LED files is indeed an interesting option.

I also included another opengl demo which is provided with the original Iup Toolkit.

There are two demos of projectB/Iup where I did some small modifications:

jfdemo1H.o2bas needs this modification:

  label = Create("label", `TITLE="Enter Word to Search For:" , SIZE=x12`, bottomBox)

The text of TITLE must be enclosed with quotes, therefore I used the alternative quoting too.

In pwdemo1.o2bas I used iup_draw.h directly to call the api functions. This works very nice.

I also found that there is no problem creating executables. On the whole I think that OxygenBasic can handle the Iup toolkit very well either wrapping the functions or (with some limitation) using the header files directly.

Should it be possible to use the 64bit dlls with the code too? (I did not yet try this).


Roland



.
Title: Re: Question about IUP
Post by: JRS on July 04, 2015, 11:01:15 AM
Quote
Also added are two demos (tabs.o2bas, zbox.o2bas) which use LED files. These are simple text files which can be used for creating dialogs and controls. The callback events are then handled in the main .o2bas files. Using LED files is indeed an interesting option.

Thanks Roland for the LED file examples! I have been contemplating using the LED method as an alternative to my home brew SBx IUP wrapper. Just to let you know, I'm following your progress with IUP/O2 closely. 
Title: Re: Question about IUP
Post by: Arnold on July 05, 2015, 12:25:03 AM
Hi John,

from my point of view, LED files could simplify the layout of dialogs and controls in IUP. Although they look a little bit strange at the first moment, they have a simple syntax:

From IUP Helpfile:
Quote
In LED, attributes and expressions follow this form:

elem = element[attribute1=value1,attribute2=value2,...](...expression...)

The names of the elements must not contain the “iup” prefix

I think the elements could be drawn on paper and then simply specified in a LED file. They can be loaded at run time with IupLoad. There is also a function IupLoadBuffer which loads a string with the LED specification. I have not yet tried this, but if it works a LED file could be loaded as a string in the main program or in an include file. There is also a LED compiler (ledc) which generates C modules from one or more LED files. Many combinations of using LED files are possible.

Roland
Title: Re: Question about IUP
Post by: JRS on July 05, 2015, 10:28:49 PM
Sounds great Roland. I'll give LED a try in Script BASIC and post a link when I have something to show.

Title: Re: Question about IUP
Post by: Arnold on July 06, 2015, 02:00:47 AM
This is an example which will also run in projectsB\IUP. It uses IupLoadBuffer to create the dialog and controls from a string with the LED specification. I used this routine to load the string:

Code: OxygenBasic
  1. $ filename "sample_w_led.exe"
  2. 'include "$/inc/RTL32.inc"
  3.  
  4. extern lib "IUP/iup.dll" cdecl
  5. includepath "IUP/"
  6. include "iup.h"
  7.  
  8. end extern  
  9.  
  10. extern cdecl
  11.  
  12. typedef sys Ihandle
  13.  
  14.  
  15. includepath ""
  16. include "sample.inc"
  17.  
  18. sub Load_LED_Dialog()
  19.   string err = NULL
  20.  
  21.   /* Initialization of IUP and its controls */
  22.  
  23.   err = IupLoadBuffer(sample_led)
  24.   if len(err) then
  25.     IupMessage("LED error", err)
  26.     'hasta la vista baby
  27.    terminate()
  28.     end
  29.   end if
  30.    
  31.   IupShow(IupGetHandle("dlg"))
  32.    
  33. end sub
  34.  
  35.  
  36. sub main()
  37.  
  38.    IupOpen(0,0)
  39.    Load_LED_Dialog()
  40.    IupMainLoop()
  41.    IupClose()
  42.  
  43. end sub
  44.  
  45. main()
  46.  

I like creating the dialogs this way. IupGetClassName in the Iup Helpfile indicates the elements which can be created with LED (expander should also work). By adding some callbacks for the events in the main .o2bas file the application could then be further developed.

Roland

.
Title: Re: Question about IUP
Post by: JRS on July 06, 2015, 04:51:43 PM
Works Great!

Code: Script BASIC
  1. ' Script BASIC IUP/LED
  2.  
  3. IMPORT iup.bas
  4. sample_led = """
  5.  
  6. img1 = IMAGE[0="0 0 0",1="BGCOLOR",2="255 0 0"]
  7. (32,32
  8. ,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
  9. ,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1
  10. ,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1
  11. ,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1
  12. ,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1
  13. ,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1
  14. ,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1
  15. ,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1
  16. ,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,2
  17. ,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,2
  18. ,2,2,2,0,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
  19. ,2,2,2,0,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
  20. ,2,2,2,0,2,0,2,0,2,2,0,2,2,2,0,0,0,2,2,2,0,0,2,0,2,2,0,0,0,2,2,2
  21. ,2,2,2,0,2,0,0,2,0,0,2,0,2,0,2,2,2,0,2,0,2,2,0,0,2,0,2,2,2,0,2,2
  22. ,2,2,2,0,2,0,2,2,0,2,2,0,2,2,2,2,2,0,2,0,2,2,2,0,2,0,2,2,2,0,2,2
  23. ,2,2,2,0,2,0,2,2,0,2,2,0,2,2,0,0,0,0,2,0,2,2,2,0,2,0,0,0,0,0,2,2
  24. ,2,2,2,0,2,0,2,2,0,2,2,0,2,0,2,2,2,0,2,0,2,2,2,0,2,0,2,2,2,2,2,2
  25. ,2,2,2,0,2,0,2,2,0,2,2,0,2,0,2,2,2,0,2,0,2,2,0,0,2,0,2,2,2,0,2,2
  26. ,2,2,2,0,2,0,2,2,0,2,2,0,2,2,0,0,0,0,2,2,0,0,2,0,2,2,0,0,0,2,2,2
  27. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,2,2,2,2,2,2,2,2
  28. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,2,2,2,0,2,2,2,2,2,2,2,2
  29. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,2,2,2,2,2,2,2,2,2
  30. ,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,2
  31. ,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,2
  32. ,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1
  33. ,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1
  34. ,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1
  35. ,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  36. ,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  37. ,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  38. ,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  39. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  40. )
  41.  
  42. img2 = IMAGE[0="0 0 0",1="0 255 0",2="BGCOLOR",3="255 0 0"]
  43. (32,32
  44. ,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,3,3,2
  45. ,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,3,3,2,2
  46. ,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,3,3,2,2,2
  47. ,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,3,3,2,2,2,2
  48. ,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,3,3,2,2,2,2,2
  49. ,2,2,2,2,2,2,2,2,2,2,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2
  50. ,2,2,2,2,2,2,2,2,2,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2
  51. ,2,2,2,2,2,2,2,2,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2
  52. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  53. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  54. ,3,3,3,0,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  55. ,3,3,3,0,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  56. ,3,3,3,0,3,0,3,0,3,3,0,3,3,3,1,1,0,3,3,3,0,0,3,0,3,3,0,0,0,3,3,3
  57. ,3,3,3,0,3,0,0,3,0,0,3,0,3,0,1,1,3,0,3,0,3,3,0,0,3,0,3,3,3,0,3,3
  58. ,3,3,3,0,3,0,3,3,0,3,3,0,3,3,1,1,3,0,3,0,3,3,3,0,3,0,3,3,3,0,3,3
  59. ,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
  60. ,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
  61. ,3,3,3,0,3,0,3,3,0,3,3,0,3,0,1,1,3,0,3,0,3,3,0,0,3,0,3,3,3,0,3,3
  62. ,3,3,3,0,3,0,3,3,0,3,3,0,3,3,1,1,0,0,3,3,0,0,3,0,3,3,0,0,0,3,3,3
  63. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3
  64. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,0,3,3,3,0,3,3,3,3,3,3,3,3
  65. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,0,0,0,3,3,3,3,3,3,3,3,3
  66. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  67. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  68. ,2,2,2,2,2,2,2,3,3,3,3,3,3,3,1,1,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2
  69. ,2,2,2,2,2,2,3,3,3,3,3,3,3,3,1,1,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2
  70. ,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
  71. ,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
  72. ,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
  73. ,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
  74. ,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
  75. ,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
  76. )
  77.  
  78. mnu = MENU
  79. (
  80.  SUBMENU("IupSubMenu 1",
  81.    MENU
  82.    (
  83.      ITEM[VALUE=ON]("IupItem 1 Checked",myaction),
  84.      SEPARATOR(),
  85.      ITEM[ACTIVE="NO"]("IupItem 2 Disabled",myaction)
  86.    )
  87.  ),
  88.  ITEM("IupItem 3",myaction),
  89.  ITEM("IupItem 4",myaction)
  90. )
  91.  
  92. dlg = DIALOG[TITLE="IupDialog Title",MENU="mnu"]
  93. (
  94.  VBOX[GAP="5",ALIGNMENT="ARIGHT",MARGIN="5x5"]
  95.  (
  96.    HBOX
  97.    (
  98.      FRAME[TITLE="IupButton"]
  99.      (
  100.        VBOX
  101.        (
  102.          BUTTON("Button Text",myaction),
  103.          BUTTON[IMAGE=img1]("",myaction),
  104.          BUTTON[IMAGE=img1,IMPRESS=img2]("",myaction)
  105.        )
  106.      ),
  107.      FRAME[TITLE="IupLabel"]
  108.      (
  109.        VBOX
  110.        (
  111.          LABEL("Label Text"),
  112.          LABEL[SEPARATOR=HORIZONTAL](""),
  113.          LABEL[IMAGE=img1]("")
  114.        )
  115.      ),
  116.      FRAME[TITLE="IupToggle"]
  117.      (
  118.        VBOX
  119.        (
  120.          TOGGLE[VALUE="ON"]("Toggle Text",myaction),
  121.          TOGGLE[IMAGE=img1,IMPRESS=img2]("",myaction),
  122.          FRAME[TITLE="IupRadio"]
  123.          (
  124.            RADIO
  125.            (
  126.              VBOX
  127.              (
  128.                TOGGLE("Toggle Text",myaction),
  129.                TOGGLE("Toggle Text",myaction)
  130.              )
  131.            )
  132.          )
  133.        )
  134.      ),
  135.      FRAME[TITLE="IupText/IupMultiline"]
  136.      (
  137.        VBOX
  138.        (
  139.          TEXT[SIZE="80x",VALUE="IupText Text"](myaction),
  140.          MULTILINE[SIZE="80x60",EXPAND="YES",VALUE="IupMultiline Text\nSecond Line\nThird Line"](myaction)
  141.        )
  142.      ),
  143.      FRAME[TITLE="IupList"]
  144.      (
  145.        VBOX
  146.        (
  147.          LIST[EXPAND="YES",VALUE="1",1="Item 1 Text",2="Item 2 Text",3="Item 3 Text"](myaction),
  148.          LIST[DROPDOWN="YES",EXPAND="YES",VALUE="2",1="Item 1 Text",2="Item 2 Text",3="Item 3 Text"](myaction),
  149.          LIST[EDITBOX="YES",EXPAND="YES",VALUE="3",1="Item 1 Text",2="Item 2 Text",3="Item 3 Text"](myaction)
  150.        )
  151.      )
  152.    ),
  153.    CANVAS[BGCOLOR="128 255 0"](myaction)
  154.  )
  155. )
  156. """
  157.  
  158. Iup::Open()
  159. Iup::LoadBuffer(sample_led)
  160. Iup::Show(Iup::GetHandle("dlg"))
  161. Iup::MLoop()
  162. IUP::Close()
  163.  


.
Title: Re: Question about IUP
Post by: Arnold on July 07, 2015, 03:02:20 AM
Hi John,

it seems that Scriptbasic can also handle IUP in Linux. This is of course a very nice feature. Is there a downloadable version of Scriptbasic for Windows too?

I do not know if this is the case in Scriptbasic but with OxygenBasic I have to take care for the case that there is an error in the LED file or in the string of the LED specification. Otherwise IupMainLoop will prevent gxo2 or the application to exit and release memory. I can do this in the main sub with using a simple return in case of an error. If I use IupLoad / IupLoadBuffer in a separate routine I use terminate() to force the exit of the program. (I did not find another way). When loading a faulty LED file an error message shows where the error occured in the LED file, loading the string only shows an error message with the LED file. For this reason it should be better to construct the dialogs in a separate LED file.

This would be jfdemo1_led.o2bas using LED:

Code: OxygenBasic
  1. $ filename "jfdemo1_led.exe"
  2. 'include "$/inc/RTL32.inc"
  3.  
  4. extern lib "IUP/iup.dll" cdecl
  5. includepath "IUP/"
  6. include "iup.h"
  7.  
  8. end extern  
  9.  
  10. extern cdecl
  11.  
  12. typedef sys Ihandle
  13.  
  14.  
  15. 'Exit Button Callback
  16. function quit_cb() as sys
  17.   function = %IUP_CLOSE
  18. end function
  19.  
  20.  
  21. sub Load_LED_Dialog()
  22.   string err = NULL
  23.  
  24.   err = IupLoad("jfdemo1.led")
  25.   if len(err) then
  26.     IupMessage("LED error", err)
  27.     terminate()
  28.     end
  29.   end if
  30.  
  31.     'SETUP CALLBACK FOR EXIT BUTTON
  32.  IupSetCallback(IupGetHandle("btnExit"), "ACTION", @quit_cb)
  33.  
  34.   IupShow(IupGetHandle("win"))
  35.  
  36.   IupSetFocus(IupGetHandle("btnFetch"))
  37.    
  38. end sub
  39.  
  40.  
  41. sub main()
  42.  
  43.    IupOpen(0,0)
  44.    Load_LED_Dialog()
  45.    IupMainLoop()  
  46.    IupClose()
  47.  
  48. end sub
  49.  
  50. main()
  51.  

And this would be the LED specification:

Code: [Select]
#jfdemo1H Example in LED

servercombo = LIST [DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1] (NULL)
btnFetch = BUTTON [SIZE = 50x] ("Fetch",NULL)
btnAbout = BUTTON [SIZE = 50x] ("About",NULL)
btnClear = BUTTON [SIZE = 50x] ("Clear",NULL)
btnExit = BUTTON [SIZE = 50x] ("E&xit", quit_cb)
serverList = LIST [EXPAND=YES, VISIBLELINES=1] (NULL)
textbox = TEXT [MULTILINE=YES, EXPAND=YES] (NULL)
lable = LABEL [SIZE=x12] ("Enter Word to Search For:")
entry = TEXT [EXPAND=HORIZONTAL] (NULL)
btnSearch = BUTTON [SIZE=50x] ("Search", NULL)
chkAll = TOGGLE [VALUE=ON, SIZE=x12] ("ALL", NULL)
chkUTF = TOGGLE [SIZE=x12] ("UTF-8", NULL)
 

win = DIALOG [TITLE=Thesaurus, SIZE=500x300]
(
VBOX [MARGIN=10x10]
  (
   HBOX [GAP=10]
   ( FRAME [TITLE=Servers, EXPAND=YES]
     ( HBOX [GAP=5] ( servercombo, btnFetch ) ) ,
          FRAME [TITLE=Controls]
          ( HBOX [MARGIN=6x6, GAP=5] ( btnAbout, btnClear, btnExit ) )
   ) ,
 
   FRAME [TITLE=Dictionaries]
   ( serverList ) ,
 
   FRAME [TITLE=Translation]
   ( textbox) ,
 
   HBOX [GAP=10] ( lable, entry, btnSearch, chkAll, chkUTF )
  )

)


I am not sure if I could represent the vertical / horizontal flow of VBOX / HBOX a little bit better? Putting everything of HBOX in one line could be confusing at some time too.

Roland

.
Title: Re: Question about IUP
Post by: JRS on July 07, 2015, 03:10:59 AM
Quote
it seems that Scriptbasic can also handle IUP in Linux. This is of course a very nice feature. Is there a downloadable version of Scriptbasic for Windows too?

You have two choices under Windows with Script BASIC and IUP. You can use my cross platform (32/64 bit) IUP extension module or use Charles's (32 bit) DLLC extension module which also lets you run IUP in multi-threaded mode. (IUP is not by default thread safe)

Here is the Script BASIC Windows 64 bit version of the dictionary example.

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

Code: Script BASIC
  1. IMPORT iup.bas
  2.  
  3. servers[0]="dict.org"
  4. servers[1]="dict1.us.dict.org"
  5. servers[2]="all.dict.org"
  6.  
  7. about="""This is a Demo
  8. of the IUP GUI Binding
  9. for Scriptbasic"""
  10.  
  11. ' Initialize IUP
  12. Iup::Open()
  13.  
  14. ' Create main window
  15.  
  16. win = Iup::Create("dialog")
  17.   Iup::SetAttributes(win, "TITLE=\"ScriptBasic IUP Online Dictionary\", SIZE=500x300")
  18.   Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))
  19.  
  20. ' Create container to house ALL GUI objects
  21.  
  22. vbox = Iup::Create("vbox")
  23.   Iup::SetAttributes(vbox, "MARGIN=10x10")
  24.  
  25. ' Create server panel
  26.  
  27. topBox = Iup::Create("hbox")
  28.   Iup::SetAttributes(topBox, "GAP=10")
  29.   Iup::Append(vbox, topBox)
  30. serverFrame = Iup::Create("frame")
  31.   Iup::SetAttributes(serverFrame, "TITLE=Servers, EXPAND=YES")
  32.   Iup::Append(topBox, serverFrame)
  33. serverBox = Iup::Create("hbox")
  34.   Iup::SetAttributes(serverBox, "GAP=5")
  35.   Iup::Append(serverFrame, serverBox)
  36. serverCombo = Iup::Create("list")
  37.   Iup::SetAttributes(serverCombo, "DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1")
  38.   Iup::Append(serverBox, serverCombo)
  39.   Iup::SetCallback(serverCombo, "ACTION", ADDRESS(serverCombo_selected()))
  40. btnFetch = Iup::Create("button")
  41.   Iup::SetAttributes(btnFetch, "TITLE=Fetch, SIZE = 50x")
  42.   Iup::Append(serverBox, btnFetch)
  43.   Iup::SetCallback(btnFetch, "ACTION", ADDRESS(btnFetch_clicked()))
  44.  
  45. ' Create control panel
  46.  
  47. controlFrame = Iup::Create("frame")
  48.   Iup::SetAttributes(controlFrame, "TITLE=Controls")
  49.   Iup::Append(topBox, controlFrame)
  50. controlBox = Iup::Create("hbox")
  51.   Iup::SetAttributes(controlBox, "GAP=5")
  52.   Iup::Append(controlFrame, controlBox)
  53. btnAbout = Iup::Create("button")
  54.   Iup::SetAttributes(btnAbout, "TITLE=About, SIZE = 50x")
  55.   Iup::Append(controlBox, btnAbout)
  56.   Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))
  57. btnClear = Iup::Create("button")
  58.   Iup::SetAttributes(btnClear, "TITLE=Clear, SIZE = 50x")
  59.   Iup::Append(controlBox, btnClear)
  60.   Iup::SetCallback(btnClear, "ACTION", ADDRESS(btnClear_clicked()))
  61. btnExit = Iup::Create("button")
  62.   Iup::SetAttributes(btnExit, "TITLE=Exit, SIZE = 50x")
  63.   Iup::Append(controlBox, btnExit)
  64.   Iup::SetCallback(btnExit,"ACTION",ADDRESS(Win_exit()))
  65.  
  66. ' Create dictionary panel
  67.  
  68. dictFrame = Iup::Create("frame")
  69.   Iup::SetAttributes(dictFrame, "TITLE=Dictionaries")
  70.   Iup::Append(vbox, dictFrame)
  71. serverList = Iup::Create("list")
  72.   Iup::SetAttributes(serverList, "EXPAND=YES, VISIBLELINES=1")
  73.   Iup::Append(dictFrame, serverList)
  74.   Iup::SetCallback(serverList, "ACTION", ADDRESS(serverList_selected()))
  75.  
  76. ' Create text part
  77.  
  78. transFrame = IUP::Create("frame")
  79.   Iup::SetAttributes(transFrame, "TITLE=Translation")
  80.   Iup::Append(vbox, transFrame)
  81. text = Iup::Create("text")
  82.   Iup::SetAttributes(text, "MULTILINE=YES, EXPAND=YES")
  83.   Iup::Append(transFrame, text)
  84.  
  85. ' Create entry and search button
  86.  
  87. bottomBox = Iup::Create("hbox")
  88.   Iup::SetAttributes(bottomBox, "GAP=10")
  89.   Iup::Append(vbox, bottomBox)
  90. label = Iup::Create("label")
  91.   Iup::SetAttributes(label, "TITLE=\"Enter Word to Search For:\", SIZE=x12")
  92.   Iup::Append(bottomBox, label)
  93. entry = Iup::Create("text")
  94.   Iup::SetAttributes(entry, "EXPAND=HORIZONTAL")
  95.   Iup::Append(bottomBox, entry)
  96. btnSearch = Iup::Create("button")
  97.   Iup::SetAttributes(btnSearch,"TITLE=Search, SIZE=50x")
  98.   Iup::Append(bottomBox, btnSearch)
  99.   Iup::SetCallback(btnSearch, "ACTION", ADDRESS(btnSearch_clicked()))
  100. chkAll = Iup::Create("toggle")
  101.   Iup::SetAttributes(chkAll, "TITLE=ALL, SIZE=x12")
  102.   Iup::Append(bottomBox, chkAll)
  103. chkUTF = Iup::Create("toggle")
  104.   Iup::SetAttributes(chkUTF, "TITLE=UTF-8, SIZE=x12")
  105.   Iup::Append(bottomBox, chkUTF)
  106.  
  107. ' Add the main GUI container to the Window
  108.  
  109. Iup::Append(win, vbox)
  110.  
  111. ' Setup dialog defaults
  112.  
  113. Iup::Show(win)
  114. Iup::SetFocus(btnFetch)
  115. FOR i = 0 TO UBOUND(servers)
  116.   Iup::SetAttribute(serverCombo, "APPENDITEM", servers[i])
  117. NEXT
  118. Iup::SetAttribute(serverCombo, "VALUE", "1")
  119. Iup::Update(serverCombo)
  120. server_selection = servers[0]
  121.  
  122. ' Main processing loop
  123.  
  124. Iup::MainLoop()
  125. Iup::Close()
  126. END
  127.  
  128. ' Callback routines
  129.  
  130. SUB Win_exit
  131.   Iup::ExitLoop = TRUE
  132. END SUB
  133.  
  134. SUB btnAbout_clicked
  135.   Iup::Message("ABOUT", about)
  136. END SUB
  137.  
  138. SUB serverCombo_selected
  139.   server_selection = Iup::GetListText()
  140. END SUB
  141.  
  142. SUB serverList_selected
  143.   whichDictionary = Iup::GetListText()
  144. END SUB
  145.  
  146. SUB btnFetch_clicked
  147.   LOCAL dat, total, count
  148.   ON ERROR GOTO G_NetError
  149.   OPEN server_selection & ":2628" FOR SOCKET AS #1
  150.   PRINT#1,"SHOW DB\n"
  151.   LINE INPUT#1, dat
  152.   LINE INPUT#1, dat
  153.   count = 0
  154.   WHILE LEFT(dat, 1) <> "."
  155.     LINE INPUT#1, dat
  156.     IF LEFT(dat, 1) <> "." THEN total[count] = TRIM(dat)
  157.     count+=1
  158.   WEND
  159.   PRINT#1,"QUIT\n"
  160.   CLOSE(#1)
  161.   FOR cnt = 0 TO count - 2
  162.     Iup::SetAttribute(serverList, "APPENDITEM", total[cnt])
  163.   NEXT
  164.   Iup::SetAttribute(serverList, "VALUE", "1")
  165.   Iup::Update(serverCombo)
  166.   whichDictionary = total[0]
  167.   EXIT SUB
  168.  
  169.   G_NetError:
  170.   PRINT "Server ",server_selection," not available. (",ERROR,")\n"
  171. END SUB
  172.  
  173. SUB btnClear_clicked
  174.   Iup::ClearList(serverList)
  175.   Iup::SetAttribute(text, "VALUE", "")
  176.   Iup::SetAttribute(entry, "VALUE", "")
  177. END SUB
  178.  
  179. SUB btnSearch_clicked
  180.   LOCAL dict, dat, total, info
  181.   IUP::SetAttribute(text, "VALUE","Fetching....")
  182.   ON ERROR GOTO L_NetError
  183.   dict = LEFT(whichDictionary, INSTR(whichDictionary, " "))
  184.   OPEN server_selection & ":2628" FOR SOCKET AS 1
  185.   IF Iup::GetAttribute(chkAll, "VALUE") THEN
  186.     PRINT#1,"DEFINE * " & Iup::GetAttribute(entry,"VALUE") & "\n"
  187.   ELSE
  188.     PRINT#1,"DEFINE " & dict & " " & Iup::GetAttribute(entry,"VALUE") & "\n"
  189.   END IF
  190.   REPEAT
  191.     LINE INPUT#1, dat
  192.     IF LEFT(dat, 3) = "151" THEN
  193.       total$ &= "------------------------------\r\n"
  194.       total$ &= RIGHT(dat, LEN(dat) - LEN(Iup::GetAttribute(entry, "VALUE")) - LEN(dict))
  195.       total$ &= "------------------------------\r\n"
  196.       REPEAT
  197.         LINE INPUT#1, info
  198.         info = REPLACE(info, CHR(34), CHR(92) & CHR(34))
  199.         IF LEFT(info, 1) <> "." THEN total &= TRIM(info) & "\n"
  200.       UNTIL LEFT(info, 1) = "."
  201.       total &= "\n"
  202.     END IF
  203.   UNTIL LEFT(dat, 3) = "250" OR VAL(LEFT(dat, 3)) > 499
  204.   PRINT#1,"QUIT\n"
  205.   CLOSE(#1)
  206.   IF LEFT(dat, 3) = "552" THEN
  207.     total = "No match found."
  208.   ELSE IF LEFT(dat, 3) = "501" THEN
  209.     total = "Select a dictionary first!"
  210.   ELSE IF LEFT(dat, 3) = "550" THEN
  211.     total = "Invalid database!"
  212.   END IF
  213.   Iup::SetAttribute(text, "VALUE", total)
  214. EXIT SUB
  215.  
  216. L_NetError:
  217.   dat[0] = "Could not lookup word! (" & ERROR & ")"
  218.   Iup::SetAttribute(text, "VALUE", dat)
  219. END SUB
  220.  
Title: Re: Question about IUP
Post by: Charles Pegge on July 07, 2015, 04:09:35 AM
Thanks Roland,

I've merged your material into projectsB/IUP

An alternative way of handling a LED error:

Code: OxygenBasic
  1. $ filename "sample_w_led.exe"
  2. 'include "$/inc/RTL32.inc"
  3.  
  4. extern lib "IUP/iup.dll" cdecl
  5. includepath "IUP/"
  6. include "iup.h"
  7.  
  8. end extern  
  9.  
  10. extern cdecl
  11.  
  12. typedef sys Ihandle
  13.  
  14.  
  15. includepath ""
  16. include "sample.inc"
  17.  
  18. function Load_LED_Dialog() as sys
  19.   string err = NULL
  20.  
  21.   /* Initialization of IUP and its controls */
  22.  
  23.   err = IupLoadBuffer(sample_led)
  24.   if len(err) then
  25.     IupMessage("LED error", err)
  26.     return 0
  27.   end if
  28.    
  29.   IupShow(IupGetHandle("dlg"))
  30.   return 1
  31.    
  32. end function
  33.  
  34.  
  35. sub main()
  36.  
  37.    IupOpen(0,0)
  38.    if Load_LED_Dialog() then
  39.      IupMainLoop()
  40.    end if
  41.    IupClose()
  42.  
  43. end sub
  44.  
  45. main()
  46.  
Title: Re: Question about IUP
Post by: JRS on July 07, 2015, 05:00:05 AM
FYI I rarely add error trapping support to the examples I post. I test what I post so what's the point?

Quote from: Antonio Scuri
Hi All,

  We just released IUP version 3.15.

  We would like to highlight some of the new features:

- New: "iup_class_cbs.hpp" header with macros to help creation of callbacks as methods in C++.
- New: global hot key (Alt+Ctrl+Shft+L) to show the current dialog layout in a IupLayoutDialog dialog.
- New: Tutorial section in the documentation. It is still under construction but already has several topics completed.
- New: IupFlatButton control that mimics a IupButton but does not have native system decorations.
- New: IupConfig support in Lua.

  You can find the complete list of changes and files for download at:

http://www.tecgraf.puc-rio.br/iup/
and
http://iup.sourceforge.net/

Best Regards,
Antonio Scuri
Title: Re: Question about IUP
Post by: Mike Lobanovsky on July 07, 2015, 06:01:07 AM
The point is to know *how* to do it efficiently just in case. ;)
Title: Re: Question about IUP
Post by: JRS on July 07, 2015, 06:02:46 AM
I'm posting examples. I get paid for writing production code.
Title: Re: Question about IUP
Post by: Charles Pegge on July 07, 2015, 07:41:36 AM
Hi John,

You should be fast asleep. Are you nocturnal? :)
Title: Re: Question about IUP
Post by: Mike Lobanovsky on July 07, 2015, 09:13:01 AM
Senile insomnia. ;)

Diagnosis not confirmed. :)
Title: Re: Question about IUP
Post by: JRS on July 07, 2015, 11:24:55 AM
Quote
You should be fast asleep. Are you nocturnal?

I have a client in London that I try to catch some of their day.

Title: Re: Question about IUP
Post by: JRS on December 16, 2015, 09:34:31 PM
Roland,

I got a chance to play with IUP LED files with Swift and I really like the concept and ease of use. Couple that with the IupDialogLayout() function and GUI is a walk in the park.

John
Title: Re: Question about IUP
Post by: Arnold on December 17, 2015, 01:11:56 AM
Hi John,

I also think that using LED and IupDialogLayout() could be very useful for creating applications. After finishing the BCXgui project I will restart the Iup-Oxygen project again (if nobody else does) using Iup.dll and in particular LED and the Iup header files. I am not quite sure how to name the topic then as IUP's version is still changing (in the moment version 3.17) and it does not make sense to start a new section for each update of IUP.

Roland
Title: Re: Question about IUP
Post by: jcfuller on December 17, 2015, 08:58:25 AM
Roland,
  Take a look at reply #4 for another iup approach.

http://www.bcxbasic.com/smf/index.php?topic=922.0

James
Title: Re: Question about IUP
Post by: JRS on December 17, 2015, 11:03:57 AM
Great to see you coding with IUP James!

Here is my IUP LED example in Swift showing how to tie callbacks to the LED definition.

http://www.allbasic.info/forum/index.php?topic=428.msg4598#msg4598

Title: Re: Question about IUP
Post by: Arnold on December 18, 2015, 01:27:36 AM
Hi James,

I know about the two powerful functions Create and AddChild which alone could be used to create almost any control in Iup. But using LED is much easier and more comfortable. It is easy to understand - reading the LED specification and comparing some LED templates should be sufficient. (See John's link above for the LED specification).

The LED file for jfdemo1.o2bas is located here:


http://www.oxygenbasic.org/forum/index.php?topic=1316.msg14321#msg14321
 (http://www.oxygenbasic.org/forum/index.php?topic=1316.msg14321#msg14321)

In the latest distribution of OxygenBasic Charles included two examples in folder projectsB\IUP which use led files for creating the controls. (tabs.o2bas and zbox.o2bas). Using Iupload when using led in a separate file or IupLoadBuffer when using LED in a string is sufficient to create the controls on the fly. It demonstrates the power of IUP but also the power of Oxygenbasic. (using header files directly is a powerful feature). As Oxygenbasic can not handle some containers of Iup directly with the Iup header files, create and addchild strategy is used here too via IupCreate, IupAppend and IupRefresh.

The interesting part is that LED files can be used unchanged in any language which can access functions of a foreign dll. And as BCX / BC9 translate to C, there should be no big problem to port these two examples. But I have not yet tried this.


Roland


.
Title: Re: Question about IUP
Post by: JRS on December 18, 2015, 08:02:30 PM
Roland,

With the Script BASIC version of IUP LED, I'm using a SQLite database to maintain screen definitions. I'm working on a client for a web service. Tons of fun!

John
Title: Re: Question about IUP
Post by: jcfuller on December 20, 2015, 11:13:20 AM
Roland,
  Thanks for all the LED info.
I agree, this is probably the best way to implement especially because I program in several programming languages.

James
Title: Re: Question about IUP
Post by: JRS on December 20, 2015, 01:50:42 PM
The biggest issue this solves is not having to use dynamic Variadic functions to obtain the intended ease of use of the GUI toolkit. I still haven't found any other GUI library that even comes close.



Title: Re: Question about IUP
Post by: jcfuller on December 22, 2015, 12:04:19 PM
Roland,
  This was a bit tricky ;)
James

Code: [Select]
# ==============================================================================
#cardfile
# ==============================================================================
btn_prior = BUTTON[SIZE = 50x15]("<< Prior",NULL)
btn_next =  BUTTON[SIZE = 50x15]("Next >>",NULL)
btn_find =   BUTTON[SIZE = 50x15]("Find",NULL)
btn_add  =   BUTTON[SIZE = 50x15]("Add",NULL)
btn_update =  BUTTON[SIZE = 50x15]("Update",NULL)
btn_delete =  BUTTON[SIZE = 50x15]("Delete",NULL)
btn_print =  BUTTON[SIZE = 50x15]("Print",NULL)
btn_cancel = BUTTON[SIZE = 50x15]("Dismiss",NULL)
# ==============================================================================
id_index = LABEL[]("0 / 0")
entry_company = TEXT[EXPAND = HORIZONTAL](NULL)
entry_last = TEXT[EXPAND = HORIZONTAL](NULL)
entry_first = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add1 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add2 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add3 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_city = TEXT[EXPAND = HORIZONTAL](NULL)
entry_state = TEXT[SIZE = 120x](NULL)
entry_zip = TEXT[SIZE = 80x](NULL)
cbo_country = LIST[DROPDOWN=YES, SIZE=100x,VALUE=1](NULL)
entry_phone = TEXT[SIZE=70x](NULL)
entry_fax = TEXT[SIZE=70x](NULL)
entry_email = TEXT[EXPAND = HORIZONTAL](NULL)
entry_www = TEXT[EXPAND = HORIZONTAL](NULL)
entry_comments = TEXT[MULTILINE=YES, EXPAND=YES](NULL)
# ==============================================================================
cardfile = DIALOG[ USERSIZE = 750x563, TITLE = "Card File", RASTERSIZE = 750x563]
(
    VBOX[MARGIN = 5x5]
    (
        HBOX[GAP = 5]
        (
            FILL(),
            LABEL[TITLE = " Record No."](""),id_index
        ),
        FRAME[TITLE = Company]
        (
             entry_company
        ),
        HBOX[GAP = 5]
        (
            FRAME[TITLE = "Last Name"]
            (
                entry_last
            ),
            FRAME[TITLE = "First Name"]
            (
                entry_first
            )
        ),
        FRAME[TITLE = "Address"]
        (
            VBOX[GAP = 5]
            (
                entry_add1,
                entry_add2,
                entry_add3
            )
        ),
        HBOX[GAP = 5]
        (
            FRAME[TITLE = "City"]
            (
                entry_city
            ),
            FRAME[ TITLE = "State / Province"]
            (
                 entry_state
            ),
            FRAME[TITLE = "Zip or Postal Code"]
            (
                entry_zip
            ),
            FRAME[TITLE = "Country"]
            (
                 cbo_country
            )
        ),
        HBOX[GAP = 5]
        (
            FRAME[TITLE = "Phone"]
            (
                entry_phone
            ),
            FRAME[TITLE = "Fax"]
            (
                entry_fax
            ),
            FRAME[TITLE = "Email"]
            (
                entry_email
            ),
            FRAME[TITLE = "www"]
            (
                entry_www
            )
        ),
        FRAME[TITLE = "Comments"]
        (
            TEXT[EXPAND = YES,MULTILINE = YES,NAME = entry_comments](do_nothing)
        ),
        HBOX[GAP = 10]
        (
            FILL(),
            btn_prior,btn_next,btn_find,btn_add,btn_update,btn_delete,btn_print,btn_cancel,
            FILL()
        )
    )
)


Title: Re: Question about IUP
Post by: JRS on December 22, 2015, 02:34:53 PM
Here is what it looks like in Script BASIC. (Ubuntu 14.04 LTS 64 bit)

Comments:
* I think less FRAME controls would be more appealing.
* I had to make the dialog larger to see all the controls. I would let the containers determine the size of the dialog.


Code: Script BASIC
  1. ' James Fuller IUP LED Example
  2.  
  3. IMPORT iup.bas
  4.  
  5. LED = """
  6. # ==============================================================================
  7. #cardfile
  8. # ==============================================================================
  9. btn_prior = BUTTON[SIZE = 50x15]("<< Prior",NULL)
  10. btn_next =  BUTTON[SIZE = 50x15]("Next >>",NULL)
  11. btn_find =   BUTTON[SIZE = 50x15]("Find",NULL)
  12. btn_add  =   BUTTON[SIZE = 50x15]("Add",NULL)
  13. btn_update =  BUTTON[SIZE = 50x15]("Update",NULL)
  14. btn_delete =  BUTTON[SIZE = 50x15]("Delete",NULL)
  15. btn_print =  BUTTON[SIZE = 50x15]("Print",NULL)
  16. btn_cancel = BUTTON[SIZE = 50x15]("Dismiss",NULL)
  17. # ==============================================================================
  18. id_index = LABEL[]("0 / 0")
  19. entry_company = TEXT[EXPAND = HORIZONTAL](NULL)
  20. entry_last = TEXT[EXPAND = HORIZONTAL](NULL)
  21. entry_first = TEXT[EXPAND = HORIZONTAL](NULL)
  22. entry_add1 = TEXT[EXPAND = HORIZONTAL](NULL)
  23. entry_add2 = TEXT[EXPAND = HORIZONTAL](NULL)
  24. entry_add3 = TEXT[EXPAND = HORIZONTAL](NULL)
  25. entry_city = TEXT[EXPAND = HORIZONTAL](NULL)
  26. entry_state = TEXT[SIZE = 120x](NULL)
  27. entry_zip = TEXT[SIZE = 80x](NULL)
  28. cbo_country = LIST[DROPDOWN=YES, SIZE=100x,VALUE=1](NULL)
  29. entry_phone = TEXT[SIZE=70x](NULL)
  30. entry_fax = TEXT[SIZE=70x](NULL)
  31. entry_email = TEXT[EXPAND = HORIZONTAL](NULL)
  32. entry_www = TEXT[EXPAND = HORIZONTAL](NULL)
  33. entry_comments = TEXT[MULTILINE=YES, EXPAND=YES](NULL)
  34. # ==============================================================================
  35. cardfile = DIALOG[ USERSIZE = 750x563, TITLE = "Card File", RASTERSIZE = 750x563]
  36. (
  37.    VBOX[MARGIN = 5x5]
  38.    (
  39.        HBOX[GAP = 5]
  40.        (
  41.            FILL(),
  42.            LABEL[TITLE = " Record No."](""),id_index
  43.        ),
  44.        FRAME[TITLE = Company]
  45.        (
  46.             entry_company
  47.        ),
  48.        HBOX[GAP = 5]
  49.        (
  50.            FRAME[TITLE = "Last Name"]
  51.            (
  52.                entry_last
  53.            ),
  54.            FRAME[TITLE = "First Name"]
  55.            (
  56.                entry_first
  57.            )
  58.        ),
  59.        FRAME[TITLE = "Address"]
  60.        (
  61.            VBOX[GAP = 5]
  62.            (
  63.                entry_add1,
  64.                entry_add2,
  65.                entry_add3
  66.            )
  67.        ),
  68.        HBOX[GAP = 5]
  69.        (
  70.            FRAME[TITLE = "City"]
  71.            (
  72.                entry_city
  73.            ),
  74.            FRAME[ TITLE = "State / Province"]
  75.            (
  76.                 entry_state
  77.            ),
  78.            FRAME[TITLE = "Zip or Postal Code"]
  79.            (
  80.                entry_zip
  81.            ),
  82.            FRAME[TITLE = "Country"]
  83.            (
  84.                 cbo_country
  85.            )
  86.        ),
  87.        HBOX[GAP = 5]
  88.        (
  89.            FRAME[TITLE = "Phone"]
  90.            (
  91.                entry_phone
  92.            ),
  93.            FRAME[TITLE = "Fax"]
  94.            (
  95.                entry_fax
  96.            ),
  97.            FRAME[TITLE = "Email"]
  98.            (
  99.                entry_email
  100.            ),
  101.            FRAME[TITLE = "www"]
  102.            (
  103.                entry_www
  104.            )
  105.        ),
  106.        FRAME[TITLE = "Comments"]
  107.        (
  108.            TEXT[EXPAND = YES,MULTILINE = YES,NAME = entry_comments](do_nothing)
  109.        ),
  110.        HBOX[GAP = 10]
  111.        (
  112.            FILL(),
  113.            btn_prior,btn_next,btn_find,btn_add,btn_update,btn_delete,btn_print,btn_cancel,
  114.            FILL()
  115.        )
  116.    )
  117. )
  118. """
  119. Iup::Open
  120. Iup::LoadBuffer LED
  121. Iup::Show(Iup::GetHandle("cardfile"))
  122. Iup::MLoop
  123. Iup::Close
  124.  

.
Title: Re: Question about IUP
Post by: Arnold on December 23, 2015, 01:54:27 AM
This would be the version in Oxygenbasic, including the LED in a string. The files are running in projectsB/IUP.

This is the inc file:

Code: [Select]
dim as string cardfile_led = quote

-cardfile-
# ==============================================================================
#cardfile
# ==============================================================================
btn_prior = BUTTON[SIZE = 50x15]("<< Prior", message_cb)
btn_next =  BUTTON[SIZE = 50x15]("Next >>",message_cb)
btn_find =   BUTTON[SIZE = 50x15]("Find",message_cb)
btn_add  =   BUTTON[SIZE = 50x15]("Add",message_cb)
btn_update =  BUTTON[SIZE = 50x15]("Update",message_cb)
btn_delete =  BUTTON[SIZE = 50x15]("Delete",message_cb)
btn_print =  BUTTON[SIZE = 50x15]("Print",message_cb)
btn_cancel = BUTTON[SIZE = 50x15]("Dismiss", cancel_cb)
# ==============================================================================
id_index = LABEL[]("0 / 0")
entry_company = TEXT[EXPAND = HORIZONTAL](NULL)
entry_last = TEXT[EXPAND = HORIZONTAL](NULL)
entry_first = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add1 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add2 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add3 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_city = TEXT[EXPAND = HORIZONTAL](NULL)
entry_state = TEXT[SIZE = 120x](NULL)
entry_zip = TEXT[SIZE = 80x](NULL)
cbo_country = LIST[DROPDOWN=YES, SIZE=100x,VALUE=1](NULL)
entry_phone = TEXT[SIZE=70x](NULL)
entry_fax = TEXT[SIZE=70x](NULL)
entry_email = TEXT[EXPAND = HORIZONTAL](NULL)
entry_www = TEXT[EXPAND = HORIZONTAL](NULL)
entry_comments = TEXT[MULTILINE=YES, EXPAND=YES](NULL)
# ==============================================================================
cardfile = DIALOG[ USERSIZE = 750x563, TITLE = "Card File", RASTERSIZE = 750x563]
(
    VBOX[MARGIN = 5x5]
    (
        HBOX[GAP = 5]
        (
            FILL(),
            LABEL[TITLE = " Record No."](""),id_index
        ),
        FRAME[TITLE = Company]
        (
             entry_company
        ),
        HBOX[GAP = 5]
        (
            FRAME[TITLE = "Last Name"]
            (
                entry_last
            ),
            FRAME[TITLE = "First Name"]
            (
                entry_first
            )
        ),
        FRAME[TITLE = "Address"]
        (
            VBOX[GAP = 5]
            (
                entry_add1,
                entry_add2,
                entry_add3
            )
        ),
        HBOX[GAP = 5]
        (
            FRAME[TITLE = "City"]
            (
                entry_city
            ),
            FRAME[ TITLE = "State / Province"]
            (
                 entry_state
            ),
            FRAME[TITLE = "Zip or Postal Code"]
            (
                entry_zip
            ),
            FRAME[TITLE = "Country"]
            (
                 cbo_country
            )
        ),
        HBOX[GAP = 5]
        (
            FRAME[TITLE = "Phone"]
            (
                entry_phone
            ),
            FRAME[TITLE = "Fax"]
            (
                entry_fax
            ),
            FRAME[TITLE = "Email"]
            (
                entry_email
            ),
            FRAME[TITLE = "www"]
            (
                entry_www
            )
        ),
        FRAME[TITLE = "Comments"]
        (
            TEXT[EXPAND = YES,MULTILINE = YES,NAME = entry_comments](do_nothing)
        ),
        HBOX[GAP = 10]
        (
            FILL(),
            btn_prior,btn_next,btn_find,btn_add,btn_update,btn_delete,btn_print,btn_cancel,
            FILL()
        )
    )
)
-cardfile-

The NULLs for the controls can be replaced with the name of the callback functions.

This would be  the code for the o2bas file:

Code: OxygenBasic
  1. $ filename "sample.exe"
  2. 'include "$/inc/RTL32.inc"
  3.  
  4. extern lib "IUP/iup.dll" cdecl
  5. includepath "IUP/"
  6. include "iup.h"
  7.  
  8. end extern  
  9.  
  10. extern cdecl
  11.  
  12. typedef sys Ihandle
  13.  
  14.  
  15. includepath ""
  16. include "cardfile.inc"
  17.  
  18.  
  19.  
  20. sub main()
  21.  
  22.    IupOpen(0,0)
  23.  
  24.    'load string
  25.   err = IupLoadBuffer(cardfile_led)  
  26.    if len(err) then
  27.      IupMessage("LED error", err)
  28.      return
  29.    end if
  30.  
  31.   '
  32.  ' Sets callbacks
  33.  '
  34.  IupSetFunction("cancel_cb", @cancel_cb)
  35.   IupSetFunction("message_cb", @message_cb)  
  36.    
  37.    '
  38.   'Shows dialog and starts iteration
  39.   '
  40.   IupShow(IupGetHandle("cardfile"))
  41.    IupMainLoop()
  42.  
  43.    IupDestroy(IupGetHandle("cardfile"))
  44.  
  45.    IupClose()
  46.  
  47. end sub
  48.  
  49. main()
  50.  
  51. '--------------------------------------
  52.  
  53. function cancel_cb(sys *self)
  54.   IupMessage("Started action", IupGetAttribute(self, "TITLE") & ": Bye-Bye")
  55.   return IUP_CLOSE
  56. end function
  57.  
  58. function message_cb(sys *self)
  59.   return IupMessage("Started action", IupGetAttribute(self, "TITLE"))
  60. end function
  61.  
  62.  


Of course this only serves as a template. There are certainly some more possibilities using IUP / LED with OxygenBasic.

Roland

.
Title: Re: Question about IUP
Post by: JRS on December 23, 2015, 10:50:23 AM
Here is James example on Windows 7 32 bit using Script BASIC. I handle callbacks a bit differently in Script BASIC.

Code: Script BASIC
  1. ' James Fuller IUP LED Example
  2.  
  3. LED = """
  4. # ==============================================================================
  5. #cardfile
  6. # ==============================================================================
  7. btn_prior = BUTTON[SIZE = 50x15]("<< Prior",NULL)
  8. btn_next =  BUTTON[SIZE = 50x15]("Next >>",NULL)
  9. btn_find =   BUTTON[SIZE = 50x15]("Find",NULL)
  10. btn_add  =   BUTTON[SIZE = 50x15]("Add",NULL)
  11. btn_update =  BUTTON[SIZE = 50x15]("Update",NULL)
  12. btn_delete =  BUTTON[SIZE = 50x15]("Delete",NULL)
  13. btn_print =  BUTTON[SIZE = 50x15]("Print",NULL)
  14. btn_cancel = BUTTON[SIZE = 50x15]("Dismiss",NULL)
  15. # ==============================================================================
  16. id_index = LABEL[]("0 / 0")
  17. entry_company = TEXT[EXPAND = HORIZONTAL](NULL)
  18. entry_last = TEXT[EXPAND = HORIZONTAL](NULL)
  19. entry_first = TEXT[EXPAND = HORIZONTAL](NULL)
  20. entry_add1 = TEXT[EXPAND = HORIZONTAL](NULL)
  21. entry_add2 = TEXT[EXPAND = HORIZONTAL](NULL)
  22. entry_add3 = TEXT[EXPAND = HORIZONTAL](NULL)
  23. entry_city = TEXT[EXPAND = HORIZONTAL](NULL)
  24. entry_state = TEXT[SIZE = 120x](NULL)
  25. entry_zip = TEXT[SIZE = 80x](NULL)
  26. cbo_country = LIST[DROPDOWN=YES, SIZE=100x,VALUE=1](NULL)
  27. entry_phone = TEXT[SIZE=70x](NULL)
  28. entry_fax = TEXT[SIZE=70x](NULL)
  29. entry_email = TEXT[EXPAND = HORIZONTAL](NULL)
  30. entry_www = TEXT[EXPAND = HORIZONTAL](NULL)
  31. entry_comments = TEXT[MULTILINE=YES, EXPAND=YES](NULL)
  32. # ==============================================================================
  33. cardfile = DIALOG[ USERSIZE = 750x563, TITLE = "Card File", RASTERSIZE = 750x563]
  34. (
  35.    VBOX[MARGIN = 5x5]
  36.    (
  37.        HBOX[GAP = 5]
  38.        (
  39.            FILL(),
  40.            LABEL[TITLE = " Record No."](""),id_index
  41.        ),
  42.        FRAME[TITLE = Company]
  43.        (
  44.             entry_company
  45.        ),
  46.        HBOX[GAP = 5]
  47.        (
  48.            FRAME[TITLE = "Last Name"]
  49.            (
  50.                entry_last
  51.            ),
  52.            FRAME[TITLE = "First Name"]
  53.            (
  54.                entry_first
  55.            )
  56.        ),
  57.        FRAME[TITLE = "Address"]
  58.        (
  59.            VBOX[GAP = 5]
  60.            (
  61.                entry_add1,
  62.                entry_add2,
  63.                entry_add3
  64.            )
  65.        ),
  66.        HBOX[GAP = 5]
  67.        (
  68.            FRAME[TITLE = "City"]
  69.            (
  70.                entry_city
  71.            ),
  72.            FRAME[ TITLE = "State / Province"]
  73.            (
  74.                 entry_state
  75.            ),
  76.            FRAME[TITLE = "Zip or Postal Code"]
  77.            (
  78.                entry_zip
  79.            ),
  80.            FRAME[TITLE = "Country"]
  81.            (
  82.                 cbo_country
  83.            )
  84.        ),
  85.        HBOX[GAP = 5]
  86.        (
  87.            FRAME[TITLE = "Phone"]
  88.            (
  89.                entry_phone
  90.            ),
  91.            FRAME[TITLE = "Fax"]
  92.            (
  93.                entry_fax
  94.            ),
  95.            FRAME[TITLE = "Email"]
  96.            (
  97.                entry_email
  98.            ),
  99.            FRAME[TITLE = "www"]
  100.            (
  101.                entry_www
  102.            )
  103.        ),
  104.        FRAME[TITLE = "Comments"]
  105.        (
  106.            TEXT[EXPAND = YES,MULTILINE = YES,NAME = entry_comments](do_nothing)
  107.        ),
  108.        HBOX[GAP = 10]
  109.        (
  110.            FILL(),
  111.            btn_prior,btn_next,btn_find,btn_add,btn_update,btn_delete,btn_print,btn_cancel,
  112.            FILL()
  113.        )
  114.    )
  115. )
  116. """
  117.  
  118. SUB Win_exit
  119.   Iup::ExitLoop = TRUE
  120. END SUB
  121.  
  122. IMPORT iup.bas
  123.  
  124. Iup::Open(0,0)
  125.  
  126. Iup::LoadBuffer(LED)
  127.  
  128. Iup::SetCallback(Iup::GetHandle("btn_cancel"), "ACTION", ADDRESS(Win_exit()))
  129.  
  130. Iup::Show(Iup::GetHandle("cardfile"))
  131.  
  132. Iup::MainLoop()
  133.  
  134. Iup::Close()
  135.  


.
Title: Re: Question about IUP
Post by: JRS on December 24, 2015, 01:18:07 PM
I added default IUP graphics to the buttons. I also let the containers determine overall dialog size. (linux version)

Code: Script BASIC
  1. ' James Fuller IUP LED Example
  2.  
  3. IMPORT iup.bas
  4.  
  5. LED = """
  6. # ==============================================================================
  7. #cardfile
  8. # ==============================================================================
  9. btn_prior = BUTTON[SIZE = 50x15, IMAGE=IUP_ArrowLeft]("",NULL)
  10. btn_next =  BUTTON[SIZE = 50x15, IMAGE=IUP_ArrowRight]("",NULL)
  11. btn_find =   BUTTON[SIZE = 50x15, IMAGE=IUP_EditFind]("",NULL)
  12. btn_add  =   BUTTON[SIZE = 50x15, IMAGE=IUP_FileSave]("",NULL)
  13. btn_update =  BUTTON[SIZE = 50x15, IMAGE=IUP_NavigateRefresh]("",NULL)
  14. btn_delete =  BUTTON[SIZE = 50x15, IMAGE=IUP_EditErase]("",NULL)
  15. btn_print =  BUTTON[SIZE = 50x15, IMAGE=IUP_Print]("",NULL)
  16. btn_cancel = BUTTON[SIZE = 50x15, IMAGE=IUP_ActionCancel]("",NULL)
  17. # ==============================================================================
  18. id_index = LABEL[]("0 / 0")
  19. entry_company = TEXT[EXPAND = HORIZONTAL](NULL)
  20. entry_last = TEXT[EXPAND = HORIZONTAL](NULL)
  21. entry_first = TEXT[EXPAND = HORIZONTAL](NULL)
  22. entry_add1 = TEXT[EXPAND = HORIZONTAL](NULL)
  23. entry_add2 = TEXT[EXPAND = HORIZONTAL](NULL)
  24. entry_add3 = TEXT[EXPAND = HORIZONTAL](NULL)
  25. entry_city = TEXT[EXPAND = HORIZONTAL](NULL)
  26. entry_state = TEXT[SIZE = 120x](NULL)
  27. entry_zip = TEXT[SIZE = 80x](NULL)
  28. cbo_country = LIST[DROPDOWN=YES, SIZE=100x,VALUE=1](NULL)
  29. entry_phone = TEXT[SIZE=70x](NULL)
  30. entry_fax = TEXT[SIZE=70x](NULL)
  31. entry_email = TEXT[EXPAND = HORIZONTAL](NULL)
  32. entry_www = TEXT[EXPAND = HORIZONTAL](NULL)
  33. entry_comments = TEXT[MULTILINE=YES, EXPAND=YES](NULL)
  34. # ==============================================================================
  35. cardfile = DIALOG[TITLE = "Card File"]
  36. (
  37.    VBOX[MARGIN = 5x5]
  38.    (
  39.        HBOX[GAP = 5]
  40.        (
  41.            FILL(),
  42.            LABEL[TITLE = " Record No."](""),id_index
  43.        ),
  44.        FRAME[TITLE = Company]
  45.        (
  46.             entry_company
  47.        ),
  48.        HBOX[GAP = 5]
  49.        (
  50.            FRAME[TITLE = "Last Name"]
  51.            (
  52.                entry_last
  53.            ),
  54.            FRAME[TITLE = "First Name"]
  55.            (
  56.                entry_first
  57.            )
  58.        ),
  59.        FRAME[TITLE = "Address"]
  60.        (
  61.            VBOX[GAP = 5]
  62.            (
  63.                entry_add1,
  64.                entry_add2,
  65.                entry_add3
  66.            )
  67.        ),
  68.        HBOX[GAP = 5]
  69.        (
  70.            FRAME[TITLE = "City"]
  71.            (
  72.                entry_city
  73.            ),
  74.            FRAME[ TITLE = "State / Province"]
  75.            (
  76.                 entry_state
  77.            ),
  78.            FRAME[TITLE = "Zip or Postal Code"]
  79.            (
  80.                entry_zip
  81.            ),
  82.            FRAME[TITLE = "Country"]
  83.            (
  84.                 cbo_country
  85.            )
  86.        ),
  87.        HBOX[GAP = 5]
  88.        (
  89.            FRAME[TITLE = "Phone"]
  90.            (
  91.                entry_phone
  92.            ),
  93.            FRAME[TITLE = "Fax"]
  94.            (
  95.                entry_fax
  96.            ),
  97.            FRAME[TITLE = "Email"]
  98.            (
  99.                entry_email
  100.            ),
  101.            FRAME[TITLE = "www"]
  102.            (
  103.                entry_www
  104.            )
  105.        ),
  106.        FRAME[TITLE = "Comments"]
  107.        (
  108.            TEXT[EXPAND = YES,MULTILINE = YES,NAME = entry_comments](do_nothing)
  109.        ),
  110.        HBOX[GAP = 10]
  111.        (
  112.            FILL(),
  113.            btn_prior,btn_next,btn_find,btn_add,btn_update,btn_delete,btn_print,btn_cancel,
  114.            FILL()
  115.        )
  116.    )
  117. )
  118. """
  119. Iup::Open
  120. Iup::ImageLibOpen
  121.  
  122. Iup::LoadBuffer LED
  123.  
  124. Iup::Show(Iup::GetHandle("cardfile"))
  125.  
  126. Iup::MLoop
  127.  
  128. Iup::Close
  129.  


.
Title: Re: Question about IUP
Post by: JRS on December 25, 2015, 01:23:39 PM
I added a call to set a common system font for both Windows and Linux version for the cross platform IUP examples I've posted. I'm using Helvetica font face which was the recommendation in the IUP docs for common ground (sizing) between platforms. I'm using 11 pt for Windows and 10 pt for Linux Gtk. If you plan to try this cross platform, your settings may be different based on your monitor and DPI on each platform. I don't even want to think how this is going to look on Windows 10.  :o

Code: [Select]
Iup::Open
Iup::ImageLibOpen
Iup::SetGlobal("DEFAULTFONT", "Helvetica, 10")
Iup::LoadBuffer LED

Iup::Show(Iup::GetHandle("cardfile"))

Iup::MainLoop

Iup::Close

.
Title: Re: Question about IUP
Post by: JRS on January 04, 2016, 09:14:06 PM
Hi Roland,

How are things going with your O2 IUP adventures? It looks like James is chipping away at it based on posts to the IUP mailing list. It would be interesting to hear where he is going with IUP.

Title: Re: Question about IUP
Post by: Arnold on January 06, 2016, 08:58:23 AM
Hi John,

I have not yet continued with IUP as I am still working on the Oxygen-BCX project which is still a fascinating matter. In the meantime I managed to work with accelerator keys, added the code for font and color dialog and at the moment I try to add memory based dialogs. Thanks to the help of Charles and Mike I advanced much more than I expected when I started this project. Three major controls and the code for sound must be added to the library, some bugs must be examined. Working a little bit at a snail's pace this will take some time. But then the library should be ready to pass the testing phase.

Roland
Title: Re: Question about IUP
Post by: JRS on January 06, 2016, 11:52:40 AM
Roland,

I don't understand why anyone would take a funky BASIC to C translator written in itself and cripple O2 BASIC emulating it. James has spent years chasing the BCX dream. IUP and O2 is the best path IMHO.

@James: Try using IupStoreAttribute() rather than IupSetAttribute() with your PBCC issues.

John
Title: Re: Question about IUP
Post by: Arnold on January 07, 2016, 01:09:13 AM
Hi John,

yes, IUP is a very powerful library. But with the already included examples in the Oxygen distribution and presented here it is already possible to do own researches.

BTW in the thread:

Exploring Iup Library version 3.14
 (http://www.oxygenbasic.org/forum/index.php?topic=1344.0)

I uploaded a zip file with Iup3.14 dlls and a zip file with lot of examples using an include file with wrapped Iup functions. These files seem not to be present any more. Are uploaded files deleted automatically after some time? The same happened to theForger Winapi examples which show many principles of WinApi programming using OxygenBasic.

The BCXgui library is not a translator of BCX to o2. It is a collection of selected BCX runtime functions for using Windows gui with OxygenBasic. If there would be a bcxgui.dll I would have used this. The advantage of using a runtime library written in O2 is that it can be modified and extended in the same language. I could have used different names for the functions or combined it with some other functionality but that would be cheating. (Some minimal modifications are necessary nevertheless).

Not all BCX functions are necessary as OxygenBasic has it's own powerful built-in functions set. And therefore I can run almost all BCX code with only minimal changes. The files work at least with 32 bit Windows Vista. Maybe this will be different with Windows 8.1 and Windows 10 but I am not yet to this point.

Roland

Title: Re: Question about IUP
Post by: Aurel on January 07, 2016, 05:07:44 AM
Quote
Are uploaded files deleted automatically after some time?
who ...what ..where ?
I doubt that some files are deleted automatically ,but maybe im wrong...
anyway ...
i don't like this Iup BUT only in one case
if i remeber there is a built in Iup - browser ?
and IF...what web layer use this web browser?
Title: Re: Question about IUP
Post by: Aurel on January 07, 2016, 05:36:44 AM
well...it looks that i need to translate this :
to oxygen...hmmm  ..maybe i will  ::)

Code: [Select]
/*
 * IupWebBrowser sample
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <iup.h>
#include <iupweb.h>


#ifndef WIN32
static int history_cb(Ihandle* ih)
{
  int i;
  char str[50];
  int back = IupGetInt(ih, "BACKCOUNT");
  int fwrd = IupGetInt(ih, "FORWARDCOUNT");

  printf("HISTORY ITEMS\n");
  for(i = -(back); i < 0; i++)
  {
    sprintf(str, "ITEMHISTORY%d", i);
    printf("Backward %02d: %s\n", i, IupGetAttribute(ih, str));
  }

  sprintf(str, "ITEMHISTORY%d", 0);
  printf("Current  %02d: %s\n", 0, IupGetAttribute(ih, str));

  for(i = 1; i <= fwrd; i++)
  {
    sprintf(str, "ITEMHISTORY%d", i);
    printf("Forward  %02d: %s\n", i, IupGetAttribute(ih, str));
  }

  return IUP_DEFAULT;
}
#endif

static int navigate_cb(Ihandle* self, char* url)
{
  printf("NAVIGATE_CB: %s\n", url);
  (void)self;
  if (strstr(url, "download")!=NULL)
    return IUP_IGNORE;
  return IUP_DEFAULT;
}
                   
static int error_cb(Ihandle* self, char* url)
{
  printf("ERROR_CB: %s\n", url);
  (void)self;
  return IUP_DEFAULT;
}

static int completed_cb(Ihandle* self, char* url)
{
  printf("COMPLETED_CB: %s\n", url);
  (void)self;
  return IUP_DEFAULT;
}

static int newwindow_cb(Ihandle* self, char* url)
{
  printf("NEWWINDOW_CB: %s\n", url);
  IupSetAttribute(self, "VALUE", url);
  return IUP_DEFAULT;
}

static int back_cb(Ihandle* self)
{
  Ihandle* web  = (Ihandle*)IupGetAttribute(self, "MY_WEB");
  IupSetAttribute(web, "BACKFORWARD", "-1");
//  printf("zoom=%s\n", IupGetAttribute(web, "ZOOM"));
  return IUP_DEFAULT;
}

static int forward_cb(Ihandle* self)
{
  Ihandle* web  = (Ihandle*)IupGetAttribute(self, "MY_WEB");
  IupSetAttribute(web, "BACKFORWARD", "1");
//  IupSetAttribute(web, "ZOOM", "200");
  return IUP_DEFAULT;
}

static int stop_cb(Ihandle* self)
{
  Ihandle* web  = (Ihandle*)IupGetAttribute(self, "MY_WEB");
  IupSetAttribute(web, "STOP", NULL);
  return IUP_DEFAULT;
}

static int reload_cb(Ihandle* self)
{
  Ihandle* web  = (Ihandle*)IupGetAttribute(self, "MY_WEB");
  IupSetAttribute(web, "RELOAD", NULL);

  //TEST:
//  printf("STATUS=%s\n", IupGetAttribute(web, "STATUS"));
  return IUP_DEFAULT;
}

static int load_cb(Ihandle* self)
{
  Ihandle* txt  = (Ihandle*)IupGetAttribute(self, "MY_TEXT");
  Ihandle* web  = (Ihandle*)IupGetAttribute(self, "MY_WEB");
  IupSetAttribute(web, "VALUE", IupGetAttribute(txt, "VALUE"));

  //TESTS:
//  IupSetAttribute(txt, "VALUE", IupGetAttribute(web, "VALUE"));
//  IupSetAttribute(web, "HTML", "<html><body><b>Hello</b>, World!</body></html>");
//  IupSetAttribute(web, "VALUE", "http://www.microsoft.com");

  return IUP_DEFAULT;
}

void WebBrowserTest(void)
{
  Ihandle *txt, *dlg, *web;
  Ihandle *btLoad, *btReload, *btBack, *btForward, *btStop;
#ifndef WIN32
  Ihandle *history;
#endif

  IupWebBrowserOpen();             

  // Creates an instance of the WebBrowser control
  web = IupWebBrowser();

  // Creates a dialog containing the control
  dlg = IupDialog(IupVbox(IupHbox(btBack = IupButton("Back", NULL),
                                  btForward = IupButton("Forward", NULL),
                                  txt = IupText(""),
                                  btLoad = IupButton("Load", NULL),
                                  btReload = IupButton("Reload", NULL),
                                  btStop = IupButton("Stop", NULL),
#ifndef WIN32
                                  history = IupButton("History", NULL),
#endif
                                  NULL),
                                  web, NULL));
  IupSetAttribute(dlg, "TITLE", "IupWebBrowser");
  IupSetAttribute(dlg, "MY_TEXT", (char*)txt);
  IupSetAttribute(dlg, "MY_WEB", (char*)web);
  IupSetAttribute(dlg, "RASTERSIZE", "800x600");
  IupSetAttribute(dlg, "MARGIN", "10x10");
  IupSetAttribute(dlg, "GAP", "10");

   //IupSetAttribute(web, "HTML", "<html><body><b>Hello</b>World!</body></html>");
//   IupSetAttribute(txt, "VALUE", "My HTML");
  IupSetAttribute(txt, "VALUE", "http://www.tecgraf.puc-rio.br/iup");
//  IupSetAttribute(txt, "VALUE", "file:///D:/tecgraf/iup/html/index.html");
  IupSetAttribute(web, "VALUE", IupGetAttribute(txt, "VALUE"));
  IupSetAttributeHandle(dlg, "DEFAULTENTER", btLoad);

  IupSetAttribute(txt, "EXPAND", "HORIZONTAL");
  IupSetCallback(btLoad, "ACTION", (Icallback)load_cb);
  IupSetCallback(btReload, "ACTION", (Icallback)reload_cb);
  IupSetCallback(btBack, "ACTION", (Icallback)back_cb);
  IupSetCallback(btForward, "ACTION", (Icallback)forward_cb);
  IupSetCallback(btStop, "ACTION", (Icallback)stop_cb);
#ifndef WIN32
  IupSetCallback(history, "ACTION", (Icallback)history_cb);
#endif

  IupSetCallback(web, "NEWWINDOW_CB", (Icallback)newwindow_cb);
  IupSetCallback(web, "NAVIGATE_CB", (Icallback)navigate_cb);
  IupSetCallback(web, "ERROR_CB", (Icallback)error_cb);
  IupSetCallback(web, "COMPLETED_CB", (Icallback)completed_cb);

  // Shows dialog
  IupShow(dlg);
}

int main(int argc, char* argv[])
{
  IupOpen(&argc, &argv);

  WebBrowserTest();

  IupMainLoop();

  IupClose();

  return EXIT_SUCCESS;
}
Title: Re: Question about IUP
Post by: JRS on January 07, 2016, 08:54:46 PM
Quote
Are uploaded files deleted automatically after some time?
who ...what ..where ?
I doubt that some files are deleted automatically ,but maybe im wrong...
anyway ...
i don't like this Iup BUT only in one case
if i remeber there is a built in Iup - browser ?
and IF...what web layer use this web browser?

IUP is a framework and uses the OS native API. The IUP driver is what is unique to each OS.