Author Topic: need O2 IUP translation  (Read 8149 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3721
    • Oxygen Basic
Re: need O2 IUP translation
« Reply #30 on: August 09, 2012, 01:04:09 PM »
James,

I declare your machine haunted by the Ghost of Oxygen.dll past :). It's hiding in there somewhere.

All I can suggest is replacing '!' with 'declare function', and see if it accepts everything else. (This feature was introduced 3 June, 1 month prior to the A039 release)

If it is still using the old dll then a substantial number of the examples & projects will appear broken.

Charles
« Last Edit: August 09, 2012, 01:23:46 PM by Charles Pegge »

Peter

  • Full Member
  • ***
  • Posts: 161
Re: need O2 IUP translation
« Reply #31 on: August 09, 2012, 03:29:12 PM »
Hi,

Quote
I then deleted the oxygen.dll and tried again.
I then got a can't find oxygen.dll popup.

Lol

Try this dll.

X

jcfuller

  • Full Member
  • ***
  • Posts: 143
Re: need O2 IUP translation
« Reply #32 on: August 10, 2012, 03:12:51 AM »
Charles,
It is not a dll issue. I have the latest oxygen.dll. There are no ghosts
 I think some non printable characters are being copied and pasted.

Please attach a working example source.

James
 


Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3721
    • Oxygen Basic
Re: need O2 IUP translation
« Reply #33 on: August 10, 2012, 04:30:54 AM »
Hi James,

I checked the forum copy/paste and it was ok.

Attached here:

X

jcfuller

  • Full Member
  • ***
  • Posts: 143
Re: need O2 IUP translation
« Reply #34 on: August 10, 2012, 04:48:25 AM »
Ok, I figured a couple of things out.
As Peter did not know where he got his dll I tried one of  the "official" ones from the IUP sourceforge 3.6 downloads.

I tried:
http://sourceforge.net/projects/iup/files/3.6/Windows%20Libraries/Dynamic/iup-3.6_Win32_dllw4_lib.zip/download
and it worked fine.

This code compiles and runs fine.
The secret was the IupOpen declaration.
I checked The FreeBasic iup.bi and it had it with no parameters.

Code: [Select]
extern lib "\iup_dllw4\iup.dll" cdecl
! IupOpen()
! IupClose()
! IupMessage(string title, string msg)
end extern

IupOpen()
IupMessage("IupMessage Example", "Press the button")
IupClose()


I have not tried your upload yet.
I will try next

James


 

jcfuller

  • Full Member
  • ***
  • Posts: 143
Re: need O2 IUP translation
« Reply #35 on: August 10, 2012, 05:00:17 AM »
The problem was the IupOpen.
This compiles and runs fine.
I used
http://sourceforge.net/projects/iup/files/3.6/Windows%20Libraries/Dynamic/iup-3.6_Win32_dllw4_lib.zip/download

James


Code: [Select]

%IUP_CLOSE = -3
%IUP_ERROR = 1


extern lib "\iup_dllw4\iup.dll" cdecl
! IupOpen()
! IupCreate(string cname) as sys
! IupClose         ()
! IupSetAttributes (sys ih,string strz) as sys
! IupAppend        (sys ih, child) as sys
! IupRefresh       (sys ih)
! IupSetCallback   (sys ih,string sname, sys func) as sys
! IupShow          (sys ih) as sys
! IupSetFocus      (sys ih) as sys
! IupMainLoop      ()

end extern

extern cdecl

'Exit Button Callback
function quit_cb() as sys
  function = %IUP_CLOSE
end function


'Helper functions
'================



sub AddChild(sys *parent, *child)
  IupAppend parent,child
  IupRefresh parent
end sub


function Create ( string Value ,Attr ,sys parent) as sys
  sys hWnd
  hWnd = IupCreate(Value)
  If hWnd Then
    If Len(Attr)
      IupSetAttributes(hWnd,Attr)
    End If
    If parent
      AddChild parent,hWnd
    End If   
    Function = hWnd
  End If   
end function

