wxFlatNotebook

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
framepointer
Super wx Problem Solver
Super wx Problem Solver
Posts: 264
Joined: Mon Aug 07, 2006 3:25 pm
Location: Baia Mare, Romania
Contact:

fnb update

Post by framepointer »

The new version is very nice.
The properties dialog is nice, but I can't let users in some cases to close tabs (so no x is shown) or to drag tabs to foreign notebooks, so I must disable changing those options.

Aslo there is a minor problem, since you changed the wxRect::Inside to wxRect::Contains, the notebook is no longer wx26_ compatible :).
Under linux you can use the following lines in the makefile

WX_CONFIG_PATH=wx-config
WX_DOT_RELEASE=$(shell $(WX_CONFIG_PATH) --release)
WX_RELEASE := __WX_R$(subst .,_,$(WX_DOT_RELEASE))__
CFLAGS+=-D$(WX_RELEASE)
CXXFLAGS+=-D$(WX_RELEASE)

This will define __WX_R2_6__ in case of any wx26 release, __WX_R2_8__ in case of aany wx28 relase, etc.

So in the source code you can have:

Code: Select all

	if(rect.
#ifdef __WX_R2_6__	
		  Inside
#else
		  Contains
#endif
		  (pt))
For windows you can define this in a header somewhere ( wxrelease.h ) so people can change it as they like.

I attached the files I modified slightly to fit my needs (using parent fonts, flatmenu, etc) in case some1 is intrested (note: I ectracted the sources from a current project, so you might need to remove/modify some includes).


Regards
Attachments
FlatNoteBook.zip
modified source of current fnb version
(46.99 KiB) Downloaded 210 times
Software is like sex,
It's better when it's free.
~Linus Torvalds
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif »

framepointer wrote:The new version is very nice.
Thanks
framepointer wrote:The properties dialog is nice, but I can't let users in some cases to close tabs (so no x is shown) or to drag tabs to foreign notebooks, so I must disable changing those options.
I know, I noticded that problem myself when I used it for my needs. I started on a solution for this:
A new function was added: wxFlatNotebook::SetCustomizeOptions(long options)

For each notebook you can determine which parameters are configurable,
for example, to allow user only to change the tab look style and to change tabs orientation (upper or bottom), you can set:
wxFNB_CUSTOM_TAB | wxFNB_CUSTOM_ORIENTATION

The changes are not yet committed, but they should fix your problem (and mine as well).
framepointer wrote:Aslo there is a minor problem, since you changed the wxRect::Inside to wxRect::Contains, the notebook is no longer wx26_ compatible Smile.
I will integrate your solution in my code to allow compilation with 2.6.* version.

Regards,
Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
framepointer
Super wx Problem Solver
Super wx Problem Solver
Posts: 264
Joined: Mon Aug 07, 2006 3:25 pm
Location: Baia Mare, Romania
Contact:

Post by framepointer »

Hi.

