sGUI

User projects written in or related to FreeBASIC.
Muttonhead
Posts: 117
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Dec 12, 2014 6:23

Code: Select all

MenuOff(event)
MenuOff(event)
MenuOn(event)
MenuOff(event)
MenuOff(event)
MenuOn(event)
MenuOn(event)
MenuOff(event)
MenuOff(event)
MenuOn(event)


runs fine on my machine.
But youre right, there is a bug.
Recalling MenuOn creates a new imagebuffer whithout deleting the previous.
Recalling MenuOff deletes an no longer existing imagebuffer

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

Re: sGUI

Postby petan » Dec 12, 2014 8:23

Could you write example for multilevel 'Menu or Listbox or Combobox', Mutton ?
Actually I work in 5 projects and seeing this as highly missing in Mistral.
Muttonhead
Posts: 117
Joined: May 28, 2009 20:07

Re: sGUI

Postby Muttonhead » Dec 12, 2014 11:36

What do you mean with "multilevel" exactly? Such a thing like submenues?

Haaa, function ->GetMenuStatus allways exists. Forget to use it :)

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

Re: sGUI

Postby petan » Dec 13, 2014 1:32

Yes, interest me getting standard submenus style to work .Playing with examples..
I don't know this theme, just seeing on problem, howto define/dim/index it all -
items in sub/menu's strip lists - in easy way.
E.g. for 5 submenu levels I see it as quite polymorphed octopus, or fractal; not a regular squared matrix.
So manually entering all for a bit real app looks hard&long, something easier needed to me .
With designer work it will be better - regrouping text items on right places = much faster job.
Seems I'll add a few new easy menumouseflags to decode status quo for opening a submenu; similar ones as used for gadget moving.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Dec 13, 2014 10:13

"Phrases.bi" tuning ;)

Code: Select all

'phrases
const as string phrase_ok="OK"
const as string phrase_cancel="Cancel"
const as string phrase_retry="Retry"
const as string phrase_ignore="Ignore"
const as string phrase_yes="Yes"
const as string phrase_no="No"
const as string phrase_path="Path"
const as string phrase_load="Load"
const as string phrase_open="Open"
const as string phrase_save="Save"
const as string phrase_edit="Edit"
const as string phrase_delete="Delete"
const as string phrase_search="Search"
const as string phrase_file="File"
const as string phrase_folder="Folder"
const as string phrase_drive="Drive"
const as string phrase_error="Error"
const as string phrase_mask="Mask"
const as string phrase_fileaccessdenied="file access denied"
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Dec 13, 2014 11:56

Added variables for multileveling ;)
"sGUI.bas"

Code: Select all

'...
'Gadget params
const as integer MAXsnapshotIndex=3         'my
'Multileveling
dim shared as integer mouseOnStripItem=0,mouseOnMenuHeadItem=0,mouseOnStripItemID=0,mouseOnMenuHeadItemID=0   'my
'Keyboard
dim shared as string  KEY
'...
Last edited by petan on Dec 14, 2014 0:26, edited 1 time in total.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Dec 14, 2014 0:00

Taking farer look on it..
What about this syntax for multilevel menus ?

Code: Select all

refMenu(event,parentMenuID,actualMenuID,childrenMenuID,parentItemStripIndex,itemStripIndex,activatedYN,itemText)
'or
refMenu(event,parentMenuID,actualMenuID,parentItemStripIndex,itemStripIndex,activatedYN,itemText)

If NONE parentMenuID or childrenMenuID exists, then its value=0
(main menu or last submenu)
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Dec 14, 2014 0:45

'Hiliter' tuning ..;)

Code: Select all

sub EventHandle.Hiliter (overheader as MenuHeader ptr)
  dim as MenuItem ptr overitem
'my 8x
mouseOnStripItem=0:mouseOnStripItemID=0
if overheader>0 then
   mouseOnMenuHeadItem=1
   mouseOnMenuHeadItemID=overheader->headerID
else
 mouseOnMenuHeadItem=0
 mouseOnMenuHeadItemID=0
end if
 
 if strippedheader then
    if hiliteheader<>strippedheader then
      if hiliteheader then hiliteheader->DoDraw(hiliteheader,0)
      strippedheader->DoDraw(strippedheader,1)
      hiliteheader=strippedheader
      hiliteitem=0'Striphighlighting
    end if

    'Block Striphighlighting
    overitem=GetMenuItemPointer(strippedheader)
    if overitem then
      mouseOnStripItem=1         'my
      mouseOnStripItemID=overitem->itemID   'my
      if hiliteitem<>overitem and strippedheader->act=1 then
        if hiliteitem then hiliteitem->DoDraw(hiliteitem,0)
      overitem->DoDraw(overitem,1)
      hiliteitem=overitem
     end if
    else
      if hiliteitem then hiliteitem->DoDraw(hiliteitem,0)
      hiliteitem=0
   end if
    'Ende Block Striphighlighting

 else
     if overheader>0 then
      if hiliteheader<>overheader then
        if hiliteheader then hiliteheader->DoDraw(hiliteheader,0)
        overheader->DoDraw(overheader,1)
        hiliteheader=overheader
      end if
     else
      if hiliteheader>0 then
        hiliteheader->DoDraw(hiliteheader,0)
        hiliteheader=0
      end if
     end if
    hiliteitem=0'Striphighlighting
 end if
end sub
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Dec 14, 2014 10:10

Example for new 4 variables functionality test: (ride&select menu element or go off menu area)
"Demo-mouseOnMenuElement.bas"

Code: Select all

'Compileroption -s gui
#include "sGUI\sGUI.bas"
#include once "sGUI\Menu.bas"
using sGUI
screen 20,32
InitGFX
dim as EventHandle ptr event=new EventHandle


Menu (event,1,0,1,"Menue A")    '"Header", that what you can see as menuname in the menubar
Menu (event,1,1,1,"Eintrag A")  'normal item, active
Menu (event,1,2,0,"Eintrag B")  'normal item, inactive
Menu (event,1,3,4,"")           'separator
Menu (event,1,4,3,"Option A")   'entry with checkmark, active
Menu (event,1,5,2,"Option B")   'entry with checkmark, inactive

Menu (event,2,0,1,"")           'menu 2 and its strip will not be displayed, cause headers string is empty
Menu (event,2,1,1,"subEintrag 1")  '
Menu (event,2,2,0,"subEintrag 2")  '
Menu (event,2,3,1,"subEintrag E")  '
Menu (event,2,4,0,"subEintrag F")  '
Menu (event,2,5,1,"subEintrag 3")  '
Menu (event,2,6,0,"subEintrag 4")  '
'menu 3 shifts to left (menu 2 is invisible)
Menu (event,3,0,0,"Menue C")    'when header is inactive, then its strip is inactive too
Menu (event,3,2,0,"Eintrag D")  'item activation ignored
Menu (event,3,1,1,"Eintrag C")  'item activation ignored
MenuOn(event)

do
  event->xSleep(1)
  locate 5,5:? space(100)
  locate 6,5:? space(100)
  locate 6,5:? "   menuID= "+str(mouseOnMenuHeadItemID)+"   itemID= "+str(mouseOnStripItemID)   
  if KEY="q" then event->EXITEVENT=1
  if event->MENUMESSAGE then
   locate 5,5:? "mouseOnGadget= "+str(mouseOnGadget)+ "    mouseOnMenuHeadItem= "+str(mouseOnMenuHeadItem)+"    mouseOnItem= "+str(mouseOnStripItem)+"   MENUNUMBER= "+str(event->MENUNUMBER)+"   ITEMNUMBER= "+str(event->ITEMNUMBER)
  end if
loop until event->EXITEVENT

delete event
? "is out.."
sleep 1500
end
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Dec 24, 2014 13:20

Founded important thing; this must be documented in 'eventloop' hint/warning.
When some gadget (MultilineEditor e.g.) is used repeatidly in own separate eventloop,
(no Scope/Sub/Funct for clearing variables), then this code must be used:

Code: Select all

'..
event->exitevent=0   
do
'..
loop until event->exitevent=1

otherwise gadget is executed only one times.I spent quite long moment until discovering this.
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Dec 27, 2014 12:06

'ListBox' tuned..
In DrawLB() fixed first 2 spaces for ITM.Not needed here, seems, if you need it - add it via 'TO_AppendLine=space(2)+yourString(i)'.
yourString(i) stays untouched for next work !
"ListBox_Basis.bas"

Code: Select all

           ' tmpstring=left(space(2) & right(tmpstring,len(tmpstring)-8),boxc)   'orig
            tmpstring=left(right(tmpstring,len(tmpstring)-8),boxc)      'my


Second thing seen - I always forget to add zero prefix to itemID.
It looks easily fixable & 3 digits limitation could be solved too.
I'll do it tonight.
edit:
Done.

Code: Select all

sub DrawLB (gad as Gadget ptr)
'...
     Dim as integer ela7
'...
          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
'...           
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Dec 30, 2014 3:47

Also in'LBActions(..)' change,
"ListBox_Basis.bas"

Code: Select all

'...
dim as integer ela7,ela8
'...
            header=left(lc,3)
            if header="ITM" then
              'itemid=mid(lc,5,3)      'orig
              ela7=InStr(lc,":")+1:ela8=InStrRev(lc,":")      'my
              itemid=mid(lc,ela7,ela8-ela7)      'my
              gad->Ctrl(14)=val(itemid)
'...

and 'SetListBoxVal(..)' too:
"ListBox.bas"

Code: Select all

'...
dim as integer ela7,ela8
'...
        header=left(lc,3)
        if header="ITM" then
          itemid=val(mid(lc,5,3))      'orig
          ela7=InStr(lc,":")+1:ela8=InStrRev(lc,":")      'my
          itemid=val(Mid(lc,ela7,ela8-ela7))      'my         
          if itemid=i then found=lcount
'...
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Jan 21, 2015 11:33

Founded problem in rgs() macro (WizDizzy); when many gadgets and someones over another >> buggy layout - OFF gads shadows criple others.
This is caused if OFF gads are at the end of gadlist, because gads are renewed in order of creation.

Possible the same problem in sGUI's RestoreGadState function, but I don't use it now, sgs+rgs is better.

Fixed - solution: simple sort and renewing gads in order: Off, Sleep,On ;)
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Feb 25, 2016 9:07

Hi, Mutton

I added for your sGUI new module "Widget.bas" to have (movable) sGUI widgets.
This is a first shot, based on "MessageBox.bas" + my tuning, after a forced year pause.Not perfect I know, but works.

Just I cannot remember if sGUI has already X-button written, usable as 'CLOSE btn' for widget; so I solved it speedy
by label "x" in first try, after that (no big likeing) I made a small tuning in "Arrows.bas".
X-btn is added as arrow 4.
"Arrows.bas"

Code: Select all

function AddArrow(...)
(...)
'    if DirArrow=2 or DirArrow=3 then   'orig
    if DirArrow=2 or DirArrow=3 or DirArrow=4 then    'my - close button added
      gad->gadw=15
      gad->gadh=16
    end if
(...)

"sGUI_Drawing.bas"

Code: Select all

(...)
sub Arrow (xpos as integer,ypos as integer,size as integer,d as integer,col as uinteger)
  dim as integer i
  for i=0 to size
    if d=0 then line(xpos+size-i,ypos+i)-(xpos+size-i,ypos+2*size-i),col
    if d=1 then line(xpos+i,ypos+i)-(xpos+i,ypos+2*size-i),col
    if d=2 then line(xpos+i,ypos+size-i)-(xpos+2*size-i,ypos+size-i),col
    if d=3 then line(xpos+i,ypos+i)-(xpos+2*size-i,ypos+i),col
  next i
  'my - close button
  if d=4 then draw string (xpos+1,ypos+3-fontheight/2),"x",TextColor
end sub
(...)


Would you take a quick look and comment it, please?
Nowadays I started beta testing of WizDizzy (visualdesigner ver 0.5 ) for tuned sGUI version 084
Image
S'shot
petan
Posts: 683
Joined: Feb 16, 2010 15:34
Location: Europe
Contact:

Re: sGUI

Postby petan » Mar 19, 2016 0:01

Maybe sleepin' but this behavior looks like a bug.
If combobox created with 1 item, no detection of clicked item (getcomboboxval prints nothing), if clicked e.g. 5 times in a row!
Also, when combo created with more items, value setted to 1 - getcomboboxval prints nothing at repeatidly clickin' on its first item.
Correct reaction after click on 2+ item, then on first - detected ok, and all next cliks on the first item are unrecognized.
Bug in GADGETMESSAGE filling, or MiniSelector ?? or something another..?
(I want to move LOAD project option from Add NEW mode to Edit Old as first item in a list for designer)

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 20 guests