sGUI

User projects written in or related to FreeBASIC.
TJF
Posts: 3502
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: sGUI

Postby TJF » Oct 07, 2014 6:37

@Muttonhead:

Did you consider to generate the documentation by fb-doc and Doxygen, yet?

  • Single source (documentation in source code files).
  • High quality output in different formats (html, pdf, chm, ...)
  • Auto-creation of useful information (ie. links between text, graphs and source listings, or graphs for includes and caller / callees).
And more...
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Oct 07, 2014 8:59

Nice, 19 pages is real help for starting..
I'll read it all, looks good.
Thx.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Oct 08, 2014 0:41

My forgotten english is saying:
in 1. page - would be
----------
With a lot of LINE
,if you need a few buttons
*INKEY doesn't work well:
*sGUI is too slow

in 3. page - would be
----------
'please...,if the color is not black
returns some information about
collecting all events, executing all..., executing all... in sGUI.

in 5. page - would be
----------
DrawGadget does exactly that.It redraws
How to create it ? In

in 6. page - would be
----------
creates an arrow

in 7. page - would be
----------
, if not - an empty string

in 12. page - would be
----------
If it's on - you can

in 14. page - would be
----------
Which menu item was
...
Which menu item was
value when creates an item

in 15. page - would be
----------
It's possible that

in 18. page - would be
----------
It's a kind of
loading a string (

in 19. page - would be
----------
replacing the content of the row
...
replacing the content of the row
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Oct 08, 2014 9:07

Comments:
a) Last sentence from 1-th page of QuickReference ( about custom backgrouncolor ) is unclear, because it has more solutions/sences.More detailed explanation needed here, IMHO.
Having trouble with that for dynamic subwindow/widget creation.
I used non elegant solution - one unused videopage colorized as background.

b) missing important warning about using 'fullscreen' flag.
The best way for developing/debugging app with sGUI used inside is 'windowed' mode;
and only after getting perfect funcionality of sGUI controls it's recommended switching to 'fullscreen' mode.
(Due loosing control over app, if wrong relations enabled.)

edit:
- dynamic subwindow/widget creation - Fixed finally
Last edited by petan on Oct 10, 2014 6:21, edited 1 time in total.
Muttonhead
Posts: 118
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Oct 08, 2014 15:57

@petan
aahhh... too many errors...
my last english lesson was in 1986
i am sad :/

Having trouble with that for dynamic subwindow/widget creation.

what is the problem?


@TJF:
powerful, i like it.
the output looks great, Doxy is a little bit tricky to config, dont get the cool graphics at moment...
my personal problem is: all looks "dot-c-ized".
but this is more a question of taste

Mutton
TJF
Posts: 3502
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: sGUI

Postby TJF » Oct 08, 2014 17:14

Yes, the configuration of Doxygen is overhelming at the beginning. Most options aren't helpful for my projects and it still takes some time to test out what and how to customize. But the output is great and usable. I often use the caller / callee graphs to get some overview about the internal interactions.

Muttonhead wrote:..., dont get the cool graphics at moment...

Did you create / generate /use the file fb-doc.lfn?

Muttonhead wrote:my personal problem is: all looks "dot-c-ized".

It started with C++ (and is written in C++ as well) and then further programming languages were added.

BTW:
I'm using an advanced version of fb-doc that can generate FB source listings with correct syntax highlighting (including links to the text / graphs like in that page of the libpruio documentation). It's unpublished yet because the documentation isn't finished (and the command line options changed a lot to simplify operations). Perhaps you're interested in beta testing?
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Oct 09, 2014 1:01

Muttonhead wrote:
Having trouble with that for dynamic subwindow/widget creation.

what is the problem?

"Demo-activation2.bas" (edited now)

Code: Select all

#include "sGUI\sGUI.bas"
#include once "sGUI\ComboBox.bas"
#include once "sGUI\SimpleGadget.bas"
#include once "sGUI\BMPSimpleGadget.bas"
#include once "sGUI\ToggleGadget.bas"
#include once "sGUI\CheckMarkGadget.bas"
#include once "sGUI\RadioButton.bas"
#include once "sGUI\StringGadget.bas"
#include once "sGUI\TrackBar.bas"
#include once "sGUI\ScrollBar.bas"
#include once "sGUI\Arrows.bas"
#include once "sGUI\ListBox.bas"
#include once "sGUI\MultiLineEditBox.bas"
#include once "sGUI\FileRequester.bas"
#include once "sGUI\Label.bas"
#include once "sGUI\Menu.bas"
using sGUI

