Update ListEdit.h
Fix title case and punctuation, remove one line at the top
This commit is contained in:
parent
4052011e09
commit
2d427d3a3b
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ListTypes.h"
|
#include "ListTypes.h"
|
||||||
|
@ -35,25 +34,25 @@ public:
|
||||||
m_nExitChar = 0;
|
m_nExitChar = 0;
|
||||||
m_nMaxLen = nMaxLen;
|
m_nMaxLen = nMaxLen;
|
||||||
|
|
||||||
// destroy old edit control...
|
// Destroy old edit control
|
||||||
if ( IsWindow() )
|
if ( IsWindow() )
|
||||||
DestroyWindow();
|
DestroyWindow();
|
||||||
|
|
||||||
DWORD dwStyle = WS_CHILD | ES_AUTOHSCROLL | WS_BORDER;
|
DWORD dwStyle = WS_CHILD | ES_AUTOHSCROLL | WS_BORDER;
|
||||||
|
|
||||||
// right-justify numbers
|
// Right-justify numbers
|
||||||
if ( nFlags & ( ITEM_FLAGS_EDIT_NUMBER | ITEM_FLAGS_EDIT_FLOAT ) )
|
if ( nFlags & ( ITEM_FLAGS_EDIT_NUMBER | ITEM_FLAGS_EDIT_FLOAT ) )
|
||||||
dwStyle |= ES_RIGHT;
|
dwStyle |= ES_RIGHT;
|
||||||
|
|
||||||
if ( nFlags & ITEM_FLAGS_EDIT_UPPER )
|
if ( nFlags & ITEM_FLAGS_EDIT_UPPER )
|
||||||
dwStyle |= ES_UPPERCASE;
|
dwStyle |= ES_UPPERCASE;
|
||||||
|
|
||||||
// create edit control
|
// Create edit control
|
||||||
CRect Area( rcRect.left - 2, rcRect.top - 3, rcRect.right + 3, rcRect.bottom + 2 );
|
CRect Area( rcRect.left - 2, rcRect.top - 3, rcRect.right + 3, rcRect.bottom + 2 );
|
||||||
if ( CWindowImpl< CListEdit, CEdit >::Create( hWndParent, Area, NULL, dwStyle ) == NULL )
|
if ( CWindowImpl< CListEdit, CEdit >::Create( hWndParent, Area, NULL, dwStyle ) == NULL )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// get system message font
|
// Get system message font
|
||||||
CLogFont logFont;
|
CLogFont logFont;
|
||||||
logFont.SetMessageBoxFont();
|
logFont.SetMessageBoxFont();
|
||||||
if ( !m_fntEditFont.IsNull() )
|
if ( !m_fntEditFont.IsNull() )
|
||||||
|
@ -65,7 +64,7 @@ public:
|
||||||
SetMargins( ITEM_EDIT_MARGIN, ITEM_EDIT_MARGIN );
|
SetMargins( ITEM_EDIT_MARGIN, ITEM_EDIT_MARGIN );
|
||||||
SetWindowText( lpszItemText );
|
SetWindowText( lpszItemText );
|
||||||
|
|
||||||
// show edit control
|
// Show edit control
|
||||||
ShowWindow( SW_SHOW );
|
ShowWindow( SW_SHOW );
|
||||||
|
|
||||||
SetSelAll();
|
SetSelAll();
|
||||||
|
@ -76,7 +75,7 @@ public:
|
||||||
|
|
||||||
BOOL IsValid( TCHAR nChar )
|
BOOL IsValid( TCHAR nChar )
|
||||||
{
|
{
|
||||||
// validate number and float input
|
// Validate number and float input
|
||||||
if ( !( m_nFlags & ( ITEM_FLAGS_EDIT_HEX | ITEM_FLAGS_EDIT_NUMBER | ITEM_FLAGS_EDIT_FLOAT ) ) || nChar == VK_BACK )
|
if ( !( m_nFlags & ( ITEM_FLAGS_EDIT_HEX | ITEM_FLAGS_EDIT_NUMBER | ITEM_FLAGS_EDIT_FLOAT ) ) || nChar == VK_BACK )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -88,7 +87,7 @@ public:
|
||||||
WindowText.resize(nValueLength);
|
WindowText.resize(nValueLength);
|
||||||
GetWindowTextW((wchar_t *)WindowText.c_str(), nValueLength + 1);
|
GetWindowTextW((wchar_t *)WindowText.c_str(), nValueLength + 1);
|
||||||
}
|
}
|
||||||
// get selected positions
|
// Get selected positions
|
||||||
int nStartChar;
|
int nStartChar;
|
||||||
int nEndChar;
|
int nEndChar;
|
||||||
GetSel( nStartChar, nEndChar );
|
GetSel( nStartChar, nEndChar );
|
||||||
|
@ -100,7 +99,7 @@ public:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// are we changing the sign?
|
// Are we changing the sign?
|
||||||
if ( ( m_nFlags & ITEM_FLAGS_EDIT_NEGATIVE ) && nChar == _T( '-' ) )
|
if ( ( m_nFlags & ITEM_FLAGS_EDIT_NEGATIVE ) && nChar == _T( '-' ) )
|
||||||
{
|
{
|
||||||
BOOL bNegative = FALSE;
|
BOOL bNegative = FALSE;
|
||||||
|
@ -119,12 +118,12 @@ public:
|
||||||
|
|
||||||
SetWindowText(WindowText.c_str());
|
SetWindowText(WindowText.c_str());
|
||||||
|
|
||||||
// restore select position
|
// Restore select position
|
||||||
SetSel( bNegative ? nStartChar - 1 : nStartChar + 1, bNegative ? nEndChar - 1 : nEndChar + 1 );
|
SetSel( bNegative ? nStartChar - 1 : nStartChar + 1, bNegative ? nEndChar - 1 : nEndChar + 1 );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct new value string using entered character
|
// Construct new value string using entered character
|
||||||
std::wstring strNewValue = WindowText.substr(0, nStartChar ) + nChar + WindowText.substr(WindowText.length() - nEndChar );
|
std::wstring strNewValue = WindowText.substr(0, nStartChar ) + nChar + WindowText.substr(WindowText.length() - nEndChar );
|
||||||
|
|
||||||
int nGreaterThan = 0;
|
int nGreaterThan = 0;
|
||||||
|
@ -183,18 +182,18 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// invalid if text contains more than one '>', '<', '=' or '.'
|
// Invalid if text contains more than one '>', '<', '=' or '.'
|
||||||
if ( nGreaterThan > 1 || nLessThan > 1 || nEquals > 1 || nDecimalPoint > 1 )
|
if ( nGreaterThan > 1 || nLessThan > 1 || nEquals > 1 || nDecimalPoint > 1 )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// invalid if text contains '=>' or '=<'
|
// Invalid if text contains '=>' or '=<'
|
||||||
if ( nGreaterIndex != -1 && nEqualIndex != -1 && nGreaterIndex > nEqualIndex )
|
if ( nGreaterIndex != -1 && nEqualIndex != -1 && nGreaterIndex > nEqualIndex )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if ( nLessIndex != -1 && nEqualIndex != -1 && nLessIndex > nEqualIndex )
|
if ( nLessIndex != -1 && nEqualIndex != -1 && nLessIndex > nEqualIndex )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// invalid if digits exist before operator
|
// Invalid if digits exist before operator
|
||||||
if ( nDigitIndex != -1 && nGreaterIndex != -1 && nGreaterIndex > nDigitIndex )
|
if ( nDigitIndex != -1 && nGreaterIndex != -1 && nGreaterIndex > nDigitIndex )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if ( nDigitIndex != -1 && nLessIndex != -1 && nLessIndex > nDigitIndex )
|
if ( nDigitIndex != -1 && nLessIndex != -1 && nLessIndex > nDigitIndex )
|
||||||
|
@ -234,7 +233,7 @@ public:
|
||||||
listNotify.m_lpszItemText = strValue.c_str();
|
listNotify.m_lpszItemText = strValue.c_str();
|
||||||
listNotify.m_lpItemDate = NULL;
|
listNotify.m_lpItemDate = NULL;
|
||||||
|
|
||||||
// forward notification to parent
|
// Forward notification to parent
|
||||||
FORWARD_WM_NOTIFY( wndParent, listNotify.m_hdrNotify.idFrom, &listNotify.m_hdrNotify, ::SendMessage );
|
FORWARD_WM_NOTIFY( wndParent, listNotify.m_hdrNotify.idFrom, &listNotify.m_hdrNotify, ::SendMessage );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue