Page 1 of 17


Posted: Fri Dec 30, 2005 1:14 pm
by eranif
For a project I am working, I needed a more "modern" notebook, than the one that come with wxWidgets.

Searching here I did found here a flat tab control - but however I found it with some flaws:

1. It did not manage to windows but only the tabs drawing.
2. If I opened too many tabs the drawing is bad (overflow, noway to scroll, etc.)

So, attach you can find a link to my work of the wxFlatNotebook.

The wxFlatNotebook is a full implementation of the wxNotebook, and designed to be a drop-in replacement for the wxNotebook. The API functiosn are similar so one can expect the function to behave in the same way.

Some nice features:
1. The buttons are highlighted a la Firefox style :)
2. The scrolling is done for bulks of tabs (so, the scrolling is faster and better)
3. The buttons area is never overdrawn by tabs (unlike many other implementations I saw)
4. It is a generic control
5. Currently there are 3 differnt styles - VC 71, Standard and Fancy.
6. Mouse middle click can be used to close tabs
7. A function to add right click menu for tabs (simple as SetRightClickMenu)
8. All styles has bottom style as well (they can be drawn in the bottom of screen)
9. An option to hide 'X' button or navigation buttons (separately)

My initial code (for how to draw tabs) was taken from the arucard visual studio tab control - so thanks arucard.


Linux screenshot:

More screenshots for different styles, can be seen here: ... _id=156698

Download sources and demo from here (sourceforge):


Posted: Fri Dec 30, 2005 11:32 pm
by RealityMage
Looks awesome. Two questions:

1. What license is this code under?

2. What is the purpose of USTabControl.h/cpp? I don't see it being referred to anywhere other than in the two files itself in the package you included.

Posted: Fri Dec 30, 2005 11:57 pm
by T-Rex
Very nice work. Like it :)
I have some propositions which can make the work with your class easier...

- place X button to source using XPM-like variable (I mean save X button as XPM and copy-paste contents of XPM file to the source code)
- create doxygen-like comments and generate the documentation
- create two separate projects (library and sample)
- create standard contrib structure (build - src - include - lib - docs) and installer.

I can help in implementing this propositions if you want.


Posted: Sat Dec 31, 2005 7:35 am
by Ceniza

Dunno if you've heard about Code::Blocks (it's an IDE made with wxWidgets) and we've been looking for a notebook with a close button to replace the current wxNotebook we're using, and the current implementation for the close button (it wastes space).

Somebody posted a link to this thread in the forums and it looks promising. I've already been playing a bit with it and got it to work under Windows and Linux with a few minor changes.

eranif: Would you mind if we take your current code and use it for Code::Blocks?

Thanks in advance :D

Sorry for the advertisement

Posted: Sat Dec 31, 2005 7:44 am
by RealityMage
I think there is a great demand for this. If it were put into wxCode, I think it would be incredibly popular.

Posted: Sat Dec 31, 2005 8:44 am
by eranif

USTabCtrl.cpp/h - is a left over, you can safely remove it.

The notebook is under the usual wxWidgets license

You can take it for Code::blocks (and yes, I have heard about it)

The API implemented is similar to the common wxNotebook, so you could expect the functions to work the same

only one fucntion is changed:

AddPage - instead of receving an index of the image in the image list (using functions like SetImageList or AssignImageList), you need to provide the image directly.

I did it this way since I encountered a bug that I do the following code:

Code: Select all

wxImageList *imgList = new wxImageList(16, 16);

// Assigne the image list

The icons lost their alpha channel !
(my icons are 32bit png files with alpha channel)

I would prefer to use the usuall way of assinging image with functions like( Set/Assign)
So any ideas why I lost the alpha channel are welcomed.

I will update the library in the coming days with more functionality (SetPageText, less flickering, menus and tooltips)

T-Rex - I will apprectiate if you will change the directory structure and send me a link to where i can download it from


Posted: Sat Dec 31, 2005 9:31 pm
by eranif
Hi ,

Just wanted to update you that I updated the class, it now contains the following changes:

1. Ctrl+Tab / Ctrl + Shift + Tab are now supported.
2. Fixed bug in the scrolling when resizing the control, you might have missed some tabs ...
3. The directory files is now changed to suite the usuall contrib directory - Thanks to T-Rex for the job
4. SetSelection API is added to the notebook
5. GetPageCount API is added to the notebook

You can still use the same link from above to download the source files

I will add more styles to the control in the comming days, so stay tuned!


Posted: Sun Jan 01, 2006 1:21 pm
by T-Rex
priyank_bolia, could you explain your changes?
I have already added support of non-rectangular tab headers (Inclined borders for tab headers) and I hope this changes will be accepted by eranif. I sent him the private message but still have no answer....
The source code changed by me is avaliable at