'my colors
const cBlack=rgb(0,0,0)      
const cGold=rgb(128,128,0)   
const cRed=rgb(255,0,0)
const cGreen=rgb(0,255,0)
const cSilver=rgb(192,192,192)


declare sub dynaWiget()
declare sub wiget2() 

'screen 19,32,3,&H04      'orig
'width 800\8,600\16      'orig

'screen 20,32,4,&H04      'my1

screenres 1000,752,32,3,&H04   'my2
width 1000\8,752\16

'screenres 1024,768,32,3,&H01   'my3 fullscreen
'width 1024\8,768\16

InitGFX
screenset 0,0

' BackGroundColor=cGold
'color TextColor,BackGroundColor
'cls

windowtitle "videopage 0 switched..."
 ? "dynamic & static demo... & two videopages"
  bload "BMPs\stives.bmp",0
 
 dim as EventHandle ptr event=new EventHandle
dim as Gadget ptr check,acton,actsleep,actoff

dim as single kolik      
dim as string someText="3",someText2=""

acton     =AddRadioButton(event,730,460,1,"On",0)
actsleep  =AddRadioButton(event,730,480,0,"Sleep",acton)
actoff    =AddRadioButton(event,730,500,0,"Off",acton)

check=AddCheckMarkGadget(event,730,440,1,"Menue")
GadgetOn(acton,check)
'? "GadgetOn(acton,check)...":sleep

'examples of all buttons
dim as Gadget ptr checkrs2(1 to 4),optas3(1 to 3),optas4(1 to 3)
dim as Gadget ptr okay,opta,checker,radioa,radiob,radioc,radiod
dim as Gadget ptr stringer,track,scroll
dim as Gadget ptr arrowl,arrowr,arrowu,arrowd,sarrowl,sarrowr,sarrowu,sarrowd
dim as Gadget ptr bmpplus,bmpminus,label,label2,label3,label4,bmpPMvalue
dim as Gadget ptr listbox,combobox,textbox
dim as Gadget ptr list2,separe

okay    =AddSimpleGadget(event,20,30,130,20,"Dynamic")
opta    =AddToggleGadget(event,20,60,70,20,1,"Option A","")
checker =AddCheckMarkGadget(event,20,90,1,"Option")

checkrs2(1)=AddCheckMarkGadget(event,210,240,1,"aaa")
checkrs2(2)=AddCheckMarkGadget(event,210,260,0,"bbb")
checkrs2(3)=AddCheckMarkGadget(event,210,280,0,"ccc")
checkrs2(4)=AddCheckMarkGadget(event,210,300,1,"ddd")

 label3=AddLabel(event,20,450,"'Centered' print style",&HFFDD00)
optas3(1)=AddToggleGadget(event,20,480,170,20,0,"Choice A","")
optas3(2)=AddToggleGadget(event,20,500,170,20,1,"The best choice of the day..","")
optas3(3)=AddToggleGadget(event,20,520,170,20,1,"Bad choice","")

 label4=AddLabel(event,260,450,"'Lefty' print style",&HFFDD00)
optas4(1)=AddToggleGadget(event,260,480,170,20,0,"Choice A","L")
optas4(2)=AddToggleGadget(event,260,500,170,20,1,"Better choice..","L")
optas4(3)=AddToggleGadget(event,260,520,170,20,1,"Bad choice","L")

radioa  =AddRadioButton(event,20,110,0,"ball",0)
radiob  =AddRadioButton(event,20,130,0,"cube",radioa)
radioc  =AddRadioButton(event,20,150,1,"cone",radioa)
radiod  =AddRadioButton(event,20,170,0,"cylinder",radioa)

stringer=AddStringGadget(event,20,190,10,"Text")
track   =AddTrackBar(event,20,220,150,-5,2,1,0)
scroll  =AddScrollBar(event,20,250,150,1,100,22,30,0)

