Oxygen Basic

Programming => Example Code => Topic started by: Arnold on August 26, 2016, 03:10:23 AM

Title: Working with IUP
Post by: Arnold on August 26, 2016, 03:10:23 AM
Hi Charles,

in the folder projectsB/IUP I splitted scanf1.o2bas and scanf2.o2bas into scanf1, scanf2, getparam1 and getparam2.o2bas. Perhaps you consider to use them. Some small modifications were necessary to run them correctly. They work the same way using version IUP 3.14 and IUP 3.191.

There is a problem with getparam1(2).o2bas though. They work correctly when using the buttons, but they still crash if I use Alt+F4 or System-X button. I am not sure if this is an expected behaviour or if there is something missing in the code?

Would the IupGetParam example work in another language e.g. Scriptbasic?

Roland



.
Title: Re: Working with IUP
Post by: Arnold on August 26, 2016, 03:13:47 AM
This is the code for testing IupGetParam in C. Unfortunately I do not know how to compile this code to run with a Iup.dll.

Could I get some help? I use msys and mingw. I would need the arguments to compile the code for using the exe file with a dynamic library.

Roland

Code: [Select]
/* IupGetParam: Example in C
   Shows a dialog with all the possible fields.
*/

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

#include <iup.h>
// #include <iupcontrols.h>

int param_action(Ihandle* dialog, int param_index, void* user_data)
{               
  switch(param_index)
  {
  case IUP_GETPARAM_BUTTON1:
    printf("Button1 (OK)\n");
    break;
  case IUP_GETPARAM_INIT:
    printf("Init\n");
    break;
  case IUP_GETPARAM_BUTTON2:
    printf("Button2 (Cancel)\n");
    break;
  case IUP_GETPARAM_BUTTON3:
    printf("Button3 (Help)\n");
    break;
  default:
    {
      Ihandle* param;
      char param_str[50];
      sprintf(param_str, "PARAM%d", param_index);
      param = (Ihandle*)IupGetAttribute(dialog, param_str);
      printf("%s = %s\n", param_str, IupGetAttribute(param, "VALUE"));
      break;
    }
  }
  return 1;
}

int main(int argc, char **argv)
{
  int pboolean = 1;
  int pinteger = 3456;
  float preal = 3.543f;
  int pinteger2 = 192;
  float preal2 = 0.5f;
  float pangle = 90;
  char pstring[100] = "string text";
  char pcolor[100] = "255 0 128";
  int plist = 2;
  char pstring2[200] = "second text\nsecond line";
  char pfile_name[500] = "test.jpg";
 
  IupOpen(&argc, &argv);
//  IupControlsOpen();   /* so we can show the IupDial, but can be tested without it */
//  IupSetLanguage("ENGLISH");

  if (!IupGetParam("Title", param_action, 0,
                   "Boolean: %b[No,Yes]{Boolean Tip}\n"
                   "Integer: %i{Integer Tip}\n"
                   "Real 1: %r{Real Tip}\n"
                   "Sep1 %t\n"
                   "Integer: %i[0,255]{Integer Tip 2}\n"
                   "Real 2: %r[-1.5,1.5]{Real Tip 2}\n"
                   "Sep2 %t\n"
                   "Angle: %a[0,360]{Angle Tip}\n"
                   "String: %s{String Tip}\n"
                   "List: %l|item1|item2|item3|{List Tip}\n"
                   "File: %f[OPEN|*.bmp;*.jpg|CURRENT|NO|NO]{File Tip}\n"
                   "Color: %c{Color Tip}\n"
                   "Sep3 %t\n"
                   "Multiline: %m{Multiline Tip}\n",
                   &pboolean, &pinteger, &preal, &pinteger2, &preal2, &pangle, pstring, &plist, pfile_name, pcolor, pstring2, NULL))
    return IUP_DEFAULT;
 
  IupMessagef("IupGetParam",
              "Boolean Value: %d\n"
              "Integer: %d\n"
              "Real 1: %g\n"
              "Integer: %d\n"
              "Real 2: %g\n"
              "Angle: %g\n"
              "String: %s\n"
              "List Index: %d\n"
              "FileName: %s\n"
              "Color: %s\n"
              "Multiline: %s",
              pboolean, pinteger, (double)preal, pinteger2, (double)preal2, (double)pangle, pstring, plist, pfile_name, pcolor, pstring2);

  IupClose();

  return EXIT_SUCCESS;

}
Title: Re: Working with IUP
Post by: JRS on August 26, 2016, 10:17:15 AM
gcc IupGetParam.c -liup -o IupGetParam.exe
Title: Re: Working with IUP
Post by: Charles Pegge on August 27, 2016, 12:34:55 AM
Hi Roland,

Does it work with 3.9.0.0 ?. This is the version of IUP.dll included with o2.

Your GetParam examples Alt-F4 correctly with my current o2.  I will be releasing it shortly.
Title: Re: Working with IUP
Post by: Arnold on August 27, 2016, 02:25:26 AM
Hi Charles,

with Iup.dll of the O2 distribution (properties/details: 3.9.0.0, sysinfo.o2bas: Version 3.14) getparam1(2).o2bas will close correctly (sigh of relief). I replaced iup.dll / iupgl.dll and the include files with version build 3.18 and closing the getparam examples will work correctly with this version too.

So something has changed with version Iup 3.19 / 3.191 which must be followed. Nevertheless Iup 3.19 seems to be a very powerful new release. Currently I am rebuilding my examples with this version only using the header files (which is simply a splendid feature) and this works quite nice until now.

As John has pointed me to the right direction I will try to compile the C code. But I assume I will get the same results.

Roland
Title: Re: Working with IUP
Post by: Arnold on August 28, 2016, 02:13:40 AM
Hello,

this was my approach to compile getparam.c to be used with IUP.dll:

I created the folders CTests, CTests\Iup3.191 and CTests\Iup3.191\IUP. From the IUP/mingw distribution version 3.191 I copied iup.dll, libiup.a and the include files into CTests\Iup3.191\IUP. Then I copied getparam.c into folder CTests\Iup3.191. In a dos window I used this command:

gcc GetParam.c -I./IUP/ -L./IUP -liup -o GetParam.exe

As I had not set a path to Iup.dll I had to move the exe file to the IUP folder. But this approach will help me to do more simple checks in the future.

And the results are as expected: if I run the exe file against Iup.dll of version 3.14 or 3.18 the app will close correctly using Alt-F4, System-x and Esc, using Iup.dll of version 3.19 or 3.191 the app will crash. I am still not sure if there is a fault in the 32-bit Iup.dll of 3.19/3.191 ? For the time being I will use Iup version 3.18 for my experiments.

Roland
Title: Re: Working with IUP
Post by: Arnold on August 28, 2016, 06:18:41 AM
Perhaps this might be of interest too: I also managed to compile with the Tiny C compiler tcc.exe version 0.9.26 (i386 Win32):

path=c:\tcc;%path%
tcc GetParam.c -I./IUP/ -L./IUP -liup -o GetParam.exe

The resulting size of the exe file is about 4K. 
Title: Re: Working with IUP
Post by: Arnold on August 29, 2016, 12:33:44 AM
Hi John,

your hint using the -l option was extremely helpful for me. I simply did not understand the meaning before.
I tried another test: I copied getparam.c into folder projectsB\IUP. Using a dos window in this folder I used the command (leaving out the / and ./):

gcc GetParam.c -IIUP -LIUP -liup -o GetParam.exe

This will also work with tcc. To my surprise I did not need a .def file or a libiup.a or something else which I thought would be necessary.
Hopefully I was not too lengthy. But this topic was completely news to me and the solution surprisingly easy (afterwards).

Roland
Title: Re: Working with IUP
Post by: JRS on August 29, 2016, 10:13:52 PM
Quote
your hint using the -l option was extremely helpful for me. I simply did not understand the meaning before.

Taking the time to place your libraries in the correct place makes the compile line less verbose.
Title: Re: Working with IUP
Post by: Arnold on August 30, 2016, 04:43:18 AM
Hello,

this is a small IupSbox example. IupSbox is a container which allows its child to be resized. If wished the button can be expanded only vertical (line 19). The color of the bar handler can be changed (line 25).

Roland

