Gadget properties userlib
BlitzPlus Forums/BlitzPlus Programming/Gadget properties userlib
| ||
Just finished a simple, yet powerfull userlib you may be interested in! http://www.acsv.net/acsite/viewsoftware.php?id=103 This userlib uses the WindowProperties api, to assign named integers to any window/gadget. This can be used to store a simple number with an existing window, or to assign a blitz object to a window. Blitz objects are stored as integers (image/bank/gadget/etc), so it is simply a matter of setting an integer to the handles value. Below is the code of the example included in the download. ;example ;this example demonstrates attatching blitz objects to a window. Include "skn3gadgetobjects.bb" Function CreateMyCustomWindow(name$,width,height,r,g,b,parent=0) ;this function creates a custom blitz window, with a background color ;it uses the CreateGadgetInt() to attatch a color panel, and store its ;handle in the window, for later use ;create gadgets Local window = CreateWindow(name$,(ClientWidth(Desktop())/2)-(width/2),(ClientHeight(Desktop())/2)-(height/2),width,height,parent,1+2) Local panel = CreatePanel(0,0,ClientWidth(window),ClientHeight(window),window) ;setup gadgets SetGadgetLayout(panel,1,1,1,1) SetPanelColor(panel,r,g,b) ;link panel to window as a sub object CreateGadgetInt(window,"MyCustomWindow_panel",panel) ;return blitz handle to window Return window End Function Function SetMyCustomWindowColor(window,r,g,b) SetPanelColor(GetGadgetInt(window,"MyCustomWindow_panel"),r,g,b) End Function Function FreeMyCustomWindow(window) FreeGadget(FreeGadgetInt(window,"MyCustomWindow_panel")) FreeGadget(window) End Function Global window = CreateMyCustomWindow("Resize to change color",400,250, 255,0,0, 0) Repeat Select WaitEvent() Case $802 SetMyCustomWindowColor(window,Rand(0,255),Rand(0,255),Rand(0,255)) Case $803 Exit End Select Forever FreeMyCustomWindow(window) |