arrowl  =AddArrow(event,20,280,0)
arrowr  =AddArrow(event,40,280,1)
arrowu  =AddArrow(event,60,280,2)
arrowd  =AddArrow(event,80,280,3)
sarrowl =AddSmallArrow(event,20,310,0)
sarrowr =AddSmallArrow(event,40,310,1)
sarrowu =AddSmallArrow(event,60,310,2)
sarrowd =AddSmallArrow(event,80,310,3)
bmpplus= AddBMPSimpleGadget(event,30,330,"BMPs\PlusUnSelected.bmp","BMPs\PlusSelected.bmp","BMPs\PlusMask.bmp")
bmpminus= AddBMPSimpleGadget(event,41,330,"BMPs\MinusUnSelected.bmp","BMPs\MinusSelected.bmp","BMPs\MinusMask.bmp")
bmpPMvalue=AddStringGadget(event,80,330,10,someText)
bmpPMvalue->caption=someText

label=AddLabel(event,10,360,"a clickable label",&HFFDD00)

listbox=AddListBox(event,530,25,10,10)
TO_LoadText(listbox,"Scrolltext.txt")
UpdateGadget(listbox)

combobox=AddComboBox(event,500,200,10,20)   'moved here to get continuous checkprint area
TO_LoadText(combobox,"Scrolltext.txt")
SetComboBoxVal(combobox,100)
UpdateGadget(combobox)

textbox=AddMultiLineEditBox(event,150,25,40,10,1)
TO_SetText(textbox,"Ein editierbarer mehrzeiliger Text|||und ja, es sind mehrere Zeilen","|")
UpdateGadget(textbox)
GadgetOn (okay,textbox)
'? "GadgetOn(okay,textbox)...":sleep

MenuOn(event)   'activated upper bar
menu (event,1,0,1,"Project")
menu (event,1,1,1,"Load")
menu (event,1,2,0,"Save")
menu (event,1,3,4,)
menu (event,1,4,3,"Option")
'menu (event,1,5,4,)      'orig
menu (event,1,5,4,"")
menu (event,1,6,1,"End")

'switch off activation messagebox
/'
GadgetSleep (acton,textbox)
MessageBox(200,300,"Activation Demo","!",MBType_OK)
RestoreActivation (acton,textbox)
'/
'MessageBox(200,200,"End Demo ???","Question",MBType_YESNO)

          if MessageBox(200,300,"End Demo ???","Question",MBType_YESNO)=MBButton_YES then
             'event->EXITEVENT=1
          else
          end if

' open console for output
dim as integer ff=freefile
open cons for output as ff

dim as integer menunum,itemnum
dim as string openfile
do
  event->xSleep(1)
  if KEY<>"" then            'my
   if KEY="q" then exit do      'my
   if ASCCODE=27 then
/'      
      '? "esc pressed.."
      GadgetOff(label2,radiocH)
      sleep
      getkey
         GadgetOn (label2,radiocH)
'/         
   end if
   'if ASCCODE then ? tab(68);"pressed..";ASCCODE
  end if
 
  'check menu events
  if event->MENUMESSAGE then
    menunum=event->MENUNUMBER
    itemnum=event->ITEMNUMBER

    if menunum=1 then
'? tab(84);"menunum=1... itemnum= ";itemnum
      select case itemnum
        case 1
          MenuOff(event)
          GadgetOff (acton,textbox)
          openfile=FileRequester(160,80,"Load",curdir,,1)
          TO_LoadText(textbox,openfile)
          UpdateGadget(textbox)
          RestoreActivation (acton,textbox)
          MenuOn (event)

        case 4
          if GetChecked(event,1,4) then
            Menu (event,1,4,1,"Option")
          else
            Menu (event,1,4,3,"Option")
          end if
        case 6
          'GadgetSleep (acton,textbox)   'orig - remmed
          if MessageBox(200,200,"End Demo ???","Question",MBType_YESNO)=MBButton_YES then
            event->EXITEVENT=1
          else
            'RestoreActivation (acton,textbox)
            RestoreActivation (okay,textbox)
          end if
      end select
    end if
  end if

  if event->GADGETMESSAGE then
    select case event->GADGETMESSAGE

      case acton
        GadgetOn (okay,textbox)
'? tab(84);"case acton- GadgetOn (okay,textbox)"
      case actsleep
        GadgetSleep (okay,textbox)
'? tab(84);"case actSleep- GadSleep (okay,textbox)"
      case actoff
        GadgetOff (okay,textbox)
'? tab(84);"case actoff- GadgetOff (okay,textbox)"
      case check
        if GetSelect(check) then
          MenuOn(event)
        else
          MenuOff(event)
        end if
      case okay
        GadgetOff (okay,textbox)
       dynaWiget()
        GadgetOn (okay,textbox)
      case bmpplus
      bmpPMvalue->caption=str(val(bmpPMvalue->caption)+0.1)
      kolik=val(bmpPMvalue->caption)
      bmpPMvalue->caption=str(kolik)
      SetString (bmpPMvalue,bmpPMvalue->caption)    
      UpdateGadget(bmpPMvalue)    
'      kolik=val(bmpPMvalue->caption)
       locate 21,40:? using "###.#";kolik
          
      someText2="second"
      SetString (stringer,someText2)    
      UpdateGadget(stringer)    
     case bmpminus
      bmpPMvalue->caption=str(val(bmpPMvalue->caption)-0.1)
      kolik=val(bmpPMvalue->caption)
      bmpPMvalue->caption=str(kolik)      
      SetString (bmpPMvalue,bmpPMvalue->caption)    
      UpdateGadget(bmpPMvalue)    
'      kolik=val(bmpPMvalue->caption)
       locate 21,40:? using "###.#";kolik

      someText2="third"
      SetString (stringer,someText2)           
      UpdateGadget(stringer)                  
    end select
  end if
loop until event->EXITEVENT
 ? tab(84);"is out..."
 MenuOff(event)            'works
 GadgetOff (okay,textbox)   'works
delete event
 sleep 2000
 end


sub dynaWiget()
dim as EventHandle ptr event2=new EventHandle
dim as Gadget ptr radioaH,radiobH,radiocH,label2
dim as Gadget ptr button1,button2,button3
dim as integer pozX,pozY
pozX=20
'pozY=
/'
         screenset 1,0
 BackGroundColor=cGold
color TextColor,BackGroundColor
'color BackGroundColor
cls
'/
         dotColor=cBlack
         label2=AddLabel(event2,10,380,"a dynamic widget with custom Dot color added",rgb(192,192,192))
         radioaH  =AddRadioButton(event2,20,420,1,"Hori",0)
         radiobH  =AddRadioButton(event2,80,420,0,"zon",radioaH)
         radiocH  =AddRadioButton(event2,130,420,0,"tal radioButton",radioaH)
         
         screenset 2,2
         paint (100,100),cGreen
         windowtitle "videopage 1 switched...  press .. (H)elp"
         ?:? ,"dynamic widgets demo ..."
         'line (10,415)-(280,440),cGold,BF
         'line (10,415)-(280,440),cSilver,B
         
button1= AddToggleGadget(event2,pozX,50,150,20,0,"Hori","")
button2= AddToggleGadget(event2,pozX+button1->gadw,50,150,20,0,"zon","")
button3= AddToggleGadget(event2,pozX+button1->gadw+button2->gadw,50,150,20,0,"tal toggleButton","")

do
 event2->xSleep(1)
 if KEY="q" or ASCCODE=27 then event2->EXITEVENT=1
  if KEY="h" then MessageBox(200,300,"ToggleRadiobuttons   >> A|Radiobuttons   >> B|Widget   >> S|||Esc+q >> Quit|Right_MB >> Off","Videopage 1 - Help ... press btn.",MBType_OK)
  if KEY="s" then wiget2() 
  if KEY="a" then
      GadgetOn(button1,button3)
  end if   
  if KEY="b" then
        GadgetOn (radioaH,radiocH)
  end if   
'   if RMB then GadgetOff(radioaH,button3)
    if RMB then GadgetOff(button1,button3)
  if event2->GADGETMESSAGE then
    select case event2->GADGETMESSAGE
      case button1
      if GetSelect(button1) then          '1
         SetSelect(button2,0)
         SetSelect(button3,0)
      end if     
      case button2
      if GetSelect(button2) then          '1
         SetSelect(button1,0)
         SetSelect(button3,0)       
      end if       
      case button3
      if GetSelect(button3) then          '1
         SetSelect(button1,0)
         SetSelect(button2,0)   
      end if 
    end select
  end if
loop until event2->EXITEVENT
event2->EXITEVENT=0
   GadgetOff (radioaH,radiocH)
   'GadgetOff (button1,button3)
    delete event2
    screenset 0,0       
    windowtitle "videopage 0 switched..."
 dotColor=GadgetColor
end sub

 
sub wiget2() 
dim as any ptr gfxbackup5   
dim as integer y2,y1,x2,x1,gX,gY,ramikX,ramikY,widzetW,widzetH
dim as integer x,y,w,h
dim as EventHandle ptr event=new EventHandle

dim as Gadget ptr list2,label1,separe
dim as Gadget ptr radioa,radiob,radioc,radiod
gX=400
gY=200
list2=AddListBox(event,gX,gY,26,10,1)'<-!!!! mode 0=bisherige Darstellung, mode=1 Spielerei mit Label und Item
'TO_AppendLine(list2, " Aieee !,  distro runs ? ")
TO_AppendLine(list2, "Dynamic widget, close it !")
TO_AppendLine(list2, "LBL:distros:")
TO_AppendLine(list2, "ITM:001:Danix")
TO_AppendLine(list2, "ITM:002: Knoppix 7")
TO_AppendLine(list2, "ITM:003:  Slacko 533")
TO_AppendLine(list2, "ITM:004:   Mint 9")
TO_AppendLine(list2, "ITM:005:  Ultima 1")
TO_AppendLine(list2, "ITM:006: DSL 4.10")
TO_AppendLine(list2, "ITM:007:OpenSuSe 12")
UpdateGadget(list2)

screenset 1,0
paint (100,100),cGold

label1=AddLabel(event,gX+16,gY+5+list2->gadh,"terminal:",cSilver)

dotColor=cBlack
radioa=AddRadioButton(event,420,390,1,"none",0)
radiob=AddRadioButton(event,420,410,0,"xTerm",radioa)
radioc=AddRadioButton(event,420,430,0,"rxvt",radioa)
radiod=AddRadioButton(event,420,450,0,"urxvt",radioa)

'separe=AddSeparator(event,420,470,"Dole ??",cSilver,radiod->gadw)
separe=AddLabel(event,420,470,"Ready ??",cSilver)
screenset 2,2

/' 'old code
ramikX=20   'frame
ramikY=10
x1=gX-ramikX
y1=gY-ramikY
x2=gX+ramikX+list2->gadw
y2=separe->posy+separe->gadh+ramikY
'/
'NEW elegant way
ramikX=20   'frame
ramikY=10
CalcMinBBox (event,x,y,w,h)
x1=x-ramikX
y1=y-ramikY
x2=x+ramikX+w
y2=y+ramikY+h
'? "x1,x2  y1,y2";x1,x2,y1,y2

widzetW=x2-x1+1      'wiget size
widzetH=y2-y1+1

'? "widzetW x widzetH ";widzetW;"x";widzetH
gfxbackup5=imagecreate(widzetW,widzetH)

 if gfxbackup5>0 then get (x1,y1)-(x2,y2),gfxbackup5
 
line (x1,y1)-(x2,y2),cGold,BF
line (x1,y1)-(x2,y2),cSilver,B

GadgetOn (list2,separe)

Separator (420+10+separe->gadw,470+10,x2-x1-separe->gadw-3*ramikX)

do
  event->xSleep(1)
   if KEY<>"" or RMB then event->EXITEVENT=1
   if event->GADGETMESSAGE then
  end if
loop until event->EXITEVENT
GadgetOff (list2,radiod)
'refresh
 put (x1,y1),gfxbackup5,pset
imagedestroy gfxbackup5

delete event
end sub