Posted: Sun Jan 01, 2006 1:39 pm
by priyank_bolia
I modified it little bit to provide greater portability to existing wxNotebook, by providing more functions.

Posted: Sun Jan 01, 2006 1:41 pm
by priyank_bolia
T-Rex wrote:priyank_bolia, could you explain your changes?
I have already added support of non-rectangular tab headers (Inclined borders for tab headers) and I hope this changes will be accepted by eranif. I sent him the private message but still have no answer....
The source code changed by me is avaliable at
More functions like:


Left right arrow disable when they don't have anything to do

Sets a minimum size for the tab, when no text or image is given, also when there is no images, the right border overlapped the text, so the padding is increased.

Vector warning removed, coding standards revised, etc..

Posted: Sun Jan 01, 2006 4:13 pm
by eranif
T-Rex - I accepted your changes,

However, I am now working on adding new style - VC7.1 style then I will re-publisj the source (will take a day, maybe later on today i will load them)


Posted: Sun Jan 01, 2006 4:42 pm
by T-Rex
OK, I'm waiting eagerly :)

Posted: Sun Jan 01, 2006 8:57 pm
by eranif
As promissed:

Attached is the updated source file with the following changes:

1. T-Rex added an shaped rectangle option (see demo for usage)
2. Minor bug fixes + API added by priyank_bolia - InsertPage, SetPageText etc. (check out header file)
3. Scrolling buttons are disabled when no scrolling can take place - priyank_bolia
5. bug fixes - drawing issues and fixed crash situation
6. Merge between T-Rex additional style and priyank_bolia fixes (their fixes had a conflict :))
7. I introduced a new style and API - SetBookStyle:
you can set it to wxFNB_DEFAULT_STYLE or wxFNB_VC71

Attach are the screenshots for the updated styles

Again, the full source code and example can be downloaded from

Screen shots:
Standard style (both images and shaped and non-shaped rectangles):


VC71 style (Visual Studio 7.1, 2003)


And thanks to all contributors,
Let me know if you find a bug ...


Posted: Sun Jan 01, 2006 9:03 pm
by tiwag
has anybody built this wxFlatNotebook lib and Test-demo with MinGW gcc ??

i tried it - built wxFlatNoteBook as static lib, everything compiles smoothly,

but got stuck at linktime with the event-types class

Code: Select all

IMPLEMENT_DYNAMIC_CLASS(wxFlatNotebookEvent, wxNotifyEvent)
the linker gets the following unresolved refernces, when linking the wxNotebookTest application with the static libwxNoteBook.a

Code: Select all

mingw32-g++.exe -L..\..\lib -Ld:\wx262\lib\gcc_dll -Ld:\wx262\lib -LD:\MinGW\lib  -o Debug\wxFlatNotebookTest.exe Debug\Frame.o Debug\resources.o Debug\App.o    -lwxFlatNotebookd -lwinmm -lcomctl32 -lrpcrt4 -lwsock32 -loleacc -lodbc32 -lwxmsw26  -mwindows
Debug\Frame.o: In function `Z41__static_initialization_and_destruction_0ii':
D:/devel/CodeBlocks/_projects/TESTS/wxFlatNotebook/my/samples/wxFlatNotebook/Frame.cpp:22: undefined reference to `_imp__wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGING'
D:/devel/CodeBlocks/_projects/TESTS/wxFlatNotebook/my/samples/wxFlatNotebook/Frame.cpp:22: undefined reference to `_imp__wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGED'
D:/devel/CodeBlocks/_projects/TESTS/wxFlatNotebook/my/samples/wxFlatNotebook/Frame.cpp:22: undefined reference to `_imp__wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSING'
collect2: ld returned 1 exit status
in the libwxFlatNoteBook.a these are exported as

Code: Select all

how can i declare these imports or exports so that it can be linked ?
any suggestions ?


found a workaround to get the demo running - i had to build wxFlatNotebook as dll instead as static lib

it must something have to do with my wx-widgets build, which is wx262 shared library (wxmsw26.dll)

maybe someone knows a slotution how i can use a self-built static wxwidgets library side by side with a shared wx-widgets library.

Posted: Sun Jan 01, 2006 9:20 pm
by T-Rex
But please, remove this line
#include "resource.h"
from wxFlatNotebook.h
There is no such file in the distro and it causes an error message when compiling using wxDev-CPP
And one more notice... when you press navigation button and there is no more tabs to scroll, it becomes invisible while mouse pointer is above this button but if we move mouse pointer elsewhere it becomes visible.... could you change this behaviour because it irritates IMO.