sGUI

User projects written in or related to FreeBASIC.
Coolman
Posts: 213
Joined: Nov 05, 2010 15:09

Re: sGUI

Postby Coolman » Apr 20, 2019 12:55

interesting. but the examples in version 0.8.60 no longer work...
Muttonhead
Posts: 118
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Apr 20, 2019 16:43

interesting. but the examples in version 0.8.60 no longer work...

is still a piece of work, but the differences between the two versions are not as big as it is impossible.
Mutton
Coolman
Posts: 213
Joined: Nov 05, 2010 15:09

Re: sGUI

Postby Coolman » Apr 20, 2019 18:35

I will soon migrate to linux. I have tested many libraries. sgui would be perfect. I may use it in some projects. version 0.8.60 works well under ubuntu after a few corrections...

the new version works (good job).

for corrections under linux:

replace chr$( by chr(

file name case-sensitive....
ppf
Posts: 73
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » May 20, 2019 14:44

Hi Mutton,

nice new features to see in progress, thank you for your effort !

I plan to use sGui(v.084) gadgets (in interactive graphs) as "bubble" help.
Slowly added ones and small trouble founded.

Say, for example, drawing big resizable (X x Y step) line raster (and a lot of graphs).
When raster crosspoints are hovered, bubble help is shown ( X,Y coordinates of that point, e.g.)
On the fly also raster size can be modified (resized&redrawn from 50x50 to 100x100 e.g and back) to zoom a needed part of graph.
Used many commands "window (x1,y1) -(x2,y2)" in drawing.
For now I have implemented "Messagebox Yes/No" gadget.
I see bad drawing of it after using "window (x1,y1) -(x2,y2)".Flow frozen, program must be killed.
Then founded solution, calling "window" (without parameters) to revert to screen coordinates, before
"MessageBox" command is used.

Code: Select all

 window: MessageBox(parameters list)

So the question is:
"Can sGui solve this behavior internally, in some way ?"
E.g., including "window" into all gadgets ??

Maybe stupid question, so excuse me; I see only one gadget problem, not for all yet due slow implementation of the rest.

Regards
ppf
Posts: 73
Joined: Oct 10, 2017 6:41

incremental ListBox search navigator on-the-fly

Postby ppf » Feb 18, 2020 15:33

Hi,

long time no news here, so one from me ;),
for more pleasured work with listboxes I wrote/expand sGui files with this code (searching funcionality);
maybe after one hour of playing with 0.84 sources..(Not sured if it cannot be solved with existing sGui functions, thought.)
Extremely usable in case of long lists passed into listbox (IMHO hundreds+ items, but case to case ..I had 160 ones.)

maked code additions (version 0.84ext)
in file "Demo_ActivationTest.bas"

Code: Select all

'...other lines
 dim as EventHandle ptr event=new EventHandle      'after this line add
 Dim As Integer listID            'new line
 Dim As string maska=""            'new line
'...other lines
  'in KEY block
  if KEY<>"" then            
   maska+=KEY
    if len(maska)>5 then maska=""        'mask clear  (automatic easy if too long)
     if KEY="*" then maska=""          'mask clear  (hard)      Can be in one line both;)
     if ASCCODE=27 then exit do         'exit loop
      listID=TO_FindTextLineMasked(listbox,maska)      'find position in list
      SetListBoxVal(listbox,listID)                'set listbox to that position
    'SetListBoxVal(listbox,TO_GetMaskLines(listbox,maska))     'enable this syntax too ;)
    'maybe future - add comfort search logic - from left/right/anywhere & from position & after marker char  ;)

After compile&run input mask chars "i" + "n" +"p" +"x" and see what happens in listbox !
(Third find shows 'Input' keyword, forth goes back to 1.item - nothing founded)

in file "TextObject.bas"

Code: Select all

'... declares part (public)
public:
'...
declare function FindTextlineMasked(mask as string) as integer      
private:
'...
'... functions part
function TextObject.FindTextlineMasked(mask as string) as integer   
  if firstline=0 then
    function=0
  else
    dim as TextLine ptr l   
    dim as integer found,Ll
    dim as string s
    s=""
    Ll=len(mask)
    l=firstline
    found=0
    do
      s =l->text
      if lcase(left(s,Ll))=lcase(mask) then    'quick search, no uppercase, not suitable for me
      found=l->index
     end if   
      l=l->nextline
    loop until (found<>0) or (l=0)
    function=found 
  end if
end function




in file "TOGadgetBindings.bas"

Code: Select all

'... declares part
declare function TO_FindTextLineMasked(gad as _Gadget ptr,mask as string) as integer

'... functions part
function TO_FindTextLineMasked(gad as _Gadget ptr,mask as string) as integer
  function=0
  dim as TextObject ptr tobj=GetTOAddress(gad)
  if tobj then function=tobj->FindTextlineMasked(mask)
end function
'...other lines

I am satisfied greatly with, what do you think about this functionality, Mutton?
And many thanks for your library!
Last edited by ppf on Feb 19, 2020 18:16, edited 2 times in total.
ppf
Posts: 73
Joined: Oct 10, 2017 6:41

incremental ComboBox search navigator on-the-fly

Postby ppf » Feb 18, 2020 22:35

Uhmm, it works with combobox too /;D
Last edited by ppf on Feb 19, 2020 18:17, edited 1 time in total.
ppf
Posts: 73
Joined: Oct 10, 2017 6:41

ListBox/ComboBox comfort search/navigator on the fly

Postby ppf » Feb 18, 2020 22:36

Hi,

above code upgraded.Added comfort search - from left/right/anywhere in listbox/combobox.

The goal is to significantly speed-up time of setting list/combobox item, mostly in case of long and wide lists.
Opening that and reading+searching and moving mice kurzor takes a lot of time, no doubts!

in file "Demo_ActivationTest.bas"

Code: Select all

'...other lines
 dim as EventHandle ptr event=new EventHandle      'after this line add
 Dim As Integer listID            'new line
 Dim As string maska=""            'new line
'...other lines
  'in KEY block
  if KEY<>"" then            
   maska+=KEY
    if len(maska)>5 then maska=""        'mask clear  (automatic easy if too long)         (5 - set lenght of your choice)
     if KEY="*" then maska=""          'mask clear  (hard)      Can be in one line both;)    (* - set symbol of your choice)
     if ASCCODE=27 then exit do         'exit loop
      listID=TO_FindTextLineMasked(listbox,maska)      'find position in list of listbox
      SetListBoxVal(listbox,listID)                'set listbox to that position
      
rem      listID=TO_FindTextLineMasked(combobox,maska)      'find position in list of combobox
rem      SetComboBoxVal(combobox,listID)                'set combobox to that position
            
    'SetListBoxVal(listbox,TO_GetMaskLines(listbox,maska))     'enable this syntax too ;)
    'maybe future - add expanded comfort search logic - from position & after marker char  ;)

After compile&run input mask chars "i" + "n" +"p" +"x" and see what happens in listbox/combobox !
(Third find shows 'Input' keyword, forth goes back to 1.item - nothing founded).

in file "TextObject.bas"

Code: Select all

'... declares part (public)
public:
'...
declare function FindTextlineMasked(mask as string, searchWay as string="left") as integer      
private:
'...
'... functions part
function TextObject.FindTextlineMasked(mask as string, searchWay as string="left") as integer   
  if firstline=0 then
    function=0
  else
    dim as TextLine ptr l   
    dim as integer found,Ll
    dim as string s
    s=""
    Ll=len(mask)
    l=firstline
    found=0
    do
      s =l->text
'old      if lcase(left(s,Ll))=lcase(mask) then    'quick search, no uppercase, not suitable for me
'old      found=l->index
'old     end if   
   'comfort logic
select case searchWay
 case "left"   'first match from left - 1.position
      if lcase(left(s,Ll))=lcase(mask) then
      found=l->index
     end if   
 case "any"           'match anywhere in string
      if instr(lcase(s),lcase(mask)) then
      found=l->index
     end if   
 case "right"        'first match from right - 1.position
      if lcase(right(s,Ll))=lcase(mask) then
      found=l->index
     end if   
end select

      l=l->nextline
    loop until (found<>0) or (l=0)
    function=found 
  end if
end function


in file "TOGadgetBindings.bas"

Code: Select all

'... declares part
declare function TO_FindTextLineMasked(gad as _Gadget ptr,mask as string, searchWay as string="left") as integer

'... functions part
function TO_FindTextLineMasked(gad as _Gadget ptr,mask as string, searchWay as string="left") as integer
  function=0
  dim as TextObject ptr tobj=GetTOAddress(gad)
  if tobj then function=tobj->FindTextlineMasked(mask,searchWay)
end function
'...other lines

Syntax usage:
combobox/listbox - set its name

Code: Select all

 
  listID=TO_FindTextLineMasked(combobox,maska,"left")      'find match position in list, (default) search from left
  listID=TO_FindTextLineMasked(combobox,maska)            'find match position in list, default search from left - keyword omitted
  listID=TO_FindTextLineMasked(combobox,maska,"any")      'find match position anywhere in list
  listID=TO_FindTextLineMasked(combobox,maska,"right")      'find match position in list, search from right
 


