| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- #ifndef __UIBUTTON_H__
- #define __UIBUTTON_H__
- #pragma once
- namespace DuiLib
- {
- class UILIB_API CButtonUI : public CLabelUI
- {
- DECLARE_DUICONTROL(CButtonUI)
- public:
- CButtonUI();
- LPCTSTR GetClass() const;
- LPVOID GetInterface(LPCTSTR pstrName);
- UINT GetControlFlags() const;
- bool Activate();
- void SetEnabled(bool bEnable = true);
- void DoEvent(TEventUI& event);
- // ------------------------------------------------------------------
- // [触屏] 清除"按下/按下高亮"相关位:PUSHED | CAPTURED | HOT。
- //
- // 存在的理由(Win10 真机 bug):属性弹框弹出时,被点的商品按钮
- // (「古古怪怪」)的 PUSHED 态残留不消失。
- // 成因是 CButtonUI::DoEvent 的 UIEVENT_BUTTONUP 分支带 CAPTURED 守卫 ——
- // 弹框把 manager 搬走时 CAPTURED 被清掉,导致弹框关闭后那条补发的
- // BUTTONUP 进不了分支,PUSHED 就永远留着。
- //
- // CControlUI 基类里现在有了 `virtual void ClearPushedState()`(默认空实现),
- // 本类把它 override 成"清 PUSHED|CAPTURED|HOT 三个显示位"。
- // 于是 CPaintManagerUI::ClearPushedStateAt 只需按基类指针调用,
- // 就能同时覆盖 CButtonUI 与业务自绘控件(如 CDiandanFoodItemUI)。
- //
- // ⚠️ 只用于"搬家"与"触摸滑动起手"这种确定性时点。
- // **不要**拿它去给触摸抬手打补丁 —— 触摸路径的按下态残留是
- // **消息顺序**问题(状态收尾被夹在业务回调之前),已在
- // EndTouchSlideGesture / TouchUp 里按顺序修正,不靠事后补清。
- // ------------------------------------------------------------------
- virtual void ClearPushedState();
- virtual LPCTSTR GetNormalImage();
- virtual void SetNormalImage(LPCTSTR pStrImage);
- virtual LPCTSTR GetHotImage();
- virtual void SetHotImage(LPCTSTR pStrImage);
- virtual LPCTSTR GetPushedImage();
- virtual void SetPushedImage(LPCTSTR pStrImage);
- virtual LPCTSTR GetFocusedImage();
- virtual void SetFocusedImage(LPCTSTR pStrImage);
- virtual LPCTSTR GetDisabledImage();
- virtual void SetDisabledImage(LPCTSTR pStrImage);
- virtual LPCTSTR GetHotForeImage();
- virtual void SetHotForeImage(LPCTSTR pStrImage);
- virtual LPCTSTR GetPushedForeImage();
- virtual void SetPushedForeImage(LPCTSTR pStrImage);
- void SetStateCount(int nCount);
- int GetStateCount() const;
- virtual LPCTSTR GetStateImage();
- virtual void SetStateImage(LPCTSTR pStrImage);
- void BindTabIndex(int _BindTabIndex);
- void BindTabLayoutName(LPCTSTR _TabLayoutName);
- void BindTriggerTabSel(int _SetSelectIndex = -1);
- void RemoveBindTabIndex();
- int GetBindTabLayoutIndex();
- LPCTSTR GetBindTabLayoutName();
- void SetHotFont(int index);
- int GetHotFont() const;
- void SetPushedFont(int index);
- int GetPushedFont() const;
- void SetFocusedFont(int index);
- int GetFocusedFont() const;
- void SetHotBkColor(DWORD dwColor);
- DWORD GetHotBkColor() const;
- void SetPushedBkColor(DWORD dwColor);
- DWORD GetPushedBkColor() const;
- void SetDisabledBkColor(DWORD dwColor);
- DWORD GetDisabledBkColor() const;
- void SetHotTextColor(DWORD dwColor);
- DWORD GetHotTextColor() const;
- void SetPushedTextColor(DWORD dwColor);
- DWORD GetPushedTextColor() const;
- void SetFocusedTextColor(DWORD dwColor);
- DWORD GetFocusedTextColor() const;
- void SetHotBorderColor(DWORD dwColor);
- DWORD GetHotBorderColor() const;
- void SetPushedBorderColor(DWORD dwColor);
- DWORD GetPushedBorderColor() const;
- void SetDisabledBorderColor(DWORD dwColor);
- DWORD GetDisabledBorderColor() const;
- void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
- void PaintText(HDC hDC);
- void PaintBkColor(HDC hDC);
- void PaintStatusImage(HDC hDC);
- void PaintBorder(HDC hDC);
- void PaintForeImage(HDC hDC);
- void DrawBorder(HDC hDC, const RECT& rcItem, const DWORD& dwBorderColor, const int& nBorderSize, const RECT& rcBorderSize, const SIZE& cxyBorderRound, const int& nBorderStyle);
- protected:
- UINT m_uButtonState;
- int m_iHotFont;
- int m_iPushedFont;
- int m_iFocusedFont;
- DWORD m_dwHotBkColor;
- DWORD m_dwPushedBkColor;
- DWORD m_dwDisabledBkColor;
- DWORD m_dwHotTextColor;
- DWORD m_dwPushedTextColor;
- DWORD m_dwFocusedTextColor;
- DWORD m_dwHotBorderColor;
- DWORD m_dwPushedBorderColor;
- DWORD m_dwDisabledBorderColor;
- CDuiString m_sNormalImage;
- CDuiString m_sHotImage;
- CDuiString m_sHotForeImage;
- CDuiString m_sPushedImage;
- CDuiString m_sPushedForeImage;
- CDuiString m_sFocusedImage;
- CDuiString m_sDisabledImage;
- int m_nStateCount;
- CDuiString m_sStateImage;
- int m_iBindTabIndex;
- CDuiString m_sBindTabLayoutName;
- };
- } // namespace DuiLib
- #endif // __UIBUTTON_H__
|