Whats a panel!?

BlitzPlus Forums/BlitzPlus Programming/Whats a panel!?

Regular K(Posted 2004) [#1]
Can someone explain the use and functionality of a panel?


Eikon(Posted 2004) [#2]
It's the equivalent of a frame in visual basic and whats called a groupbox in vb.net/c++. Think of them as containers that you parent other objects to. It can be useful in many situations, deleting groups of child gadgets by deleting the parent panel for instance. BB panels have a style property of raised/sunken and they can also be assigned images with SetPanelImage.

I always inset my canvas in a sunken panel for games because of its better appearance.


Regular K(Posted 2004) [#3]
Is it like how mIRC contains the channel windows in the main window?

Or?


skn3(Posted 2004) [#4]
Actualy arn't panels different from a frame/group box ?

A frame/groupbox is a button style, and uses the windows button class. But a panel has a whole different windows class. It can have background color / image, and can be used for lots of things rather than just grouping gadgets.


Eikon(Posted 2004) [#5]

Is it like how mIRC contains the channel windows in the main window?

No, thats known as an MDI application, Multiple Document Interface. BP doesn't currently support MDI.

Actualy arn't panels different from a frame/group box ?


I know they're not exactly the same, frames can have captions and generally have a lot more functionality than panels, its the closet thing we have to them though and I was looking for something to relate them to.

@MrSak: Create a few and play around with them, they're not that hard to figure out.


Regular K(Posted 2004) [#6]
I still dont understand it.

Can someone provide me with an example?


soja(Posted 2004) [#7]
Every gadget in BlitzPlus must have a parent gadget (even if it's a new window that uses the Desktop as it parent). This is so that BlitzPlus knows where to draw it and how to treat it in relation to other gadgets when certain events occur.

For instance, when you create a bunch of radio buttons with certain attributes and a certain parent (wndMain), like this:
CreateButton("1", 0, 0, 100, 20, wndMain, 3)
CreateButton("2", 0, 25, 100, 20, wndMain, 3)
CreateButton("a", 0, 50, 100, 20, wndMain, 3)
CreateButton("b", 0, 75, 100, 20, wndMain, 3)
...you'll end up with a column of four radio buttons whose parent is the main window. But the interesting thing about radio buttons is that only one of them in a group is allowed to be selected at a time. So what if you want to put them into groups so that either 1 and 2 can be selected along with either a or b? That's one reason to use panels.

If you create two panels and use panel1 as the parent of the first two buttons (instead of wndMain), and use panel2 as the parent of the next two buttons, then you will have successfully grouped your gadgets. (wndMain will be the parent of panel1 and panel2.)

the other thing about using panels is that the location of a child gadget is now in reference to the panel's (parent's) upper-left corner instead of the main window. So you would have something like this:

panel1 = CreatePanel(0,0,100,50,wndMain)
panel2 = CreatePanel(0,50,100,50,wndMain)
CreateButton("1", 0, 0, 100, 20, panel1, 3)
CreateButton("2", 0, 25, 100, 20, panel1, 3)
CreateButton("a", 0, 0, 100, 20, panel2, 3)
CreateButton("b", 0, 25, 100, 20, panel2, 3)

Do you see the subtle differences? It would look exactly the same to the user, but it would function a little bit differently.

Also, if you want to perform a gadget operation (like HideGadget, ShowGadget, FreeGadget, DisableGadget, EnableGadget, etc) then you can perform it on the parent, and it will act on all of its children. So for example, if I wanted to hide the top two radio buttons but leave the bottom two radio buttons visible, I would just have to say:

HideGadget(panel1)

Does that help explain things better?


Regular K(Posted 2004) [#8]
That makes sense.

I thought it was something similiar to that.