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:

Post by framepointer » Tue Mar 06, 2007 2:20 pm

Also, I like your flatmenu much, so i put it for the tab navigation popupmenu.

In wxFlatNoteBook.cpp

Code: Select all

void wxPageContainer::PopupTabsMenu()
{
// 	wxMenu popupMenu;
// 
// 	for(size_t i=0; i<m_pagesInfoVec.GetCount(); i++)
// 	{
// 		wxPageInfo pi = m_pagesInfoVec[i];
// 		wxMenuItem *item = new wxMenuItem(&popupMenu, static_cast<int>(i), pi.GetCaption(), pi.GetCaption(), wxITEM_NORMAL);
// 
// 		// This code is commented, since there is an alignment problem with wx2.6.3 & Menus
// //		if( TabHasImage(static_cast<int>(i)) )
// //			item->SetBitmaps( (*m_ImageList)[pi.GetImageIndex()] );
// 
// 		popupMenu.Append( item );
// 	}
// 
// 	// connect an event handler to our menu
// 	popupMenu.Connect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(wxPageContainer::OnTabMenuSelection), NULL, this);
// 	PopupMenu( &popupMenu );
	
	if(mP_TabChangePopupMenu)
		mP_TabChangePopupMenu->Clear();
	else
	{
                mP_TabChangePopupMenu = new /*wxMenu*/ wxFlatMenu();
		mP_TabChangePopupMenu->Connect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(wxPageContainer::OnTabMenuSelection), NULL, this);
	}

		
	
	for(size_t i=0; i<m_pagesInfoVec.GetCount(); i++)
	{
		wxPageInfo pi = m_pagesInfoVec[i];
		wxFlatMenuItem *item = new wxFlatMenuItem(mP_TabChangePopupMenu, static_cast<int>(i), pi.GetCaption(), pi.GetCaption(), wxITEM_NORMAL);
		mP_TabChangePopupMenu->Append( item );
	}
	
	mP_TabChangePopupMenu->Popup(wxGetMousePosition()/*ClientToScreen(event.GetPoint())*/);
}
In the constructor wxPageContainer::wxPageContainer

Code: Select all

mP_TabChangePopupMenu = 0L;
And in wxFlatNoteBook.h, in the wxPageContainer definition.

Code: Select all

wxFlatMenu *mP_TabChangePopupMenu;
I think it looks pritty nice :)

Regards
Software is like sex,
It's better when it's free.
~Linus Torvalds

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Tue Mar 06, 2007 5:33 pm

Also, I like your flatmenu much, so i put it for the tab navigation popupmenu
I thought of doing it myself, but I decided not to because I did not want to cause a dependency between these two components.

Once I will merge them into single library, I will do it.

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

zhouhao
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2005 7:02 am

Post by zhouhao » Wed Mar 14, 2007 7:27 pm

I got the following linkage error:

unresolved external symbol "int const wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGED" ([email protected]@3HB)

My compiler is vs c++ 8 express. The wxWidgets is 2.8.0. Can anybody tell what is the possible reason?
Forgot to add WXUSINGDLL_FNB in preprocessor.

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Wed Mar 14, 2007 8:46 pm

I got the following linkage error:

unresolved external symbol "int const wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGED" ([email protected]@3HB)

My compiler is vs c++ 8 express. The wxWidgets is 2.8.0. Can anybody tell what is the possible reason?


Forgot to add WXUSINGDLL_FNB in preprocessor.
You took the words out of my mouth ...

OT:
I upgraded to solution file (.sln) to VC8 express.
and fixed several warnings regarding deprecated functions from 2.6.3 -> 2.8.2

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 » Thu Mar 29, 2007 4:08 pm

@eranif
I am not tracking this forum, but I see a lot of suggestions and code pouring every now and then, is there any new release planned or the source forge release is the latest one. Sorry, I know this is a silly question, but just for curiosity.

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Sun Apr 01, 2007 7:18 am

priyank_bolia wrote:@eranif
I am not tracking this forum, but I see a lot of suggestions and code pouring every now and then, is there any new release planned or the source forge release is the latest one. Sorry, I know this is a silly question, but just for curiosity.
I think I answered most of the questions/ suggestions in this forum.