Code: OxygenBasic
  1. $ filename "sbox.exe"
  2.  
  3. 'include     "$/inc/RTL32.inc"
  4. 'include     "$/inc/console.inc"
  5.  
  6. includepath "iup/"      
  7. extern lib "IUP/iup.dll" cdecl
  8. include "iup.h"
  9.      
  10. extern cdecl      
  11.  
  12.  
  13. sub SboxTest()
  14.  
  15.   sys dlg, btn, box, lbl, ml, vbox, hbox
  16.  
  17.   btn = IupButton("Button", NULL)
  18.   'if only vertical expanding the button
  19.  'IupSetAttribute(btn, "EXPAND", "VERTICAL")
  20.  IupSetAttribute(btn, "EXPAND", "YES")
  21.  
  22.   box = IupSbox(btn)
  23.   'place at the bottom of the button
  24.  IupSetAttribute(box, "DIRECTION", "SOUTH")  
  25.   'IupSetAttribute(box, "COLOR", "0 255 0")
  26.  
  27.   ml = IupMultiLine(NULL)
  28.   IupSetAttribute(ml, "EXPAND", "YES")
  29.   IupSetAttribute(ml, "VISIBLELINES", "5")
  30.   vbox = IupVbox(box, ml, NULL)
  31.  
  32.   lbl = IupLabel("Label")
  33.   IupSetAttribute(lbl, "EXPAND", "VERTICAL")
  34.  
  35.   hbox = IupHbox(vbox, lbl, NULL)
  36.  
  37.   dlg = IupDialog(hbox)
  38.   IupSetAttribute(dlg, "TITLE", "IupSbox Example")
  39.   IupSetAttribute(dlg, "MARGIN", "10x10")
  40.   IupSetAttribute(dlg, "GAP", "10")
  41.  
  42.   IupShow(dlg)
  43.  
  44. end sub
  45.  
  46.  
  47. sub main()
  48.  
  49.   IupOpen(0,0)
  50.   SboxTest()
  51.   IupMainLoop()
  52.   IupClose()
  53.  
  54. end sub
  55.  
  56. main()
  57.  
Title: Re: Working with IUP
Post by: Arnold on August 30, 2016, 04:57:24 AM
This is a IupHbox example. IupHbox is a container for composing elements horizontally.

I build from bottom up - in this case: first buttons, then hbox, then frame, then a vbox with the frames, and finally the dialog with the vbox. When commenting out line 64 (f1, f2) one should see the difference of frame3 when the window is resized horizontally.

And of course only the header files are used.

Roland

Code: OxygenBasic
  1. $ filename "hbox.exe"
  2.  
  3. 'include     "$/inc/RTL32.inc"
  4. 'include     "$/inc/console.inc"
  5.  
  6. includepath "iup/"
  7. extern lib "IUP/iup.dll" cdecl
  8. include "iup.h"
  9.  
  10. extern cdecl
  11.  
  12.  
  13. sub HboxTest()
  14.  
  15.    'buttons
  16.   b11=IupButton("1", NULL)
  17.    b12=IupButton("2", NULL)
  18.    b13=IupButton("3", NULL)
  19.  
  20.    'hbox
  21.   h1 = IupHbox (b11, b12, b13, NULL)
  22.  
  23.    'Creates frame with three top aligned buttons
  24.   fr1 = IupFrame(h1)
  25.  
  26. '   IupSetAttribute(fr1, "TITLE", "ALIGNMENT=ATOP")
  27.   IupSetAttribute(fr1, "TITLE", "IupHbox")
  28.    IupSetAttribute(b11, "SIZE", "10x10")
  29.    IupSetAttribute(b12, "SIZE", "20x16")
  30.    IupSetAttribute(b13, "SIZE", "30x20")
  31.    'Sets hbox's alignment, gap and size
  32.   IupSetAttributes(h1, "ALIGNMENT=ATOP")  
  33. '   IupSetAttribute(h1, "HOMOGENEOUS", "YES")
  34. '   IupSetAttribute(h1, "EXPANDCHILDREN", "YES")
  35. '   IupSetAttribute(b12, "VISIBLE", "NO")
  36. '   IupSetAttribute(b12, "FLOATING", "YES")
  37.  
  38.    'buttons
  39.   b21=IupButton("1", NULL)
  40.    b22=IupButton("2", NULL)
  41.    b23=IupButton("3", NULL)
  42.  
  43.    'hbox
  44.   h2=IupHbox (b21, b22, b23, NULL)
  45.  
  46.    'Creates frame with three buttons
  47.   fr2 = IupFrame (h2)
  48.    IupSetAttribute(fr2, "TITLE", "ALIGNMENT=ACENTER,GAP=20 ")
  49.    IupSetAttribute(b21, "SIZE", "30x30")
  50.    IupSetAttribute(b22, "SIZE", "30x40")
  51.    IupSetAttribute(b23, "SIZE", "30x50")
  52.    'Sets hbox's alignment and gap
  53.   IupSetAttributes(h2, "ALIGNMENT=ACENTER, GAP=20")
  54.  
  55.    'buttons
  56.   b31=IupButton ("1", NULL)
  57.    b32=IupButton ("2", NULL)
  58.    b33=IupButton ("3", NULL)
  59.    f1=IupFill()
  60.    f2=IupFill()
  61.  
  62.    'hbox
  63.   h3=IupHbox (b31, b32, b33,
  64.                f1, f2,
  65.                NULL)
  66.  
  67.    'Creates frame with three bottom aligned buttons
  68.   fr3 = IupFrame (h3)
  69.    IupSetAttribute(fr3, "TITLE", "ALIGNMENT=ABOTTOM, MARGIN=10x10")
  70.    IupSetAttribute(b31, "SIZE", "30x30")
  71.    'IupSetAttribute(b31, "EXPAND", "HORIZONTAL")
  72.   'IupSetAttribute(b31, "EXPAND", "YES")
  73.   IupSetAttribute(b32, "SIZE", "30x40")
  74.    IupSetAttribute(b33, "SIZE", "30x50")
  75.    'Sets hbox's alignment and size
  76.   IupSetAttributes(h3, "ALIGNMENT=ABOTTOM, MARGIN=10x10")
  77.  
  78.    'Create vbox with three frames
  79.   vbox=IupVbox(fr1, fr2, fr3, NULL)
  80.  
  81.    'Creates dlg with the three frames    
  82.   dlg = IupDialog(vbox)
  83.  
  84.    IupSetAttribute(dlg, "TITLE", "IupHbox Test") ' Sets dlg's title
  85.   IupSetAttribute(dlg, "NMARGIN", "10x10")
  86.    IupSetAttribute(dlg, "NGAP", "10")
  87. '  IupSetAttribute(fr1, "MARGIN", "0x0")   ' avoid attribute propagation
  88. '  IupSetAttribute(fr2, "MARGIN", "0x0")
  89. '  IupSetAttribute(fr3, "MARGIN", "0x0")
  90. '  IupSetAttribute(fr1, "GAP", "0")
  91. '  IupSetAttribute(fr2, "GAP", "0")
  92. '  IupSetAttribute(fr3, "GAP", "0")
  93.  
  94.    'Shows dlg in the center of the screen
  95.   IupShowXY(dlg, IUP_CENTER, IUP_CENTER)
  96.  
  97. end sub
  98.  
  99.  
  100. sub main()
  101.  
  102.    IupOpen(0,0)
  103.    HboxTest()
  104.    IupMainLoop()
  105.    IupClose()
  106.  
  107. end sub
  108.  
  109. main
  110.  
Title: Re: Working with IUP
Post by: Arnold on August 30, 2016, 08:04:45 AM
This is a small example using IupLink. IupLink is a label with an underlined clickable text. It can be used e.g. to open a web page.

Code: OxygenBasic
  1. $ filename "link.exe"
  2.  
  3. 'include     "$/inc/RTL32.inc"
  4. 'include     "$/inc/console.inc"
  5.  
  6. includepath "iup/"
  7. extern lib "IUP/iup.dll" cdecl
  8. include "iup.h"
  9.  
  10. extern cdecl
  11.  
  12.  
  13. function action(sys ih, url)
  14.   zstring link at url
  15.   print "ACTION (" link ")" & chr(13,10)
  16.   return IUP_DEFAULT
  17. end function
  18.  
  19. sub LinkTest()
  20.  
  21.   'the links
  22.  linkEmpty = IupLink(NULL, "Nothing")
  23.   linkButton = IupLink("http://www.tecgraf.puc-rio.br/iup", "IUP Toolkit")
  24.   linkButtonLabel = IupLink("http://www.OxygenBasic.org", "OxygenBasic web site")
  25.  
  26.   'labels horizontal
  27.  hbox1 = IupHbox(linkEmpty, NULL)
  28.   hbox2 = IupHbox(linkButton, NULL)
  29.   hbox3 = IupHbox(linkButtonLabel, NULL)
  30.  
  31.   'show vertical
  32.  vbox = IupVbox(hbox1, hbox2, hbox3, NULL)
  33.  
  34.   'create dialog
  35.  dlg = IupDialog(vbox)
  36.  
  37.   IupSetAttribute(dlg, "TITLE", "IupLink Test")
  38.   IupSetAttribute(dlg, "MARGIN", "10x10")
  39.   IupSetAttribute(dlg, "RASTERSIZE", "500x500")
  40.  
  41.   'actions  
  42.  IupSetCallback(linkEmpty, "ACTION", @action)
  43.   IupSetCallback(linkButton, "ACTION", @action)
  44.   IupSetCallback(linkButtonLabel, "ACTION", @action)
  45.  
  46.   IupShowXY(dlg,IUP_CENTER,IUP_CENTER)
  47. end sub
  48.  
  49.  
  50. sub main()
  51.  
  52.   IupOpen(0,0)
  53.   LinkTest()
  54.   IupMainLoop()
  55.   IupClose()
  56.  
  57. end sub
  58.  
  59. main()
  60.  

