TinyDialog a simple Windows and Linux user interface.

Post your FreeBASIC tips and tricks here. Please don’t post your code without including an explanation.
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Re: TinyDialog a simple Windows user interface.

Postby 1000101 » Jan 01, 2013 20:19

It would be nice if this was cross platform. A simple clean windows/linux UI interface would be great but I understand the complications and additional requirements of doing so.

As I understand it, the dialogue Show() method is a blocking function? Also, being winapi it should be thread-safe, yes?

Anyway - Nice, clean, simple - Great.
D.J.Peters
Posts: 7862
Joined: May 28, 2005 3:28

Re: TinyDialog a simple Windows user interface.

Postby D.J.Peters » Jan 02, 2013 1:28

1000101 wrote:... A simple clean windows/linux UI interface would be great but I understand the complications and additional requirements of doing so.
Why so pessimistic :-)
It's in the current download.

Joshy
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Re: TinyDialog a simple Windows user interface.

Postby 1000101 » Jan 02, 2013 7:26

D.J.Peters wrote:
1000101 wrote:... A simple clean windows/linux UI interface would be great but I understand the complications and additional requirements of doing so.
Why so pessimistic :-)
It's in the current download.

Joshy



*re-reads thread*...*facepalm* :)


1000101 wrote:As I understand it, the dialogue Show() method is a blocking function? Also, being a native api it should be thread-safe, yes?


No answer so my suspicions are correct?
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: TinyDialog a simple Windows and Linux user interface.

Postby petan » Mar 31, 2013 15:54

Very nice job, using with FBGFX :)
/tested on linux puppy slacko 5.3/
TinyDialog-fbgfx-Test01.bas

Code: Select all

' my using of this nice TinyDialog with FBGFX graphics window...
#include once "TinyDialog.bi"
screen 18
? "started fbgfx graphics.."

'start-TinyDialog window
dim as TinyDialog dlg
var Bool1 = dlg.addBoolean("Exit of program:",0,"no","yes","boolean!")
 dlg.addSeperator "Will be ended ?"
 dlg.show()
'ended-TinyDialog window

? "boolean value is ";
? dlg.GetInteger(Bool1)   'boolean value is
if dlg.GetInteger(Bool1)=1 then
       rem "program ended .. fbgfx graphics .. without sleeping !"
else
       ? "Press a key...to end of program !"
       sleep
end if
end

Thx,
Pete

Image
Last edited by petan on Aug 19, 2013 10:03, edited 3 times in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

TinyDialog - Questions, requests, etc.

Postby petan » Apr 13, 2013 16:23

edited
@ D.J.Peters
How could we destroy variable Bool1 from your example "Test01.bas" ? For next using in another window ?
Just and only Bool1 variable, not all.That job is done via Scope block;)

Q- Is possible to use New and Delete commands ??

Code: Select all

var Bool1 = dlg.addBoolean("boolean:",1,"no","yes","boolean!")


Thx,
Pete

A - after discussion+research. Answer is YES, but destroying is possible via Scope..End scope command, otherwise only zeroed data contents !
See below.
Last edited by petan on Apr 19, 2013 12:51, edited 3 times in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: TinyDialog a simple Windows and Linux user interface.

Postby petan » Apr 14, 2013 13:44

TinyDialog-fbgfx-Test02.bas
simple 2-way switch menu, variables fixed in Scope block

Code: Select all

'second example of using  TinyDialog with FBGFX graphics window...
' tested on linux puppy Slacko 533+FB 0.24+devx_Slacko_533.sfs
#include once "TinyDialog.bi"
screen 17
dim as string NflLive,NhlLive,MlbLive,NbaLive,uLoha,myBrowzer
NflLive="http://www.nfl.com"
NhlLive="http://www.nhl.com"
MlbLive="http://www.mlb.com"
NbaLive="http://www.nba.com"
? "started fbgfx graphics.."
? "testing Bool1 for two windows..."

   'open browser in background
 myBrowzer="seamonkey"      'name of default browser, or absolute path - change to your path if needed
 'myBrowzer="/opt/opera/bin/opera"
 uLoha=myBrowzer+"&"
 Shell uLoha   'browser started

'   start-TinyDialog window #1
dim as TinyDialog dlg
 dlg.Title  = "^^     M E N U      ^^"
