sGUI

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

Thanks for this info, Muttonhead, german reference not seen deeply ... !

For me personally is enough to knowing that problem with possible misusing 'Get/SetCombo/ListVals' routines for wrong gadtype, and adding a few words about it to designer online help - F1 keypress - as general part "Troubles & solutions". For now it 'll be sufficient without changes in sGUI code.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

Hi, Mutton
I made next another tuning for 084 'ListBox/ComboBox' to be used both as Color Chooser (palette of user defined NAMED colors in an array). other things stays now.
256 color palette is in file "colors256.bi".
It's alpha version but works.

Q - I don't know which header parameter is better for calling it ?? - next number {...,colorChooser as integer=0 / 1, or string ...,colorChooser as string="" / "cc"} ?
This flag is then stored in 'gad->Ctrl(4)' as integer.

Screenshot + discussion about color contrast is here http://www.freebasic.net/forum/viewtopi ... =3&t=24782

Founded that 'sGUI' has global variable 'contrast', but not satisfied with trial results.
I 'll post final 084 code and upload 085 files later.
Last edited by petan on Jun 21, 2016 0:09, edited 1 time in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

"sGUI.bas" added new variable

Code: Select all

(...)
dim shared as uinteger colorChooserBackgroundColor=black	'my	Johnson black light r g b
static shared as uinteger dotColor=rgb(0,0,0)		'my
'System Events
(...)
084 ListBox - color chooser mode

"ListBox.bas"

Code: Select all

(...)
declare function AddListBox(event as EventHandle ptr,PosX as integer,PosY as integer,NumChars as integer,NumRows as integer,DisplayMode as integer=0,ScrollBarMode as integer=0,colorLister as integer=0) as Gadget ptr
(...)
function AddListBox(event as EventHandle ptr,PosX as integer,PosY as integer,NumChars as integer,NumRows as integer,DisplayMode as integer=0,ScrollBarMode as integer=0,colorLister as integer=0) as Gadget ptr
  function=0
  dim as Gadget ptr gad
  gad=event->GadgetList->AppendNew (GadgetType)
  if gad then
    gad->event=event
  	gad->sel=0
    gad->act=0
    gad->gadKind=3			'my GadgetType flag    
    gad->posx=PosX
    gad->posy=PosY
    gad->gadw=NumChars*8 + 6 + 15 '6 >> Rand innerhalb MLEB,  15>> Breite ScrollBar rechts
    gad->gadh=fontheight*NumRows + 6'6 >> Rand innerhalb MLEB

    gad->Ctrl(1)=DisplayMode
    gad->Ctrl(2)=NumRows
    
    gad->subevent=new EventHandle
    if gad->subevent then
      gad->gad(0)=AddLBGadget(gad->subevent,gad->posx,gad->posy,NumChars,NumRows,DisplayMode)     
      gad->gad(1)=AddScrollBar(gad->subevent,gad->posx+NumChars*8 + 6,gad->posy,NumRows*fontheight+6,1,1,1,NumRows,1,ScrollBarMode)		
	end if

    gad->extTObject=gad->gad(0)->TObject'Verbindung zum Textobjekt erzeugen das eigentlich zur LB in gad(0) gehört
    gad->useextTO=1                     'Flag für alle TO-Befehle extTObject zu benutzen

    gad->gad(0)->Ctrl(4)=colorLister	'my color chooser flag


    gad->DoDraw     =@DrawList
    gad->DoAction   =@ListActions
    gad->DoUpdate   =@UpdateLB

		'gad->SaveBackGround
		function=gad
  end if
end function
(...)
"ListBox_Basis.bas"

Code: Select all

(...)
sub DrawLB (gad as Gadget ptr)
	Dim as integer PosX,PosY,GadWidth,GadHeight,offset,NumRows
  	Dim as integer boxc,boxl,scrollpos,scrollline,lcount,selline
  	Dim as integer idc,ela7		'my
	dim as uinteger tcolor
  	Dim as TextLine ptr l
  	Dim as string tmpstring,cursorchar
  PosX   =gad->posx
	PosY   =gad->posy
	GadWidth		   =gad->gadw
	GadHeight		   =gad->gadh
	offset=3
  NumRows=TO_GetLines(gad)
  boxc=gad->Ctrl(0)
  boxl=gad->Ctrl(1)
  scrollpos=gad->Ctrl(2)
  scrollline=gad->Ctrl(2)
  l=TO_GetLineAddr(gad,scrollline)
  selline=gad->Ctrl(15)

  tmpstring=""
  screenlock
  
  
 ' ? "b gad->Ctrl(4) ";gad->Ctrl(4), "b gad ";gad
  
  if gad->act=0 then