Title: Re: Working with IUP
Post by: Arnold on August 30, 2016, 08:12:56 AM
This is a small example using IupGridBox. IupGridBox is a container for composing elements in a regular grid. Details can be found in the IUP Helpfile. (exists as .chm or .pdf file).

Code: OxygenBasic
  1. $ filename "gridbox.exe"
  2.  
  3. 'include     "$/inc/RTL32.inc"
  4. 'include     "$/inc/console.inc"
  5.  
  6. includepath "iup/"
  7. extern lib "IUP/iup.dll" cdecl
  8. include "iup.h"
  9.  
  10. extern cdecl
  11.  
  12.  
  13. sub GridBoxTest()
  14.  
  15.   l1=IupLabel(" ")
  16.   l2=IupLabel("col1"): IupSetAttributes(l2,"FONTSTYLE=Bold")
  17.   l3=IupLabel("col2"): IupSetAttributes(l3, "FONTSTYLE=Bold")
  18.  
  19.   l4=IupLabel("lin1"): IupSetAttributes(l4, "FONTSTYLE=Bold")
  20.   l5=IupLabel("lbl"):  IupSetAttributes(l5, "XSIZE=50x12")
  21.   b6=IupButton("but", NULL): IupSetAttributes(b6, "XSIZE=50")
  22.  
  23.   l7=IupLabel("lin2"):  IupSetAttributes(l7, "FONTSTYLE=Bold")
  24.   l8=IupLabel("label"): IupSetAttributes(l8, "XSIZE=x12")
  25.   b9=IupButton("button",NULL): IupSetAttributes(b9, "XEXPAND=Horizontal")
  26.  
  27.   l10=IupLabel("lin3"): IupSetAttributes(l10, "FONTSTYLE=Bold")
  28.   l11=IupLabel("label large"): IupSetAttributes(l11, "XSIZE=x12")
  29.   b12=IupButton("button large", NULL): IupSetAttributes(b12, "")
  30.  
  31.   gbox = IupGridBox(l1,l2,l3,l4,l5,b6,l7,l8,b9,l10,l11,b12, NULL)
  32.  
  33.   fr1 = IupFrame(gbox)
  34.  
  35.   IupSetAttribute(gbox, "SIZECOL", "2")
  36.   IupSetAttribute(gbox, "SIZELIN", "3")
  37. '  IupSetAttribute(gbox, "HOMOGENEOUSLIN", "Yes")
  38. '  IupSetAttribute(gbox, "HOMOGENEOUSCOL", "Yes")
  39. '  IupSetAttribute(gbox, "EXPANDCHILDREN", "HORIZONTAL")
  40. '  IupSetAttribute(gbox, "NORMALIZESIZE", "BOTH")
  41. '  IupSetAttribute(gbox, "NORMALIZESIZE", "HORIZONTAL")
  42.  
  43.   IupSetAttribute(gbox, "NUMDIV", "3")
  44. '  IupSetAttribute(gbox, "NUMDIV", "2")
  45.  
  46. '  IupSetAttribute(gbox, "ORIENTATION", "VERTICAL")
  47. '  IupSetAttribute(gbox, "SIZECOL", "3")
  48. '  IupSetAttribute(gbox, "SIZELIN", "2")
  49.  
  50. '  IupSetAttribute(gbox, "SIZE", "70x")
  51. '  IupSetAttribute(gbox, "NUMDIV", "AUTO")
  52. '  IupSetAttribute(gbox, "NORMALIZESIZE", "BOTH")
  53.  
  54.   IupSetAttribute(gbox, "ALIGNMENTLIN", "ACENTER")
  55.   IupSetAttribute(gbox, "MARGIN", "10x10")
  56.   IupSetAttribute(gbox, "GAPLIN", "5")
  57.   IupSetAttribute(gbox, "GAPCOL", "5")
  58.  
  59.   hbox = IupHbox(fr1, NULL)
  60.  
  61.   dlg = IupDialog (hbox)
  62.  
  63.   IupSetAttribute(dlg, "TITLE", "IupGridBox Test")
  64.   IupSetAttribute(dlg, "MARGIN", "10x10")
  65.   IupSetAttribute(fr1, "MARGIN", "0x0")   ' avoid attribute propagation
  66.  
  67.   'Shows dlg in the center of the screen
  68.  IupShowXY(dlg, IUP_CENTER, IUP_CENTER)
  69. end sub
  70.  
  71.  
  72. sub main()
  73.  
  74.   IupOpen(0,0)
  75.   GridBoxTest()
  76.   IupMainLoop()
  77.   IupClose()
  78.  
  79. end sub
  80.  
  81. main
  82.  
Title: Re: Working with IUP
Post by: Arnold on August 30, 2016, 12:41:23 PM
This is a small mdi example with a simple menu and some old style callback functions using IupSetFunction. No problem with OxygenBasic.

Code: OxygenBasic
  1. $ filename "mdi.exe"
  2.  
  3. 'include     "$/inc/RTL32.inc"
  4. include     "$/inc/console.inc"
  5.  
  6. includepath "iup/"      
  7. extern lib "IUP/iup.dll" cdecl
  8. include "iup.h"
  9.      
  10. extern cdecl      
  11.  
  12.  
  13. function mdi_tilehoriz(sys ih)
  14.   IupSetAttribute(IupGetDialog(ih), "MDIARRANGE", "TILEHORIZONTAL")
  15.   return IUP_DEFAULT
  16. end function
  17.  
  18. function mdi_tilevert(sys ih)
  19.   IupSetAttribute(IupGetDialog(ih), "MDIARRANGE", "TILEVERTICAL")
  20.   return IUP_DEFAULT
  21. end function
  22.  
  23. function mdi_cascade(sys ih)
  24.   IupSetAttribute(IupGetDialog(ih), "MDIARRANGE", "CASCADE")
  25.   return IUP_DEFAULT
  26. end function
  27.  
  28. function mdi_icon(sys ih)
  29.   IupSetAttribute(IupGetDialog(ih), "MDIARRANGE", "ICON")
  30.   return IUP_DEFAULT
  31. end function
  32.  
  33. function mdi_next(sys ih)
  34.   IupSetAttribute(IupGetDialog(ih), "MDIACTIVATE", "NEXT")
  35.   return IUP_DEFAULT
  36. end function
  37.  
  38. function mdi_previous(sys ih)
  39.   IupSetAttribute(IupGetDialog(ih), "MDIACTIVATE", "PREVIOUS")
  40.   return IUP_DEFAULT
  41. end function
  42.  
  43. function mdi_closeall(sys ih)
  44.   IupSetAttribute(IupGetDialog(ih), "MDICLOSEALL", NULL)
  45.   return IUP_DEFAULT
  46. end function
  47.  
  48. function mdi_activate(sys ih)  
  49.   print "mdi_activate " & IupGetName(ih) & cr
  50.   return IUP_DEFAULT
  51. end function
  52.  
  53. function button_cb(sys ih)
  54.   print "button_cb()" & cr
  55.   return IUP_DEFAULT
  56. end function
  57.  
  58. function mdi_new(sys ih)
  59.   static int id = 0
  60.   sys box, txt, dlg, btn
  61.  
  62.   txt = IupText(NULL)
  63.  
  64.   btn = IupButton("Test", NULL)
  65.   IupSetCallback(btn,"ACTION", @button_cb)
  66.  
  67.   hbox = IupHbox(btn, NULL)
  68.   box = IupVbox(hbox, txt, NULL)
  69.   IupSetAttribute(box,"MARGIN","5x5")
  70.  
  71.   dlg = IupDialog(box)
  72.   IupSetfAttribute(dlg,"TITLE","MDI Child (%d)", id) : id++
  73.   IupSetAttribute(dlg,"MDICHILD","YES")
  74.   IupSetAttribute(dlg,"PARENTDIALOG","mdiFrame")
  75.   IupSetCallback(dlg,"MDIACTIVATE_CB",@mdi_activate)
  76.   IupSetAttribute(dlg,"RASTERSIZE","300x300")
  77. '  IupSetAttribute(dlg, "PLACEMENT", "MAXIMIZED")
  78.  
  79.   IupShow(dlg)
  80.  
  81.   IupSetAttribute(dlg,"RASTERSIZE",NULL)
  82.  
  83.   return IUP_DEFAULT
  84. end function
  85.  
  86. sub createMenu()
  87.   sys winmenu, mnu
  88.  
  89.   'create menus, bottom-up from items to sub menu to main menu
  90.  items1   = IupMenu(IupItem("New", "mdi_new"), NULL)  
  91.   submenu1 = IupSubmenu("MDI", items1)  
  92.  
  93.   'more then a single item must be splitted
  94.  i1=IupItem("Tile Horizontal", "mdi_tilehoriz")
  95.   i2=IupItem("Tile Vertical", "mdi_tilevert")
  96.   i3=IupItem("Cascade", "mdi_cascade")
  97.   i4=IupItem("Icon Arrange", "mdi_icon")
  98.   i5=IupItem("Close All", "mdi_closeall")
  99.   i6=IupSeparator()
  100.   i7=IupItem("Next", "mdi_next")
  101.   i8=IupItem("Previous", "mdi_previous")
  102.  
  103.   winmenu  = IupMenu(i1,i2,i3,i4,i5,i6,i7,i8,NULL)
  104.   submenu2 =IupSubmenu("Window", winmenu)
  105.  
  106.   'main menu    
  107.  mnu = IupMenu(submenu1, submenu2, null)
  108.  
  109.   IupSetHandle("mnu",mnu)
  110.   IupSetHandle("mdiMenu",winmenu)
  111.  
  112.   'callbacks, old depricated style
  113.  IupSetFunction("mdi_new", @mdi_new)
  114.   IupSetFunction("mdi_tilehoriz", @mdi_tilehoriz)
  115.   IupSetFunction("mdi_tilevert", @mdi_tilevert)
  116.   IupSetFunction("mdi_cascade", @mdi_cascade)
  117.   IupSetFunction("mdi_icon", @mdi_icon)
  118.   IupSetFunction("mdi_next", @mdi_next)
  119.   IupSetFunction("mdi_previous", @mdi_previous)
  120.   IupSetFunction("mdi_closeall", @mdi_closeall)
  121.  
  122. end sub
  123.  
  124. function createFrame() as sys
  125.  
  126.   sys dlg, cnv, box, btn
  127.  
  128.   cnv = IupCanvas( NULL)
  129.   IupSetAttribute(cnv,"MDICLIENT","YES")
  130.   IupSetAttribute(cnv,"MDIMENU","mdiMenu")
  131.   IupSetAttribute(cnv,"BGCOLOR","128 255 0")
  132.  
  133.   btn = IupButton("Test", NULL)
  134.   IupSetCallback(btn,"ACTION", @button_cb)
  135.  
  136.   box = IupHbox(btn, NULL)
  137.   IupSetAttribute(box,"MARGIN","5x5")
  138.  
  139.   vbox = IupVbox(box, cnv, NULL)
  140.   dlg = IupDialog(vbox)
  141.  
  142.   IupSetAttribute(dlg,"TITLE","MDI Frame")
  143.   IupSetAttribute(dlg,"MDIFRAME","YES")
  144.   IupSetAttribute(dlg,"RASTERSIZE","800x600")
  145.   IupSetAttribute(dlg,"MENU","mnu")
  146.   IupSetHandle("mdiFrame", dlg)
  147.  
  148.   return dlg
  149. end function
  150.  
  151. sub MdiTest()
  152.  
  153.   sys dlg
  154.  
  155.   createMenu()
  156.   dlg = createFrame()
  157. '  IupSetAttribute(dlg, "PLACEMENT", "MAXIMIZED")
  158.  
  159.   IupShow(dlg)
  160.   IupSetAttribute(dlg,"RASTERSIZE", NULL)
  161.  
  162. end sub
  163.  
  164.  
  165. sub main()
  166.  
  167.   IupOpen(0,0)
  168.   MdiTest()
  169.   IupMainLoop()
  170.   IupClose()
  171.  
  172. end sub
  173.  
  174.  
  175. main()
  176.  


.
Title: Re: Working with IUP
Post by: JRS on August 30, 2016, 05:30:01 PM
Glad to see you back on the IUP trail again.

IUP works well with O2 and easy to use as well.

@Charles - How does O2 support Windows themes? The old Win2000 default style controls are ugly!

Title: Re: Working with IUP
Post by: Arnold on August 31, 2016, 12:14:41 AM
Hi John,

I assume you refer to the appearance of the window in the picture above? I use an old 32-bit computer with a predefined style which I could change, even to old classic Win95 but I am used to this appearance. If I run the oxygen examples in a newer computer using Win7 or Win8 the appearance of the windows are different. And running them in Windows10 there is still another look. So I am not sure if a special manifest would be necessary to change the appearance?

Roland
Title: Re: Working with IUP
Post by: JRS on August 31, 2016, 08:53:13 AM
I'm referring to 'XP Theme' support. (works on Win7)  I don't run Win10 so I can't comment on if XP Theming is relevant to that version of the OS.

