📄 radio.lst
字号:
RADIO_SetValue(hObj, Sel);
}
WM_Invalidate(hObj);
Notification = WM_NOTIFICATION_CLICKED;
WM_SetFocus(hObj);
}
} else {
Hit =1;
Notification = WM_NOTIFICATION_RELEASED;
}
} else {
Notification = WM_NOTIFICATION_MOVED_OUT;
}
WM_NotifyParent(hObj, Notification);
if (Hit == 1) {
GUI_DEBUG_LOG("RADIO: Hit\n");
GUI_StoreKey(pObj->Widget.Id);
}
}
/*********************************************************************
*
* _OnKey
*/
static void _OnKey(RADIO_Handle hObj, WM_MESSAGE*pMsg) {
WM_KEY_INFO* pKeyInfo;
int Key;
pKeyInfo = (WM_KEY_INFO*)(pMsg->Data.p);
C51 COMPILER V8.05a RADIO 04/11/2008 14:19:37 PAGE 5
Key = pKeyInfo->Key;
if (pKeyInfo->PressedCnt > 0) {
switch (Key) {
case GUI_KEY_RIGHT:
case GUI_KEY_DOWN:
RADIO_Inc(hObj);
break; /* Send to parent by not doing anything */
case GUI_KEY_LEFT:
case GUI_KEY_UP:
RADIO_Dec(hObj);
break; /* Send to parent by not doing anything */
default:
return;
}
}
}
/*********************************************************************
*
* _Callback
*/
static void _RADIO_Callback (WM_MESSAGE *pMsg) {
RADIO_Handle hObj;
RADIO_Obj* pObj;
hObj = pMsg->hWin;
pObj = RADIO_H2P(hObj);
/* Let widget handle the standard messages */
if (WIDGET_HandleActive(hObj, pMsg) == 0) {
return;
}
switch (pMsg->MsgId) {
case WM_PAINT:
GUI_DEBUG_LOG("RADIO: _Callback(WM_PAINT)\n");
_Paint(hObj, pObj);
return;
case WM_TOUCH:
_OnTouch(hObj, pObj, pMsg);
break;
case WM_KEY:
_OnKey(hObj, pMsg);
break;
}
WM_DefaultProc(pMsg);
}
/*********************************************************************
*
* Exported routines: Create
*
**********************************************************************
*/
/* Note: the parameters to a create function may vary.
Some widgets may have multiple create functions */
RADIO_Handle RADIO_Create (int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags, unsig
-ned Para) {
RADIO_Handle hObj;
unsigned NumItems;
unsigned Spacing;
int Height = 15;
C51 COMPILER V8.05a RADIO 04/11/2008 14:19:37 PAGE 6
/* Create the window */
WM_LOCK();
/* Calculate helper variables */
Spacing = (Para >> 8) & 255;
if (Spacing == 0) {
Spacing = 20;
}
NumItems = Para & 255;
if (NumItems == 0) {
NumItems = 2;
}
if (ysize == 0) {
ysize = Height + ((NumItems-1) * Spacing);
}
hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent,
Flags, _RADIO_Callback, sizeof(RADIO_Obj)-sizeof(WM_Obj));
if (hObj) {
RADIO_Obj* pObj = RADIO_H2P(hObj);
/* init widget specific variables */
WIDGET__Init(&pObj->Widget, WIDGET_STATE_FOCUSSABLE | WIDGET_STATE_ENABLED);
pObj->Widget.Id = Id;
/* init member variables */
RADIO_INIT_ID(pObj);
pObj->aBkColor[0] = RADIO_BKCOLOR0_DEFAULT;
pObj->aBkColor[1] = RADIO_BKCOLOR1_DEFAULT;
pObj->NumItems = NumItems;
pObj->Spacing = Spacing;
pObj->Height = Height;
} else {
GUI_DEBUG_ERROROUT_IF(hObj==0, "RADIO_Create failed")
}
WM_UNLOCK();
return hObj;
}
RADIO_Handle RADIO_CreateIndirect(const GUI_WIDGET_CREATE_INFO* pCreateInfo, WM_HWIN hWinParent, int x0, i
-nt y0, WM_CALLBACK* cb) {
RADIO_Handle hThis;
GUI_USE_PARA(cb);
hThis = RADIO_Create(pCreateInfo->x0 + x0, pCreateInfo->y0 + y0, 16, 0,
hWinParent, pCreateInfo->Id, pCreateInfo->Flags, pCreateInfo->Para);
return hThis;
}
/*********************************************************************
*
* Exported routines: Various methods
*
**********************************************************************
*/
void RADIO_AddValue(RADIO_Handle hObj, int Add) {
RADIO_Obj* pObj;
if (hObj) {
WM_LOCK();
pObj = RADIO_H2P(hObj);
RADIO_SetValue(hObj, pObj->Sel + Add);
WM_UNLOCK();
}
}
void RADIO_Dec(RADIO_Handle hObj) { RADIO_AddValue(hObj, -1); }
C51 COMPILER V8.05a RADIO 04/11/2008 14:19:37 PAGE 7
void RADIO_Inc(RADIO_Handle hObj) { RADIO_AddValue(hObj, 1); }
void RADIO_SetValue(RADIO_Handle hObj, int v) {
RADIO_Obj* pObj;
int Max;
if (hObj) {
WM_LOCK();
pObj = RADIO_H2P(hObj);
Max = pObj->NumItems - 1;
if (Max < 0)
Max =0;
/* Put in min/max range */
if (v < 0) {
v = 0;
}
if (v > Max) {
v = Max;
}
if (pObj->Sel != v) {
pObj->Sel = v;
WM_InvalidateWindow(hObj);
WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED);
}
WM_UNLOCK();
}
}
/*********************************************************************
*
* Exported routines: Query state
*
**********************************************************************
*/
int RADIO_GetValue(RADIO_Handle hObj) {
int r = 0;
RADIO_Obj* pObj;
if (hObj) {
WM_LOCK();
pObj = RADIO_H2P(hObj);
r = pObj->Sel;
WM_UNLOCK();
}
return r;
}
#endif /* #if GUI_WINSUPPORT */
411
412
413
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = ---- ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
C51 COMPILER V8.05a RADIO 04/11/2008 14:19:37 PAGE 8
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -