Author Topic: Working with IUP  (Read 13288 times)

0 Members and 1 Guest are viewing this topic.

Arnold

  • Guest
Working with IUP
« 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



.

Arnold

  • Guest
Re: Working with IUP
« Reply #1 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;

}

JRS

  • Guest
Re: Working with IUP
« Reply #2 on: August 26, 2016, 10:17:15 AM »
gcc IupGetParam.c -liup -o IupGetParam.exe

Charles Pegge

  • Guest
Re: Working with IUP
« Reply #3 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.

Arnold

  • Guest
Re: Working with IUP
« Reply #4 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

Arnold

  • Guest
Re: Working with IUP
« Reply #5 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
« Last Edit: August 28, 2016, 04:04:08 AM by Arnold »

Arnold

  • Guest
Re: Working with IUP
« Reply #6 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. 

Arnold

  • Guest
Re: Working with IUP
« Reply #7 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

JRS

  • Guest
Re: Working with IUP
« Reply #8 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.

Arnold

  • Guest
Re: Working with IUP
« Reply #9 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.  

Arnold

  • Guest
Re: Working with IUP
« Reply #10 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.  

Arnold

  • Guest
Re: Working with IUP
« Reply #11 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.  


Arnold

  • Guest
Re: Working with IUP
« Reply #12 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.  

Arnold

  • Guest
Re: Working with IUP
« Reply #13 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.  


.

JRS

  • Guest
Re: Working with IUP
« Reply #14 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!

« Last Edit: August 30, 2016, 06:39:41 PM by John »