function main () as sys
  long rv As long
  sys  win,vbox,topBox,serverFrame,serverBox,serverCombo,btnFetch,controlFrame,
       controlBox,btnAbout,btnClear,btnExit,dictFrame,serverList,transFrame,
       text,bottomBox,label,entry,btnSearch,chkAll,chkUTF
  'Initialize IUP     
  IupOpen()

   
  'Create Main Window
  win = Create("dialog","TITLE=Thesaurus, SIZE=500x300",0)
  'create container to house ALL GUI objects
  vbox = Create("vbox","MARGIN=10x10",0)
  'Create Server panel
  topBox = Create("hbox", " GAP=10", vbox)
  serverFrame = Create("frame", "TITLE=Servers, EXPAND=YES", topBox)
  serverBox= Create("hbox", "GAP=5", serverFrame)
  serverCombo = Create("list", "DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1", serverBox)
  btnFetch = Create("button", "TITLE=Fetch, SIZE = 50x", serverBox)
  'Create control panel
  controlFrame = Create("frame", "TITLE=Controls", topBox)
  controlBox = Create("hbox", "Margin=6x6, GAP=5", controlFrame)
  btnAbout = Create("button", "TITLE=About, SIZE = 50x", controlBox)
  btnClear = Create("button", "TITLE=Clear, SIZE = 50x", controlBox)
  btnExit = Create("button", "TITLE=Exit, SIZE = 50x", controlBox)
  'SETUP CALLBACK FOR EXIT BUTTON
  IupSetCallback(btnExit, "ACTION", @quit_cb)
  'Create dictionary panel
  dictFrame = Create("frame", "TITLE=Dictionaries", vbox)
  serverList = Create("list", "EXPAND=YES, VISIBLELINES=1", dictFrame)
  'Create text part
  transFrame = Create("frame", "TITLE=Translation", vbox)
  text = Create("text", "MULTILINE=YES, EXPAND=YES", transFrame)
  'Create entry and search button
  bottomBox = Create("hbox", "GAP=10", vbox)
  label = Create("label", "TITLE=Enter Word to Search For: , SIZE=x12", bottomBox)
  entry = Create("text", " EXPAND=HORIZONTAL",bottomBox)
  btnSearch = Create("button","TITLE=Search, SIZE=50x", bottomBox)
  chkAll = Create("toggle", "TITLE=ALL, VALUE=ON,SIZE=x12", bottomBox)
  chkUTF = Create("toggle", "TITLE=UTF-8, SIZE=x12", bottomBox)
  '       
  'Add the main GUI container to the Window
  AddChild(win, vbox)
  'Show the Window
  IupShow(win)
  IupSetFocus(btnFetch)
  IupMainLoop()
  IupClose()
end function

main




 

Peter

  • Full Member
  • ***
  • Posts: 161
Re: need O2 IUP translation
« Reply #36 on: August 10, 2012, 05:24:17 AM »
Hi Charles,

Another iup demo.

Code: [Select]
#define IUP_TITLE  "TITLE"

%IUP_CLOSE = -3 
%IUP_ERROR = 1 

enum { IUP_DRAW_FILL, IUP_DRAW_STROKE, IUP_DRAW_STROKE_DASH }

typedef struct Ihandle_ {}
Ihandle_ Ihandle
typedef int (*Icallback)(Ihandle*)
typedef struct _IdrawCanvas {}
_IdrawCanvas IdrawCanvas

! IupOpen             Lib "iup.dll" (sys argc,argv) as sys 
! IupCreate           Lib "iup.dll" (string cname) as sys 
! IupSetAttributes    Lib "iup.dll" (sys ih,string strz) as sys 
! IupAppend           Lib "iup.dll" (sys ih, child) as sys 
! IupRefresh          Lib "iup.dll" (sys ih) 
! IupSetCallback      Lib "iup.dll" (sys ih,string sname, sys func) as sys 
! IupShow             Lib "iup.dll" (sys ih) as sys 
! IupShowXY           Lib "iup.dll" (Ihandle *ih, sys x, sys y) as sys
! IupSetFocus         Lib "iup.dll" (sys ih) as sys 
! IupRecordInput      Lib "iup.dll" (string *filename, sys mode) as sys
! IupPlayInput        Lib "iup.dll" (string *filename) as sys
! IupMainLoop         Lib "iup.dll" () as sys
! IupImageLibOpen     Lib "iup.dll" () as sys
! IupLoopStep         Lib "iup.dll" () as sys
! IupLoopStepWait     Lib "iup.dll" () as sys
! IupMainLoopLevel    Lib "iup.dll" () as sys
! IupClose            Lib "iup.dll" ()
! IupFlush            Lib "iup.dll" ()
! IupExitLoop         Lib "iup.dll" ()
! IupUpdate           Lib "iup.dll" (Ihandle *ih)
! IupUpdateChildren   Lib "iup.dll" (Ihandle *ih)
! IupRedraw           Lib "iup.dll" (Ihandle *ih, sys children)
! IupRefresh          Lib "iup.dll" (Ihandle *ih)
! IupRefreshChildren  Lib "iup.dll" (Ihandle *ih) 
! IupMapFont          Lib "iup.dll" (string *iupfont) as string
! IupUnMapFont        Lib "iup.dll" (string *driverfont) as string
! IupHelp             Lib "iup.dll" (string url) as sys
! IupLoad             Lib "iup.dll" (string *filename) as string
! IupLoadBuffer       Lib "iup.dll" (string *buffer) as string
! IupVersion          Lib "iup.dll" () as string
! IupVersionDate      Lib "iup.dll" () as string
! IupVersionNumber    Lib "iup.dll" () as sys
! IupSetLanguage      Lib "iup.dll" (string *lng)
! IupGetLanguage      Lib "iup.dll" () as string

