void ESEnumerableModifyWnd::SetEnumerableObject(EnumerableObject<Serializable>* pEnumerable){ ASSERT(pEnumerable); if( !pEnumerable ) return; ESChildControlList* pList = (ESChildControlList*)GetChildControl(1000); if( pList ){ Serializable* pObject = pEnumerable->CreateSerializableObject(); ASSERT(pObject); VariableInfo* pInfo = pObject->GetThisInfo(); MercuryGUI* pGUI = MercuryGUI::GetInstance(); _Size szText(0, 0); _string sTitle; int nLoop = 1; while( pInfo[nLoop].m_sAttributeName.length() > 0 ){ if( !pInfo[nLoop].m_bComplexType ){ sTitle = pInfo[nLoop].m_sDbFieldName; pGUI->header.m_fontItemText.GetTextSize(&sTitle, szText); if( szText.cx <= 0 ) szText.cx = 80; pList->AddColumn(pInfo[nLoop].m_sDbFieldName, pInfo[nLoop].m_sAttributeName, HAlignment::HAlignement_Left, szText.cx + 5, szText.cx + 5); szText.cx = 0; } nLoop ++; } VirtualRowSet* pRowSet = Serializable::SerializableObjectToVRowSet(pEnumerable); m_pListRowSet = pRowSet; m_pEnumerable = pEnumerable; pList->SetRowSet(pRowSet, true, true); delete pObject; } }
void KviWindow::outputNoFmt(int iMsgType, const char * pcText, int iFlags, const QDateTime & datetime) { QString szText(pcText); preprocessMessage(szText); const QChar * pC = szText.constData(); if(!pC) return; internalOutput(m_pIrcView, iMsgType, (kvi_wchar_t *)pC, iFlags, datetime); }
CString AfxFormatSystemString(DWORD dwMessageId) { LPTSTR lpBuffer; ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwMessageId, 0, (LPTSTR) & lpBuffer, 0, NULL); CString szText(lpBuffer); LocalFree(lpBuffer); return szText; }
static MEVENT AddCListNotification(MCONTACT hContact, LPCSTR acc, POPUPDATAT *data, LPCTSTR url) { T2Utf szUrl(url), szText(data->lptzText); DBEVENTINFO dbei = { sizeof(dbei) }; dbei.szModule = (LPSTR)acc; dbei.timestamp = time(NULL); dbei.flags = DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; char szEventText[4096]; dbei.cbBlob = mir_snprintf(szEventText, _countof(szEventText), "%s\r\n%s", szUrl, szText); dbei.pBlob = (PBYTE)szEventText; return db_event_add(hContact, &dbei); }
int COutputWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { CRect rect(0, 0, 1, 1); DWORD dwStyle; if (CSizingControlBar::OnCreate(lpCreateStruct) == -1) return -1; dwStyle = WS_VISIBLE | WS_CHILD; CString szText( (LPCTSTR)IDS_CTRL_OUTPUT_WINDOW ); m_stcCaptionOutput.Create(szText, dwStyle, rect, this, IDC_OUTPUT_CAPTION); dwStyle = WS_VISIBLE | WS_CHILD | CCS_NORESIZE | CCS_NODIVIDER | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS; m_btnWinButtons.Create(dwStyle, rect, this, IDC_OUTPUT_TOOLBAR); dwStyle = WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | LBS_USETABSTOPS; m_lstConsoleOutput.Create(dwStyle, rect, this, IDC_OUTPUT_LIST); m_lstConsoleOutput.ModifyStyleEx(0, WS_EX_CLIENTEDGE, 0); m_lstConsoleOutput.SetHorizontalExtent(2560); m_lstConsoleOutput.SetTabStops(32); // dialog based unit (approximately 4 character) dwStyle = WS_VISIBLE | WS_CHILD; m_edtConsoleInput.Create(dwStyle, rect, this, IDC_OUTPUT_EDIT); m_edtConsoleInput.ModifyStyleEx(0, WS_EX_CLIENTEDGE, 0); m_edtConsoleInput.SetReadOnly(TRUE); // set image list // m_imgToolbarOutput.Create(IDB_OUTPUT_TOOLBAR, 16, 0, RGB(255, 0, 255)); // m_btnToolbarOutput.SetImageList( & m_imgToolbarOutput ); m_imgWinButtons.Create(IDB_WIN_BUTTONS, 12, 0, RGB(255, 0, 255)); m_btnWinButtons.SetImageList( & m_imgWinButtons ); // set control font CFont * pFont = CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT)); LOGFONT lf; pFont->GetLogFont( & lf ); m_fontControl.CreateFontIndirect( & lf ); m_stcCaptionOutput.SetFont( & m_fontControl, FALSE ); // set output font ApplyOutputFont( FALSE ); // initialize toolbar // m_btnToolbarOutput.AddButtons( 6, m_tbiToolbarOutput ); m_btnWinButtons.AddButtons( 1, m_tbiWinButtons ); // set occupied flag m_bOccupied = FALSE; return 0; }
void DockingCont::SelectTab(int iTab) { if (iTab != -1) { const TCHAR *pszMaxTxt = NULL; TCITEM tcItem = {0}; SIZE size = {0}; int maxWidth = 0; int iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); // get data of new active dialog tcItem.mask = TCIF_PARAM; ::SendMessage(_hContTab, TCM_GETITEM, iTab, (LPARAM)&tcItem); // show active dialog if (!tcItem.lParam) return; ::ShowWindow(((tTbData*)tcItem.lParam)->hClient, SW_SHOW); ::SetFocus(((tTbData*)tcItem.lParam)->hClient); // Notify switch in NMHDR nmhdr; nmhdr.code = DMN_SWITCHIN; nmhdr.hwndFrom = _hSelf; nmhdr.idFrom = 0; ::SendMessage(((tTbData*)tcItem.lParam)->hClient, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr); if ((unsigned int)iTab != _prevItem) { // hide previous dialog ::SendMessage(_hContTab, TCM_GETITEM, _prevItem, (LPARAM)&tcItem); if (!tcItem.lParam) return; ::ShowWindow(((tTbData*)tcItem.lParam)->hClient, SW_HIDE); // Notify switch off NMHDR nmhdr; nmhdr.code = DMN_SWITCHOFF; nmhdr.hwndFrom = _hSelf; nmhdr.idFrom = 0; ::SendMessage(((tTbData*)tcItem.lParam)->hClient, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr); } // resize tab item // get at first largest item ... HDC hDc = ::GetDC(_hContTab); SelectObject(hDc, _hFont); for (int iItem = 0; iItem < iItemCnt; ++iItem) { const TCHAR *pszTabTxt = NULL; ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); if (!tcItem.lParam) continue; pszTabTxt = ((tTbData*)tcItem.lParam)->pszName; // get current font width GetTextExtentPoint32(hDc, pszTabTxt, lstrlen(pszTabTxt), &size); if (maxWidth < size.cx) { maxWidth = size.cx; pszMaxTxt = pszTabTxt; } } ::ReleaseDC(_hSelf, hDc); tcItem.mask = TCIF_TEXT; for (int iItem = 0; iItem < iItemCnt; ++iItem) { generic_string szText(TEXT("")); if (iItem == iTab && pszMaxTxt) { // fake here an icon before text ... szText = TEXT(" "); szText += pszMaxTxt; } tcItem.pszText = (TCHAR *)szText.c_str(); ::SendMessage(_hContTab, TCM_SETITEM, iItem, (LPARAM)&tcItem); } // selects the pressed tab and store previous tab ::SendMessage(_hContTab, TCM_SETCURSEL, iTab, 0); _prevItem = iTab; // update caption text updateCaption(); onSize(); } }
//该函数返回的x最少有5个值。 //从x[0]开始分别为: 最小值的黑线、BOX的下线,中间值、BOX的上线、最大的值的黑线 //如返回的int值大于5。则说明有extrem值。需要单独在图形中显示。 void CTChartBoxplot::CalcBoxPlot(CDoubleVector &v, void **pData, int &nCount) { CTString szText(""); int i = 0; int nVari=5,nVark=5,nMax=0,nMin=0; double fMin=0,fMax=0,fMd=0,fDn=0,fUp=0; int nVlen = v.vlen();//已经排序 int nCol = m_bWeight ? 1 : 0; nMin = nVlen; fDn = m_fPercentile[2][1]; fMd = m_fPercentile[3][1]; fUp = m_fPercentile[4][1]; for (i=nVlen-1;i>0;i--) //求取最大值及超出最大值 { if (v(i) <= (fUp+1.5*(fUp-fDn))) break; nMax = i; } for (i=0;i<nVlen-1;i++)//求取最小值及超出最小值 { if (v(i) >= (fDn-1.5*(fUp-fDn))) break; nMin = i; } if (nMax > 0) { fMax = v(nMax-1); nVari += nVlen - nMax; } else { fMax = v(nVlen-1); } if (nMin < nVlen-1) { fMin = v(nMin+1); nVari += nMin + 1; } else { fMin = v(0); } *pData = new tagDataPointStrArr; tagDataPointStrArr *pDataTemp = (tagDataPointStrArr *)*pData; szText.Format("%d",nVlen); pDataTemp->strName = szText; pDataTemp->arrYVal.Add(fMin); pDataTemp->arrYVal.Add(fDn); pDataTemp->arrYVal.Add(fMd); pDataTemp->arrYVal.Add(fUp); pDataTemp->arrYVal.Add(fMax); if (nVari > 5 && nMax > 0) //超出最大值的异常点 { for (i=nMax;i<nVlen;i++) { pDataTemp->arrYVal.Add(v(i)); } } if (nVari > 5 && nMin < nVlen)//超出最小值的异常点 { for (i=0;i<nMin+1;i++) { pDataTemp->arrYVal.Add(v(i)); } } nCount = nVari; }
int CXTPSyntaxEditDrawTextProcessor::PrintRowPart(CDC* pDC, int nRow, int nPosY, UINT nFlags, LPCTSTR pcszText, int nchCount, int *pnPrintedTextLen) { if (pnPrintedTextLen) *pnPrintedTextLen = 0; if (m_nPrintingRow != nRow) { m_nPrintingRow = nRow; m_ptNextPrintPos = CPoint(0, 0); } if (nRow == -1) return 0; //-------------------------------------------------------- int nTextLen = 0; if (nchCount < 0) { nchCount = (int)_tcsclen(pcszText); nTextLen = (int)_tcslen(pcszText); } else { nTextLen = (int)_tcsnbcnt(pcszText, nchCount); } ASSERT(nchCount <= (int)_tcsclen(pcszText)); //-------------------------------------------------------- if (m_arBuf_aDx.GetSize() < nTextLen) m_arBuf_aDx.SetSize(nTextLen + 100); LPINT alpDx = (int*)m_arBuf_aDx.GetData(); //-------------------------------------------------------- CRect rcText = m_rcTextRect; int nTextLen_rest = nTextLen; LPCTSTR pTxt = NULL; for (pTxt = pcszText; nTextLen_rest;) { int nY = m_rcTextRect.top + nPosY + m_ptNextPrintPos.y; int nX = m_rcTextRect.left + m_ptNextPrintPos.x; if (nY + GetRowHeight() > m_rcTextRect.bottom) break; //-------------------------------------------------------- int nMaxExtent = max(0, rcText.right - nX - 20); int nFit = 0; CSize szText(0, 0); BOOL bResExt = GetTextExtentExPoint( m_bUseOutputDC ? pDC->m_hDC : pDC->m_hAttribDC, // HDC hdc, // handle to DC pTxt, // LPCTSTR lpString, // character string nTextLen_rest, // int nCount, // number of characters nMaxExtent, // maximum extent for string &nFit, // LPINT lpnFit, // maximum number of characters alpDx, // array of partial string widths &szText //LPSIZE lpSize // string dimensions ); VERIFY(bResExt); //nFit = min(nFit, nTextLen_rest); LPCTSTR pTextToDtaw = pTxt; BOOL bAllTextDrawn = (nFit == nTextLen_rest); if (nFit > 0 && nFit <= nTextLen_rest) { CString strSeps = _T(" .,!?)-+=;\\"); //_T(" .,!?)-+=*&^%$#@~`:;\\|/"); int nFit_wb = 0; int nTextLen_wb = nTextLen_rest; LPCTSTR pTxt_wb = pTxt; LPCTSTR p_prev = NULL; int i = 0; for (i = 0; i < nFit; i++) { p_prev = pTxt; pTxt = _tcsinc(pTxt); int nCharLen = int(pTxt - p_prev); i += nCharLen - 1; // skip second byte for MBCS chars. nTextLen_rest--; if ((nFlags & DT_WORDBREAK) && strSeps.Find(*p_prev, 0) >= 0) { nFit_wb = i+1; nTextLen_wb = nTextLen_rest; pTxt_wb = pTxt; } } if (!bAllTextDrawn && (nFlags & DT_WORDBREAK)) { if (nFit_wb >= 0) { nFit = nFit_wb; nTextLen_rest = nTextLen_wb; pTxt = pTxt_wb; } } if (nFit) { m_ptNextPrintPos.x += alpDx[nFit - 1] + 1; } } // Draw text (if need) if (nFit && (nFlags & DT_CALCRECT) == 0) { rcText.left = max(rcText.left, nX); // ENSURE THE TEXT IS CLIPPED APPROPRIATELY pDC->ExtTextOut(nX, nY, ETO_CLIPPED, &rcText, pTextToDtaw, nFit, NULL); } CXTPRowInfo* pRI = GetRowInfo(nRow); if (pRI) pRI->nMaxWidth = m_ptNextPrintPos.x; // Move point to the next line (if need) if (!bAllTextDrawn && (nFlags & DT_SINGLELINE) == 0) { int nIconX = m_rcTextRect.left + m_ptNextPrintPos.x + 3; int nIconY = m_rcTextRect.top + nPosY + m_ptNextPrintPos.y; int nDelta = GetRowHeight() - GetRowHeight()/4; CPen pen1(PS_SOLID, 1, RGB(0,0,0)); CPen pen2(PS_SOLID, 2, RGB(0,0,0)); CPen* pPen_old = pDC->SelectObject(&pen1); pDC->MoveTo(nIconX, nIconY + nDelta/2); pDC->LineTo(nIconX, nIconY + nDelta); pDC->LineTo(nIconX + nDelta/2 - 1, nIconY + nDelta); pDC->SelectObject(&pen2); pDC->MoveTo(nIconX + 1, nIconY + nDelta - 1); pDC->LineTo(nIconX + nDelta/2, nIconY + nDelta/2); pDC->SelectObject(pPen_old); int nSublineOffsetX = m_tmText.tmAveCharWidth * 3; m_ptNextPrintPos.y += GetRowHeight(); m_ptNextPrintPos.x = nSublineOffsetX; if (pRI) pRI->nMaxWidth = m_ptNextPrintPos.x; } else { break; } } if (pnPrintedTextLen) { int nLen0 = int(pTxt - pcszText); *pnPrintedTextLen = (int)_tcsnccnt(pcszText, nLen0); } return m_ptNextPrintPos.y + GetRowHeight(); }
int CXTPSyntaxEditDrawTextProcessor::DrawRowPart(CDC* pDC, int nRow, LPCTSTR pcszText, int nchCount) { if (m_nDrawingRow != nRow) { if (nRow >= 0) // the new row started ResetRowInfo(nRow); m_nDrawingRow = nRow; m_nNextRowPosX = 0; } if (nRow == -1) return 0; //-------------------------------------------------------- int nTextLen = 0; if (nchCount < 0) { nchCount = (int) _tcsclen(pcszText); nTextLen = (int) _tcslen(pcszText); } else { #ifdef XTP_FIXED // "nchCount" meen byte length. // so, need not translate form TextLength to ByteLength. nTextLen = nchCount; #else nTextLen = (int) _tcsnbcnt(pcszText, nchCount); #endif } // ASSERT(nchCount <= (int) _tcsclen(pcszText)); //-------------------------------------------------------- int nY = m_rcTextRect.top + nRow * m_nRowHeight; int nX = m_rcTextRect.left - m_nScrollXOffset + m_nNextRowPosX; CRect rcText = m_rcTextRect; rcText.left = max(rcText.left, nX); // ENSURE THE TEXT IS CLIPPED APPROPRIATELY pDC->ExtTextOut(nX, nY, ETO_CLIPPED, &rcText, pcszText, nTextLen, NULL); //-------------------------------------------------------- if (m_arBuf_aDx.GetSize() < nTextLen) m_arBuf_aDx.SetSize(nTextLen + 100); int nMaxExtent = m_rcTextRect.Width() + m_nScrollXOffset - m_nNextRowPosX + 30; // 30 is a gap to be sure nMaxExtent = max(nMaxExtent, 30); int nFit = 0; LPINT alpDx = (int*)m_arBuf_aDx.GetData(); CSize szText(0, 0); BOOL bResExt = GetTextExtentExPoint(pDC->m_hAttribDC, pcszText, nTextLen, 0, // nMaxExtent, NULL, // &nFit, alpDx, // array of partial string widths &szText // string dimensions ); nFit = nTextLen; VERIFY(bResExt); CXTPRowInfo* pRI = GetRowInfo(nRow); if (pRI) { if (nFit >= 0 && nFit <= nTextLen) { int i; LPCTSTR p = pcszText; LPCTSTR p_prev = pcszText; for (i = 0; i < nFit; i++) { pRI->arCharsEnds.AddData(m_nNextRowPosX + alpDx[i]); p_prev = p; p = _tcsinc(p); int nCharLen = int(p - p_prev); #ifdef XTP_FIXED if (nCharLen > 1) pRI->arCharsEnds.AddData(m_nNextRowPosX + alpDx[i]); // ASSERT( nCharLen > 2 ); #endif i += nCharLen - 1; // skip second byte for MBCS chars. } } else { ASSERT(FALSE); } pRI->nMaxWidth += szText.cx; } m_nNextRowPosX += szText.cx; return m_nNextRowPosX; }
void AMessageForm::InitControls() { AutoDisableLayout adl(m_pUICore); int delta = 5; int iIconWidth = 48; //初始化图标 AContainer* pContent = GetContent(); int iconID=0; switch(m_iMessageType) { case MESSAGE_TYPE_INFOR:iconID = IDI_ICON_INFOR; break; case MESSAGE_TYPE_WARN:iconID = IDI_ICON_WARNING;break; case MESSAGE_TYPE_QUESTION:iconID = IDI_ICON_QUESTION;break; case MESSAGE_TYPE_ERROR:iconID = IDI_ICON_ERROR;break; case MESSAGE_TYPE_WAIT:iconID = IDI_ICON_WAITING;break; default: break; } if( iconID != 0 ) { AImageControl* pImageControl = new AImageControl(pContent); pImageControl->SetLeft(delta); pImageControl->SetTop(delta); pImageControl->SetWidth(iIconWidth); pImageControl->SetHeight(iIconWidth); //pImageControl->SetDrawStyle(idsStretch); AImage* pImage = AImage::CreateImage(); pImage->LoadIcon( ::LoadIcon(g_hInstance,MAKEINTRESOURCE(iconID)) ); pImageControl->SetGraphic(pImage); } //初始化文本 ACanvas* cs = m_pUICore->GetCanvas(); AStringArray sa; sa.FromString(m_sUserText,_T("\n")); ASize szText(0,0); AFont f;//缺省字体 int iw=0; int ih=0; for(int i=0;i<sa.GetCount();i++) { ASize sz( (sa[i].Length()) * f.GetSize(),f.GetSize());//缺省度量 if( cs ) sz = cs->MeasureText(sa[i]); if( sz.cx > szText.cx ) szText.cx = sz.cx; szText.cy += sz.cy + 6; } szText.cy += 23; ALabel* pTextLabel = new ALabel(pContent); if( m_iMessageType == MESSAGE_TYPE_INPUT ) { pTextLabel->SetLeft(16); pTextLabel->SetTop(10); pTextLabel->SetWidth(300); pTextLabel->SetHeight(20); AEdit* pEdit = new AEdit(pContent); pEdit->SetLeft(16); pEdit->SetTop(40); pEdit->SetWidth(200); pEdit->SetHeight(22); pEdit->SetName(_T("Input")); } else { pTextLabel->SetLeft(delta*2+96); pTextLabel->SetTop(delta); pTextLabel->SetWidth(szText.cx); pTextLabel->SetHeight(szText.cy+2 * delta); } pTextLabel->SetText(m_sUserText); pTextLabel->SetTextAlign(taLeftMiddle); //pTextLabel->Font.SetSize(16); //pTextLabel->SetUseSkin(false); int iWidth = delta * 3 + 32 + szText.cx+100; if( iWidth < 320 ) iWidth = 320; if( m_iMessageType == MESSAGE_TYPE_INPUT ) iWidth = 320; this->SetWidth(iWidth); this->SetHeight(28+(iIconWidth > szText.cy ? iIconWidth : szText.cy )+46+delta*2); if( m_iMessageType == MESSAGE_TYPE_INPUT ) this->SetHeight(160); //初始化按钮 int iButtonCount = 0; if( m_dbs & dbOK) iButtonCount ++; if( m_dbs & dbCancel ) iButtonCount ++; if( m_dbs & dbYes ) iButtonCount ++; if( m_dbs & dbNo ) iButtonCount ++; int iButtonWidth = 72; int iButtonHeight = 22; if( iButtonCount > 0 ) { int iButtonSpace = 10;//间隔距离 int iLeft = iButtonSpace * (iButtonCount-1) + iButtonWidth * iButtonCount; iLeft = (iWidth - iLeft)/2; int index=0; AContainer* pButtonContainer = GetBottomContainer(); if( m_dbs & dbOK ) { m_pOKButton = new AButton(pButtonContainer); m_pOKButton->SetWidth( iButtonWidth ); m_pOKButton->SetLeft( iLeft ); m_pOKButton->SetHeight( iButtonHeight ); m_pOKButton->SetTop( 10 ); m_pOKButton->SetText(_T("确定")); EVENT_CONNECT(m_pOKButton,OnClick,OnOKClick); iLeft += iButtonWidth+iButtonSpace; } if( m_dbs & dbYes ) { m_pYesButton = new AButton(pButtonContainer); m_pYesButton->SetWidth( iButtonWidth ); m_pYesButton->SetLeft( iLeft ); m_pYesButton->SetHeight( iButtonHeight ); m_pYesButton->SetTop( 10 ); m_pYesButton->SetText(_T("是")); EVENT_CONNECT(m_pYesButton,OnClick,OnYesClick); iLeft += iButtonWidth+iButtonSpace; } if( m_dbs & dbNo ) { m_pNoButton = new AButton(pButtonContainer); m_pNoButton->SetWidth( iButtonWidth ); m_pNoButton->SetLeft( iLeft ); m_pNoButton->SetHeight( iButtonHeight ); m_pNoButton->SetTop( 10 ); m_pNoButton->SetText(_T("否")); EVENT_CONNECT(m_pNoButton,OnClick,OnNoClick); iLeft += iButtonWidth+iButtonSpace; } if( m_dbs & dbCancel ) { m_pCancelButton = new AButton(pButtonContainer); m_pCancelButton->SetWidth( iButtonWidth ); m_pCancelButton->SetLeft( iLeft ); m_pCancelButton->SetHeight( iButtonHeight ); m_pCancelButton->SetTop( 10 ); m_pCancelButton->SetText(_T("取消")); EVENT_CONNECT(m_pCancelButton,OnClick,OnCancelClick); iLeft += iButtonWidth+iButtonSpace; } } //初始化标题 switch(m_iMessageType) { case MESSAGE_TYPE_INFOR:this->SetText(_T("提示"));break; case MESSAGE_TYPE_WARN:this->SetText(_T("警告"));break; case MESSAGE_TYPE_QUESTION:this->SetText(_T("询问"));break; case MESSAGE_TYPE_ERROR:this->SetText(_T("错误"));break; case MESSAGE_TYPE_WAIT:this->SetText(_T("等待"));break; default: break; } }
int CXTPTabPaintManager::DrawSingleButtonIconAndText(CDC* pDC, CXTPTabManagerItem* pItem, CRect rcItem, BOOL bDraw) { CXTPTabManager* pManager = pItem->GetTabManager(); XTPTabLayoutStyle layout = pManager->GetLayout(); BOOL bVertical = !pManager->IsHorizontalPosition(); if (layout == xtpTabLayoutRotated) bVertical = !bVertical; CString strItem = pItem->GetCaption(); CFont* pFont = m_bBoldSelected && pItem->IsSelected() && pManager->IsActive() ? GetBoldFont(bVertical) : GetFont(bVertical); CXTPFontDC fnt(pDC, pFont); CSize szIcon(m_szIcon); BOOL bDrawIcon = pManager->DrawIcon(pDC, 0, pItem, FALSE, szIcon); BOOL bDrawText = layout != xtpTabLayoutCompressed || pItem->IsSelected(); int nNavigateButtonsLength = 0; if (bDrawText && pItem->GetNavigateButtons()->GetSize() > 0) { nNavigateButtonsLength = 0; for (int i = 0; i < (int)pItem->GetNavigateButtons()->GetSize(); i++) { CXTPTabManagerNavigateButton* pButton = pItem->GetNavigateButtons()->GetAt(i); if (pManager->IsNavigateButtonVisible(pButton)) { CSize sz = pButton->GetSize(); nNavigateButtonsLength += bVertical ? sz.cy : sz.cx; } } if (nNavigateButtonsLength > 0) nNavigateButtonsLength += 3; } if (bDraw) { if (nNavigateButtonsLength > 0) { m_pColorSet->SetTextColor(pDC, pItem); if (bVertical) rcItem.bottom -= 3; else rcItem.right -= 3; for (int i = (int)pItem->GetNavigateButtons()->GetSize() - 1; i >= 0; i--) { CXTPTabManagerNavigateButton* pButton = pItem->GetNavigateButtons()->GetAt(i); if (pManager->IsNavigateButtonVisible(pButton)) { CSize szButton = pButton->GetSize(); if (!bVertical) { pButton->SetRect(CRect(rcItem.right - szButton.cx, rcItem.CenterPoint().y + szButton.cy / 2 - szButton.cy, rcItem.right, rcItem.CenterPoint().y + szButton.cy / 2)); rcItem.right -= szButton.cx; } else { pButton->SetRect(CRect(rcItem.CenterPoint().x - szButton.cx / 2, rcItem.bottom - szButton.cy, rcItem.CenterPoint().x - szButton.cx / 2 + szButton.cx, rcItem.bottom)); rcItem.bottom -= szButton.cy; } pItem->GetNavigateButtons()->GetAt(i)->Draw(pDC); } } } m_pColorSet->SetTextColor(pDC, pItem); CRect rcFocus(rcItem); if (bVertical) { int nAvailLength = pItem->GetButtonLength() - pItem->GetContentLength(); if (nAvailLength > 0) { rcItem.DeflateRect(0, nAvailLength / 2); } rcItem.top += m_rcButtonTextPadding.left + m_rcButtonMargin.left; if (pManager->GetPosition() == xtpTabPositionRight) rcItem.DeflateRect(m_rcButtonMargin.bottom, 0, m_rcButtonMargin.top, 0); else rcItem.DeflateRect(m_rcButtonMargin.top, 0, m_rcButtonMargin.bottom, 0); if (bDrawIcon) { CPoint pt(rcItem.CenterPoint().x - szIcon.cx/2, rcItem.top - 1); if (rcItem.Height() > szIcon.cy) pManager->DrawIcon(pDC, pt, pItem, TRUE, szIcon); rcItem.top += szIcon.cy + 2; } if (bDrawText && rcItem.bottom > rcItem.top + 8) { CSize szText = pDC->GetTextExtent(strItem); rcItem.left = rcItem.right - (rcItem.Width() - szText.cy - (pManager->GetPosition() == xtpTabPositionRight ? 1 : 0)) / 2; rcItem.right = rcItem.left + rcItem.Height(); rcItem.bottom -= m_rcButtonMargin.right + max(0, m_rcButtonTextPadding.right - 4); if (!m_bDrawTextNoPrefix) StripMnemonics(strItem); if (m_bDrawTextPathEllipsis) { DrawTextPathEllipsis(pDC, pManager, strItem, rcItem, DT_SINGLELINE | DT_NOCLIP | DT_NOPREFIX); } else { m_pAppearanceSet->DrawText(pDC, pManager, strItem, &rcItem, DT_SINGLELINE | DT_NOCLIP | DT_NOPREFIX | (m_bDrawTextEndEllipsis ? DT_END_ELLIPSIS : 0)); } } } else { int nAvailLength = pItem->GetButtonLength() - pItem->GetContentLength(); if (nAvailLength > 0) { rcItem.DeflateRect(nAvailLength / 2, 0); } rcItem.left += m_rcButtonTextPadding.left + m_rcButtonMargin.left; if (pManager->GetPosition() == xtpTabPositionBottom) rcItem.DeflateRect(0, m_rcButtonMargin.bottom, 0, m_rcButtonMargin.top); else rcItem.DeflateRect(0, m_rcButtonMargin.top, 0, m_rcButtonMargin.bottom); if (bDrawIcon) { CPoint pt(rcItem.left - 1, rcItem.CenterPoint().y - szIcon.cy/2); if (rcItem.Width() > szIcon.cx) pManager->DrawIcon(pDC, pt, pItem, TRUE, szIcon); rcItem.left += szIcon.cx + 2; } if (bDrawText && rcItem.right > rcItem.left) { rcItem.right -= m_rcButtonTextPadding.right + m_rcButtonMargin.right - (bDrawIcon ? 2 : 0); if (pItem->GetMarkupUIElement()) { XTPMarkupSetDefaultFont(pItem->GetTabManager()->GetMarkupContext(), (HFONT)pFont->GetSafeHandle(), pDC->GetTextColor()); CRect rcText(rcItem); if (m_nDrawTextFormat & DT_VCENTER) { CSize szText = XTPMarkupMeasureElement(pItem->GetMarkupUIElement()); rcText.top = (rcText.top + rcText.bottom - szText.cy) / 2; rcText.bottom = rcText.top + szText.cy; } XTPMarkupRenderElement(pItem->GetMarkupUIElement(), pDC->GetSafeHdc(), rcText); } else if (m_bDrawTextPathEllipsis) { DrawTextPathEllipsis(pDC, pManager, strItem, rcItem, DT_SINGLELINE | m_nDrawTextFormat | (m_bDrawTextNoPrefix ? DT_NOPREFIX : 0)); } else { if (m_bDrawTextHidePrefix) StripMnemonics(strItem); m_pAppearanceSet->DrawText(pDC, pManager, strItem, rcItem, DT_SINGLELINE | m_nDrawTextFormat | (m_bDrawTextHidePrefix || m_bDrawTextNoPrefix ? DT_NOPREFIX : 0) | (m_bDrawTextEndEllipsis ? DT_END_ELLIPSIS : 0)); } } } if (pItem->IsFocused()) { DrawFocusRect(pDC, pItem, rcFocus); } return 0; } else { if (layout == xtpTabLayoutFixed) { return _GetButtonLength(m_nFixedTabWidth, m_nMinTabWidth, m_nMaxTabWidth); } if (layout == xtpTabLayoutCompressed) { if (!bDrawText) return _GetButtonLength(8 + (bVertical ? szIcon.cy : szIcon.cx), m_nMinTabWidth, m_nMaxTabWidth) ; CXTPFontDC fntItems(pDC, m_bBoldSelected && pManager->IsActive() ? GetBoldFont(bVertical) : GetFont(bVertical)); int nLength = 0; for (int i = 0; i < pManager->GetItemCount(); i++) { CRect rcItemText(0, 0, 0, 0); m_pAppearanceSet->DrawText(pDC, pManager, pManager->GetItem(i)->GetCaption(), rcItemText, DT_SINGLELINE | DT_CALCRECT | DT_NOCLIP | (m_bDrawTextNoPrefix ? DT_NOPREFIX : 0)); nLength = max(nLength, rcItemText.Width()); } return _GetButtonLength(nNavigateButtonsLength + nLength + m_rcButtonTextPadding.left + m_rcButtonTextPadding.right + (!bDrawIcon ? 0: bVertical ? szIcon.cy : szIcon.cx), m_nMinTabWidth, m_nMaxTabWidth); } CSize szText(0); if (pItem->GetMarkupUIElement()) { XTPMarkupSetDefaultFont(pManager->GetMarkupContext(), (HFONT)pFont->GetSafeHandle(), pDC->GetTextColor()); szText = XTPMarkupMeasureElement(pItem->GetMarkupUIElement()); } else { m_pAppearanceSet->DrawText(pDC, pManager, strItem, rcItem, DT_SINGLELINE | DT_CALCRECT | DT_NOCLIP | (m_bDrawTextNoPrefix ? DT_NOPREFIX : 0)); szText = rcItem.Size(); } return _GetButtonLength(nNavigateButtonsLength + szText.cx + m_rcButtonTextPadding.left + m_rcButtonTextPadding.right + (!bDrawIcon ? 0: bVertical ? szIcon.cy : szIcon.cx), m_nMinTabWidth, m_nMaxTabWidth); } }