note:
Rules of search logic can be more precised in the future..
Search from 'right' I don't use in general, so not sured about the code; but it works.Place for discussion,
what is the correct search flow.

Not sured about usage of Mask keyword, tested with maska, maskb, maskc.Maska stays.
Feel free to use this code in your library, Mutton.

I have only a few apps 'sGui-featured' with constant lists, so not too much space for hard testing of this expanded functionality.
I will slowly experiment next.
Last edited by ppf on Feb 19, 2020 18:19, edited 1 time in total.
ppf
Posts: 73
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » Feb 19, 2020 18:16

Well, hurry thinking ..
'SetListBoxVal(listbox,TO_GetMaskLines(listbox,maska)) 'enable this syntax too ;)

shortened oneline syntax works too as well ;)

Code: Select all

      SetComboBoxVal(combobox,TO_FindTextLineMasked(combobox,maska,"any"))
       SetListBoxVal(listbox,TO_FindTextLineMasked(listbox,maska,"any"))
      
       SetComboBoxVal(combobox,TO_FindTextLineMasked(combobox,maska,"right"))
       SetListBoxVal(listbox,TO_FindTextLineMasked(listbox,maska,"right"))
      
       SetComboBoxVal(combobox,TO_FindTextLineMasked(combobox,maska,"left"))
       SetListBoxVal(listbox,TO_FindTextLineMasked(listbox,maska,"left"))
      
       SetComboBoxVal(combobox,TO_FindTextLineMasked(combobox,maska))
       SetListBoxVal(listbox,TO_FindTextLineMasked(listbox,maska))



Second - seems one important word is missing in this theme.
Incremental. Incremental search navigator. Post title corrected.

Third - search from "right" is OK, no debate needed.I was too math&logic purist.
You directly see in listbox how it search among items, if you have also displayed entered mask in (testing only) String gadget.

Last - TIP:
When incremental mask catch is activated (and Listbox/Combobox is On too), it will be good to show warning info - two colorized label
e.g. "A-Z", near at Listbox/Combobox.As mnemonic helper, you'll know yet after years, incremental mask catch is activated ;)
(After selecting item in Listbox/Combobox switch Off that Label gad too.)

Code: Select all

AddLabelBackgrounded(event,10,360,"A-Z",foreColor,backColor)   'enhanced via Wizdizzy 0.3

or change GadgetTextBackgroundColor variable

Code: Select all

GadgetTextBackgroundColor=backColor
AddLabel(event,10,360,"A-Z",foreColor)

Enjoy it!
ppf
Posts: 73
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » Feb 25, 2020 20:58

Hi,

to see long URLs (on whole screen) in opened ComboBoxLong (function added by petan) I enhanced code of "MiniSelector.bas" file to get 'flowin' functionality
of called listbox.(Longer text than screen is therefore cutted from left.I know the most important text is on right side, but
I keep sGui idea to be smart&small.This is quick workaround.
Lenght of activated listbox of opened combobox is growin (by its text) to right side of screen.
After reachin it it grows also to left side to max size of screen.)
Short test, works as expected ;)

What do you think about this , Mutton?

"MiniSelector.bas" ver 0.84ext

Code: Select all

#include once "ListBox.bas"

namespace sGUI

declare function MiniSelector(PosX as integer,PosY as integer,NumChars as integer, NumRows as integer, TOAddr as textobject ptr=0, EntrySelected as integer=0,DisplayMode as integer=0) as integer

function MiniSelector(posx as integer,posy as integer,NumChars as integer, NumRows as integer, TOAddr as textobject ptr=0, EntrySelected as integer=0,DisplayMode as integer=0) as integer
  function=0
  'dim as integer boxw,boxh,l,scrh         'orig
  'screeninfo ,scrh                     'orig
  dim as integer boxw,boxh,l,scrh,scrw      'new
  screeninfo scrw,scrh                  'new
  boxw=NumChars * 8 + 6 + 15

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'new adjust box x size, NumChars, posx
    while boxw>scrw
      NumChars-=1
      boxw=NumChars * 8 + 6 + 15
    wend
    if (posx+boxw) >= scrw then posx=scrw-boxw-1         
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  boxh=fontheight * NumRows + 6
  if (posy+boxh) >= scrh then posy=scrh-boxh-1
  dim as FB.Image ptr gfxbackup
'..... the rest of file 

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 0 guests