|
HiEasyX
Ver 0.3.0
EasyX 全面扩展库
|
控件基础
更多...
#include <ControlBase.h>
|
| ControlBase () |
|
| ControlBase (std::wstring wstrText) |
|
| ControlBase (int x, int y, int w=0, int h=0, std::wstring wstrText=L"") |
|
virtual | ~ControlBase () |
|
ControlBase * | GetParent () |
|
virtual void | SetParent (ControlBase *p) |
| 设置父控件(父控件调用 AddChild) 更多...
|
|
virtual bool | IsAutoSizeForChild () const |
|
virtual void | EnableAutoSizeForChild (bool enable) |
| 为子控件自动改变大小以容纳控件(不容纳负坐标部分) 更多...
|
|
std::list< ControlBase * > & | GetChildList () |
|
size_t | GetChildCount () |
| 获取子控件总数 更多...
|
|
virtual void | AddChild (ControlBase *p, int offset_x=0, int offset_y=0) |
|
virtual void | RemoveChild (ControlBase *p) |
|
virtual bool | IsEnabled () const |
|
virtual void | SetEnable (bool enable) |
|
virtual bool | IsVisible () const |
|
virtual void | SetVisible (bool visible) |
|
virtual bool | GetAutoRedrawState () const |
|
virtual void | EnableAutoRedraw (bool enable) |
| 启用自动重绘(接受到基础消息事件时自动标识需要重绘) 更多...
|
|
virtual Canvas & | GetCanvas () |
|
virtual COLORREF | GetBkColor () const |
|
virtual void | SetBkColor (COLORREF color) |
|
virtual COLORREF | GetTextColor () const |
|
virtual void | SetTextColor (COLORREF color) |
|
virtual void | EnableBorder (bool bEnableBorder, COLORREF color=BLACK, int thickness=1) |
|
virtual void | SetAlpha (BYTE alpha, bool bUseCanvasAlpha, bool isAlphaCalculated) |
|
virtual std::wstring | GetText () const |
|
virtual void | SetText (std::wstring wstr) |
|
virtual void | Draw_Text (int nTextOffsetX=0, int nTextOffsetY=0) |
|
virtual void | Redraw () |
| 重绘控件 更多...
|
|
virtual void | Draw (bool draw_child=true) |
| 绘制控件 更多...
|
|
virtual void | Render (Canvas *dst, RECT *pRct=nullptr, int *pCount=0) |
| 渲染控件到外部 更多...
|
|
virtual void | SetMsgProcFunc (MESSAGE_PROC_FUNC func) |
| 设置消息响应函数 更多...
|
|
virtual void | SetMsgProcFunc (MESSAGE_PROC_FUNC_CLASS static_class_func, void *_this) |
| 设置消息响应函数为静态类函数 更多...
|
|
virtual void | UpdateMessage (ExMessage msg) |
| 更新消息 更多...
|
|
virtual bool | IsHovered () const |
| 判断鼠标是否悬停 更多...
|
|
virtual bool | IsFocused () const |
| 判断是否拥有焦点 更多...
|
|
virtual bool | IsPressed () const |
| 判断是否按下 更多...
|
|
| Container () |
|
virtual | ~Container () |
|
RECT | GetRect () const |
|
void | SetRect (int x, int y, int w, int h) |
| 设置位置和宽高 更多...
|
|
void | SetRect (RECT rct) |
| 设置矩形区域 更多...
|
|
POINT | GetPos () const |
|
int | GetX () const |
|
int | GetY () const |
|
void | SetPos (int x, int y) |
|
void | SetPos (POINT pt) |
|
void | Move (int x, int y) |
|
void | MoveRel (int dx, int dy) |
|
int | GetWidth () const |
|
void | SetWidth (int w) |
|
int | GetHeight () const |
|
void | SetHeight (int h) |
|
void | Resize (int w, int h) |
|
控件基础
在文件 ControlBase.h 第 52 行定义.
◆ ControlBase() [1/3]
HiEasyX::ControlBase::ControlBase |
( |
| ) |
|
◆ ControlBase() [2/3]
HiEasyX::ControlBase::ControlBase |
( |
std::wstring |
wstrText | ) |
|
◆ ControlBase() [3/3]
HiEasyX::ControlBase::ControlBase |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
w = 0 , |
|
|
int |
h = 0 , |
|
|
std::wstring |
wstrText = L"" |
|
) |
| |
◆ ~ControlBase()
HiEasyX::ControlBase::~ControlBase |
( |
| ) |
|
|
virtual |
◆ AddChild()
void HiEasyX::ControlBase::AddChild |
( |
ControlBase * |
p, |
|
|
int |
offset_x = 0 , |
|
|
int |
offset_y = 0 |
|
) |
| |
|
virtual |
◆ CallUserMsgProcFunc()
void HiEasyX::ControlBase::CallUserMsgProcFunc |
( |
int |
msgid, |
|
|
ExMessage |
msg |
|
) |
| |
|
protectedvirtual |
◆ ChildRectChanged()
void HiEasyX::ControlBase::ChildRectChanged |
( |
ControlBase * |
pChild | ) |
|
|
protectedvirtual |
子控件区域变更
- 参数
-
在文件 ControlBase.cpp 第 380 行定义.
385 if (pChild->m_rct.right > _w) _w += pChild->m_rct.right - _w;
386 if (pChild->m_rct.bottom > _h) _h += pChild->m_rct.bottom - _h;
◆ Draw()
void HiEasyX::ControlBase::Draw |
( |
bool |
draw_child = true | ) |
|
|
virtual |
◆ Draw_Text()
void HiEasyX::ControlBase::Draw_Text |
( |
int |
nTextOffsetX = 0 , |
|
|
int |
nTextOffsetY = 0 |
|
) |
| |
|
virtual |
◆ DrawChild()
void HiEasyX::ControlBase::DrawChild |
( |
| ) |
|
|
protectedvirtual |
◆ EnableAutoRedraw()
void HiEasyX::ControlBase::EnableAutoRedraw |
( |
bool |
enable | ) |
|
|
virtual |
◆ EnableAutoSizeForChild()
void HiEasyX::ControlBase::EnableAutoSizeForChild |
( |
bool |
enable | ) |
|
|
virtual |
◆ EnableBorder()
void HiEasyX::ControlBase::EnableBorder |
( |
bool |
bEnableBorder, |
|
|
COLORREF |
color = BLACK , |
|
|
int |
thickness = 1 |
|
) |
| |
|
virtual |
◆ GetAutoRedrawState()
virtual bool HiEasyX::ControlBase::GetAutoRedrawState |
( |
| ) |
const |
|
inlinevirtual |
◆ GetBkColor()
virtual COLORREF HiEasyX::ControlBase::GetBkColor |
( |
| ) |
const |
|
inlinevirtual |
◆ GetCanvas()
virtual Canvas& HiEasyX::ControlBase::GetCanvas |
( |
| ) |
|
|
inlinevirtual |
◆ GetChildCount()
size_t HiEasyX::ControlBase::GetChildCount |
( |
| ) |
|
◆ GetChildList()
std::list< ControlBase * > & HiEasyX::ControlBase::GetChildList |
( |
| ) |
|
◆ GetParent()
◆ GetText()
virtual std::wstring HiEasyX::ControlBase::GetText |
( |
| ) |
const |
|
inlinevirtual |
◆ GetTextColor()
virtual COLORREF HiEasyX::ControlBase::GetTextColor |
( |
| ) |
const |
|
inlinevirtual |
◆ IsAutoSizeForChild()
virtual bool HiEasyX::ControlBase::IsAutoSizeForChild |
( |
| ) |
const |
|
inlinevirtual |
◆ IsEnabled()
virtual bool HiEasyX::ControlBase::IsEnabled |
( |
| ) |
const |
|
inlinevirtual |
◆ IsFocused()
virtual bool HiEasyX::ControlBase::IsFocused |
( |
| ) |
const |
|
inlinevirtual |
◆ IsHovered()
virtual bool HiEasyX::ControlBase::IsHovered |
( |
| ) |
const |
|
inlinevirtual |
◆ IsPressed()
virtual bool HiEasyX::ControlBase::IsPressed |
( |
| ) |
const |
|
inlinevirtual |
◆ IsVisible()
virtual bool HiEasyX::ControlBase::IsVisible |
( |
| ) |
const |
|
inlinevirtual |
◆ MarkNeedClearRect()
void HiEasyX::ControlBase::MarkNeedClearRect |
( |
RECT |
rct | ) |
|
|
protected |
◆ MarkNeedRedrawAndRender()
void HiEasyX::ControlBase::MarkNeedRedrawAndRender |
( |
| ) |
|
|
protected |
◆ Redraw()
void HiEasyX::ControlBase::Redraw |
( |
| ) |
|
|
virtual |
◆ RemoveChild()
void HiEasyX::ControlBase::RemoveChild |
( |
ControlBase * |
p | ) |
|
|
virtual |
◆ Render()
void HiEasyX::ControlBase::Render |
( |
Canvas * |
dst, |
|
|
RECT * |
pRct = nullptr , |
|
|
int * |
pCount = 0 |
|
) |
| |
|
virtual |
渲染控件到外部
- 参数
-
[in] | dst | 渲染目标 |
[in] | pRct | 内部使用,传入父控件渲染区域数组 |
[in,out] | pCount | 内部使用,传入父控件渲染区域数量指针 |
被 HiEasyX::Page 重载.
在文件 ControlBase.cpp 第 254 行定义.
258 RECT* my_rct =
new RECT[size];
269 dst->ClearRectangle(child->m_rctClear);
271 child->m_bClear =
false;
272 child->m_rctClear = { 0 };
300 child->Render(&
m_canvas, my_rct, &my_count);
307 for (
int i = 0; i < my_count; i++)
309 dst->PutImageIn_Alpha(
320 for (
int i = 0; i < my_count; i++)
323 pRct[(*pCount)++] = my_rct[i];
◆ SetAlpha()
void HiEasyX::ControlBase::SetAlpha |
( |
BYTE |
alpha, |
|
|
bool |
bUseCanvasAlpha, |
|
|
bool |
isAlphaCalculated |
|
) |
| |
|
virtual |
◆ SetBkColor()
void HiEasyX::ControlBase::SetBkColor |
( |
COLORREF |
color | ) |
|
|
virtual |
◆ SetEnable()
void HiEasyX::ControlBase::SetEnable |
( |
bool |
enable | ) |
|
|
virtual |
◆ SetMsgProcFunc() [1/2]
◆ SetMsgProcFunc() [2/2]
设置消息响应函数为静态类函数
- 参数
-
[in] | static_class_func | 消息响应函数(静态类函数) |
[in] | _this | 类指针 |
在文件 ControlBase.cpp 第 347 行定义.
◆ SetParent()
void HiEasyX::ControlBase::SetParent |
( |
ControlBase * |
p | ) |
|
|
virtual |
◆ SetText()
void HiEasyX::ControlBase::SetText |
( |
std::wstring |
wstr | ) |
|
|
virtual |
◆ SetTextColor()
void HiEasyX::ControlBase::SetTextColor |
( |
COLORREF |
color | ) |
|
|
virtual |
◆ SetVisible()
void HiEasyX::ControlBase::SetVisible |
( |
bool |
visible | ) |
|
|
virtual |
◆ TransformMessage()
ExMessage & HiEasyX::ControlBase::TransformMessage |
( |
ExMessage & |
msg | ) |
|
|
protectedvirtual |
◆ UpdateMessage()
void HiEasyX::ControlBase::UpdateMessage |
( |
ExMessage |
msg | ) |
|
|
virtual |
更新消息
- 参数
-
被 HiEasyX::ScrollBar , 以及 HiEasyX::Button 重载.
在文件 ControlBase.cpp 第 391 行定义.
398 bool msg_worth_redraw =
false;
401 if (
IsInRect(msg.x, msg.y, { 0,0,GetWidth(),GetHeight() }))
435 case WM_LBUTTONDBLCLK:
449 msg_worth_redraw =
true;
461 msg_worth_redraw =
true;
470 msg_worth_redraw =
true;
482 msg_worth_redraw =
true;
504 child->UpdateMessage(msg);
◆ UpdateRect()
void HiEasyX::ControlBase::UpdateRect |
( |
RECT |
rctOld | ) |
|
|
overrideprotectedvirtual |
◆ m_alpha
BYTE HiEasyX::ControlBase::m_alpha = 255 |
|
protected |
◆ m_bAlwaysRedrawAndRender
bool HiEasyX::ControlBase::m_bAlwaysRedrawAndRender = false |
|
protected |
◆ m_bAutoRedrawWhenReceiveMsg
bool HiEasyX::ControlBase::m_bAutoRedrawWhenReceiveMsg = true |
|
protected |
◆ m_bAutoSizeForChild
bool HiEasyX::ControlBase::m_bAutoSizeForChild = false |
|
protected |
◆ m_bClear
bool HiEasyX::ControlBase::m_bClear = false |
|
protected |
◆ m_bCompleteFirstSetRect
bool HiEasyX::ControlBase::m_bCompleteFirstSetRect = false |
|
protected |
◆ m_bEnableBorder
bool HiEasyX::ControlBase::m_bEnableBorder = true |
|
protected |
◆ m_bEnabled
bool HiEasyX::ControlBase::m_bEnabled = true |
|
protected |
◆ m_bFocused
bool HiEasyX::ControlBase::m_bFocused = false |
|
protected |
◆ m_bHovered
bool HiEasyX::ControlBase::m_bHovered = false |
|
protected |
◆ m_bPressed
bool HiEasyX::ControlBase::m_bPressed = false |
|
protected |
◆ m_bRedraw
bool HiEasyX::ControlBase::m_bRedraw = true |
|
protected |
◆ m_bRender
bool HiEasyX::ControlBase::m_bRender = true |
|
protected |
◆ m_bUseCanvasAlpha
bool HiEasyX::ControlBase::m_bUseCanvasAlpha = false |
|
protected |
◆ m_bVisible
bool HiEasyX::ControlBase::m_bVisible = true |
|
protected |
◆ m_canvas
Canvas HiEasyX::ControlBase::m_canvas |
|
protected |
◆ m_cBackground
COLORREF HiEasyX::ControlBase::m_cBackground = CLASSICGRAY |
|
protected |
◆ m_cBorder
◆ m_cText
COLORREF HiEasyX::ControlBase::m_cText = BLACK |
|
protected |
◆ m_funcMessageProc
◆ m_funcMessageProc_Class
◆ m_isAlphaCalculated
bool HiEasyX::ControlBase::m_isAlphaCalculated = false |
|
protected |
◆ m_listChild
std::list<ControlBase*> HiEasyX::ControlBase::m_listChild |
|
protected |
◆ m_nBorderThickness
int HiEasyX::ControlBase::m_nBorderThickness = 1 |
|
protected |
◆ m_pCalledClass
void* HiEasyX::ControlBase::m_pCalledClass = nullptr |
|
protected |
◆ m_pParent
◆ m_rctClear
RECT HiEasyX::ControlBase::m_rctClear = { 0 } |
|
protected |
◆ m_wstrText
std::wstring HiEasyX::ControlBase::m_wstrText |
|
protected |
该类的文档由以下文件生成:
void MarkNeedRedrawAndRender()
标记需要重绘和渲染
MESSAGE_PROC_FUNC_CLASS m_funcMessageProc_Class
若绑定的消息处理函数是静态类函数,则记录其地址
void Resize(int w, int h)
void MarkNeedClearRect(RECT rct)
标记需要清空矩形区域
#define MOVE_RECT(rct, dx, dy)
void Resize(int w, int h) override
重设画布大小(若绑定了窗口,则不建议调用)
std::wstring m_wstrText
控件文本
void ClearRectangle(int left, int top, int right, int bottom)
MESSAGE_PROC_FUNC m_funcMessageProc
消息处理函数
virtual void DrawChild()
绘制子控件
int TextHeight(LPCTSTR lpszText)
bool m_bAlwaysRedrawAndRender
总是重绘和渲染(占用更高)
virtual void UpdateRect(RECT rctOld)
响应更新区域消息
ControlBase * m_pParent
父控件
void * m_pCalledClass
若绑定的消息处理函数是静态类函数,则记录该类指针
void SetLineThickness(int thickness)
virtual void RemoveChild(ControlBase *p)
void SetTextColor(COLORREF color)
UINT GetExMessageType(ExMessage msg)
获取 ExMessage 的消息类型
std::list< ControlBase * > m_listChild
子控件
int OutTextXY(int x, int y, LPCTSTR lpszText, bool isSetColor=false, COLORREF c=0)
在指定位置输出文本
bool m_bEnableBorder
是否绘制边框
virtual void Draw(bool draw_child=true)
绘制控件
int TextWidth(LPCTSTR lpszText)
获取文本像素宽度
virtual void ChildRectChanged(ControlBase *pChild)
子控件区域变更
void FillRectangle(int left, int top, int right, int bottom, bool isSetColor=false, COLORREF cLine=0, COLORREF cFill=0)
bool m_bAutoSizeForChild
为子控件自动改变大小以容纳控件
void SetRect(int x, int y, int w, int h)
设置位置和宽高
size_t GetChildCount()
获取子控件总数
virtual void CallUserMsgProcFunc(int msgid, ExMessage msg)
分发消息到用户函数
void SetBkColor(COLORREF color)
bool IsInRect(int x, int y, RECT rct)
点是否位于矩形内
int m_nBorderThickness
边框粗细
virtual void SetText(std::wstring wstr)
bool m_bAutoRedrawWhenReceiveMsg
当默认消息处理函数接受到消息时,是否自动标识重绘和渲染
virtual void AddChild(ControlBase *p, int offset_x=0, int offset_y=0)
virtual ExMessage & TransformMessage(ExMessage &msg)
转换消息
void SetLineColor(COLORREF color)
bool m_bUseCanvasAlpha
是否使用画布自身的透明度信息
bool m_bCompleteFirstSetRect
是否已经完成第一次设置区域
bool m_isAlphaCalculated
画布是否已经计算透明混合颜色
COLORREF m_cBackground
背景色