(http://files.allbasic.info/ScriptBasic/cboxw.png)
Title: Re: Working with IUP
Post by: Charles Pegge on August 31, 2016, 12:03:48 PM

Hi John,

You guys know more than I do about themes - I just change them through the Windows Control Panel / Appearance.
Title: Re: Working with IUP
Post by: JRS on August 31, 2016, 01:36:25 PM
Roland,

You need to download the IUP source to get the resources for theming.

I have a special Script BASIC scriba that has the IUP theming resources included I use with IUP projects I do.

John
Title: Re: Working with IUP - a problem
Post by: Arnold on September 02, 2016, 02:51:09 AM
Hi Charles,

there must be a fault in my logic and although I tried for some time now I fail to find it.

I try to use IupButton with an image e.g.:
  button = IupButton(NULL, NULL)
  IupSetAttribute(button, "TITLE", "Images")
  IupSetAttributeHandle(button, "IMAGE", load_image_FileSave())

If I use the wrapped Iup functions this will work. If I use Iup.h this does not work correctly. Should I use a cast somewhere?

The appended code shows the working case. If I comment out line 6, line 32 and remove the comments from line 34, line 58 then the faulty case is shown.
I think there must be only a minor modification somewhere but until now I have not yet found the needle.

Roland

Code: OxygenBasic
  1. $ filename "button2.exe"
  2.  
  3. 'include "$/inc/RTL32.inc"
  4. include "$/inc/console.inc"
  5.  
  6. /* this does not work correctly
  7. includepath "iup/"      
  8. extern lib "IUP/iup.dll" cdecl
  9. include "iup.h"
  10.  
  11. '  used in iup.h
  12. '  #define IUP_DEFAULT   -2
  13. '  int       IupOpen          (int *argc, char ***argv);
  14. '  void      IupClose         (void);
  15. '  int       IupMainLoop      (void);
  16. '  int       IupShow          (Ihandle* ih);
  17. '  Ihandle*  IupDialog     (Ihandle* child);
  18. '  Ihandle*  IupButton     (const char* title, const char* action);    
  19. '  Ihandle*  IupImage      (int width, int height, const unsigned char *pixmap);
  20. '  Ihandle*  IupImageRGB   (int width, int height, const unsigned char *pixmap);
  21. '  Ihandle*  IupImageRGBA  (int width, int height, const unsigned char *pixmap);
  22. '  Ihandle*  IupHbox       (Ihandle* child,...);
  23. '  Ihandle*  IupVbox       (Ihandle* child, ...);
  24. '  Ihandle*  IupAppend       (Ihandle* ih, Ihandle* child);
  25. '  void      IupSetAttribute   (Ihandle* ih, const char* name, const char* value);
  26. '  void      IupSetAttribute   (Ihandle* ih, const char* name, const char* value);
  27. '  char*     IupGetAttribute(Ihandle* ih, const char* name);
  28. '  void      IupSetAttributeHandle(Ihandle* ih, const char* name, Ihandle* ih_named);
  29. '  Icallback IupSetCallback (Ihandle* ih, const char *name, Icallback func);
  30.  
  31. extern cdecl      
  32. */
  33.  
  34. '/* this would work
  35. includepath "iup/"      
  36. extern lib "IUP/iup.dll" cdecl      
  37.  
  38. #define IUP_DEFAULT   -2
  39. ! IupOpen          (sys argc,argv) as int
  40. ! IupClose         ()
  41. ! IupMainLoop      () as int
  42. ! IupShow          (sys ih) as int
  43. ! IupDialog        (sys child) as sys
  44. ! IupButton        (char* title, char* action) as sys
  45. ! IupImage         (int width, int height, byte ptr pixmap) as sys
  46. ! IupImageRGB      (int width, int height, byte ptr pixmap) as sys
  47. ! IupImageRGBA     (int width, int height, byte ptr pixmap) as sys
  48. ! IupHbox          (sys child,...) as sys
  49. ! IupVbox          (sys child, ...) as sys
  50. ! IupAppend        (sys ih, sys child) as sys
  51. ! IupSetAttribute  (sys ih, char* name, char* value)
  52. ! IupGetAttribute  (sys ih, char* name) as char ptr
  53. ! IupSetAttributeHandle (sys ih, char* name, sys ih_named)
  54. ! IupSetCallback   (sys ih, char *name, sys func) as sys
  55.  
  56. end extern
  57. extern cdecl      
  58. '*/
  59. '  As the size of the code is too large it is appended.
  60.  


.
Title: Re: Working with IUP - a problem
Post by: Arnold on September 02, 2016, 08:08:25 AM
I assume the problem arises with IupImage, IupImageRGB and IupImageRGBA. Iup.h uses: const unsigned char *pixmap, I wrapped this using: byte *pixmap. But using Iup.h if I try to dim imgdata as char in function load_image_FileSave then the app will crash.

Is there a possibility to redefine 'const unsigned char' somehow? Or could I wrap some functions of Iup outside of Iup.h? But perhaps I forgot something else.

Roland

Title: Re: Working with IUP
Post by: JRS on September 02, 2016, 08:59:35 AM
Hi Roland,

I had a similar issue with IUP and C byte array image definitions. I ended up creating a SB function that parsed the text C array code and generated a binary string to pass to the IUP image functions.
 
Title: Re: Working with IUP
Post by: Charles Pegge on September 02, 2016, 11:07:25 AM
Hi Roland,

One solution is to override the offending definitions:

Code: [Select]
include "$/inc/console.inc"
includepath "iup/"     
extern lib "IUP/iup.dll" cdecl
include "iup.h"
'overriding const unsigned char* pixmap
Ihandle*  IupImage      (int width, int height, byte *pixmap);
Ihandle*  IupImageRGB   (int width, int height, byte *pixmap);
Ihandle*  IupImageRGBA  (int width, int height, byte *pixmap);

But I will see if I can persuade o2 to accept signed/unsigned char as a byte.
Title: Re: Working with IUP
Post by: Arnold on September 02, 2016, 12:52:18 PM
Thank you Charles for the overriding option. This is an alternative which I must bear in mind in the future. The app works very fine now. I will need the functions for the cbox example.

Roland

.
Title: Re: Working with IUP
Post by: JRS on September 03, 2016, 12:35:56 AM
Roland,

Here is my compile line instructions to build a C console-less (Windows program) that has the resources (manifest) to enable theming.

Code: C
  1. windres -O coff -o iup.res ../../../etc/iup.rc
  2. gcc -Wl,-subsystem,windows -o sample.exe sample.c iup.res -I../../../include -L../../../lib/dllw4 -liupstub -liup
  3.  
Title: Re: Working with IUP
Post by: Arnold on September 03, 2016, 08:26:20 AM
Hello,

this is an IupCbox example. Cbox is a container for position the elements in absolute coordinates. IupMatrix is not included here. This would need iupcontrols.dll which calls some more dlls and which needs another approach.

@John - I would be interested. Creating an exe file and linking to Iup.rc does not make much difference to me. Do you notice a difference?
This is what I have done: copy iup.rc, pen.cur, tecgraf.ico, iup.manifest from folder /iup/etc to folder projectsB\IUP. Create cbox1.exe by removing the comment from:
'include     "$/inc/RTL32.inc" in cbox1.o2bas.
In a Dos Window in projectsB\IUP I call these commands:
windres -iiup.rc -oiup.res -Ores
..\..\tools\LinkRes2Exe.exe iup.res cbox1.exe

GoRc.exe cannot process Iup.rc as is. In a project with WinResources Charles has already used a resource file which would work similar like Iup.rc.

Roland

Code: [Select]
$ filename "cbox1.exe"

'include     "$/inc/RTL32.inc"
'include     "$/inc/console.inc"

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

'overriding const unsigned char* pixmap in iup.h
Ihandle*  IupImage      (int width, int height, byte *pixmap)
Ihandle*  IupImageRGB   (int width, int height, byte *pixmap)
Ihandle*  IupImageRGBA  (int width, int height, byte *pixmap)

end extern
extern cdecl
       

cr=chr(13,10)

byte img_bits1[] =>
{
 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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
}

byte img_bits2[] =>
{
 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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
,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
}


function createtree() as sys

  sys tree = IupTree()

  IupSetAttributes(tree, "FONT=COURIER_NORMAL_12, NAME=Figures,
                          RASTERSIZE=180x180, CX=600, CY=10" )

  return tree
end function

sub func_1 ()

  sys cbox, cnv_1, dlg, img,
    frm_1, frm_2, frm_3, hbox, ctrl_1,
    list_1, list_2, list_3, text_1, ml_1

  img = IupImage(32,32, @img_bits1)
  IupSetHandle ("img1", img)
  IupSetAttribute (img, "0", "0 0 0")
  IupSetAttribute (img, "1", "BGCOLOR")
  IupSetAttribute (img, "2", "255 0 0")

  img = IupImage(32,32, @img_bits2)
  IupSetHandle ("img2", img)
  IupSetAttribute (img, "0", "0 0 0")
  IupSetAttribute (img, "1", "0 255 0")
  IupSetAttribute (img, "2", "BGCOLOR")
  IupSetAttribute (img, "3", "255 0 0")

  'bottom-up
  b1=IupButton("Button Text",NULL) : b2=IupButton("",NULL) : b3=IupButton("",NULL)
  IupSetAttribute(b1, "CINDEX","1")
  IupSetAttributes(b2, "IMAGE=img1, CINDEX=2")
  IupSetAttributes(b3, "IMAGE=img1,IMPRESS=img2,CINDEX=3")

  vbox1 = IupVbox(b1,b2,b3,NULL)
  frm_1 = IupFrame(vbox1)
  IupSetAttributes(frm_1,"TITLE=IupButton, CX=10, CY=180")

  'bottom-up
  l1=IupLabel("Label Text") : l2=IupLabel(NULL) : l3=IupLabel(NULL)
  IupSetAttribute(l1, "CINDEX","1")
  IupSetAttributes(l2, "SEPARATOR=HORIZONTAL,CINDEX=2")
  IupSetAttributes(l3, "IMAGE=img1,CINDEX=3")

  vbox2 = IupVbox(l1, l2, l3, NULL)
  frm_2 = IupFrame(vbox2) 
  IupSetAttributes(frm_2,"TITLE=IupLabel, CX=200, CY=250")


  'bottom-up
  'checkboxes
  t1=IupToggle("Toggle Text", NULL) : t2=IupToggle("", NULL)
    IupSetAttributes(t1, "VALUE=ON, CINDEX=1")
    IupSetAttributes(t2, "IMAGE=img1, IMPRESS=img2, CINDEX=2")
    'show verical
    vb1=IupVbox(t1, t2, NULL)

  'radios
  t3=IupToggle("Toggle Text", NULL) : t4=IupToggle("Toggle Text", NULL)
    IupSetAttributes(t3, "CINDEX=3")
    IupSetAttributes(t4, "CINDEX=4")
    'show vertical
    vb2=IupVbox(t3,t4)
    'change to radios
    radio=IupRadio(vb2)
    'frame them
    frame=IupFrame(radio)
    IupSetAttribute(frame, "TITLE", "IupRadio")

  vbox3=IupVbox(vb1,frame, NULL)
  frm_3=IupFrame(vbox3)
  IupSetAttribute(frm_3,"TITLE","IupToggle")
  IupSetAttribute(frm_3,"CX","400")
  IupSetAttribute(frm_3,"CY","250")

  text_1 = IupText( NULL)
  IupSetAttribute(text_1,"VALUE","IupText Text")
  IupSetAttributes(text_1,"SIZE=80x, CINDEX=1, CX=10, CY=100")

  ml_1 = IupMultiLine( NULL)
  IupSetAttribute(ml_1,"VALUE","IupMultiline Text" & cr & "Second Line" & cr & "Third Line" & cr)
  IupSetAttributes(ml_1,"SIZE=80x60, CINDEX=1, CX=200, CY=100")

  list_1 = IupList( NULL)
  IupSetAttributes(list_1,"VALUE=1, CINDEX=1, CX=10, CY=10")
  IupSetAttribute(list_1,"1","Item 1 Text")
  IupSetAttribute(list_1,"2","Item 2 Text")
  IupSetAttribute(list_1,"3","Item 3 Text")

  list_2 = IupList( NULL)
  IupSetAttributeS(list_2,"DROPDOWN=YES, VALUE=2, CINDEX=2, CX=200, CY=10")
  IupSetAttribute(list_2,"1","Item 1 Text")
  IupSetAttribute(list_2,"2","Item 2 Text")
  IupSetAttribute(list_2,"3","Item 3 Text")

  list_3 = IupList( NULL)
  IupSetAttributes(list_3,"EDITBOX=YES, VALUE=3, CINDEX=3, CX=400, CY=10")
  IupSetAttribute(list_3,"1","Item 1 Text")
  IupSetAttribute(list_3,"2","Item 2 Text")
  IupSetAttribute(list_3,"3","Item 3 Text")

  cnv_1 = IupCanvas( NULL)
  IupSetAttributes(cnv_1,"RASTERSIZE=100x100, POSX=0, POSY=0, CX=400, CY=150")
  IupSetAttribute(cnv_1,"BGCOLOR","128 255 0") 'green

  ctrl_1 = IupVal(NULL)
  IupSetAttributes(ctrl_1,"CX=600, CY=200")

  cbox = IupCbox(
    text_1,
    ml_1,
    list_1,
    list_2,
    list_3,
    cnv_1,
    ctrl_1,
    createtree(),
    frm_1,
    frm_2,
    frm_3,
    NULL)
  IupSetAttribute(cbox,"SIZE","480x200")

  hbox = IupHbox(cbox, NULL)
  IupSetAttribute(hbox, "MARGIN"," 10x10")

  dlg = IupDialog(hbox)
  IupSetHandle("dlg",dlg)
  IupSetAttribute(dlg,"TITLE","Cbox Test")
end sub

sub main()

  IupOpen(0,0)           
  func_1()
  IupShowXY(IupGetHandle("dlg"),IUP_CENTER,IUP_CENTER)
  IupMainLoop()
  IupClose() 

end sub


main()


.
Title: Re: Working with IUP
Post by: Aurel on September 03, 2016, 11:05:54 AM
Hi
May i ask about web browser with iUP?
i think that John present one written in SciptBasic
Title: Re: Working with IUP
Post by: JRS on September 03, 2016, 08:51:49 PM
Hi
May i ask about web browser with iUP?
i think that John present one written in SciptBasic

Here is the IUP web browser control running under BaCon

(http://files.allbasic.info/BaCon/iup_web.png)

Code: Text
  1. ' IupWebBrowser sample
  2.  
  3. PRAGMA OPTIONS -I/usr/include/iup
  4. PRAGMA LDFLAGS iup iupweb
  5. PRAGMA INCLUDE iup.h iupweb.h
  6.  
  7. PROTO IupOpen IupWebBrowserOpen IupSetAttribute IupSetAttributeHandle IupSetCallback IupShow IupMainLoop IupClose
  8.  
  9. DECLARE web TYPE Ihandle*
  10. DECLARE txt TYPE Ihandle*
  11. DECLARE dlg TYPE Ihandle*
  12. DECLARE btLoad TYPE Ihandle*
  13. DECLARE btReload TYPE Ihandle*
  14. DECLARE btBack TYPE Ihandle*
  15. DECLARE btForward TYPE Ihandle*
  16. DECLARE btStop TYPE Ihandle*
  17. DECLARE self TYPE Ihandle*
  18. DECLARE url TYPE STRING
  19.  
  20. FUNCTION navigate_cb(Ihandle* self, STRING url)
  21.   PRINT "NAVIGATE_CB: ", url
  22.   self = NULL
  23.   IF INSTR(url, "download") THEN
  24.     RETURN IUP_IGNORE
  25.   ELSE
  26.     RETURN IUP_DEFAULT
  27.   END IF
  28. END FUNCTION
  29.  
  30. FUNCTION error_cb(Ihandle* self, STRING url)
  31.   PRINT "ERROR_CB: ", url
  32.   self = NULL
  33.   RETURN IUP_DEFAULT
  34. END FUNCTION
  35.  
  36. FUNCTION completed_cb(Ihandle* self, STRING url)
  37.   PRINT "COMPLETED_CB: ", url
  38.   self = NULL
  39.   RETURN IUP_DEFAULT
  40. END FUNCTION
  41.  
  42. FUNCTION newwindow_cb(Ihandle* self, STRING url)
  43.   PRINT "NEWWINDOW_CB: ", url
  44.   IupSetAttribute(self, "VALUE", url)
  45.   RETURN IUP_DEFAULT
  46. END FUNCTION
  47.  
  48. FUNCTION back_cb(Ihandle* self)
  49.   web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  50.   IupSetAttribute(web, "BACKFORWARD", "-1")
  51.   RETURN IUP_DEFAULT
  52. END FUNCTION
  53.  
  54. FUNCTION forward_cb(Ihandle* self)
  55.   web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  56.   IupSetAttribute(web, "BACKFORWARD", "1")
  57.   RETURN IUP_DEFAULT
  58. END FUNCTION
  59.  
  60. FUNCTION stop_cb(Ihandle* self)
  61.   web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  62.   IupSetAttribute(web, "STOP", NULL)
  63.   RETURN IUP_DEFAULT
  64. END FUNCTION
  65.  
  66. FUNCTION reload_cb(Ihandle* self)
  67.   web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  68.   IupSetAttribute(web, "RELOAD", NULL)
  69.   ' TEST:
  70.   ' PRINT "STATUS=", IupGetAttribute(web, "STATUS")
  71.   RETURN IUP_DEFAULT
  72. END FUNCTION
  73.  
  74. FUNCTION load_cb(Ihandle* self)
  75.   txt  = (Ihandle*)IupGetAttribute(self, "MY_TEXT")
  76.   web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  77.   IupSetAttribute(web, "VALUE", IupGetAttribute(txt, "VALUE"))
  78.   ' TESTS:
  79.   ' IupSetAttribute(txt, "VALUE", IupGetAttribute(web, "VALUE"))
  80.   ' IupSetAttribute(web, "HTML", "<html><body><b>Hello</b>, World!</body></html>")
  81.   ' IupSetAttribute(web, "VALUE", "http://www.microsoft.com")
  82.   RETURN IUP_DEFAULT
  83. END FUNCTION
  84.  
  85. IupOpen(NULL, NULL)
  86. IupWebBrowserOpen()            
  87. ' Creates an instance of the WebBrowser control
  88. web = IupWebBrowser()
  89. ' Creates a dialog containing the control
  90. dlg = IupDialog(IupVbox(IupHbox(btBack = IupButton("Back", NULL), \
  91.                                 btForward = IupButton("Forward", NULL), \
  92.                                 txt = IupText(""), \
  93.                                 btLoad = IupButton("Load", NULL), \
  94.                                 btReload = IupButton("Reload", NULL), \
  95.                                 btStop = IupButton("Stop", NULL), \
  96.                                 NULL), \
  97.                                 web, NULL))
  98. IupSetAttribute(dlg, "TITLE", "IupWebBrowser")
  99. IupSetAttribute(dlg, "MY_TEXT", (STRING)txt)
  100. IupSetAttribute(dlg, "MY_WEB", (STRING)web)
  101. IupSetAttribute(dlg, "RASTERSIZE", "800x600")
  102. IupSetAttribute(dlg, "MARGIN", "10x10")
  103. IupSetAttribute(dlg, "GAP", "10")
  104. ' IupSetAttribute(web, "HTML", "<html><body><b>Hello</b>World!</body></html>")
  105. ' IupSetAttribute(txt, "VALUE", "My HTML")
  106. ' IupSetAttribute(txt, "VALUE", "file:///D:/tecgraf/iup/html/index.html")
  107. IupSetAttribute(txt, "VALUE", "http://www.basic-converter.org/")
  108. IupSetAttribute(web, "VALUE", IupGetAttribute(txt, "VALUE"))
  109. IupSetAttributeHandle(dlg, "DEFAULTENTER", btLoad)
  110. IupSetAttribute(txt, "EXPAND", "HORIZONTAL")
  111. IupSetCallback(btLoad, "ACTION", (Icallback)load_cb)
  112. IupSetCallback(btReload, "ACTION", (Icallback)reload_cb)
  113. IupSetCallback(btBack, "ACTION", (Icallback)back_cb)
  114. IupSetCallback(btForward, "ACTION", (Icallback)forward_cb)
  115. IupSetCallback(btStop, "ACTION", (Icallback)stop_cb)
  116. IupSetCallback(web, "NEWWINDOW_CB", (Icallback)newwindow_cb)
  117. IupSetCallback(web, "NAVIGATE_CB", (Icallback)navigate_cb)
  118. IupSetCallback(web, "ERROR_CB", (Icallback)error_cb)
  119. IupSetCallback(web, "COMPLETED_CB", (Icallback)completed_cb)
  120. IupShow(dlg)
  121. IupMainLoop()
  122. IupClose()
  123.  


jrs@laptop:~/BaCon/B29$ ./iup_web
NAVIGATE_CB: http://www.basic-converter.org/
COMPLETED_CB: http://www.basic-converter.org/
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
jrs@laptop:~/BaCon/B29$
Title: Re: Working with IUP
Post by: Aurel on September 03, 2016, 10:51:32 PM
thanks John
well this is Bacon version for Linux
but if we wish windows version to work in o2 ..right?
Title: Re: Working with IUP
Post by: Charles Pegge on September 03, 2016, 11:41:58 PM
That should translate very easily into o2. No Windows API extras required.


PS:
 The next o2 will interpret signed char and unsigned char as bytes. I will also introduce a new type: sbyte for signed bytes. (range: -128 to 127)
Title: Re: Working with IUP
Post by: Arnold on September 04, 2016, 02:54:11 AM
Hello,

this is my solution for IupWebbrowser() so far. Unfortunately something is still missing so I am hesitating a little bit.
...

Edit: deleted. I submitted the corrected code in a later message

.
Title: Re: Working with IUP
Post by: Aurel on September 04, 2016, 07:00:44 AM
hi arnold
where i can find iupweb.dll ?
or do you can put it in attachment.

thanks...
...and friendly suggestion never put 3party dll-s into system32 folder  ;)

i also found this error
Arnold i download whole iup package
and what exactly this program need?


.
Title: Re: Working with IUP
Post by: Arnold on September 04, 2016, 09:14:41 AM
Hi Aurel,

...

The problem is that Iupweb.dll calls Iupole.dll and librarypath cannot not process this fully (or I do it wrong).
...

Roland
Title: Re: Working with IUP
Post by: Aurel on September 04, 2016, 10:21:31 AM
Hi Arnold
Thanks for zip..i will download and see what is inside.
Well about paths i am not sure ,,,because i never use anything from folder projects
in fact i have one separate folder called o2Mini where i have oxygen compiler few include files
my new interpreter and some GUI programs which use my awinh.inc include file.
For iup-case  i add new subfolder into this one and try to compile...
so i will see...  :)   
Title: Re: Working with IUP
Post by: Aurel on September 04, 2016, 10:38:48 AM
OK
I have again problem with incude iup.h
which invoke also two other headers
iupkey.h and iupdef.h
yes i comment include console.inc  and why this program need console  :o
all your given files are in same folder and i will add this both includes..

.
Title: Re: Working with IUP
Post by: Arnold on September 04, 2016, 11:14:34 AM
Hi Aurel,

I see that you have copied webbrowser.o2bas into folder D:\o2Mini\webbrowser. Then you must copy the contents of projectsB\IUP\IUP into this folder too, namely the dll files, the .h header files and so on. Also iupweb.dll and iupole.dll. Then the first time try to run the program unchanged.

include console.inc is used to see the print statements in a console window. If you do not see the console window then it could be minimized in the task bar. If you click on the Icon in the task bar this window will get into front.

Roland
Title: Re: Working with IUP - OT: Set Path
Post by: Arnold on September 05, 2016, 12:27:51 AM
On second thoughts I will modifiy my (incomplete) webbrowser example so that it can be run in projectsB\IUP. The path for IUP libraries must be added in Windows System Control / User Account.
And this makes sense to me. I use many applications where I must set the path after the installation so that they can be executed e.g. gcc, tcc, bcx etc. Other applications which use dlls are bundled in the same directory.
Therefore nothing is wrong with Oxygenbasic when claiming dependant dlls. It is the logic way how Windows works.

Roland
Title: Re: Working with IUP
Post by: JRS on September 05, 2016, 01:14:55 AM
I put all of Script BASIC's extension module dependency DLLs (IUP, SDL, MySQL, ...) in the bin directory and only have to set one entry in the %PATH% environment variable.
Title: Re: Working with IUP
Post by: Aurel on September 05, 2016, 02:06:14 AM
Sorry Arnold
but this program simply not work for me
it is not clear to me why compiled dll need  include file :o

Do you can compile this program into standalone exe version with required dll-s ?
Title: Re: Working with IUP
Post by: Arnold on September 05, 2016, 03:51:47 AM
Hi Aurel,

attached you will find Aurel_web.zip which contains the files which you will need to run the program. It is not yet complete and not yet finished, (you cannot load a new web page), but it works so far.

Create a folder and copy the files into it or use an already existing folder.

(zip file deleted)

Roland
Title: Re: Working with IUP
Post by: Aurel on September 05, 2016, 08:10:32 AM
Thanks  :)
So that's it just 3 dll-s no include
why the heck then o2 complain about  ???
maybe because i try to use without console ?
Title: Re: Working with IUP
Post by: Arnold on September 05, 2016, 09:34:03 AM
Hurrah! I found my bug (as always my weakness using pointers).
I am cleaning up the code and will then upload my results.