! iupDrawCreateCanvas Lib "iup.dll" (Ihandle *ih) as sys
! iupDrawKillCanvas   Lib "iup.dll" (sys *dc)
! iupDrawFlush        Lib "iup.dll" (sys *dc)
! iupDrawUpdateSize   Lib "iup.dll" (sys *dc)
! iupDrawGetSize      Lib "iup.dll" (sys *dc, *w, *h)
! iupDrawLine         Lib "iup.dll" (sys *dc, x1, y1, x2, y2, byte r, g, b, sys style)
! iupDrawRectangle    Lib "iup.dll" (sys *dc, x1, y1, x2, y2, byte r, g, b, sys style)
! iupDrawArc          Lib "iup.dll" (sys *dc, x1, y1, x2, y2, double a1, a2, byte r, g, b, sys style)
! iupDrawPolygon      Lib "iup.dll" (sys *dc, *points, count, byte r, g, b, sys style)
! iupDrawText         Lib "iup.dll" (sys *dc, string *text, sys len, x, y, byte r, g, b, string *font)
! iupDrawImage        Lib "iup.dll" (sys *dc, string *name, sys make_inactive, x, y, *img_w, *img_h)
! iupDrawSetClipRect  Lib "iup.dll" (sys *dc, x1, y1, x2, y2)
! iupDrawResetClip    Lib "iup.dll" (sys *dc)

! iupDrawRectangleInvert  Lib "iup.dll" (sys *dc, x1, y1, x2, y2)
! iupDrawParentBackground Lib "iup.dll" (sys *dc)

Function quit_cb() as sys 
Function = IUP_CLOSE 
End Function 
 
Sub AddChild(sys *parent, *child) 
    IupAppend parent,child 
    IupRefresh parent 
End Sub 
 
Function Create (string Value ,Attr ,sys parent) as sys 
sys hwnd 
hWnd = IupCreate(Value) 
if hwnd   
if Len(Attr) 
   IupSetAttributes(hwnd,Attr) 
End if 
if parent 
   AddChild parent,hwnd 
End if     
Return hwnd   
End if     
end function 
 
sys canvas, width, height

Function Main() as sys 
IupOpen(0,0)
win = Create("dialog","TITLE=IUP*TEST*PETER, SIZE=300x200",0) 
iupShowXY *win,380,180 
canvas = IupDrawCreateCanvas *win
iupDrawGetSize *canvas, *width, *height 
iupDrawRectangle *canvas, 10, 10, 40, 40, 255, 0, 0, 0
iupDrawRectangle *canvas, 50, 10, 90, 40, 255,255,0, 1
iupDrawRectangle *canvas, 100,10, 140,40, 255,0,255, 2
iupDrawLine *canvas, 0, 100, &width, 100, 0,255,0, 2 
iupDrawFlush *canvas
iupMainLoop() 
iupDrawKillCanvas *canvas
iupClose() 
End Function 
 
Main()

jcfuller

  • Full Member
  • ***
  • Posts: 143
Re: need O2 IUP translation
« Reply #37 on: August 10, 2012, 05:53:36 AM »

Peter's code  compiles and runs fine here with the iup.dll I mentioned above.

Now the question is why do both work??

I see no cdecl in Peter's code

James


X

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3721
    • Oxygen Basic
Re: need O2 IUP translation
« Reply #38 on: August 10, 2012, 08:43:03 AM »
Glad it works now, James.

You can get away with not using cdecl if certain conditions are met to avoid stack overflow.

1 the calls are made inside an o2 procedure.

2 the calls are not iterated or have very few iterations.

If the call has no parameters then there are no restrictions.

Old parameters will accumulate on the stack, but the O2 procedures epilog will restore the stack pointer,  to its correct value.


Charles