'  Bool1 will be used in second window too !
 var Bool1 = dlg.addBoolean("NFL",0,"no","yes","boolean!")

scope
'var Bool1 = dlg.addBoolean("NFL",1,"no","yes","boolean!")
var Bool2 = dlg.addBoolean("NHL",0,"no","yes","boolean!")
var Bool3 = dlg.addBoolean("MLB",1,"no","yes","boolean!")
var Bool4 = dlg.addBoolean("NBA",1,"no","yes","boolean!")
 dlg.show()
'  ended-TinyDialog window #1

'   prog flow logics         
if dlg.GetInteger(Bool1)=1 then          
 uLoha=myBrowzer+" "+NflLive
 ? uLoha
 Shell uLoha
end if
if dlg.GetInteger(Bool2)=1 then          
 uLoha=myBrowzer+" "+NhlLive
 ? uLoha
 Shell uLoha
end if
if dlg.GetInteger(Bool3)=1 then          
 uLoha=myBrowzer+" "+MlbLive
 ? uLoha
 Shell uLoha
end if
if dlg.GetInteger(Bool4)=1 then          
 uLoha=myBrowzer+" "+NbaLive
 ? uLoha
 Shell uLoha
end if
' variables Bool2,Bool3,Bool4 destroyed
end scope
 
'  start-TinyDialog window #2
 dlg.Clear
 dlg.Title  = "Finishing..."
 dlg.addSeperator "^^  Watch up  ^^"
 'var Bool1 = dlg.addBoolean("E X I T   of program:",0,"no","yes","boolean!")
 Bool1 = dlg.addBoolean("E X I T   of program:",0,"no","yes","boolean!")
 dlg.addSeperator "Will be ended ?"
 dlg.show()
'  ended-TinyDialog window #2

'   prog flow logics
if dlg.GetInteger(Bool1)=1 then
   rem "program ended .. fbgfx graphics .. without sleeping !"
   end
end if

 ? "Press a key...to end of program !"
 sleep
end


Pete
Last edited by petan on Apr 18, 2013 23:34, edited 1 time in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: TinyDialog - Questions, requests, etc.

Postby petan » Apr 16, 2013 11:00

edited
Founded solution... Answer is Yes. Var can be constructed with New..Delete command in TinyDialog.
attention - example for integer here. Watch on return value !
http://www.freebasic.net/forum/viewtopic.php?f=3&t=21066

Code: Select all

'     define
var xBool0 =new integer(dlg.addBoolean("someText",0,"no","yes","boolean!"))   'checked-OK
'     setup
*xBool0=dlg.addBoolean("someAnotherText",1,"no","yes","boolean!")   'checked-OK

if dlg.GetInteger(*xBool0)=1 then
    'do some action   'checked-OK
end if
'~~~~~~~~~~~~~~~~~~
'    here was my mistake, I  forgot check status of variable !! after delete
'compiler says no errors
delete xBool0    '  zeroed, but not destroyed !! ,  variable still exists
'~~~~~~~~~~~~~~~~~~
'  if on doubt with New+Delete command, use next two lines for variable status check
? " pointer xBool0= ";xBool0  'if not familiar with command, check what happens
? "data contents on pointer address *xBool0= ";*xBool0  'if not familiar with command, check what happens

Pete
Last edited by petan on Apr 19, 2013 11:10, edited 6 times in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: TinyDialog a simple Windows and Linux user interface.

Postby petan » Apr 16, 2013 15:05

TinyDialog-fbgfx-Test03.bas
- select alphabetical letter from list

Code: Select all

' my using this nice TinyDialog with FBGFX graphics window...
' tested on linux puppy Slacko 533
#include once "TinyDialog.bi"
screen 17: ? "started fbgfx graphics.."
dim as string statySu
dim as string aLetter(1 to 26)
dim as integer iCountr
statySu=""
iCountr=0
for i as integer=65 to 90
  if i <90 then
    statySu+=chr(i)+" | " 
  else
    statySu+=chr(i)+" " 
  end if
  iCountr+=1
  aLetter(iCountr)=chr(i)
next
'? statySu