Roland
Title: Re: Working with IUP
Post by: JRS on September 05, 2016, 09:51:12 AM
Quote
Hurrah! I found my bug (as always my weakness using pointers).

(https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcR4YugI9Byjjv1rGPjB5bXHsNFnEWqz8Lpi1kp-kZGn5a-JA5DJ)
Title: Re: Working with IUP
Post by: Arnold on September 05, 2016, 12:16:56 PM
Hello,

attached is the modified IupWebbrowser example (webbrowser.zip) containing webbrowser.o2bas, iupweb.dll and iupole.dll. The dlls are intended to be copied into \OxygenBasic\projectsB\IUP\IUP. The environment variable PATH must be set or extended with this folder. Webbrowser.o2bas can be run anywhere on the disk, but if not using the header files of projectsB\IUP\IUP then the includepath statement must be modified.

The IupWebbrowser control works very nice. I can confirm this as I send this message via webbrowser.o2bas.

Roland

Code: OxygenBasic
  1.  
  2. /* IupWebBrowser sample with Oxygenbasic */
  3.  
  4. ' This program can be run anywhere on a data medium with Oxygenbasic,
  5. ' provided there is a path set for the IUP dlls: Iup.dll, Iupole.dll and Iupweb.dll
  6. ' It is assumed there exists \OxygenBasic\projectsB\IUP\IUP\ for the header files
  7. ' otherwise the includepath statement must be corrected.
  8. ' A created executable can run anywhere too, but a path for the IUP dlls must be provided also.
  9.  
  10. $ filename "webbrowser.exe"
  11.  
  12. 'include     "$/inc/RTL32.inc"
  13. include     "$/inc/console.inc"
  14.  
  15. includepath "$/projectsB/iup/iup/"
  16. extern lib "iup.dll" cdecl
  17. include "iup.h"
  18. 'extern lib "iupole.dll" cdecl
  19. extern lib "iupweb.dll" cdecl      
  20. include "iupweb.h"
  21.  
  22. extern cdecl
  23.  
  24.  
  25. function navigate_cb(Ihandle* self, char* url) as int
  26.   printl "NAVIGATE_CB: " & url
  27.   if instr(url, "download") then
  28.     printl "download ignored" & cr
  29.     return IUP_IGNORE
  30.   end if
  31.   return IUP_DEFAULT
  32. end function
  33.                    
  34. function error_cb(Ihandle* self, char* url) as int
  35.   printl "ERROR_CB: " & url & cr
  36.   return IUP_DEFAULT
  37. end function
  38.  
  39. function completed_cb(Ihandle* self, char* url) as int
  40.   printl "COMPLETED_CB: " & url
  41.   return IUP_DEFAULT
  42. end function
  43.  
  44. function newwindow_cb(Ihandle* self, char* url) as int
  45.   printl "NEWWINDOW_CB: " & url & cr
  46.   IupSetAttribute(self, "VALUE", url)
  47.   return IUP_DEFAULT
  48. end function
  49.  
  50. function back_cb(Ihandle* self) as int
  51.   Ihandle* web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  52.   IupSetAttribute(web, "BACKFORWARD", "-1")
  53. //  printl "zoom=" & IupGetAttribute(web, "ZOOM") & cr
  54.   return IUP_DEFAULT
  55. end function
  56.  
  57. function forward_cb(Ihandle* self) as int
  58.   Ihandle* web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  59.   IupSetAttribute(web, "BACKFORWARD", "1")
  60. //  IupSetAttribute(web, "ZOOM", "200")
  61.   return IUP_DEFAULT
  62. end function
  63.  
  64. function stop_cb(Ihandle* self) as int
  65.   Ihandle* web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  66.   IupSetAttribute(web, "STOP", NULL)
  67.   return IUP_DEFAULT
  68. end function
  69.  
  70. function reload_cb(Ihandle* self) as int
  71.   Ihandle* web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")
  72.   IupSetAttribute(web, "RELOAD", NULL)
  73.  
  74.   //TEST:
  75. //  printl "STATUS=" & IupGetAttribute(web, "STATUS") & cr
  76.   return IUP_DEFAULT
  77. end function
  78.  
  79. function load_cb(Ihandle* self) as int
  80.  
  81.   Ihandle *txt  = (Ihandle*)IupGetAttribute(self, "MY_TEXT")  
  82.   Ihandle *web  = (Ihandle*)IupGetAttribute(self, "MY_WEB")  
  83.   IupSetAttribute(web, "VALUE", IupGetAttribute(txt, "VALUE"))
  84.  
  85.   //TESTS:
  86. //  IupSetAttribute(txt, "VALUE", IupGetAttribute(web, "VALUE"))
  87. //  IupSetAttribute(web, "HTML", "<html><body><b>Hello</b>, World!</body></html>")
  88. //  IupSetAttribute(web, "VALUE", "http://www.microsoft.com")
  89.  
  90.   return IUP_DEFAULT
  91. end function
  92.  
  93.  
  94. sub WebBrowserTest()
  95.  
  96.   Ihandle *txt, *dlg, *web
  97.   Ihandle *btLoad, *btReload, *btBack, *btForward, *btStop
  98.  
  99.   IupWebBrowserOpen()              
  100.  
  101.   // Creates an instance of the WebBrowser control
  102.   web = IupWebBrowser()
  103.  
  104.   // Creates a dialog containing the control
  105.   'from bottom up
  106.  'controls
  107.  btBack = IupButton("Back", NULL)
  108.   btForward = IupButton("Forward", NULL)
  109.   txt = IupText("")
  110.   btLoad = IupButton("Load", NULL)
  111.   btReload = IupButton("Reload", NULL)
  112.   btStop = IupButton("Stop", NULL)
  113.  
  114.   'container show horizontally
  115.  hbox = IupHbox(btBack, btForward, txt, btLoad, btReload, btStop, NULL)
  116.   'container show vertically hbox and webbrowser
  117.  vbox = IupVbox(hbox, web, NULL)              
  118.  
  119.   'final dialog                
  120.  dlg = IupDialog(vbox)
  121.  
  122.   IupSetAttribute(dlg, "TITLE", "IupWebBrowser")
  123.   zstring ptr ptxt at txt
  124.   IupSetAttribute(dlg, "MY_TEXT", ptxt)  
  125.   zstring ptr pweb at web
  126.   IupSetAttribute(dlg, "MY_WEB", pweb)
  127.  
  128.   IupSetAttribute(dlg, "RASTERSIZE", "800x600")
  129.   IupSetAttribute(dlg, "MARGIN", "10x10")
  130.   IupSetAttribute(dlg, "GAP", "10")
  131.  
  132.    //IupSetAttribute(pweb, "HTML", "<html><body><b>Hello</b>World!</body></html>")
  133. //   IupSetAttribute(ptxt, "VALUE", "My HTML")
  134. ''  IupSetAttribute(ptxt, "VALUE", "http://www.tecgraf.puc-rio.br/iup")
  135.  IupSetAttribute(ptxt, "VALUE", "http://www.oxygenbasic.org")  
  136. //  IupSetAttribute(ptxt, "VALUE", "file:///D:/tecgraf/iup/html/index.html")
  137.   IupSetAttribute(pweb, "VALUE", IupGetAttribute(ptxt, "VALUE"))
  138.  
  139.   IupSetAttributeHandle(dlg, "DEFAULTENTER", btLoad)
  140.   IupSetAttribute(txt, "EXPAND", "HORIZONTAL")
  141.  
  142.   IupSetCallback(btLoad, "ACTION", @load_cb)
  143.   IupSetCallback(btReload, "ACTION", @reload_cb)
  144.   IupSetCallback(btBack, "ACTION", @back_cb)
  145.   IupSetCallback(btForward, "ACTION", @forward_cb)
  146.   IupSetCallback(btStop, "ACTION", @stop_cb)
  147.  
  148.   IupSetCallback(web, "NEWWINDOW_CB", @newwindow_cb)
  149.   IupSetCallback(web, "NAVIGATE_CB", @navigate_cb)
  150.   IupSetCallback(web, "ERROR_CB", @error_cb)
  151.   IupSetCallback(web, "COMPLETED_CB", @completed_cb)
  152.  
  153.   // Shows dialog
  154.   IupShow(dlg)
  155. end sub
  156.  
  157. sub main()
  158.  
  159.   IupOpen(0,0)
  160.   WebBrowserTest()
  161.   IupMainLoop()
  162.   IupClose()
  163.  
  164. end sub
  165.  
  166. main()


