📄 ppadjinputbox.cpp
字号:
#include "ppADJInputBox.h"
#if _USE_GUI == 1
#define UGMB_OK_TEXT " 确 定 "
#define UGMB_CANCEL_TEXT " 取 消 "
#define UGMB_YES_TEXT " 是 "
#define UGMB_NO_TEXT " 否 "
#define UGMB_BUTTON_MARGIN 10
#define UGMB_MSGBOX_MARGIN 18
#define UGMB_ICON_WIDTH 32
#define UGMB_ICON_HEIGHT 32
#define UGMB_HEIGHT 120
NANAADJInputBox::NANAADJInputBox()
{
w_pParentWnd = 0;
}
NANAADJInputBox::~NANAADJInputBox()
{
}
void NANAADJInputBox::Show(NANAWnd * pParentWnd,const char* strValueName,const char * strTips,int nDigitWidth,int nDecimalPos,int nInitValue,int nMinValue,int nMaxValue)
{
int nStartx, nStarty, nWidth, nHeight;
//calculate the size required to display
nStartx = 50;
nStarty = 50;
nWidth = 200;
nHeight = 100;
w_strValueName = strValueName;
w_pParentWnd = pParentWnd;
//创建窗体
NANAWnd::CreateWnd(NULL, nStartx, nStarty, nWidth, nHeight);
}
void NANAADJInputBox::Close()
{
CloseWindow();
}
void NANAADJInputBox::OnClose()
{
w_ButtonOK.CloseWindow();
w_ButtonCancel.CloseWindow();
ReleaseMouse();
}
#define BUTTON_HEIGHT 25
#define BUTTON_WIDTH 50
void NANAADJInputBox::OnCreate()
{
NANARect rc;
GetWindowRect(&rc);
w_ButtonOK.CreateWnd(
this,
rc.w_nX1+8,
rc.w_nY2-BUTTON_HEIGHT - 8,
BUTTON_WIDTH,
BUTTON_HEIGHT);
w_ButtonOK.SetCaption("确定");
w_ButtonCancel.CreateWnd(this,
rc.w_nX2 - BUTTON_WIDTH - 8,
rc.w_nY2-BUTTON_HEIGHT-8,
BUTTON_WIDTH,
BUTTON_HEIGHT);
w_ButtonCancel.SetCaption("取消");
}
void NANAADJInputBox::OnPaint()
{
NANA_FONT font;
font = &NANA_FONT16;
NANARect rc;
GetWindowRect(&rc);
RectFill(rc.w_nX1, rc.w_nY1, rc.w_nX2, rc.w_nY2,COLOR_BKGROUND);
RoundRectangle_Big(rc.w_nX1, rc.w_nY1, rc.w_nX2, rc.w_nY2,1);
TextPrint(
w_strValueName,
rc.w_nX1 + 5,
rc.w_nY1 + 5,
&NANA_FONT12,
0);
DrawHorizontalLine( rc.w_nX1+5, rc.w_nY2-BUTTON_HEIGHT-15, rc.GetWidth()-10,1);
}
void NANAADJInputBox::OnKey(int nKeyCode,int bKeyDown)
{
if (bKeyDown == MSGCODE_KEY_DOWN)
{
switch(nKeyCode)
{
case UGIB_KEY_OK:
w_ButtonOK.SetPress(1);
break;
case UGIB_KEY_CANCEL:
w_ButtonCancel.SetPress(1);
break;
}
}
else if(bKeyDown == MSGCODE_KEY_UP)
{
switch(nKeyCode)
{
case UGIB_KEY_OK:
w_ButtonOK.SetPress(0);
NotifyWindow(w_pParentWnd,UGNC_MSGBOX,UGIB_NOTIFY_OK,0);
Close();
break;
case UGIB_KEY_CANCEL:
w_ButtonCancel.SetPress(0);
NotifyWindow(w_pParentWnd,UGNC_MSGBOX,UGIB_NOTIFY_CANCEL,0);
Close();
break;
default:
break;
}
}
else
{
}
}
void NANAADJInputBox::OnNotify(NANAWnd *pSrcWnd,int nMessageCode,int nParam1,int nParam2)
{
if(UGNC_CLICK == nMessageCode)
{
if(pSrcWnd == &w_ButtonOK)
{
NotifyWindow(w_pParentWnd,UGNC_MSGBOX,UGIB_NOTIFY_OK,0);
Close();
}else
if(pSrcWnd == &w_ButtonCancel)
{
NotifyWindow(w_pParentWnd,UGNC_MSGBOX,UGIB_NOTIFY_CANCEL,0);
Close();
}
}
}
void NANAADJInputBox::OnDefault()
{
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -