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!
Post Reply
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

wxFlatNotebook

Post by eranif »

Hi,
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.

Image

Linux screenshot:

Image
More screenshots for different styles, can be seen here:
http://sourceforge.net/project/screensh ... _id=156698

Download sources and demo from here (sourceforge):
http://sourceforge.net/projects/wxflatnotebook/

Enjoy,
Eran
Last edited by eranif on Wed Jan 25, 2006 9:57 pm, edited 5 times in total.
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
RealityMage
Experienced Solver
Experienced Solver
Posts: 75
Joined: Tue Aug 23, 2005 3:47 am

Post 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.
User avatar
T-Rex
Moderator
Moderator
Posts: 1248
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post 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.

Regards,
T-Rex
Ceniza
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Dec 31, 2005 7:25 am
Location: Colombia (South America)

Post by Ceniza »

Hi.

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
RealityMage
Experienced Solver
Experienced Solver
Posts: 75
Joined: Tue Aug 23, 2005 3:47 am

Post by RealityMage »

I think there is a great demand for this. If it were put into wxCode, I think it would be incredibly popular.
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif »

Hi,

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);
imgList->Add(wxXmlResources::Get()->LoadBitmap("imag1"));
imgList->Add(wxXmlResources::Get()->LoadBitmap("imag2"));

// Assigne the image list
book->AssignImageList(imgList);



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

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post 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!

Enjoy,
Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
User avatar
T-Rex
Moderator
Moderator
Posts: 1248
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post 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
http://www.ttanalytics.nm.ru/wxFlatNotebook.zip
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

I modified it little bit to provide greater portability to existing wxNotebook, by providing more functions.
http://www.priyank.in/downloads/wxFlatNotebook.zip
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post 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
http://www.ttanalytics.nm.ru/wxFlatNotebook.zip
More functions like:

SetPageText
InsertPage
SetPadding
RemovePage
ShowTabTooltip

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..
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post 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)

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
User avatar
T-Rex
Moderator
Moderator
Posts: 1248
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex »

OK, I'm waiting eagerly :)
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif »

Ok,
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
http://www.eistware.com/wx/wxFlatNotebook.zip

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

Image

VC71 style (Visual Studio 7.1, 2003)
Image


Enjoy,

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

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org
tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post 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)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGING)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSING)
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

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

thx


[edit]
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.
Last edited by tiwag on Sun Jan 01, 2006 9:59 pm, edited 1 time in total.
-tiwag
User avatar
T-Rex
Moderator
Moderator
Posts: 1248
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex »

Excellent!
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.
Post Reply