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!
User avatar
Billy Bones
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Nov 13, 2006 7:54 pm
Location: Moscow, Russia
Contact:

Post by Billy Bones » Mon Nov 13, 2006 8:10 pm

Hi eranif, thank you for really great work!
I detected that wxFlatNotebook sample has memory leaks. I compile wxWidgets 2.7.1 as monolithic shared library and wxFlatnotebook 2.1 as shared library. Than I compile sample application and start debugging it under Visual Studio 2005. When I close application and in the output window I saw "detected memory leaks...". I'was really surprised because with wxWidgets 2.6.3 there was any problem...
And one more question: what does mean preprocessor definition 'FNB_USE_AUI'?
Sorry for my bad english, please.

benedicte
wxWorld Domination!
wxWorld Domination!
Posts: 1409
Joined: Wed Jan 19, 2005 3:44 pm
Location: Paris, France

Post by benedicte » Mon Nov 13, 2006 8:54 pm

Billy Bones wrote:Hi eranif, thank you for really great work!
I detected that wxFlatNotebook sample has memory leaks. I compile wxWidgets 2.7.1 as monolithic shared library and wxFlatnotebook 2.1 as shared library. Than I compile sample application and start debugging it under Visual Studio 2005. When I close application and in the output window I saw "detected memory leaks...". I'was really surprised because with wxWidgets 2.6.3 there was any problem...
And one more question: what does mean preprocessor definition 'FNB_USE_AUI'?
Sorry for my bad english, please.
That's not really a memory leak...
When building flatnotebook as DLL, and using it in your app, there is a singleton object instanciated twice (once in the dll, once in the app).
The "Get" method initializes the copy in the DLL.
When releasing it (calling wxFNBRendererMgrST::Free();), you "free" the copy in the app.
Thus, when closing, memory leak...

I submitted a patch for this. Maybe you should check the SVN repository of wxFlatNotebook, and get the latest version.
I also added files to declare wxFlatNotebook objects in XRC files, as well as minor features and code clean-up.

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

Post by eranif » Mon Nov 13, 2006 11:05 pm

benedicte wrote:I submitted a patch for this. Maybe you should check the SVN repository of wxFlatNotebook, and get the latest version.
I also added files to declare wxFlatNotebook objects in XRC files, as well as minor features and code clean-up.
All your patches exist in the SVN, including this one and the XRC handlers.
Billy Bones wrote:what does mean preprocessor definition 'FNB_USE_AUI'
This preprocessor is for a demo I was working on with bwilliams, to show possible integration of wxFlatNotebook & AUI.

If you would like to see what I achieved with minimum code changes, you can try this sample (the source code for this is not integrated into SVN):
http://www.eistware.com/aui_dock/wxFlatNotebookTest.zip

To "play" with it try this:

To add more AUI panes, do the following:
0. Add some tabs using Ctrl + N
1. Set: Edit->Enable Darg and Drop of tabs
2. Set: Edit->Enable Darg and Drop of tabs to foreign notebooks
3. Pull tabs from the main notebook and drop them anywhere but on the their's tab drawing area (the thin area where they are drawn) - the result is that your tab now floats
4. Dock the tab, you can add as many tabs as you want
5. Now that you have some docking panes, play with the styles.

This sample also shows an initial implementation for the wxDockArt class. (the class that is reponsible for drawing the caption area, buttons etc)

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

Belgabor
I live to help wx-kind
I live to help wx-kind
Posts: 173
Joined: Mon Sep 25, 2006 1:12 pm

Post by Belgabor » Mon Nov 13, 2006 11:26 pm

Hi eranif,

As discussion has grown into a different direction, I continue with my code::blocks/wxFlatNotebook issue here (From the 10.11. nightly thread). I tried the demo in your last post and it doesn't have the issue. Here is a screenshot of what happens, before (top) and after (bottom) opening a new file:

Image

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

Post by priyank_bolia » Fri Nov 17, 2006 6:27 am

Can you please change the name of the wxAui.lib to the wxMSW28[d]_AUI.lib as aui is integrated into wxWidgets with this name. Also for the debug unicode, the flatnotebook character set is not set to unicode and the test project the optimization is enabled for debug unicode causing compilation error as /o2 and /zi used in the same project. Also I find the Release Unicode missing project.

rjmyst3
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Oct 10, 2006 7:02 pm
Contact:

Post by rjmyst3 » Wed Nov 29, 2006 8:52 pm

Eran,
The drop-down arrow is not drawn correctly when wxFNB_NO_X_BUTTON is used.

Image


I looked at the source, and it seems that the same bitmap (m_xBgBmp) is used to draw the background for both the drop-down arrow and the x button, and if the x button is not drawn, then the background bitmap is not initialized correctly, thus the background is all black. (I think)

Here is a patch which fixes it:

Code: Select all

Index: renderer.cpp
===================================================================
--- renderer.cpp	(revision 3)
+++ renderer.cpp	(working copy)
@@ -205,7 +205,7 @@
 	xbmp.SetMask(new wxMask(xbmp, MASK_COLOR));
 	// erase old bitmap
 	int posx = GetDropArrowButtonPos( pc );
-	dc.DrawBitmap(m_xBgBmp, posx, 6);
+	dc.DrawBitmap(m_rightBgBmp, posx, 6);
 
 	// Draw the new bitmap
 	dc.DrawBitmap(xbmp, posx, 6, true);

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

Post by phonxe » Mon Dec 04, 2006 4:39 am

There is a bug on wxFlatNotebook.cpp:

Code: Select all

