第三方框架改为仓内子集并完善构建忽略规则
完整 NIM_Duilib_Framework 仓库移至父目录,third_party 仅保留实际使用的 base、duilib、bin/resources 与许可证;.gitignore 覆盖 MSBuild 与打包产物。
This commit is contained in:
1 parent
249e8548de
commit
e1e26acc49
391 files changed
+342850
No files matched your search
@@ -0,0 +1,79 @@
|
||||
#ifndef UI_CONTROL_BUTTON_H_
|
||||
#define UI_CONTROL_BUTTON_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ui
|
||||
{
|
||||
template<typename InheritType = Control>
|
||||
class UILIB_API ButtonTemplate : public LabelTemplate<InheritType>
|
||||
{
|
||||
public:
|
||||
ButtonTemplate();
|
||||
|
||||
/// 重写父类方法,提供个性化功能,请参考父类声明
|
||||
virtual void Activate() override;
|
||||
virtual void HandleMessage(EventArgs& event) override;
|
||||
virtual UINT GetControlFlags() const override;
|
||||
|
||||
/**
|
||||
* @brief 绑定鼠标点击处理函数
|
||||
* @param[in] callback 要绑定的回调函数
|
||||
* @return 无
|
||||
*/
|
||||
void AttachClick(const EventCallback& callback) { this->OnEvent[kEventClick] += callback; }
|
||||
};
|
||||
|
||||
template<typename InheritType>
|
||||
UINT ui::ButtonTemplate<InheritType>::GetControlFlags() const
|
||||
{
|
||||
return this->IsKeyboardEnabled() && this->IsEnabled() ? UIFLAG_TABSTOP : UIFLAG_DEFAULT;
|
||||
}
|
||||
|
||||
template<typename InheritType>
|
||||
ButtonTemplate<InheritType>::ButtonTemplate()
|
||||
{
|
||||
this->m_uTextStyle = DT_VCENTER | DT_CENTER | DT_END_ELLIPSIS | DT_NOCLIP | DT_SINGLELINE;
|
||||
}
|
||||
|
||||
template<typename InheritType>
|
||||
void ButtonTemplate<InheritType>::HandleMessage(EventArgs& event)
|
||||
{
|
||||
if (!this->IsMouseEnabled() && event.Type > kEventMouseBegin && event.Type < kEventMouseEnd) {
|
||||
if (this->m_pParent != NULL) this->m_pParent->HandleMessageTemplate(event);
|
||||
else __super::HandleMessage(event);
|
||||
return;
|
||||
}
|
||||
if (event.Type == kEventKeyDown)
|
||||
{
|
||||
if (this->IsKeyboardEnabled()) {
|
||||
if (event.chKey == VK_SPACE || event.chKey == VK_RETURN) {
|
||||
Activate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event.Type == kEventInternalMenu)
|
||||
{
|
||||
if (this->IsContextMenuUsed()) {
|
||||
this->m_pWindow->SendNotify(this, kEventMouseMenu, event.wParam, event.lParam);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
__super::HandleMessage(event);
|
||||
}
|
||||
|
||||
template<typename InheritType>
|
||||
void ButtonTemplate<InheritType>::Activate()
|
||||
{
|
||||
if (!this->IsActivatable()) return;
|
||||
if (this->m_pWindow != NULL) this->m_pWindow->SendNotify(this, kEventClick);
|
||||
}
|
||||
|
||||
typedef ButtonTemplate<Control> Button;
|
||||
typedef ButtonTemplate<Box> ButtonBox;
|
||||
|
||||
} // namespace ui
|
||||
|
||||
#endif // UI_CONTROL_BUTTON_H_
|
||||
Reference in new issue
Block a user