label of acive notebook tab in bold font

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
francesco
Knows some wx things
Knows some wx things
Posts: 29
Joined: Tue Mar 08, 2005 2:51 pm
Location: Upper Austria
Contact:

label of acive notebook tab in bold font

Post by francesco » Tue Mar 08, 2005 3:02 pm

Hi,

my question is for wxPython, but I thought it is a generel question.

Is it possible to show in a wxNotebook the label of the active
(currentliy selected tab) in bold font, so it is easy to discern?
(is there or could there any built in functions used)?

If not, could this be implemented otherwise in a workaround?

Thank you for your replies!

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Tue Mar 08, 2005 3:23 pm

The question you always should ask yourself, does WINDOWS / GTK support it ?

If Windows/GTK does support it but wxWidgets don't, additions can be made :-)

In such cases it is wise to just scan the source code of wxWidgets itself.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

francesco
Knows some wx things
Knows some wx things
Posts: 29
Joined: Tue Mar 08, 2005 2:51 pm
Location: Upper Austria
Contact:

Post by francesco » Wed Mar 09, 2005 7:57 am

thank you.

Hm, Windows seems to support it (firefox: active tab is in bold font labeled).

Addition would be nice; the active notebook tab looks a little inconspicious otherwise.

Ok, good hint with taking a look at the source code.

Cheers

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Wed Mar 09, 2005 8:09 am

FireFox uses owner drawn functions. No cotnrol in FireFox is really native. So that is not a good argument to say windows supports it ;-)

You should look at MSDN, Windows API calls or MFC to see if windows really supports this. An alternative is writing your own tab control, which is not THAT hard, and you can even make it more fancy with animating tabs, mouse overs, pictures, etc etc.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

User avatar
ABX
Can't get richer than this
Can't get richer than this
Posts: 810
Joined: Mon Sep 06, 2004 1:43 pm
Location: Poznan, Poland
Contact:

Post by ABX » Wed Mar 09, 2005 8:17 am

Jorg wrote:FireFox uses owner drawn functions. No cotnrol in FireFox is really native.
I just wanted to write the same.
Jorg wrote:An alternative is writing your own tab control, which is not THAT hard, and you can even make it more fancy with animating tabs, mouse overs, pictures, etc etc.
Actuallly writing could be not necessary because alternative (not native)notebook is in wxMSWUniv code. All is needed is to make it included in native MSW build but I think with some determination it is doable.

ABX
CVS Head, 2.8.X
wxMSW, wxWinCE, wxPalmOS, wxOS2, wxMGL, bakefile
gcc 3.2.3, bcc 5.51, dmc 8.48, ow 1.6, vc 7.1, evc 3/4, pods 1.2

Avi
Super wx Problem Solver
Super wx Problem Solver
Posts: 398
Joined: Mon Aug 30, 2004 9:27 pm
Location: Tel-Aviv, Israel

Post by Avi » Wed Mar 09, 2005 11:42 pm

eMule uses DCs to draw images and custom text colors:

Code: Select all

void CClosableTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CRect rect = lpDrawItemStruct->rcItem;
	int nTabIndex = lpDrawItemStruct->itemID;
	if (nTabIndex < 0)
		return;
	BOOL bSelected = (nTabIndex == GetCurSel());

	TCHAR szLabel[256];
	TC_ITEM tci;
	tci.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_STATE;
	tci.pszText = szLabel;
	tci.cchTextMax = ARRSIZE(szLabel);
	tci.dwStateMask = TCIS_HIGHLIGHTED;
	if (!GetItem(nTabIndex, &tci))
		return;

	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	if (!pDC)
		return;

	int iOldBkMode = pDC->SetBkMode(TRANSPARENT);

	// Draw image on left side
	CImageList* piml = GetImageList();
	if (tci.iImage >= 0 && piml && piml->m_hImageList)
	{
		IMAGEINFO ii;
		piml->GetImageInfo(0, &ii);
		rect.left += bSelected ? 8 : 4;
		piml->Draw(pDC, tci.iImage, CPoint(rect.left, rect.top + 2), ILD_TRANSPARENT);
		rect.left += (ii.rcImage.right - ii.rcImage.left);
		if (!bSelected)
			rect.left += 4;
	}

	bool bCloseable = m_bCloseable;
	if (bCloseable && GetParent()->SendMessage(UM_QUERYTAB, nTabIndex))
		bCloseable = false;

	// Draw 'Close button' at right side
	if (bCloseable && m_ImgLstCloseButton.m_hImageList)
	{
		CRect rcCloseButton;
		GetCloseButtonRect(rect, rcCloseButton);
		m_ImgLstCloseButton.Draw(pDC, 0, rcCloseButton.TopLeft(), ILD_TRANSPARENT);
		rect.right = rcCloseButton.left - 2;
	}

	COLORREF crOldColor = RGB(0, 0, 0);
	if (tci.dwState & TCIS_HIGHLIGHTED)
		crOldColor = pDC->SetTextColor(RGB(192, 0, 0));

	rect.top += 4;
	pDC->DrawText(szLabel, rect, DT_SINGLELINE | DT_TOP | DT_CENTER | DT_NOPREFIX);

	if (tci.dwState & TCIS_HIGHLIGHTED)
		pDC->SetTextColor(crOldColor);
	pDC->SetBkMode(iOldBkMode);
}
Maybe it helps? :wink: Maybe we can use wxDC to do the exact same and make it multi platform... ;)

francesco
Knows some wx things
Knows some wx things
Posts: 29
Joined: Tue Mar 08, 2005 2:51 pm
Location: Upper Austria
Contact:

Post by francesco » Thu Mar 10, 2005 4:03 pm

Maybe it helps? :wink: Maybe we can use wxDC to do the exact same and make it multi platform... ;)
Thank you for your info.

I could imagine, this should be also be possible to implement this
purely in wxPython (?)

regards

Post Reply