'OFF
    put(PosX,PosY),gad->Background,pset
  else
'ON
    FrameB PosX,PosY,GadWidth,GadHeight,1
'set backgrounds
	'my    if as color chooser funcionality
		if gad->Ctrl(4) then	
			ClearBox PosX+1,PosY+1,GadWidth-2,GadHeight-2,colorChooserBackgroundColor		'my		
		else
			'ClearBox PosX+1,PosY+1,GadWidth-2,GadHeight-2,white
			ClearBox PosX+1,PosY+1,GadWidth-2,GadHeight-2,GadgetTextBackgroundColor		 'orig
		end if
		
		
    if NumRows then
      lcount=0
      do
        tmpstring=TO_GetLineContent(gad,l)
			
	'my    if as color chooser funcionality
			if gad->Ctrl(4) then
				idc=valint(mid(tmpstring,instr(tmpstring,"~")+1))
				if idc andalso idc<ubound(kolorem)+1 then	'check array range
					tmpstring=String(5,chr(219))+m+kolorem(idc).nameKolorem		'global - user 256 colors palette e.g.
				else
					? "listbox kolor index error"
				end if
			
			end if

        if gad->Ctrl(3) then  'DisplayMode 1
          
          if left(tmpstring,3)="LBL" then
            tmpstring=left(right(tmpstring,len(tmpstring)-4),boxc)
            FillA PosX+1,PosY+offset+lcount*fontheight,GadWidth-2,fontheight,BackgroundColor,0
            tcolor=&HEE5500
          end if

          if left(tmpstring,3)="ITM" then 
          	ela7=InStrRev(tmpstring,":")
           ' tmpstring=left(space(2) & right(tmpstring,len(tmpstring)-8),boxc)		'orig
'            tmpstring=left(right(tmpstring,len(tmpstring)-8),boxc)						'my
            tmpstring=left(right(tmpstring,len(tmpstring)-ela7),boxc)						'my
            
            if (scrollline+lcount=selline) then
              tcolor=white
              ClearBox PosX+1,PosY+offset+lcount*fontheight,GadWidth-2,fontheight,CursorColor
            else
              tcolor=TextColor
            end if                     
          end if
          
        else                  'DisplayMode 0
         
          tmpstring=left(tmpstring,boxc)
          if (scrollline+lcount=selline) then
            tcolor=white
            ClearBox PosX+1,PosY+offset+lcount*fontheight,GadWidth-2,fontheight,CursorColor
          else
            tcolor=TextColor
          end if        
        
        end if

		'my  if as color chooser funcionality
		if gad->Ctrl(4) then
			tcolor=kolorem(idc).whichKolorem		'my
		end if
				
		draw string ( PosX+offset, PosY+offset+lcount*fontheight ),tmpstring,tcolor		'orig		
			

        l=l->nextline
  		  lcount +=1
      loop until (l=0) or (lcount=boxl)'keine Zeile im TO oder der Zeilenzähler=Anzahl der zu zeigenden Zeilen(lcount startet bei 0!)
    end if
'SLEEP
    if gad->act=2 then put(PosX,PosY),gad->Background,alpha,SleepShade
  end if
  screenunlock
end sub
(...)
Testing example - Listbox color chooser and contrast

Code: Select all

(...)

/' user color palette defined in designer file 'colors256.bi'
type Kolory256
nameKolorem as string
whichKolorem as uinteger
end type
 dim shared as Kolory256 kolorem(1 to 256)
scope
dim as string a
dim as uinteger b
for i as integer=1 to 256
read a,b
kolorem(i).nameKolorem=a
kolorem(i).whichKolorem=b
next i
end scope


data "AliceBlue",&HF0F8FF
data "AlizarinCrimson",&HE32636
data "Amber",&HFFBF00
data "Amethyst",&H9966CC
data "AntiqueWhite",&HFAEBD7
data "Aquamarine",&H7FFFD4
data "Asparagus",&H7BA05B
(...)
'/

(...)
kolorList=AddListBox(event2,530,25,26,15,,,1)
for pjt=1 to ubound(kolorem)
	TO_AppendLine(kolorList,kolorem(pjt).nameKolorem+"~"+str(pjt))	
next pjt
UpdateGadget(kolorList)
(...)
GadgetOn(kolorList)
x=0
'backgrounds of colorchooser
dim as uinteger ccBkgC(4)
ccBkgC(1)=rgb(0,0,0)
ccBkgC(2)=rgb(255,0,0)
ccBkgC(3)=rgb(0,255,0)
ccBkgC(4)=rgb(0,0,255)
do
 event2->EXITEVENT=0	
  event2->xSleep(1,0)
