Page 1 of 1
FreeGadget() - Optional parameter for Window
Posted: Sun Nov 08, 2015 10:12 pm
by RSBasic
Hello,
I hope this thread does not exist already and I wish this optional parameter for window:
Re: FreeGadget() - Optional parameter for Window
Posted: Sun Nov 08, 2015 11:37 pm
by bbanelli
Would that even be possible if one is using #PB_Any for creation of gadgets?
Re: FreeGadget() - Optional parameter for Window
Posted: Wed Nov 11, 2015 5:06 pm
by mestnyi
Code: Select all
DeclareModule Free
EnableExplicit
Declare Gadgets(Gadget = #PB_Any, Window = #PB_Any)
EndDeclareModule
Module Free
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Import ""
CompilerElse
ImportC ""
CompilerEndIf
PB_Object_EnumerateStart( PB_Objects )
PB_Object_EnumerateNext( PB_Objects, *ID.Integer )
PB_Object_EnumerateAbort( PB_Objects )
PB_Gadget_Objects.i
EndImport
Procedure GadgetWindowID( Gadget )
Protected GadgetWindowID, GadgetID
If IsGadget( Gadget )
GadgetID = GadgetID( Gadget )
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
CompilerError #PB_Compiler_Procedure
CompilerCase #PB_OS_Linux
GadgetWindowID = gtk_widget_get_toplevel_ ( GadgetID )
CompilerCase #PB_OS_Windows
While GadgetID
GadgetWindowID = GadgetID :GadgetID = GetParent_( GadgetID )
Wend
CompilerEndSelect
ProcedureReturn GadgetWindowID
EndIf
EndProcedure
Procedure Gadgets(Gadget = #PB_Any, Window = #PB_Any)
If Gadget = #PB_Any
If PB_Gadget_Objects
PB_Object_EnumerateStart(PB_Gadget_Objects)
While PB_Object_EnumerateNext(PB_Gadget_Objects, @Gadget)
If IsWindow(Window)
If (WindowID(Window) ! GadgetWindowID( Gadget ))
Continue
EndIf
EndIf
FreeGadget(Gadget)
Wend
PB_Object_EnumerateAbort(PB_Gadget_Objects)
EndIf
Else
FreeGadget(Gadget)
EndIf
EndProcedure
EndModule
Macro FreeGadget(Gadget = #PB_Any, Window = #PB_Any)
Free::Gadgets(Gadget, Window)
EndMacro
CompilerIf #PB_Compiler_IsMainFile
X = 100
For i = 1 To 3
OpenWindow(i, 200, X, 150, 60, "Window_" + Trim(Str(i)))
ContainerGadget(100 * (i), 5, 5, 120,50, #PB_Container_Flat)
ButtonGadget(10 * (i),10,10,100,15,"Button_" + Trim(Str(i*10)))
ButtonGadget((i),10,25,100,15,"Button_" + Trim(Str(i)))
CloseGadgetList() ; ContainerGadget
X + 100
Next :Window = 1
FreeGadget(#PB_Any, 2)
Repeat
If IsWindow( Window )
Event = WaitWindowEvent( )
If Event = #PB_Event_CloseWindow
CloseWindow( EventWindow( ) )
Debug "Close " + EventWindow( )
EndIf
Else
Break
EndIf
ForEver
Debug "Exit"
CompilerEndIf
Re: FreeGadget() - Optional parameter for Window
Posted: Sun Sep 25, 2016 3:04 pm
by Kurzer
RSBasic wrote:Hello,
I hope this thread does not exist already and I wish this optional parameter for window:
I was about to write the same feature request, so +1 from me.
Such a parameter is very handy, if a programm creates and destroy different gadget-layouts on the same window during runtime.
Re: FreeGadget() - Optional parameter for Window
Posted: Sun Sep 25, 2016 7:37 pm
by mk-soft
For MacOS
Code: Select all
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
GadgetWindowID = WindowID(PeekI(IsGadget( Gadget ) + 4 * SizeOf(Integer)))
SDK
Code: Select all
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
;- PB Interne Struktur Gadget Windows
Structure Gadget
Gadget.i
*vt.GadgetVT
UserData.i
OldCallback.i
Daten.i[4]
EndStructure
CompilerCase #PB_OS_Linux
;- PB Interne Struktur Gadget Linux
Structure Gadget
Gadget.i
GadgetContainer.i
*vt.GadgetVT
UserData.i
Daten.i[4]
EndStructure
CompilerCase #PB_OS_MacOS
; PB Interne Struktur Gadget MAcOS
Structure Gadget
*gadget
*container
*vt.GadgetVT
UserData.i
WindowID.i
Type.i
Flags.i
EndStructure
CompilerEndSelect