void CTreeList::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { PULONG pMagic = (PULONG) lpDrawItemStruct->itemData; TCHAR lpBuffer[256]; LV_ITEM lvi; LV_COLUMN lvc, lvcprev ; memset(lpBuffer, 0, 256); lvi.mask = LVIF_TEXT | LVIF_PARAM ; lvi.iItem = lpDrawItemStruct->itemID ; lvi.iSubItem = 0; lvi.pszText = lpBuffer ; lvi.cchTextMax = sizeof(lpBuffer); GetItem(&lvi); ::ZeroMemory(&lvc, sizeof(lvc)); ::ZeroMemory(&lvcprev, sizeof(lvcprev)); lvc.mask = LVCF_WIDTH |LVCF_FMT; lvcprev.mask = LVCF_WIDTH | LVCF_FMT; CDC* pDC; pDC = CDC::FromHandle(lpDrawItemStruct->hDC); int nCol; CRect rcText = lpDrawItemStruct->rcItem; CFont Fnt, *pOldFont = NULL; LOGFONT lf; int cyPixels = pDC->GetDeviceCaps(LOGPIXELSY); memset(&lf, 0, sizeof(LOGFONT)); if (pMagic == NULL) { return; } if (*pMagic == EXT2_CDROM_DEVICE_MAGIC || *pMagic == EXT2_DISK_MAGIC) { if (IsVistaOrAbove()) { lstrcpy(lf.lfFaceName, "MS Sans Serif"); /*Courier New*/ lf.lfHeight = -MulDiv(8, cyPixels, 72); lf.lfWeight = TRUE; } else { lstrcpy(lf.lfFaceName, "Arial Black"); /*Courier New*/ lf.lfHeight = -MulDiv(8, cyPixels, 72); lf.lfWeight = TRUE; } } else { lstrcpy(lf.lfFaceName, "MS Sans Serif"); lf.lfHeight = -MulDiv(8, cyPixels, 72); } Fnt.CreateFontIndirect(&lf); pOldFont = (CFont *) pDC->SelectObject(&Fnt); /* loading bitmap */ if (m_hBitmap == NULL) { m_hBitmap = (HBITMAP)::LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_LINE_SEP), IMAGE_BITMAP, 0, 0, 0); if (m_hBitmap) { m_hMemDC = ::CreateCompatibleDC(this->GetDC()->m_hDC); m_hOldBmp = (HBITMAP)::SelectObject(m_hMemDC, m_hBitmap); } } if (TRUE) { if (!m_SelectionFlag) { for (nCol=0; GetColumn(nCol, &lvc); nCol++) { if (nCol > 0) { GetSubItemRect(lpDrawItemStruct->itemID, nCol,LVIR_BOUNDS, m_SelectionRect); } else { GetItemRect(lpDrawItemStruct->itemID, m_SelectionRect,LVIR_BOUNDS); m_SelectionRect.right = GetColumnWidth(0); m_SelectionRect.left = 0; } if (m_SelectionRect.PtInRect(m_Point)) { m_SelectionFlag = TRUE; break; } else { m_SelectionFlag = FALSE; } } } if ((lpDrawItemStruct->itemState & ODS_SELECTED) && m_SelectionFlag ) { CRect rc = lpDrawItemStruct->rcItem; rc.left += 4; rc.right -= 4; rc.top += 1; rc.bottom -= 0; if (*pMagic == EXT2_CDROM_DEVICE_MAGIC || *pMagic == EXT2_DISK_MAGIC) { rc.bottom -= 3; rc.top -= 1; rc.right = (rc.Width() * 7 / 8) + rc.left; } pDC->FillSolidRect(&rc, GetSysColor(m_bFocus ? COLOR_HIGHLIGHT : COLOR_INACTIVEBORDER)); } else { CRect rc = lpDrawItemStruct->rcItem; pDC->FillSolidRect(&rc, GetSysColor(COLOR_WINDOW)) ; pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT)) ; } } for (nCol=0; GetColumn(nCol, &lvc); nCol++) { UINT uFormat = DT_LEFT ; if (*pMagic == EXT2_CDROM_DEVICE_MAGIC || *pMagic == EXT2_DISK_MAGIC) { rcText = lpDrawItemStruct->rcItem; rcText.left += 4; rcText.bottom += 1; rcText.top = rcText.bottom - 6 + lf.lfHeight; ::DrawText(lpDrawItemStruct->hDC, lpBuffer, strlen(lpBuffer), &rcText, DT_LEFT) ; CRect rect = lpDrawItemStruct->rcItem; int rc = 0; BITMAP cs; rect.top = rcText.bottom - 4; rc = ::GetObject(m_hBitmap, sizeof(cs), &cs); if (rc == 0) { pDC->SelectObject(pOldFont); return; } ::StretchBlt(pDC->m_hDC, rect.left + 4, (rect.bottom + rect.top) / 2, rect.Width() * 7 / 8, cs.bmHeight, m_hMemDC, 0, 0, cs.bmWidth, cs.bmHeight, SRCCOPY); } else { if (nCol > 0) { GetColumn(nCol, &lvcprev) ; rcText.left = rcText.right; rcText.right += lvcprev.cx; rcText.left += 4; if (nCol == 3 || nCol == 4) { uFormat = DT_RIGHT; rcText.right -= 4; } } else { rcText = lpDrawItemStruct->rcItem; rcText.top += (16 + lf.lfHeight) / 2; rcText.right = rcText.left + GetColumnWidth(0); rcText.left += 20; } // Get and draw the text memset(lpBuffer, 0, 256); ::ZeroMemory(&lvi, sizeof(lvi)); lvi.iItem = lpDrawItemStruct->itemID; lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.iSubItem = nCol; lvi.pszText = lpBuffer; lvi.cchTextMax = sizeof(lpBuffer); GetItem(&lvi); ::DrawText(lpDrawItemStruct->hDC, lpBuffer, strlen(lpBuffer), &rcText, uFormat) ; if (nCol == 0) { rcText.left -= 20; } else { rcText.left -= 4; if (nCol == 3 || nCol == 4) { rcText.right += 4; } } } } pDC->SelectObject(pOldFont); return; }
/******************************************************************************* Function Name : ShowColumn Input(s) : nCol, bShow Output : BOOL Functionality : Shows/Hides a Column nCol based on boolean bShow. Member of : CRxMsgList Author(s) : Arunkumar K Date Created : 20-05-2010 Modifications : *******************************************************************************/ BOOL CRxMsgList::ShowColumn(int nCol, bool bShow) { SetRedraw(FALSE); ColumnState& columnState = GetColumnState(nCol); int nColCount = GetHeaderCtrl()->GetItemCount(); int* pOrderArray = new int[nColCount]; VERIFY( GetColumnOrderArray(pOrderArray, nColCount) ); if (bShow) { // Restore the position of the column int nCurIndex = -1; for(int i = 0; i < nColCount ; ++i) { if (pOrderArray[i]==nCol) { nCurIndex = i; } else if (nCurIndex!=-1) { // We want to move it to the original position, // and after the last hidden column if ( (i <= columnState.m_OrgPosition) || !IsColumnVisible(pOrderArray[i]) ) { pOrderArray[nCurIndex] = pOrderArray[i]; pOrderArray[i] = nCol; nCurIndex = i; } } } } else { // Move the column to the front of the display order list int nCurIndex(-1); for(int i = nColCount-1; i >=0 ; --i) { if (pOrderArray[i]==nCol) { // Backup the current position of the column columnState.m_OrgPosition = i; nCurIndex = i; } else if (nCurIndex!=-1) { pOrderArray[nCurIndex] = pOrderArray[i]; pOrderArray[i] = nCol; nCurIndex = i; } } } VERIFY( SetColumnOrderArray(nColCount, pOrderArray) ); delete [] pOrderArray; if (bShow) { // Restore the column width columnState.m_Visible = true; VERIFY( SetColumnWidth(nCol, columnState.m_OrgWidth) ); } else { // Backup the column width if(GetColumnWidth(nCol) == 0) { columnState.m_Visible = false; } else { int orgWidth = GetColumnWidth(nCol); VERIFY( SetColumnWidth(nCol, 0) ); columnState.m_Visible = false; columnState.m_OrgWidth = orgWidth; } } SetRedraw(TRUE); Invalidate(FALSE); return TRUE; }
/******************************************************************************* Function Name : pomEditItem Inputs : nRow - Index of the Row nColumn - Index of the Column Output : CEdit * - Pointer to the control Description : This function will create and show a editbox. Member of : CLinFlexListCtrl Author(s) : Raja N Date Created : 22.07.2004 Modifications : *******************************************************************************/ CEdit* CLinFlexListCtrl::pomEditItem(int nItem, int nSubItem) { // Item rect and Client rect CRect omRect, omClientRect; // Set the item to be visible if(!EnsureVisible(nItem, TRUE)) { return NULL; } // Get the item rect GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, omRect); // Now scroll if we need to expose the column GetClientRect(omClientRect); if( omRect.left < 0 || omRect.left > omClientRect.right ) { CSize size(omRect.left,0); Scroll(size); omRect.left -= size.cx; } omRect.right = omRect.left + GetColumnWidth(nSubItem); // If the size is bigger then the client size then resizes if(omRect.right > omClientRect.right) { omRect.right = omClientRect.right; } // Get Column alignment LV_COLUMN lvcol; lvcol.mask = LVCF_FMT; GetColumn(nSubItem, &lvcol); DWORD dwStyle; // Get the justification style of the list item if((lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT) { dwStyle = ES_LEFT; } else if((lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT) { dwStyle = ES_RIGHT; } else { dwStyle = ES_CENTER; } // Include standard styles dwStyle |=WS_BORDER|WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL; // Get the item text CString omStrText = GetItemText(nItem, nSubItem); // Create the control now CEdit* pomEdit = NULL; pomEdit = new CEditItem(nItem, nSubItem, omStrText); if( pomEdit != NULL ) { pomEdit->Create(dwStyle, omRect, this, IDC_CONTROL); } else { CString omStrErr; omStrErr.Format( _(defFLC_CREATE_FAILED), defEDIT_ITEM ); AfxMessageBox( omStrErr ); } // Retrun the window pointer return pomEdit; }
CSize CToolPalette::CalcButtonLocations(int nColumns, bool bCalcOnly) { if (nColumns < 1) { nColumns = 1; } bool bHorizontal = (GetCurrentAlignment () & CBRS_ORIENT_HORZ) != 0; // Toolbar layout mode CRect rectClient; GetClientRect (rectClient); EDisplayOptions edo = GetToolbarDisplayOptions (); if ((edo & eDisplayTitle) != 0) { if (!bHorizontal) { rectClient.top += m_nCaptionHeight + 4; } } int xBorders = 0; int yBorders = 0; if ((edo & eDisplayBorder) != 0) { const CRect& rectCorners = m_imgCaption.GetParams ().m_rectCorners; rectClient.left += rectCorners.left + 3; rectClient.top += rectCorners.top; xBorders = rectCorners.left + rectCorners.right; yBorders = rectCorners.top + rectCorners.bottom; } else { rectClient.left += 1; } if ((edo & eDisplaySizeControl) != 0 && bHorizontal) { const int sizeControlHeight = m_imgCaption.GetParams ().m_rectImage.Height (); yBorders += sizeControlHeight; rectClient.top += sizeControlHeight; } // Consider border area CPoint xyPos = rectClient.TopLeft (); // Current position bool bPrevSeparator = true; // Indicates that previous button was a separator. // Initial 'true' value prevents separator to appear first. CClientDC dc (this); CSize szButtonDefault (GetColumnWidth (), GetRowHeight ()); // Default button size to pass to button's OnCalculateSize method int nMaxSize = nColumns * (bHorizontal ? szButtonDefault.cy : szButtonDefault.cx) * 11 / 10; // (11/10) adds +10% space here // The toolbar height (for horizontal layout) or width (for vertical) of toolbar. CList<ButtonStripe, const ButtonStripe&> listStripes; ButtonStripe stripe; // Current stripe CBCGPToolbarButton* pButton = NULL; // Current button for (POSITION pos = m_Buttons.GetHeadPosition (); pos != NULL;) { pButton = (CBCGPToolbarButton*)m_Buttons.GetNext (pos); if (pButton == NULL) { break; } if (!pButton->IsVisible ()) { continue; } bool bSep = (pButton->m_nStyle & TBBS_SEPARATOR) != 0; if (bSep && bPrevSeparator) { continue; } // Layout algorithm: // ------------------- // if (separator) AddPreviousStripe, AddSeparatorStripe, BeginNewStripe // else { // AddButton // if (stripe.breadth > default_stripe_breadth) // AddPreviousStripe, BeginNewStripe, AddButton // } CSize szButton = pButton->OnCalculateSize (&dc, szButtonDefault, bHorizontal); if (bHorizontal) { } else // vertical layout { if (bSep) { if (stripe.buttonCount > 0) { listStripes.AddTail (stripe); } stripe.buttonCount = 1; stripe.breadth = 0; // separator length is set automatically stripe.size = szButton.cy; // cx for horz. listStripes.AddTail (stripe); stripe = ButtonStripe (); } else if (szButton.cx > nMaxSize) // this button is larger than current toolbar width { if (stripe.buttonCount > 0) { listStripes.AddTail (stripe); } stripe.buttonCount = 1; stripe.breadth = szButton.cx; // cy for horz. stripe.size = szButton.cy; // cx for horz. listStripes.AddTail (stripe); // stripe with a single large button stripe = ButtonStripe (); } else // usual button { if (stripe.breadth + szButton.cx <= nMaxSize) { stripe.breadth += szButton.cx; stripe.buttonCount ++; if (szButton.cy > stripe.size) stripe.size = szButton.cy; } else { if (stripe.buttonCount > 0) { listStripes.AddTail (stripe); } stripe.buttonCount = 1; stripe.breadth = szButton.cx; // cy for horz. stripe.size = szButton.cy; // cx for horz. } } } bPrevSeparator = bSep; } if (stripe.buttonCount > 0) { listStripes.AddTail (stripe); } if (listStripes.IsEmpty ()) { return CSize (0, 0); } if (listStripes.GetTail ().breadth == 0) // last item is separator { listStripes.RemoveTail (); } // Now calculate total size int totalLength = m_nCaptionHeight + 4; int maxBreadth = nMaxSize; POSITION posStripes = listStripes.GetHeadPosition (); while (posStripes != NULL) { stripe = listStripes.GetNext (posStripes); ASSERT (stripe.buttonCount > 0); totalLength += stripe.size; if (stripe.breadth > maxBreadth) { maxBreadth = stripe.breadth; } } if (!bCalcOnly) { CPoint ptButtonPos = rectClient.TopLeft (); posStripes = listStripes.GetHeadPosition (); stripe = ButtonStripe(); for (POSITION pos = m_Buttons.GetHeadPosition (); pos != NULL;) { pButton = (CBCGPToolbarButton*)m_Buttons.GetNext (pos); if (pButton == NULL) { break; } if (!pButton->IsVisible ()) { continue; } bool bSep = (pButton->m_nStyle & TBBS_SEPARATOR) != 0; if (bSep && bPrevSeparator) { continue; } CSize szButton = pButton->OnCalculateSize (&dc, szButtonDefault, bHorizontal); CRect rcButton (0, 0, 0, 0); if (stripe.buttonCount == 0) // this member is decremented below { ptButtonPos.y += stripe.size; if (posStripes == NULL) { break; } stripe = listStripes.GetNext (posStripes); ptButtonPos.x = rectClient.left + (maxBreadth - stripe.breadth) / 2; // center-alignment } if (bSep) { ASSERT (stripe.breadth == 0); ASSERT (stripe.buttonCount == 1); rcButton.left = rectClient.left; rcButton.top = ptButtonPos.y; rcButton.right = rcButton.left + maxBreadth; rcButton.bottom = rcButton.top + szButton.cy; } else { rcButton.left = ptButtonPos.x; rcButton.top = ptButtonPos.y + (stripe.size - szButton.cy) / 2; // center-alignment rcButton.right = rcButton.left + szButton.cx; rcButton.bottom = rcButton.top + szButton.cy; ptButtonPos.x += szButton.cx; } pButton->SetRect (rcButton); stripe.buttonCount --; } } if (m_bAdditionalPixel) { ++maxBreadth; } return bHorizontal ? CSize (totalLength + xBorders, maxBreadth + yBorders) : CSize (maxBreadth + xBorders, totalLength + yBorders); }
//绘画函数 void CUserListView::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CRect rcItem=lpDrawItemStruct->rcItem; CDC * pDC=CDC::FromHandle(lpDrawItemStruct->hDC); tagUserData const *pMeUserData = m_pIClientKernel->GetMeUserInfo(); int iItem=lpDrawItemStruct->itemID; int iCount=GetHeaderCtrl()->GetItemCount(); int iBeen=rcItem.left; TCHAR szBuffer[1024]; tagUserData *pIUserItem = (tagUserData *)GetItemData(iItem); GetItemRect(iItem, rcItem, LVIR_LABEL); for (int i=0;i<iCount;i++) { CRect rcSubItem; int iWidth=GetColumnWidth(i); GetSubItemRect(iItem,i,LVIR_LABEL,rcSubItem); if ( i == 0 ) { GetSubItemRect(iItem,i,LVIR_ICON,rcSubItem); //如果是焦点(被点击) if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->FillSolidRect(&rcSubItem,RGB(212,204,193)); else pDC->FillSolidRect(&rcSubItem,GetBkColor()); //如果是焦点(被点击) if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->SetTextColor(RGB(0,0,0)); else if (pIUserItem->dwUserID == pMeUserData->dwUserID) { if(0 < pIUserItem->cbMemberOrder) pDC->SetTextColor(RGB(255,0,0)); else pDC->SetTextColor(RGB(0,0,0)); pDC->FillSolidRect(&rcSubItem,RGB(225,237,173)); } else if ( 0 < pIUserItem->cbMemberOrder /*&& DTP_USER_ACCOUNTS== m_wDataDescribe[i]*/) { pDC->SetTextColor(RGB(255,0,0)); pDC->FillSolidRect(&rcSubItem,RGB(251,237,166)); } else pDC->SetTextColor(RGB(0,0,0)); //绘画标志 UINT uImageIndex=GetImageStation(pIUserItem); m_StatusImage.Draw(pDC,uImageIndex,CPoint(rcSubItem.left,rcSubItem.top),ILD_TRANSPARENT); GetItemText(iItem,i,szBuffer,sizeof(szBuffer)); GetSubItemRect(iItem,i,LVIR_LABEL,rcSubItem); if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->FillSolidRect(&rcSubItem,RGB(212,204,193)); else if (pIUserItem->dwUserID == pMeUserData->dwUserID) { if(0 < pIUserItem->cbMemberOrder) pDC->SetTextColor(RGB(255,0,0)); else pDC->SetTextColor(RGB(0,0,0)); pDC->FillSolidRect(&rcSubItem,RGB(225,237,173)); } else if ( 0 < pIUserItem->cbMemberOrder /*&& DTP_USER_ACCOUNTS== m_wDataDescribe[i]*/) { pDC->FillSolidRect(&rcSubItem,RGB(251,237,166)); } else pDC->FillSolidRect(&rcSubItem,GetBkColor()); rcSubItem.top+=3; pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcSubItem,DT_LEFT|DT_END_ELLIPSIS); } else { //如果是焦点(被点击) if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->FillSolidRect(&rcSubItem,RGB(212,204,193)); else pDC->FillSolidRect(&rcSubItem,GetBkColor()); //如果是焦点(被点击) if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->SetTextColor(RGB(0,0,0)); else if (pIUserItem->dwUserID == pMeUserData->dwUserID) { if(0 < pIUserItem->cbMemberOrder) pDC->SetTextColor(RGB(255,0,0)); else pDC->SetTextColor(RGB(0,0,0)); pDC->FillSolidRect(&rcSubItem,RGB(225,237,173)); } else if ( 0 < pIUserItem->cbMemberOrder /*&& DTP_GAME_ID == m_wDataDescribe[i]*/) { pDC->SetTextColor(RGB(255,0,0)); pDC->FillSolidRect(&rcSubItem,RGB(251,237,166)); } else pDC->SetTextColor(RGB(0,0,0)); GetItemText(iItem,i,szBuffer,sizeof(szBuffer)); CRect rcTempItem =rcSubItem; rcTempItem.left +=2; rcTempItem.right +=2; rcTempItem.top +=3; pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcTempItem,DT_LEFT|DT_END_ELLIPSIS); } } //绘画选择 if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->DrawFocusRect(&rcItem); return; }
//绘画函数 void CUserListView::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CRect rcItem=lpDrawItemStruct->rcItem; CDC * pDC=CDC::FromHandle(lpDrawItemStruct->hDC); int nSavedDC = pDC->SaveDC(); int iItem=lpDrawItemStruct->itemID; int iCount=GetHeaderCtrl()->GetItemCount(); int iBeen=rcItem.left; LV_ITEM lvi; lvi.mask = LVIF_IMAGE | LVIF_STATE; lvi.iItem = iItem; lvi.iSubItem = 0; lvi.stateMask = 0xFFFF; // get all state flags GetItem(&lvi); BOOL bSelect =((lvi.state & LVIS_DROPHILITED) || ( (lvi.state & LVIS_SELECTED) && ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS) ) ) ); tagUserData * pUserItem=(tagUserData *)GetItemData(iItem); CRect rcBounds, rcLabel, rcIcon; GetItemRect(iItem, rcBounds, LVIR_BOUNDS); CRect rcHighlight; CRect rcWnd; GetClientRect(&rcWnd); rcHighlight = rcBounds; rcHighlight.left = rcLabel.left; rcHighlight.right = rcWnd.right +1 ; if (bSelect) { pDC->FillSolidRect(&rcHighlight,RGB(49,105,198)); pDC->SetTextColor(RGB(255,255,255)); } else { pDC->FillSolidRect(&rcHighlight,RGB(165,189,213)); pDC->SetTextColor(RGB(49,85,132)); } TCHAR szBuffer[1024]; for (int i=0;i<iCount;i++) { int iWidth=GetColumnWidth(i); GetSubItemRect(iItem,i,LVIR_LABEL,rcItem); if (i==1) { if (m_StatusImage) { m_StatusImage.Draw(pDC, GetImageStation(pUserItem), CPoint(rcItem.left, rcItem.top), ILD_TRANSPARENT |ILC_MASK ); } } if (i==2) { m_pIUserFaceRes->DrawSmallFace(pDC,rcItem.left,rcItem.top,pUserItem->szFace,pUserItem->cbGender); } GetItemText(iItem,i,szBuffer,sizeof(szBuffer)); pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcItem,DT_LEFT|DT_END_ELLIPSIS); } pDC->RestoreDC( nSavedDC ); return; /* if (lpDrawItemStruct->itemState==0) { CDC BitmapDC; BitmapDC.CreateCompatibleDC(pDC); BitmapDC.SelectObject(&m_Bitmap); pDC->BitBlt(rcItem.left,rcItem.top,rcItem.Width(),rcItem.Height(),&BitmapDC,0,0,SRCCOPY); } else pDC->FillSolidRect(&rcItem,RGB(255,255,255)); */ }
void KGListCtrl::OnMouseMove(UINT nFlags, CPoint point) { if (m_nToolTipFlag) { CString szTipText = _T(""); CRect rect; SIZE size; int nSubItemCount = 0; int nItemPos = 0; int nCurSubItem = 0; LPKGLISTITEM lpItem = NULL; nItemPos = HitTest(point); KG_PROCESS_ERROR(nItemPos != -1); nSubItemCount = GetHeaderCtrl()->GetItemCount(); lpItem = (LPKGLISTITEM)GetItemData(nItemPos); KG_PROCESS_ERROR(lpItem); ZeroMemory(&size ,sizeof(size)); if (*(lpItem->szTipText) == '\0') { for (nCurSubItem = nSubItemCount - 1; nCurSubItem >= 0; nCurSubItem--) { GetSubItemRect(nItemPos, nCurSubItem, LVIR_BOUNDS, rect); if (rect.PtInRect(point)) { szTipText = GetItemText(nItemPos, nCurSubItem); CDC* pDC = GetDC(); if (pDC && pDC->m_hDC) GetTextExtentPoint( pDC->m_hDC, szTipText.GetBuffer(), szTipText.GetLength(), &size ); if (nCurSubItem == nSubItemCount - 1) { CRect rectClient; GetWindowRect(rectClient); ScreenToClient(rectClient); rect.right = rectClient.right; if (size.cx < rect.Width()) { szTipText = _T(""); } } else { if (size.cx < GetColumnWidth(nCurSubItem)) { szTipText = _T(""); } } break; } } } else { szTipText = lpItem->szTipText; } m_toolTipCtrl.Activate(TRUE); m_toolTipCtrl.UpdateTipText(szTipText.GetBuffer(), this); KillTimer(1); SetTimer(1, 2000, NULL); } Exit0: return CListCtrl::OnMouseMove(nFlags, point); }
void CUploadListCtrl::DrawItemInfo(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); CRect rtItem = lpDrawItemStruct->rcItem; VideoInfo item = UploadQueueManager::GetInstance().GetItem(GetItemText(lpDrawItemStruct->itemID, 0).GetString()); int cw = rtItem.left; // 上传状态 int iStateWidth = GetColumnWidth(0); CRect rtState(cw, rtItem.top, cw + iStateWidth - 1, rtItem.bottom); CDC StateMemDC; StateMemDC.CreateCompatibleDC(pDC); CBitmap* pOldBitmap = NULL; COLORREF oldColor; switch(item.m_dwState) { case VideoInfo::Complete: oldColor = pDC->SetTextColor(RGB(0, 0, 0)); pOldBitmap = StateMemDC.SelectObject(&m_CompleteStateBmpObj); break; case VideoInfo::Validate: case VideoInfo::Uploading: oldColor = pDC->SetTextColor(RGB(0, 0, 0)); pOldBitmap = StateMemDC.SelectObject(&m_RunningStateBmpObj); break; case VideoInfo::WaitKey: case VideoInfo::Wait: oldColor = pDC->SetTextColor(RGB(0, 0, 0)); pOldBitmap = StateMemDC.SelectObject(&m_WaitStateBmpObj); break; case VideoInfo::Delete: case VideoInfo::Pause: oldColor = pDC->SetTextColor(RGB(0, 0, 0)); pOldBitmap = StateMemDC.SelectObject(&m_PauseStateBmpObj); break; default: oldColor = pDC->SetTextColor(RGB(255, 0, 0)); pOldBitmap = StateMemDC.SelectObject(&m_FailStateBmpObj); break; } int descX, descY, descWidth, descHeight, srcX, srcY, srcWidth, srcHeight; if(rtState.Height() > rtState.Width()) { if(rtState.Width() < 16) { descX = rtState.left; descY = rtState.top; descWidth = rtState.Width(); descHeight = rtState.Height(); srcX = (16 - rtState.Width()) / 2; srcY = (16 - rtState.Height()) / 2; srcWidth = rtState.Width(); srcHeight = rtState.Height(); } else { descX = (rtState.Width() - 16) / 2 + rtState.left; descY = (rtState.Height() - 16) / 2 + rtState.top; descWidth = 16; descHeight = 16; srcX = 0; srcY = 0; srcWidth = 16; srcHeight = 16; } } else { if(rtState.Height() < 16) { descX = rtState.left; descY = rtState.top; descWidth = rtState.Width(); descHeight = rtState.Height(); srcX = (16 - rtState.Width()) / 2; srcY = (16 - rtState.Height()) / 2; srcWidth = rtState.Width(); srcHeight = rtState.Height(); } else { descX = (rtState.Width() - 16) / 2 + rtState.left; descY = (rtState.Height() - 16) / 2 + rtState.top; descWidth = 16; descHeight = 16; srcX = 0; srcY = 0; srcWidth = 16; srcHeight = 16; } } pDC->TransparentBlt(descX, descY, descWidth, descHeight, &StateMemDC, srcX, srcY, srcWidth, srcHeight, RGB(255, 0, 255)); StateMemDC.SelectObject(pOldBitmap); StateMemDC.DeleteDC(); cw += iStateWidth; // 视频名称 int iNameWidth = GetColumnWidth(1); CRect rtName(cw, rtItem.top, cw + iNameWidth - 1, rtItem.bottom); pDC->DrawText(item.m_strVideoName.c_str(), item.m_strVideoName.length(), &rtName, DT_LEFT|DT_VCENTER|DT_SINGLELINE); cw += iNameWidth; pDC->SetTextColor(oldColor); // 上传通道 int iUploadChannelWidth = GetColumnWidth(2); CRect rtUploadChannel(cw, rtItem.top, cw + iUploadChannelWidth - 1, rtItem.bottom); if(item.m_dwVideoUploadChannel == VideoInfo::FastChannel) { oldColor = pDC->SetTextColor(RGB(0xFF, 0, 0)); pDC->DrawText(TEXT("快速"), TSTRLEN(TEXT("快速")), &rtUploadChannel, DT_CENTER|DT_VCENTER|DT_SINGLELINE); pDC->SetTextColor(oldColor); } else { pDC->DrawText(TEXT("普通"), TSTRLEN(TEXT("普通")), &rtUploadChannel, DT_CENTER|DT_VCENTER|DT_SINGLELINE); } cw += iUploadChannelWidth; // 优先级 int iVideoPriorityWidth = GetColumnWidth(3); CString strVideoPriority; switch(item.m_dwPriority) { case VideoInfo::Normal: oldColor = pDC->SetTextColor(RGB(0, 0, 0)); strVideoPriority = TEXT("中"); break; case VideoInfo::Important: oldColor = pDC->SetTextColor(RGB(0xFF, 0x99, 0)); strVideoPriority = TEXT("高"); break; default: oldColor = pDC->SetTextColor(RGB(255, 0, 0)); strVideoPriority = TEXT("低"); break; } CRect rtVideoPriority(cw, rtItem.top, cw + iVideoPriorityWidth - 1, rtItem.bottom); pDC->DrawText(strVideoPriority, strVideoPriority.GetLength(), &rtVideoPriority, DT_CENTER|DT_VCENTER|DT_SINGLELINE); cw += iVideoPriorityWidth; pDC->SetTextColor(oldColor); // 视频大小 int iVideoSizeWidth = GetColumnWidth(4); double szFile = item.m_dwFileSize; szFile = szFile / 1048576; CString strVideoSize; strVideoSize.Format(TEXT("%.2fMB "), szFile); CRect rtVideoSize(cw, rtItem.top, cw + iVideoSizeWidth - 1, rtItem.bottom); pDC->DrawText(strVideoSize, strVideoSize.GetLength(), &rtVideoSize, DT_RIGHT|DT_VCENTER|DT_SINGLELINE); cw += iVideoSizeWidth; // 上传进度 int iUploadProcessWidth = GetColumnWidth(5); double dUploadProcess = (double)item.m_dwPosition / item.m_dwFileSize; CRect rtUploadProcess(cw + 1, rtItem.top + 1, cw + iUploadProcessWidth - 2, rtItem.bottom - 1); pDC->Rectangle(&rtUploadProcess); CDC dc; dc.CreateCompatibleDC(pDC); CBitmap* pOldBitmapObj = dc.SelectObject(&m_ProcessBackgroundBmpObj); pDC->TransparentBlt(rtUploadProcess.left + 1, rtUploadProcess.top + 1, (int)(rtUploadProcess.Width() * dUploadProcess) - 2, rtUploadProcess.Height() - 2, &dc, 0, 0, 1, 15, RGB(0, 0, 0)); dc.SelectObject(pOldBitmapObj); dc.DeleteDC(); CString strProcess; strProcess.Format(TEXT("%.2f%%"), dUploadProcess * 100); pDC->DrawText(strProcess, strProcess.GetLength(), &rtUploadProcess, DT_CENTER|DT_VCENTER|DT_SINGLELINE); cw += iUploadProcessWidth; // 上传速度 int iSpeedWidth = GetColumnWidth(6); CString strSpeed; if(item.m_dwState == VideoInfo::Uploading) { double dTmpSpeed = item.m_dSpeed * 1000 / 1024; if(dTmpSpeed >= 1024) { dTmpSpeed = dTmpSpeed / 1024; strSpeed.Format(TEXT("%.2fMB/s "), dTmpSpeed); } else strSpeed.Format(TEXT("%.2fKB/s "), dTmpSpeed); } CRect rtSpeed(cw, rtItem.top, cw + iSpeedWidth - 1, rtItem.bottom); pDC->DrawText(strSpeed, strSpeed.GetLength(), &rtSpeed, DT_RIGHT|DT_VCENTER|DT_SINGLELINE); cw += iSpeedWidth; // 剩余时间 int iRemainTimeWidth = GetColumnWidth(7); CString strRemainTime = item.m_strNeedTime.c_str(); strRemainTime.Append(TEXT(" ")); CRect rtRemainTime(cw, rtItem.top, cw + iRemainTimeWidth - 1, rtItem.bottom); pDC->DrawText(strRemainTime, strRemainTime.GetLength(), &rtRemainTime, DT_RIGHT|DT_VCENTER|DT_SINGLELINE); cw += iRemainTimeWidth; // 码率 int iBitRateWidth = GetColumnWidth(8); CString strBitRate; double dTmpBitRate = (double)item.m_iVideoBitRate / 1000; strBitRate.Format(TEXT("%.2fkbps "), dTmpBitRate); CRect rtBitRate(cw, rtItem.top, cw + iBitRateWidth - 1, rtItem.bottom); pDC->DrawText(strBitRate, strBitRate.GetLength(), &rtBitRate, DT_RIGHT|DT_VCENTER|DT_SINGLELINE); cw += iBitRateWidth; // 时长 int iVideoDurationWidth = GetColumnWidth(9); CString strVideoDuration = item.m_strVideoDuration.c_str(); strVideoDuration.Append(TEXT(" ")); CRect rtVideoDuration(cw, rtItem.top, cw + iVideoDurationWidth - 1, rtItem.bottom); pDC->DrawText(strVideoDuration, strVideoDuration.GetLength(), &rtVideoDuration, DT_RIGHT|DT_VCENTER|DT_SINGLELINE); cw += iVideoDurationWidth; // 备注 int iRemarkWidth = GetColumnWidth(10); CString strRemark = item.m_strErrorMessage.c_str(); CRect rtRemark(cw, rtItem.top, cw + iRemarkWidth - 1, rtItem.bottom); pDC->DrawText(strRemark, strRemark.GetLength(), &rtRemark, DT_LEFT|DT_VCENTER|DT_SINGLELINE); cw += iRemarkWidth; }
/******************************************************************************* Function Name : pomComboList Inputs : nRow - Index of the Row nColumn - Index of the Column omList - List of strings Output : CComboItem* - Pointer to the control Description : This function will create and show editable combo box.This control will be placed over the list item. The combobox will be filled with the data given the omList. Member of : CFlexListCtrl Author(s) : Raja N Date Created : 22.07.2004 Modifications : *******************************************************************************/ CComboItem* CFlexListCtrl::pomComboList( int nItem, int nSubItem, const CStringArray& omList) { // Get the item text from the list control CString strFind = GetItemText(nItem, nSubItem); //basic code start CRect omRect; // Make sure that the item is visible if( !EnsureVisible(nItem, TRUE)) { return NULL; } // Get the size of the list item GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, omRect); // Now scroll if we need to expose the column CRect omClientRect; // Get the list rect GetClientRect(omClientRect); // Check for scrolling if( omRect.left < 0 || omRect.left > omClientRect.right ) { CSize size; size.cx = omRect.left; size.cy = 0; Scroll(size); omRect.left -= size.cx; } omRect.right = omRect.left + GetColumnWidth(nSubItem); // Reduce the size of the control if the list item is not completely // Visible if(omRect.right > omClientRect.right) { omRect.right = omClientRect.right; } //basic code end //dropdown area omRect.bottom += 100; // Set the standard style and combobox type DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | CBS_DROPDOWN; CComboItem* pomCBox = NULL; pomCBox = new CComboItem(nItem, nSubItem, omList, strFind, TRUE); if( pomCBox != NULL ) { // Create the UI control pomCBox->Create(dwStyle, omRect, this, IDC_CONTROL); // Show the Drop-down list pomCBox->ShowDropDown(); // Set the seleted item text pomCBox->SetWindowText(strFind); // Select the item from the list. If it is not available the // Set the text with out any selection if (pomCBox->SelectString(-1, strFind.GetBuffer(1)) == CB_ERR ) { // Set the with out any selection from the list pomCBox->SetWindowText(strFind); } } else { CString omStrErr; omStrErr.Format(_(defFLC_CREATE_FAILED),defCOMBO_LIST); AfxMessageBox( omStrErr ); } // The returned pointer should not be saved return pomCBox; }
/******************************************************************************* Function Name : pomNumItem Inputs : nRow - Index of the Row nColumn - Index of the Column sInfo - Numeric info like Min val, Max val, Base... Please see the structure definition to get all field info Output : CEdit * - Pointer to the control Description : This function will create and show a numeric edit control with or without spin control Member of : CFlexListCtrl Author(s) : Raja N Date Created : 22.07.2004 Modifications : *******************************************************************************/ CNumEdit* CFlexListCtrl::pomNumItem( int nItem, int nSubItem, const SNUMERICINFO& sInfo) { CRect omRect; // Set the item to be visible if(!EnsureVisible(nItem, TRUE)) { return NULL; } // Get the item rect GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, omRect); // Now scroll if we need to expose the column CRect omClientRect; GetClientRect(omClientRect); if( omRect.left < 0 || omRect.left > omClientRect.right ) { CSize size( omRect.left, 0 ); Scroll( size ); omRect.left -= size.cx; } omRect.right = omRect.left + GetColumnWidth(nSubItem); if(omRect.right > omClientRect.right) { omRect.right = omClientRect.right; } // Get Column alignment LV_COLUMN lvcol; lvcol.mask = LVCF_FMT; GetColumn(nSubItem, &lvcol); DWORD dwStyle; if((lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT) { dwStyle = ES_LEFT; } else if((lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT) { dwStyle = ES_RIGHT; } else { dwStyle = ES_CENTER; } // Set the standard windows style dwStyle |=WS_BORDER|WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL; // Get the selected item text CString omStrText = GetItemText(nItem, nSubItem); // Create the control CNumEdit* pomEdit = NULL; pomEdit = new CNumEdit(nItem, nSubItem, omStrText, sInfo); if( pomEdit != NULL ) { pomEdit->Create(dwStyle, omRect, this, IDC_CONTROL); } else { CString omStrErr; omStrErr.Format( _(defFLC_CREATE_FAILED), defNUM_ITEM ); AfxMessageBox( omStrErr ); } // Return the window pointer return pomEdit; }
/******************************************************************************* Function Name : pomComboItem Inputs : nRow - Index of the Row nColumn - Index of the Column omList - List of strings Output : CComboItem* - Pointer to the control Description : This function will create and show non editable combo box.This control will be placed over the list item. The combobox will be filled with the data given the omList. Member of : CFlexListCtrl Author(s) : Raja N Date Created : 22.07.2004 Modifications : *******************************************************************************/ CComboItem* CFlexListCtrl::pomComboItem(int nItem, int nSubItem, const CStringArray& omList) { // Get the item text from the list control CString strFind = GetItemText(nItem, nSubItem); //basic code start CRect omRect; // Make sure that the item is visible if( !EnsureVisible(nItem, TRUE)) { return NULL; } // Get the size of the list item GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, omRect); // Now scroll if we need to expose the column CRect omClientRect; // Get the list rect GetClientRect(omClientRect); // Check for scrolling if( omRect.left < 0 || omRect.left > omClientRect.right ) { CSize size; size.cx = omRect.left; size.cy = 0; Scroll(size); omRect.left -= size.cx; } omRect.right = omRect.left + GetColumnWidth(nSubItem); // Reduce the size of the control if the list item is not completely // Visible if(omRect.right > omClientRect.right) { omRect.right = omClientRect.right; } //basic code end //dropdown area omRect.bottom += 100; // Set the standard style and combobox type DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | CBS_DROPDOWNLIST; // Create the non editable combobox CComboItem* pomCBox = NULL; // Create the control pomCBox = new CComboItem( nItem, // Item Index nSubItem, // Sub Item Index omList, // Lsit of strings strFind, // Selected Text FALSE); // Editing is FALSE if( pomCBox != NULL ) { // Create the UI pomCBox->Create(dwStyle, omRect, this, IDC_CONTROL); // Set the text pomCBox->SetWindowText(strFind); // Select the text from the list pomCBox->SelectString(-1 , strFind.GetBuffer(1)); // Show the drop-down list pomCBox->ShowDropDown(); } else { CString omStrErr; omStrErr.Format(_(defFLC_CREATE_FAILED),defCOMBO_ITEM); AfxMessageBox( omStrErr ); } // The return the pointer just for reference // Destroy will delete this memory. So this should not be deleted outside return pomCBox; }
void CGameListCtrl::AutomaticColumnWidth() { wxRect rc(GetClientRect()); if (GetColumnCount() == 1) { SetColumnWidth(0, rc.GetWidth()); } else if (GetColumnCount() > 0) { int resizable = rc.GetWidth() - ( GetColumnWidth(COLUMN_PLATFORM) + GetColumnWidth(COLUMN_BANNER) + GetColumnWidth(COLUMN_ID) + GetColumnWidth(COLUMN_COUNTRY) + GetColumnWidth(COLUMN_SIZE) + GetColumnWidth(COLUMN_EMULATION_STATE)); // We hide the Maker column if the window is too small // Use ShowColumn() instead of SetColumnWidth because // the maker column may have been autohidden and the // therefore the content needs to be restored. if (resizable > 425) { if (SConfig::GetInstance().m_showMakerColumn && SConfig::GetInstance().m_showFileNameColumn) { SetColumnWidth(COLUMN_TITLE, resizable / 3); ShowColumn(COLUMN_MAKER, resizable / 3); SetColumnWidth(COLUMN_FILENAME, resizable / 3); } else if (SConfig::GetInstance().m_showMakerColumn) { SetColumnWidth(COLUMN_TITLE, resizable / 2); ShowColumn(COLUMN_MAKER, resizable / 2); } else if (SConfig::GetInstance().m_showFileNameColumn) { SetColumnWidth(COLUMN_TITLE, resizable / 2); SetColumnWidth(COLUMN_FILENAME, resizable / 2); } else { SetColumnWidth(COLUMN_TITLE, resizable); } } else { if (SConfig::GetInstance().m_showFileNameColumn) { SetColumnWidth(COLUMN_TITLE, resizable / 2); SetColumnWidth(COLUMN_FILENAME, resizable / 2); } else { SetColumnWidth(COLUMN_TITLE, resizable); } HideColumn(COLUMN_MAKER); } } }
void CQueueListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (!theApp.emuledlg->IsRunning()) return; if (!lpDrawItemStruct->itemData) return; // ==> Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle /* CMemDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem); */ CMemoryDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem); // <== Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle BOOL bCtrlFocused; //Xman narrow font at transferwindow /* InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused); */ // ==> Design Settings [eWombat/Stulle] - Stulle /* InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused, true); //Xman end */ InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused, true, style_b_queuelist); // <== Design Settings [eWombat/Stulle] - Stulle CRect cur_rec(lpDrawItemStruct->rcItem); CRect rcClient; GetClientRect(&rcClient); const CUpDownClient *client = (CUpDownClient *)lpDrawItemStruct->itemData; // ==> Design Settings [eWombat/Stulle] - Stulle /* COLORREF crOldBackColor = dc->GetBkColor(); //Xman PowerRelease //Xman show LowIDs */ // <== Design Settings [eWombat/Stulle] - Stulle CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - sm_iLabelOffset; cur_rec.left += sm_iIconOffset; for (int iCurrent = 0; iCurrent < iCount; iCurrent++) { int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if (!IsColumnHidden(iColumn)) { UINT uDrawTextAlignment; int iColumnWidth = GetColumnWidth(iColumn, uDrawTextAlignment); cur_rec.right += iColumnWidth; if (cur_rec.left < cur_rec.right && HaveIntersection(rcClient, cur_rec)) { TCHAR szItem[1024]; GetItemDisplayText(client, iColumn, szItem, _countof(szItem)); switch (iColumn) { case 0:{ int iImage; //Xman Show correct Icons /* if (client->IsFriend()) iImage = 4; else if (client->GetClientSoft() == SO_EDONKEYHYBRID) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 8; else iImage = 7; } else if (client->GetClientSoft() == SO_MLDONKEY) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 6; else iImage = 5; } else if (client->GetClientSoft() == SO_SHAREAZA) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 10; else iImage = 9; } else if (client->GetClientSoft() == SO_AMULE) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 12; else iImage = 11; } else if (client->GetClientSoft() == SO_LPHANT) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 14; else iImage = 13; } else if (client->ExtProtocolAvailable()) { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 3; else iImage = 1; } else { if (client->credits->GetScoreRatio(client->GetIP()) > 1) iImage = 2; else iImage = 0; } */ if (client->IsFriend()) iImage = 6; else if (client->GetClientSoft() == SO_EDONKEYHYBRID){ iImage = 10; } else if (client->GetClientSoft() == SO_EDONKEY){ iImage = 2; } else if (client->GetClientSoft() == SO_MLDONKEY){ iImage = 8; } else if (client->GetClientSoft() == SO_SHAREAZA){ iImage = 12; } else if (client->GetClientSoft() == SO_AMULE){ iImage = 14; } else if (client->GetClientSoft() == SO_LPHANT){ iImage = 16; } else if (client->ExtProtocolAvailable()){ // ==> Mod Icons - Stulle /* iImage = 4; */ if(client->GetModClient() == MOD_NONE) iImage = 4; else iImage = (uint8)(client->GetModClient() + 19); // <== Mod Icons - Stulle } else{ iImage = 0; } //Xman Anti-Leecher if(client->IsLeecher()>0) iImage=18; else //Xman end if (((client->credits)?client->credits->GetScoreRatio(client):0) > 1) // ==> Mod Icons - Stulle // ==> CreditSystems [EastShare/ MorphXT] - Stulle /* iImage++; */ if (client->GetModClient() == MOD_NONE){ if(client->credits && client->credits->GetHasScore(client)) iImage++; } // <== CreditSystems [EastShare/ MorphXT] - Stulle // <== Mod Icons - Stulle //Xman end UINT nOverlayImage = 0; if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED)) nOverlayImage |= 1; //Xman changed: display the obfuscation icon for all clients which enabled it /* if (client->IsObfuscatedConnectionEstablished()) */ if(client->IsObfuscatedConnectionEstablished() || (!(client->socket != NULL && client->socket->IsConnected()) && (client->SupportsCryptLayer() && thePrefs.IsClientCryptLayerSupported() && (client->RequestsCryptLayer() || thePrefs.IsClientCryptLayerRequested())))) nOverlayImage |= 2; int iIconPosY = (cur_rec.Height() > 16) ? ((cur_rec.Height() - 16) / 2) : 1; POINT point = { cur_rec.left, cur_rec.top + iIconPosY }; m_ImageList.Draw(dc, iImage, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage)); // ==> Mod Icons - Stulle if(client->Credits() && client->credits->GetHasScore(client) && client->GetModClient() != MOD_NONE) { if (nOverlayImage & 1) m_overlayimages.Draw(dc,1, point, ILD_TRANSPARENT); else m_overlayimages.Draw(dc,0, point, ILD_TRANSPARENT); } // <== Mod Icons - Stulle //Xman friend visualization if (client->IsFriend() && client->GetFriendSlot()) m_ImageList.Draw(dc,19, point, ILD_NORMAL); //Xman end //EastShare Start - added by AndCycle, IP to Country if(theApp.ip2country->ShowCountryFlag() ) { cur_rec.left+=20; POINT point2= {cur_rec.left,cur_rec.top+1}; //theApp.ip2country->GetFlagImageList()->Draw(dc, client->GetCountryFlagIndex(), point2, ILD_NORMAL); theApp.ip2country->GetFlagImageList()->DrawIndirect(&theApp.ip2country->GetFlagImageDrawParams(dc,client->GetCountryFlagIndex(),point2)); cur_rec.left += sm_iLabelOffset; } //EastShare End - added by AndCycle, IP to Country cur_rec.left += 16 + sm_iLabelOffset; dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment); cur_rec.left -= 16; cur_rec.right -= sm_iSubItemInset; //EastShare Start - added by AndCycle, IP to Country if(theApp.ip2country->ShowCountryFlag() ) { cur_rec.left-=20; } //EastShare End - added by AndCycle, IP to Country break; } case 9: if (client->GetUpPartCount()) { cur_rec.bottom--; cur_rec.top++; COLORREF crOldBackColor = dc->GetBkColor(); //Xman Code Improvement: FillSolidRect client->DrawUpStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar()); dc.SetBkColor(crOldBackColor); //Xman Code Improvement: FillSolidRect //Xman client percentage (font idea by morph) CString buffer; // ==> Show Client Percentage optional [Stulle] - Stulle /* if (thePrefs.GetUseDwlPercentage()) */ if (thePrefs.GetShowClientPercentage()) // <== Show Client Percentage optional [Stulle] - Stulle { if(client->GetHisCompletedPartsPercent_UP() >=0) { COLORREF oldclr = dc.SetTextColor(RGB(0,0,0)); int iOMode = dc.SetBkMode(TRANSPARENT); buffer.Format(_T("%i%%"), client->GetHisCompletedPartsPercent_UP()); CFont *pOldFont = dc.SelectObject(&m_fontBoldSmaller); #define DrawClientPercentText dc.DrawText(buffer, buffer.GetLength(),&cur_rec, ((MLC_DT_TEXT | DT_RIGHT) & ~DT_LEFT) | DT_CENTER) cur_rec.top-=1;cur_rec.bottom-=1; DrawClientPercentText;cur_rec.left+=1;cur_rec.right+=1; DrawClientPercentText;cur_rec.left+=1;cur_rec.right+=1; DrawClientPercentText;cur_rec.top+=1;cur_rec.bottom+=1; DrawClientPercentText;cur_rec.top+=1;cur_rec.bottom+=1; DrawClientPercentText;cur_rec.left-=1;cur_rec.right-=1; DrawClientPercentText;cur_rec.left-=1;cur_rec.right-=1; DrawClientPercentText;cur_rec.top-=1;cur_rec.bottom-=1; DrawClientPercentText;cur_rec.left++;cur_rec.right++; dc.SetTextColor(RGB(255,255,255)); DrawClientPercentText; dc.SelectObject(pOldFont); dc.SetBkMode(iOMode); dc.SetTextColor(oldclr); } } //Xman end cur_rec.bottom++; cur_rec.top--; } break; default: // ==> Design Settings [eWombat/Stulle] - Stulle /* //Xman PowerRelease //Xman show LowIDs if(iColumn == 1) { const CKnownFile *file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID()); if(file && file->GetUpPriority()==PR_POWER) dc.SetBkColor(RGB(255,225,225)); } else if(iColumn == 10 && client->HasLowID()) dc.SetBkColor(RGB(255,250,200)); //Xman end */ // <== Design Settings [eWombat/Stulle] - Stulle dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment); // ==> Design Settings [eWombat/Stulle] - Stulle /* dc.SetBkColor(crOldBackColor); //Xman PowerRelease //Xman show LowIDs */ // <== Design Settings [eWombat/Stulle] - Stulle break; } } cur_rec.left += iColumnWidth; } } DrawFocusRect(dc, lpDrawItemStruct->rcItem, lpDrawItemStruct->itemState & ODS_FOCUS, bCtrlFocused, lpDrawItemStruct->itemState & ODS_SELECTED); }
bool CBOINCListCtrl::OnSaveState(wxConfigBase* pConfig) { wxString strBaseConfigLocation = wxEmptyString; wxInt32 iIndex = 0; wxInt32 iStdColumnCount = 0; wxInt32 iActualColumnCount = GetColumnCount(); int i, j; wxASSERT(pConfig); // Retrieve the base location to store configuration information // Should be in the following form: "/Projects/" strBaseConfigLocation = pConfig->GetPath() + wxT("/"); iStdColumnCount = m_pParentView->m_iStdColWidthOrder.size(); // Cycle through the columns recording their widths for (iIndex = 0; iIndex < iActualColumnCount; iIndex++) { m_pParentView->m_iStdColWidthOrder[m_pParentView->m_iColumnIndexToColumnID[iIndex]] = GetColumnWidth(iIndex); } for (iIndex = 0; iIndex < iStdColumnCount; iIndex++) { pConfig->SetPath(strBaseConfigLocation + m_pParentView->m_aStdColNameOrder->Item(iIndex)); pConfig->Write(wxT("Width"), m_pParentView->m_iStdColWidthOrder[iIndex]); } // Save sorting column and direction pConfig->SetPath(strBaseConfigLocation); pConfig->Write(wxT("SortColumn"), m_pParentView->m_iSortColumnID); pConfig->Write(wxT("ReverseSortOrder"), m_pParentView->m_bReverseSort); // Save Column Order wxString strColumnOrder; wxString strBuffer; wxString strHiddenColumns; wxArrayInt aOrder(iActualColumnCount); CBOINCBaseView* pView = (CBOINCBaseView*)GetParent(); wxASSERT(wxDynamicCast(pView, CBOINCBaseView)); #ifdef wxHAS_LISTCTRL_COLUMN_ORDER aOrder = GetColumnsOrder(); #else for (i = 0; i < iActualColumnCount; ++i) { aOrder[i] = i; } #endif strColumnOrder.Printf(wxT("%s"), pView->m_aStdColNameOrder->Item(pView->m_iColumnIndexToColumnID[aOrder[0]])); for (i = 1; i < iActualColumnCount; ++i) { strBuffer.Printf(wxT(";%s"), pView->m_aStdColNameOrder->Item(pView->m_iColumnIndexToColumnID[aOrder[i]])); strColumnOrder += strBuffer; } pConfig->Write(wxT("ColumnOrder"), strColumnOrder); strHiddenColumns = wxEmptyString; for (i = 0; i < iStdColumnCount; ++i) { bool found = false; for (j = 0; j < iActualColumnCount; ++j) { if (pView->m_iColumnIndexToColumnID[aOrder[j]] == i) { found = true; break; } } if (found) continue; if (!strHiddenColumns.IsEmpty()) { strHiddenColumns += wxT(";"); } strHiddenColumns += pView->m_aStdColNameOrder->Item(i); } pConfig->Write(wxT("HiddenColumns"), strHiddenColumns); return true; }
void CUploadListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (!theApp.emuledlg->IsRunning()) return; if (!lpDrawItemStruct->itemData) return; CMemDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem); BOOL bCtrlFocused; InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused); CRect cur_rec(lpDrawItemStruct->rcItem); CRect rcClient; GetClientRect(&rcClient); const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData; COLORREF crOldBackColor = dc->GetBkColor(); //Xman PowerRelease CKnownFile* file = CGlobalVariable::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 && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 8; else image = 7; } else if (client->GetClientSoft() == SO_MLDONKEY) { if (client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 6; else image = 5; } else if (client->GetClientSoft() == SO_SHAREAZA) { if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 10; else image = 9; } else if (client->GetClientSoft() == SO_AMULE) { if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 12; else image = 11; } else if (client->GetClientSoft() == SO_LPHANT) { if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 14; else image = 13; } else if (client->ExtProtocolAvailable()) { if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1) image = 3; else image = 1; } else { if (client->credits && 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; POINT point = {cur_rec.left, cur_rec.top+1}; imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0)); Sbuffer = client->GetUserName(); //EastShare Start - added by AndCycle, IP to Country CString tempStr; tempStr.Format(_T("%s%s"), client->GetCountryName(), Sbuffer); Sbuffer = tempStr; if(CGlobalVariable::ip2country->ShowCountryFlag()) { cur_rec.left += 20; POINT point2= {cur_rec.left,cur_rec.top+1}; CGlobalVariable::ip2country->GetFlagImageList()->DrawIndirect(dc, client->GetCountryFlagIndex(), point2, CSize(18,16), CPoint(0,0), ILD_NORMAL); } //EastShare End - added by AndCycle, IP to Country cur_rec.left += 20; dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT); cur_rec.left -= 20; //EastShare Start - added by AndCycle, IP to Country if(CGlobalVariable::ip2country->ShowCountryFlag()) { cur_rec.left-=20; } //EastShare End - added by AndCycle, IP to Country break; } case 1: if (file) Sbuffer = file->GetFileName(); else Sbuffer = _T("?"); if(file && file->GetUpPriority()==PR_POWER) ///PowerRelease dc->SetBkColor(RGB(255,225,225)); 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); dc->SetBkColor( crOldBackColor ); 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);*/ }
void CBOINCListCtrl::DrawProgressBars() { long topItem, numItems, numVisibleItems, row; wxRect r, rr; int w = 0, x = 0, xx, yy, ww; int progressColumn = -1; if (m_pParentView->GetProgressColumn() >= 0) { progressColumn = m_pParentView->m_iColumnIDToColumnIndex[m_pParentView->GetProgressColumn()]; } #if USE_NATIVE_LISTCONTROL wxClientDC dc(this); m_bProgressBarEventPending = false; #else wxClientDC dc(GetMainWin()); // Available only in wxGenericListCtrl #endif if (progressColumn < 0) { m_iRowsNeedingProgressBars.Clear(); return; } int n = (int)m_iRowsNeedingProgressBars.GetCount(); if (n <= 0) return; wxColour progressColor = wxTheColourDatabase->Find(wxT("LIGHT BLUE")); wxBrush progressBrush(progressColor); numItems = GetItemCount(); if (numItems) { topItem = GetTopItem(); // Doesn't work properly for Mac Native control in wxMac-2.8.7 numVisibleItems = GetCountPerPage(); ++numVisibleItems; if (numItems <= (topItem + numVisibleItems)) numVisibleItems = numItems - topItem; x = 0; int progressColumnPosition = GetColumnOrder(progressColumn); for (int i=0; i<progressColumnPosition; i++) { x += GetColumnWidth(GetColumnIndexFromOrder(i)); } w = GetColumnWidth(progressColumn); #if USE_NATIVE_LISTCONTROL x -= GetScrollPos(wxHORIZONTAL); #else CalcScrolledPosition(x, 0, &x, &yy); #endif wxFont theFont = GetFont(); dc.SetFont(theFont); for (int i=0; i<n; ++i) { row = m_iRowsNeedingProgressBars[i]; if (row < topItem) continue; if (row > (topItem + numVisibleItems -1)) continue; GetItemRect(row, r); #if ! USE_NATIVE_LISTCONTROL r.y = r.y - GetHeaderHeight() - 1; #endif r.x = x; r.width = w; r.Inflate(-1, -2); rr = r; wxString progressString = m_pParentView->GetProgressText(row); dc.GetTextExtent(progressString, &xx, &yy); r.y += (r.height - yy - 1) / 2; // Adapted from ellipis code in wxRendererGeneric::DrawHeaderButtonContents() if (xx > r.width) { int ellipsisWidth; dc.GetTextExtent( wxT("..."), &ellipsisWidth, NULL); if (ellipsisWidth > r.width) { progressString.Clear(); xx = 0; } else { do { progressString.Truncate( progressString.length() - 1 ); dc.GetTextExtent( progressString, &xx, &yy); } while (xx + ellipsisWidth > r.width && progressString.length() ); progressString.append( wxT("...") ); xx += ellipsisWidth; } } dc.SetLogicalFunction(wxCOPY); dc.SetBackgroundMode(wxSOLID); dc.SetPen(progressColor); dc.SetBrush(progressBrush); dc.DrawRectangle( rr ); rr.Inflate(-2, -1); ww = rr.width * m_pParentView->GetProgressValue(row); rr.x += ww; rr.width -= ww; #if 0 // Show background stripes behind progress bars wxListItemAttr* attr = m_pParentView->FireOnListGetItemAttr(row); wxColour bkgd = attr->GetBackgroundColour(); dc.SetPen(bkgd); dc.SetBrush(bkgd); #else dc.SetPen(*wxWHITE_PEN); dc.SetBrush(*wxWHITE_BRUSH); #endif dc.DrawRectangle( rr ); dc.SetPen(*wxBLACK_PEN); dc.SetBackgroundMode(wxTRANSPARENT); if (xx > (r.width - 7)) { dc.DrawText(progressString, r.x, r.y); } else { dc.DrawText(progressString, r.x + (w - 8 - xx), r.y); } } } m_iRowsNeedingProgressBars.Clear(); }
int ListBox::OnLButtonDown(int x, int y) { if (!captured) captured = SetCapture(); mouse_x = x - rect.x; mouse_y = y - rect.y; int x_scroll_bar = rect.w; if (IsScrollVisible()) x_scroll_bar -= SCROLL_WIDTH; if (mouse_x < x_scroll_bar) { scrolling = SCROLL_NONE; if (show_headings && mouse_y < line_height+BORDER_WIDTH+EXTRA_WIDTH) { int next_col_start = 0; int max_column = columns.size()-1; int column; for (column = 0; column < max_column; column++) { next_col_start += GetColumnWidth(column); if (mouse_x < next_col_start) break; } sort_column = column; int& sort_criteria = columns[sort_column]->sort; if (sort_criteria != LIST_SORT_NEVER) { if (!sort_criteria) sort_criteria = LIST_SORT_ALPHA_DESCENDING; else sort_criteria = -sort_criteria; SortItems(); } } else { selecting = true; } } else { selecting = false; if (mouse_y < TRACK_START) { scrolling = SCROLL_UP; Scroll(scrolling, 1); Button::PlaySound(Button::SND_LIST_SCROLL); } else if (mouse_y > rect.h-TRACK_START) { scrolling = SCROLL_DOWN; if (top_index < items.size()-1) top_index++; Button::PlaySound(Button::SND_LIST_SCROLL); } else if (mouse_y < thumb_pos) { scrolling = SCROLL_PAGE_UP; Scroll(scrolling, page_size); Button::PlaySound(Button::SND_LIST_SCROLL); } else if (mouse_y > thumb_pos+THUMB_HEIGHT) { scrolling = SCROLL_PAGE_DOWN; Scroll(scrolling, page_size); Button::PlaySound(Button::SND_LIST_SCROLL); } else { scrolling = SCROLL_THUMB; } } if (selecting) { list_index = IndexFromPoint(mouse_x, mouse_y); preselected = IsSelected(list_index); if (!multiselect || !Keyboard::KeyDown(VK_SHIFT)) ClearSelection(); SetSelected(list_index); EnsureVisible(list_index); Button::PlaySound(Button::SND_LIST_SELECT); } return ActiveWindow::OnLButtonDown(x,y); }
void CQueueListCtrl::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); 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; } POINT point = {cur_rec.left, cur_rec.top+1}; imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0)); 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: if(file){ switch (file->GetUpPriority()) { case PR_VERYLOW : { Sbuffer = GetResString(IDS_PRIOVERYLOW); break; } case PR_LOW : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOLOW); else Sbuffer = GetResString(IDS_PRIOLOW); break; } case PR_NORMAL : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTONORMAL); else Sbuffer = GetResString(IDS_PRIONORMAL); break; } case PR_HIGH : { if( file->IsAutoUpPriority() ) Sbuffer = GetResString(IDS_PRIOAUTOHIGH); else Sbuffer = GetResString(IDS_PRIOHIGH); break; } case PR_VERYHIGH : { Sbuffer = GetResString(IDS_PRIORELEASE); break; } default: Sbuffer.Empty(); } } else Sbuffer = _T("?"); break; case 3: Sbuffer.Format(_T("%i"),client->GetScore(false,false,true)); break; case 4: if (client->HasLowID()){ if (client->m_bAddNextConnect) Sbuffer.Format(_T("%i ****"),client->GetScore(false)); else Sbuffer.Format(_T("%i LowID"),client->GetScore(false)); } else Sbuffer.Format(_T("%i"),client->GetScore(false)); break; case 5: Sbuffer.Format(_T("%i"),client->GetAskedCount()); break; case 6: Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetLastUpRequest())/1000); break; case 7: Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetWaitStartTime())/1000); break; case 8: if(client->IsBanned()) Sbuffer = GetResString(IDS_YES); else Sbuffer = GetResString(IDS_NO); break; case 9: if( client->GetUpPartCount()){ cur_rec.bottom--; cur_rec.top++; client->DrawUpStatusBar(dc,&cur_rec,false,thePrefs.UseFlatBar()); cur_rec.bottom++; cur_rec.top--; } break; } if( iColumn != 9 && 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); }
void ListBox::DrawContent(const Rect& ctrl_rect) { SizeColumns(); Rect item_rect = ctrl_rect; item_rect.h = line_height; int h = rect.h; // draw headings at top, if needed: if (show_headings) { Color save_color = back_color; back_color = ShadeColor(back_color, 1.3); font->SetColor(fore_color); int max_column = columns.size()-1; item_rect.h += HEADING_EXTRA; page_size = (h-item_rect.h) / (line_height + leading); for (int column = 0; column <= max_column; column++) { item_rect.w = GetColumnWidth(column); // draw heading button FillRect(item_rect, back_color); DrawStyleRect(item_rect, WIN_RAISED_FRAME); Rect title_rect = item_rect; title_rect.Deflate(3,3); DrawText(GetColumnTitle(column), 0, title_rect, DT_CENTER|DT_SINGLELINE); item_rect.x += item_rect.w; } item_rect.y += item_rect.h; back_color = save_color; item_rect.h = line_height; } int index = 0; ListIter<ListBoxItem> iter = items; while (++iter && item_rect.y < h) { ListBoxItem* item = iter.value(); if (index++ >= top_index) { // draw main item: int column = 0; item_rect.x = ctrl_rect.x; item_rect.w = GetColumnWidth(column) - 2; if (item_rect.y + item_rect.h > h) { item_rect.h = h - item_rect.y - 1; } Color item_color = GetItemColor(index-1, 0); if (item->selected) { font->SetColor(selected_color); if (seln_style == LIST_ITEM_STYLE_FILLED_BOX) FillRect(item_rect, selected_color * 0.25); if (seln_style >= LIST_ITEM_STYLE_BOX) DrawRect(item_rect, selected_color); } else { font->SetColor(item_color); if (item_style == LIST_ITEM_STYLE_FILLED_BOX) FillRect(item_rect, item_color * 0.25); if (item_style >= LIST_ITEM_STYLE_BOX) DrawRect(item_rect, item_color); } Rect text_rect = item_rect; if (item->image && item->image->Width() > 0 && item->image->Height() > 0) { DrawBitmap(text_rect.x, text_rect.y, text_rect.x + text_rect.w, text_rect.y + line_height, item->image); } else { text_rect.Deflate(2,0); DrawText(item->text.data(), item->text.length(), text_rect, GetColumnAlign(column)|DT_SINGLELINE); } // draw subitems: ListIter<ListBoxCell> sub_iter = item->subitems; while (++sub_iter) { ListBoxCell* sub = sub_iter.value(); column++; item_rect.x += item_rect.w + 2; item_rect.w = GetColumnWidth(column) - 2; if (item->selected) { if (seln_style == LIST_ITEM_STYLE_FILLED_BOX) FillRect(item_rect, selected_color * 0.25); if (seln_style >= LIST_ITEM_STYLE_BOX) DrawRect(item_rect, selected_color); } else { if (item_style == LIST_ITEM_STYLE_FILLED_BOX) FillRect(item_rect, item_color * 0.25); if (item_style >= LIST_ITEM_STYLE_BOX) DrawRect(item_rect, item_color); } if (item->selected) font->SetColor(selected_color); else font->SetColor(GetItemColor(index-1, column)); Rect text_rect = item_rect; if (sub->image && sub->image->Width() > 0 && sub->image->Height() > 0) { DrawBitmap(text_rect.x, text_rect.y, text_rect.x + text_rect.w, text_rect.y + line_height, sub->image); } else { text_rect.Deflate(2,0); DrawText(sub->text.data(), sub->text.length(), text_rect, GetColumnAlign(column)|DT_SINGLELINE); } } item_rect.y += line_height + leading; } } }
// This shows a little tooltip with the current Game's emulation state void CGameListCtrl::OnMouseMotion(wxMouseEvent& event) { int flags; long subitem = 0; const long item = HitTest(event.GetPosition(), flags, &subitem); static int lastItem = -1; if (GetColumnCount() <= 1) return; if (item != wxNOT_FOUND) { wxRect Rect; #ifdef __WXMSW__ if (subitem == COLUMN_EMULATION_STATE) #else // The subitem parameter of HitTest is only implemented for wxMSW. On // all other platforms it will always be -1. Check the x position // instead. GetItemRect(item, Rect); if (Rect.GetX() + Rect.GetWidth() - GetColumnWidth(COLUMN_EMULATION_STATE) < event.GetX()) #endif { if (toolTip || lastItem == item || this != FindFocus()) { if (lastItem != item) lastItem = -1; event.Skip(); return; } // Emulation status static const char* const emuState[] = { "Broken", "Intro", "In-Game", "Playable", "Perfect" }; const GameListItem& rISO = *m_ISOFiles[GetItemData(item)]; const int emu_state = rISO.GetEmuState(); const std::string& issues = rISO.GetIssues(); // Show a tooltip containing the EmuState and the state description if (emu_state > 0 && emu_state < 6) { char temp[2048]; sprintf(temp, "^ %s%s%s", emuState[emu_state - 1], issues.size() > 0 ? " :\n" : "", issues.c_str()); toolTip = new wxEmuStateTip(this, StrToWxStr(temp), &toolTip); } else { toolTip = new wxEmuStateTip(this, _("Not Set"), &toolTip); } // Get item Coords GetItemRect(item, Rect); int mx = Rect.GetWidth(); int my = Rect.GetY(); #ifndef __WXMSW__ // For some reason the y position does not account for the header // row, so subtract the y position of the first visible item. GetItemRect(GetTopItem(), Rect); my -= Rect.GetY(); #endif // Convert to screen coordinates ClientToScreen(&mx, &my); toolTip->SetBoundingRect(wxRect(mx - GetColumnWidth(COLUMN_EMULATION_STATE), my, GetColumnWidth(COLUMN_EMULATION_STATE), Rect.GetHeight())); toolTip->SetPosition(wxPoint(mx - GetColumnWidth(COLUMN_EMULATION_STATE), my - 5 + Rect.GetHeight())); lastItem = item; } } if (!toolTip) lastItem = -1; event.Skip(); }
void CClientListCtrl::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); int iOldBkMode; if (m_crWindowTextBk == CLR_NONE){ DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0); iOldBkMode = dc.SetBkMode(TRANSPARENT); } else iOldBkMode = OPAQUE; 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 = 2; else if (client->GetClientSoft() == SO_EDONKEYHYBRID) image = 4; else if (client->GetClientSoft() == SO_MLDONKEY) image = 3; else if (client->GetClientSoft() == SO_SHAREAZA) image = 5; else if (client->GetClientSoft() == SO_URL) image = 6; else if (client->GetClientSoft() == SO_AMULE) image = 7; else if (client->GetClientSoft() == SO_LPHANT) image = 8; else if (client->ExtProtocolAvailable()) image = 1; else image = 0; uint32 nOverlayImage = 0; if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED)) nOverlayImage |= 1; if (client->IsObfuscatedConnectionEstablished()) nOverlayImage |= 2; POINT point = {cur_rec.left, cur_rec.top+1}; imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0)); if (client->GetUserName()==NULL) Sbuffer.Format(_T("(%s)"), GetResString(IDS_UNKNOWN)); else Sbuffer = client->GetUserName(); //EastShare Start - added by AndCycle, IP to Country CString tempStr; tempStr.Format(_T("%s%s"), client->GetCountryName(), Sbuffer); Sbuffer = tempStr; if(CGlobalVariable::ip2country->ShowCountryFlag()){ cur_rec.left+=20; POINT point2= {cur_rec.left,cur_rec.top+1}; CGlobalVariable::ip2country->GetFlagImageList()->DrawIndirect(dc, client->GetCountryFlagIndex(), point2, CSize(18,16), CPoint(0,0), ILD_NORMAL); } //EastShare End - added by AndCycle, IP to Country cur_rec.left +=20; dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT); cur_rec.left -=20; //EastShare Start - added by AndCycle, IP to Country if(CGlobalVariable::ip2country->ShowCountryFlag()){ cur_rec.left-=20; } //EastShare End - added by AndCycle, IP to Country break; } case 1:{ Sbuffer = client->GetUploadStateDisplayString(); break; } case 2:{ if(client->credits) Sbuffer = CastItoXBytes(client->credits->GetUploadedTotal(), false, false); else Sbuffer.Empty(); break; } case 3:{ Sbuffer = client->GetDownloadStateDisplayString(); break; } case 4:{ if(client->credits) Sbuffer = CastItoXBytes(client->credits->GetDownloadedTotal(), false, false); else Sbuffer.Empty(); break; } case 5:{ Sbuffer = client->GetClientSoftVer(); if (Sbuffer.IsEmpty()) Sbuffer = GetResString(IDS_UNKNOWN); break; } case 6:{ if(client->socket){ if(client->socket->IsConnected()){ Sbuffer = GetResString(IDS_YES); break; } } Sbuffer = GetResString(IDS_NO); break; } case 7: Sbuffer = md4str(client->GetUserHash()); break; } if( 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); }
//绘画函数 void CHappyGoDlgT::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (lpDrawItemStruct->CtlType==ODT_LISTVIEW) { //获取数据 UINT iWidth=0; TCHAR szBuffer[30]; CSize TextSize; memset(szBuffer,0,sizeof(szBuffer)); CDC * pDC=CDC::FromHandle(lpDrawItemStruct->hDC); CRect rect; GetClientRect(&rect); CDC memDC; memDC.CreateCompatibleDC(pDC); CBitmap Screen; Screen.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()); memDC.SelectObject(&Screen); CFont *pOldFont = memDC.SelectObject(&m_Font); Screen.DeleteObject(); memDC.SetBkMode(TRANSPARENT); memDC.FillSolidRect(&rect,RGB(255,0,255)); //设置颜色 COLORREF crTextColor,crBackColor; bool bSelect=(lpDrawItemStruct->itemState&ODS_SELECTED);//||(lpDrawItemStruct->itemState&ODS_FOCUS); GetDrawColor(crTextColor,crBackColor,0,bSelect); memDC.SetBkColor(crBackColor); memDC.SetTextColor(crTextColor); //memDC.SelectObject(m_Font); memDC.SetBkMode(TRANSPARENT); // 绘制背景 if(lpDrawItemStruct->itemID % 2 == 0) memDC.FillSolidRect(lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.top, lpDrawItemStruct->rcItem.right-lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top,RGB(154,169,200)); else memDC.FillSolidRect(lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.top, lpDrawItemStruct->rcItem.right-lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top,RGB(213,218,238)); //绘画信息 if(bSelect) { memDC.FillSolidRect(lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.top, lpDrawItemStruct->rcItem.right-lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top,crBackColor); } for (int i=0;i<m_ListHeader.GetItemCount();i++) { int iTemp=GetColumnWidth(i); if(m_processpos == i) { TextSize=pDC->GetTextExtent(szBuffer,lstrlen(szBuffer)); GetItemText(lpDrawItemStruct->itemID,i,szBuffer,sizeof(szBuffer)); CRect TextRect(lpDrawItemStruct->rcItem.left+iWidth,lpDrawItemStruct->rcItem.top,lpDrawItemStruct->rcItem.left+iWidth+iTemp,lpDrawItemStruct->rcItem.bottom); if(!m_probgImage.IsNull() && !m_proImage.IsNull()) { m_probgImage.Draw(memDC, CRect(TextRect.left,TextRect.top,TextRect.left+m_probgImage.GetWidth(),TextRect.top+m_probgImage.GetHeight()), CRect(0,0,m_probgImage.GetWidth(),m_probgImage.GetHeight())); int length = (int)(m_probgImage.GetWidth() * (m_ProgressList[lpDrawItemStruct->itemID] / 100.0f)); int count = length / m_proImage.GetWidth() - 2; for(int i=0;i<count;i++) { m_proImage.Draw(memDC,TextRect.left+i*m_proImage.GetWidth()+1,TextRect.top); } char buff[128]; sprintf(buff,"%d",m_ProgressList[lpDrawItemStruct->itemID]); strcat(buff," %"); memDC.DrawText(buff,lstrlen(buff),TextRect,DT_RIGHT|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); } iWidth+=iTemp; continue; } else { TextSize=pDC->GetTextExtent(szBuffer,lstrlen(szBuffer)); GetItemText(lpDrawItemStruct->itemID,i,szBuffer,sizeof(szBuffer)); CRect TextRect(lpDrawItemStruct->rcItem.left+iWidth,lpDrawItemStruct->rcItem.top,lpDrawItemStruct->rcItem.left+iWidth+iTemp,lpDrawItemStruct->rcItem.bottom); memDC.DrawText(szBuffer,lstrlen(szBuffer),&TextRect,DT_CENTER|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); iWidth+=iTemp; } } pDC->TransparentBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, rect.left,rect.top,rect.Width(),rect.Height(),RGB(255,0,255)); memDC.SelectObject(pOldFont); //dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY); memDC.DeleteDC(); } return; }
CAlphaCharEdit* CLinFlexListCtrl::pomAlphaNumericChar( int nItem, int nSubItem) { CRect omRect; // Set the item to be visible if(!EnsureVisible(nItem, TRUE)) { return NULL; } // Get the item rect GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, omRect); sUserProgInfo ouUserProg; bool bIsIconAvail = false; if( m_omUserProg.Lookup(lGetMapID(nItem, nSubItem) , ouUserProg) == TRUE ) { bIsIconAvail = ouUserProg.m_bIcon; } if ( true == bIsIconAvail ) { CRect omRect2; GetSubItemRect(nItem, nSubItem, LVIR_ICON , omRect2); omRect.left = omRect2.right; //omRect.right = omRect2.right; } else { omRect.right = omRect.left + GetColumnWidth(nSubItem); } // Now scroll if we need to expose the column CRect omClientRect; GetClientRect(omClientRect); if( omRect.left < 0 || omRect.left > omClientRect.right ) { CSize size( omRect.left, 0 ); Scroll( size ); omRect.left -= size.cx; } if(omRect.right > omClientRect.right) { omRect.right = omClientRect.right; } // Get Column alignment LV_COLUMN lvcol; lvcol.mask = LVCF_FMT; GetColumn(nSubItem, &lvcol); DWORD dwStyle; if((lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT) { dwStyle = ES_LEFT; } else if((lvcol.fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_RIGHT) { dwStyle = ES_RIGHT; } else { dwStyle = ES_CENTER; } // Set the standard windows style dwStyle |=WS_BORDER|WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL; // Get the selected item text CString omStrText = GetItemText(nItem, nSubItem); // Create the control CAlphaCharEdit* pomEdit2 = NULL; SNUMERICINFO info; info.m_uMaxVal.m_n64Value = 5; info.m_uMaxVal.m_n64Value = 0; //omStrText = ""; CAlphaCharEdit* pomEdit = new CAlphaCharEdit(nItem, nSubItem, omStrText); if( pomEdit != NULL ) { pomEdit->Create(WS_BORDER|WS_CHILD | WS_VISIBLE, omRect, this, IDC_CONTROL); pomEdit->SetLimitText(1); pomEdit->SetFocus(); } else { CString omStrErr; omStrErr.Format( _(defFLC_CREATE_FAILED), defNUM_ITEM ); AfxMessageBox( omStrErr ); } // Return the window pointer return pomEdit2; }