IsGadgetList(#GadgetList) and CloseGadgetList(#GadgetList)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

IsGadgetList(#GadgetList) and CloseGadgetList(#GadgetList)

Post by Kwai chang caine »

Hi

If i create for example A containerGadget in an AreaGadget, it's possible to have several GadgetList one inside other like this :

Code: Select all

OpenWindow(#Window_0, 216, 0, 619, 279, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )

ScrollAreaGadget(#ScrollArea_0, 21, 27, 581, 233, 1162, 466, 10)

 ContainerGadget(#Container_0, 40, 41, 352, 138, #PB_Container_Raised)
  
  If a = x 
   ScrollAreaGadget(#ScrollArea_1, 31, 19, 249, 96, 498, 192, 10)
  EndIf
  
  Code ..... 
  Code .....
  Code .....
  Code .....
  Code .....
  
  If IsGadgetList(#ScrollArea_1)
   CloseGadgetList(#ScrollArea_1)
  EndIf

 CloseGadgetList((#Container_0)

CloseGadgetList((#ScrollArea_0)
And it's difficult in this case to manage the CloseGadgetList()
There is nothing way to control if all the GadgetLists is closed and furthermore an over CloseGadgetList() crash the program :(

Good day
ImageThe happiness is a road...
Not a destination
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: IsGadgetList(#GadgetList) and CloseGadgetList(#GadgetList)

Post by srod »

I can't say as this has ever been a problem that I have encountered Kwai. It is just something you have to manage yourself and PB does force a measure of rigour upon proceedings in that there should be a CloseGadgetList() for each OpenGadgetList() etc. Your suggestion would simply encourage some 'sloppy' coding in my opinion, as is indeed the case with the kind of code you have posted above.
I may look like a mule, but I'm not a complete ass.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: IsGadgetList(#GadgetList) and CloseGadgetList(#GadgetList)

Post by Kwai chang caine »

Ooohh!!!! my master :shock:

Forgive to your your floorcloth MASTER, i don't see your answer :oops:
Because i have fighted all the day with a bad menu :?
And obviously....no MASTER SROD at the skyline :roll:
Perhaps you are hidden behind a tree, and good hidden, because this time KCC don't find you :mrgreen:

Fortunately the MASTER TROND have helped your servant 8)
My MASTER wrote:Your suggestion would simply encourage some 'sloppy' coding in my opinion, as is indeed the case with the kind of code you have posted above.
Obviously, it's always the fault at your servant :? :lol: :lol:
And KCC always making cowpat code :? :lol:

If i have good understand, i must close and open and close.....for each element i add :roll:

Ok, ok...i make a deal with you.....but at the minimum, a empty IsGadgetList() can be usefull no ??? :roll:
Or perhaps, i have win a new medal of IDIOT today, with this new request :D
ImageThe happiness is a road...
Not a destination
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Re: IsGadgetList(#GadgetList) and CloseGadgetList(#GadgetList)

Post by Kaeru Gaman »

each window element has a GadgetList.
you can say UseGadgetList( GadgetID( #Container ) ) to add sub-gadget to one specific gadget.

yes, it's your barn duty to KNOW wich bloody list you have opened and are writing into.
oh... and have a nice day.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: IsGadgetList(#GadgetList) and CloseGadgetList(#GadgetList)

Post by srod »

Kaeru Gaman wrote:...yes, it's your barn duty to KNOW wich bloody list you have opened and are writing into.
:lol:
I may look like a mule, but I'm not a complete ass.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: IsGadgetList(#GadgetList) and CloseGadgetList(#GadgetList)

Post by Kwai chang caine »

This story of GadgetList is not really simple, but for me like usually :oops:
Because everybody have understand..everybody exept one http://www.purebasic.fr/english/memberl ... ile&u=2947 :oops:

Me i believe that the GadgetList is only with Container or Area etc..
But apparently....i can create a GadgetList with not Gadget around :roll:

I have read the example of FRED, at the first see...it's logic...but after see more...
KCC ask to him : "Why is the real use of GadgetList alone, exept if the windows is #PB_Window_NoGadgets" :roll:

Never mind...perhaps a day KCC understand....it's like that perhaps a day it snowing in the desert :mrgreen:

Code: Select all

If OpenWindow(0, 0, 0, 500, 500, "Fenêtre principale", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
    ButtonGadget(0, 10, 10, 150, 25, "Bouton 1")
    
    ; Creation d'une seconde fenêtre avec #PB_Window_NoGadgets pour empêcher la création automatique d'une GadgetList
    If OpenWindow(1, 0, 0, 300, 200, "Fenêtre secondaire", #PB_Window_TitleBar|#PB_Window_WindowCentered|#PB_Window_NoGadgets, WindowID(0))     
      OldGadgetList = UseGadgetList(WindowID(1)) ; Creation d'une GadgetList et sauvegarde l'ancienne GadgetList
      
      ButtonGadget(10, 10, 10, 150, 25, "Bouton Fenêtre secondaire") ; Ajoute ce bouton dans la nouvelle GadgetList(Fenêtre secondaire)
      
      UseGadgetList(OldGadgetList)               ; Retour à la GadgetList précédente
    EndIf
    
    ButtonGadget(1, 10, 45, 150, 25, "Bouton 2") ; Ce bouton sera sur la fenêtre principale 
    
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
ImageThe happiness is a road...
Not a destination
Post Reply