How to dinamically enable/disable borders? Topic is solved
How to dinamically enable/disable borders?
Sorry if this have been already answered, but I google and searched but all i can find is this question and i can't get what it means.
I need to enable or disable some of the borders of a panel (well, a simplenotebook really, but i think it is the same) and i can't find how to access them.
So, suppose that i want to enable the TOP and LEFT borders of myPanel, what should i do?
I need to enable or disable some of the borders of a panel (well, a simplenotebook really, but i think it is the same) and i can't find how to access them.
So, suppose that i want to enable the TOP and LEFT borders of myPanel, what should i do?
Re: How to dinamically enable/disable borders?
The post you linked talks about borders in the sense of gaps, not visible borders. Which ones do you mean?
For visible borders you can't select individual sides, they're either on or off. (wxBORDER_NONE, wxBORDER_SIMPLE etc.). But even these border flags don't work for all controls.
For visible borders you can't select individual sides, they're either on or off. (wxBORDER_NONE, wxBORDER_SIMPLE etc.). But even these border flags don't work for all controls.
Use the source, Luke!
Re: How to dinamically enable/disable borders?
The gaps, specified along alignment, expand etc... You can also specify how much pixel they are.
wxCrafter calls them "sizer flags", and are that "blueish" buttons on this picture:
Re: How to dinamically enable/disable borders?
Like already mentioned in the link you posted, you can't define a border for a single item (like a padding in CSS). You can only define borders when adding an item to a sizer. So i guess you could just have one initial sizer and then add another sizer with the gaps/borders you want and then start adding items in the inner sizer. That should create the same effect.
Use the source, Luke!
Re: How to dinamically enable/disable borders?
If i've right understood, as i'd need to change the borders depending on the page the simplebook is showing, i should:
manage the simplebook pagechange event and there create a new sizer, assign it to the existing parent, and then add the existing simplebook to this new sizer setting the borders as i want.
Questions:
do i have to ... remove the simplebook from his existing sizer?
should i delete the old sizers?
if yes could you pass a short (pseudo)code so i see what i have to manage and how to "transfer" an object from one sizer to another?
what layout() or other resizing/refreshing functions should i call? this part is still so foggy for me...
manage the simplebook pagechange event and there create a new sizer, assign it to the existing parent, and then add the existing simplebook to this new sizer setting the borders as i want.
Questions:
do i have to ... remove the simplebook from his existing sizer?
should i delete the old sizers?
if yes could you pass a short (pseudo)code so i see what i have to manage and how to "transfer" an object from one sizer to another?
what layout() or other resizing/refreshing functions should i call? this part is still so foggy for me...
Re: How to dinamically enable/disable borders?
I've never done that, but looking at the API it should be possible to change the border of an existing sizer. wxSizer::Add returns a wxSizerItem* and there are methods to set border(size) and flags.
https://docs.wxwidgets.org/trunk/classw ... 65ffe639db
https://docs.wxwidgets.org/trunk/classw ... f44a1aadfb
https://docs.wxwidgets.org/trunk/classw ... 65ffe639db
https://docs.wxwidgets.org/trunk/classw ... f44a1aadfb
Use the source, Luke!
Re: How to dinamically enable/disable borders?
Sorry to seems pedantic, but i'm struggling with this...
if i have a tree like this:
how do i get a pointer to Sizer3?
Or
how do i get a pointer to the Panel3 wxSizerItem?
if i have a tree like this:
Code: Select all
mainform
|
+---- Sizer1
|
+---- Sizer2
| |
| +---- Panel1
|
+---- Sizer3
|
+---- Panel2
|
+---- Panel3
Or
how do i get a pointer to the Panel3 wxSizerItem?
Re: How to dinamically enable/disable borders?
You store it in a member variable when you create it.how do i get a pointer to Sizer3?
You store the result of the wxSizer::Add() call when you put the panel into its sizer.ow do i get a pointer to the Panel3 wxSizerItem?
Use the source, Luke!
Re: How to dinamically enable/disable borders?
Well, i "can't" 'cause the creating function is "automated" by wxCrafter, so i should'nt tamper with the generated code.
BUT
seems that this way works:
Code: Select all
panel3->GetContainingSizer()->GetItem(panel3)->SetFlag(wxLEFT|wxEXPAND);
panel3->GetParent()->Layout();
panel3->Refresh();
The second one "updates" the panel3 borders and position (without it you don't see any difference)
The third line is there 'cause (in my app) i'm drawing on a child panel and got a bunch of "bitmap not ok" errors, so my guess is that everything inside panel3 needs to be refreshed/resized/recreated.
Do you have any tip/suggestion/warning about this code?