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

Post by eranif » Sun Jan 01, 2006 9:43 pm

Ok,
Both fixes done - I removed the redundant include file, and fixed the navigation buttons drawings

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 Jan 01, 2006 9:44 pm

I didnt mentioned it, but you can download the sources from the same place ...

http://www.eistware.com/wx/wxFlatNotebook.zip

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

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 » Mon Jan 02, 2006 4:56 am

Really nice.

There's just a minor bug left: sometimes when you move your mouse over the X and move it away from the bar quickly, the hover remains.

The way to solve it is just adding another mouse event: EVT_LEAVE_WINDOW

The function would look like this:

Code: Select all

void wxPageContainer::OnMouseLeave(wxMouseEvent& event)
{
  m_bHoverLeftArrow = false;
  m_bHoverX = false;
  m_bHoverRightArrow = false;

  wxClientDC dc(this);
  dc.BeginDrawing();

  DrawX(m_bHoverX, dc);
  DrawLeftArrow(m_bHoverLeftArrow, dc);
  DrawRightArrow(m_bHoverRightArrow, dc);

  dc.EndDrawing();
  event.Skip();
}
[edit]
I just noticed when trying to integrate this control to Code::Blocks that RemovePage is declared but never defined.
[/edit]

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

Post by priyank_bolia » Mon Jan 02, 2006 7:01 am

Ceniza wrote: I just noticed when trying to integrate this control to Code::Blocks that RemovePage is declared but never defined.
eranif, could you look at that.

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

Post by priyank_bolia » Mon Jan 02, 2006 7:17 am

As you are supporting visual studio like tabs, I modified it little bit to have hollow disabled arrows.

Code: Select all

void wxPageContainer::DrawLeftArrow(bool hover, wxDC& dc)
{
	if(hover)
	{
		if(m_nFrom == 0)
		{
			// First draw the button as diabled, then return
			// Erase any previous drawing
			wxRect rect = GetClientRect();
			int clientWidth = rect.width;
			int btnLeftPos = clientWidth - 54;
			rect = wxRect(btnLeftPos, 5, 12, 12);

			wxPen pen = wxPen(m_nStyle & wxFNB_VC71 ? wxColour(247, 243, 233) : wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
			wxBrush brush = wxBrush(m_nStyle & wxFNB_VC71 ? wxColour(247, 243, 233) : wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
			dc.SetPen(pen);
			dc.SetBrush(brush);

			dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
			wxPoint points[] = { wxPoint(rect.x + 3, rect.y + 6), wxPoint(rect.x + 7, rect.y + 2), wxPoint(rect.x + 7, rect.y + 10) };

			pen   = wxPen(wxColor(128, 128, 128));
			dc.SetPen(pen);
			dc.SetBrush(brush);

			dc.DrawPolygon(3, points);
			return;
		}

		wxPen pen = wxPen(*wxWHITE);
		wxBrush brush = wxBrush(*wxRED);
		dc.SetPen(pen);
		dc.SetBrush(brush);

		// Draw a white rectangle around the arrow
		wxRect rect = GetClientRect();
		
		int clientWidth = rect.width;
		int btnLeftPos = clientWidth - 54;
		rect = wxRect(btnLeftPos, 5, 12, 12);
		dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);

		wxPoint points[] = { wxPoint(rect.x + 3, rect.y + 6), wxPoint(rect.x + 7, rect.y + 2), wxPoint(rect.x + 7, rect.y + 10) };

		brush = wxBrush(*wxWHITE);
		dc.SetBrush(brush);
		dc.DrawPolygon(3, points);
	}
	else
	{
		// Erase any previous drawing
		wxRect rect = GetClientRect();

		// Draw the black triangle
		int clientWidth = rect.width;
		int btnLeftPos = clientWidth - 54;
		rect = wxRect(btnLeftPos, 5, 12, 12);

		wxPen pen = wxPen(m_nStyle & wxFNB_VC71 ? wxColour(247, 243, 233) : wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
		wxBrush brush = wxBrush(m_nStyle & wxFNB_VC71 ? wxColour(247, 243, 233) : wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
		dc.SetPen(pen);
		dc.SetBrush(brush);

		dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
		wxPoint points[] = { wxPoint(rect.x + 3, rect.y + 6), wxPoint(rect.x + 7, rect.y + 2), wxPoint(rect.x + 7, rect.y + 10) };

		if(m_nFrom == 0)
		{
			pen   = wxPen(wxColor(128, 128, 128));
		}
		else
		{
			pen   = wxPen(wxColor(128, 128, 128));
			brush = wxBrush(wxColor(128, 128, 128));
		}
		dc.SetPen(pen);
		dc.SetBrush(brush);

		dc.DrawPolygon(3, points);
	}
}

void wxPageContainer::DrawRightArrow(bool hover, wxDC& dc)
{
	if(hover)
	{
		// Check if the right most tab is visible, if it is
		// don't rotate right anymore
		if(m_pagesInfoVec[m_pagesInfoVec.size()-1].m_pos != wxPoint(-1, -1))
		{
			// Draw the button as disabled
			wxRect rect = GetClientRect();
			int clientWidth = rect.width;
			int btnLeftPos = clientWidth - 38;
			rect = wxRect(btnLeftPos, 5, 12, 12);

			wxPen pen = wxPen(m_nStyle & wxFNB_VC71 ? wxColour(247, 243, 233) : wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
			wxBrush brush = wxBrush(m_nStyle & wxFNB_VC71 ? wxColour(247, 243, 233) :wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
			dc.SetPen(pen);
			dc.SetBrush(brush);
			dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
			wxPoint points[] = { wxPoint(rect.x + 8, rect.y + 6), wxPoint(rect.x + 4, rect.y + 2), wxPoint(rect.x + 4, rect.y + 10) };
			pen   = wxPen(wxColor(128, 128, 128));
			dc.SetPen(pen);
			dc.SetBrush(brush);
			dc.DrawPolygon(3, points);
			return;
		}

		wxPen pen = wxPen(*wxWHITE);
		wxBrush brush = wxBrush(*wxRED);
		dc.SetPen(pen);
		dc.SetBrush(brush);

		// Draw a white rectangle around the arrow
		wxRect rect = GetClientRect();
		int clientWidth = rect.width;
		int btnLeftPos = clientWidth - 38;
		rect = wxRect(btnLeftPos, 5, 12, 12);
		dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
		brush = wxBrush(*wxWHITE);
		wxPoint points[] = { wxPoint(rect.x + 8, rect.y + 6), wxPoint(rect.x + 4, rect.y + 2), wxPoint(rect.x + 4, rect.y + 10) };
		dc.SetBrush(brush);
		dc.DrawPolygon(3, points);
	}
	else
	{
		wxRect rect = GetClientRect();
		int clientWidth = rect.width;
		int btnLeftPos = clientWidth - 38;
		rect = wxRect(btnLeftPos, 5, 12, 12);

		wxPen pen = wxPen(m_nStyle & wxFNB_VC71 ? wxColour(247, 243, 233) : wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
		wxBrush brush = wxBrush(m_nStyle & wxFNB_VC71 ? wxColour(247, 243, 233) :wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
		dc.SetPen(pen);
		dc.SetBrush(brush);
		dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
		wxPoint points[] = { wxPoint(rect.x + 8, rect.y + 6), wxPoint(rect.x + 4, rect.y + 2), wxPoint(rect.x + 4, rect.y + 10) };
		if(m_pagesInfoVec[m_pagesInfoVec.size()-1].m_pos != wxPoint(-1, -1))
		{
			pen   = wxPen(wxColor(128, 128, 128));
		}
		else
		{
			pen   = wxPen(wxColor(128, 128, 128));
			brush = wxBrush(wxColor(128, 128, 128));
		}
		dc.SetPen(pen);
		dc.SetBrush(brush);
		dc.DrawPolygon(3, points);
	}
}

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

Post by eranif » Mon Jan 02, 2006 8:25 am

Hi,

I updated the source files with all the comments mentioned here OnMouseLeave
hollow disabled arrows
and added the missing function (RemovePage() - probably I missed it in the merge with priyank_bolia changes)

In addition I added support for right click menu (the demo is updated)
The new function:

SetRightClickMenu(wxMenu* pMenu) - once a valid menu is set, every right click on a tab will bring the tab to front (will select it) and displays the menu.

To disable it (the default) set the menu to NULL

Regards,
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 » Mon Jan 02, 2006 8:56 am

You didn;t change the button color to gray from black, VS use gray shade, black looks very eye catching. Also personally I like doubleclick to close, I think so should add that too.

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 » Mon Jan 02, 2006 9:00 am

Double click to close...

I'm used to middle click to close (just like Firefox does) :)

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

Post by eranif » Mon Jan 02, 2006 9:34 am

Hi,
I am familiar with middle button click (from firefox) but what application uses double click to close tabs?

Is it standard?

The sources are updated with middle click + grey arrows.
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 » Mon Jan 02, 2006 9:57 am

eranif wrote:Hi,
I am familiar with middle button click (from firefox) but what application uses double click to close tabs?

Is it standard?

The sources are updated with middle click + grey arrows.
Eran
It doesn't matter for me, double click or middle anything is just great.

arucard
Experienced Solver
Experienced Solver
Posts: 61
Joined: Tue Dec 28, 2004 10:16 am
Location: Czech rep.

Post by arucard » Mon Jan 02, 2006 11:50 am

Hello. I Am the creator of the wxTabCtrl from which eranif came out and I must say great work guys!
wxWidgets 2.8.4, winxp, VC2003 and above

leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio » Mon Jan 02, 2006 12:22 pm

Nice work!
However, I'd like to stress the importance of using native controls.
You might want to have different tabs for things like undockable tabs (a la wxIFM), but otherwise... using the standard control is a wise idea, especially if your application is supposed to work on multiple platforms, not only Windows.
For example, I would not trade the look of http://ucw.dustbite.net/pics/omgui/notebook2.png in standard notebook with the look of wxFlatNotebook in case of wxGTK.
Nevertheless, great work and it has its uses!
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/

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

Post by eranif » Mon Jan 02, 2006 12:25 pm

Hi All,

Again, I am updating the sources with new style ! - Fancy tabs

Image

The new style offers gradient coloring for the selected tab, you can set the color for the: 'to' 'from' and border (check out the demo for this)

Also added GetPageText() - which was missing (funny I could of swear I did add it !)

The updated sources are at:
http://www.eistware.com/wx/wxFlatNotebook.zip

Btw, I am using 7-zip to compress the files, So if you have problems decompressing it (like Julian Smart had) try to download it from Sourceforge and decompress it (I dont have WinZip - so this is the only way I can compress 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 » Mon Jan 02, 2006 1:07 pm


User avatar
T-Rex
Moderator
Moderator
Posts: 1198
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Post by T-Rex » Mon Jan 02, 2006 2:08 pm

Hey, people!
I just added support of ImageList and now I'm working on doxygen comments for all class members... I think they will be finished today and wxFlatNotebook will have the documentation :)

Post Reply