UINT CGridCell::GetMargin() const { if (m_nMargin == (UINT)-1) { CGridDefaultCell *pDefaultCell = (CGridDefaultCell*) GetDefaultCell(); if (!pDefaultCell) return 0; return pDefaultCell->GetMargin(); } return m_nMargin; }
DWORD CGridCell::GetFormat() const { if (m_nFormat == (DWORD)-1) { CGridDefaultCell *pDefaultCell = (CGridDefaultCell*) GetDefaultCell(); if (!pDefaultCell) return 0; return pDefaultCell->GetFormat(); } return m_nFormat; }
LOGFONT* CGridCell::GetFont() const { if (m_plfFont == NULL) { CGridDefaultCell *pDefaultCell = (CGridDefaultCell*) GetDefaultCell(); if (!pDefaultCell) return NULL; return pDefaultCell->GetFont(); } return m_plfFont; }
void NewCreds_OnInitDialog (HWND hDlg) { LPTSTR pszCell = (LPTSTR)GetWindowLongPtr (hDlg, DWLP_USER); if (!pszCell) pszCell = TEXT(""); if (GetDlgItem (hDlg, IDC_NEWCREDS_TITLE)) { TCHAR szText[ cchRESOURCE ]; GetDlgItemText (hDlg, IDC_NEWCREDS_TITLE, szText, cchRESOURCE); LPTSTR pszText = FormatString (szText, TEXT("%s"), pszCell); SetDlgItemText (hDlg, IDC_NEWCREDS_TITLE, pszText); FreeString (pszText); } if (pszCell && *pszCell) { SetDlgItemText (hDlg, IDC_NEWCREDS_CELL, pszCell); } else { TCHAR szCell[ cchRESOURCE ] = TEXT(""); (void)GetDefaultCell (szCell); SetDlgItemText (hDlg, IDC_NEWCREDS_CELL, szCell); } lock_ObtainMutex(&g.credsLock); size_t iCreds; for (iCreds = 0; iCreds < g.cCreds; ++iCreds) { if (*pszCell && !lstrcmpi (g.aCreds[ iCreds ].szCell, pszCell)) break; } if ((iCreds == g.cCreds) || (!g.aCreds[ iCreds ].szUser[0])) { PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (hDlg, IDC_NEWCREDS_USER), TRUE); } else // (we have a valid username already) { SetDlgItemText (hDlg, IDC_NEWCREDS_USER, g.aCreds[ iCreds ].szUser); PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (hDlg, IDC_NEWCREDS_PASSWORD), TRUE); } lock_ReleaseMutex(&g.credsLock); NewCreds_OnEnable (hDlg); SetForegroundWindow(hDlg); KillTimer (g.hMain, ID_SERVICE_TIMER); }
CFont* CGridCell::GetFontObject() const { // If the default font is specified, use the default cell implementation if (m_plfFont == NULL) { CGridDefaultCell *pDefaultCell = (CGridDefaultCell*) GetDefaultCell(); if (!pDefaultCell) return NULL; return pDefaultCell->GetFontObject(); } else { static CFont Font; Font.DeleteObject(); Font.CreateFontIndirect(m_plfFont); return &Font; } }
// EFW - Various changes to make it draw cells better when using alternate // color schemes. Also removed printing references as that's now done // by PrintCell() and fixed the sort marker so that it doesn't draw out // of bounds. BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBkgnd /*=TRUE*/) { // Note - all through this function we totally brutalise 'rect'. Do not // depend on it's value being that which was passed in. //Used for merge cells //by Huang Wei if( m_Hide && !IsMerged()) { return TRUE; } CGridCtrl* pGrid = GetGrid(); ASSERT(pGrid); if (!pGrid || !pDC) return FALSE; if( rect.Width() <= 0 || rect.Height() <= 0) // prevents imagelist item from drawing even return FALSE; // though cell is hidden //TRACE3("Drawing %scell %d, %d\n", IsFixed()? _T("Fixed ") : _T(""), nRow, nCol); int nSavedDC = pDC->SaveDC(); pDC->SetBkMode(TRANSPARENT); // Get the default cell implementation for this kind of cell. We use it if this cell // has anything marked as "default" CGridDefaultCell *pDefaultCell = (CGridDefaultCell*) GetDefaultCell(); if (!pDefaultCell) return FALSE; // Set up text and background colours COLORREF TextClr, TextBkClr; TextClr = (GetTextClr() == CLR_DEFAULT)? pDefaultCell->GetTextClr() : GetTextClr(); if (GetBackClr() == CLR_DEFAULT) TextBkClr = pDefaultCell->GetBackClr(); else { bEraseBkgnd = TRUE; TextBkClr = GetBackClr(); } // Draw cell background and highlighting (if necessary) if ( IsFocused() || IsDropHighlighted() ) { // Always draw even in list mode so that we can tell where the // cursor is at. Use the highlight colors though. if(GetState() & GVIS_SELECTED) { TextBkClr = ::GetSysColor(COLOR_HIGHLIGHT); TextClr = ::GetSysColor(COLOR_HIGHLIGHTTEXT); bEraseBkgnd = TRUE; } rect.right++; rect.bottom++; // FillRect doesn't draw RHS or bottom if (bEraseBkgnd) { TRY { CBrush brush(TextBkClr); pDC->FillRect(rect, &brush); } CATCH(CResourceException, e) { //e->ReportError(); } END_CATCH } // Don't adjust frame rect if no grid lines so that the // whole cell is enclosed. if(pGrid->GetGridLines() != GVL_NONE) { rect.right--; rect.bottom--; } if (pGrid->GetFrameFocusCell()) { // Use same color as text to outline the cell so that it shows // up if the background is black. TRY { CBrush brush(TextClr); pDC->FrameRect(rect, &brush); } CATCH(CResourceException, e) { //e->ReportError(); } END_CATCH } pDC->SetTextColor(TextClr); // Adjust rect after frame draw if no grid lines if(pGrid->GetGridLines() == GVL_NONE) { rect.right--; rect.bottom--; } //rect.DeflateRect(0,1,1,1); - Removed by Yogurt }
// This hack allows you to determine the height that a cell should be in order to display // stuff properly in the given width. CSize CGridCellMultiLine::GetTextExtentEx(int width, LPCTSTR szText, CDC* pDC /*= NULL*/) { CGridCtrl* pGrid = GetGrid(); ASSERT(pGrid); BOOL bReleaseDC = FALSE; if (pDC == NULL) { pDC = pGrid->GetDC(); if (!pDC) { CGridDefaultCell* pDefCell = (CGridDefaultCell*) GetDefaultCell(); ASSERT(pDefCell); return CSize(pDefCell->GetWidth(), pDefCell->GetHeight()); } bReleaseDC = TRUE; } CFont *pOldFont = NULL, *pFont = GetFontObject(); if (pFont) pOldFont = pDC->SelectObject(pFont); CSize size; int nFormat = GetFormat(); TEXTMETRIC tm; pDC->GetTextMetrics(&tm); int textWidth = width - (4*GetMargin ()); // corrects the bug if resizing column gives a text width smaller than (4*Getmargin()) if (textWidth <= 0) { textWidth = 1; } // If the cell is a multiline cell, then use the width of the cell // to get the height if ((nFormat & DT_WORDBREAK) && !(nFormat & DT_SINGLELINE)) { CRect rect; rect.SetRect(0, 0, textWidth, 0); pDC->DrawText(szText, -1, rect, nFormat | DT_CALCRECT); size.cx = rect.Width (); size.cy = rect.Height (); } else size = pDC->GetTextExtent(szText, _tcslen(szText)); size.cx += (tm.tmOverhang); if (pOldFont) pDC->SelectObject(pOldFont); size += CSize(4*GetMargin(), 2*GetMargin()); // Kludge for vertical text LOGFONT *pLF = GetFont(); if (pLF->lfEscapement == 900 || pLF->lfEscapement == -900) { int nTemp = size.cx; size.cx = size.cy; size.cy = nTemp; size += CSize(0, 4*GetMargin()); } if (bReleaseDC) pGrid->ReleaseDC(pDC); return size; }