I dont know if it's a bug or not, but the fancy tabs style seems to have a bug wich causes a blue gradinet to be shown (without setting any gradinet). I noticed this a while ago, mainly when i set the X to be on the tab.
I`ll take a look at my code, mayI made a mistake somewhere,.


Regards
Software is like sex,
It's better when it's free.
~Linus Torvalds
rjmyst3
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Oct 10, 2006 7:02 pm
Contact:

Post by rjmyst3 »

Eran,
The new version is excellent. I love the customize dialog. :D
I have a small feature request:
Could you add an event for when the style has been updated by the user?
I'd like to monitor/save the style of the notebook from the parent application.

Thanks.
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif »

rjmyst3 wrote:Eran,
The new version is excellent. I love the customize dialog. Very Happy
thanks alot
rjmyst3 wrote: I'd like to monitor/save the style of the notebook from the parent application.
I am using this feature my self without any events involved, by simply saving the wxFlatNotebook::GetWindowStyleFlag() at my Frame::OnClose() event.

If this is still not sufficient for you, I could add such an event to the control.

-Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
rjmyst3
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Oct 10, 2006 7:02 pm
Contact:

Post by rjmyst3 »

If this is still not sufficient for you, I could add such an event to the control.
My specific use is in wxFormBuilder. When using the wxAdditions plugin, a user can place a wxFlatNotebook in the GUI that they are designing. The user can change the style of their wxFlatNotebook control with the property grid, or with the notebook's customize dialog.

The only way I can think of to keep the property grid in sync with the notebook's style is to be notified when the notebook's style has been changed by the notebook's dialog.

If you have a better idea, I am open to it.

Thanks for your help.
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

Hi eranif,
The latest version of wxFlatNotebook is leaking a lot of memory. If I use wxNotebook, I don't see any memory leaks, but while using wxFlatNotebook there are lot of memory leaks. Can you please check that. If you need any help in memory leak detection let me know.

My usage is simple:

Code: Select all

	m_pFlatNotebook = new wxFlatNotebook(this, wxID_NOTEBOOK_FLAT, wxDefaultPosition, wxDefaultSize, wxFNB_TABS_BORDER_SIMPLE | wxFNB_NO_X_BUTTON | wxFNB_NO_NAV_BUTTONS | wxFNB_NODRAG);
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif »

wxFNB uses a singleton object which never get freed unless it is freed manually by calling wxFlatNotebook::CleanUp();

Try to add it to your main frame destructor.

Hope it helps,
If not, I will look into it
Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

eranif wrote:wxFNB uses a singleton object which never get freed unless it is freed manually by calling wxFlatNotebook::CleanUp();
Problem is solved, but I have a question, why is wxFlatNotebook::CleanUp() not called from the wxFlatNotebook destructor. I feel calling wxFlatNotebook::CleanUp() is an unnecessary thing, and many users of wxFlatNotebook will simply forgot or don't know. Can we solve this problem in a better way. Like calling from some destructor, or shared_ptr, or create a global static class, which calls wxFlatNotebook::CleanUp() in its destructor.
Any Ideas :?:
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif »

Creating a static global should do the trick - and freeing the renderer on its destructor

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
Sof_T
Can't get richer than this
Can't get richer than this
Posts: 864
Joined: Thu Jul 28, 2005 9:48 pm
Location: New Forest, United Kingdom
Contact:

Post by Sof_T »

Obviously calling wxFlatNotebook::CleanUp() from the wxFlatNotebook destructor is not going to work when you have more than one FlatNotebook in an application.

Having a particular function which must be called at application termination is not that unusual, for example wxAUI which requires Uninit() to be called on the application termination.

If this is a problem for users, is it possible for the singleton object to implement reference counting for each notebook created and to clean itself up when there are no more left?

Sof.T
The home of Sof.T http://www.sof-t.site88.net/
Author of Programming with wxDevC++
http://sourceforge.net/projects/wxdevcpp-book/
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

The issue is not how hard it is to call wxFlatNotebook::CleanUp(), the thing I am asking is how easy it is to forget for new users.
wxAUI logic can't be applied to wxFlatNotebook. The goal of wxFlatNotebook should be to 100% compatible with wxNotebook (By that I mean this should work #define wxFlatNotebook wxNotebook), whereas wxAUI is a complete independent framework.
If a reference counting is needed, then it should be done, the efforts would be well justified.
rjmyst3
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Oct 10, 2006 7:02 pm
Contact:

Post by rjmyst3 »

Eran,
gcc 4.2 warns about using a char* instead of a const char* with string literals. All of the xpm images embedded in wxFlatNotebook use char*, which causes gcc 4.2 to generate hundreds of warnings.

Please apply the small patches I've attached to fix this.

Thanks.
Attachments
fnb_resources_patch.zip
(4.29 KiB) Downloaded 178 times
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

Hi Eranif,
None of the pages receive the close event, when the flatnotebook is destroyed. Is this the expected behavior?
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif »

None of the pages receive the close event, when the flatnotebook is destroyed. Is this the expected behavior?
Yes. I did not realize that wxNotebook sends them.
Can you confirm that wxNotebook sends it?

Now, that I think of it, what happens if the notebook does send a close event, but the page Vetos it? Should the notebook destroy should be canceled?

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
Post Reply