?? ew_radiobutton.cpp
字號:
/*--------------------------------------------------------------------------
RadioButton.cpp - 收音機按鈕類的實現文件
本程序是FishGUI軟件的一部分
版權所有 (C) 2003,2004 王詠武
http://www.contextfree.net/wangyw/
----------------------------------------------------------------------------
作者對 FishGUI 軟件及其所有源代碼授權如下:
允許任何個人、組織、機構、企業無償獲得、修改、使用、重新發布 FishGUI 軟
件及其源代碼,或按照有償或者無償的方式發行基于 FishGUI 源代碼的全部或部
分內容開發的軟件產品,——但行使以上權利時,須遵守以下約定:
1、重新發布 FishGUI 軟件及其源代碼時,不得隱去軟件及其源代碼中原有的版
權信息和開發者標識。
2、發行基于 FishGUI 源代碼的全部或部分內容開發的軟件產品時,必須在產品
的顯著位置標明以下字樣:
【本產品的一部分功能是基于王詠武在 FishGUI 軟件中的工作完成的】
3、在正式出版物中引用 FishGUI 的文檔、源代碼或注釋內容的,應注明軟件的
原作者為王詠武。
--------------------------------------------------------------------------*/
/*! \addtogroup Framework
* @{
*/
/*! \file
* \brief 收音機按鈕類的實現文件
*/
/*! @} */
#include "../Utility/EW_Utility.h"
#include "EW_RadioButton.h"
BEGIN_MESSAGE_MAP(EW_RadioButton, EW_TextWidget)
ON_DRAW (EW_RadioButton::OnDraw)
ON_KEYDOWN (EW_RadioButton::OnKeyDown)
ON_LBUTTONDOWN (EW_RadioButton::OnLButtonDown)
END_MESSAGE_MAP()
EW_RadioButton::EW_RadioButton(const char * Text, const EW_Rect & Rect, EW_RadioButton * const pSameGroup, const WORD wID)
: m_bChecked(false), EW_TextWidget(Text, Rect, wID, FS_NONE)
{
if (pSameGroup)
{
m_pNext = pSameGroup->m_pNext;
pSameGroup->m_pNext = this;
}
else
{
m_pNext = this;
}
}
//##ModelId=3F65E8E3031A
void EW_RadioButton::OnDraw(EW_OSAdaptor * pAdaptor)
{
pAdaptor->BeginDraw(m_Rect);
EW_TextWidget::OnDraw(pAdaptor);
EW_Rect rect;
GetClientRect(rect);
WORD y = rect.wTop + (rect.wBottom - rect.wTop + 1 - pAdaptor->GetTextHeight(GetText())) / 2;
// 繪制位圖
if (m_bChecked)
pAdaptor->DrawBitmap("Radio_EC", rect.wLeft, y + 2);
else
pAdaptor->DrawBitmap("Radio_ENC", rect.wLeft, y + 2);
// 繪制文本
if (TextLength())
{
WORD x = rect.wLeft + 14;
pAdaptor->DrawText(GetText(), x, y, m_ForeColor);
DrawTextFocus(pAdaptor, x, y);
}
pAdaptor->EndDraw();
}
//##ModelId=3F65E8E3032E
bool EW_RadioButton::OnKeyDown(EW_Message * pMsg)
{
if (pMsg->lData == FVK_ENTER)
{
UncheckGroup();
m_bChecked = true;
RequestDraw();
NotifyParent(FRN_CHECKED);
return true;
}
else
return false;
}
//##ModelId=3F65E8E30342
bool EW_RadioButton::OnLButtonDown(EW_Message * pMsg)
{
UncheckGroup();
m_bChecked = true;
RequestDraw();
NotifyParent(FRN_CHECKED);
return true;
}
//##ModelId=3F65EDEC0183
void EW_RadioButton::UncheckGroup(void)
{
EW_RadioButton * pRadio = m_pNext;
while (pRadio != this)
{
if (pRadio->m_bChecked)
{
pRadio->m_bChecked = false;
pRadio->RequestDraw();
NotifyParent(FRN_UNCHECKED);
}
pRadio = pRadio->m_pNext;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -