Browse::Open Source > VC/C++/C# >

DirectUI interface library

Time:2011-06-03 Author:xmboo.com Click:

China's first open source directui interface library, open, sharing, public benefits, win-win situation, follow the bsd protocol, free for commercial projects, now supports Windows 32, Window CE, Mobile and other platforms. 

wohtml.com,wohtml.com

[code] [C/C++/Objective-C]

001 #ifndef __UICONTROL_H__
002 #define __UICONTROL_H__
003  
004 #pragma once
005  
006 namespace DuiLib {
007  
008 /////////////////////////////////////////////////////////////////////////////////////
009 //
010  
011 typedef CControlUI* (CALLBACK* FINDCONTROLPROC)(CControlUI*, LPVOID);
012  
013 class UILIB_API CControlUI
014 {
015 public:
016     CControlUI();
017     virtual ~CControlUI();
018  
019 public:
020     virtual CStdString GetName() const;
021     virtual void SetName(LPCTSTR pstrName);
022     virtual LPCTSTR GetClass() const;
023     virtual LPVOID GetInterface(LPCTSTR pstrName);
024     virtual UINT GetControlFlags() const;
025  
026     virtual bool Activate();
027     virtual CPaintManagerUI* GetManager() const;
028     virtual void SetManager(CPaintManagerUI* pManager, CControlUI* pParent, bool bInit = true);
029     virtual CControlUI* GetParent() const;
030  
031     // 文本相关
032     virtual CStdString GetText() const;
033     virtual void SetText(LPCTSTR pstrText);
034  
035     // 图形相关
036     DWORD GetBkColor() const;
037     void SetBkColor(DWORD dwBackColor);
038     DWORD GetBkColor2() const;
039     void SetBkColor2(DWORD dwBackColor);
040     DWORD GetBkColor3() const;
041     void SetBkColor3(DWORD dwBackColor);
042     LPCTSTR GetBkImage();
043     void SetBkImage(LPCTSTR pStrImage);
044     DWORD GetBorderColor() const;
045     void SetBorderColor(DWORD dwBorderColor);
046     DWORD GetFocusBorderColor() const;
047     void SetFocusBorderColor(DWORD dwBorderColor);
048     int GetBorderSize() const;
049     void SetBorderSize(int nSize);
050     SIZE GetBorderRound() const;
051     void SetBorderRound(SIZE cxyRound);
052     bool DrawImage(HDC hDC, LPCTSTR pStrImage, LPCTSTR pStrModify = NULL);
053  
054     // 位置相关
055     virtual const RECT& GetPos() const;
056     virtual void SetPos(RECT rc);
057     virtual int GetWidth() const;
058     virtual int GetHeight() const;
059     virtual int GetX() const;
060     virtual int GetY() const;
061     virtual RECT GetPadding() const;
062     virtual void SetPadding(RECT rcPadding); // 设置外边距,由上层窗口绘制
063     virtual SIZE GetFixedXY() const;         // 实际大小位置使用GetPos获取,这里得到的是预设的参考值
064     virtual void SetFixedXY(SIZE szXY);      // 仅float为true时有效
065     virtual int GetFixedWidth() const;       // 实际大小位置使用GetPos获取,这里得到的是预设的参考值
066     virtual void SetFixedWidth(int cx);      // 预设的参考值
067     virtual int GetFixedHeight() const;      // 实际大小位置使用GetPos获取,这里得到的是预设的参考值
068     virtual void SetFixedHeight(int cy);     // 预设的参考值
069     virtual int GetMinWidth() const;
070     virtual void SetMinWidth(int cx);
071     virtual int GetMaxWidth() const;
072     virtual void SetMaxWidth(int cx);
073     virtual int GetMinHeight() const;
074     virtual void SetMinHeight(int cy);
075     virtual int GetMaxHeight() const;
076     virtual void SetMaxHeight(int cy);
077     virtual void SetRelativePos(SIZE szMove,SIZE szZoom);
078     virtual void SetRelativeParentSize(SIZE sz);
079     virtual TRelativePosUI GetRelativePos() const;
080     virtual bool IsRelativePos() const;
081  
082     // 鼠标提示
083     virtual CStdString GetToolTip() const;
084     virtual void SetToolTip(LPCTSTR pstrText);
085  
086     // 快捷键
087     virtual TCHAR GetShortcut() const;
088     virtual void SetShortcut(TCHAR ch);
089  
090     // 菜单
091     virtual bool IsContextMenuUsed() const;
092     virtual void SetContextMenuUsed(bool bMenuUsed);
093  
094     // 用户属性
095     virtual const CStdString& GetUserData(); // 辅助函数,供用户使用
096     virtual void SetUserData(LPCTSTR pstrText); // 辅助函数,供用户使用
097     virtual UINT_PTR GetTag() const; // 辅助函数,供用户使用
098     virtual void SetTag(UINT_PTR pTag); // 辅助函数,供用户使用
099  
100     // 一些重要的属性
101     virtual bool IsVisible() const;
102     virtual void SetVisible(bool bVisible = true);
103     virtual void SetInternVisible(bool bVisible = true); // 仅供内部调用,有些UI拥有窗口句柄,需要重写此函数
104     virtual bool IsEnabled() const;
105     virtual void SetEnabled(bool bEnable = true);
106     virtual bool IsMouseEnabled() const;
107     virtual void SetMouseEnabled(bool bEnable = true);
108     virtual bool IsFocused() const;
109     virtual void SetFocus();
110     virtual bool IsFloat() const;
111     virtual void SetFloat(bool bFloat = true);
112  
113     virtual CControlUI* FindControl(FINDCONTROLPROC Proc, LPVOID pData, UINT uFlags);
114  
115     void Invalidate();
116     bool IsUpdateNeeded() const;
117     void NeedUpdate();
118     void NeedParentUpdate();
119  
120     virtual void Init(TEventUI& event);
121     virtual void DoInit();
122  
123     virtual void Event(TEventUI& event);
124     virtual void DoEvent(TEventUI& event);
125  
126     virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
127     CControlUI* ApplyAttributeList(LPCTSTR pstrList);
128  
129     virtual SIZE EstimateSize(SIZE szAvailable);
130  
131     virtual void DoPaint(HDC hDC, const RECT& rcPaint);
132     virtual void PaintBkColor(HDC hDC);
133     virtual void PaintBkImage(HDC hDC);
134     virtual void PaintStatusImage(HDC hDC);
135     virtual void PaintText(HDC hDC);
136     virtual void PaintBorder(HDC hDC);
137  
138     virtual void DoPostPaint(HDC hDC, const RECT& rcPaint);
139  
140 public:
141     CEventSource OnInit;
142     CEventSource OnDestroy;
143     CEventSource OnEvent;
144  
145 protected:
146     CPaintManagerUI* m_pManager;
147     CControlUI* m_pParent;
148     CStdString m_sName;
149     bool m_bUpdateNeeded;
150     bool m_bMenuUsed;
151     RECT m_rcItem;
152     RECT m_rcPadding;
153     SIZE m_cXY;
154     SIZE m_cxyFixed;
155     SIZE m_cxyMin;
156     SIZE m_cxyMax;
157     bool m_bVisible;
158     bool m_bInternVisible;
159     bool m_bEnabled;
160     bool m_bMouseEnabled;
161     bool m_bFocused;
162     bool m_bFloat;
163     bool m_bFloatSetPos; // 防止SetPos循环调用
164     TRelativePosUI m_tRelativePos;
165  
166     CStdString m_sText;
167     CStdString m_sToolTip;
168     TCHAR m_chShortcut;
169     CStdString m_sUserData;
170     UINT_PTR m_pTag;
171  
172     DWORD m_dwBackColor;
173     DWORD m_dwBackColor2;
174     DWORD m_dwBackColor3;
175     CStdString m_sBkImage;
176     DWORD m_dwBorderColor;
177     DWORD m_dwFocusBorderColor;
178     int m_nBorderSize;
179     SIZE m_cxyBorderRound;
180     RECT m_rcPaint;
181 };
182  
183 } // namespace DuiLib
184  
185 #endif // __UICONTROL_H__

copyright:wohtml.com

 

 

 

Wonderful,direct access to the view: www.ecleads.com www.xmu9.com www.xm94.com
Keywords: DirectUI,library,Open Source,Php Program,Asp Program,Js Script (Source:go2html.com)
TAGS: DirectUI(1)library(1)
cndo.org