void FolderView::OnPaint(void) { CPaintDC sDC(this); // device context for painting CRect sClientRect; GetClientRect(&sClientRect); CMemDC sMemDC(&sDC); sMemDC.FillSolidRect(&sClientRect, ::GetSysColor(COLOR_WINDOW)); }
void DIALOG_DESIGN_RULES::FillListBoxWithNetNames( NETS_LIST_CTRL* aListCtrl, const wxString& aNetClass ) { aListCtrl->ClearList(); PNETCUPS ptrList; // get a subset of m_AllNets in pointer form, sorted as desired. makePointers( &ptrList, aNetClass ); #if 0 && defined(DEBUG) int r = 0; for( PNETCUPS::iterator i = ptrList.begin(); i!=ptrList.end(); ++i, ++r ) { printf( "[%d]: %s %s\n", r, TO_UTF8( (*i)->net ), TO_UTF8( (*i)->clazz ) ); } #endif // Add netclass info to m_Netnames and m_Classnames wxArrayString buffers // aListCtrl uses wxLC_VIRTUAL option, so this is fast wxClientDC sDC( aListCtrl ); int row = 0; // recompute the column widths here, after setting texts int net_colsize = sDC.GetTextExtent( NET_TITLE ).x; int class_colsize = sDC.GetTextExtent( CLASS_TITLE ).x; for( PNETCUPS::iterator i = ptrList.begin(); i!=ptrList.end(); ++i, ++row ) { wxSize net_needed = sDC.GetTextExtent( (*i)->net ); wxSize class_needed = sDC.GetTextExtent( (*i)->clazz ); net_colsize = std::max( net_colsize, net_needed.x ); class_colsize = std::max( class_colsize, class_needed.x ); aListCtrl->SetRowItems( row, (*i)->net, (*i)->clazz ); } int margin = sDC.GetTextExtent( wxT( "XX" ) ).x; aListCtrl->SetColumnWidth( 0, net_colsize + margin ); aListCtrl->SetColumnWidth( 1, class_colsize + margin ); aListCtrl->Refresh(); }
HBITMAP wxDIB::CreateDDB(HDC hdc) const { wxCHECK_MSG( m_handle, 0, wxT("wxDIB::CreateDDB(): invalid object") ); DIBSECTION ds; if ( !GetDIBSection(m_handle, &ds) ) { wxLogLastError(wxT("GetObject(hDIB)")); return 0; } // how many colours are we going to have in the palette? DWORD biClrUsed = ds.dsBmih.biClrUsed; if ( !biClrUsed ) { // biClrUsed field might not be set biClrUsed = GetNumberOfColours(ds.dsBmih.biBitCount); } if ( !biClrUsed ) { return ConvertToBitmap((BITMAPINFO *)&ds.dsBmih, hdc, ds.dsBm.bmBits); } else { // fake a BITMAPINFO w/o bits, just the palette info wxCharBuffer bmi(sizeof(BITMAPINFO) + (biClrUsed - 1)*sizeof(RGBQUAD)); BITMAPINFO *pBmi = (BITMAPINFO *)bmi.data(); MemoryHDC hDC; // get the colour table SelectInHDC sDC(hDC, m_handle); ::GetDIBColorTable(hDC, 0, biClrUsed, pBmi->bmiColors); memcpy(&pBmi->bmiHeader, &ds.dsBmih, ds.dsBmih.biSize); return ConvertToBitmap(pBmi, hdc, ds.dsBm.bmBits); } }