if RMB=HIT then
	event2->EXITEVENT=1
end if

	'F1 - swap background
  if multikey(&h3b) then 
	x+=1:if x>ubound(ccBkgC) then x=1		'Johnson counter
	colorChooserBackgroundColor=ccBkgC(x)
	GadgetOff(kolorList)
	GadgetOn(kolorList)
  end if  
loop until event2->EXITEVENT=1
GadgetOff(kolorList)
(...)
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

085 ListBox speedy tuning as colorchooser succesfull ;)

Problem is fixed font; when loaded, no colorized polygon written, but some "U" chars.
Equally as label, fontMode must be optional parameter for ListBox/ComboBox to prevent this behavior, when
colorchooser mode is needed.
I'll play with that for a moment, uploading 085 ListBox files tonight.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

Uploaded.
(Updated *.BAS - Demo_font, Demo_label, Demo_ListBox, sGUI_font, sGUI, Listbox, Listbox_Basis)
Added hard FB default 8 px font as fontMode 2, it can be used even if another fonts exist & loaded in FontImg.
Now it likes me more ;)
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

;))
085 ComboBox is able in colorchooser funcionality too, looks 084 'll be equally.
(Color background swap indipendent in Combo and MiniSelector)
What a ride.Code upload tomorrow, tired.
Image
edit
084 done too ;)
Last edited by petan on Jun 23, 2016 9:07, edited 1 time in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

Okay, done.
084+085 'ListBox+ComboBox' colorChooser functionality added (user defined palette in array)
'FillA' tuned slightly to catch/highlight ANY color selected item in ListBox+ComboBox.
Now it's fine, black&yellow pattern box frame 'll do that.
Maybe better tuning for pattern remains - dashed/dotted/another ??
Background color is swapped to get contrast for color name item
Image
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

Hi, Mutton

Looks like a bug in 085 alpha ?
combobox and listbox - when mouse is on opened list items, then mouse cursor is invisible... until moved a bit...?
084 is OK.

edit
Not a bug, some code switched badly !, searching...
Last edited by petan on Jun 27, 2016 21:24, edited 1 time in total.
Muttonhead
Posts: 139
Joined: May 28, 2009 20:07

Re: sGUI

Post by Muttonhead »

can't repeat the behavior...:(. on my machine its looks ok...
but there's a heavy bug in the update routine of listbox in v.0.85...
it appears when you use the filerequester: scroll up and down and then try to go to parent directory, program will crash...
i'll check this... this version is embeded in Charset2FBFont too. :O :(
Muttonhead
Posts: 139
Joined: May 28, 2009 20:07

Re: sGUI

Post by Muttonhead »

in ListBox.bas routine UpdateListBox(gad as Gadget ptr)
comment line 102:

Code: Select all

UpdateGadget(listbox)
to

Code: Select all

'UpdateGadget(listbox)
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

edited
085 Mouse visibility IS MY problem tested in "DemoActivationTest.bas" !

- mouse off any gadget is visible - if in move or stay
- mouse on gadget is invisible - if stay
If slowly in move - is visible
- mouse on gadget is fully visible Ok - ONLY on 'BMP gadget' and 'String gadget' and 'Label'
and 'MultilineEditbox gadget'

edit
Upss, tested second clear copy of 085 alpha pack, there is correct behavior.You are right!

'Setmouse' command is not a source of problem, so it looks like an intensive refresh somewhere added, or switched by me in tuned code.
Clear, I'll check tuned files separately to isolate that behavior and reason.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

Hmm, 085 Filerequester seems withou crash here on Slax 7, I cannot repeat that behavior..
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

084 mouse visibility problem in designer too.Color chooser is OK.

Mouse invisible even off designer widget - this bug detected to 'windowtitle' command in a loop.
Next visibility troubles on some gadgets activated, on others is cursor OK.
IDU this, looks like some refresh problem in a bigger complex code.
Trying to isolate that problem.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

tip for 084/085 Manual/Tutorial - to add this note (chapter "Troubles/Solutions")

... important functional difference, easily changeable in mind, between
if GetSelect(myGadgetXY)=1 then .... 'gadget is clicked
'and
if myGadgetXY->act=1 then .... 'gadget is visible

lost a 30 min until founded mistaked functionality in designer's improved gad properties setup.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Post by petan »

Back in resizing .. IMHO this would be good as default possibility for MultilineEditor and Filerequester..

Q - is 'xSleep' routine able to compute a mouse distance between 'click-hold-(move)-released' mouse sequence ?
Post Reply