用于EagleEye3.0 规则集漏报和误报测试的示例项目,项目收集于github和gitee
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

384 lines
9.3 KiB

5 months ago
/**
* Copyright (C) 2014-2050 SOUI<EFBFBD>Ŷ<EFBFBD>
* All rights reserved.
*
* @file SDateTimeEdit.h
* @brief ͨ<EFBFBD>ÿؼ<EFBFBD>
* @version v1.0
* @author soui
* @date 2014-06-27
*
* Describe ʱ<EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD>
*/
#pragma once
#include <control/SRichEdit.h>
#include <helper/STime.h>
namespace SOUI{
//===========================================================================
// Summary:
// SMaskEdit is a CXTPEdit derived class. It allows text masking to be
// applied to the control to format it for special editing restrictions.
//===========================================================================
/**
* @class SMaskEdit
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* Describe <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ڹ̶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
*/
class SMaskEdit : public SEdit
{
SOUI_CLASS_NAME(SMaskEdit, L"maskedit")
public:
/**
* SMaskEdit::SMaskEdit
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* Describe <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
SMaskEdit();
/**
* SMaskEdit::CanUseMask
* @brief <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD>BOOL
*
* Describe <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
BOOL CanUseMask() const;
/**
* SMaskEdit::SetUseMask
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param BOOL bUseMask -- TRUE FALSE
*
* Describe <EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void SetUseMask(BOOL bUseMask);
/**
* SMaskEdit::CanOverType
* @brief <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param <EFBFBD><EFBFBD><EFBFBD><EFBFBD>BOOL
*
* Describe <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
BOOL CanOverType() const;
/**
* SMaskEdit::SetOverType
* @brief <EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param BOOL bOverType -- TRUE FALSE
*
* Describe <EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void SetOverType(BOOL bOverType);
/**
* SMaskEdit::PosInRange
* @brief <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param <EFBFBD><EFBFBD><EFBFBD><EFBFBD>BOOL
*
* Describe <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
BOOL PosInRange(int nPos) const;
/**
* SMaskEdit::CanUseMask
* @brief <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param <EFBFBD><EFBFBD><EFBFBD><EFBFBD>BOOL
*
* Describe <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
TCHAR GetPromptChar() const;
/**
* SMaskEdit::CanUseMask
* @brief <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param <EFBFBD><EFBFBD><EFBFBD><EFBFBD>BOOL
*
* Describe <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
SStringT GetPromptString(int nLength) const;
/**
* SMaskEdit::CanUseMask
* @brief <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param <EFBFBD><EFBFBD><EFBFBD><EFBFBD>BOOL
*
* Describe <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mask<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void SetPromptChar(TCHAR ch, BOOL bAutoReplace = TRUE);
BOOL MaskCut();
BOOL MaskCopy();
void MaskReplaceSel(LPCTSTR lpszNewText);
BOOL MaskPaste();
void MaskDeleteSel();
BOOL MaskClear();
void MaskSelectAll();
BOOL IsModified() const;
void SetMaskedText(LPCTSTR lpszMaskedText, int nPos = 0, BOOL bUpdateWindow = TRUE);
virtual BOOL SetEditMask(LPCTSTR lpszMask, LPCTSTR lpszLiteral, LPCTSTR lpszDefault=NULL);
TCHAR ConvertUnicodeAlpha(TCHAR nChar, BOOL bUpperCase) const;
virtual BOOL CheckChar(TCHAR& nChar, int nPos);
virtual BOOL ProcessMask(TCHAR& nChar, int nEndPos);
void DeleteCharAt(int nPos);
void InsertCharAt(int nPos, TCHAR nChar);
SStringT GetMaskedText(int nStartPos = 0, int nEndPos = -1) const;
void GetMaskState(BOOL bCorrectSelection = TRUE);
void SetMaskState();
void MaskGetSel();
BOOL CopyToClipboard(const SStringT& strText);
BOOL IsPromptPos(int nPos) const;
BOOL IsPromptPos(const SStringT& strLiteral, int nPos) const;
BOOL CorrectPosition(int& nPos, BOOL bForward = TRUE);
void CorrectWindowText();
virtual BOOL IsPrintChar(TCHAR nChar);
virtual BOOL IsAlphaChar(TCHAR nChar);
virtual void NotifyPosNotInRange();
virtual void NotifyInvalidCharacter(TCHAR /*nChar*/, TCHAR /*chMask*/);
void ProcessChar(TCHAR nChar);
protected:
/**
* SMaskEdit::OnCreate
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param LPVOID
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵint
*
* Describe <EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
int OnCreate(LPVOID);
/**
* SMaskEdit::OnChar
* @brief <EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>Ϣ
* @param UINT nChar -- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
* @param UINT nRepCnt -- <EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param UINT nFlags -- <EFBFBD><EFBFBD>־
*
* Describe <EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
/**
* SMaskEdit::OnKeyDown
* @brief <EFBFBD><EFBFBD><EFBFBD>̰<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
* @param UINT nChar -- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
* @param UINT nRepCnt -- <EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param UINT nFlags -- <EFBFBD><EFBFBD>־
*
* Describe <EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
/**
* SMaskEdit::OnSetFocus
* @brief <EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD>
*
* Describe <EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void OnSetFocus(SWND wndOld);
protected:
int m_nStartChar; // Current position of the first character in the current selection.
int m_nEndChar; // Current position of the first non-selected character past the end of the current selection.
BOOL m_bUseMask; // TRUE to use the edit mask.
BOOL m_bOverType; // TRUE to over type the text, set with VK_INSERT key press.
BOOL m_bModified; // TRUE if mask edit has been modified.
TCHAR m_chPrompt; // Prompt character used to identify the text entry.
SStringT m_strMask; // Buffer that holds the actual edit mask value.
SStringT m_strDefault; // Contains the edit controls default display text.
SStringT m_strWindowText; // Buffer that holds the actual edit text.
SStringT m_strLiteral; // Literal format that restricts where the user can enter text.
protected:
SOUI_MSG_MAP_BEGIN()
MSG_WM_CREATE(OnCreate)
MSG_WM_CHAR(OnChar)
MSG_WM_KEYDOWN(OnKeyDown)
MSG_WM_SETFOCUS_EX(OnSetFocus)
SOUI_MSG_MAP_END()
};
/**
* @class SDateEdit
* @brief <EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD>
*
* Describe <EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD>
*/
class SDateEdit : public SMaskEdit
{
SOUI_CLASS_NAME(SDateEdit, L"dateedit")
public:
/**
* SDateEdit::SDateEdit
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* Describe <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
SDateEdit();
/**
* SDateEdit::SetDateTime
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param LPCTSTR strDate -- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
*
* Describe <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
virtual void SetDateTime(LPCTSTR strDate);
/**
* SDateEdit::SetDateTime
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param CTime tm -- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* Describe <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
virtual void SetDateTime(STime tm);
/**
* SDateEdit::GetWindowDateTime
* @brief <EFBFBD><EFBFBD>ȡϵͳʱ<EFBFBD><EFBFBD>
* @return SStringT <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
*
* Describe <EFBFBD><EFBFBD>ȡϵͳʱ<EFBFBD><EFBFBD>
*/
virtual SStringT GetWindowDateTime();
virtual BOOL ProcessMask(TCHAR& nChar, int nEndPos);
protected:
/**
* SDateEdit::OnCreate
* @brief <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return int
*
* Describe <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
int OnCreate(LPVOID);
protected:
SOUI_MSG_MAP_BEGIN()
MSG_WM_CREATE(OnCreate)
SOUI_MSG_MAP_END()
};
//===========================================================================
// CDxTimeEdit
/**
* @class STimeEdit
* @brief ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* Describe ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
class STimeEdit : public SDateEdit
{
SOUI_CLASS_NAME(STimeEdit, L"timeedit")
public:
/**
* STimeEdit::STimeEdit
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* Describe <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
STimeEdit();
public:
/**
* SDateEdit::SetHours
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сʱ
*
* Describe <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сʱ
*/
virtual void SetHours(int nHours);
/**
* SDateEdit::SetMins
* @brief <EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD>
*
* Describe <EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD>
*/
virtual void SetMins(int nMins);
/**
* SDateEdit::SetTime
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
* @param int nHours -- Сʱ
* @param int nMins -- <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* Describe <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
*/
virtual void SetTime(int nHours, int nMins);
/**
* SDateEdit::GetHours
* @brief <EFBFBD><EFBFBD>ȡСʱ
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD>int
*
* Describe <EFBFBD><EFBFBD>ȡСʱ
*/
int GetHours() const;
/**
* SDateEdit::GetMins
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD>int
*
* Describe <EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD>
*/
int GetMins() const;
virtual BOOL ProcessMask(TCHAR& nChar, int nEndPos);
void SetMilitary(BOOL bMilitary = TRUE);
protected:
int m_nHours; /**< Сʱ */
int m_nMins; /**< <EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
BOOL m_bMilitary; /**< */
protected:
/**
* STimeEdit::OnCreate
* @brief <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return int
*
* Describe <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
int OnCreate(LPVOID);
protected:
SOUI_MSG_MAP_BEGIN()
MSG_WM_CREATE(OnCreate)
SOUI_MSG_MAP_END()
};
//////////////////////////////////////////////////////////////////////
inline int STimeEdit::GetHours() const
{
return m_nHours;
}
inline int STimeEdit::GetMins() const
{
return m_nMins;
}
inline void STimeEdit::SetMilitary(BOOL bMilitary)
{
m_bMilitary = bMilitary;
}
}//end of namespace