void CUploadListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (!theApp.emuledlg->IsRunning()) return; if (!lpDrawItemStruct->itemData) return; CDC* odc = CDC::FromHandle(lpDrawItemStruct->hDC); BOOL bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS)); if (lpDrawItemStruct->itemState & ODS_SELECTED) { if (bCtrlFocused) odc->SetBkColor(m_crHighlight); else odc->SetBkColor(m_crNoHighlight); } else odc->SetBkColor(GetBkColor()); const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData; CMemDC dc(odc, &lpDrawItemStruct->rcItem); CFont* pOldFont = dc.SelectObject(GetFont()); CRect cur_rec(lpDrawItemStruct->rcItem); COLORREF crOldTextColor = dc.SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : m_crWindowText); if (client->GetSlotNumber() > theApp.uploadqueue->GetActiveUploadsCount()) { dc.SetTextColor(::GetSysColor(COLOR_GRAYTEXT)); } int iOldBkMode; if (m_crWindowTextBk == CLR_NONE){ DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0); iOldBkMode = dc.SetBkMode(TRANSPARENT); } else iOldBkMode = OPAQUE; CKnownFile* file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID()); CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - 8; cur_rec.left += 4; CString Sbuffer; for (int iCurrent = 0; iCurrent < iCount; iCurrent++) { int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if (!IsColumnHidden(iColumn)) { cur_rec.right += GetColumnWidth(iColumn); switch (iColumn) { case 0:{ uint8 image; if (client->IsFriend()) image = 4; else if (client->GetClientSoft() == SO_EDONKEYHYBRID){ if (client->credits->GetScoreRatio(client->GetIP()) > 1) image = 8; else image = 7; } else if (client->GetClientSoft() == SO_MLDONKEY){ if (client->credits->GetScoreRatio(client->GetIP()) > 1) image = 6; else image = 5; } else if (client->GetClientSoft() == SO_SHAREAZA){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 10; else image = 9; } else if (client->GetClientSoft() == SO_AMULE){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 12; else image = 11; } else if (client->GetClientSoft() == SO_LPHANT){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 14; else image = 13; } else if (client->ExtProtocolAvailable()){ if(client->credits->GetScoreRatio(client->GetIP()) > 1) image = 3; else image = 1; } else{ if (client->credits->GetScoreRatio(client->GetIP()) > 1) image = 2; else image = 0; } uint32 nOverlayImage = 0; if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED)) nOverlayImage |= 1; if (client->IsObfuscatedConnectionEstablished()) nOverlayImage |= 2; int iIconPosY = (cur_rec.Height() > 16) ? ((cur_rec.Height() - 16) / 2) : 1; POINT point = {cur_rec.left, cur_rec.top + iIconPosY}; imagelist.Draw(dc,image, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage)); Sbuffer = client->GetUserName(); cur_rec.left += 20; dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT); cur_rec.left -= 20; break; } case 1: if (file) Sbuffer = file->GetFileName(); else Sbuffer = _T("?"); break; case 2: Sbuffer = CastItoXBytes(client->GetDatarate(), false, true); break; case 3: // NOTE: If you change (add/remove) anything which is displayed here, update also the sorting part.. if (thePrefs.m_bExtControls) Sbuffer.Format( _T("%s (%s)"), CastItoXBytes(client->GetSessionUp(), false, false), CastItoXBytes(client->GetQueueSessionPayloadUp(), false, false)); else Sbuffer = CastItoXBytes(client->GetSessionUp(), false, false); break; case 4: if (client->HasLowID()) Sbuffer.Format(_T("%s (%s)"), CastSecondsToHM(client->GetWaitTime()/1000), GetResString(IDS_IDLOW)); else Sbuffer = CastSecondsToHM(client->GetWaitTime()/1000); break; case 5: Sbuffer = CastSecondsToHM(client->GetUpStartTimeDelay()/1000); break; case 6: Sbuffer = client->GetUploadStateDisplayString(); break; case 7: cur_rec.bottom--; cur_rec.top++; client->DrawUpStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar()); cur_rec.bottom++; cur_rec.top--; break; } if (iColumn != 7 && iColumn != 0) dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT); cur_rec.left += GetColumnWidth(iColumn); } } //draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT outline_rec = lpDrawItemStruct->rcItem; outline_rec.top--; outline_rec.bottom++; dc.FrameRect(&outline_rec, &CBrush(GetBkColor())); outline_rec.top++; outline_rec.bottom--; outline_rec.left++; outline_rec.right--; if (bCtrlFocused) dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine)); else dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine)); } if (m_crWindowTextBk == CLR_NONE) dc.SetBkMode(iOldBkMode); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); }
/** Load image from disk, update imgr and imgf * @return true on success */ static bool do_open_image(char const* filename) { // MessageBox(NULL, filename, "opening image", 0); if (imgf!=NULL) { if (imgr!=NULL) { delete imgr; imgr=NULL; } delete imgf; imgf=NULL; if (filename2!=NULL) filename2[0]='-'; /* mark file closed */ } // !! free // !! check for errors // !! generalize SimBuffer::B loadHints; #if 0 Image::Loader::reader_t reader=in_bmp_loader.checker( "BM\0\0\0\0" "\0\0\0\0" "\0\0\0\0" "\0\0\0\0", "", opt); FILE *f=fopen(filename, "rb"); if (f==NULL) return false; Image::Sampled *img=reader((Image::filep_t)f, loadHints); fclose(f); #endif init_loader(); SamImageLoad args; args.filename=filename; args.loadHints=&loadHints; Image::Sampled *img=(Image::Sampled*)do_samfun((SamArgs::samfun_t)do_image_load, &args); if (img==NULL) return false; // Image::load(filename, loadHints); imgr=new WinImageRGB(CopyableAdapter(*img)); // Image::Sampled *imgrgb=img->toRGB(8); // imgr=new WinImageRGB(img->getWd(), img->getHt()); // imgr->fill(0,0,(char)255); // imgr->fromPPM8(imgrgb->getRowbeg()); assert(imgr!=NULL); /* `operator new' never returns NULL */ // HDC hdc_main=GetDC(hwnd_main); imgf=new WinFastImage(hwnd_main, imgr->getHbitmap()); wd_last=imgf->getWd(); ht_last=imgf->getHt(); // ReleaseDC(hwnd_main, hdc_main); slen_t len=strlen(filename); if (filename2!=NULL) delete [] filename2; strcpy(filename2=new char[len+3], ": "); strcpy(filename2+2, filename); SetWindowText(hwnd_main, filename2); SetWindowLong(hwnd_main, GWL_STYLE, GetWindowLong(hwnd_main, GWL_STYLE)&~WS_THICKFRAME); /* ^^^ The Win32 API way to say hwnd_main.setResizable(false); :-) */ InvalidateRect(hwnd_main, NULL, TRUE); #if 0 LONG fr_wd, fr_ht; getFrameSize(hwnd_main, fr_wd, fr_ht); // !! handle minimum window size SetWindowPos(hwnd_main, NULL, 0, 0, fr_wd+imgf->getWd(), fr_ht+imgf->getHt(), SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER); GdiFlush(); { /* Dat: strange, two iterations of getFrameSize + SetWindowPos is needed !! still bad */ getFrameSize(hwnd_main, fr_wd, fr_ht); SetWindowPos(hwnd_main, NULL, 0, 0, fr_wd+imgf->getWd(), fr_ht+imgf->getHt(), SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER); } BOOL CYourWndOrDialog::ResizeClient (int nWidth, int nHeight, BOOL bRedraw) { RECT rcWnd; GetClientRect (&rcWnd); if(nWidth != -1) rcWnd.right = nWidth; if(nHeight != -1) rcWnd.bottom = nHeight; if(!::AdjustWindowRectEx(&rcWnd, GetStyle(), (!(GetStyle() & WS_CHILD) && GetMenu() != NULL)), GetExStyle())) return FALSE; UINT uFlags = SWP_NOZORDER | SWP_NOMOVE; if(!bRedraw) uFlags |= SWP_NOREDRAW; return SetWindowPos(NULL, 0, 0, rcWnd.right - rcWnd.left, rcWnd.bottom - rcWnd.top, uFlags); } // CYourWndOrDialog::ResizeClient
void CKofBCGPFontComboBox::OnPaint() { if ((GetStyle () & 0x0003L) == CBS_SIMPLE) { Default (); return; } if (!m_bVisualManagerStyle && !m_bOnGlass) { Default (); return; } CPaintDC dc(this); // device context for painting BYTE alpha = 0; if (m_bOnGlass) { alpha = 255; } CBCGPMemDC memDC (dc, this, alpha); CDC* pDC = &memDC.GetDC (); CRect rectClient; GetClientRect (rectClient); CBCGPDrawManager dm (*pDC); dm.DrawRect (rectClient, globalData.clrWindow, (COLORREF)-1); // 得注释掉这句话 // SendMessage (WM_PRINTCLIENT, (WPARAM) pDC->GetSafeHdc (), (LPARAM) PRF_CLIENT); const int cxDropDown = ::GetSystemMetrics (SM_CXVSCROLL) + 4; int nCurSel = GetCurSel(); if (CB_ERR != nCurSel) { if (m_Images.GetSafeHandle () == NULL) { CBCGPLocalResource locaRes; m_Images.Create (IDB_BCGBARRES_FONT, nImageWidth, 0, RGB (255, 255, 255)); } CFont fontSelected; CFont* pOldFont = NULL; CRect rc(rectClient); rc.right -= cxDropDown; CBCGPFontDesc* pDesc = (CBCGPFontDesc*)GetItemDataPtr(nCurSel); if (pDesc != NULL) { if (pDesc->m_nType & (DEVICE_FONTTYPE | TRUETYPE_FONTTYPE)) { CPoint ptImage (rc.left + 3, rc.top + (rc.Height () - nImageHeight) / 2); m_Images.Draw (pDC, pDesc->GetImageIndex (), ptImage, ILD_NORMAL); } rc.left += nImageWidth + 9; if (m_bDrawUsingFont && pDesc->m_nCharSet != SYMBOL_CHARSET) { LOGFONT lf; globalData.fontRegular.GetLogFont (&lf); lstrcpy (lf.lfFaceName, pDesc->m_strName); if (pDesc->m_nCharSet != DEFAULT_CHARSET) { lf.lfCharSet = pDesc->m_nCharSet; } if (lf.lfHeight < 0) { lf.lfHeight -= 4; } else { lf.lfHeight += 4; } fontSelected.CreateFontIndirect (&lf); pOldFont = pDC->SelectObject (&fontSelected); } } CString strText; GetLBText (nCurSel, strText); pDC->DrawText (strText, rc, DT_SINGLELINE | DT_VCENTER); if (pOldFont != NULL) { pDC->SelectObject (pOldFont); } } m_rectBtn = rectClient; m_rectBtn.left = m_rectBtn.right - cxDropDown; m_rectBtn.DeflateRect (2, 2); CBCGPDrawOnGlass dog (m_bOnGlass); CKofBCGPToolbarComboBoxButton buttonDummy; #ifndef _BCGSUITE_ buttonDummy.m_bIsCtrl = TRUE; CBCGPVisualManager::GetInstance ()->OnDrawComboDropButton ( pDC, m_rectBtn, !IsWindowEnabled (), m_bIsDroppedDown, m_bIsButtonHighlighted, &buttonDummy); #else CMFCVisualManager::GetInstance ()->OnDrawComboDropButton ( pDC, m_rectBtn, !IsWindowEnabled (), m_bIsDroppedDown, m_bIsButtonHighlighted, &buttonDummy); #endif dm.DrawRect (rectClient, (COLORREF)-1, globalData.clrBarShadow); rectClient.DeflateRect (1, 1); dm.DrawRect (rectClient, (COLORREF)-1, globalData.clrWindow); }
wxObject *wxChoicebookXmlHandler::DoCreateResource() { if (m_class == wxT("choicebookpage")) { wxXmlNode *n = GetParamNode(wxT("object")); if ( !n ) n = GetParamNode(wxT("object_ref")); if (n) { bool old_ins = m_isInside; m_isInside = false; wxObject *item = CreateResFromNode(n, m_choicebook, NULL); m_isInside = old_ins; wxWindow *wnd = wxDynamicCast(item, wxWindow); if (wnd) { m_choicebook->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected"))); if ( HasParam(wxT("bitmap")) ) { wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); wxImageList *imgList = m_choicebook->GetImageList(); if ( imgList == NULL ) { imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() ); m_choicebook->AssignImageList( imgList ); } int imgIndex = imgList->Add(bmp); m_choicebook->SetPageImage(m_choicebook->GetPageCount()-1, imgIndex ); } } else wxLogError(wxT("Error in resource.")); return wnd; } else { wxLogError(wxT("Error in resource: no control within choicebook's <page> tag.")); return NULL; } } else { XRC_MAKE_INSTANCE(nb, wxChoicebook) nb->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style")), GetName()); wxChoicebook *old_par = m_choicebook; m_choicebook = nb; bool old_ins = m_isInside; m_isInside = true; CreateChildren(m_choicebook, true/*only this handler*/); m_isInside = old_ins; m_choicebook = old_par; return nb; } }
//************************************************************************************* void CBCGPFrameWnd::RecalcLayout (BOOL bNotify) { if (m_bInRecalcLayout) return; m_bInRecalcLayout = TRUE; BOOL bWasOleInPlaceActive = m_Impl.m_bIsOleInPlaceActive; m_Impl.m_bIsOleInPlaceActive = FALSE; COleClientItem* pActiveItem = GetInPlaceActiveItem (); if (pActiveItem != NULL && pActiveItem->m_pInPlaceFrame != NULL && pActiveItem->GetItemState () == COleClientItem::activeUIState) { m_Impl.m_bIsOleInPlaceActive = TRUE; m_Impl.m_bHadCaption = (GetStyle () & WS_CAPTION) != 0; } if (!m_bIsMinimized) { CView* pView = GetActiveView (); if (m_dockManager.IsPrintPreviewValid () || m_pNotifyHook != NULL) { if (pView != NULL && pView->IsKindOf (RUNTIME_CLASS (CBCGPPrintPreviewView))) { m_dockManager.RecalcLayout (bNotify); CRect rectClient = m_dockManager.GetClientAreaBounds (); pView->SetWindowPos (NULL, rectClient.left, rectClient.top, rectClient.Width (), rectClient.Height (), SWP_NOZORDER | SWP_NOACTIVATE); } else { if (bNotify && m_pNotifyHook != NULL) { ActiveItemRecalcLayout (); } else { m_bInRecalcLayout = FALSE; CFrameWnd::RecalcLayout (bNotify); AdjustClientArea (); } } } else { m_dockManager.RecalcLayout (bNotify); AdjustClientArea (); } } m_bInRecalcLayout = FALSE; if (bWasOleInPlaceActive != m_Impl.m_bIsOleInPlaceActive) { if (!m_Impl.m_bHadCaption) { if (m_Impl.m_bIsOleInPlaceActive) { ModifyStyle (0, WS_CAPTION); } else { ModifyStyle (WS_CAPTION, 0); } } m_Impl.OnChangeVisualManager (); SetWindowPos (NULL, -1, -1, -1, -1, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_FRAMECHANGED); } }
bool CWidget::CalcPositionFromClientRect(RECT *pRect) const { if (m_hwnd==nullptr) return false; return ::AdjustWindowRectEx(pRect,GetStyle(),FALSE,GetExStyle())!=FALSE; }
wxString wxNativeFontInfo::ToUserString() const { wxString desc; // first put the adjectives, if any - this is English-centric, of course, // but what else can we do? if ( GetUnderlined() ) { desc << _("underlined"); } if ( GetStrikethrough() ) { desc << _(" strikethrough"); } switch ( GetWeight() ) { default: wxFAIL_MSG( wxT("unknown font weight") ); wxFALLTHROUGH; case wxFONTWEIGHT_NORMAL: break; case wxFONTWEIGHT_THIN: desc << _(" thin"); break; case wxFONTWEIGHT_EXTRALIGHT: desc << _(" extra light"); break; case wxFONTWEIGHT_LIGHT: desc << _(" light"); break; case wxFONTWEIGHT_MEDIUM: desc << _(" medium"); break; case wxFONTWEIGHT_SEMIBOLD: desc << _(" semi bold"); break; case wxFONTWEIGHT_BOLD: desc << _(" bold"); break; case wxFONTWEIGHT_EXTRABOLD: desc << _(" extra bold"); break; case wxFONTWEIGHT_HEAVY: desc << _(" heavy"); break; case wxFONTWEIGHT_EXTRAHEAVY: desc << _(" extra heavy"); break; } switch ( GetStyle() ) { default: wxFAIL_MSG( wxT("unknown font style") ); wxFALLTHROUGH; case wxFONTSTYLE_NORMAL: break; // we don't distinguish between the two for now anyhow... case wxFONTSTYLE_ITALIC: case wxFONTSTYLE_SLANT: desc << _(" italic"); break; } wxString face = GetFaceName(); if ( !face.empty() ) { if (face.Contains(' ') || face.Contains(';') || face.Contains(',')) { face.Replace("'", ""); // eventually remove quote characters: most systems do not // allow them in a facename anyway so this usually does nothing // make it possible for FromUserString() function to understand // that the different words which compose this facename are // not different adjectives or other data but rather all parts // of the facename desc << wxT(" '") << face << wxT("'"); } else desc << wxT(' ') << face; } else // no face name specified { // use the family wxString familyStr; switch ( GetFamily() ) { case wxFONTFAMILY_DECORATIVE: familyStr = "decorative"; break; case wxFONTFAMILY_ROMAN: familyStr = "roman"; break; case wxFONTFAMILY_SCRIPT: familyStr = "script"; break; case wxFONTFAMILY_SWISS: familyStr = "swiss"; break; case wxFONTFAMILY_MODERN: familyStr = "modern"; break; case wxFONTFAMILY_TELETYPE: familyStr = "teletype"; break; case wxFONTFAMILY_DEFAULT: case wxFONTFAMILY_UNKNOWN: break; default: wxFAIL_MSG( "unknown font family" ); } if ( !familyStr.empty() ) desc << " '" << familyStr << " family'"; } int size = GetPointSize(); if ( size != wxNORMAL_FONT->GetPointSize() ) { desc << wxT(' ') << size; } #if wxUSE_FONTMAP wxFontEncoding enc = GetEncoding(); if ( enc != wxFONTENCODING_DEFAULT && enc != wxFONTENCODING_SYSTEM ) { desc << wxT(' ') << wxFontMapper::GetEncodingName(enc); } #endif // wxUSE_FONTMAP return desc.Strip(wxString::both).MakeLower(); }
UINT CIconButtonCtrl::OnGetDlgCode() { return ( GetStyle() & BS_DEFPUSHBUTTON ) ? DLGC_DEFPUSHBUTTON : DLGC_UNDEFPUSHBUTTON; }
void CXTPSkinObjectTab::DrawTabText(CDC* pDC, CRect& rcItem, int iItem, int iCount, BOOL bSelected) { CTabCtrl* pTabCtrl = (CTabCtrl*)this; CString strCaption; LPTSTR pszText = strCaption.GetBuffer(256); pszText[0] = 0; TC_ITEM tci; tci.mask = TCIF_TEXT; tci.pszText = pszText; tci.cchTextMax = 255; BOOL bResult = pTabCtrl->GetItem(iItem, &tci); strCaption.ReleaseBuffer(); #ifdef _UNICODE if (!bResult) { char tText[256]; tText[0] = 0; TC_ITEMA tcia; ::ZeroMemory(&tcia, sizeof(TC_ITEMA)); tcia.mask = TCIF_TEXT; // Get the header item text and format tcia.pszText = tText; tcia.cchTextMax = 255; ::SendMessage(pTabCtrl->m_hWnd, TCM_GETITEMA, iItem, (LPARAM)&tcia); strCaption = tText; } #else if (!bResult) return; #endif if (strCaption.GetLength() == 0) return; pDC->SetTextColor(GetColor(COLOR_BTNTEXT)); // Set the font for the tab label. DWORD dwStyle = GetStyle(); CXTPSkinManagerClass* pClass = GetSkinClass(); int nStateId = bSelected ? TIS_SELECTED: m_nHotItem == iItem ? TIS_HOT : TIS_NORMAL; int nPartId = iItem == 0 ? TABP_TOPTABITEMLEFTEDGE : iItem == iCount - 1 && !bSelected ? TABP_TOPTABITEMRIGHTEDGE : TABP_TOPTABITEM; // Draw the tab label. if (IsHorz(dwStyle)) { UINT dsFlags = DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_END_ELLIPSIS; if (SendMessage(WM_QUERYUISTATE) & UISF_HIDEACCEL) { dsFlags |= DT_HIDEPREFIX; } if (!(GetStyle() & TCS_BUTTONS)) { rcItem.top += bSelected ? -2 : 1; rcItem.right -= iItem == 0 ? 3 : 0; } else { rcItem.top += bSelected ? 0 : -1; } pClass->DrawThemeText(pDC, nPartId, nStateId, strCaption, dsFlags, &rcItem); } else { CSize sz = pDC->GetTextExtent(strCaption); rcItem.left = rcItem.right-(rcItem.Width()-sz.cy + 1)/ 2; rcItem.top = rcItem.top+(rcItem.Height()-sz.cx + 1)/ 2; pClass->DrawThemeText(pDC, nPartId, nStateId, strCaption, DT_SINGLELINE | DT_NOCLIP, &rcItem); } }
void MFCSimpleTypeView::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { int m_bClientWidthSel = TRUE; int m_cxClient = 0; int m_cxStateImageOffset = 0; COLORREF m_clrText = ::GetSysColor(COLOR_WINDOWTEXT); COLORREF m_clrTextBk = ::GetSysColor(COLOR_WINDOW); COLORREF m_clrBkgnd = ::GetSysColor(COLOR_WINDOW); CListCtrl& listCtrl=GetListCtrl(); CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); CRect rcItem(lpDrawItemStruct->rcItem); UINT uiFlags = ILD_TRANSPARENT; CImageList* pImageList; int nItem = lpDrawItemStruct->itemID; BOOL bFocus = (GetFocus() == this); COLORREF clrTextSave, clrBkSave; COLORREF clrImage = m_clrBkgnd; static _TCHAR szBuff[MAX_PATH]; LPCTSTR pszText; StabEnt *itemSym = SymForItem(nItem); // get item data LV_ITEM lvi; lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE; lvi.iItem = nItem; lvi.iSubItem = 0; lvi.pszText = szBuff; lvi.cchTextMax = sizeof(szBuff); lvi.stateMask = 0xFFFF; // get all state flags listCtrl.GetItem(&lvi); BOOL bSelected = (bFocus || (GetStyle() & LVS_SHOWSELALWAYS)) && lvi.state & LVIS_SELECTED; bSelected = bSelected || (lvi.state & LVIS_DROPHILITED); // set colors if item is selected CRect rcAllLabels; listCtrl.GetItemRect(nItem, rcAllLabels, LVIR_BOUNDS); CRect rcLabel; listCtrl.GetItemRect(nItem, rcLabel, LVIR_BOUNDS); // listCtrl.GetItemRect(nItem, rcLabel, LVIR_LABEL); rcAllLabels.left = rcLabel.left; if (m_bClientWidthSel && rcAllLabels.right<m_cxClient) rcAllLabels.right = m_cxClient; if (bSelected) { clrTextSave = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); clrBkSave = pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT)); pDC->FillRect(rcAllLabels, &CBrush(::GetSysColor(COLOR_HIGHLIGHT))); } else pDC->FillRect(rcAllLabels, &CBrush(m_clrTextBk)); // set color and mask for the icon if (lvi.state & LVIS_CUT) { clrImage = m_clrBkgnd; uiFlags |= ILD_BLEND50; } else if (bSelected) { clrImage = ::GetSysColor(COLOR_HIGHLIGHT); uiFlags |= ILD_BLEND50; } // draw state icon UINT nStateImageMask = lvi.state & LVIS_STATEIMAGEMASK; if (nStateImageMask) { int nImage = (nStateImageMask>>12) - 1; pImageList = listCtrl.GetImageList(LVSIL_STATE); if (pImageList) { pImageList->Draw(pDC, nImage, CPoint(rcItem.left, rcItem.top), ILD_TRANSPARENT); } } // draw normal and overlay icon /* CRect rcIcon; ListCtrl.GetItemRect(nItem, rcIcon, LVIR_ICON); pImageList = listCtrl.GetImageList(LVSIL_SMALL); if (pImageList) { UINT nOvlImageMask=lvi.state & LVIS_OVERLAYMASK; if (rcItem.left<rcItem.right-1) { ImageList_DrawEx(pImageList->m_hImageList, lvi.iImage, pDC->m_hDC,rcIcon.left,rcIcon.top, 16, 16, m_clrBkgnd, clrImage, uiFlags | nOvlImageMask); } } */ // draw item label // listCtrl.GetItemRect(nItem, rcItem, LVIR_LABEL); LV_COLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH; listCtrl.GetItemRect(nItem, rcItem, LVIR_BOUNDS); listCtrl.GetColumn(0, &lvc); rcItem.right = lvc.cx; // pszText = MakeShortString(pDC, szBuff, // rcItem.right-rcItem.left, 2*OFFSET_FIRST); pszText = szBuff; rcLabel = rcItem; rcLabel.left += OFFSET_FIRST; rcLabel.right -= OFFSET_FIRST; pDC->SetTextColor(rgb_black); pDC->DrawText(pszText,-1,rcLabel,DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER); // draw labels for extra columns if (itemSym) { UINT nOvlImageMask=lvi.state & LVIS_OVERLAYMASK; // type listCtrl.GetColumn(1, &lvc); rcItem.left = rcItem.right; rcItem.right += lvc.cx; rcLabel = rcItem; rcLabel.left += OFFSET_OTHER; rcLabel.right -= OFFSET_OTHER; string tnm = findTypeName(itemSym->type); if (tnm.size()) { pDC->SetTextColor(rgb_blue); long h = pDC->DrawText(tnm.c_str() , -1, rcLabel, DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER); } // length listCtrl.GetColumn(2, &lvc); rcItem.left = rcItem.right; rcItem.right += lvc.cx; // fprintf(stderr, "%d %d %d\n", pszText, itemSym->type, lvc.cx); rcLabel = rcItem; rcLabel.left += OFFSET_OTHER; rcLabel.right -= OFFSET_OTHER; if (itemSym->indirection > 0) { char buf[120]; buf[0] = 0; for (short i=1; i<itemSym->indirection; i++) { char nbuf[10]; sprintf(nbuf, "%s%d", i>1?",":"",itemSym->size[i]); strcat(buf, nbuf); } pDC->SetTextColor(rgb_blue); pDC->DrawText(buf, -1, rcLabel, DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER); } // controller listCtrl.GetColumn(3, &lvc); rcItem.left = rcItem.right; rcItem.right += lvc.cx; if (itemSym->controlMode != StabEnt::DISPLAY_NOT) { ImageList_DrawEx(images, itemSym->controlMode == StabEnt::DISPLAY_CTL ? 0 : itemSym->controlMode == StabEnt::DISPLAY_DISP? 2 : 0, pDC->m_hDC,rcItem.left,rcItem.top, 16, 16, m_clrBkgnd, clrImage, uiFlags | nOvlImageMask); } // envelope listCtrl.GetColumn(4, &lvc); rcItem.left = rcItem.right; rcItem.right += lvc.cx; if (itemSym->isEnveloped) { ImageList_DrawEx(images, 1 /* which one */, pDC->m_hDC,rcItem.left,rcItem.top, 16, 16, m_clrBkgnd, clrImage, uiFlags | nOvlImageMask); } } /* for(int nColumn = 1; listCtrl.GetColumn(nColumn, &lvc); nColumn++) { rcItem.left = rcItem.right; rcItem.right += lvc.cx; int nRetLen = listCtrl.GetItemText(nItem, nColumn, szBuff, sizeof(szBuff)); if (nRetLen == 0) continue; // pszText = MakeShortString(pDC, szBuff, // rcItem.right - rcItem.left, 2*OFFSET_OTHER); pszText = szBuff; UINT nJustify = DT_LEFT; if(pszText == szBuff) { switch(lvc.fmt & LVCFMT_JUSTIFYMASK) { case LVCFMT_RIGHT: nJustify = DT_RIGHT; break; case LVCFMT_CENTER: nJustify = DT_CENTER; break; default: break; } } rcLabel = rcItem; rcLabel.left += OFFSET_OTHER; rcLabel.right -= OFFSET_OTHER; pDC->DrawText(pszText, -1, rcLabel, nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER); }*/ // draw focus rectangle if item has focus if (lvi.state & LVIS_FOCUSED && bFocus) pDC->DrawFocusRect(rcAllLabels); // set original colors if item was selected if (bSelected) { pDC->SetTextColor(clrTextSave); pDC->SetBkColor(clrBkSave); } }
void CSliderCtrlEx::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) { int loopMax = colorList.GetSize(); // number of color ranges to process LPNMCUSTOMDRAW lpCustDraw = (LPNMCUSTOMDRAW)pNMHDR; //////////////////////////////////////////////////////////////////////////////// // OnCustomDraw() is called at many different stages during the painting process // of the control. We only care about the PREPAINT state or the ITEMPREPAINT // state and not always then. // // If we want to be notified about subcontrol painting, we have to say so when // we get the initial PREPAINT message. //////////////////////////////////////////////////////////////////////////////// if(lpCustDraw->dwDrawStage == CDDS_PREPAINT) { // should we report slider's position? int curVal = GetPos(); if((m_Callback != NULL) && (curVal != m_oldPosition)) { m_oldPosition = curVal; m_Callback(m_p2Object, m_data1, curVal, m_IsDragging); } // If we don't have any special coloring to do, skip all the silliness... if(loopMax <= 0) { *pResult = CDRF_DODEFAULT; } else { // We want to be informed when each part of the control is being // processed so we can intercept the channel drawing. *pResult = CDRF_NOTIFYITEMDRAW; // send messages for each piece-part } return; } /////////////////////////////////////////////////////////////////////////////// // A slider (track control) is drawn in several steps: // 1. Erase // 2. Tics // 3. Channel // 4. Thumb // // It would be nice to capture when the background has been painted and // before the other sub-pieces have been painted. Then we could just // substitute our own painting routine. But this doesn't seem to be // available. // // So this routine captures the tics by inserting operations before // painting the thumb. // // Look at the help on NMCUSTOMDRAW for complete details, but the pNMHDR // pointer looks at a structure like: // // typedef struct tagNMCUSTOMDRAWINFO { // NMHDR hdr; // DWORD dwDrawStage; // This indicates what stage of the drawing process is involved // HDC hdc; // graphics context of the control (or sub-component) // RECT rc; // DWORD dwItemSpec; // This is the particular piece-part of the slider involved // UINT uItemState; // LPARAM lItemlParam; // } NMCUSTOMDRAW // // The stages include CDDS_PREPAINT, which is just before painting of the entire // control. However, unless the *pResult parameter is set to CDRF_NOTIFYITEMDRAW, // we will get notification for the control as a whole, not for each piece-part. // So the first thing to do is set *pResult. Thereafter, we must intercept // the sub-parts. // // We don't care about painting the background (we will re-paint later on). We // don't care about PREPAINT on the CHANNEL or the TICS since we will overwrite // everything when we get to the THUMB. ///////////////////////////////////////////////////////////////////////////////// if((lpCustDraw->dwDrawStage == CDDS_ITEMPREPAINT) && (lpCustDraw->dwItemSpec != TBCD_THUMB)) { *pResult = CDRF_DODEFAULT; return; } // get channel orientation BOOL IsVertical = (TBS_VERT & GetStyle()) ? TRUE : FALSE; // Get the coordinates of the control's window CRect crect; GetClientRect(crect); // client coordinates (top = left = 0, bottom = height, right = width) // Much of this is "paraphrased" from Nic Wilson's work -- see the header file ////////////////////////////////////////////////////////////////////////////////// // This bit does the tics marks transparently. // Create a memory dc to hold a copy of the oldbitmap data that includes the tics, // because when we add the background in we will lose the tic marks. /////////////////////////////////////////////////////////////////////////////////// CDC *pDC = CDC::FromHandle(lpCustDraw->hdc); CDC SaveCDC; CBitmap SaveCBmp; //set the colours for the monochrome mask bitmap COLORREF crOldBack = pDC->SetBkColor(RGB(0,0,0)); // set to Black COLORREF crOldText = pDC->SetTextColor(RGB(255,255,255)); // set to White int iWidth = crect.Width(); // channel width int iHeight = crect.Height(); // channel height //////////////////////////////////////////////////////////////////////////// // Create an in-memory copy of displayed bitmap, including the tics. // This is a monochrome bitmap since it was created from a memory DC. // If it had been created from pDC (an actual device DC, not a memory // DC) then this would be something with 8, 16, 24, or 32 bits per pixel. // // This will have a black background, with the tic marks in white. // // For reasons I don't yet understand, this saves only the tic marks and // the channel's centerline (both originally in black), and not the other // colors (such as drawn AROUND the channel's centerline). I am not sure // what would have happened if the tic marks were not black... //////////////////////////////////////////////////////////////////////////// SaveCDC.CreateCompatibleDC(pDC); SaveCBmp.CreateCompatibleBitmap(&SaveCDC, iWidth, iHeight); CBitmap* SaveCBmpOld = (CBitmap *)SaveCDC.SelectObject(SaveCBmp); SaveCDC.BitBlt(0, 0, iWidth, iHeight, pDC, crect.left, crect.top, SRCCOPY); if(m_dumpBitmaps) // debugging stuff { SaveBitmap("MonoTicsMask.bmp",SaveCBmp); } // Do as much of this stuff in memory as possible, then blit it to the screen CDC memDC; memDC.CreateCompatibleDC(pDC); CBitmap memBM; memBM.CreateCompatibleBitmap(pDC,iWidth,iHeight); // create from pDC, not memDC CBitmap *oldbm = memDC.SelectObject(&memBM); //////////////////////////////////////////////////////////////////////////////// // copy screen bitmap to memory bitmap for manipulation. If this is the very // first time the control has been updated, the screen bitmap will show only // the tic marks (in black) and the default background color (RGB(214,207,189)). // If the control has been updated before, remnants of the previously drawn // background color ranges will also show up. //////////////////////////////////////////////////////////////////////////////// memDC.BitBlt(0,0,iWidth,iHeight,pDC,0,0,SRCCOPY); if(m_dumpBitmaps) // debugging { SaveBitmap("ScrnStart.bmp",memBM); } ///////////////////////////////////////////////////////////////////////////// // Color parts of the channel if necessary. It SHOULD be necessary since we // don't get notifications unless there are colors to print, but we may have // a race condition and it is best to check. ///////////////////////////////////////////////////////////////////////////// if(loopMax) { ///////////////////////////////////////////////////////////////////////////////// // We need to draw colors over the subrange of the channel that the center of the // thumb traverses, rather than the entire client window. Later on, extend these // colors outwards to the ends of the client window (for nicer appearance). This // allows for more precise correlation with color and thumb position. ///////////////////////////////////////////////////////////////////////////////// CRect chanRect; GetChannelRect(&chanRect); CRect thmbRect; GetThumbRect(&thmbRect); // For unknown reasons, GetChannelRect() returns a rectangle // as though it were a horizonally oriented slider, even if it isn't! if(IsVertical) { CRect n; // could probably just change chanRect directly n.left = chanRect.top; n.right = chanRect.bottom; n.top = chanRect.left; n.bottom = chanRect.right; n.NormalizeRect(); chanRect.CopyRect(&n); } // Offset into client rectangle for beginning of coloring range int Offset = chanRect.left + thmbRect.Width()/2; if(IsVertical) { Offset = chanRect.top + thmbRect.Height()/2; } // Range for center of thumb on the channel int ht = chanRect.Height() - thmbRect.Height(); int wd = chanRect.Width() - thmbRect.Width(); // scaling between control range and bitmap int min,max; GetRange(min,max); // range of values for the slider double scale = (double(max) - double(min))/double(IsVertical ? ht : wd); BOOL gotStartColor = FALSE; BOOL gotEndColor = FALSE; COLORREF startColor = 0, endColor = 0; int loop; // Loop through the array of color ranges for(loop = 0; loop < loopMax; loop++) { clrRange clr; clr = colorList[loop]; // Get the good values. If not set, then entire range is good int lval = clr.lval; int hval = clr.hval; if((lval < min) || (lval > max)) lval = min; if((hval > max) || (hval < min)) hval = max; if(lval == min) { gotStartColor = TRUE; startColor = clr.strColor; } if(hval == max) { gotEndColor = TRUE; endColor = clr.endColor; } int minVal = lval - min; // offset into bitmap for this color minVal = int(double(minVal)/scale); // width (or height for vertical slider) inside bitmap for this color int widthVal = hval - lval; widthVal = int((double(widthVal)/scale) + 1.0); // For drawing a gradient, we need to know the individual RGB values int sR,eR,sG,eG,sB,eB; // start and end R, G, and B values sR = GetRValue(clr.strColor); eR = GetRValue(clr.endColor); sG = GetGValue(clr.strColor); eG = GetGValue(clr.endColor); sB = GetBValue(clr.strColor); eB = GetBValue(clr.endColor); if(GradientFill != NULL) { TRIVERTEX vert[2]; // for specifying range to gradient fill GRADIENT_RECT gRect; // Warning C4244: conversion from 'int' to 'unsigned short', possible loss of data #pragma warning (push) #pragma warning (disable : 4244) vert[0].Red = sR<<8; // expects 16-bit color values! vert[0].Green = sG<<8; vert[0].Blue = sB<<8; vert[0].Alpha = 0; // no fading/transparency vert[1].Red = eR<<8; vert[1].Green = eG<<8; vert[1].Blue = eB<<8; vert[1].Alpha = 0; #pragma warning (pop) gRect.UpperLeft = 0; gRect.LowerRight = 1; BOOL retval; if(IsVertical) // vertically oriented? { vert[0].x = 0; vert[0].y = Offset + minVal; vert[1].x = iWidth; vert[1].y = Offset + minVal + widthVal; retval = GradientFill(memDC,vert,2,&gRect,1,GRADIENT_FILL_RECT_V); } else { vert[0].x = Offset + minVal; vert[0].y = 0; vert[1].x = Offset + minVal + widthVal; vert[1].y = iHeight; retval = GradientFill(memDC,vert,2,&gRect,1,GRADIENT_FILL_RECT_H); } } else { // Homebrew version of GradientFill for rectangles -- works pretty well, sort of. int i; for(i = 0; i < widthVal; i++) // for each pixel column in bitmap color range { int R = sR; int G = sG; int B = sB; if(widthVal) { R += ::MulDiv(eR - sR, i, widthVal); G += ::MulDiv(eG - sG, i, widthVal); B += ::MulDiv(eB - sB, i, widthVal); } if(IsVertical) { // widthVal really refers to height //memDC.FillSolidRect(0,minVal+i,iWidth,widthVal-i,GetNearestColor(memDC,RGB(R,G,B))); memDC.FillSolidRect( 0, // starting X value Offset + minVal + i, // starting Y value iWidth, // full width 1, // one pixel height GetNearestColor(memDC,RGB(R,G,B))); } else { //memDC.FillSolidRect(minVal+i,0,widthVal-i,iHeight,GetNearestColor(memDC,RGB(R,G,B))); memDC.FillSolidRect( Offset + minVal + i, // Starting X value 0, // Starting Y value 1, // 1 pixel wide iHeight, // full height GetNearestColor(memDC,RGB(R,G,B))); } } } } if(m_extendColors) { // If we have put in colors at the slider ends, then extend those same // colors to the rest of the background. We could try to determine the // colors by examining the bitmap, but this is awkward and it is just // as easy to grab them on-the-fly in the coloring loop above. // // If you want to see why this is done, just set m_extendColors to FALSE // and take a look at the control. Ugly. But there might be a legitimate // reason for it so leave the option to suppress. if(IsVertical) { if(gotStartColor) { memDC.FillSolidRect(0, 0, iWidth, Offset, startColor); } if(gotEndColor) { memDC.FillSolidRect(0, iHeight - Offset - 1, iWidth, Offset, endColor); } } else { if(gotStartColor) { memDC.FillSolidRect(0, 0, Offset, iHeight, startColor); } if(gotEndColor) { memDC.FillSolidRect(iWidth - Offset - 1, 0, Offset, iHeight, endColor); } } } } // The screen bitmap should now have only the color ranges filled in, no tic // marks should be visible. if(m_dumpBitmaps) // debugging { SaveBitmap("ScrnColors.bmp",memBM); } ////////////////////////////////////////////////////////////// // More "paraphrasing" from Nic Wilson's work... ////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // At this point, memDC's bitmap contains just the color ranges drawn above. // No tic marks are visible. Doing SRCINVERT with the mask will draw in the // tic marks, but all the colors will be backwards. Also, the tics will be // whatever color was drawn in the color range stuff, rather than solid, // normal tic marks. SRCINVERT means the RGB values are changed by subtracting // from 255: // // RGB(255,0,0) --> RGB(0,255,255) // RGB(247,8,0) --> RGB(8,247,255) // RGB(214,40,255) --> RGB(41,215,0) // ///////////////////////////////////////////////////////////////////////////// memDC.SetBkColor(pDC->GetBkColor()); memDC.SetTextColor(pDC->GetTextColor()); memDC.BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCINVERT); if(m_dumpBitmaps) // debugging { SaveBitmap("ScrnInvert.bmp",memBM); } // Change the tic marks from the color range to the background color. This // changes only the tic marks (and the channel centerline) and leaves the // rest alone. The tic marks wind up black. memDC.BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCAND); if(m_dumpBitmaps) // debugging { SaveBitmap("ScrnAnd.bmp",memBM); } // Finally, invert the color ranges to their normal values. Since the tic // marks in the SaveCDC bitmap are white, they get inverted to black. memDC.BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCINVERT); if(m_dumpBitmaps) // debugging { SaveBitmap("ScrnFinal.bmp",memBM); } // Now copy out to screen pDC->BitBlt(0,0,iWidth,iHeight,&memDC,0,0,SRCCOPY); // restore and clean up pDC->SetBkColor(crOldBack); pDC->SetTextColor(crOldText); DeleteObject(SelectObject(SaveCDC, SaveCBmpOld)); DeleteDC(SaveCDC); DeleteObject(SelectObject(memDC,oldbm)); DeleteDC(memDC); *pResult = CDRF_DODEFAULT; m_dumpBitmaps = FALSE; // only do this once! }
void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); CRect rcItem(lpDrawItemStruct->rcItem); UINT uiFlags = ILD_TRANSPARENT; CImageList* pImageList; int nItem = lpDrawItemStruct->itemID; BOOL bFocus = (GetFocus() == this); COLORREF clrTextSave, clrBkSave; COLORREF clrImage = m_clrBkgnd; static _TCHAR szBuff[MAX_PATH]; LPCTSTR pszText; // get item data LV_ITEM lvi; lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE; lvi.iItem = nItem; lvi.iSubItem = 0; lvi.pszText = szBuff; lvi.cchTextMax = sizeof(szBuff); lvi.stateMask = 0xFFFF; // get all state flags GetItem(&lvi); BOOL bSelected = (bFocus || (GetStyle() & LVS_SHOWSELALWAYS)) && lvi.state & LVIS_SELECTED; bSelected = bSelected || (lvi.state & LVIS_DROPHILITED); // set colors if item is selected CRect rcAllLabels; GetItemRect(nItem, rcAllLabels, LVIR_BOUNDS); CRect rcLabel; GetItemRect(nItem, rcLabel, LVIR_LABEL); rcAllLabels.left = rcLabel.left; if (m_bClientWidthSel && rcAllLabels.right<m_cxClient) rcAllLabels.right = m_cxClient; // @@ clrTextSave = pDC->SetTextColor(colTextColor[0]); if (bSelected) { //@@ //clrTextSave = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); clrBkSave = pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT)); pDC->FillRect(rcAllLabels, &CBrush(::GetSysColor(COLOR_HIGHLIGHT))); } else pDC->FillRect(rcAllLabels, &CBrush(m_clrTextBk)); // set color and mask for the icon if (lvi.state & LVIS_CUT) { clrImage = m_clrBkgnd; uiFlags |= ILD_BLEND50; } else if (bSelected) { clrImage = ::GetSysColor(COLOR_HIGHLIGHT); uiFlags |= ILD_BLEND50; } // draw state icon UINT nStateImageMask = lvi.state & LVIS_STATEIMAGEMASK; if (nStateImageMask) { int nImage = (nStateImageMask>>12) - 1; pImageList = GetImageList(LVSIL_STATE); if (pImageList) { pImageList->Draw(pDC, nImage, CPoint(rcItem.left, rcItem.top), ILD_TRANSPARENT); } } // draw normal and overlay icon CRect rcIcon; GetItemRect(nItem, rcIcon, LVIR_ICON); pImageList = GetImageList(LVSIL_SMALL); if (pImageList) { UINT nOvlImageMask=lvi.state & LVIS_OVERLAYMASK; if (rcItem.left<rcItem.right-1) { ImageList_DrawEx(pImageList->m_hImageList, lvi.iImage, pDC->m_hDC,rcIcon.left,rcIcon.top, 16, 16, m_clrBkgnd, clrImage, uiFlags | nOvlImageMask); } } // draw item label GetItemRect(nItem, rcItem, LVIR_LABEL); rcItem.right -= m_cxStateImageOffset; pszText = MakeShortString(pDC, szBuff, rcItem.right-rcItem.left, 2*OFFSET_FIRST); rcLabel = rcItem; rcLabel.left += OFFSET_FIRST; rcLabel.right -= OFFSET_FIRST; pDC->DrawText(pszText,-1,rcLabel,DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER); // draw labels for extra columns LV_COLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH; for(int nColumn = 1; GetColumn(nColumn, &lvc); nColumn++) { rcItem.left = rcItem.right; rcItem.right += lvc.cx; int nRetLen = GetItemText(nItem, nColumn, szBuff, sizeof(szBuff)); if (nRetLen == 0) continue; pszText = MakeShortString(pDC, szBuff, rcItem.right - rcItem.left, 2*OFFSET_OTHER); UINT nJustify = DT_LEFT; if(pszText == szBuff) { switch(lvc.fmt & LVCFMT_JUSTIFYMASK) { case LVCFMT_RIGHT: nJustify = DT_RIGHT; break; case LVCFMT_CENTER: nJustify = DT_CENTER; break; default: break; } } rcLabel = rcItem; rcLabel.left += OFFSET_OTHER; rcLabel.right -= OFFSET_OTHER; if (nColumn < NR_COL_COLORS) pDC->SetTextColor(colTextColor[nColumn]); pDC->DrawText(pszText, -1, rcLabel, nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER); } // draw focus rectangle if item has focus if (lvi.state & LVIS_FOCUSED && bFocus) pDC->DrawFocusRect(rcAllLabels); // set original colors if item was selected if (bSelected) { pDC->SetTextColor(clrTextSave); pDC->SetBkColor(clrBkSave); } }
BOOL CXTPSkinObjectFrame::HasCaption() const { return (GetStyle() & WS_CAPTION) == WS_CAPTION; }
wxObject *wxRadioBoxXmlHandler::DoCreateResource() { if ( m_class == wxT("wxRadioBox")) { // find the selection long selection = GetLong( wxT("selection"), -1 ); // need to build the list of strings from children m_insideBox = true; CreateChildrenPrivately( NULL, GetParamNode(wxT("content"))); XRC_MAKE_INSTANCE(control, wxRadioBox) control->Create(m_parentAsWindow, GetID(), GetText(wxT("label")), GetPosition(), GetSize(), m_labels, GetLong(wxT("dimension"), 1), GetStyle(), wxDefaultValidator, GetName()); if (selection != -1) control->SetSelection(selection); SetupWindow(control); const unsigned count = m_labels.size(); for( unsigned i = 0; i < count; i++ ) { #if wxUSE_TOOLTIPS if ( !m_tooltips[i].empty() ) control->SetItemToolTip(i, m_tooltips[i]); #endif // wxUSE_TOOLTIPS #if wxUSE_HELP if ( m_helptextSpecified[i] ) control->SetItemHelpText(i, m_helptexts[i]); #endif // wxUSE_HELP if ( !m_isShown[i] ) control->Show(i, false); if ( !m_isEnabled[i] ) control->Enable(i, false); } // forget information about the items of this radiobox, we should start // afresh for the next one m_labels.clear(); #if wxUSE_TOOLTIPS m_tooltips.clear(); #endif // wxUSE_TOOLTIPS #if wxUSE_HELP m_helptexts.clear(); m_helptextSpecified.clear(); #endif // wxUSE_HELP m_isShown.clear(); m_isEnabled.clear(); return control; } else // inside the radiobox element { // we handle handle <item>Label</item> constructs here, and the item // tag can have tooltip, helptext, enabled and hidden attributes wxString label = GetNodeContent(m_node); wxString tooltip; m_node->GetAttribute(wxT("tooltip"), &tooltip); wxString helptext; bool hasHelptext = m_node->GetAttribute(wxT("helptext"), &helptext); if (m_resource->GetFlags() & wxXRC_USE_LOCALE) { label = wxGetTranslation(label, m_resource->GetDomain()); if ( !tooltip.empty() ) tooltip = wxGetTranslation(tooltip, m_resource->GetDomain()); if ( hasHelptext ) helptext = wxGetTranslation(helptext, m_resource->GetDomain()); } m_labels.push_back(label); #if wxUSE_TOOLTIPS m_tooltips.push_back(tooltip); #endif // wxUSE_TOOLTIPS #if wxUSE_HELP m_helptexts.push_back(helptext); m_helptextSpecified.push_back(hasHelptext); #endif // wxUSE_HELP m_isEnabled.push_back(GetBoolAttr("enabled", 1)); m_isShown.push_back(!GetBoolAttr("hidden", 0)); return NULL; } }
void CPartialGroupBox::OnPaint(HDC /*hDC*/) { CPaintDC dc(m_hWnd); //paint groupbox manually CRect controlrect; GetClientRect(controlrect); //::MapWindowPoints(HWND_DESKTOP, GetParent(), (LPPOINT)(LPRECT)controlrect, (sizeof(RECT)/sizeof(POINT))); CFontHandle font = GetFont(); dc.SelectFont(font); dc.SetMapMode(MM_TEXT); dc.SelectBrush(GetSysColorBrush(COLOR_BTNFACE)); TCHAR grptext[MAX_PATH]; GetWindowText(grptext,MAX_PATH); CRect fontsizerect(0,0,0,0); dc.DrawText(grptext,-1,fontsizerect,DT_SINGLELINE|DT_LEFT|DT_CALCRECT); CRect framerect(controlrect); framerect.top += (fontsizerect.Height())/2; long Style = GetStyle(); if((Style & 0xF000) == BS_FLAT) { dc.Draw3dRect(framerect,RGB(0,0,0),RGB(0,0,0)); framerect.DeflateRect(1,1); dc.Draw3dRect(framerect,RGB(255,255,255),RGB(255,255,255)); } else { Draw3dLine(dc,framerect,GetSysColor(COLOR_3DSHADOW),GetSysColor(COLOR_3DHILIGHT)); framerect.DeflateRect(1,1); Draw3dLine(dc,framerect,GetSysColor(COLOR_3DHILIGHT),GetSysColor(COLOR_3DSHADOW)); } if(_tcslen(grptext)) { CRect fontrect(controlrect); fontrect.bottom = controlrect.top+fontsizerect.Height(); if((Style & 0xF00) == BS_RIGHT) { fontrect.right -= 6; fontrect.left = fontrect.right - fontsizerect.Width(); } else if((Style & 0xF00) == BS_CENTER) { fontrect.left += (controlrect.Width()-fontsizerect.Width())/2; fontrect.right = fontrect.left + fontsizerect.Width(); } else //BS_LEFT or default { fontrect.left += 6; fontrect.right = fontrect.left + fontsizerect.Width(); } fontrect.InflateRect(2,0); dc.FillRect(fontrect,GetSysColor(COLOR_BTNFACE)); fontrect.DeflateRect(2,0); //Draw Caption dc.SetBkMode(OPAQUE); dc.SetBkColor(GetSysColor(COLOR_BTNFACE)); dc.DrawText(grptext,-1,fontrect,DT_SINGLELINE|DT_LEFT); } }
void MailTreeDelegate::paint (QPainter *painter, const QStyleOptionViewItem& stockItem, const QModelIndex& index) const { auto option = stockItem; const auto style = GetStyle (option); painter->save (); style->drawPrimitive (QStyle::PE_PanelItemViewItem, &option, painter, option.widget); if (option.state & QStyle::State_Selected) painter->setPen (option.palette.color (QPalette::HighlightedText)); if (Mode_ == MailListMode::MultiSelect) DrawCheckbox (painter, style, option, index); DrawIcon (painter, option, index); const auto& subject = GetString (index, MailModel::Column::Subject); const auto& subjFontInfo = GetSubjectFont (index, option); const auto subjHeight = subjFontInfo.second.height (); auto y = option.rect.top () + subjHeight; const auto actionsWidth = View_->isPersistentEditorOpen (index) ? GetActionsBarWidth (index, style, option, subjHeight) : 0; const auto actionsHintWidth = DrawMessageActionIcons (painter, option, index, subjHeight); painter->setFont (subjFontInfo.first); painter->drawText (option.rect.left (), y, subjFontInfo.second.elidedText (subject, Qt::ElideRight, option.rect.width () - actionsHintWidth - actionsWidth)); const QFontMetrics fontFM { option.font }; auto stringHeight = [&fontFM] (const QString&) { return fontFM.height (); }; auto from = GetString (index, MailModel::Column::From); if (const auto childrenCount = index.data (MailModel::MailRole::TotalChildrenCount).toInt ()) { from += " ("; if (const auto unread = index.data (MailModel::MailRole::UnreadChildrenCount).toInt ()) from += QString::number (unread) + "/"; from += QString::number (childrenCount) + ")"; } const auto& date = GetString (index, MailModel::Column::Date); y += std::max (stringHeight (from), stringHeight (date)); painter->setFont (option.font); const auto dateWidth = fontFM.boundingRect (date).width (); painter->drawText (option.rect.right () - dateWidth, y, date); painter->drawText (option.rect.left (), y, fontFM.elidedText (from, Qt::ElideRight, option.rect.width () - dateWidth - 5 * Padding)); painter->restore (); }
void CMDIChildWnd::ActivateFrame(int nCmdShow) { BOOL bVisibleThen = (GetStyle() & WS_VISIBLE) != 0; CMDIFrameWnd* pFrameWnd = GetMDIFrame(); ASSERT_VALID(pFrameWnd); // determine default show command if (nCmdShow == -1) { // get maximized state of frame window (previously active child) BOOL bMaximized; pFrameWnd->MDIGetActive(&bMaximized); // convert show command based on current style DWORD dwStyle = GetStyle(); if (bMaximized || (dwStyle & WS_MAXIMIZE)) nCmdShow = SW_SHOWMAXIMIZED; else if (dwStyle & WS_MINIMIZE) nCmdShow = SW_SHOWMINIMIZED; } // finally, show the window CFrameWnd::ActivateFrame(nCmdShow); // update the Window menu to reflect new child window CMDIFrameWnd* pFrame = GetMDIFrame(); ::SendMessage(pFrame->m_hWndMDIClient, WM_MDIREFRESHMENU, 0, 0); // Note: Update the m_bPseudoInactive flag. This is used to handle the // last MDI child getting hidden. Windows provides no way to deactivate // an MDI child window. BOOL bVisibleNow = (GetStyle() & WS_VISIBLE) != 0; if (bVisibleNow == bVisibleThen) return; if (!bVisibleNow) { // get current active window according to Windows MDI HWND hWnd = (HWND)::SendMessage(pFrameWnd->m_hWndMDIClient, WM_MDIGETACTIVE, 0, 0); if (hWnd != m_hWnd) { // not active any more -- window must have been deactivated ASSERT(!m_bPseudoInactive); return; } // check next window ASSERT(hWnd != NULL); pFrameWnd->MDINext(); // see if it has been deactivated now... hWnd = (HWND)::SendMessage(pFrameWnd->m_hWndMDIClient, WM_MDIGETACTIVE, 0, 0); if (hWnd == m_hWnd) { // still active -- fake deactivate it ASSERT(hWnd != NULL); OnMDIActivate(FALSE, NULL, this); m_bPseudoInactive = TRUE; // so MDIGetActive returns NULL } } else if (m_bPseudoInactive) { // if state transitioned from not visible to visible, but // was pseudo deactivated -- send activate notify now OnMDIActivate(TRUE, this, NULL); ASSERT(!m_bPseudoInactive); // should get set in OnMDIActivate! } }
void CTextProgressCtrl::OnPaint() { if (m_nMin >= m_nMax) return; COLORREF crBarColour, crBgColour; crBarColour = (m_crBarClr == CLR_DEFAULT)? ::GetSysColor(COLOR_HIGHLIGHT) : m_crBarClr; crBgColour = (m_crBgClr == CLR_DEFAULT)? ::GetSysColor(COLOR_WINDOW) : m_crBgClr; CRect LeftRect, RightRect, ClientRect; GetClientRect(ClientRect); double Fraction = (double)(m_nPos - m_nMin) / ((double)(m_nMax - m_nMin)); CPaintDC PaintDC(this); // device context for painting CMemDC dc(&PaintDC); //CPaintDC dc(this); // device context for painting (if not double buffering) dc.SelectObject(GetParent()->GetFont()); // pja July 1, 2001 // Draw Bar LeftRect = RightRect = ClientRect; #ifdef PBS_VERTICAL DWORD dwStyle = GetStyle(); if (dwStyle & PBS_VERTICAL) { LeftRect.top = LeftRect.bottom - (int)((LeftRect.bottom - LeftRect.top)*Fraction); RightRect.bottom = LeftRect.top; } else #endif { LeftRect.right = LeftRect.left + (int)((LeftRect.right - LeftRect.left)*Fraction); RightRect.left = LeftRect.right; } dc.FillSolidRect(LeftRect, crBarColour); dc.FillSolidRect(RightRect, crBgColour); // Draw Text if not vertical if (m_bShowText #ifdef PBS_VERTICAL && (dwStyle & PBS_VERTICAL) == 0 #endif ) { CString str; if (m_strText.GetLength()) str = m_strText; else str.Format("%d%%", (int)(Fraction*100.0)); dc.SetBkMode(TRANSPARENT); DWORD dwTextStyle = DT_CENTER | DT_VCENTER | DT_SINGLELINE; // If we are drawing vertical, then create a new verticla font // based on the current font (only works with TrueType fonts) CFont font, *pOldFont = NULL; #ifdef PBS_VERTICAL if (dwStyle & PBS_VERTICAL) { LOGFONT lf; GetFont()->GetLogFont(&lf); lf.lfEscapement = lf.lfOrientation = 900; font.CreateFontIndirect(&lf); pOldFont = (CFont*) dc.SelectObject(&font); dwTextStyle = DT_VCENTER|DT_CENTER|DT_SINGLELINE; } #endif CRgn rgn; rgn.CreateRectRgn(LeftRect.left, LeftRect.top, LeftRect.right, LeftRect.bottom); dc.SelectClipRgn(&rgn); dc.SetTextColor(m_crTextClr == CLR_DEFAULT ? crBgColour : m_crTextClr); dc.DrawText(str, ClientRect, dwTextStyle); rgn.DeleteObject(); rgn.CreateRectRgn(RightRect.left, RightRect.top, RightRect.right, RightRect.bottom); dc.SelectClipRgn(&rgn); dc.SetTextColor(m_crTextClr == CLR_DEFAULT ? crBarColour : m_crTextClr); dc.DrawText(str, ClientRect, dwTextStyle); if (pOldFont) { dc.SelectObject(pOldFont); font.DeleteObject(); } } }
wxObject *wxBitmapComboBoxXmlHandler::DoCreateResource() { if (m_class == wxT("ownerdrawnitem")) { if ( !m_combobox ) { ReportError("ownerdrawnitem only allowed within a wxBitmapComboBox"); return NULL; } m_combobox->Append(GetText(wxT("text")), GetBitmap(wxT("bitmap"))); return m_combobox; } else /*if( m_class == wxT("wxBitmapComboBox"))*/ { // find the selection long selection = GetLong( wxT("selection"), -1 ); XRC_MAKE_INSTANCE(control, wxBitmapComboBox) control->Create(m_parentAsWindow, GetID(), GetText(wxT("value")), GetPosition(), GetSize(), 0, NULL, GetStyle(), wxDefaultValidator, GetName()); m_isInside = true; m_combobox = control; wxXmlNode *children_node = GetParamNode(wxT("object")); wxXmlNode *n = children_node; #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while (n) { if ((n->GetType() == wxXML_ELEMENT_NODE) && (n->GetName() == wxT("object"))) { CreateResFromNode(n, control, NULL); } n = n->GetNext(); } m_isInside = false; m_combobox = NULL; if (selection != -1) control->SetSelection(selection); SetupWindow(control); return control; } }
wxObject *ctlCheckTreeViewXmlHandler::DoCreateResource() { ctlCheckTreeView *ctl=new ctlCheckTreeView(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle()); SetupWindow(ctl); return ctl; }
CXTPChartColor CXTPChartAreaSeriesView::GetActualColor2() const { CXTPChartColor clr = GetColor2(); return CXTPChartColor((BYTE)((CXTPChartAreaSeriesStyle*)GetStyle())->GetTransparency(), clr.GetR(), clr.GetG(), clr.GetB()); }
void CSkinDialog::OnNcPaint() { // TODO: Add your message handler code here if(!CImgSkin::IsLoaded()) { CXTPDialog::OnNcPaint(); return; } if(HasStyle(WS_CHILD)) { return; } /* RECT ClientRect; GetClientRect(&ClientRect); OffsetRect(&ClientRect, 100, 100); ExcludeClipRect(GetWindowDC()->GetSafeHdc(), ClientRect.left, ClientRect.top, ClientRect.right, ClientRect.bottom); */ CRect rcWindow; GetWindowRect(&rcWindow); Bitmap bmpBuf(rcWindow.Width(), rcWindow.Height()); Graphics graphics(&bmpBuf); Graphics g(GetWindowDC()->GetSafeHdc()); Rect rc, rc1; // Title Left rc = m_bActive?m_mapRect["TitleLeftActive"]:m_mapRect["TitleLeft"]; rc1.X = 0; rc1.Y = 0; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Title Center rc = m_bActive?m_mapRect["TitleCenterActive"]:m_mapRect["TitleCenter"]; rc1.X = m_mapRect["TitleLeftActive"].Width; rc1.Y = 0; rc1.Width = rcWindow.Width()-m_mapRect["TitleLeftActive"].Width-m_mapRect["TitleRightActive"].Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Title Right rc = m_bActive?m_mapRect["TitleRightActive"]:m_mapRect["TitleRight"]; rc1.X = rc1.GetRight(); rc1.Y = 0; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Border Left rc = m_bActive?m_mapRect["BorderLeftActive"]:m_mapRect["BorderLeft"]; rc1.X = 0; rc1.Y = m_mapRect["TitleLeftActive"].Height; rc1.Width = rc.Width; rc1.Height = rcWindow.Height()-m_mapRect["TitleLeftActive"].Height-m_mapRect["BorderBotActive"].Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Border Bottom rc = m_bActive?m_mapRect["BorderBotActive"]:m_mapRect["BorderBot"]; rc1.X = 0; rc1.Y = rcWindow.Height()-rc.Height-1; rc1.Width = rcWindow.Width(); rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Border Right rc = m_bActive?m_mapRect["BorderRightActive"]:m_mapRect["BorderRight"]; rc1.X = rcWindow.Width()-rc.Width-1; rc1.Y = m_mapRect["TitleLeftActive"].Height; rc1.Width = rc.Width; rc1.Height = rcWindow.Height()-m_mapRect["TitleLeftActive"].Height-m_mapRect["BorderBotActive"].Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Close Button rc = m_nButtonDown==HT_CLOSE?m_mapRect["NcBtnCloseDown"]:m_mapRect["NcBtnClose"]; rc1.X = rcWindow.Width()-m_mapRect["NcBtnClosePos"].X; rc1.Y = m_mapRect["NcBtnClosePos"].Y; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Max Button if(GetStyle()&WS_MAXIMIZEBOX) { rc = IsZoomed()?(m_nButtonDown==HT_MAX?m_mapRect["NcBtnResDown"]:m_mapRect["NcBtnRes"]):(m_nButtonDown==HT_MAX?m_mapRect["NcBtnMaxDown"]:m_mapRect["NcBtnMax"]); rc1.X = rcWindow.Width()-m_mapRect["NcBtnMaxPos"].X; rc1.Y = m_mapRect["NcBtnMaxPos"].Y; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); } // Min Button if(GetStyle()&WS_MINIMIZEBOX) { rc = m_nButtonDown==HT_MIN?m_mapRect["NcBtnMinDown"]:m_mapRect["NcBtnMin"]; rc1.X = rcWindow.Width()-m_mapRect["NcBtnMinPos"].X; rc1.Y = m_mapRect["NcBtnMinPos"].Y; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); } Font myFont(L"宋体", 9); Color col(255,0,0,0); col.SetFromCOLORREF(m_mapColor["Caption"]); SolidBrush blackBrush(col); StringFormat format; format.SetAlignment(StringAlignmentNear); RectF layoutRect(::GetSystemMetrics(SM_CYICON)+m_mapRect["TitleTextStart"].X, m_mapRect["TitleTextStart"].Y, rcWindow.Width(), rcWindow.Height()); WCHAR string[MAX_PATH] = {0}; CString str; GetWindowText(str); MultiByteToWideChar( CP_ACP, 0, str, -1, string, MAX_PATH) ; graphics.DrawString(string, -1, &myFont, layoutRect, &format, &blackBrush); g.DrawImage(&bmpBuf, 0, 0); // Do not call CXTPDialog::OnNcPaint() for painting messages }
wxObject *wxTreebookXmlHandler::DoCreateResource() { if (m_class == wxT("wxTreebook")) { XRC_MAKE_INSTANCE(tbk, wxTreebook) tbk->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style")), GetName()); wxImageList *imagelist = GetImageList(); if ( imagelist ) tbk->AssignImageList(imagelist); wxTreebook * old_par = m_tbk; m_tbk = tbk; bool old_ins = m_isInside; m_isInside = true; wxArrayTbkPageIndexes old_treeContext = m_treeContext; m_treeContext.Clear(); CreateChildren(m_tbk, true/*only this handler*/); m_treeContext = old_treeContext; m_isInside = old_ins; m_tbk = old_par; return tbk; } // else ( m_class == wxT("treebookpage") ) wxXmlNode *n = GetParamNode(wxT("object")); wxWindow *wnd = NULL; if ( !n ) n = GetParamNode(wxT("object_ref")); if (n) { bool old_ins = m_isInside; m_isInside = false; wxObject *item = CreateResFromNode(n, m_tbk, NULL); m_isInside = old_ins; wnd = wxDynamicCast(item, wxWindow); if (wnd == NULL && item != NULL) { ReportError(n, "treebookpage child must be a window"); } } size_t depth = GetLong( wxT("depth") ); if( depth <= m_treeContext.GetCount() ) { // first prepare the icon int imgIndex = wxNOT_FOUND; if ( HasParam(wxT("bitmap")) ) { wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); wxImageList *imgList = m_tbk->GetImageList(); if ( imgList == NULL ) { imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() ); m_tbk->AssignImageList( imgList ); } imgIndex = imgList->Add(bmp); } else if ( HasParam(wxT("image")) ) { if ( m_tbk->GetImageList() ) { imgIndex = GetLong(wxT("image")); } else // image without image list? { ReportError(n, "image can only be used in conjunction " "with imagelist"); } } // then add the page to the corresponding parent if( depth < m_treeContext.GetCount() ) m_treeContext.RemoveAt(depth, m_treeContext.GetCount() - depth ); if( depth == 0) { m_tbk->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")), imgIndex); } else { m_tbk->InsertSubPage(m_treeContext.Item(depth - 1), wnd, GetText(wxT("label")), GetBool(wxT("selected")), imgIndex); } m_treeContext.Add( m_tbk->GetPageCount() - 1); } else { ReportParamError("depth", "invalid depth"); } return wnd; }
bool CSkinDialog::LoadSkin(const char * szSkinPath /* = NULL */, const char * szControlName) { if(szSkinPath==NULL) { CImgSkin::Unload(); return true; } if(!CImgSkin::Load(szSkinPath, szControlName)) return false; m_dwStyle = GetStyle(); // 去掉标题栏,边框,只留客户区 // ModifyStyle(WS_CAPTION|WS_THICKFRAME, 0); ModifyStyle(WS_CAPTION, 0); CRect rcWindow; CRect rcClient; CRect rc; GetWindowRect(&rcWindow); GetClientRect(&m_rcClient); // 圆角 SetWindowRgn(CreateRoundRectRgn(0, 0, rcWindow.Width(), rcWindow.Height(), m_mapRect["RoundCorner"].Width, m_mapRect["RoundCorner"].Height), TRUE); if(!HasStyle(WS_CHILD)) { // 调整窗口自己 rcWindow.left -= m_mapRect["BorderLeft"].Width; rcWindow.right += m_mapRect["BorderRight"].Width; rcWindow.top -= m_mapRect["TitleLeft"].Height; rcWindow.bottom += m_mapRect["BorderBot"].Height; CWnd * pParent = GetParent(); if(pParent==NULL) pParent = GetDesktopWindow(); //pParent->ScreenToClient(&rcWindow); //MoveWindow(rcWindow, FALSE); GetClientRect(&rcClient); POINT ptOffset = {0}; CRect rcChild; CWnd* pWndChild; // 菜单 CMenu * pMenu = GetMenu(); if(pMenu) { m_wndMenuBar.CreateToolBar(WS_VISIBLE|WS_CHILD|CBRS_TOOLTIPS, this, ID_MENU_BAR); m_wndMenuBar.LoadMenu(pMenu); m_wndMenuBar.SetFlags(xtpFlagStretched); SetMenu(NULL); CXTPPaintManager::SetTheme(xtpThemeOffice2003); m_wndMenuBar.LoadSkin(szSkinPath); RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposDefault, NULL, &rcClient); AddAnchor(m_wndMenuBar, ANCHOR_TOPLEFT|ANCHOR_TOPRIGHT); m_wndMenuBar.GetWindowRect(&rc); ptOffset.y += rc.Height(); pWndChild = GetWindow(GW_CHILD); while (pWndChild) { if(pWndChild!=&m_wndMenuBar) { pWndChild->GetWindowRect(rcChild); rcChild.OffsetRect(ptOffset); ScreenToClient(&rcChild); pWndChild->MoveWindow(rcChild, FALSE); } pWndChild = pWndChild->GetNextWindow(); } } // 调整子窗口 /* ptOffset.x = m_mapRect["BorderLeft"].Width; ptOffset.y = m_mapRect["TitleLeft"].Height; pWndChild = GetWindow(GW_CHILD); while (pWndChild) { pWndChild->GetWindowRect(rcChild); rcChild.OffsetRect(ptOffset); ScreenToClient(&rcChild); pWndChild->MoveWindow(rcChild, FALSE); pWndChild = pWndChild->GetNextWindow(); } m_rcClient.left = ptOffset.x; m_rcClient.right = m_rcClient.left+rcClient.Width(); m_rcClient.top += ptOffset.y; m_rcClient.bottom = m_rcClient.top+rcClient.Height(); */ } return true; }
GlowWidget::AutoPackError GlowQuickPanelWidget::OnAutoPack( int hSize, int vSize, AutoPackOptions hOption, AutoPackOptions vOption, int& leftMargin, int& rightMargin, int& topMargin, int& bottomMargin) { GLOW_DEBUGSCOPE("GlowQuickPanelWidget::OnAutoPack"); int position = (arrangement_ == vertical) ? vmargin_ : hmargin_; int size = 0; int minWidth = position; // Arrange widgets with default alignment for (GlowComponent* child = FirstChild(); child != 0; child = child->Next()) { // Get next widget GlowWidget* widget = dynamic_cast<GlowWidget*>(child); if (widget == 0 || !widget->IsVisible() || widget->IsClosing()) { continue; } // Handle the label of the panel (if any) differently. if (widget == label_) { if (GetStyle() == GlowPanelWidget::etchedStyle) { // Etched style: label is half in and half out of the panel widget->AutoPack(hmargin_, unspecifiedPos, 0, unspecifiedPos, leftPos | preferredSize, centerPos | preferredSize); topMargin = widget->Height()/2; if (arrangement_ == vertical) { position += widget->Height()/2; } } else { // Other style: label is completely out of the panel widget->AutoPack(hmargin_, unspecifiedPos, unspecifiedPos, 0, leftPos | preferredSize, bottomPos | preferredSize); topMargin = widget->Height(); } minWidth = widget->Width()+hmargin_+hmargin_; continue; } int leftMargin = 0, rightMargin = 0, topMargin = 0, bottomMargin = 0; if (arrangement_ == horizontal) { widget->AutoPack(position, unspecifiedPos, vmargin_, unspecifiedPos, leftPos | preferredSize, topPos | preferredSize, leftMargin, rightMargin, topMargin, bottomMargin); size = GLOW_STD::max(size, widget->Height()+topMargin+bottomMargin); position += widget->Width()+leftMargin+rightMargin+spacing_; } else { widget->AutoPack(hmargin_, unspecifiedPos, position, unspecifiedPos, leftPos | preferredSize, topPos | preferredSize, leftMargin, rightMargin, topMargin, bottomMargin); size = GLOW_STD::max(size, widget->Width()+leftMargin+rightMargin); position += widget->Height()+topMargin+bottomMargin+spacing_; } } // Preferred width and height int pwidth = 0, pheight = 0; if (arrangement_ == horizontal) { pwidth = GLOW_STD::max(minWidth, position-spacing_+hmargin_); pheight = size+vmargin_+vmargin_; } else { pwidth = GLOW_STD::max(minWidth, size+hmargin_+hmargin_); pheight = position-spacing_+vmargin_; } // Panel width int hnew = Width(); if (hOption == forcedSize || hOption == expandPreferredSize) { hnew = hSize; } else if (hOption == preferredSize) { hnew = pwidth; } if (hnew < pwidth) { return hAutoPackError; } // Panel height int vnew = Height(); if (vOption == forcedSize || vOption == expandPreferredSize) { vnew = vSize-topMargin; // because of label } else if (vOption == preferredSize) { vnew = pheight; } if (vnew < pheight) { return vAutoPackError; } // Update size if (arrangement_ == horizontal) { size = vnew-vmargin_-vmargin_; } else { size = hnew-hmargin_-hmargin_; } // Now align contents int i=0; for (GlowComponent* child = FirstChild(); child != 0; child = child->Next(), ++i) { GlowWidget* widget = dynamic_cast<GlowWidget*>(child); if (widget == 0 || widget == label_ || !widget->IsVisible()) { continue; } if (arrangement_ == horizontal) { // Horizontal arrangement AutoPackOptions vOption = (alignment_ & alignExpand) ? expandPreferredSize : preferredSize; if ((alignment_ & 3) == alignBottom) { vOption |= bottomPos; } else if ((alignment_ & 3) == alignCenter) { vOption |= centerPos; } else { vOption |= topPos; } widget->AutoPack(unspecifiedPos, unspecifiedPos, vmargin_, vmargin_+size, noMove | noReshape, vOption); } else { // Vertical arrangement AutoPackOptions hOption = (alignment_ & alignExpand) ? expandPreferredSize : preferredSize; if ((alignment_ & 3) == alignLeft) { hOption |= leftPos; } else if ((alignment_ & 3) == alignCenter) { hOption |= centerPos; } else { hOption |= rightPos; } widget->AutoPack(hmargin_, hmargin_+size, unspecifiedPos, unspecifiedPos, hOption, noMove | noReshape); } } Reshape(hnew, vnew); return noAutoPackError; }
void CSkinDialog::DrawFrame(Graphics & graphics) { CRect rcWindow; GetWindowRect(&rcWindow); Rect rc, rc1; // Title Left rc = m_bActive?m_mapRect["TitleLeftActive"]:m_mapRect["TitleLeft"]; rc1.X = 0; rc1.Y = 0; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Title Center rc = m_bActive?m_mapRect["TitleCenterActive"]:m_mapRect["TitleCenter"]; rc1.X = m_mapRect["TitleLeftActive"].Width; rc1.Y = 0; rc1.Width = rcWindow.Width()-m_mapRect["TitleLeftActive"].Width-m_mapRect["TitleRightActive"].Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Title Right rc = m_bActive?m_mapRect["TitleRightActive"]:m_mapRect["TitleRight"]; rc1.X = rc1.GetRight(); rc1.Y = 0; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Border Left rc = m_bActive?m_mapRect["BorderLeftActive"]:m_mapRect["BorderLeft"]; rc1.X = 0; rc1.Y = m_mapRect["TitleLeft"].Height; rc1.Width = rc.Width; rc1.Height = rcWindow.Height()-m_mapRect["TitleLeftActive"].Height-m_mapRect["BorderBotActive"].Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Border Bottom rc = m_bActive?m_mapRect["BorderBotActive"]:m_mapRect["BorderBot"]; rc1.X = 0; rc1.Y = rcWindow.Height()-rc.Height-1; rc1.Width = rcWindow.Width(); rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Border Right rc = m_bActive?m_mapRect["BorderRightActive"]:m_mapRect["BorderRight"]; rc1.X = rcWindow.Width()-rc.Width-1; rc1.Y = m_mapRect["TitleLeftActive"].Height; rc1.Width = rc.Width; rc1.Height = rcWindow.Height()-m_mapRect["TitleLeftActive"].Height-m_mapRect["BorderBotActive"].Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Close Button rc = m_nButtonDown==HT_CLOSE?m_mapRect["NcBtnCloseDown"]:m_mapRect["NcBtnClose"]; rc1.X = rcWindow.Width()-m_mapRect["NcBtnClosePos"].X; rc1.Y = m_mapRect["NcBtnClosePos"].Y; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); // Max Button if(GetStyle()&WS_MAXIMIZEBOX) { rc = IsZoomed()?(m_nButtonDown==HT_MAX?m_mapRect["NcBtnResDown"]:m_mapRect["NcBtnRes"]):(m_nButtonDown==HT_MAX?m_mapRect["NcBtnMaxDown"]:m_mapRect["NcBtnMax"]); rc1.X = rcWindow.Width()-m_mapRect["NcBtnMaxPos"].X; rc1.Y = m_mapRect["NcBtnMaxPos"].Y; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); } // Min Button if(GetStyle()&WS_MINIMIZEBOX) { rc = m_nButtonDown==HT_MIN?m_mapRect["NcBtnMinDown"]:m_mapRect["NcBtnMin"]; rc1.X = rcWindow.Width()-m_mapRect["NcBtnMinPos"].X; rc1.Y = m_mapRect["NcBtnMinPos"].Y; rc1.Width = rc.Width; rc1.Height = rc.Height; graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height, UnitPixel); } Font myFont(L"宋体", 9); Color col(255,0,0,0); col.SetFromCOLORREF(m_mapColor["Caption"]); SolidBrush blackBrush(col); StringFormat format; format.SetAlignment(StringAlignmentNear); RectF layoutRect(::GetSystemMetrics(SM_CYICON)+m_mapRect["TitleTextStart"].X, m_mapRect["TitleTextStart"].Y, rcWindow.Width(), rcWindow.Height()); WCHAR string[MAX_PATH] = {0}; CString str; GetWindowText(str); MultiByteToWideChar( CP_ACP, 0, str, -1, string, MAX_PATH) ; graphics.DrawString(string, -1, &myFont, layoutRect, &format, &blackBrush); }
void CClickList::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { static const COLORREF COLOR_1 = RGB(239, 246, 249), COLOR_2 = RGB(209, 226, 239); ASSERT(NULL != lpDrawItemStruct); ASSERT(NULL != lpDrawItemStruct->hDC); CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC); ASSERT_VALID(pDC); // The CWinApp idle-time handler will automatically call // CDC::DeleteTempMap to delete any temporary CDC objects // created by FromHandle CRect rcItem(lpDrawItemStruct->rcItem); int nItem = lpDrawItemStruct->itemID; int nSavedDC = pDC->SaveDC(); // Get item image and state info LV_ITEM lvi; lvi.mask = LVIF_IMAGE | LVIF_STATE; lvi.iItem = nItem; lvi.iSubItem = 0; lvi.stateMask = -1; GetItem(&lvi); // Should the item be highlighted bool bHighlight = LVIS_DROPHILITED == (lvi.state & LVIS_DROPHILITED) || LVIS_SELECTED == (lvi.state & LVIS_SELECTED) && (this == GetFocus() || LVS_SHOWSELALWAYS == (GetStyle() & LVS_SHOWSELALWAYS)); // Get rectangles for drawing CRect rcBounds, rcLabel, rcIcon; GetItemRect(nItem, rcBounds, LVIR_BOUNDS); GetItemRect(nItem, rcLabel, LVIR_LABEL); GetItemRect(nItem, rcIcon, LVIR_ICON); CRect rcCol(rcBounds); CString sLabel = GetItemText(nItem, 0); // Labels are offset by a certain amount // This offset is related to the width of a space character int offset = pDC->GetTextExtent(_T(" "), 1 ).cx * 2; CRect rcHighlight; CRect rcWnd; int nExt; switch (m_HighlightType) { case HT_NORMAL: nExt = pDC->GetOutputTextExtent(sLabel).cx + offset; rcHighlight = rcLabel; if (rcLabel.left + nExt < rcLabel.right) rcHighlight.right = rcLabel.left + nExt; break; case HT_ALLCOLUMNS: rcHighlight = rcBounds; rcHighlight.left = rcLabel.left; break; case HT_ROW: GetClientRect(&rcWnd); rcHighlight = rcBounds; rcHighlight.left = rcLabel.left; rcHighlight.right = rcWnd.right; break; default: ASSERT(false); } // Draw the background color if (bHighlight) { pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); pDC->SetBkColor(::GetSysColor(COLOR_HIGHLIGHT)); pDC->FillRect(rcHighlight, &CBrush(::GetSysColor(COLOR_HIGHLIGHT))); } else { CRect rcClient, rcRow = rcItem; GetClientRect(&rcClient); rcRow.right = rcClient.right; pDC->FillRect(rcRow, &CBrush(nItem % 2 ? COLOR_1 : COLOR_2)); //pDC->FillRect(rcHighlight, &CBrush(::GetSysColor(COLOR_WINDOW))); } // Set clip region rcCol.right = rcCol.left + GetColumnWidth(0); CRgn rgn; rgn.CreateRectRgnIndirect(&rcCol); pDC->SelectClipRgn(&rgn); rgn.DeleteObject(); // Draw state icon CImageList *pImageList; if (LVIS_STATEIMAGEMASK == (lvi.state & LVIS_STATEIMAGEMASK)) { pImageList = GetImageList(LVSIL_STATE); if (NULL != pImageList) { int nImage = ((lvi.state & LVIS_STATEIMAGEMASK) >> 12) - 1; pImageList->Draw(pDC, nImage, CPoint(rcCol.left, rcCol.top), ILD_TRANSPARENT); }
void CXTPChartPyramidSeriesView::CalculatePointLayout(CXTPChartDeviceContext* pDC, CRect rcBounds) { CXTPChartPyramidSeriesStyle* pStyle = STATIC_DOWNCAST(CXTPChartPyramidSeriesStyle, GetStyle()); rcBounds.DeflateRect(5, 5, 5, 5); CXTPChartPyramidSeriesLabel* pLabel = (CXTPChartPyramidSeriesLabel*)pStyle->GetLabel(); if (pLabel->IsVisible() && !pLabel->IsInside()) { CSize sz(0, 0); for (int i = 0; i < m_pPointsView->GetCount(); i++) { CXTPChartPyramidSeriesPointView* pPointView = (CXTPChartPyramidSeriesPointView*)m_pPointsView->GetAt(i); CXTPChartString text(pLabel->GetPointLabel(pPointView->GetPoint())); CXTPChartTextPainter painter(pDC, text, pLabel); sz.cx = max(sz.cx, (INT)painter.GetSize().Width); sz.cy = max(sz.cy, (INT)painter.GetSize().Height); } int nLineLength = pStyle->GetLabel()->GetLineLength(); if (pLabel->GetPosition() == xtpChartPyramidLabelRight) rcBounds.DeflateRect(0, 0, nLineLength + sz.cx, 0); if (pLabel->GetPosition() == xtpChartPyramidLabelLeft) rcBounds.DeflateRect(nLineLength + sz.cx, 0, 0, 0); } double dRatio = pStyle->GetHeightToWidthRatio(); if (dRatio > CXTPChartMathUtils::m_dEPS) { int nHeight = rcBounds.Height(); int nWidth = int(nHeight / dRatio); if (nWidth > rcBounds.Width()) { nWidth = rcBounds.Width(); nHeight = int(nWidth * dRatio); } CPoint ptTopLeft((rcBounds.left + rcBounds.right - nWidth) / 2, (rcBounds.top + rcBounds.bottom - nHeight) / 2); rcBounds = CRect(ptTopLeft, CSize(nWidth, nHeight)); } m_rcInnterBounds = rcBounds; CalculateValues(); int nCount = m_pPointsView->GetCount(); double dFrom = 0; for (int i = 0; i < nCount; i++) { CXTPChartPyramidSeriesPointView* pPointView = (CXTPChartPyramidSeriesPointView*)m_pPointsView->GetAt(i); pPointView->CalculateLayout(i, nCount, dFrom, dFrom + pPointView->m_dValue); dFrom += pPointView->m_dValue; } }
void CUploadListCtrl::SetAllIcons() { ApplyImageList(NULL); m_ImageList.DeleteImageList(); m_ImageList.Create(16, 16, theApp.m_iDfltImageListColorFlags | ILC_MASK, 0, 1); //Xman Show correct Icons /* m_ImageList.Add(CTempIconLoader(_T("ClientEDonkey"))); m_ImageList.Add(CTempIconLoader(_T("ClientCompatible"))); m_ImageList.Add(CTempIconLoader(_T("ClientEDonkeyPlus"))); m_ImageList.Add(CTempIconLoader(_T("ClientCompatiblePlus"))); m_ImageList.Add(CTempIconLoader(_T("Friend"))); m_ImageList.Add(CTempIconLoader(_T("ClientMLDonkey"))); m_ImageList.Add(CTempIconLoader(_T("ClientMLDonkeyPlus"))); m_ImageList.Add(CTempIconLoader(_T("ClientEDonkeyHybrid"))); m_ImageList.Add(CTempIconLoader(_T("ClientEDonkeyHybridPlus"))); m_ImageList.Add(CTempIconLoader(_T("ClientShareaza"))); m_ImageList.Add(CTempIconLoader(_T("ClientShareazaPlus"))); m_ImageList.Add(CTempIconLoader(_T("ClientAMule"))); m_ImageList.Add(CTempIconLoader(_T("ClientAMulePlus"))); m_ImageList.Add(CTempIconLoader(_T("ClientLPhant"))); m_ImageList.Add(CTempIconLoader(_T("ClientLPhantPlus"))); */ m_ImageList.Add(CTempIconLoader(_T("ClientDefault"))); //0 m_ImageList.Add(CTempIconLoader(_T("ClientDefaultPlus"))); //1 m_ImageList.Add(CTempIconLoader(_T("ClientEDonkey"))); //2 m_ImageList.Add(CTempIconLoader(_T("ClientEDonkeyPlus"))); //3 m_ImageList.Add(CTempIconLoader(_T("ClientCompatible"))); //4 m_ImageList.Add(CTempIconLoader(_T("ClientCompatiblePlus"))); //5 m_ImageList.Add(CTempIconLoader(_T("ClientFriend"))); //6 m_ImageList.Add(CTempIconLoader(_T("ClientFriendPlus"))); //7 m_ImageList.Add(CTempIconLoader(_T("ClientMLDonkey"))); //8 m_ImageList.Add(CTempIconLoader(_T("ClientMLDonkeyPlus"))); //9 m_ImageList.Add(CTempIconLoader(_T("ClientEDonkeyHybrid"))); //10 m_ImageList.Add(CTempIconLoader(_T("ClientEDonkeyHybridPlus")));//11 m_ImageList.Add(CTempIconLoader(_T("ClientShareaza"))); //12 m_ImageList.Add(CTempIconLoader(_T("ClientShareazaPlus"))); //13 m_ImageList.Add(CTempIconLoader(_T("ClientAMule"))); //14 m_ImageList.Add(CTempIconLoader(_T("ClientAMulePlus"))); //15 m_ImageList.Add(CTempIconLoader(_T("ClientLPhant"))); //16 m_ImageList.Add(CTempIconLoader(_T("ClientLPhantPlus"))); //17 m_ImageList.Add(CTempIconLoader(_T("LEECHER"))); //18 //Xman Anti-Leecher //Xman friend visualization m_ImageList.Add(CTempIconLoader(_T("ClientFriendSlotOvl"))); //19 //Xman end //Xman End // ==> Mod Icons - Stulle m_ImageList.Add(CTempIconLoader(_T("AAAEMULEAPP"))); //20 m_ImageList.Add(CTempIconLoader(_T("STULLE"))); //21 m_ImageList.Add(CTempIconLoader(_T("XTREME"))); //22 m_ImageList.Add(CTempIconLoader(_T("MORPH"))); //23 m_ImageList.Add(CTempIconLoader(_T("EASTSHARE"))); //24 m_ImageList.Add(CTempIconLoader(_T("EMF"))); //25 m_ImageList.Add(CTempIconLoader(_T("NEO"))); //26 m_ImageList.Add(CTempIconLoader(_T("MEPHISTO"))); //27 m_ImageList.Add(CTempIconLoader(_T("XRAY"))); //28 m_ImageList.Add(CTempIconLoader(_T("MAGIC"))); //29 // <== Mod Icons - Stulle m_ImageList.SetOverlayImage(m_ImageList.Add(CTempIconLoader(_T("ClientSecureOvl"))), 1); m_ImageList.SetOverlayImage(m_ImageList.Add(CTempIconLoader(_T("OverlayObfu"))), 2); m_ImageList.SetOverlayImage(m_ImageList.Add(CTempIconLoader(_T("OverlaySecureObfu"))), 3); // ==> Mod Icons - Stulle m_overlayimages.DeleteImageList (); m_overlayimages.Create(16,16,theApp.m_iDfltImageListColorFlags|ILC_MASK,0,1); m_overlayimages.SetBkColor(CLR_NONE); m_overlayimages.Add(CTempIconLoader(_T("ClientCreditOvl"))); m_overlayimages.Add(CTempIconLoader(_T("ClientCreditSecureOvl"))); // <== Mod Icons - Stulle // Apply the image list also to the listview control, even if we use our own 'DrawItem'. // This is needed to give the listview control a chance to initialize the row height. ASSERT( (GetStyle() & LVS_SHAREIMAGELISTS) != 0 ); VERIFY( ApplyImageList(m_ImageList) == NULL ); }
wxObject *wxPropertySheetDialogXmlHandler::DoCreateResource() { if (m_class == wxT("propertysheetpage")) { wxXmlNode *n = GetParamNode(wxT("object")); if (!n) n = GetParamNode(wxT("object_ref")); if (n) { wxBookCtrlBase *bookctrl = m_dialog->GetBookCtrl(); bool old_ins = m_isInside; m_isInside = false; wxObject *item = CreateResFromNode(n, bookctrl, NULL); m_isInside = old_ins; wxWindow *wnd = wxDynamicCast(item, wxWindow); if (wnd) { bookctrl->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected"))); if (HasParam(wxT("bitmap"))) { wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); wxImageList *imgList = bookctrl->GetImageList(); if (imgList == NULL) { imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight()); bookctrl->AssignImageList(imgList); } int imgIndex = imgList->Add(bmp); bookctrl->SetPageImage(bookctrl->GetPageCount()-1, imgIndex); } } else { ReportError(n, "propertysheetpage child must be a window"); } return wnd; } else { ReportError("propertysheetpage must have a window child"); return NULL; } } else { XRC_MAKE_INSTANCE(dlg, wxPropertySheetDialog) dlg->Create(m_parentAsWindow, GetID(), GetText(wxT("title")), GetPosition(), GetSize(), GetStyle(), GetName()); if (HasParam(wxT("icon"))) dlg->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON)); SetupWindow(dlg); wxPropertySheetDialog *old_par = m_dialog; m_dialog = dlg; bool old_ins = m_isInside; m_isInside = true; CreateChildren(m_dialog, true/*only this handler*/); m_isInside = old_ins; m_dialog = old_par; if (GetBool(wxT("centered"), false)) dlg->Centre(); wxString buttons = GetText(wxT("buttons")); if (!buttons.IsEmpty()) { int flags = 0; if (buttons.Find(wxT("wxOK")) != wxNOT_FOUND) flags |= wxOK; if (buttons.Find(wxT("wxCANCEL")) != wxNOT_FOUND) flags |= wxCANCEL; if (buttons.Find(wxT("wxYES")) != wxNOT_FOUND) flags |= wxYES; if (buttons.Find(wxT("wxNO")) != wxNOT_FOUND) flags |= wxNO; if (buttons.Find(wxT("wxHELP")) != wxNOT_FOUND) flags |= wxHELP; if (buttons.Find(wxT("wxNO_DEFAULT")) != wxNOT_FOUND) flags |= wxNO_DEFAULT; dlg->CreateButtons(flags); } return dlg; } }