.
Title: Re: Working with IUP
Post by: Arnold on September 08, 2016, 04:30:09 AM
Hi Charles,

Oxygenbasic works very well with IUP. And if I add a path to the IUP dlls there is no problem to work with dependent dlls like iupweb.dll which calls iupole.dll or e.g iupcontrols.dll which is dependent on iupcd.dll, cd.dll, zlib1.dll and freetype6.dll.

As O2 works so nice with IUP 32-bit, I tried to replace IUP.dll with IUP.dll 64-bit on my 64-bit Windows 10. But this time Oxygen refuses to load  IUP.dll no matter if I use a path for the dlls or if I try the way in projectsB\IUP. I tried with Win64_dll10, compiled with VC10 and Win64_dllw4, compiled with mingw.

I am not sure if O2 is not suited for the IUP 64-bit dlls or if there are some additional aspects which must be noted? The IUP download pages states: for 64-bits systems using the x64 standard. I suppose I do not even know the 32-bit standard.

Roland
Title: Re: Working with IUP
Post by: JRS on September 08, 2016, 10:14:50 AM
FWIW, I have used 64 bit Windows IUP with Script BASIC 64 bit using TDMGCC 32/64. Using Microsoft's VC10 for 64 bit was a can of worms. IMO





Title: Re: Working with IUP
Post by: Charles Pegge on September 09, 2016, 02:14:36 AM
Hi Roland,

To use the 64 bit DLLs You will need to compile your programs to independent 64bit EXEs, using RTL64.inc. The o2 dynamic run-time is limited to 32-bit, since oxygen.dll itself is 32bit

PS:

You will also need to remove cdecl from the extern statements.
Title: Re: Working with IUP
Post by: Arnold on September 09, 2016, 03:46:16 AM
Hi Charles,

thank you. Now I understand. And creating an executable with RTL64.inc and commenting out the cdecl calling convention worked very fine. But before I continue trying out the 64bit possibilities, I will have to set up my Win 10 notebook a little bit. At the moment I feel uncomfortable with it.

Out of curiosity: as FreeBasic 1.05 exits for 64-bit systems too, would it be also possible to create oxygen.dll for x64 systems? I did not even try to spy at the source code of Oxygen, and I will not do this until I understand at least more of Oxygen's provided include files.

Roland
Title: Re: Working with IUP
Post by: Charles Pegge on September 10, 2016, 02:16:39 AM
Hi Roland,

Yes, I think it would be possible to create a 64bit oxygen.dll using 64bit FB. This would require a complete rewrite of o2runt.bas and parts of o2hdrs.bas, and any other sections containing assembler.