Here is "Demo-activation2.bas" with gold dynamic widget and 3 videopages.
Trouble of dynamic widget creation is that I don't know size of all single gadgets sooner, prior using Add.. routine,
for drawing golden square widget background.
Only after that I can use Add... routines.So missing me group of routines like 'GetGadgetSize.Add...()' with the same header as 'Add...()' routine has.
Pseudocode wil looks like

Code: Select all

...
wigetSize=(0,0)         'widget size is empty
wigetSize+=GetGadgetSize.Add...gadgetA()   'gadget size is - widget size  will be
wigetSize+=GetGadgetSize.Add...gadgetB()   'gadget size is - widget size  will be
wigetSize+=GetGadgetSize.Add...gadgetC()   'gadget size is - widget size  will be
wigetSize+=GetGadgetSize.Add...gadgetD()   'gadget size is - widget size  will be
'widget size known
get ...               'store screen background
line ...,cGold,BF         'draw widget golden background
Add...gadgetA()      'create all gadgets
Add...gadgetB()
Add...gadgetC()
Add...gadgetD()
GadgetOn(A,D)
...
GadgetOff(A,D)
put ...            'restore screen background

edit:
- dynamic widgets building OK now

Image
Last edited by petan on Oct 11, 2014 21:47, edited 9 times in total.
Muttonhead
Posts: 118
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Oct 09, 2014 16:34

@petan:

open "sGUI_Misc.bas" and append these lines

Code: Select all

'******************************************************************************
'******************************************************************************
'Set new background in one or all control(s)***********************************

sub SetNewBackGround overload (gad as Gadget ptr)
  gad->SaveBackGround
  if gad->subevent then
    for i as integer=0 to ubound(gad->gad)
      if gad->gad(i)>0 then
        SetNewBackGround (gad->gad(i))
      end if
    next i
  end if
end sub



sub SetNewBackGround (event as EventHandle ptr)
  dim as Gadget ptr gad
  gad=event->GadgetList->GetFirst
  if gad then
    do
      SetNewBackGround (gad)
      gad=cast(Gadget ptr,gad->next_node)
    loop until (gad=0)
  end if
end sub



'******************************************************************************
'******************************************************************************
'Calculates the Minimum Bounding Box that surrounds all controls***************

sub CalcMinBBox (event as EventHandle ptr, byref BBposx as integer,byref BBposy as integer, byref BBwidth as integer, byref BBheight as integer)
  dim as integer bbleft,bbright,bbtop,bbbottom
  screeninfo bbleft,bbtop
  bbbottom=0
  bbright=0
  dim as Gadget ptr gad

  gad=event->GadgetList->GetFirst
  if gad then
    do
      if gad->posx < bbleft then bbleft=gad->posx
      if gad->posy < bbtop then bbtop=gad->posy
      if gad->posx + gad->gadw - 1 > bbright then bbright = gad->posx + gad->gadw - 1
      if gad->posy + gad->gadh - 1 > bbbottom then bbbottom = gad->posy + gad->gadh - 1
      gad=cast(Gadget ptr,gad->next_node)
    loop until (gad=0)
  end if
  BBposx    =bbleft
  BBposy    =bbtop
  BBwidth   =bbright - bbleft + 1
  BBheight  =bbbottom - bbtop + 1
end sub


a bounding box + replace background demo:

Code: Select all

#include "sGUI\sGUI.bas"
#include once "sGUI\SimpleGadget.bas"
using sGUI

screen 19,32

InitGFX

dim as EventHandle ptr event=new EventHandle

dim as Gadget ptr button1,button2
button1= AddSimpleGadget(event,100,250,200,20,"upper left")
button2= AddSimpleGadget(event,430,330,200,20,"bottom right")
GadgetOn(button1,button2)
print "press any key"
sleep


GadgetOff(button1,button2)
cls
GadgetOn(button1,button2)
dim as integer x,y,w,h
CalcMinBBox (event,x,y,w,h)
line (x,y)-(x+w-1,y+h-1),&HFF8800,b
print "a Minimum Bounding Box that surrounds all controls"
print "no background image"
print "press any key"
sleep

GadgetOff(button1,button2)
cls
bload "BMPs\stives.bmp",0
SetNewBackGround (event)
print "all controls off -> load new background to screen -> save new background for each control in list"
print "press any key"
sleep


