Alternative GUI libraries with PureBasic ?

Everything else that doesn't fall into one of the other PB categories.
agb2008
User
User
Posts: 60
Joined: Fri Jan 15, 2016 2:22 pm

Re: Alternative GUI libraries with PureBasic ?

Post by agb2008 »

Playing around with IUP library I could confirm that in most cases to get UTF-8 strings working one would have to set

IupSetGlobal("UTF8MODE",YES")

just after primary IUP toolkit initialization function:

IupOpen()

But... I was unable to get UTF8 strings working for example with IupFileDlg() function... :?

Also was unable to find a solution how to return string value from IupGetAttribute function.

As for positive findings - I was able to compile all libraries from source using MinGW/MinGW64 on Windows platform
to static / dynamic libraries. Looks like there is an issue using such libraries with PureBasic: if i use them - PB
could compile and create an executable file that i could run lately. But if I try to compile and run from within PureBasic
IDE it's crashing while using .dll files generated by MinGW compiler.
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Re: Alternative GUI libraries with PureBasic ?

Post by hallodri »

IupGetAttribute gives a pointer on a string back. The simple way is a Macro :

Code: Select all

PrototypeC  Icallback(*ih.Integer)

ImportC "iup.lib"
  IupOpen()
  IupMainLoop()
  IupClose()     
  IupButton(title.p-utf8, action.p-utf8)
  IupCbox(*handle, a=0, b=0, c=0)  ;(...)
  IupSetAttribute(*handle, name.p-utf8, value.p-utf8)
  IupSetAttributes(*handle, str.p-utf8)
  IupDialog(*handle)
  IupPopup(*handle, x.l, y.l)
  IupStoreGlobal(*name, value.p-utf8)
  IupGetGlobal(name.p-utf8)
  IupSetGlobal(name.p-utf8, value.p-utf8)
  IupGetAttribute(*ih, name.p-utf8)
  IupGetAttributes(*ih)
  IupSetCallback(ih, name.p-utf8, *func)
  IupSetFunction(*name.p-utf8, *func)
  IupDestroy(ih)
  IupMessage(t.p-utf8, msg.p-utf8)
  IupFileDlg()
  IupGetInt.l(ih, t.p-utf8)
EndImport

Procedure.s IupGetAttribute2(i, s.s)
  Protected result = IupGetAttribute(i, s)  
  Protected ss.s = Space(MemoryStringLength(result, #PB_Ascii) *2)  
  If result        
    PokeS(@ss,PeekS(result,-1,#PB_Ascii),-1,#PB_Unicode)
    ProcedureReturn ss
  EndIf  
  ProcedureReturn ""
EndProcedure

Macro IupGetAttribute(a, b)
  IupGetAttribute2(a, b)
EndMacro

#IUP_CENTER =  $FFFF
#IUP_CLOSE  =  -3

Procedure main()  
	
  IupOpen()  
  
  IupSetGlobal("UTF8AUTOCONVERT", "YES")
	IupSetGlobal("UTF8MODE","YES")
	
	filedlg = IupFileDlg()
 
	IupSetAttributes(filedlg, ~"DIALOGTYPE=SAVE, TITLE=\"File Save\", FILTER=\"*.*\", FILTERINFO=\"Bitmap Files\"")	
	
  IupPopup(filedlg, #IUP_CENTER, #IUP_CENTER)
  
  a = IupGetInt(filedlg, "STATUS")
  
  Select IupGetInt(filedlg, "STATUS")
  
    Case 1: 
      IupMessage("New file",IupGetAttribute(filedlg, "VALUE")) 
    Case 0 : 
      IupMessage("File already exists",IupGetAttribute(filedlg, "VALUE"))
    Case -1 : 
      IupMessage("IupFileDlg","Operation Canceled");
  EndSelect

  IupDestroy(filedlg)
  IupClose()
	
EndProcedure:main()
agb2008
User
User
Posts: 60
Joined: Fri Jan 15, 2016 2:22 pm

Re: Alternative GUI libraries with PureBasic ?

Post by agb2008 »

hallodri:

Thank you again ! Your solution works and solves issue that i mentioned.
I still do not understand why IupSetAttribute function works for IupVBox/IupCBox
container types and the same function just does not work for IupFileDlg

BTW - I've contacted developers of IUP toolkit and they said that only UTF8MODE setting
is needed for IUP to work with UTF8 strings. I as well checked that by commenting
UTF8AUTOCONVERT setting and could confirm that it's working fine with only one
global setting:

Code: Select all

IupSetGlobal("UTF8MODE","YES")
BTW: if you type a new name of the file (to make sure that it does not exist - what result you got ?
In my case unfortunately just one single char from file path displayed instead of full path name... :?
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Re: Alternative GUI libraries with PureBasic ?

Post by hallodri »

agb2008 wrote: I still do not understand why IupSetAttribute function works for IupVBox/IupCBox
container types and the same function just does not work for IupFileDlg
I did not understand. For some functions, it seems to work, while others do not.
agb2008 wrote: BTW: if you type a new name of the file (to make sure that it does not exist - what result you got ?
In my case unfortunately just one single char from file path displayed instead of full path name... :?
In ASCII mode? IupGetAttribute2 is only for the Unicode mode. For ASCII must extend the function:

Code: Select all

Procedure.s IupGetAttribute2(i, s.s)
  Protected result = IupGetAttribute(i, s)  
  CompilerIf #PB_Compiler_Unicode 
  Protected ss.s = Space(MemoryStringLength(result, #PB_Ascii) *2)  
  If result        
    PokeS(@ss,PeekS(result,-1,#PB_Ascii),-1,#PB_Unicode)
    ProcedureReturn ss
  EndIf  
  CompilerElse
  If result           
    ProcedureReturn PeekS(result)
  EndIf    
  CompilerEndIf
  ProcedureReturn ""
EndProcedure
agb2008
User
User
Posts: 60
Joined: Fri Jan 15, 2016 2:22 pm

Re: Alternative GUI libraries with PureBasic ?

Post by agb2008 »

hallodri:

I've posted few additional notes in a separate forum section: http://www.purebasic.fr/english/viewtop ... 30#p490330

It seems that IupSetStrAttribute function could be used instead of IupSetAttribute for UNICODE (UTF-8) strings.
Post Reply