sGUI

User projects written in or related to FreeBASIC.
Roland Chastain
Posts: 858
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: sGUI

Postby Roland Chastain » Jun 03, 2012 19:09

Done!

I am glad of this little binary-decimal converter. :-)

I will try BMP later.

Thank you friends for your kind help.
counting_pine
Site Admin
Posts: 6200
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: sGUI

Postby counting_pine » Jun 04, 2012 1:00

I think the binary-decimal converter is effectively equivalent to doing valint("&b" & n).
It's also worth noting that '1 shl n' is a very fast way to do powers of 2.
Roland Chastain
Posts: 858
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: sGUI

Postby Roland Chastain » Jun 04, 2012 23:04

counting_pine wrote:I think the binary-decimal converter is effectively equivalent to doing valint("&b" & n).
It's also worth noting that '1 shl n' is a very fast way to do powers of 2.


Thank you for the tips, counting_pine. I will have a look at this.
Roland Chastain
Posts: 858
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: sGUI

Postby Roland Chastain » Sep 19, 2014 7:26

Hello! More than two years without a new post in this thread! sGUI 0.8.4 has just been released.
tinycla
Posts: 121
Joined: Jan 07, 2006 12:51

Re: sGUI

Postby tinycla » Sep 23, 2014 12:47

It's an interesting library, it works well on both Windows and Linux. Would it be possible to set the default font for all control? It would be nice if we can use truetype fonts.
Roland Chastain
Posts: 858
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: sGUI

Postby Roland Chastain » Sep 23, 2014 16:04

tinycla wrote:Would it be possible to set the default font for all control?


Unfortunately I believe it isn't possible for now. Muttonhead made CharSet2FBFont but it can't be used with sGUI controls. If you want True Type fonts you have to look for another library.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Sep 25, 2014 0:44

Awesome job, thx.
Tested on Puppy linux + FB0901, OK.
But problem founded:
1/ missing EN documentation
( what exactly does 'GadgetOff(xyz)' routine ? )
2/ in "Demo_BMPSimpleGadget.bas" added my testing code to the end of file

Code: Select all

? "is out..."
GadgetOff(plus)
GadgetOff(minus)
sleep
end

Awaited disappearing of both gadgets, but only 'minus' is away; plus gadget is still there..

(edit:)
#1/ OK now, thx.
#2/ Solved by next replies, thx.
Last edited by petan on Oct 07, 2014 12:39, edited 4 times in total.
Muttonhead
Posts: 130
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Sep 25, 2014 15:54

At moment sGUI support the buildin Fonts only. All internal calculations based on that fact. Maybe, an iso BitmapFont... in the Future :) Sorry for that.

@petan:
Yeahh, my English is not so good... i can translate all that stuff via google, but, it doesnt make the situation better... :)

The main function of GadgetOff is: 1.) make the control unusable and 2.) invisible (restore the origin background).

But i can not repeat the problem with your snipplet. Is it possible to get more code?

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

Re: sGUI

Postby petan » Sep 26, 2014 1:41

(edit:)
explained in replies ('delete event' placing..), thx.

Also problem founded for syntax GadgetOff(from,to).
In the same example file, when Ini/Deinitialisation changed
from:

Code: Select all

GadgetOn(plus)
GadgetOn(minus)
...
GadgetOff(plus)
GadgetOff(minus)

to:

Code: Select all

'GadgetOn(plus)
'GadgetOn(minus)
GadgetOn(plus,minus)
...
'GadgetOff(plus)
'GadgetOff(minus)
GadgetOff(plus,minus)

here already nothing happened at all..


After longer evening tries a few notes:
1/ sGUI has own event handling, so missing me here examplefile for detection, what is pressed.
Do-loop cycle>>Printing->
-nothing pressed
-keyboard AND/OR mouse pressed ..> which buttons

2/ sGUI looks quite well expandable.
Example "Demo_ActivationTest.bas" shows,IMO, static screen layout.
Sothat next examplefile for dynamic screen layout is missing and would be good to add one.
Dynamic I mean (e.g.) opening subwindow/box/gadget (with controls) in fullscreen mode for changing some parameters of program flow.
'OK + Cancel' buttons unneeded for closing gadget - possible by 'ESC' or 'right MouseButton' pressing (or any other defined).
In such manner this dynamics takes style of AntTweakBar(scientific needs) or H.U.D.(game needs).

3/ cosmetic sGUI pack improvement, for easier life maybe better would be
- adding folder "Documentation" with En and De manual/tutorial
plus Readme.txt file, naming what is what (a few words about sGUI + usage>>which FB version is needed + what are examples and how named >> "Demo_something.bas")
plus Changelog.txt file
Reason - as I am on Puppy linux, DE .pdf manual was not seen and I was lost for a moment (what is what&where), due midwindows opening by system.

[edit:]
#1/ simple example written
#2/ Solved "Demo_ActivationTest-2.bas"
Last edited by petan on Oct 10, 2014 6:19, edited 6 times in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Sep 26, 2014 1:46

Yes, here is tuned example
BTW all examples compiled as GUI.

Code: Select all

'Compileroption: "-s console"
#include "sGUI\sGUI.bas"
#include once "sGUI\BMPSimpleGadget.bas"
using sGUI

screen 14,32
InitGFX 0

dim as EventHandle ptr event=new EventHandle

dim as Gadget ptr plus2,minus2
plus2= AddBMPSimpleGadget(event,30,30,"BMPs\PlusUnSelected.bmp","BMPs\PlusSelected.bmp","BMPs\PlusMask.bmp")
minus2= AddBMPSimpleGadget(event,41,30,"BMPs\MinusUnSelected.bmp","BMPs\MinusSelected.bmp","BMPs\MinusMask.bmp")
'GadgetOn(plus2)
'GadgetOn(minus2)
GadgetOn(plus2,minus2)

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

do
  event->xSleep(1)
  if KEY<>"" then
   if KEY="q" then exit do   'my
  end if 
  if event->GADGETMESSAGE then
    select case event->GADGETMESSAGE
      case plus2
        print #ff,"BMPSimpleButton PLUS wurde angeklickt"
      case minus2
        print #ff,"BMPSimpleButton MINUS wurde angeklickt"
    end select
  end if
loop until event->EXITEVENT

close ff

delete event
? "is out ..."
'GadgetOff(plus2)
'GadgetOff(minus2)
GadgetOff(plus2,minus2)
sleep
end
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Sep 26, 2014 1:51

Don't worry about english in documentation, we will help you with it ;)
Muttonhead
Posts: 130
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Sep 26, 2014 8:03

@petan:
Ok, i will start an english doc. :)

Code: Select all

   'Compileroption: "-s console"
    #include "sGUI\sGUI.bas"
    '......
    using sGUI

    screen 14,32
    InitGFX 0

    dim as EventHandle ptr event=new EventHandle
   
   'now you can use all sGUI related routines
   'they work proper while an Eventhandle exists
   
    delete event
   


All Add... routines are allocating memoryblocks for the controls.
Inside of the Eventhandle all controls are managed in a list.
If you delete the Eventhandle you are delete the controls too.
A call of GadgetOff() after "delete event" is an access to memory that
not longer belongs to the program

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

Re: sGUI

Postby petan » Sep 26, 2014 12:59

Continuing tests with example "Demo_ActivationTest.bas".
Without documentation I tune it with adding a few checklog lines of code for knowing what happened.
One gadget moved on other place to get printing area for checklogs.
Code here.

Code: Select all

'Compileroption -s console
#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

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

'screen 20,32,,&H04      'my1

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

InitGFX
bload "BMPs\stives.bmp",0
 dim as EventHandle ptr event=new EventHandle

dim as Gadget ptr check,acton,actsleep,actoff
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 okay,opta,checker,radioa,radiob,radioc
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
dim as Gadget ptr listbox,combobox,textbox

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

radioa  =AddRadioButton(event,20,120,1,"ball",0)
radiob  =AddRadioButton(event,20,140,0,"cube",radioa)
radioc  =AddRadioButton(event,20,160,0,"cone",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")
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,670,25,10,20)   'orig
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)
'sleep
GadgetOn (okay,textbox)
'? "GadgetOn(okay,textbox)...":sleep

MenuOn(event)   'activated upper bar
'? "MenuOn(event)...":sleep
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,"")      'my
menu (event,1,6,1,"End")

'switch off activation messagebox
/'
GadgetSleep (acton,textbox)
MessageBox(200,300,"Activation Demo","!",MBType_OK or KEY="a")
RestoreActivation (acton,textbox)
'/

' 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
  '? "KEY=";KEY
  '? "ascKEY=";asc(KEY)
   if KEY="q" then exit do      'my
   'if KEY="Enter" then ? "Enter.."   'my
   if KEY=chr(13) then ? "Enter.."      'my
  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 - off
          if MessageBox(200,200,"End Demo ???","Question",MBType_YESNO)=MBButton_YES then
             'keyboard not accepted ??
          'if MessageBox(200,200,"End Demo ???","Question",MBType_YESNO)=KBButton_YES then   'keyboard not accepted ??
           'sleep
           ? tab(84);" End Demo ?? YES"
            event->EXITEVENT=1
          else
            RestoreActivation (acton,textbox)
            'RestoreActivation (okay,textbox)
           ? tab(84);" End Demo ?? NO"
          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
    end select
  end if
loop until event->EXITEVENT
 ? tab(84);"is out..."
 MenuOff(event)            'works Here
 GadgetOff (okay,textbox)   'works Here
delete event

/'
   'segfaults if enabled here
   'event is global ??
? "event=";event   
'GadgetOff (okay,textbox)   
'GadgetOff (acton,textbox)   
'GadgetOff(acton,check)      
'/
sleep
end

Founded three things-
# 1/ Gadgets bmpplus bmpminus (AddBMPSimpleGadget...) are here switched off/sleeped correctly, if among others controls.In separate example as reported previously, not good.
[edit]
Ha, depends on event deleting place, as you wrote.I found out this problem here and untest gadget in separate example.Really tired&sleeping..
I'll test it today.Seems, thing #1 is SOLVED

# 2/ When clickin on 'Exit demo -> NO' five times in line, I see two cycling behaviors - hiding/appearing
a/ all simple gadgets hidden & appeared gadgets: check+acton+actsleep+actoff
b/ all simple gadgets appeared & hidden gadgets: check+acton+actsleep+actoff
Screenshots of that:
Image
Image

Why ?, if I do nothing with that.
Seems this is done by 'RestoreActivation(...)' routine.Bug there ..?
What exactly does 'RestoreActivation(...)' routine ?

# 3/ How looks code e.g. for Messagebox ?, if I need 'YES' choice with either 'Enter' keyboard button or 'right mousebutton' pressing to have it confirmed ?

[edit:]
Okay; #1/ and #3/ Solved now.
#2/ Explained, thx.

Thanks for your answers, Muttonhead, to get me out of troubles.
Last edited by petan on Oct 05, 2014 9:32, edited 2 times in total.
Muttonhead
Posts: 130
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Sep 26, 2014 16:51

@petan:

Activation
**********
The activation mode describes the usability and visibility of a control. There 3 states:
ON -> the control is visible and usable
SLEEP -> the control is visible(a little bit ghosty) but unusable
OFF -> the control unvisible and unusable. When you create new control (via an Add..() routine) is this the default state.

you can modify the state with these four routines:
GadgetOn(),GadgetSleep(),GadgetOff() and RestoreActivation()

If you modify an activation state, the current state will saved in the control.
The routine RestoreActivation() is a kind of "undo of last activation modification".
That can be helpfully , e.g. switch all controls off --> do another stuff on screen, when you are ready with that stuff--> restore all controls in their last activation modes.

and dont forget to re-enter an eventloop.

The Control List
****************
Inside every eventhandle is a linked list for the controls. Each Add...()routine appends a
pointer of the created control to that list. The list can only be longer!!!
Its could be important to add ( append ) related controls "en bloc". read next ;)

overload activation routines
****************************
For every Activation routine exists an overload version (with 2 parameters, first and last control of the range in list):
So its possible to modify a range of controls at the same time with one command.


Yes you comment this line in case 6-> 'GadgetSleep (acton,textbox) 'orig - off
So the controls "toggle" between their first activation "OFF" an their second activation "ON" when you call RestoreActivation again and again...

sGUI supports at moment the left mouse button only in controls. may be in future...

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

Re: sGUI

Postby petan » Sep 30, 2014 12:16

Excellent, Muttonhead!

after my small laboring I have done creation of dynamic widgets (aka classic subwindow)
+ horizontal radiobutton + user defined color for DOT (in radiobutton).
Screenshot shows one priority dynamic widget with horizontal radiobutton and custom dotcolor.
Image

(edit:)
- newer Screenshot
- creation of dynamic widgets fixed now
Last edited by petan on Oct 10, 2014 6:15, edited 3 times in total.

Return to “Projects”

Who is online

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