Author Topic: Working with IUP  (Read 13291 times)

0 Members and 2 Guests are viewing this topic.

Arnold

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

JRS

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



Charles Pegge

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

JRS

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

Arnold

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


.

Arnold

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


JRS

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

Charles Pegge

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

Arnold

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

.

JRS

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

Arnold

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


.

Aurel

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

JRS

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



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$

Aurel

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

Charles Pegge

  • Guest
Re: Working with IUP
« Reply #29 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)
« Last Edit: September 03, 2016, 11:49:38 PM by Charles Pegge »