Index: src/ch/PropertyListCtrl.cpp =================================================================== diff -u -rd5c3edd0d167db9b5d47d04248820fda49499a5e -r9ddf8fdd5f641491dd30c49eb90f8f740314b6af --- src/ch/PropertyListCtrl.cpp (.../PropertyListCtrl.cpp) (revision d5c3edd0d167db9b5d47d04248820fda49499a5e) +++ src/ch/PropertyListCtrl.cpp (.../PropertyListCtrl.cpp) (revision 9ddf8fdd5f641491dd30c49eb90f8f740314b6af) @@ -20,6 +20,7 @@ #include "ch.h" #include "PropertyListCtrl.h" #include "dialogs.h" +#include "memdc.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -38,13 +39,10 @@ // Delete the objects created delete m_pBkBrush; delete m_pBlackBrush; -// delete m_pGrayPen; delete m_pBkPen; } BEGIN_MESSAGE_MAP(CComboButton, CButton) - //{{AFX_MSG_MAP(CComboButton) - //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// @@ -54,13 +52,12 @@ // Create the Brushes and Pens m_pBkBrush = new CBrush( GetSysColor(COLOR_BTNFACE)); m_pBkPen = new CPen( PS_SOLID, 1, GetSysColor(COLOR_BTNFACE)); -// m_pGrayPen = new CPen( PS_SOLID, 1, RGB(128,128,128)); m_pBlackBrush = new CBrush(GetSysColor(COLOR_BTNTEXT)); - // Create the CButton + // Create the CButton if( !CButton::Create(_T(""), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW, Rect, pParent, uID )) return FALSE; - + return 0; } @@ -72,12 +69,12 @@ CRect ButtonRect = lpDrawItemStruct->rcItem; CMemDC dc(prDC, ButtonRect); CMemDC *pDC=&dc; - + // Fill the Background CBrush* pOldBrush = (CBrush*)pDC->SelectObject( m_pBkBrush ); CPen* pOldPen = (CPen*)pDC->SelectObject(m_pBkPen); pDC->Rectangle(ButtonRect); - + // Draw the Correct Border if(lpDrawItemStruct->itemState & ODS_SELECTED) { @@ -126,29 +123,6 @@ // CPropertyListCtrl CPropertyListCtrl::CPropertyListCtrl() { - m_nWidestItem = 0; - m_bDeleteFont = TRUE; - m_bBoldSelection = TRUE; - - m_pBkBrush = NULL; - m_pBkPropertyBrush = NULL; - m_pEditWnd = NULL; - m_pFontButton = NULL; - m_pPathButton = NULL; - m_pDirButton=NULL; - m_pCustomButton=NULL; - m_pComboButton = NULL; - m_pListBox = NULL; - m_pBkHighlightBrush = NULL; - m_pSelectedFont = NULL; - m_pBorderPen = NULL; - m_pCurItem = NULL; - m_pCurFont = NULL; - m_pCurDrawItem = NULL; - m_pTextFont = NULL; - m_pSelectedFont = NULL; - m_pBorderPen = NULL; - m_crBorderColor = RGB(192,192,192); m_crBkColor = GetSysColor(COLOR_WINDOW); m_crPropertyBkColor = m_crBkColor; @@ -210,24 +184,24 @@ m_bDeleteFont = TRUE; m_bBoldSelection = TRUE; - m_pBkBrush = NULL; - m_pBkPropertyBrush = NULL; - m_pEditWnd = NULL; - m_pFontButton = NULL; - m_pPathButton = NULL; - m_pDirButton=NULL; - m_pCustomButton=NULL; - m_pComboButton = NULL; - m_pListBox = NULL; - m_pBkHighlightBrush = NULL; - m_pSelectedFont = NULL; - m_pBorderPen = NULL; - m_pCurItem = NULL; - m_pCurFont = NULL; - m_pCurDrawItem = NULL; - m_pTextFont = NULL; - m_pSelectedFont = NULL; - m_pBorderPen = NULL; + m_pBkBrush = nullptr; + m_pBkPropertyBrush = nullptr; + m_pEditWnd = nullptr; + m_pFontButton = nullptr; + m_pPathButton = nullptr; + m_pDirButton=nullptr; + m_pCustomButton=nullptr; + m_pComboButton = nullptr; + m_pListBox = nullptr; + m_pBkHighlightBrush = nullptr; + m_pSelectedFont = nullptr; + m_pBorderPen = nullptr; + m_pCurItem = nullptr; + m_pCurFont = nullptr; + m_pCurDrawItem = nullptr; + m_pTextFont = nullptr; + m_pSelectedFont = nullptr; + m_pBorderPen = nullptr; m_crBorderColor = RGB(192,192,192); m_crBkColor = GetSysColor(COLOR_WINDOW); @@ -297,29 +271,29 @@ if(m_pBkPropertyBrush) return (HBRUSH)(m_pBkPropertyBrush->GetSafeHandle() ); - else - return hbr; + + return hbr; } void CPropertyListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // Make sure its a valid item if( lpDrawItemStruct->itemID == LB_ERR ) return; - - // Obtain the text for this item + + // Obtain the text for this item m_csText.Empty(); GetText(lpDrawItemStruct->itemID, m_csText); // Get the drawing DC CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); - + // Set the Current member we are drawing - m_pCurDrawItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(lpDrawItemStruct->itemID)); - + m_pCurDrawItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(lpDrawItemStruct->itemID)); + // Obtain the Item Rect CRect ItemRect(lpDrawItemStruct->rcItem); - - // Draw This item + + // Draw This item DrawItem( pDC, ItemRect, lpDrawItemStruct->itemState & ODS_SELECTED); } void CPropertyListCtrl::MeasureItem(LPMEASUREITEMSTRUCT /*lpMeasureItemStruct*/) @@ -335,6 +309,9 @@ CRect TempRect = m_CurRect; MapWindowPoints(GetDesktopWindow(), TempRect); + if(!m_pCurItem) + return; + // Display the Correct Control switch(m_pCurItem->nType) { @@ -400,6 +377,10 @@ // Display the Correct Control CRect TempRect = m_CurRect; TempRect.InflateRect(-1,-1); + + if(!m_pCurItem) + return; + switch(m_pCurItem->nType) { case ID_PROPERTY_TEXT: @@ -460,7 +441,7 @@ if(m_pCurItem->csProperties.GetSize() > 5) TempRect.bottom += GetItemHeight(0) * 5; else - TempRect.bottom += GetItemHeight(0) * m_pCurItem->csProperties.GetSize(); + TempRect.bottom += GetItemHeight(0) * boost::numeric_cast(m_pCurItem->csProperties.GetSize()); // pobierz wsp�rz�dne tej kontrolki w stosunku do okna parenta // CRect rcThisParent; @@ -513,7 +494,7 @@ return; // Add it and select it - m_pCurItem->nPropertySelected = m_pCurItem->csProperties.Add(csText); + m_pCurItem->nPropertySelected = boost::numeric_cast(m_pCurItem->csProperties.Add(csText)); } } void CPropertyListCtrl::OnEditChange() @@ -550,9 +531,9 @@ QuizFileDlg.m_ofn.lpstrInitialDir = csPath; if(QuizFileDlg.DoModal() != IDOK) return; - + // Obtain the Path they selected - m_pCurItem->csProperties.SetAt(0, QuizFileDlg.GetPathName()); + m_pCurItem->csProperties.SetAt(0, QuizFileDlg.GetPathName()); // Redraw RedrawWindow(); @@ -756,7 +737,7 @@ BOOL CPropertyListCtrl::AddString(UINT nIDString) { - return AddString(GetResManager()->LoadString(nIDString)); + return AddString(GetResManager().LoadString(nIDString)); } BOOL CPropertyListCtrl::AddString(UINT nIDString, int nType, CString csData, void (*pfnCallback)(LPVOID, int, CPtrList*, int), LPVOID lpParam, int iParam, int nPropertySelected, int nAlignment, BOOL bComboEditable) @@ -766,13 +747,13 @@ return FALSE; // load string - const TCHAR *pszText=GetResManager()->LoadString(nIDString); + const TCHAR *pszText=GetResManager().LoadString(nIDString); // Create a new Structure to hold it PROPERTYITEM* pNewItem = new PROPERTYITEM; pNewItem->nType = nType; pNewItem->nAlignment = nAlignment; - pNewItem->pBrush = NULL; + pNewItem->pBrush = nullptr; pNewItem->bComboEditable = bComboEditable; pNewItem->pfnCallback=pfnCallback; pNewItem->iParam=iParam; @@ -823,7 +804,7 @@ PROPERTYITEM* pNewItem = new PROPERTYITEM; pNewItem->nType = nType; pNewItem->nAlignment = nAlignment; - pNewItem->pBrush = NULL; + pNewItem->pBrush = nullptr; pNewItem->bComboEditable = bComboEditable; // Calculate the Width of the string based on the font set @@ -863,12 +844,12 @@ BOOL CPropertyListCtrl::AddString(UINT nIDString, int nType, UINT nIDData, int nPropertySelected, int nAlignment, BOOL bComboEditable) { - return AddString(GetResManager()->LoadString(nIDString), nType, GetResManager()->LoadString(nIDData), nPropertySelected, nAlignment, bComboEditable); + return AddString(GetResManager().LoadString(nIDString), nType, GetResManager().LoadString(nIDData), nPropertySelected, nAlignment, bComboEditable); } BOOL CPropertyListCtrl::AddString(UINT nIDString, int nType, CString csData, int nPropertySelected, int nAlignment, BOOL bComboEditable) { - return AddString(GetResManager()->LoadString(nIDString), nType, csData, nPropertySelected, nAlignment, bComboEditable); + return AddString(GetResManager().LoadString(nIDString), nType, csData, nPropertySelected, nAlignment, bComboEditable); } BOOL CPropertyListCtrl::AddString(CString csText, COLORREF crColor, int nAlignment) @@ -882,7 +863,7 @@ BOOL CPropertyListCtrl::AddString(UINT nIDString, COLORREF crColor, int nAlignment) { - return AddString(GetResManager()->LoadString(nIDString), crColor, nAlignment); + return AddString(GetResManager().LoadString(nIDString), crColor, nAlignment); } BOOL CPropertyListCtrl::AddString(CString csText, CFont* pFont, int nAlignment) @@ -896,7 +877,7 @@ BOOL CPropertyListCtrl::AddString(UINT nIDString, CFont* pFont, int nAlignment) { - return AddString(GetResManager()->LoadString(nIDString), pFont, nAlignment); + return AddString(GetResManager().LoadString(nIDString), pFont, nAlignment); } ///////////////////////////////////////////////////////////////////////////// @@ -1016,7 +997,7 @@ case ID_PROPERTY_FONT: if(m_pCurDrawItem->LogFont.lfHeight) - pDC->DrawText( m_pCurDrawItem->LogFont.lfFaceName, _tcslen(m_pCurDrawItem->LogFont.lfFaceName), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_NOPREFIX); + pDC->DrawText( m_pCurDrawItem->LogFont.lfFaceName, boost::numeric_cast(_tcslen(m_pCurDrawItem->LogFont.lfFaceName)), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_NOPREFIX); break; } } @@ -1117,7 +1098,7 @@ if(m_pCurFont) { m_pCurFont->GetLogFont(&pPropertyItem->LogFont); - m_pCurFont = NULL; + m_pCurFont = nullptr; } break; @@ -1143,13 +1124,13 @@ // Establish string and get the first token: pWord = _tcstok( pText, Separations); - while( pWord != NULL ) + while( pWord != nullptr ) { // Add this to the Array pPropertyItem->csProperties.Add(pWord); // Get next token - pWord = _tcstok( NULL, Separations ); + pWord = _tcstok( nullptr, Separations ); } // Release the buffer @@ -1269,7 +1250,7 @@ *SelectedItem = pItem->nPropertySelected; // Do they want the text - if(pText != NULL && pItem->nType == ID_PROPERTY_COMBO_LIST) + if(pText != nullptr && pItem->nType == ID_PROPERTY_COMBO_LIST) *pText = pItem->csProperties.GetAt(pItem->nPropertySelected); return true; }