'   start-TinyDialog window #1
dim as TinyDialog dlg
 dlg.Title  = "^^     M E N U      ^^"
 var List1 = dlg.addList("Letter:",statySu,1,"tip: some letter")
 dlg.show()
'   ended-TinyDialog window #1

? " selected letter is ";aLetter(dlg.GetInteger(List1)+1)
? "Press a key...to end of program !"
sleep
end


Image

Pete
Last edited by petan on Aug 14, 2013 13:01, edited 1 time in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: TinyDialog - Questions, requests, etc.

Postby petan » Apr 16, 2013 19:23

Next question, is TinyDialog able to offer list of 150 country names ?
All in one list - "Andorra, Angola.Azerbayan, ..Czechia.. Germany..USA.., Zambia, Zimbabwe",
or in sublist via first letter of name - "Andorra, Angola.Armenia,Azerbayan" ??

Pete
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: TinyDialog - Questions, requests, etc.

Postby petan » Apr 16, 2013 21:57

edited
Solution is coming.. and Done
TinyDialog-fbgfx-Test04.bas
- select country name from 156 names by first letter.

Code: Select all

' tested on linux puppy Slacko 533
' Searching in one long name list is too slow for me.
declare sub menuLetters(byval xlandsAre as string,byref letrIsID as integer)
declare function menuLands(byval letrStateName as string,byval letrIsID as integer,byval letrIs as string) as integer
#include once "TinyDialog.bi"
screen 18
? "started fbgfx graphics.."

const as integer noLttrs=26      'A-Z how much
dim as string landsAre,xlandsAre,countryIs,letrStateName
dim as string aLetter(1 to noLttrs),groupedCountryName(1 to noLttrs)
dim as string countryName(1 to noLttrs,1 to 6)
dim as integer iCountr,letrIsID
dim as string*1 letrIs

'   generate summary alphabet string
xlandsAre=""
iCountr=0
for i as integer=65 to 90
  if i <90 then
    xlandsAre+=chr(i)+"|" 
  else
    xlandsAre+=chr(i)+" " 
  end if
  iCountr+=1
  aLetter(iCountr)=chr(i)
next
? "xlandsAre= ";xlandsAre

'   here are generated virtual land names - use your real names instead
for i as integer=1 to noLttrs   '26   '156
  for i7 as integer=1 to 6   
   countryName(i,i7)=aLetter(i)+"_land"+str(i7)
  next
next

'   create substrings by first letter - make your REAL things instead
iCountr=0
for i as integer=1 to noLttrs
  for i7 as integer=1 to 6   
   iCountr+=1
   if i7 <6 then
      groupedCountryName(i)+=countryName(i,i7)+"|"   
   else
      groupedCountryName(i)+=countryName(i,i7)+""
   end if   
  next
  ? i,groupedCountryName(i)
next

labelSetIt10:
letrIsID=1
 menuLetters(xlandsAre,letrIsID)   'TinyDialog #1 select letter
letrIs=aLetter(letrIsID)
? " selected letter is ";letrIs,letrIsID

 letrStateName=groupedCountryName(letrIsID)
 '? "letrStateName ";letrStateName
iCountr=0
iCountr=menuLands(letrStateName, letrIsID, letrIs)      'TinyDialog #2 select countryname by this letter
if iCountr<0 then goto labelSetIt10      'change letter
countryIs=countryName(letrIsID,iCountr)    'result

? " *** selected country is ";countryIs," indexes (";letrIsID;",";iCountr;") ***"

?:? "Press a key...to end of program !"
sleep
end

'~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~      menuLetters    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
sub menuLetters(byval xlandsAre as string,byref letrIsID as integer)
'  start-TinyDialog window #1 Letters
dim as TinyDialog dlg
 dlg.Title  = "Country ... by first Letter"
 var List1 = dlg.addList("Letter:",xlandsAre,1,"tip: some letter")
 dlg.show()
 letrIsID=dlg.GetInteger(List1)+1
'   ended-TinyDialog window #1 Letters
end sub
'~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~      menuLands    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
function menuLands(byval letrStateName as string,byval letrIsID as integer,byval letrIs as string) as integer
'  start-TinyDialog window #2 Lands
 dim as TinyDialog dlg2
 dlg2.Title  = "CountryName by "
 var Bool1 = dlg2.addBoolean("Change Letter",0,"no","yes","boolean!")
 var List2 = dlg2.addList("Letter: "+letrIs,letrStateName,1,"tip: some country")
 dlg2.show()

 if dlg2.GetInteger(Bool1)=1 then
   return -1
 else
   return dlg2.GetInteger(List2)+1
 end if
'  ended-TinyDialog window #2 Lands
end function

Image
Last edited by petan on Aug 18, 2013 14:35, edited 6 times in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: TinyDialog a simple Windows and Linux user interface.

Postby petan » Apr 17, 2013 20:17

I have crash at changing font, Test01.bas. Tested on XP no SP.Installed font level unknown, as never changed by me.So maybe I don't have some utility for correct font's functionality.

In linux works all as well.

Pete
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: Bug - TinyDialog - Solved

Postby petan » Jul 03, 2013 11:46

I think I found bug in "TinyDialog.bi"
As shown in example - the first item is written badly without spaces on beginning of text.It's only layout of items, but personally I am preferring spaces as formatter; and this not works for the first item. .
After a small laboring I got it to needed layout with changing 'trim' function to 'rtrim' in these routines of "TinyDialog.bi":

example:

Code: Select all

#Include "fbgfx.bi"
#include once "TinyDialog.bi"
ScreenRes 800,576,32,2,FB.GFX_windowed      
Width 100,36
windowtitle "linuxing now.."
screenset 0,0

'start-TinyDialog window
 dim as TinyDialog dlg
 dlg.Title  = "Actions  ?"
rem various layout checks
 'var List1 = dlg.addList("actions are:","  Ende|  Slitaz 4|  Slacko 533|  Slacko 55",0,"tip: some item")
 'var List1 = dlg.addList("actions are:","Ende| Slitaz 4|  Slacko 533|   Slacko 55",0,"tip: some item")
 'var List1 = dlg.addList("actions are:","Ende|Slitaz 4|Slacko 533|Slacko 55",0,"tip: some item")
 var List1 = dlg.addList("actions are:","   Ende|  Slitaz 4| Slacko 533|Slacko 55",0,"tip: some item") 

 dlg.show()
 
 end
changes in "TinyDialog.bi"

Code: Select all

sub TinyDialog.AddListItems(sListItems as string)
  'sListItems=trim(sListItems):   'old
  sListItems=rtrim(sListItems):   'new
  if len(sListItems) then items &= "|" & sListItems & "|"
end sub

function TinyDialog.AddList(sLabel as string,sListItems as string,bSelected as integer,sToolTip as string) as integer
  'strExtra =trim(sListItems)   'old
  strExtra =rtrim(sListItems)   'new
  if len(strExtra)=0 then strExtra="(none)"
  return AddItem(sLabel,ParamTypes.l,strExtra,sToolTip,@bSelected)
end function
After this (1 char) injection are formatting spaces recognized everywhere on the left side of itemText.

Pete
Image
Last edited by petan on Aug 19, 2013 19:24, edited 2 times in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: TinyDialog a simple Windows and Linux user interface.

Postby petan » Jul 04, 2013 21:21

Also the same problem for separator 'dlg.addSeperator' (unrecognised spaces from left)

Code: Select all

dlg.addSeperator "Bacha 3 !"
dlg.addSeperator " Bacha 4 !"
dlg.addSeperator "  Bacha 5 !"
dlg.addSeperator "^  Bacha   !"
This fix does the job.
changes in "TinyDialog.bi"

Code: Select all

sub TinyDialog.AddText(sText as string)
  'sText=trim(sText):   'old
  sText=rtrim(sText):   'new
  if len(sText) then items &= sText
end sub

Pete
Last edited by petan on Jul 04, 2013 22:56, edited 1 time in total.
counting_pine
Site Admin
Posts: 6174
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: TinyDialog a simple Windows and Linux user interface.

Postby counting_pine » Jul 04, 2013 22:27

Hi,
Just thought I should point out: 'separator' has been misspelled.
You might want to add the correct spelling, and deprecate the existing one.
:)
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: TinyDialog a simple Windows and Linux user interface.

Postby petan » Jul 04, 2013 22:55

It seems me too as a small typo of author, so not sured what was reason to use "Seperator" word in this nice library..

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 2 guests