sGUI

User projects written in or related to FreeBASIC.
Coolman
Posts: 228
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: 130
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: 228
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: 88
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: 88
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: 88
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: 88
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: 88
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: 88
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 


Pics here:
(first combo selects & starts browser & wake up second sleepin combo with URLs)
[url]
https://postimg.cc/gallery/2zn7tw2i4/
https://postimg.cc/CBqyK9qp
https://postimg.cc/zHC9CW7d
[/url]
Last edited by ppf on Feb 26, 2020 21:23, edited 1 time in total.
dmontaine
Posts: 3
Joined: Mar 15, 2018 7:13

Re: sGUI

Postby dmontaine » Feb 26, 2020 20:46

Is there a current download location for this project?
Muttonhead
Posts: 130
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Feb 26, 2020 21:04

hello ppf, although i think that you and petan are one and the same person - which is generally no problem at all - what did i actually want to say at the moment i'm more concerned about world health than sGUI. Maybe it is panic-mongering or it is played down a bit, but... who knows...

someone in the media said: alcohol fights the virus XD...
Mutton
ppf
Posts: 88
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » Feb 26, 2020 21:22

Hi Mutton,
right, a bit of panic having too and walkin with hand at mouth.Korona is already in Austria.
(Ehh, surely not the same person.)
No problem, when I could improve sGui code I'll post a code, use it whenever as you want.
As I see just fallin in circular upgrade my sGui-featured apps.

Gruss!
Muttonhead
Posts: 130
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Feb 26, 2020 21:36

... ok, it just surprised me when the last time someone has read the source code so intensively, which, admittedly, is not very readable! i apologize for my suppositions and assumptions :)

austria you said, then it would be easier for me to give help or tips in native language via pm.
Anyway, additions and improvements to sGUI are always welcome, and I think this is the place to release it ...

Mutton
ppf
Posts: 88
Joined: Oct 10, 2017 6:41

Re: sGUI

Postby ppf » Mar 02, 2020 3:09

wow, really like petan ? I am honored, but, unlikely not.He is smart and so quick coder..I learned a lot from his sources.
And from yours and Roland's too.Great lessons, reading for months...
Hope he is healthy&OK.
PMs are good idea, but I'll do a minimal new tweaks and improvement to sGui actually.
What I want to implement brute force I made in 6 apps.No new app on horizont, only circular upgrade my oldies.
Actually (retired) I must solve liver tumor somewhere, so earnin bucks for operation.

Today, for fun, reached success in 'Demo scroll huge image' snippet (or so named, IDR).
Your demo is very close to moving a big pic, I saw in some language(windows only) many years back.
And quite similar to handling that by thumbnail in linux OS.So I was wondering if I can bypass that HVsliders,
and get a mouse drag&drop effect only.Works perfectly, amazing!
Tomorrow pasting the code.

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

Re: sGUI

Postby ppf » Mar 03, 2020 0:02

Here is code based on file "Demo_Scrollbar2.bas".
Both gads - HVsliders are omited, movin image catch depends only on mouse - movin, left button Hit, or Hold;
like mouse 'drag&drop' method to get visualisation on-the-fly.
Some small area of window is intact due zoom koeficient rounding, what is sufficient.
My real app uses fullscreen movin/rendering by mouse; speed is awesome.
(Big images (200k datasheet drawings) are drawn into the buffer and also read from disk, at size about 3000x800 pixels.)

This feature of sGui is really beautiful!

Code: Select all

'Compileroption -s gui
#include "sGUI\sGUI.bas"
#include once "sGUI\ScrollBar.bas"
using sGUI

declare sub ShowCut(xo as integer,yo as integer)
screenres 418,318,32',,&H04'kein Fullscreen erlaubt
InitGFX

dim as single koefZx,koefZy      
dim as integer x_axisOLD,y_axisOLD,x_size,y_size,wX,wY
dim shared as integer ptr img,cut
img=imagecreate(1280,1024)
cut=imagecreate(400,300)
screeninfo(x_size,y_size)

sub ShowCut(xo as integer,yo as integer)
  get img,(xo,yo)-(xo+399,yo+299),cut
  put(1,1),cut,pset
end sub

      
if img>0 and cut>0 then
  bload "BMPs\Bild.bmp",img

ImageInfo(img,wX,wY)
koefZx=wX/x_size
koefZy=wY/y_size

'koefZx,koefZy - approx.zoom solver

  'basic info:
  'size of picture 1280x1024
  'size of "scrollwindow" 400x300

  'parameters of horizontal slider:
  'first element = 0
  'last element  = 1279
  'pagesize = width of scrollwindow = 400

  'parameters of vertical slider:
  'first element = 0
  'last element = 1023
  'pagesize = height of scrollwindow = 300
  dim as integer xoffset,yoffset
  xoffset=0
  yoffset=0

  get img,(xoffset,yoffset)-(xoffset+399,yoffset+299),cut
  put(1,1),cut,pset

y_axisOLD=0
x_axisOLD=0
  dim as EventHandle ptr event=new EventHandle

  do
    event->xSleep(1)
    if LMB=HOLD then      'the same as slider but mice drag&drop
      xoffset=fix(MOUSEX*koefZx)   
      yoffset=fix(MOUSEY*koefZy)   
      ShowCut(xoffset,yoffset)      
      put(0,0),cut,pset
      y_axisOLD=0
      x_axisOLD=0
       If y_axisOLD<>MOUSEY Then
         y_axisOLD=MOUSEY
      End If   
       If x_axisOLD<>MOUSEX Then
         x_axisOLD=MOUSEX
      End If       
    End If
   
 if KEY="q" then event->EXITEVENT=1       'quit of loop
'HVsliders not used

  loop until event->EXITEVENT
  delete event
   imagedestroy img
   imagedestroy cut
end if
 sleep 500
end

Return to “Projects”

Who is online

Users browsing this forum: Baidu [Spider] and 4 guests