Exemple #1
0
void CTabCtrl::OnPaint(CDC& rDC)
{
	// Draw outer border.
	rDC.Pen(GetSysColor(COLOR_BTNHIGHLIGHT));
	rDC.Line(0, m_iTabHeight-2, 0,                m_rcArea.bottom-1);
	rDC.Line(0, m_iTabHeight-2, m_rcArea.right-1, m_iTabHeight-2);

	rDC.Pen(GetSysColor(COLOR_BTNFACE));
	rDC.Line(1, m_iTabHeight-1, 1,                m_rcArea.bottom-2);
	rDC.Line(1, m_iTabHeight-1, m_rcArea.right-2, m_iTabHeight-1);

	rDC.Pen(RGB(0,0,0));
	rDC.Line(0,                m_rcArea.bottom-1, m_rcArea.right,   m_rcArea.bottom-1);
	rDC.Line(m_rcArea.right-1, m_iTabHeight-1,    m_rcArea.right-1, m_rcArea.bottom-1);

	rDC.Pen(GetSysColor(COLOR_BTNSHADOW));
	rDC.Line(1,                m_rcArea.bottom-2, m_rcArea.right-1, m_rcArea.bottom-2);
	rDC.Line(m_rcArea.right-2, m_iTabHeight,      m_rcArea.right-2, m_rcArea.bottom-2);
	
	// Draw tabs.
	for (int i=0; i < m_iNumPages; i++)
	{
		if (i == m_iActivePage)
			DrawTab(rDC, i, TRUE);
		else
			DrawTab(rDC, i, FALSE);
	}
}
Exemple #2
0
BRect YabTabView::DrawTabs()
{
        	float left = 0;

	for (int32 i = 0; i < CountTabs(); i++) {
		BRect tabFrame = TabFrame(i);
		DrawTab(tabFrame, i, i == fSelection ? B_TAB_FRONT : (i == 0) ? B_TAB_FIRST : B_TAB_ANY, i + 1 != fSelection);

		left = tabFrame.right;
	}

	BRect frame(Bounds());
	if (left < frame.right) {
		frame.left = left;
		if(fTabOrientation == B_TAB_TOP)
			frame.bottom = fTabHeight;
		else
			frame.top = frame.bottom - fTabHeight;
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		uint32 borders = BControlLook::B_TOP_BORDER
			| BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER;
		if (left == 0)
			borders |= BControlLook::B_LEFT_BORDER;
		if(fTabOrientation == B_TAB_TOP)
			be_control_look->DrawInactiveTab(this, frame, frame, base, 0, borders);
		else
			fYabControlLook.DrawInactiveTabBottom(this, frame, frame, base, 0, borders);
	}

	if (fSelection < CountTabs())
		return TabFrame(fSelection);

	return BRect();
}      
void CXTPSkinObjectTab::OnDraw(CDC* pDC)
{
	CRect rc = GetHeaderRect();
	DWORD dwStyle = GetStyle();

	if (IsRight(dwStyle))
	{
		rc.left -= 2;
	}
	else if (IsLeft(dwStyle))
	{
		rc.right += 2;
	}
	else if (IsBottom(dwStyle))
	{
		rc.top -= 2;
	}
	else
	{
		rc.bottom += 2;
	}

	CXTPBufferDC dcMem(*pDC, rc);
	FillClient(&dcMem, CXTPClientRect(this));

	if (m_bActiveX)
	{
		m_bPaint = TRUE;
		CXTPBufferDC dcMem2(*pDC, rc);
		DefWindowProc(WM_PAINT, (WPARAM)dcMem2.GetSafeHdc(), 0);
		dcMem2.Discard();
		m_bPaint = FALSE;
	}

	CTabCtrl* pTabCtrl = (CTabCtrl*)this;

	CXTPFontDC font(&dcMem, GetFont());
	dcMem.SetBkMode(TRANSPARENT);

	for (int iItem = 0; iItem < pTabCtrl->GetItemCount(); ++iItem)
	{
		DrawTab(&dcMem, iItem);
	}

	DrawTab(&dcMem, pTabCtrl->GetCurSel());
}
Exemple #4
0
void CTabCtrl::ActivatePage(int iPageNum)
{
	CScreenDC	DC(this);

	// Page active?
	if (m_iActivePage >= 0)
	{
		// Hide current one.
		m_pPageTable[m_iActivePage].pPage->Show(SW_HIDE);
		DrawTab(DC, m_iActivePage, FALSE);
	}
	
	// Show new page.
	m_iActivePage = iPageNum;
	m_pPageTable[m_iActivePage].pPage->Show();
	DrawTab(DC, m_iActivePage, TRUE);
}
Exemple #5
0
void cMenu::DrawMenu()
{
	//Body Stuff.
	GradientRect(10, 10, 300, 20, Grey, DGrey);
	DrawFilledRectangle(10,30,300,280,DGrey);
	DrawNonFilledRectangle(10,10,300,300,Outline);
	PrintText("Mentranium", 100,20,White,Font.g_pFont);
	
	//Tabs.
	sizeoftab = 291 / (TabCount);
	DrawNonFilledRectangle(15,61, sizeoftab * TabCount, 243,Outline);
	for (int i = 0; i < TabCount; i++)
	{
		DrawTab(i, 15 + (i*sizeoftab), 41,sizeoftab);
	}
	
	//Checks.
	int d = 0;
	for(int i = 0; i < CheckCount; i++)
	{
		if(ActiveName == Checks[i].Parent)
		{
			DrawCheckBox(i,30, 70 + (d*20));
			d++;
		}
	}

	//Sliders.
	d = 0;
	for(int i = 0; i < SliderCount; i++)
	{
		if(ActiveName == Sliders[i].Parent)
		{
			DrawSlider(i,150, 100 + (d*40));
			d++;
		}
	}

	//Text Boxes.
	d = 0;
	for(int i = 0; i < TextBoxCount; i++)
	{
		if(ActiveName == TextBoxes[i].Parent)
		{
			DrawTextBox(i,150, 100 + (d*40));
			d++;
		}
	}
}
Exemple #6
0
void kGUITabObj::Draw(void)
{
	int i,x,y;
	kGUICorners c;
	kGUICorners cc;
	int l,r,h,exp;
	kGUI::GetSkin()->GetTabSize(&exp,&l,&r,&h);
	int gap=(m_close==true)?18+8:8;

	kGUI::PushClip();
	GetCorners(&c);
	kGUI::ShrinkClip(&c);
	
	/* is there anywhere to draw? */
	if(kGUI::ValidClip())
	{
		/* draw background */
		kGUI::DrawRect(c.lx,c.ty+exp+(h*m_numtabrows),c.rx,c.ty+exp+(h*m_numtabrows)+1,DrawColor(145,167,180));
		kGUI::DrawRectBevel(c.lx,c.ty+exp+(h*m_numtabrows)+1,c.rx,c.by,false);
		
		/* draw tab names */
		for(i=0;i<m_numtabs;++i)
		{
			x=c.lx+m_tabx.GetEntry(i);
			y=c.ty+m_taby.GetEntry(i);
			kGUI::GetSkin()->DrawTab(x,y,GetTabWidth(i)+gap,i==m_curtab,i==m_overtab,m_close);
			DrawTab(i,m_tabnames.GetEntryPtr(i),x+6,y+3);
		}

		if(m_numtabs)	/* if no tabs then m_curtab is not valid doh! */
		{
			kGUI::PushClip();
			GetChildCorners(&cc);
			kGUI::ShrinkClip(&cc);
			if(kGUI::ValidClip())
				DrawC(m_tabgroups.GetEntry(m_curtab));	/* draw all children of the currently selected tab */
			kGUI::PopClip();
		}
	}
	kGUI::PopClip();
}
Exemple #7
0
void CNavPaneWnd::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	CRect rcClient = ::GetClientRect(this);

	COLORREF clrBtnface = ::GetSysColor(COLOR_BTNFACE);
	COLORREF clrTabBg = ChangeBrightness(clrBtnface, 0.85);
	COLORREF clrHilight = ::GetSysColor(COLOR_BTNHILIGHT);
	COLORREF clrShadow = ::GetSysColor(COLOR_BTNSHADOW);
	COLORREF clrFrame = ::GetSysColor(COLOR_WINDOWFRAME);

	if (m_tabs.empty())
	{
		dc.FillSolidRect(rcClient, clrBtnface);
		return;
	}

	// Draw tabs offscreen
	CSize szTabs(s_nTabsWidth + 1, rcClient.Height());
	m_offscreenDC.Create(&dc, szTabs);
	CDC* pDC = &m_offscreenDC;

	CRect rcTabs(rcClient);
	rcTabs.right = rcTabs.left + s_nTabsWidth;
	pDC->FillSolidRect(rcTabs, clrTabBg);

	// Vertical line
	CRect rcLine(rcTabs.right, rcClient.top, rcTabs.right + 1, rcClient.bottom);
	pDC->FillSolidRect(rcLine, clrShadow);

	for (int nDiff = (int)m_tabs.size(); nDiff > 0; --nDiff)
	{
		if (m_nActiveTab - nDiff >= 0)
			DrawTab(pDC, m_nActiveTab - nDiff, false);
		if (m_nActiveTab + nDiff < static_cast<int>(m_tabs.size()))
			DrawTab(pDC, m_nActiveTab + nDiff, false);
	}
	DrawTab(pDC, m_nActiveTab, true);

	// Flush bitmap to screen dc
	dc.BitBlt(0, 0, szTabs.cx, szTabs.cy, pDC, 0, 0, SRCCOPY);
	m_offscreenDC.Release();

	// Left space
	rcTabs.left = rcTabs.right + 1;
	rcTabs.right = rcTabs.left + s_nLeftMargin;
	dc.FillSolidRect(rcTabs, clrBtnface);

	if (m_tabs[m_nActiveTab].bHasBorder)
	{
		rcLine.OffsetRect(s_nLeftMargin + 1, 0);
		rcLine.top += s_nTopMargin;
		dc.FillSolidRect(rcLine, clrShadow);
	}

	// Top space
	rcTabs.right = rcClient.right;
	rcTabs.bottom = rcTabs.top + s_nTopMargin;
	dc.FillSolidRect(rcTabs, clrBtnface);

	if (m_tabs[m_nActiveTab].bHasBorder)
	{
		rcLine.right = rcClient.right;
		rcLine.bottom = rcLine.top + 1;
		dc.FillSolidRect(rcLine, clrShadow);
	}

	if (rcClient.Width() > 70)
	{
		// Close button
		if (m_hTheme != NULL)
		{
			if (m_bClosePressed)
				XPDrawThemeBackground(m_hTheme, dc.m_hDC, TP_BUTTON, TS_PRESSED, m_rcClose, NULL);
			else if (m_bCloseActive)
				XPDrawThemeBackground(m_hTheme, dc.m_hDC, TP_BUTTON, TS_HOT, m_rcClose, NULL);
		}
		else
		{
			if (m_bClosePressed)
				dc.Draw3dRect(m_rcClose, clrShadow, clrHilight);
			else if (m_bCloseActive)
				dc.Draw3dRect(m_rcClose, clrHilight, clrShadow);
		}

		CPoint ptOffset(m_rcClose.left + (m_rcClose.Width() - 10) / 2,
				m_rcClose.top + (m_rcClose.Height() - 10) / 2);
		if (m_bClosePressed)
			ptOffset.Offset(1, m_hTheme != NULL ? 0 : 1);

		m_imgClose.Draw(&dc, 0, ptOffset, ILD_NORMAL);

		// Settings button
		if (m_nActiveTab != -1 && m_tabs[m_nActiveTab].bHasSettings)
		{
			if (m_hTheme != NULL)
			{
				if (m_bSettingsPressed)
					XPDrawThemeBackground(m_hTheme, dc.m_hDC, TP_BUTTON, TS_PRESSED, m_rcSettings, NULL);
				else if (m_bSettingsActive)
					XPDrawThemeBackground(m_hTheme, dc.m_hDC, TP_BUTTON, TS_HOT, m_rcSettings, NULL);
			}
			else
			{
				if (m_bSettingsPressed)
					dc.Draw3dRect(m_rcSettings, clrShadow, clrHilight);
				else if (m_bSettingsActive)
					dc.Draw3dRect(m_rcSettings, clrHilight, clrShadow);
			}

			CPoint ptOffset2(m_rcSettings.left + (m_rcSettings.Width() - 10) / 2,
					m_rcSettings.top + (m_rcSettings.Height() - 10) / 2);
			if (m_bSettingsPressed)
				ptOffset2.Offset(1, m_hTheme != NULL ? 0 : 1);

			m_imgSettings.Draw(&dc, 0, ptOffset2, ILD_NORMAL);
		}
	}
}
Exemple #8
0
pascal_ifMac void DrawTabMac(DialogPtr dialog, short itemNum)
{
	DrawTab(dialog, itemNum, FALSE);
}
Exemple #9
0
short PDClick(DialogPtr dialog, short itemNum, long lParam, VOIDPTR data)
{
	short oldScreen;
	long menuID_menuItem;
	long newMode = ADVANCEDMODE;
	Boolean closeFile = false, bOkToChange, disableDST;
	
#pragma unused(lParam)
#pragma unused(data)
	
	switch (itemNum) {
		case M1OK:

			if (GetButton(dialog, M1USERWIZARD)) newMode = NOVICEMODE;
			//else if (GetButton(dialog, M1USERINTERMEDIATE)) newMode = INTERMEDIATEMODE;
			else if (GetButton(dialog, M1USERADVANCED)) newMode = ADVANCEDMODE;

			// if they are switching to modes, we must check with the wizard
			// if there is a wizard file, we must close it because they may have changed stuff
			// if they are switching to advanced mode and have have a wizard file open
			//	we need to tell them they cannot get back
			// without starting all over
			bOkToChange = model->fWizard->OKToChangeWizardMode(model -> GetModelMode (),newMode,&closeFile);
			if(!bOkToChange) break;
			if(closeFile) 
			{
				OSErr err = CloseSaveFile(FALSE,FALSE);// wizard gave them a chance to back out
				if(err == USERCANCEL) break;
			}
			
			// point of no return
			///////////
			settings.backgroundColor = 1; // white JLM ???
				
			settings.showLatLongLines = GetButton(dialog, D1SHOWLATLONG);
			if (GetButton(dialog, D1DEG)) settings.latLongFormat = DEGREES;
			if (GetButton(dialog, D1DEGMIN)) settings.latLongFormat = DEGMIN;
			if (GetButton(dialog, D1DEGMINSEC)) settings.latLongFormat = DMS;
			if (GetButton(dialog, D1ABOVE)) settings.llPosition = LL_ABOVE;
			if (GetButton(dialog, D1BELOW)) settings.llPosition = LL_BELOW;
			settings.showIntermediateLines = GetButton(dialog, D1INTERMEDIATELINES);
			settings.customGrid = GetButton(dialog, D1CUSTOM);
			settings.longLineSpace = GetGridValue(dialog, D1LONGLINE);
			settings.longLabelSpace = GetGridValue(dialog, D1LONGLABEL);
			settings.latLineSpace = GetGridValue(dialog, D1LATLINE);
			settings.latLabelSpace = GetGridValue(dialog, D1LATLABEL);
			settings.longLineUnits = GetPopSelection(dialog, D1LONGLINEUNITSPOPUP) - 1;
			settings.longLabelUnits = GetPopSelection(dialog, D1LONGLABELUNITSPOPUP) - 1;
			settings.latLineUnits = GetPopSelection(dialog, D1LATLINEUNITSPOPUP) - 1;
			settings.latLabelUnits = GetPopSelection(dialog, D1LATLABELUNITSPOPUP) - 1;
			
//			settings.massUnits = GetPopSelection(dialog, E1MASSPOPUP);
//			settings.areaUnits = GetPopSelection(dialog, E1AREAPOPUP);
		
			if (GetButton(dialog, M1USERWIZARD)) model -> SetModelMode (NOVICEMODE);
			//if (GetButton(dialog, M1USERINTERMEDIATE)) model -> SetModelMode (INTERMEDIATEMODE);
			if (GetButton(dialog, M1USERADVANCED)) model -> SetModelMode (ADVANCEDMODE);
			if (GetButton(dialog, M1STARTUPWIZARD)) settings.modelStartMode = NOVICEMODE;
			//if (GetButton(dialog, M1STARTUPINTERMEDIATE)) settings.modelStartMode = INTERMEDIATEMODE;
			if (GetButton(dialog, M1STARTUPADVANCED)) settings.modelStartMode = ADVANCEDMODE;
			
			disableDST = GetButton(dialog, C1DSTCHECKBOX);
			if (disableDST) settings.daylightSavingsTimeFlag = DAYLIGHTSAVINGSOFF;
			else settings.daylightSavingsTimeFlag = DAYLIGHTSAVINGSON;

			return M1OK;
		
		case M1CANCEL: return M1CANCEL;
		
		case M1TAB1:
		case M1TAB2:
		case M1TAB3:
		case M1TAB4:
		case M1TAB5:
			if (settings.preferencesScreen == itemNum)
				break;
			oldScreen = settings.preferencesScreen;
			settings.preferencesScreen = itemNum;
			DrawTab(dialog, oldScreen, FALSE);
			DrawTab(dialog, settings.preferencesScreen, TRUE);
			ShowPreferenceScreen(dialog, oldScreen);
			break;
		
		
		
		case D1SHOWLATLONG:
			ToggleButton(dialog, D1SHOWLATLONG);
			EnableLatLongControls(dialog);
			break;
		
		case D1DEG:
		case D1DEGMIN:
		case D1DEGMINSEC:
			SetButton(dialog, D1DEG, itemNum == D1DEG);
			SetButton(dialog, D1DEGMIN, itemNum == D1DEGMIN);
			SetButton(dialog, D1DEGMINSEC, itemNum == D1DEGMINSEC);
			break;
		
		case D1ABOVE:
		case D1BELOW:
			SetButton(dialog, D1ABOVE, itemNum == D1ABOVE);
			SetButton(dialog, D1BELOW, itemNum == D1BELOW);
			break;
		
		case D1INTERMEDIATELINES:
			ToggleButton(dialog, D1INTERMEDIATELINES);
			break;
		
		case D1CUSTOM:
			ToggleButton(dialog, D1CUSTOM);
			EnableLatLongControls(dialog);
			break;
		
		case D1LONGLINE:
		case D1LONGLABEL:
		case D1LATLINE:
		case D1LATLABEL:
			CheckNumberTextItem(dialog, itemNum, FALSE);
			break;
		
		//case M1BACKCOLORPOPUP:
		case D1LONGLINEUNITSPOPUP:
		case D1LONGLABELUNITSPOPUP:
		case D1LATLINEUNITSPOPUP:
		case D1LATLABELUNITSPOPUP:
//		case E1MASSPOPUP:
//		case E1AREAPOPUP:
			PopClick(dialog, itemNum, &menuID_menuItem);
			break;

		case M1USERWIZARD:
		//case M1USERINTERMEDIATE:
		case M1USERADVANCED:
			SetButton(dialog, M1USERWIZARD, itemNum == M1USERWIZARD);
			//SetButton(dialog, M1USERINTERMEDIATE, itemNum == M1USERINTERMEDIATE);
			SetButton(dialog, M1USERADVANCED, itemNum == M1USERADVANCED);
			break;
		
		case M1STARTUPWIZARD:
		//case M1STARTUPINTERMEDIATE:
		case M1STARTUPADVANCED:
			SetButton(dialog, M1STARTUPWIZARD, itemNum == M1STARTUPWIZARD);
			//SetButton(dialog, M1STARTUPINTERMEDIATE, itemNum == M1STARTUPINTERMEDIATE);
			SetButton(dialog, M1STARTUPADVANCED, itemNum == M1STARTUPADVANCED);
			break;
		
		case C1DSTCHECKBOX:
			ToggleButton(dialog, C1DSTCHECKBOX);
			break;
		
	}
	
	return 0;
}
void
JXTabGroup::Draw
	(
	JXWindowPainter&	p,
	const JRect&		rect
	)
{
	const JRect ap = GetAperture();

	p.SetFont(itsFontName, itsFontSize, itsFontStyle);
	const JSize lineHeight = p.GetLineHeight();
	const JSize tabHeight  = 2*(kBorderWidth + kTextMargin) + lineHeight;

	JIndex selIndex;
	JRect selRect;
	const JBoolean hasSelection = itsCardFile->GetCurrentCardIndex(&selIndex);

	itsTabRects->RemoveAll();
	itsCanScrollUpFlag   = JI2B(itsFirstDrawIndex > 1);
	itsCanScrollDownFlag = kJFalse;

	const JCoordinate scrollArrowWidth = 2*(kArrowWidth + kBorderWidth);

	const JSize count = itsTitles->GetElementCount();
	itsLastDrawIndex  = JMax(count, itsFirstDrawIndex);

	const JColormap* cmap = p.GetColormap();
	if (itsEdge == kTop)
		{
		JRect r(ap.top + kSelMargin,             ap.left + kSelMargin,
				ap.top + kSelMargin + tabHeight, ap.left + kSelMargin);

		for (JIndex i=itsFirstDrawIndex; i<=count; i++)
			{
			const JString* title = itsTitles->NthElement(i);
			const JBoolean isSel = JI2B(hasSelection && i == selIndex);
			const TabInfo info   = itsTabInfoList->GetElement(i);

			r.right += 2*kBorderWidth + info.preMargin +info.postMargin + p.GetStringWidth(*title);
			if (info.closable)
				{
				r.right += kCloseMarginWidth + itsCloseImage->GetWidth();
				}
			JPoint titlePt(r.left + kBorderWidth + info.preMargin,
						   r.top  + kBorderWidth + kTextMargin);
			if (isSel)
				{
//				titlePt.y -= kSelMargin;
				r.top     -= kSelMargin;
				r.Expand(kSelMargin, 0);

				selRect = r;
				}

			if (isSel)
				{
				p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage));
				p.SetFilling(kJTrue);
				p.JPainter::Rect(r);
				p.SetFilling(kJFalse);
				}
			else
				{
				DrawTabBorder(p, r, kJFalse);
				}
			p.JPainter::String(titlePt, *title);

			itsTabRects->AppendElement(r);
			if (isSel)
				{
				r.top += kSelMargin;
				r.Shrink(kSelMargin, 0);
				}

			r.Shrink(kBorderWidth, kBorderWidth);
			DrawTab(i, p, r, itsEdge);
			DrawCloseButton(i, p, r);
			r.Expand(kBorderWidth, kBorderWidth);

			if (r.right >= ap.right - scrollArrowWidth)
				{
				if (itsFirstDrawIndex == 1 && i == count && r.right <= ap.right)
					{
					break;
					}
				itsCanScrollDownFlag = JI2B( itsFirstDrawIndex < count );
				itsLastDrawIndex     = i;
				if (r.right > ap.right - scrollArrowWidth && i > itsFirstDrawIndex)
					{
					itsLastDrawIndex--;
					}
				break;
				}

			r.left = r.right;
			}
		}

	else if (itsEdge == kLeft)
		{
		JRect r(ap.bottom - kSelMargin, ap.left + kSelMargin,
				ap.bottom - kSelMargin, ap.left + kSelMargin + tabHeight);

		for (JIndex i=itsFirstDrawIndex; i<=count; i++)
			{
			const JString* title = itsTitles->NthElement(i);
			const JBoolean isSel = JI2B(hasSelection && i == selIndex);
			const TabInfo info   = itsTabInfoList->GetElement(i);

			r.top -= 2*kBorderWidth + info.preMargin + info.postMargin + p.GetStringWidth(*title);
			if (info.closable)
				{
				r.top -= kCloseMarginWidth + itsCloseImage->GetWidth();
				}
			JPoint titlePt(r.left   + kBorderWidth + kTextMargin,
						   r.bottom - kBorderWidth - info.preMargin);
			if (isSel)
				{
//				titlePt.x -= kSelMargin;
				r.left    -= kSelMargin;
				r.Expand(0, kSelMargin);

				selRect = r;
				}

			if (isSel)
				{
				p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage));
				p.SetFilling(kJTrue);
				p.JPainter::Rect(r);
				p.SetFilling(kJFalse);
				}
			else
				{
				DrawTabBorder(p, r, kJFalse);
				}
			p.JPainter::String(90, titlePt, *title);

			itsTabRects->AppendElement(r);
			if (isSel)
				{
				r.left += kSelMargin;
				r.Shrink(0, kSelMargin);
				}

			r.Shrink(kBorderWidth, kBorderWidth);
			DrawTab(i, p, r, itsEdge);
			DrawCloseButton(i, p, r);
			r.Expand(kBorderWidth, kBorderWidth);

			if (r.top <= ap.top + scrollArrowWidth)
				{
				if (itsFirstDrawIndex == 1 && i == count && r.top >= ap.top)
					{
					break;
					}
				itsCanScrollDownFlag = JI2B( itsFirstDrawIndex < count );
				itsLastDrawIndex     = i;
				if (r.top < ap.top + scrollArrowWidth && i > itsFirstDrawIndex)
					{
					itsLastDrawIndex--;
					}
				break;
				}

			r.bottom = r.top;
			}
		}

	else if (itsEdge == kBottom)
		{
		JRect r(ap.bottom - kSelMargin - tabHeight, ap.left + kSelMargin,
				ap.bottom - kSelMargin,             ap.left + kSelMargin);

		for (JIndex i=itsFirstDrawIndex; i<=count; i++)
			{
			const JString* title = itsTitles->NthElement(i);
			const JBoolean isSel = JI2B(hasSelection && i == selIndex);
			const TabInfo info   = itsTabInfoList->GetElement(i);

			r.right += 2*kBorderWidth + info.preMargin + info.postMargin + p.GetStringWidth(*title);
			if (info.closable)
				{
				r.right += kCloseMarginWidth + itsCloseImage->GetWidth();
				}
			JPoint titlePt(r.left + kBorderWidth + info.preMargin,
						   r.top  + kBorderWidth + kTextMargin);
			if (isSel)
				{
//				titlePt.y += kSelMargin;
				r.bottom  += kSelMargin;
				r.Expand(kSelMargin, 0);

				selRect = r;
				}

			if (isSel)
				{
				p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage));
				p.SetFilling(kJTrue);
				p.JPainter::Rect(r);
				p.SetFilling(kJFalse);
				}
			else
				{
				DrawTabBorder(p, r, kJFalse);
				}
			p.JPainter::String(titlePt, *title);

			itsTabRects->AppendElement(r);
			if (isSel)
				{
				r.bottom -= kSelMargin;
				r.Shrink(kSelMargin, 0);
				}

			r.Shrink(kBorderWidth, kBorderWidth);
			DrawTab(i, p, r, itsEdge);
			DrawCloseButton(i, p, r);
			r.Expand(kBorderWidth, kBorderWidth);

			if (r.right >= ap.right - scrollArrowWidth)
				{
				if (itsFirstDrawIndex == 1 && i == count && r.right <= ap.right)
					{
					break;
					}
				itsCanScrollDownFlag = JI2B( itsFirstDrawIndex < count );
				itsLastDrawIndex     = i;
				if (r.right > ap.right - scrollArrowWidth && i > itsFirstDrawIndex)
					{
					itsLastDrawIndex--;
					}
				break;
				}

			r.left = r.right;
			}
		}

	else if (itsEdge == kRight)
		{
		JRect r(ap.top + kSelMargin, ap.right - kSelMargin - tabHeight,
				ap.top + kSelMargin, ap.right - kSelMargin);

		for (JIndex i=itsFirstDrawIndex; i<=count; i++)
			{
			const JString* title = itsTitles->NthElement(i);
			const JBoolean isSel = JI2B(hasSelection && i == selIndex);
			const TabInfo info   = itsTabInfoList->GetElement(i);

			r.bottom += 2*kBorderWidth + info.preMargin + info.postMargin + p.GetStringWidth(*title);
			if (info.closable)
				{
				r.bottom += kCloseMarginWidth + itsCloseImage->GetWidth();
				}
			JPoint titlePt(r.right - kBorderWidth - kTextMargin,
						   r.top   + kBorderWidth + info.preMargin);
			if (isSel)
				{
//				titlePt.x += kSelMargin;
				r.right   += kSelMargin;
				r.Expand(0, kSelMargin);

				selRect = r;
				}

			if (isSel)
				{
				p.SetPenColor(cmap->GetGrayColor(kSelGrayPercentage));
				p.SetFilling(kJTrue);
				p.JPainter::Rect(r);
				p.SetFilling(kJFalse);
				}
			else
				{
				DrawTabBorder(p, r, kJFalse);
				}
			p.JPainter::String(-90, titlePt, *title);

			itsTabRects->AppendElement(r);
			if (isSel)
				{
				r.right -= kSelMargin;
				r.Shrink(0, kSelMargin);
				}

			r.Shrink(kBorderWidth, kBorderWidth);
			DrawTab(i, p, r, itsEdge);
			DrawCloseButton(i, p, r);
			r.Expand(kBorderWidth, kBorderWidth);

			if (r.bottom >= ap.bottom - scrollArrowWidth)
				{
				if (itsFirstDrawIndex == 1 && i == count && r.bottom <= ap.bottom)
					{
					break;
					}
				itsCanScrollDownFlag = JI2B( itsFirstDrawIndex < count );
				itsLastDrawIndex     = i;
				if (r.bottom > ap.bottom - scrollArrowWidth && i > itsFirstDrawIndex)
					{
					itsLastDrawIndex--;
					}
				break;
				}

			r.top = r.bottom;
			}
		}

	JRect r = itsCardFile->GetFrame();
	r.Expand(kBorderWidth, kBorderWidth);
	JXDrawUpFrame(p, r, kBorderWidth);

	if (!selRect.IsEmpty())
		{
		DrawTabBorder(p, selRect, kJTrue);
		}

	DrawScrollButtons(p, lineHeight);
}
Exemple #11
0
//
//	Draw a series of "tabs" into a meta-file,
//	which we will use to custom-draw one of the inserted
//  scrollbar buttons
//
void InitMetaFile(void)
{
	HDC hdcEMF;
	RECT rect;
	int totalwidth = 120;
	int width = 110, height = GetSystemMetrics(SM_CYHSCROLL);
	LOGFONT lf;

	POINT pts[4];

	int tabwidth = 40, tabxslope = 5;

	pts[0].x = 0;
	pts[0].y = 0;
	pts[1].x = tabxslope;
	pts[1].y = height - 1;
	pts[2].x = tabwidth - tabxslope;
	pts[2].y = height - 1;
	pts[3].x = tabwidth;
	pts[3].y = 0;

	hpen = CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DSHADOW));
	whitepen = CreatePen(PS_INSIDEFRAME,0,RGB(0xff,0xff,0xff));

	SetRect(&rect, 0, 0, totalwidth, height+1);
	
	hdcEMF = CreateEnhMetaFile(NULL, NULL, NULL, NULL);
	
	ZeroMemory(&lf, sizeof(lf));
	lf.lfHeight = -MulDiv(7, GetDeviceCaps(hdcEMF, LOGPIXELSY), 72);
	lf.lfPitchAndFamily = DEFAULT_PITCH;
	lf.lfCharSet = ANSI_CHARSET;
	lstrcpy(lf.lfFaceName, "Arial");//Small fonts");
	hfont = CreateFontIndirect(&lf);

	pts[0].x = 0;
	pts[0].y = 0;
	pts[1].x = tabxslope;
	pts[1].y = height - 1;
	pts[2].x = tabwidth - tabxslope;
	pts[2].y = height - 1;
	pts[3].x = tabwidth;
	pts[3].y = 0;
	
	FillRect  (hdcEMF, &rect, GetSysColorBrush(COLOR_3DFACE));//GetStockObject(WHITE_BRUSH);

	//fit as many lines in as space permits

	SelectObject(hdcEMF, GetSysColorBrush(COLOR_3DFACE));

	DrawTab(hdcEMF, width-tabwidth, tabwidth, height - 1, tabxslope, FALSE);
	DrawTab(hdcEMF, width-tabwidth-tabwidth+tabxslope, tabwidth, height - 1, tabxslope, FALSE);
	DrawTab(hdcEMF, 0, tabwidth, height - 1, tabxslope, TRUE);
	
	SelectObject(hdcEMF, hpen);
	MoveToEx(hdcEMF, 110, 0, 0);
	LineTo(hdcEMF, totalwidth, 0);


	SelectObject(hdcEMF, hfont);
	SetBkMode(hdcEMF, TRANSPARENT);
	TextOut(hdcEMF, 10,1, "Build", 5);

	TextOut(hdcEMF, 42,1, "Debug", 5);
	TextOut(hdcEMF, 78,1, "Result", 6);

	SelectObject(hdcEMF, oldpen);
	DeleteObject(hpen);
	DeleteObject(whitepen);
	hemf  = CloseEnhMetaFile(hdcEMF);
}
Exemple #12
0
static int gtabset_expose(GWindow pixmap, GGadget *g, GEvent *event) {
    GTabSet *gts = (GTabSet *) g;
    int x,y,i,rd, dsel;
    GRect old1, bounds;
    int bw = GBoxBorderWidth(pixmap,g->box);
    int yoff = ( gts->rcnt==1 ? bw : 0 );
    Color fg;
    int ni = GDrawPointsToPixels(pixmap,NEST_INDENT);

    if ( g->state == gs_invisible )
return( false );

    GDrawPushClip(pixmap,&g->r,&old1);

    GBoxDrawBackground(pixmap,&g->r,g->box,g->state,false);
    bounds = g->r;

    if ( !gts->vertical ) {
	/* make room for tabs */
	bounds.y += gts->rcnt*gts->rowh+yoff-1;
	bounds.height -= gts->rcnt*gts->rowh+yoff-1;
	/* draw border around horizontal tabs only */
	GBoxDrawBorder(pixmap,&bounds,g->box,g->state,false);
    }
    else if ( g->state==gs_enabled ) {
	/* background for labels */
	GRect old2, vertListRect = g->r;
	vertListRect.width = gts->vert_list_width+bw-1;
	GDrawPushClip(pixmap,&vertListRect,&old2);
	GBoxDrawBackground(pixmap,&g->r,g->box,gs_pressedactive,false);
	GDrawPopClip(pixmap,&old2);
    }

    GDrawSetFont(pixmap,gts->font);

    if ( gts->vertical ) {
	x = g->r.x + bw + 3;
	y = g->r.y + bw + 3;
	for ( i=gts->offtop; i<gts->tabcnt; ++i ) {
	    fg = gts->tabs[i].disabled?gts->g.box->disabled_foreground:gts->g.box->main_foreground;
	    if ( fg==COLOR_DEFAULT ) fg = GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap));
	    if ( i==gts->sel ) {
		GRect r;
		r.x = x; r.y = y;
		r.width = gts->vert_list_width-10; r.height = gts->fh;
		GDrawFillRect(pixmap,&r,gts->g.box->active_border);
	    }
	    GDrawDrawText(pixmap,x+gts->tabs[i].nesting*ni,y + gts->as,gts->tabs[i].name,-1,fg);
	    y += gts->fh;
	}
	fg = gts->g.box->main_foreground;
	if ( fg==COLOR_DEFAULT ) fg = GDrawGetDefaultForeground(GDrawGetDisplayOfWindow(pixmap));
	GDrawDrawLine(pixmap,x + gts->vert_list_width-4, g->r.y + bw,
			     x + gts->vert_list_width-4, g->r.y + g->r.height - (bw+1),
			     fg);
	if ( gts->vsb != NULL )
	    gts->vsb->funcs->handle_expose(pixmap,gts->vsb,event);
    } else {
	gts->haslarrow = gts->hasrarrow = false;
	if ( gts->scrolled ) {
	    x = g->r.x + GBoxBorderWidth(pixmap,gts->g.box);
	    y = g->r.y+yoff;
	    dsel = 0;
	    if ( gts->toff!=0 )
		x = DrawLeftArrowTab(pixmap,gts,x,y);
	    for ( i=gts->toff;
		    (i==gts->tabcnt-1 && x+gts->tabs[i].width < g->r.width) ||
		    (i<gts->tabcnt-1 && x+gts->tabs[i].width < g->r.width-gts->arrow_width ) ;
		    ++i ) {
		if ( i!=gts->sel )
		    x = DrawTab(pixmap,gts,i,x,y);
		else {
		    gts->tabs[i].x = x;
		    x += gts->tabs[i].width;
		    dsel = 1;
		}
	    }
	    if ( i!=gts->tabcnt ) {
		int p = gts->g.inner.x+gts->g.inner.width - gts->arrow_width;
		if ( p>x ) x=p;
		x = DrawRightArrowTab(pixmap,gts,x,y);
		gts->tabs[i].x = 0x7fff;
	    }
	    /* This one draws on top of the others, must come last */
	    if ( dsel )
		DrawTab(pixmap,gts,gts->sel,gts->tabs[gts->sel].x, g->r.y + (gts->rcnt-1) * gts->rowh + yoff );
	} else {
	    /* r is real row, rd is drawn pos */
	    /* rd is 0 at the top of the ggadget */
	    /* r is 0 when it contains tabs[0], (the index in the rowstarts array) */
	    for ( rd = 0; rd<gts->rcnt; ++rd ) {
		int r = (gts->rcnt-1-rd+gts->active_row)%gts->rcnt;
		y = g->r.y + rd * gts->rowh + yoff;
		x = g->r.x + (gts->rcnt-1-rd) * gts->offset_per_row + GBoxBorderWidth(pixmap,gts->g.box);
		for ( i = gts->rowstarts[r]; i<gts->rowstarts[r+1]; ++i )
		    if ( i==gts->sel ) {
			gts->tabs[i].x = x;
			x += gts->tabs[i].width;
		    } else
			x = DrawTab(pixmap,gts,i,x,y);
	    }
	    /* This one draws on top of the others, must come last */
	    DrawTab(pixmap,gts,gts->sel,gts->tabs[gts->sel].x, g->r.y + (gts->rcnt-1) * gts->rowh + yoff );
	}
    }
    if ( gts->nested_expose )
	(gts->nested_expose)(pixmap,g,event);
    GDrawPopClip(pixmap,&old1);
return( true );
}
int PBTabPanel::OnDraw(bool force)
{
	if (IsVisible() && (IsChanged() || force))
	{
		PBGraphics *graphics = GetGraphics();

		graphics->FillArea(GetLeft(), GetTop(), GetWidth(), GetHeight(), m_Background);
		switch(m_Alignment)
		{
			case ALIGNMENT_BOTTOM:
				graphics->DrawLine(GetLeft(), GetTop(), GetLeft() + GetWidth() - 1, GetTop(), BLACK);
				graphics->DrawLine(GetLeft(), GetTop() + 1, GetLeft() + GetWidth() - 1, GetTop() + 1, LGRAY);
				break;

			case ALIGNMENT_LEFT:
				graphics->DrawLine(GetLeft() + GetWidth() - 1, GetTop(), GetLeft() + GetWidth() - 1, GetTop() + GetHeight(), BLACK);
				graphics->DrawLine(GetLeft() + GetWidth() - 2, GetTop(), GetLeft() + GetWidth() - 2, GetTop() + GetHeight(), LGRAY);
				break;

			case ALIGNMENT_RIGHT:
				graphics->DrawLine(GetLeft(), GetTop(), GetLeft(), GetTop() + GetHeight(), BLACK);
				graphics->DrawLine(GetLeft() + 1, GetTop(), GetLeft() + 1, GetTop() + GetHeight(), LGRAY);
				break;

			case ALIGNMENT_TOP:
				graphics->DrawLine(GetLeft(), GetTop() + GetHeight() - 1, GetLeft() + GetWidth() - 1, GetTop() + GetHeight() - 1, BLACK);
				graphics->DrawLine(GetLeft(), GetTop() + GetHeight() - 2, GetLeft() + GetWidth() - 1, GetTop() + GetHeight() - 2, LGRAY);
				break;
		}


		int x = m_X, y = m_Y;
		int curx = x, cury = y;
		char tabn[5];
		int i;

		if (m_pFont == NULL)
		{
			m_pFont = graphics->OpenFont(DEFAULTFONTB, 16, 0);
		}
		if (m_pFont != NULL) graphics->SetFont(m_pFont, BLACK);

		if (m_LeftViewTab > 3)
		{
			sprintf(tabn, "1");
			DrawTab(x, y, tabn, false);
			x += m_ShiftX;
			y += m_ShiftY;
			sprintf(tabn, "...");
			DrawTab(x, y, tabn, false);
			x += m_ShiftX;
			y += m_ShiftY;
		}

		for (i = m_LeftViewTab; i <= m_RightViewTab; i++)
		{
			if (m_TabsCurrent == i)
			{
				curx = x;
				cury = y;
			}
			else
			{
				sprintf(tabn, "%d", i);
				DrawTab(x, y, tabn, false);
			}
			x += m_ShiftX;
			y += m_ShiftY;
		}

		if (m_RightViewTab + 1 < m_TabsCount)
		{
			sprintf(tabn, "...");
			DrawTab(x, y, tabn, false);
			x += m_ShiftX;
			y += m_ShiftY;
			sprintf(tabn, "%d", m_TabsCount);
			DrawTab(x, y, tabn, false);
			x += m_ShiftX;
			y += m_ShiftY;
		}

		sprintf(tabn, "%d", m_TabsCurrent);
		DrawTab(curx, cury, tabn, true);
	}

	return 0;
}