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

355 lines
9.7 KiB

5 months ago
/**
* Copyright (C) 2014-2050 SOUI团队
* All rights reserved.
*
* @file SHeaderCtrl.h
* @brief
* @version v1.0
* @author soui
* @date 2014-07-02
*
* Describe
*/
#pragma once
#include "core/SWnd.h"
namespace SOUI
{
#define SHDI_WIDTH 0x0001
#define SHDI_TEXT 0x0002
#define SHDI_SORTFLAG 0x0004
#define SHDI_LPARAM 0x0008
#define SHDI_ORDER 0x0010
#define SHDI_VISIBLE 0x0020
/**
* @enum _SHDSORTFLAG
* @brief
*
* Describe
*/
enum SHDSORTFLAG{
ST_NULL=0,
ST_UP,
ST_DOWN,
};
/**
* @struct _SHDITEM
* @brief
*
* Describe
*/
typedef struct SHDITEM {
SHDITEM():mask(0),cx(0), bDpiAware(false),stFlag(ST_NULL),lParam(0),state(WndState_Normal),iOrder(0),bVisible(true),fWeight(0.0f){
}
UINT mask;
int cx;
float fWeight;
bool bDpiAware;
STrText strText;
SHDSORTFLAG stFlag;
LPARAM lParam;
UINT state;
int iOrder;
bool bVisible;
}*LPSHDITEM;
/**
* @class SHeaderCtrl
* @brief
*
* Describe
*/
class SOUI_EXP SHeaderCtrl: public SWindow
{
SOUI_CLASS_NAME(SHeaderCtrl, L"header")
enum{
MARGIN_ADJUST_ENABLE=4,
MARGIN_ADJUST_DISABLE=2,
};
public:
/**
* SHeaderCtrl::SHeaderCtrl
* @brief
*
* Describe
*/
SHeaderCtrl(void);
/**
* SHeaderCtrl::~SHeaderCtrl
* @brief
*
* Describe
*/
~SHeaderCtrl(void);
/**
* SHeaderCtrl::InsertItem
* @brief
* @param int iItem --
* @param LPCTSTR pszText --
* @param int nWidth --
* @param SHDSORTFLAG stFlag --
* @param LPARAM lParam --
* @return int
*
* Describe
*/
int InsertItem(int iItem,LPCTSTR pszText,int nWidth, SHDSORTFLAG stFlag,LPARAM lParam );
int InsertItem(int iItem,LPCTSTR pszText, int nWidth, SLayoutSize::Unit unit, SHDSORTFLAG stFlag,LPARAM lParam );
/**
* SHeaderCtrl::GetItem
* @brief
* @param int iItem --
* @param SHDITEM *pItem --
* @return BOOL
*
* Describe
*/
BOOL GetItem(int iItem,SHDITEM *pItem) const;
BOOL SetItem(int iItem, const SHDITEM *pItem);
/**
* SHeaderCtrl::GetItemCount
* @brief
* @return int
*
* Describe
*/
size_t GetItemCount() const{return m_arrItems.GetCount();}
/**
* SHeaderCtrl::GetTotalWidth
* @brief
* @return int
*
* Describe
*/
int GetTotalWidth(bool bMinWid=false) const;
bool IsAutoResize() const;
/**
* SHeaderCtrl::GetItemWidth
* @brief
* @param int iItem --
* @return int
*
* Describe
*/
int GetItemWidth(int iItem) const;
/**
* SHeaderCtrl::DeleteItem
* @brief
* @param int iItem --
* @return BOOL
*
* Describe
*/
BOOL DeleteItem(int iItem);
/**
* SHeaderCtrl::DeleteAllItems
* @brief
*
* Describe
*/
void DeleteAllItems();
void SetItemSort(int iItem,SHDSORTFLAG stFlag);
void SetItemVisible(int iItem, bool visible);
bool IsItemVisible(int iItem) const;
/**
* SHeaderCtrl::GetItemRect
* @brief
* @param UINT iItem --
*
* Describe
*/
CRect GetItemRect(UINT iItem) const;
int GetOriItemIndex(int iOrder) const;
SOUI_ATTRS_BEGIN()
ATTR_SKIN(L"itemSkin",m_pSkinItem,FALSE)
ATTR_SKIN(L"sortSkin",m_pSkinSort,FALSE)
ATTR_INT(L"fixWidth",m_bFixWidth,FALSE)
ATTR_INT(L"itemSwapEnable",m_bItemSwapEnable,FALSE)
ATTR_INT(L"sortHeader",m_bSortHeader,FALSE)
SOUI_ATTRS_END()
protected:
/**
* SHeaderCtrl::CreateChildren
* @brief
* @param pugi::xml_node xmlNode -- xml配置文件
*
* Describe
*/
virtual BOOL CreateChildren(pugi::xml_node xmlNode);
/**
* SHeaderCtrl::OnSetCursor
* @brief
* @param const CPoint &pt --
*
* Describe
*/
virtual BOOL OnSetCursor(const CPoint &pt);
/**
* SHeaderCtrl::OnPaint
* @brief
* @param IRenderTarget * pRT --
*
* Describe
*/
void OnPaint(IRenderTarget * pRT);
/**
* SHeaderCtrl::DrawItem
* @brief
* @param IRenderTarget * pRT --
* @param CRect rcItem --
* @param const LPSHDITEM pItem --
*
* Describe
*/
virtual void DrawItem(IRenderTarget * pRT,CRect rcItem,const LPSHDITEM pItem);
virtual void OnColorize(COLORREF cr);
virtual HRESULT OnLanguageChanged();
virtual void OnScaleChanged(int nScale);
virtual BOOL OnRelayout(const CRect &rcWnd);
/**
* SHeaderCtrl::HitTest
* @brief
* @param CPoint pt --
*
* Describe DWORDLOWORD为前面的项
* HIWORD为后面的项
*/
DWORD HitTest(CPoint pt);
/**
* SHeaderCtrl::RedrawItem
* @brief
* @param CPoint pt --
*
* Describe
*/
void RedrawItem(int iItem);
/**
* SHeaderCtrl::DrawDraggingState
* @brief
* @param DWORD dwDragTo --
*
* Describe
*/
void DrawDraggingState(DWORD dwDragTo);
/**
* SHeaderCtrl::IsItemHover
* @brief Hover状态
* @param DWORD dwHitTest
* @return BOOL
*
* Describe Hover状态
*/
BOOL IsItemHover(DWORD dwHitTest)
{
return dwHitTest!=-1 && LOWORD(dwHitTest)==HIWORD(dwHitTest);
}
/**
* SHeaderCtrl::CreateDragImage
* @brief
* @param UINT iItem --
* @return HBITMAP
*
* Describe Hover状态
*/
HBITMAP CreateDragImage(UINT iItem);
/**
* SHeaderCtrl::OnLButtonDown
* @brief
* @param UINT nFlags --
* @param CPoint point --
*
* Describe
*/
void OnLButtonDown(UINT nFlags,CPoint pt);
/**
* SHeaderCtrl::OnLButtonUp
* @brief
* @param UINT nFlags --
* @param CPoint point --
*
* Describe
*/
void OnLButtonUp(UINT nFlags,CPoint pt);
/**
* SHeaderCtrl::OnMouseMove
* @brief
* @param UINT nFlags --
* @param CPoint point --
*
* Describe
*/
void OnMouseMove(UINT nFlags,CPoint pt);
/**
* SHeaderCtrl::OnMouseLeave
* @brief
*
* Describe
*/
void OnMouseLeave();
/**
* SHeaderCtrl::OnDestroy
* @brief
*
* Describe
*/
void OnDestroy();
void OnActivateApp(BOOL bActive, DWORD dwThreadID);
SOUI_MSG_MAP_BEGIN()
MSG_WM_PAINT_EX(OnPaint)
MSG_WM_LBUTTONDOWN(OnLButtonDown)
MSG_WM_LBUTTONUP(OnLButtonUp)
MSG_WM_MOUSEMOVE(OnMouseMove)
MSG_WM_MOUSELEAVE(OnMouseLeave)
MSG_WM_ACTIVATEAPP(OnActivateApp)
MSG_WM_DESTROY(OnDestroy)
SOUI_MSG_MAP_END()
SAutoRefPtr<ISkinObj> m_pSkinItem; /**< 表头绘制Skin */
SAutoRefPtr<ISkinObj> m_pSkinSort; /**< 排序标志Skin */
BOOL m_bSortHeader; /**< 表头可以点击排序 */
BOOL m_bFixWidth; /**< 表项宽度固定开关 */
BOOL m_bItemSwapEnable; /**< 允许拖动调整位置开关 */
BOOL m_bDragging; /**< 正在拖动标志 */
HBITMAP m_hDragImg; /**< 显示拖动窗口的临时位图 */
CPoint m_ptClick; /**< 当前点击坐标 */
DWORD m_dwHitTest; /**< 鼠标位置 */
DWORD m_dwDragTo; /**< 拖放目标 */
int m_nAdjItemOldWidth; /**< 保存被拖动项的原始宽度 */
SArray<SHDITEM> m_arrItems; /**< 列表项集合 */
int m_nScale; /**< Current Scale */
};
}//end of namespace SOUI