cls
GadgetOff(button1,button2)
print "all controls off -> whith new background"
print "press any key"
sleep

cls
GadgetOn(button1,button2)

do
  event->xSleep(1)
loop until event->EXITEVENT
close ff
delete event


@TJF:
I do not know if I am good as a beta tester ... I'm not very deep into the matter.
And, the most important thing: my wife complains already: I sit too long in front of the screen :D

Mutton
TJF
Posts: 3502
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: sGUI

Postby TJF » Oct 09, 2014 17:03

Muttonhead wrote:And, the most important thing: my wife complains already: I sit too long in front of the screen :D

She just wants to spend time together. Let her help with the testing ;-)
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Oct 09, 2014 20:36

founded next tuning ;)

I am not alone I think, who hate writing on white background.This is done by default in routines
'AddMultiLineEditBox'+'AddComboBox'+'AddListBox' and 'AddStringGadget' by using line 'ClearBox...,white' in related gadget files.
So, solution was easy - added global variable 'GadgetTextBackgroundColor' and changed line 'ClearBox...,GadgetTextBackgroundColor' in all touched files related to mentioned gadgets
("ComboBox_Basis.bas","ListBox_Basis.bas","MultiLineEditBox_Basis.bas","sGUI.bas","sGUI_Drawing.bas")
- GadgetTextBackgroundColor =&HFFC880 'added into 'InitGFX' routine in "sGUI.bas"
- dim shared as uinteger GadgetTextBackgroundColor 'added into "sGUI_Drawing.bas"
Usage:
Changing this variable somewhere prior calling 'GadgetOn(...)' leads to new text background color in ALL text gadgets activated.

Usable for both static&dynamic gadget's usage style.
(Top solution is unique Color style for every text gadget, but this is not 'Question of the Day' for me, actually.
sGUI(tuned) become to stay very interesting, putting it into my another app).
Screenshot placed on previous page #2 bottom - background color is like a dust sand
Last edited by petan on Oct 10, 2014 6:07, edited 1 time in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Oct 09, 2014 23:44

@ Muttonhead

YESS ! That's it !
Exactly done, Muttonhead; THANK YOU !!

Code example:

Code: Select all

#include "sGUI\sGUI.bas"
#include once "sGUI\SimpleGadget.bas"
using sGUI
screen 17,32
InitGFX
 bload "BMPs\stives.bmp",0

dim as EventHandle ptr event=new EventHandle
dim as integer x,y,w,h
dim as integer y2,y1,x2,x1,gX,gY,ramikX,ramikY,widzetW,widzetH
dim as Gadget ptr button1,button2
button1= AddSimpleGadget(event,100,250,200,20,"upper left")
button2= AddSimpleGadget(event,430,330,200,20,"bottom right")

ramikX=20   'frame
ramikY=10
CalcMinBBox (event,x,y,w,h)
x1=x-ramikX
y1=y-ramikY
x2=x+ramikX+w
y2=y+ramikY+h

'? "x1,x2  y1,y2";x1,x2,y1,y2
widzetW=x2-x1+1      'widget size (for image saving)
widzetH=y2-y1+1

line (x1,y1)-(x2,y2),&HFF8800,BF     'widget drawn
SetNewBackGround (event)
GadgetOn(button1,button2)

do
  event->xSleep(1)
  if KEY<>"" then event->EXITEVENT=1
loop until event->EXITEVENT
? "is out.."
delete event
sleep
end
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Oct 11, 2014 21:35

Setting/changing numerical values, or interval ??

Hmm, what is core routine for displaying/setting numerical value (or interval) ?
After trying I solved/enabled this with 'AddStringGadget' - see snippet (incr/decr with step 0.1)
Is that one and only possible way ? (conversion any numerical type to string after INCR/DECRementing) + displaying new string ?

Code: Select all

'changes/adds in "Demo_ActivationTest2.bas"
'...
dim as single kolik      '=1
dim as string someText="3",someText2=""
'...
dim as Gadget ptr bmpplus,bmpminus,label,label2,label3,label4,bmpPMvalue
'...
bmpPMvalue=AddStringGadget(event,80,330,10,someText)
bmpPMvalue->caption=someText