To you question, yes I am planning to release a version in about two weeks, which will include the following (already started working on it):

- Chnages in <> roatation buttons beahvior
- Add new style to wxFlatNotebook - Firefox 2.0
- Minor bug fixes: bug #1632714, #1632842
- Add new style wxFNB_HIGHLIGHT_CURTAB - highlight the tab tab under the cursor
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 » Sun Apr 01, 2007 4:17 pm

eranif wrote: ...I am planning to release a version in about two weeks, which will include the following (already started working on it):

- Chnages in <> roatation buttons beahvior
- Add new style to wxFlatNotebook - Firefox 2.0
- Minor bug fixes: bug #1632714, #1632842
- Add new style wxFNB_HIGHLIGHT_CURTAB - highlight the tab tab under the cursor
Eran
Sounds fantastic. My co-workers and I love wxFlatNotebook and are looking forward to the new release. Keep up the good work!

RJP Computing
Experienced Solver
Experienced Solver
Posts: 75
Joined: Sat Dec 10, 2005 10:38 pm
Location: Michigan, USA
Contact:

Post by RJP Computing » Sun Apr 01, 2007 7:58 pm

This is great to hear. Can't wait.
- Ryan
RJP Computing
wxPack - Precompiled wxWidgets package.

Ubuntu 9.04 x86_64/WinXP, AMD Athlon x2 3000+, 4000MB RAM, AC 97 Audio, nVidia GeForce 9400GS 1GB

phonxe
Earned a small fee
Earned a small fee
Posts: 18
Joined: Fri May 06, 2005 12:37 pm

Post by phonxe » Wed Apr 04, 2007 7:01 am

Two bugs,

1. src/renderer.cpp, line 1614:

Code: Select all

	// According to the equation y = ax + b => x = (y-b)/a
	// We know the first 2 points
	double a = (y2 - y1) / (x2 - x1);
	double b = y1 - ((y2 - y1) / (x2 - x1)) * x1;

	if(a == 0) 
		return (int)x1;

	// Vertical line
	if(x1 == x2)
		return (int)x1;
the checking for vertical line should be before [double a = (y2 - y1) / (x2 - x1);] or it may crash.


2. If the text on the Tab is longer then the width of FlatNotebook, the Tab will disappear.
MadEdit
This is a Text/Hex Editor for Linux & Win32

zhouhao
Earned some good credits
Earned some good credits
Posts: 144
Joined: Tue Dec 06, 2005 7:02 am

Post by zhouhao » Wed Apr 11, 2007 3:21 am

One simple question. Is it possible to change the color of tabs?

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Wed Apr 11, 2007 10:08 am

zhouhao wrote:One simple question. Is it possible to change the color of tabs?
There are several functions that allows you to change tabs' colour:

Code: Select all

void SetNonActiveTabTextColour(const wxColour& color)
void SetActiveTabTextColour(const wxColour& textColour)
void SetTabAreaColour(const wxColour& color)
void SetActiveTabColour(const wxColour& color)
In addition:
If you are using VC8 style (wxFNB_VC8), you can use wxFNB_COLORFUL_TABS style to allow wxFNB to choose different colour for each tab (except for the active tab which will use the default, white)

If you are using wxFNB_FANCY_TABS, you can also use:
SetGradientColorFrom & SetGradientColorTo to change the colours used for the active tab.

I think this pretty much covers FNB tabs colouring functions.

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

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Sun Apr 15, 2007 2:30 pm

Hi,

I just updated wxFlatNotebook with the following:

- new style wxFNB_FF2 - my intentions were to make it like FF2, however it turned out to be an hybrid between wxAUI notebook glose style & FF ...I still think it looks OK. The main purpose for making it more like wxAUI is to allow applications that uses both to have same look and feel (or as close as it can get ...)

- Rolled back the solution files & projects to VC71

- Fixed several rare issues where FNB could crash

- Changed the behavior of the left/right roation arrows to rotate single tab at a time and not bulk

- updated the sample program.

This is NOT a release so the sources can be obtained from SVN or from the attached file wxflatnotebook.zip, once I will compile and test it on Linux I will make an official release at SF (and probably will fix another thing or two)

new style:
Image
Image


Eran
Attachments
wxflatnotebook.zip
(85.48 KiB) Downloaded 131 times
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 » Wed Apr 25, 2007 9:48 pm

Hi.

There us misplaced condition when removing pages. Sometimes wxFlantNotebook hangs on exit. I traced the error back to (wxFlatNotebook.cpp line 1255, method void wxPageContainer::DoDeletePage(size_t page) ):

Code: Select all

book->SetSelection(m_iActivePage);
Now, when calculating the new active tab there is this code (same method as above, line 1228 to 1231)

Code: Select all

if ((int)m_iActivePage > (int)page || (int)page >= (int)m_pagesInfoVec.Count())
	{
		newActivePageIndex = m_iActivePage-1;
	}
The condition in my opinion should be only

Code: Select all

if ((int)m_iActivePage > (int)page)
	{
		newActivePageIndex = m_iActivePage-1;
	}
since the new active page must only be decremnted by 1 if it was located after the page being removed.

Now the context in wich wxFlatNotebook generated the assertion failure is harder to describe, but I always traced it back to the call described above. After correcting the condition everything worked just fine.

Don't ask why and how that condition resulted in an assertion failure (anyway, it only occured on program close, something with null parent, and top no level parent etc...).


Oh, and good job with the new beta/(not release) version, i'll try it out soon :)

One question: does wxFlatNotebook use the parent font set with SetFont now (in theory all childs of a widget should inherit the fonts set using this call)? Or the font it's still the default system font?

Regards,
Robert
Software is like sex,
It's better when it's free.
~Linus Torvalds

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Wed Apr 25, 2007 10:56 pm

framepointer wrote:Oh, and good job with the new beta/(not release) version, i'll try it out soon
Thanks, If you want to try it - try the SVN sources - which are more updated and also contain new style wxFNB_CUSTOM_DLG and some bug fixes.

When wxFNB_CUSTOM_DLG style is set, a popup a menu will appear when right clicking on the tab area with a single option - "Customize...". When selecting this single option, a dialog will popup that allows user to customize the current notebook.

I will also have a look at the Removing page assertion that you mentioned.

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 » Thu Apr 26, 2007 11:02 am

eranif wrote:
framepointer wrote:Oh, and good job with the new beta/(not release) version, i'll try it out soon
Thanks, If you want to try it - try the SVN sources - which are more updated and also contain new style wxFNB_CUSTOM_DLG and some bug fixes.

When wxFNB_CUSTOM_DLG style is set, a popup a menu will appear when right clicking on the tab area with a single option - "Customize...". When selecting this single option, a dialog will popup that allows user to customize the current notebook.

I will also have a look at the Removing page assertion that you mentioned.

Regards,
Eran
The assertion failure may be also my fault. In my case i had something like:

A flatnotebook X with 3 tabs A, B, C.
In the top tab A I had a splitterwindow in wich i had: on the left 1 panel, on the right a flatnotebook Y with another 4 tabs: I, II, III, IV.
In the tab III of this fnotebook Y I had also a splitter with panel on the left and another flatnotebook Z on the right.

Now if i closed the the app when the tab III of notebook Y was selected, i got the assertion failure.

The problem was that I called from the destructor a method wich manually closed the tabs using removepage, than calling Destroy() on the window cantained by the tab. I needed this because tabs in the notebook Y contained windows wich had a button Detach, wich resulted in the window calling

Code: Select all

notebook_Y->RemovePage(  notebook_Y->GetPageIndex(self) ); 
self->Reparent(pSomeDialog);
And since all tabs contained sensitive data wich could make the application abort exit, I had to close them manually, by keeping all windows created in notebook Y in an array (so i could see those in detached mode since the notebook would not find them :D).

Now, my method closed not only the windows in detached mode, but also the windows that were located in tabs. And this i think trigerred the assertion failure.

I modified my code, so that first notebook_Y->DeletaAllPages() is called to close all tabs, than I call the other method wich searches the array for windows in detached mode.

I solved my problem this way, still i don't really know why the assertion failure.


Regards,
Robert
Software is like sex,
It's better when it's free.
~Linus Torvalds

Post Reply