ID and Parent
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: ID and Parent
Bear in mind that it's not a case of the team just including this code in the package. They have to start from scratch and write the procedures in the development language, which I believe is C, using their own logic and design, with appropriate documentation. It's a lot of work and as Freak points out, it's something of interest to a very small proportion of PB coders. Sure it's worth doing but the problem is, a great many other tasks would take priority over this one.
BERESHEIT
Re: ID and Parent
that is why i put my opinion that it's useful. Maybe one day enough user will have post here, and it will be considered enough to do it.
But if now I just read this and walk by, it will never change.
But if now I just read this and walk by, it will never change.
_________________________________________________
My Website : CeriseCode (Warning : perpetual changes & not completed )
My Website : CeriseCode (Warning : perpetual changes & not completed )
Re: ID and Parent
graph100 I am glad that there are reasonable people netmaestro but on account of the great work agree, I'll do it just tell me what to do and how it should be. I chose long PURICK and I do not want to leave it, so I want to improve it. And if I do not have the necessary functions that would be useful to all those who work with the interface, I think I have to offer them to add. And when nothing explaining just ignore and even more will not add the function of which only benefits you think, what are you doing where you are unnecessary.
Re: ID and Parent
I recently did the same, so we are at least two And i also needed to find out the Window-ID by its handle. The problem is, that some PB functions return a handle as well, in my case UseGadgetList().freak wrote:>...writing your own layout engine is not a very frequent use case.
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Re: ID and Parent
If when you create a gadget or form simply call these functions, it would be enough
Fred has used only for windows, and that there is no logic
GetProp_(WindowID, "PB_WindowID") -1 ; window=PB_WindowID
GetProp_(GadgetID, "PB_ID") ;gadget=PB_ID as not PB_GadgetID
GetProp_(StatusBarID, "PB_StatusBar_ID") ;StatusBar=PB_StatusBar_ID as not PB_StatusBarID
GetProp_(ToolBarID, "PB_ToolBar_ID") ;ToolBar=PB_ToolBar_ID as not PB_ToolBarID
Or all at once (cross)
Code: Select all
ProcedureDLL SetWindowID(Window)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(WindowID(Window), "PB_WindowID", Window +1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(WindowID(Window), "PB_WindowID", Window +1)
CompilerEndSelect
EndProcedure
ProcedureDLL SetGadgetID(Gadget)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(GadgetID(Gadget), "PB_GadgetID", Gadget +1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(GadgetID(Gadget), "PB_GadgetID", Gadget +1)
CompilerEndSelect
EndProcedure
ProcedureDLL SetImageID(Image)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(ImageID(Image), "PB_ImageID", Image +1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(ImageID(Image), "PB_ImageID", Image +1)
CompilerEndSelect
EndProcedure
ProcedureDLL SetStatusBarID(StatusBar)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(StatusBarID(StatusBar), "PB_StatusBarID", StatusBar +1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(StatusBarID(StatusBar), "PB_StatusBarID", StatusBar +1)
CompilerEndSelect
EndProcedure
ProcedureDLL SetToolBarID(ToolBar)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(ToolBarID(ToolBar), "PB_ToolBarID", ToolBar +1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(ToolBarID(ToolBar), "PB_ToolBarID", ToolBar +1)
CompilerEndSelect
EndProcedure
ProcedureDLL SetMenuID(Menu)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(MenuID(Menu), "PB_MenuID", Menu+1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(MenuID(Menu), "PB_MenuID", Menu +1)
CompilerEndSelect
EndProcedure
GetProp_(WindowID, "PB_WindowID") -1 ; window=PB_WindowID
GetProp_(GadgetID, "PB_ID") ;gadget=PB_ID as not PB_GadgetID
GetProp_(StatusBarID, "PB_StatusBar_ID") ;StatusBar=PB_StatusBar_ID as not PB_StatusBarID
GetProp_(ToolBarID, "PB_ToolBar_ID") ;ToolBar=PB_ToolBar_ID as not PB_ToolBarID
Code: Select all
ProcedureDLL IDWindow(WindowID)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(WindowID, "PB_WindowID") -1
CompilerCase #PB_OS_Windows
ProcedureReturn GetProp_(WindowID, "PB_WindowID") -1
CompilerEndSelect
EndProcedure
ProcedureDLL IDGadget(GadgetID)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(GadgetID, "PB_GadgetID") -1
CompilerCase #PB_OS_Windows
ProcedureReturn GetProp_(GadgetID, "PB_GadgetID") -1
CompilerEndSelect
EndProcedure
ProcedureDLL IDImage(ImageID)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(ImageID, "PB_ImageID") -1
CompilerCase #PB_OS_Windows
ProcedureReturn GetProp_(ImageID, "PB_ImageID") -1
CompilerEndSelect
EndProcedure
ProcedureDLL IDStatusBar(StatusBarID)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(StatusBarID, "PB_StatusBarID") -1
CompilerCase #PB_OS_Windows
ProcedureReturn GetProp_(StatusBarID, "PB_StatusBarID") -1
CompilerEndSelect
EndProcedure
ProcedureDLL IDToolBar(ToolBarID)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(ToolBarID, "PB_ToolBarID") -1
CompilerCase #PB_OS_Windows
ProcedureReturn GetProp_(ToolBarID, "PB_ToolBarID") -1
CompilerEndSelect
EndProcedure
ProcedureDLL IDMenu(MenuID)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(MenuID, "PB_MenuID") -1
CompilerCase #PB_OS_Windows
ProcedureReturn GetProp_(MenuID, "PB_MenuID") -1
CompilerEndSelect
EndProcedure
Code: Select all
ProcedureDLL AddID_Init()
Structure PropType
Value.i
EndStructure
Structure PropMap
Map PropName.PropType()
EndStructure
Global NewMap Props.PropMap()
EndProcedure
ProcedureDLL IDWindow(WindowID)
If MapSize(Props()) And Props(Str(WindowID))
ProcedureReturn Props()\PropName("PB_WindowID")\Value
EndIf
ProcedureReturn -1
EndProcedure
ProcedureDLL IDGadget(GadgetID)
If MapSize(Props()) And Props(Str(GadgetID))
ProcedureReturn Props()\PropName("PB_GadgetID")\Value
EndIf
ProcedureReturn -1
EndProcedure
ProcedureDLL IDImage(ImageID)
If MapSize(Props()) And Props(Str(ImageID))
ProcedureReturn Props()\PropName("PB_ImageID")\Value
EndIf
ProcedureReturn -1
EndProcedure
ProcedureDLL IDStatusBar(StatusBarID)
If MapSize(Props()) And Props(Str(StatusBarID))
ProcedureReturn Props()\PropName("PB_StatusBarID")\Value
EndIf
ProcedureReturn -1
EndProcedure
ProcedureDLL IDToolBar(ToolBarID)
If MapSize(Props()) And Props(Str(ToolBarID))
ProcedureReturn Props()\PropName("PB_ToolBarID")\Value
EndIf
ProcedureReturn -1
EndProcedure
ProcedureDLL IDMenu(MenuID)
If MapSize(Props()) And Props(Str(MenuID))
ProcedureReturn Props()\PropName("PB_MenuID")\Value
EndIf
ProcedureReturn -1
EndProcedure
ProcedureDLL AddWindowID(Window)
Props(Str(WindowID(Window)))\PropName("PB_WindowID")\Value = Window
EndProcedure
ProcedureDLL AddGadgetID(Gadget)
Props(Str(GadgetID(Gadget)))\PropName("PB_GadgetID")\Value = Gadget
EndProcedure
ProcedureDLL AddImageID(Image)
Props(Str(ImageID(Image)))\PropName("PB_ImageID")\Value = Image
EndProcedure
ProcedureDLL AddStatusBarID(StatusBar)
Props(Str(StatusBarID(StatusBar)))\PropName("PB_StatusBarID")\Value = StatusBar
EndProcedure
ProcedureDLL AddToolBarID(ToolBar)
Props(Str(ToolBarID(ToolBar)))\PropName("PB_ToolBarID")\Value = ToolBar
EndProcedure
ProcedureDLL AddMenuID(Menu)
Props(Str(MenuID(Menu)))\PropName("PB_MenuID")\Value = Menu
EndProcedure
ProcedureDLL AddID_End()
If MapSize(Props())
DeleteMapElement(Props())
EndIf
EndProcedure
Re: ID and Parent
I believe we are much more than two who have implemented their own ways or at least asked for, a quick search reveals the below:uwekel wrote:I recently did the same, so we are at least two .....freak wrote:>...writing your own layout engine is not a very frequent use case.
http://www.purebasic.fr/english/viewtop ... lit=parent
http://www.purebasic.fr/english/viewtop ... lit=parent
http://www.purebasic.fr/english/viewtop ... lit=parent
http://www.purebasic.fr/english/viewtop ... lit=parent
http://www.purebasic.fr/english/viewtop ... lit=parent
http://www.purebasic.fr/english/viewtop ... 12&t=59124
http://www.purebasic.fr/english/viewtop ... 13&t=52023
http://www.purebasic.fr/english/viewtop ... =3&t=49900
.....
and the list goes on if you look for related topics such as 'Layout Managers', 'Resizers' ... they all need similar functions. It is true the new native dialog lib has introduced an easier way of building nicer gui but till now i dont think it is really usable in building commercial gui, it still has many flaws ...
Re: ID and Parent
The Dialog layout features are great, but it should be implemented in a container gadget. Something like the TableLayoutPanel in VB.Net.
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Re: ID and Parent
Code: Select all
EnableExplicit
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
ImportC "-gtk"
g_object_set_data_(*Widget.GtkWidget, strData.p-utf8, *userdata) As "g_object_set_data"
g_object_get_data_(*Widget.GtkWidget, strData.p-utf8) As "g_object_get_data"
EndImport
CompilerElseIf #PB_Compiler_OS = #PB_OS_MacOS
Structure PropType
Value.i
EndStructure
Structure PropMap
Map PropName.PropType()
EndStructure
Global NewMap Props.PropMap()
CompilerEndIf
Procedure SetWindowID(Window)
If IsWindow(Window)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(WindowID(Window), "PB_WindowID", Window +1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(WindowID(Window), "PB_WindowID", Window +1)
CompilerDefault
ProcedureReturn Props(Str(WindowID(Window)))\PropName("PB_WindowID")\Value = Window +1
CompilerEndSelect
EndIf
EndProcedure
Procedure SetGadgetID(Gadget)
If IsGadget(Gadget)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(GadgetID(Gadget), "PB_GadgetID", Gadget +1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(GadgetID(Gadget), "PB_GadgetID", Gadget +1)
CompilerDefault
ProcedureReturn Props(Str(GadgetID(Gadget)))\PropName("PB_GadgetID")\Value = Window +1
CompilerEndSelect
EndIf
EndProcedure
Procedure SetImageID(Image)
If IsImage(Image)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(ImageID(Image), "PB_ImageID", Image +1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(ImageID(Image), "PB_ImageID", Image +1)
CompilerDefault
ProcedureReturn Props(Str(ImageID(Image)))\PropName("PB_ImageID")\Value = Window +1
CompilerEndSelect
EndIf
EndProcedure
Procedure SetMenuID(Menu)
If IsMenu(Menu)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(MenuID(Menu), "PB_MenuID", Menu +1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(MenuID(Menu), "PB_MenuID", Menu +1)
CompilerDefault
ProcedureReturn Props(Str(MenuID(Menu)))\PropName("PB_MenuID")\Value = Window +1
CompilerEndSelect
EndIf
EndProcedure
Procedure SetStatusBarID(StatusBar)
If IsStatusBar(StatusBar)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(StatusBarID(StatusBar), "PB_StatusBarID", StatusBar +1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(StatusBarID(StatusBar), "PB_StatusBarID", StatusBar +1)
CompilerDefault
ProcedureReturn Props(Str(StatusBarID(StatusBar)))\PropName("PB_StatusBarID")\Value = Window +1
CompilerEndSelect
EndIf
EndProcedure
Procedure SetToolBarID(ToolBar)
If IsToolBar(ToolBar)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_set_data_(ToolBarID(ToolBar), "PB_ToolBarID", ToolBar +1)
CompilerCase #PB_OS_Windows
ProcedureReturn SetProp_(ToolBarID(ToolBar), "PB_ToolBarID", ToolBar +1)
CompilerDefault
ProcedureReturn Props(Str(ToolBarID(ToolBar)))\PropName("PB_ToolBarID")\Value = Window +1
CompilerEndSelect
EndIf
EndProcedure
ProcedureDLL IDWindow(WindowID) ;Returns ID Window
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(WindowID, "PB_WindowID") -1
CompilerCase #PB_OS_Windows
Protected Window = GetProp_(WindowID, "PB_WindowID") -1
If Window =-1
Window = GetProp_(WindowID, "PB_Window_ID") -1
If Not (IsWindow(Window) And WindowID = WindowID(Window)) :Window =-1 :EndIf
EndIf
ProcedureReturn Window
CompilerDefault
If MapSize(Props())
ProcedureReturn (Props(Str(WindowID))\PropName("PB_WindowID")\Value) -1
EndIf
ProcedureReturn -1
CompilerEndSelect
EndProcedure
ProcedureDLL IDGadget(GadgetID) ;Returns ID Gadget
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(GadgetID, "PB_GadgetID") -1
CompilerCase #PB_OS_Windows
Protected Gadget = GetProp_(GadgetID, "PB_GadgetID") -1
If Gadget =-1
Gadget = GetProp_(GadgetID, "PB_ID")
If Not (IsGadget(Gadget) And GadgetID = GadgetID(Gadget)) :Gadget =-1 :EndIf
EndIf
ProcedureReturn Gadget
CompilerDefault
If MapSize(Props())
ProcedureReturn (Props(Str(GadgetID))\PropName("PB_GadgetID")\Value) -1
EndIf
ProcedureReturn -1
CompilerEndSelect
EndProcedure
ProcedureDLL IDImage(ImageID) ;Returns ID Image
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(ImageID, "PB_ImageID") -1
CompilerCase #PB_OS_Windows
ProcedureReturn GetProp_(ImageID, "PB_ImageID") -1
CompilerDefault
If MapSize(Props())
ProcedureReturn (Props(Str(ImageID))\PropName("PB_ImageID")\Value) -1
EndIf
ProcedureReturn -1
CompilerEndSelect
EndProcedure
ProcedureDLL IDMenu(MenuID) ;Returns ID Menu
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(MenuID, "PB_MenuID") -1
CompilerCase #PB_OS_Windows
ProcedureReturn GetProp_(MenuID, "PB_MenuID") -1
CompilerDefault
If MapSize(Props())
ProcedureReturn (Props(Str(MenuID))\PropName("PB_MenuID")\Value) -1
EndIf
ProcedureReturn -1
CompilerEndSelect
EndProcedure
ProcedureDLL IDStatusBar(StatusBarID) ;Returns ID StatusBar
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(StatusBarID, "PB_StatusBarID") -1
CompilerCase #PB_OS_Windows
ProcedureReturn GetProp_(StatusBarID, "PB_StatusBarID") -1
CompilerDefault
If MapSize(Props())
ProcedureReturn (Props(Str(StatusBarID))\PropName("PB_StatusBarID")\Value) -1
EndIf
ProcedureReturn -1
CompilerEndSelect
EndProcedure
ProcedureDLL IDToolBar(ToolBarID) ;Returns ID ToolBar
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ProcedureReturn g_object_get_data_(ToolBarID, "PB_ToolBarID") -1
CompilerCase #PB_OS_Windows
ProcedureReturn GetProp_(ToolBarID, "PB_ToolBarID") -1
CompilerDefault
If MapSize(Props())
ProcedureReturn (Props(Str(ToolBarID))\PropName("PB_ToolBarID")\Value) -1
EndIf
ProcedureReturn -1
CompilerEndSelect
EndProcedure
ProcedureDLL IsWindowID(WindowID) ;Returns TRUE if is WindowID
If IsWindow(IDWindow(WindowID))
ProcedureReturn #True
EndIf
EndProcedure
ProcedureDLL IsGadgetID(GadgetID);Returns TRUE if is GadgetID
If IsGadget(IDGadget(GadgetID))
ProcedureReturn #True
EndIf
EndProcedure
ProcedureDLL IsImageID(ImageID) ;Returns TRUE if is ImageID
If IsImage(IDImage(ImageID))
ProcedureReturn #True
EndIf
EndProcedure
ProcedureDLL IsMenuID(MenuID) ;Returns TRUE if is MenuID
If IsMenu(IDMenu(MenuID))
ProcedureReturn #True
EndIf
EndProcedure
ProcedureDLL IsToolBarID(ToolBarID);Returns TRUE if is ToolBarID
If IsToolBar(IDToolBar(ToolBarID))
ProcedureReturn #True
EndIf
EndProcedure
ProcedureDLL IsStatusBarID(StatusBarID);Returns TRUE if is StatusBarID
If IsStatusBar(IDStatusBar(StatusBarID))
ProcedureReturn #True
EndIf
EndProcedure
DisableExplicit
CompilerIf #PB_Compiler_IsMainFile
Global MainWindowID = OpenWindow(15, 0, 0, 200, 80, "MainWindow", #PB_Window_SystemMenu|#PB_Window_ScreenCentered) :SetWindowID(15)
Debug "WindowID " + MainWindowID
Debug "IDWindow " + IDWindow(MainWindowID)
Debug "IsWindow " + IsWindowID(MainWindowID)
While WaitWindowEvent() ! #PB_Event_CloseWindow :Wend
CompilerEndIf
Re: ID and Parent
in windows and mac os works great
In Linux, too, the only splitter just a little bit of a problem. (problems with rendering children)
viewtopic.php?f=3&t=61175&p=457517#p457517
In Linux, too, the only splitter just a little bit of a problem. (problems with rendering children)
viewtopic.php?f=3&t=61175&p=457517#p457517