'...
      case bmpplus
      bmpPMvalue->caption=str(val(bmpPMvalue->caption)+0.1)
      kolik=val(bmpPMvalue->caption)
      bmpPMvalue->caption=str(kolik)
      SetString (bmpPMvalue,bmpPMvalue->caption)    
      UpdateGadget(bmpPMvalue)    
'      kolik=val(bmpPMvalue->caption)
       locate 21,40:? using "###.#";kolik

'additional job - changing text contents in 'stringer' gadget          
      someText2="second"
      SetString (stringer,someText2)    
      UpdateGadget(stringer)    
     case bmpminus
      bmpPMvalue->caption=str(val(bmpPMvalue->caption)-0.1)
      kolik=val(bmpPMvalue->caption)
      bmpPMvalue->caption=str(kolik)      
      SetString (bmpPMvalue,bmpPMvalue->caption)    
      UpdateGadget(bmpPMvalue)    
'      kolik=val(bmpPMvalue->caption)
       locate 21,40:? using "###.#";kolik

'additional job - changing text contents in 'stringer' gadget
      someText2="third"
      SetString (stringer,someText2)           
      UpdateGadget(stringer)           
    end select
  end if
loop until event->EXITEVENT
Muttonhead
Posts: 118
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Oct 12, 2014 7:23

Hmm, what is core routine for displaying/setting numerical value (or interval) ?
After trying I solved/enabled this with 'AddStringGadget' - see snippet (incr/decr with step 0.1)
Is that one and only possible way ? (conversion any numerical type to string after INCR/DECRementing) + displaying new string ?


Its SetString(). No update needed.
But a Stringgadget use a TextObject to handle the String.(in the first row of a TO)
So you can use TO_routines. if you modifiy the string via this way you need an update

Short: YES you have to convert every number. A StringGadget can handle a string only

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

Re: sGUI

Postby petan » Oct 13, 2014 10:40

After long tryings+searching in files to get working countdown/up by pressed and holded mouse button I found this:

a) missing in "QuickReference..pdf"
- detailed 'xSleep' parameter explanation + examples
What exactly does xSleep(1),xSleep(0),xSleep(-1) and its double parameter specification, e.g.(-1,0)??
On page 2 founded written only

Code: Select all

event->xSleep(1)   'methode of EventHandle, program waits here for an event, (this behavior is optional)

- detailed 'GadgetControl' explanation + examples

b) for correctly working continual countdown/up of numerical value is needed this code "Demo_ActivationTest2.bas"

Code: Select all

'...   
do
  event->xSleep(0)   'CHANGE !!!
'...   
'...   
  if event->GADGETMESSAGE then
    select case event->GADGETMESSAGE 
'...   
'...   
    end select
  end if 
   if bmpminus->over and LMB=HOLD then 
        bmpPMvalue->caption=str(val(bmpPMvalue->caption)-0.1)
      kolik=val(bmpPMvalue->caption)   'fix rounding issue
      bmpPMvalue->caption=str(kolik)   'fix rounding issue      
      SetString (bmpPMvalue,bmpPMvalue->caption)    
      UpdateGadget(bmpPMvalue)    
       locate 21,40:? using "###.#";kolik
   end if      
   if bmpplus->over and LMB=HOLD then 
      bmpPMvalue->caption=str(val(bmpPMvalue->caption)+0.1)
      kolik=val(bmpPMvalue->caption)   'fix rounding issue
      bmpPMvalue->caption=str(kolik)   'fix rounding issue
      SetString (bmpPMvalue,bmpPMvalue->caption)    
      UpdateGadget(bmpPMvalue)    
       locate 21,40:? using "###.#";kolik
   end if
loop until event->EXITEVENT

This is temporary solution yet, I think better would be to write new routines for setting numeric values/intervals
such as e.g. 'AddSetNumeroValueGadget()', 'AddSetNumeroIntervalGadget()'
Muttonhead
Posts: 118
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Oct 13, 2014 13:59

If you want action while holding a button then take a look in the Code of an arrowbutton( see in "action routine"). SimpleGadgets and BMPGadgets dont trigger, but its possible to change this behavior. Modify their "action routine".

Mutton

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest