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 »

hallodri:

Thank you for suggestion. I would try to that method. But so far unfortunately I was unable to make static library solution (that you mentionedin your post)
to work on my Windows x64 system. Tested with msvc10 and gcc4 static libraries provided by IUP project on Sourceforge site (for IUP 3.18 64 bit) but without
any luck so far.
Experiments (quick ones) with shared libraries allowed me to successfully create very basic window - but unfortunately it completely ignored settings (size, position, color e.t.c.) that I was trying to set. But it was just first attempt. :?
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 »

Ok, a small example (x64 & unicode with IUP 3.18) :

Download this :
https://sourceforge.net/projects/iup/fi ... p/download
https://sourceforge.net/projects/imtool ... p/download
https://sourceforge.net/projects/canvas ... p/download

Extract only the dynamic libraries in a folder and create new pb file in this folder :

Code: Select all

OpenConsole()

#POLIB = "C:\Program Files\PureBasic\Compilers\polib.exe"

If ExamineDirectory(0, "", "*.dll")
  
  While NextDirectoryEntry(0)
    name.s = DirectoryEntryName(0)
    name = Left(name, Len(name) - 4)    
    RunProgram(#POLIB, name + ".dll /MACHINE:X64 /out:" + name + ".lib", "", #PB_Program_Wait)  
    PrintN(name)
  Wend
  
  FinishDirectory(0)
EndIf
PrintN("")
PrintN("Finish!!")
Input()
This code generated the new import libraries.

Create new pb file with this example :

Code: Select all

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)
  IupShowXY(*handle, x.l, y.l)
EndImport

#IUP_CENTER =         $FFFF

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure main()  
	
	IupOpen()  
	
	button 	= IupButton("Button", #Null$)
	cbox 		= IupCbox(button) 
	
	IupSetAttribute(cbox, "EXPAND", "YES")	
	IupSetAttributes(button, "CX=100, CY=100")
	
	dlg = IupDialog(cbox)
	
	IupSetAttribute(dlg, "RASTERSIZE", "800x600")
	
	IupShowXY(dlg, #IUP_CENTER, #IUP_CENTER)
	
	IupMainLoop()
	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:

Fantastic ! :D Thank you very much for your hint ! Extreemly useful !
agb2008
User
User
Posts: 60
Joined: Fri Jan 15, 2016 2:22 pm

Re: Alternative GUI libraries with PureBasic ?

Post by agb2008 »

hallodri:

One additional question for static libraries case: in iuppplot.pbi and iupscintilla.pb files there is a reference to the libcp.lib library
which is imported - but I can't find that lib... Could you please advice ?

Without it I am getting a number of POLINK errors:

---cut---
POLINK: error: Unresolved external symbol '__vsnprintf'.
POLINK: error: Unresolved external symbol '__assert'.
POLINK: error: Unresolved external symbol '__security_cookie'.
POLINK: error: Unresolved external symbol '__security_check_cookie'.
POLINK: error: Unresolved external symbol '__GSHandlerCheck'.
POLINK: error: Unresolved external symbol 'vsnprintf'.
POLINK: error: Unresolved external symbol 'IID_ITaskList3'.
...
POLINK: fatal error: 10 unresolved external(s).
---cut---

PureBasic 5.41 LTS (Windows - x64), IUP 3.18 (Win64_vc10_lib), CD 5.9 (Win64_vc10_lib), IM 3.10 (Win64_vc10_lib)
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 »

I have compiled the libraries. I have no solution for you. :(
agb2008
User
User
Posts: 60
Joined: Fri Jan 15, 2016 2:22 pm

Re: Alternative GUI libraries with PureBasic ?

Post by agb2008 »

Problem solved. Wrong function used. To get correct support for UTF8 UNICODE strings in IUP one have to use:

Code: Select all

IupSetGlobal("UTF8MODE", "YES")
So - please disregard the rest of my post. :D

I've started to play with IUP libraries (thanks to hallodri), but immediately got following issue (which is a bit critical for me):
for some strange reason I can't use UTF8 strings with IUP... I.e. text or button labels e.t.c. According to IUP developers website
this toolkit suppose to support UTF8. So after digging around documentation I've found that there is special global setting:
"UTF8MODE" that have to be set to "YES", right after IupOpen. I did so:

Code: Select all

IupStoreGlobal("UTF8MODE", "YES")
and I could see that this setting accepted, by checking it using:

Code: Select all

Debug IupGetGlobal("UTF8MODE")
But... I can't get my non-ASCII text in UTF8 encoding displayed correctly. It looks like some type of wrong "encoding conversion" done.
I've checked different fonts as well (with support for UTF8 encoding) - but ... :(
agb2008
User
User
Posts: 60
Joined: Fri Jan 15, 2016 2:22 pm

Re: Alternative GUI libraries with PureBasic ?

Post by agb2008 »

I've done some additional tests with IUP libraries over the weekend - overall I like solutions that they propose,
but got following "new" issue (that was probably already mentioned):

If I use pb solution made for 3.7 version of IUP libs with modern version of 3.18 IUP libs - all samples works fine,
but only if I disable "Create unicode executable" in PureBasic...

If I switch "Create unicode executable" option on - then I could still compile code, but all the parameters and callbacks
would not work.

I've tried to adjust definitions of functions to use "p-utf8" - based on samples provided by hallodri in this post, but still
was unable to make callbacks working if compiling in unicode mode... :?
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: Alternative GUI libraries with PureBasic ?

Post by HanPBF »

http://webserver2.tecgraf.puc-rio.br/iup/
IUP does not have a wide localization feature, it only includes support for messages in English and Portuguese. And it does not have support for Unicode characters.
But I think that means the overall framework internal.
PB has functions to switch from unicode to ASCII and vice versa to finally be able to call the IUP functions.

Is that Correct?

Thanks!
agb2008
User
User
Posts: 60
Joined: Fri Jan 15, 2016 2:22 pm

Re: Alternative GUI libraries with PureBasic ?

Post by agb2008 »

HanPBH:

I was able to use UNICODE strings for some of IUP controls by setting global variable "UTF8MODE" to "YES" and as well
adjusting definitions of functions that I am calling from .dll shared libraries (right now only tests were done on Windows platform
but I plan to test on Linux as well). In these calls I used prototypes to define function parameters and some functions seems to work
with unicode strings - but others just stop to function normally. If I switch off option in PureBasic to compile in unicode mode - then
IUP functions works fine, but without unicode support, if I switch this option back on - then I've got only some functions working :-(

P.S. In general authors of this GUI state that full unicode support planned in one of the upcoming releases - but it seems that this option
is not on top of priority list. If I understood correctly unicode support already exist for Linux libraries, because GTK functions seems to
support unicode by default. :?
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 »

Can you upload a example?
agb2008
User
User
Posts: 60
Joined: Fri Jan 15, 2016 2:22 pm

Re: Alternative GUI libraries with PureBasic ?

Post by agb2008 »

hallodri:

I am using examples that you actually provided with small changes:

iuplib_demo.pb:

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)
  IupShowXY(*handle, x.l, y.l)
  IupStoreGlobal(*name, value.p-utf8)
  IupGetGlobal(*name)
  IupSetGlobal(name.p-utf8, value.p-utf8)
  IupGetAttribute(*ih, name.p-utf8)
  IupGetAttributes(*ih)
	IupSetCallback(*ih.Integer, *name.Integer, func.Icallback)
	IupSetFunction(*name.p-utf8, *func)
EndImport

#IUP_CENTER =         $FFFF
#IUP_CLOSE =      -3

Procedure button_action(*self)
  Debug "Exit"
  ProcedureReturn #IUP_CLOSE
EndProcedure

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure main()
  
   
   
  IupOpen()
  
  IupSetGlobal("UTF8MODE", "YES")
    
   button    = IupButton("Это просто кнопка", "NULL")
   cbox      = IupCbox(button) 
     
   IupSetAttribute(cbox, "EXPAND", "YES")   
   IupSetAttributes(button, "CX=200, CY=300")
   IupSetAttribute(button, "FONT", "Times, Bold 18" )
   IupSetCallback(button, "ACTION", @button_action())
   
   dlg = IupDialog(cbox)
   
   IupSetAttribute(dlg, "TITLE", "Hello World !");
   IupSetAttribute(dlg, "RASTERSIZE", "800x600")

   IupShowXY(dlg, #IUP_CENTER, #IUP_CENTER)
   
   IupMainLoop()
   IupClose()   
   
EndProcedure:main()
If I compile this example in ASCII mode - then I've got button callback working but all UNICODE staff lost.
If I use UNICODE mode - unicode labels displayed correctly, but callback not working.

After a bit of experiments I've got:

iuplib_demo1.pb

Code: Select all

PrototypeC  Icallback(*ih.Integer)

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

#IUP_CENTER =         $FFFF
#IUP_CLOSE =      -3

Procedure button_action(*self)
  Debug "Exit"
  ProcedureReturn #IUP_CLOSE
EndProcedure

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure main()
   
  IupOpen()
  
  IupSetGlobal("UTF8MODE", "YES")
  IupSetGlobal("DEFAULTFONT", "Times, Bold 10")
    
   button    = IupButton("Кнопка", "#NULL")
 
   IupSetAttributes(button, "CX=200, CY=300")
   IupSetAttribute(button, "FONT", "Times, Bold 10" )
   IupSetAttribute(button, "SIZE", "200x" )
   IupSetCallback(button, "ACTION", @button_action())
   
   cbox      = IupCbox(button)
   IupSetAttribute(cbox, "EXPAND", "YES") 
   
   dlg = IupDialog(cbox)
   
   IupSetAttribute(dlg, "FONT", "Times, Bold 10" )
   IupSetAttribute(dlg, "TITLE", "Привет мир !");
   IupSetAttribute(dlg, "RASTERSIZE", "800x600")

   IupShowXY(dlg, #IUP_CENTER, #IUP_CENTER)
   
   IupMainLoop()
   IupClose()   
   
EndProcedure:main()
This time button callback working even if compiled in UNICODE mode, but main window title can't be set at all.
If I use ASCII mode and pass window title as pointer to ASCII string - then it's working...

Provided above samples tested with PureBasic 5.41/5.42 on Windows 64 bit. Libraries were created using method suggested by you.

P.S. As a side note - I've tested on to different workstations with Windows 10 x64 Pro. In one case I was able to get UNICODE button
label as presented in sample code above. But on second one that method was not working and I've got correct results only after changing
IupButton function definition to:

Code: Select all

 IupButton(title.p-ascii, action.p-ascii)
Which is a bit strange. :?

P.P.S. Probably a separate thread have to be created dedicated to just these libs: IUP, CD and IM ?
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 »

Try this :

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)
  IupShowXY(*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)
EndImport

#IUP_CENTER =  $FFFF
#IUP_CLOSE  =  -3

Procedure button_action(*self)
  Debug "Exit"
  ProcedureReturn #IUP_CLOSE
EndProcedure

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure main()
  
  IupOpen()
  
  IupSetGlobal("UTF8AUTOCONVERT", "YES") ;<=============================================
  IupSetGlobal("UTF8MODE", "YES")  
  IupSetGlobal("DEFAULTFONT", "Times, Bold 10")
  
  button = IupButton("Кнопка", "#NULL")
  cbox   = IupCbox(button)
  dlg    = IupDialog(cbox)
  
  IupSetAttributes(button, "CX=200, CY=300")
  IupSetAttribute(button, "FONT", "Times, Bold 10")
  IupSetAttribute(button, "SIZE", "200x200")  
  IupSetAttribute(cbox, "EXPAND", "YES") 
  IupSetAttribute(dlg, "FONT", "Times, Bold 10")
  IupSetAttribute(dlg, "TITLE", "Привет мир !")
  IupSetAttribute(dlg, "RASTERSIZE", "800x600")
  
  IupSetCallback(button, "ACTION", @button_action())
  
  IupShowXY(dlg, #IUP_CENTER, #IUP_CENTER)
  
  IupMainLoop()
  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:

Thanks for suggestion. Unfortunately, in my case it's not working for main application window title. For non-unicode case (using older bindings that you suggested) I could set window title - but only in ASCII and as well only if I compile application in non-unicode mode. :?

P.S. I've created a separate dedicated topic for IUP / CD / IM libraries usage with PureBasic here.

P.P.S. If I am not mistaken - you mentioned that you was able to compile these libraries from source - could you please share your experience ? Instructions in toolkits documentation are very generic and seems that there were some changes done in the tecmake model that makes compilation part a bit more complicated. :) (I am talking about Windows platform - for Linux it seems a bit easier)
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 »

That worked fine yesterday :? Can you set the title after IupShowXY ?
agb2008 wrote: P.P.S. If I am not mistaken - you mentioned that you was able to compile these libraries from source - could you please share your experience ? Instructions in toolkits documentation are very generic and seems that there were some changes done in the tecmake model that makes compilation part a bit more complicated. :) (I am talking about Windows platform - for Linux it seems a bit easier)

That 's been 3 years, but I'm trying to create something soon .
agb2008
User
User
Posts: 60
Joined: Fri Jan 15, 2016 2:22 pm

Re: Alternative GUI libraries with PureBasic ?

Post by agb2008 »

hallodri:

A bit strange... If I use IupSetAttribute function to set TITLE value before calling IupShowXY - then it's not working correctly...
But if I do exactly the same, but after calling IupShowXY - it worked with both ASCII and UNICODE strings ! :D

I also tried to use IupSetAttributes function defined as: IupSetAttributes(*handle, str.p-utf8)

IupSetAttributes(dlg, "FONT=Arial, TITLE=_Привет")

Then it also could work (a bit) before or after IupShowXY - but for UNICODE string it would work only if first char in that string is ASCII,
like one '_' in the example above. If I remove it - then nothing would be displayed for UNICODE string. :?
Post Reply