Files
player/Project/Src/MyWin/Window/mywin_inputbox.c

164 lines
3.1 KiB
C
Raw Normal View History

2025-06-27 00:32:57 +08:00
#include "mywin_inc.h"
#define WIN_INPUTBOX_TYPE "WIN_InputboxStruct"
WIN_InputboxStruct *WIN_CreatInputbox (WIN_WindowStruct *base,
void (*msgLoop)(struct _WIN_WindowStruct *win,WIN_MsgStruct *msg),
int x,int y,int x_size,int y_size)
{
2025-07-05 19:47:28 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣѭ<CFA2><D1AD>
2025-06-27 00:32:57 +08:00
if (msgLoop==0)
{
msgLoop=(void (*)(struct _WIN_WindowStruct *win,WIN_MsgStruct *msg))INPUTBOX_DefaultMsgLoop;
}
WIN_InputboxStruct *ret=mymalloc (sizeof ( WIN_InputboxStruct));
2025-07-05 19:47:28 +08:00
//<2F><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><ECBAAF>
2025-06-27 00:32:57 +08:00
if (ret)
{
mymemset (ret,0,sizeof ( WIN_InputboxStruct));
if (0==WIN_CreatWindowExt((WIN_WindowStruct *)ret,base,msgLoop,x,y,x_size,y_size))
{
2025-07-05 19:47:28 +08:00
//<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
2025-06-27 00:32:57 +08:00
myfree (ret);
ret=0;
}
else
{
2025-07-05 19:47:28 +08:00
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
2025-06-27 00:32:57 +08:00
((WIN_WindowStruct *)ret)->winType=WIN_INPUTBOX_TYPE;
((WIN_WindowStruct *)ret)->bkcolor=0x342f2a;
((WIN_WindowStruct *)ret)->color=0xc2ae9b;
2025-07-05 19:47:28 +08:00
((WIN_WindowStruct *)ret)->keyChid=1; //<2F><>Ϊ<EFBFBD>Ӵ<EFBFBD><D3B4>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD>
2025-06-27 00:32:57 +08:00
ret->color_light=0xffffff;
ret->color_dark=0x808080;
}
}
return ret;
}
int INPUTBOX_Clear(WIN_InputboxStruct *box)
{
mymemset(box->inputs,0,INPUTBOX_MAX_CHAR_NUM);
WIN_SetInvalid ((WIN_WindowStruct *)box);
return 0;
}
int INPUTBOX_SetChars(WIN_InputboxStruct *box,char *str)
{
int len=strlen(str)+1;
if (len>INPUTBOX_MAX_CHAR_NUM)
return -1;
mymemcpy(box->inputs,str,len);
WIN_SetInvalid ((WIN_WindowStruct *)box);
return 0;
}
void INPUTBOX_DefaultPaint (WIN_InputboxStruct *box)
{
int x=0;
int y=0;
int x_size=((WIN_WindowStruct *)box)->x_size;
int y_size=((WIN_WindowStruct *)box)->y_size;
WIN_PaintBackGround ((WIN_WindowStruct *)box);
WIN_SetLcdColor (((WIN_WindowStruct *)box)->color);
WIN_DrawTxtAtRect(box->inputs,x+1,y+1,x_size-2,y_size-2);
2025-07-05 19:47:28 +08:00
//<2F><><EFBFBD>Ʊ߿<C6B1>
2025-06-27 00:32:57 +08:00
if (box->press)
WIN_SetLcdColor (box->color_light);
else
WIN_SetLcdColor (box->color_dark);
WIN_DrawRect (0,0,((WIN_WindowStruct *)box)->x_size,((WIN_WindowStruct *)box)->y_size);
}
void INPUTBOX_DefaultMsgLoop (WIN_InputboxStruct *box,WIN_MsgStruct *msg)
{
WIN_MoveStruct *m=0;
WIN_KeyStruct *k=0;
switch (msg->msg)
{
case WIN_MSG_PAINT:
INPUTBOX_DefaultPaint(box);
break;
case WIN_MSG_KEY:
k=msg->data.p;
if (k->shortPress& KEY_VALUE_DOWN)
{
}
else if (k->shortPress&KEY_VALUE_UP)
{
}
break;
case WIN_MSG_MOVE:
m=msg->data.p;
switch (m->moveType)
{
case MOVE_DATA_TOUCHIN:
box->press=1;
WIN_SetInvalid ((WIN_WindowStruct *)box);
break;
case MOVE_DATA_TOUCHOUT:
if (box->press)
{
box->press=0;
2025-07-05 19:47:28 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2025-06-27 00:32:57 +08:00
INPUT_KeyBoard(((WIN_WindowStruct *)box)->baseWin,box->inputs,INPUTBOX_MAX_CHAR_NUM);
WIN_SetInvalid ((WIN_WindowStruct *)box);
}
break;
case MOVE_DATA_MOVEOUT:
box->press=0;
WIN_SetInvalid ((WIN_WindowStruct *)box);
default:
break;
}
break;
default:
WIN_DefaultMsgLoop((WIN_WindowStruct *)box,msg);
break;
}
}
WIN_InputboxStruct *INPUTBOX_InputChars (WIN_WindowStruct *base,int x,int y,int x_size,int y_size)
{
WIN_InputboxStruct *box=WIN_CreatInputbox(base,0,x,y,x_size,y_size);
2025-07-05 19:47:28 +08:00
//<2F><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
2025-06-27 00:32:57 +08:00
WIN_SetBackPic ((WIN_WindowStruct *)box);
WIN_ShowWindow((WIN_WindowStruct *)box);
return box;
}