用于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.

463 lines
13 KiB

5 months ago
#pragma once
#include "core/SWnd.h"
#include "SRichEdit.h"
#include "SDropDown.h"
namespace SOUI
{
#define IDC_CB_EDIT -100
#define IDC_DROPDOWN_LIST -200
/**
* @class SComboEdit
* @brief CommboBox中嵌入的Edit控件
*
* Describe
*/
class SOUI_EXP SComboEdit:public SEdit
{
public:
/**
* SComboEdit::SComboEdit
* @param SComboBoxBase *pOwner --
* @brief
*
* Describe
*/
SComboEdit(SWindow *pOwner);
/**
* SComboEdit::~SComboEdit
* @brief
*
* Describe
*/
virtual ~SComboEdit();
protected:
/**
* SComboEdit::OnMouseHover
* @brief
* @param WPARAM wParam
* @param CPoint ptPos --
*
* Describe
*/
void OnMouseHover(WPARAM wParam, CPoint ptPos);
/**
* SComboEdit::OnMouseLeave
* @brief
*
* Describe
*/
void OnMouseLeave();
/**
* SComboEdit::OnKeyDown
* @brief
* @param UINT nChar --
* @param UINT nRepCnt --
* @param UINT nFlags --
*
* Describe
*/
void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
/**
* SComboEdit::FireEvent
* @brief
* @param EventArgs & evt --
*
* Describe
*/
virtual BOOL FireEvent(EventArgs & evt);
virtual void OnFinalRelease();
void OnKillFocus(SWND wndFocus);
SOUI_MSG_MAP_BEGIN()
MSG_WM_MOUSEHOVER(OnMouseHover)
MSG_WM_MOUSELEAVE(OnMouseLeave)
MSG_WM_KEYDOWN(OnKeyDown)
MSG_WM_KILLFOCUS_EX(OnKillFocus)
SOUI_MSG_MAP_END()
};
class SOUI_EXP SDropDownWnd_ComboBox : public SDropDownWnd
{
public:
SDropDownWnd_ComboBox(ISDropDownOwner* pOwner):SDropDownWnd(pOwner){}
virtual BOOL PreTranslateMessage(MSG* pMsg);
};
/**
* @class SComboBoxBase
* @brief CommboBox
*
* Describe
*/
class SOUI_EXP SComboBase
: public SWindow
, public ISDropDownOwner
{
SOUI_CLASS_NAME(SComboBase,L"combobase")
public:
/**
* SComboBoxBase::SComboBoxBase
* @brief
*
* Describe
*/
SComboBase(void);
/**
* SComboBoxBase::~SComboBoxBase
* @brief
*
* Describe
*/
virtual ~SComboBase(void);
/**
* SComboBoxBase::GetCurSel
* @brief
* @return int
*
* Describe
*/
virtual int GetCurSel() const =0;
/**
* SComboBoxBase::GetCount
* @brief
* @return int
*
* Describe
*/
virtual int GetCount() const =0;
/**
* SComboBoxBase::SetCurSel
* @brief
* @param int iSel --
*
* Describe
*/
virtual BOOL SetCurSel(int iSel)=0;
/**
* SComboBoxEx::GetTextRect
* @brief
* @param LPRECT pRect --
*
* Describe
*/
virtual SStringT GetWindowText(BOOL bRawText=FALSE);
virtual SStringT GetLBText(int iItem,BOOL bRawText=FALSE) =0;
/**
* SComboBoxBase::SetWindowText
* @brief
* @param LPCTSTR pszText --
*
* Describe
*/
virtual void SetWindowText(LPCTSTR pszText);
/**
* FindString
* @brief
* @param LPCTSTR pszFind --
* @param int nAfter --
* @return int -- -1
* Describe
*/
virtual int FindString(LPCTSTR pszFind,int nAfter=-1, BOOL bPartMatch=TRUE);
virtual CSize GetDesiredSize(int nParentWid, int nParentHei);
virtual void SetFocus();
/**
* SComboBoxBase::DropDown
* @brief
*
* Describe
*/
void DropDown();
/**
* SComboBoxBase::CloseUp
* @brief
*
* Describe
*/
void CloseUp();
bool IsDropdown() const;
void SetDropdown(bool bDropdown);
protected:
/**
* SComboBoxBase::GetDropDownOwner
* @brief owner
* @return SWindow
*
* Describe owner
*/
virtual SWindow* GetDropDownOwner();
/**
* SComboBoxBase::OnCreateDropDown
* @brief
* @param SDropDownWnd *pDropDown --
*
* Describe
*/
virtual void OnCreateDropDown(SDropDownWnd *pDropDown);
/**
* SComboBoxBase::OnDestroyDropDown
* @brief
* @param SDropDownWnd *pDropDown --
* @param UINT uCode --
*
* Describe
*/
virtual void OnDestroyDropDown(SDropDownWnd *pDropDown);
/**
* SComboBoxBase::OnSelChanged
* @brief
*
* Describe
*/
virtual void OnSelChanged();
virtual BOOL FireEvent(EventArgs &evt);
protected:
/**
* SComboBoxBase::CalcPopupRect
* @brief
* @param int nHeight --
* @param CRect & rcPopup -- Rect
* @return BOOL TRUE -- FALSE --
*
* Describe ,rcPopup中
*/
BOOL CalcPopupRect(int nHeight,CRect & rcPopup);
/**
* SComboBoxBase::CreateListBox
* @brief
* @param pugi::xml_node xmlNode -- xml对象
* @return BOOL TRUE -- FALSE --
*
* Describe
*/
virtual BOOL CreateListBox(pugi::xml_node xmlNode)=0;
/**
* SComboBoxBase::GetListBoxHeight
* @brief
* @return int
*
* Describe
*/
virtual int GetListBoxHeight()=0;
/**
* SComboBoxBase::GetDropBtnRect
* @brief
* @param LPRECT prc -- Rect
*
* Describe
*/
void GetDropBtnRect(LPRECT prc);
/**
* SComboBoxBase::LoadChildren
* @brief
* @param pugi::xml_node xmlNode -- xml文件
* @return BOOL TRUE -- FALSE --
*
* Describe
*/
virtual BOOL CreateChildren(pugi::xml_node xmlNode);
/**
* SComboBoxBase::GetTextRect
* @brief
* @param LPRECT pRect --
*
* Describe
*/
virtual void GetTextRect(LPRECT pRect);
virtual void OnColorize(COLORREF cr);
virtual HRESULT OnLanguageChanged();
virtual void OnScaleChanged(int nScale);
/**
* SComboBoxBase::OnPaint
* @brief
* @param IRenderTarget * pRT --
*
* Describe
*/
void OnPaint(IRenderTarget * pRT);
/**
* SComboBoxBase::OnLButtonDown
* @brief
* @param UINT nFlags --
* @param CPoint point --
*
* Describe
*/
void OnLButtonDown(UINT nFlags,CPoint pt);
/**
* SComboBoxBase::OnMouseMove
* @brief
* @param UINT nFlags --
* @param CPoint point --
*
* Describe
*/
void OnMouseMove(UINT nFlags,CPoint pt);
/**
* SComboBoxBase::OnMouseLeave
* @brief
*
* Describe
*/
void OnMouseLeave();
/**
* SComboBoxBase::OnKeyDown
* @brief
* @param UINT nChar --
* @param UINT nRepCnt --
* @param UINT nFlags --
*
* Describe
*/
void OnKeyDown( TCHAR nChar, UINT nRepCnt, UINT nFlags );
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
/**
* SComboBoxBase::OnChar
* @brief
* @param UINT nChar --
* @param UINT nRepCnt --
* @param UINT nFlags --
*
* Describe
*/
void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
/**
* SComboBoxBase::OnDestroy
* @brief
*
* Describe
*/
void OnDestroy();
/**
* SComboBoxBase::OnGetDlgCode
* @brief
*
* Describe
*/
UINT OnGetDlgCode();
/**
* SComboBoxBase::IsFocusable
* @brief TAB键
*
* Describe TAB键
*/
BOOL IsFocusable();
void UpdateChildrenPosition();
void OnKillFocus(SWND wndFocus);
HRESULT OnAttrDropDown(const SStringW & strValue, BOOL bLoading);
SStringT GetCueText(BOOL bRawText=FALSE) const;
SOUI_ATTRS_BEGIN()
ATTR_CUSTOM(L"dropDown", OnAttrDropDown)
ATTR_LAYOUTSIZE(L"dropHeight", m_nDropHeight, TRUE)
ATTR_INT(L"curSel", m_iInitSel, FALSE)
ATTR_SKIN(L"btnSkin", m_pSkinBtn, TRUE)
ATTR_INT(L"animateTime", m_nAnimTime, FALSE)
ATTR_INT(L"autoFitDropBtn", m_bAutoFitDropBtn, TRUE)
ATTR_COLOR(L"cueColor",m_crCue,TRUE)
ATTR_I18NSTRT(L"cueText",m_strCue,TRUE)
ATTR_BOOL(L"autoMatch",m_bAutoMatch,FALSE)
SOUI_ATTRS_END()
SOUI_MSG_MAP_BEGIN()
MSG_WM_PAINT_EX(OnPaint)
MSG_WM_LBUTTONDOWN(OnLButtonDown)
MSG_WM_MOUSEMOVE(OnMouseMove)
MSG_WM_MOUSELEAVE(OnMouseLeave)
MSG_WM_MOUSEWHEEL(OnMouseWheel)
MSG_WM_KEYDOWN(OnKeyDown)
MSG_WM_CHAR(OnChar)
MSG_WM_DESTROY(OnDestroy)
MSG_WM_KILLFOCUS_EX(OnKillFocus)
SOUI_MSG_MAP_END()
protected:
/**
* SComboBoxBase::GetEditText
* @brief
*
* Describe
*/
SStringT GetEditText() const
{
if(!m_bDropdown)
{
return m_pEdit->GetWindowText();
}
else
{
return SStringT();
}
}
SRichEdit *m_pEdit; /**< SRichEdit指针 */
DWORD m_dwBtnState; /**< 按钮状态 */
SAutoRefPtr<ISkinObj> m_pSkinBtn; /**< 按钮资源 */
bool m_bDropdown; /**< Editable or dropdown only */
SLayoutSize m_nDropHeight; /**< 下拉框高度 */
int m_nAnimTime; /**< 动画时间 */
int m_iInitSel; /**< 默认选中索引 */
SDropDownWnd *m_pDropDownWnd; /**< DropDown指针 */
pugi::xml_document m_xmlDropdownStyle;/**< DropDown的style */
BOOL m_bAutoFitDropBtn; /**< 自适应下拉按钮大小*/
COLORREF m_crCue;
STrText m_strCue;
SStringT m_strMatch; /*快速输入用来定位下拉列表中的项*/
DWORD m_LastPressTime; /*最后按键的时间,*/
BOOL m_bAutoMatch;
int m_nTextLength;
};
}