Duilib::CGroupBoxUI 单选或者是多选

1 篇文章 0 订阅
//单选组合框
    class UILIB_API CGroupOptionUI : public CVerticalLayoutUI
    {
        DECLARE_DUICONTROL(CGroupOptionUI)
    public:
        CGroupOptionUI();
        ~CGroupOptionUI();
        LPCTSTR GetClass() const;
        LPVOID GetInterface(LPCTSTR pstrName);
        void SetTextColor(DWORD dwTextColor);
        DWORD GetTextColor() const;
        void SetDisabledTextColor(DWORD dwTextColor);
        DWORD GetDisabledTextColor() const;
        void SetFont(int index);
        int GetFont() const;
        //
        //单选框
        bool Activate();
        void SetEnabled(bool bEnable = true);
        void DoEvent(TEventUI& event);

        LPCTSTR GetGroup() const;
        void SetGroup(LPCTSTR pStrGroupName = NULL);
        bool IsSelected() const;
        virtual void Selected(bool bSelected, bool bMsg = true);

        void SetSelectedStateCount(int nCount);
        int GetSelectedStateCount() const;
        virtual LPCTSTR GetSelectedStateImage();
        virtual void SetSelectedStateImage(LPCTSTR pStrImage);

        LPCTSTR GetSelectedImage();
        void SetSelectedImage(LPCTSTR pStrImage);

        LPCTSTR GetSelectedHotImage();
        void SetSelectedHotImage(LPCTSTR pStrImage);

        LPCTSTR GetSelectedPushedImage();
        void SetSelectedPushedImage(LPCTSTR pStrImage);

        LPCTSTR GetSelectedForedImage();
        void SetSelectedForedImage(LPCTSTR pStrImage);
        //
        //按钮
        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);
        void SetStateCount(int nCount);
        int GetStateCount() const;
        virtual LPCTSTR GetStateImage();
        virtual void SetStateImage(LPCTSTR pStrImage);
        RECT GetTextPadding() const;
        void SetTextPadding(RECT rc);
        //
    protected:
        //Paint
        virtual void PaintText(HDC hDC);
        virtual void PaintBorder(HDC hDC);
        virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
        virtual void PaintStatusImage(HDC hDC);
        virtual void PaintImage(HDC hDC);
    private:
        SIZE CalcrectSize(SIZE szAvailable);
    protected:
        DWORD  m_dwTextColor;
        DWORD  m_dwDisabledTextColor;
        int    m_iFont;
        UINT   m_uTextStyle;
        RECT   m_rcOption;
        RECT   m_rcTextPadding;
        bool   m_bNeedEstimateSize;
        //
        //单选框
        bool			    m_bSelected;
        CDuiString		m_sGroupName;

        int m_nSelectedStateCount;
        CDuiString m_sSelectedStateImage;

        CDuiString		m_sSelectedImage;
        CDuiString		m_sSelectedHotImage;
        CDuiString		m_sSelectedPushedImage;
        CDuiString		m_sSelectedForeImage;
        //
        //按钮
        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;
    };
class UILIB_API CGroupCheckBoxUI : public CGroupOptionUI
    {
        DECLARE_DUICONTROL(CGroupCheckBoxUI)
    public:
        CGroupCheckBoxUI();

    public:
        virtual LPCTSTR GetClass() const;
        virtual LPVOID GetInterface(LPCTSTR pstrName);

        void SetCheck(bool bCheck);
        bool GetCheck() const;

    public:
        virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
        void SetAutoCheck(bool bEnable);
        virtual void DoEvent(TEventUI& event);
        virtual void Selected(bool bSelected, bool bMsg = true);

    protected:
        bool m_bAutoCheck;
    };

本代码是根据 DuiLib_Ultimate 版修改,需要的话请点击下载

看了这个代码是不是觉得眼熟,没错这个是就根据 COptionUI 和 CCheckBoxUI 而来,

但是有两个BUG,无法设置鼠标形状,还有就是图标和文字之间的边框线没有消除,看起来没那么好看,反正不影响使用,完美主义者自己改了

源码地址

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值