void wxFlatNotebook::SetSelection(size_t page)
{
//......
	if( m_sendPageChangeEvent )
	{
		// Allow the user to veto the selection
		int oldSelection = GetSelection();

		wxFlatNotebookEvent event(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGING, GetId());
		event.SetSelection( (int)page );
		event.SetOldSelection( oldSelection );
		event.SetEventObject( this );

		if( !event.IsAllowed() )
		{
			return;
		}
	}
//......
}
The codes miss out this line to trigger the PAGE_CHANGING event:
GetEventHandler()->ProcessEvent(event);
MadEdit
This is a Text/Hex Editor for Linux & Win32

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

Post by eranif » Mon Dec 04, 2006 5:55 am

phonxe wrote:The codes miss out this line to trigger the PAGE_CHANGING event:
GetEventHandler()->ProcessEvent(event);
:shock: you are right, fixed in SVN :D

@rjmyst3 your patch is also in SVN

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

vdell
Moderator
Moderator
Posts: 536
Joined: Fri Jan 07, 2005 3:44 pm
Location: Finland
Contact:

Post by vdell » Mon Dec 04, 2006 8:37 am

Would it be possible for you to make some checks for the wxWidgets 2.8.0 version? Particularly the following should be changed:
wxFlatNotebook.cpp(1036) : error C2039: 'Inside' : is not a member of 'wxRect'
d:\wxWidgets-2.8.0-rc1\include\wx\gdicmn.h(329) : see declaration of 'wxRect'
Since Inside() was declared deprecated. If I'm not mistaken, Inside() should be replaced with Contains() (at least it worked for me).

TIA
Visual C++ 9.0 / Windows XP Pro SP3 / wxWidgets 2.9.0 (SVN) | Colligere

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

Post by eranif » Mon Dec 04, 2006 1:00 pm

I already compiled it with 2.7 and fixed all deprecated calls to Inside --> Contains, however, the reason I am delaying with it is because there is a major bug in 2.7.1 which only recently fixed in CVS head by VZ which causes the Ctrl+Tab functionality not to work.

Until an official release with this issue fixed is released, I dont think I will work on porting it to 2.8 (which in the worth case will take couple of hours)

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:

making a macro with the xpm files

Post by framepointer » Mon Dec 04, 2006 2:15 pm

Hi,

Would it be to much to ask to put a macro that will "fake" the compiler not to display "not used" warining messages.

Something like:

Code: Select all

#define FNB_USE_XPM_ICONS(name) static char ** name##FNB___used___xpm__ = 1 ? name : name##FNB___used___xpm__ ;

	////////////////////////////////////////////////////////////
	// Images used by the control
	////////////////////////////////////////////////////////////
	/* XPM */
	static char *left_arrow_disabled_xpm[] = {
		/* width height num_colors chars_per_pixel */
		"    16    16        8            1",
			/* colors */
			"` c #008080",
			". c #555555",
			"# c #000000",
			"a c #000000",
			"b c #000000",
			"c c #000000",
			"d c #000000",
			"e c #000000",
			/* pixels */
			"````````````````",
			"````````````````",
			"````````````````",
			"````````.```````",
			"```````..```````",
			"``````.`.```````",
			"`````.``.```````",
			"````.```.```````",
			"`````.``.```````",
			"``````.`.```````",
			"```````..```````",
			"````````.```````",
			"````````````````",
			"````````````````",
			"````````````````",
			"````````````````"
	};
	
	FNB_USE_XPM_ICONS(left_arrow_disabled_xpm)
Would be no problem with a shared library (so/dll). I compile FNB into my binary, so i always see 10+ lines of warnings and sometimes i miss some other warining becuase I don't pay attention to them.

The macro I posted does the job. Of course it's faulty (if you look real carefully :D), but with gcc 4.1.0 it works :D.

There might be other solutions :D, like putting an inline method into a class wich "uses" the icons.

Cheers
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 » Mon Dec 04, 2006 3:25 pm

the source was re-organized in the svn repos, so these warnings don't happen anymore.

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 9:18 am

Is there any possibility to display tabs in 2 rows? :D
Anyone working on stuff like this?

I noticed a bug (wx 2.6.3) , when using VS8 tabs + close button on tab the close button is not drawn and the blue gradient from the buttons are drawn on the inactive tabs even if I set non-active tab colors, this thing keeps happening.

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 11:15 am

Hi,
framepointer wrote: Is there any possibility to display tabs in 2 rows? Very Happy
No.
framepointer wrote: Anyone working on stuff like this?
Not currently, I might have a look on it this weekend.

framepointer wrote: I noticed a bug (wx 2.6.3) , when using VS8 tabs + close button on tab the close button is not drawn and the blue gradient from the buttons are drawn on the inactive tabs even if I set non-active tab colors, this thing keeps happening.
Can you post a screensoht?

Anyway, I upgraded my wxWidgets to 2.8 so if I will fix this - it will be against my 2.8 build

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 » Tue Mar 06, 2007 1:35 pm

Hi,

I checked out the latest version from svn, works like a charm :D

One more thing that might be done is change

Code: Select all

wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)
to get the parent font if any :).

I use smaller fonts in my app and the notebook uses the default, much larger fonts.
For example in exceed all fonts in the app are huge, so i set the font explicitly to something smaller (10px usually).


Cheers

PS: in the linux makefile, under wx 2.6.3 there is problem with the wx-config arguments. Usually to compile wx stuff under linux you need 'wx-config --cxxflags --libs', the debug argument didn't work for me
Software is like sex,
It's better when it's free.
~Linus Torvalds

Post Reply