📄 uiwnd.c
字号:
GUI_BLACK, 0);
guiPopFont();
guiExitWCS();
// if(gwmtest!=2)
// gDialogTest = 1;
pMessageQueue=pDialog->messageQueue;
iRet = -1;
while(iRet==-1)
{
if(guiDequeue(pMessageQueue, &tMessage)==-1)
continue;
switch(tMessage.messageType)
{
case BUTTON_CLICK:
if(tMessage.handle==hButton1)
iRet = iRet1;
else if( tMessage.handle!=NULL && tMessage.handle==hButton2)
iRet = iRet2;
break;
}
}
guiDialog_Delete(hDialog);
return iRet;
}
/*************************************************************************/
// 显示一个缺省消息盒
// 参数:
// caption 消息盒标题
// message 消息盒中显示的信息
// style 消息盒风格(参见头文件中的定义)
// 返回值:
// 参数不正确或出错时返回0
// 正确时返回选中的Button(参见头文件中的定义)
/*************************************************************************/
DLL_EXP(int) guiMessageBox(const char *caption, const char *message, WORD style)
{
return (guiMessageBoxEx(MSGBOX_LEFT,MSGBOX_TOP,MSGBOX_RIGHT,MSGBOX_BOTTOM,caption, message, style));
}
/*************************************************************************/
// 显示窗口的帮助信息
// 参数: 无
// 返回值:
// 成功: STATUS_OK
// 失败: STATUS_ERR
/*************************************************************************/
DLL_EXP(STATUS) guiWindow_Help(void)
{
HNDL hDialog,hTextEdit;
TGuiWindow *pDialog;
TGuiMessage message;
TGuiMessageQueue * pMessageQueue;
int titleHeight;
char *pHelp;
STATUS result;
guiEnterWCS();
if(!gpTopWindow)
{
guiExitWCS();
return STATUS_ERR; // 没有顶层窗口
}
pHelp=gpTopWindow->tWinSysCtr.szHelp;
if(!pHelp)
{
guiExitWCS();
return STATUS_ERR; // 顶层窗口没有帮助信息
}
hDialog = guiDialog_Create(0,0,0,GUIWIN_RIGHT,GUIWIN_BOTTOM,RES_STR_HELP_MSG[gLanguage],0);
if( !hDialog )
{
guiExitWCS();
return STATUS_ERR; // 对话框建立失败
}
pDialog = (TGuiWindow *)hDialog;
guiPushFont(pDialog->font);
titleHeight = guiGetStringHeight()+TITLE_HEIGHT_ADD; // 标题条高度
guiPopFont();
hTextEdit = guiTextEdit_Create(0, titleHeight+1, GUIWIN_RIGHT, GUIWIN_BOTTOM, strlen(pHelp)+100,
TEXTEDIT_BORDER_NONE);
if( !hTextEdit )
{
guiDialog_Delete(hDialog);
guiExitWCS();
return STATUS_ERR;
}
guiTextEdit_SetText(hTextEdit, pHelp); // 帮助信息
guiTextEdit_SetProperty(hTextEdit, READ_ONLY, 1); // 只读
guiTextEdit_SetProperty(hTextEdit, WORD_WRAP, 1); // 按字换行
guiControl_Add(hDialog, hTextEdit); // 加入对话框
result=guiDialog_Show(hDialog); // 显示对话框
guiExitWCS();
if(result!=STATUS_OK)
{
guiDialog_Delete(hDialog);
return STATUS_ERR;
}
pMessageQueue=pDialog->messageQueue;
while(1)
{
if(guiDequeue(pMessageQueue, &message)!=-1)
{
if(message.messageType==KEYPAD_CLICK)
{
guiArrowKeyCallBack(message.x);
}
if((message.messageType==WIN_CLOSE) || (message.messageType==WIN_RETURN))
{
guiDialog_Delete(hDialog);
return STATUS_OK;
}
}
}
}
/*******************************************************
* caption: caption of dialog *
* szText : save input text *
* return : GUI_IDOK, GUI_IDCANCEL, NULL *
********************************************************/
DLL_EXP(int) guiInputDialog(const char *caption, char *szText, int maxLen,unsigned short kbdType)
{
HNDL hDialog, hTextEdit, hButton, hKbd;
TGuiWindow *pDialog;
TGuiMessage message;
TGuiMessageQueue *pMessageQueue;
int iRet;
WORD i,widthKbd,heightKbd,sizeKbd;
short titleHeight,buttonHeight,buttonWidth;
guiEnterWCS();
if(!gpTopWindow)
{
guiExitWCS();
return 0; // 没有顶层窗口
}
hDialog = guiDialog_Create(0,0,0,GUIWIN_RIGHT,GUIWIN_BOTTOM,caption,0);
if(hDialog==0)
{
guiExitWCS();
return 0; // 创建对话框失败
}
hKbd=guiSwKbd_Create(0,0,kbdType);
if(hKbd==0)
{
guiDialog_Delete(hDialog);
guiExitWCS();
return 0; // 创建键盘失败
}
guiControl_Add(hDialog,hKbd);
pDialog = (TGuiWindow *)hDialog;
guiPushFont(pDialog->font);
titleHeight = guiGetStringHeight()+TITLE_HEIGHT_ADD; // 标题条高度
buttonWidth=guiGetStringWidth(RES_STR_OK[gLanguage])+10;
guiPopFont();
sizeKbd=0;
for(i=0;i<gGUI_MAX_KBD;i++)
{
if(guiKbd_GetSize(i,&widthKbd,&heightKbd)!=STATUS_OK)
continue;
if(sizeKbd<heightKbd)
sizeKbd=heightKbd;
}
hButton = guiButton_Create(GUI_SCREEN_WIDTH-buttonWidth-5, 0,
GUI_SCREEN_WIDTH-5, titleHeight-1, RES_STR_OK[gLanguage], BUTTON_TITLE);
guiControl_Add(hDialog, hButton);
hTextEdit = guiTextEdit_Create(0, titleHeight+1, GUIWIN_RIGHT, GUIWIN_BOTTOM-sizeKbd-1, maxLen,
TEXTEDIT_BORDER_NONE);
guiTextEdit_SetText(hTextEdit, szText); // 原有信息
guiTextEdit_SetProperty(hTextEdit,UNDERLINE_TYPE,UNDERLINE_HATCH); // 有虚线
guiControl_Add(hDialog, hTextEdit); // 加入对话框
guiDialog_Show(hDialog); // 显示对话框
guiTextEdit_GetFocus(hTextEdit) ;
guiExitWCS();
iRet = -1;
pMessageQueue=((TGuiWindow *)hDialog)->messageQueue;
while(iRet==-1)
{
if(guiDequeue(pMessageQueue, &message)==-1)
continue;
if(message.messageType==BUTTON_CLICK)
{
guiTextEdit_GetText(hTextEdit, szText, maxLen);
iRet = GUI_IDOK;
}
else if(message.messageType==WIN_CLOSE)
{
szText[0] = 0;
iRet = GUI_IDCANCEL;
}
}
guiDialog_Delete(hDialog);
return iRet;
}
// by zhangxp 2003/06/25
DLL_EXP(HNDL) guiShowMessage(char *message)
{
HNDL hMsgWnd, hTopWnd;
TGuiWindow *pMsgWnd, *pBackWindow;
int left, right, len, indent;
if(gpTopWindow==NULL)
return NULL;
if(gpTopWindow->parent)
hTopWnd = (HNDL)gpTopWindow->parent;
else
hTopWnd = (HNDL)gpTopWindow;
hMsgWnd = guiWindow_Create(hTopWnd, /*caption*/NULL, NULL, NULL, GUIWIN_BORDER|GUIWIN_TITLE_NONE);
if( !hMsgWnd )
return NULL;
guiEnterWCS();
pMsgWnd = (TGuiWindow *)hMsgWnd;
pMsgWnd->left = MESSAGE_LEFT;
pMsgWnd->top = MESSAGE_TOP;
pMsgWnd->right = MESSAGE_RIGHT;
pMsgWnd->bottom = MESSAGE_BOTTOM;
pMsgWnd->BackWindowStyle = gpTopWindow->style;
gpTopWindow->style|=GUIWIN_IMAGE_SAVE;
pBackWindow=gpTopWindow; // 暂存背景窗口
guiWindow_Show(hMsgWnd);
pMsgWnd->pBackWindow=pBackWindow;
guiExitWCS();
len = guiGetStringWidth(message);
if(len>(MESSAGE_RIGHT-MESSAGE_LEFT+1-MESSAGE_INDENT*2))
{
left = MESSAGE_INDENT; right = MESSAGE_RIGHT-MESSAGE_LEFT+1-left;
}
else
{
left = ((MESSAGE_RIGHT-MESSAGE_LEFT+1-MESSAGE_INDENT*2)-len)/2;
right = MESSAGE_RIGHT-MESSAGE_LEFT+1-left;
}
pMsgWnd=(TGuiWindow *)hMsgWnd;
guiPushFont(pMsgWnd->font); // 显示信息
guiShowStringInArea(hMsgWnd, message, left, 8, right, MESSAGE_BOTTOM-MESSAGE_TOP, GUI_BLACK, 0);
guiPopFont();
return hMsgWnd;
}
DLL_EXP(STATUS) guiCloseMessage(HNDL hMsgWnd)
{
TGuiWindow *pMsgWnd;
//HNDL hMsgWin
if(!hMsgWnd)
return STATUS_ERR;
pMsgWnd = (TGuiWindow *)hMsgWnd;
if(pMsgWnd->checkFlag!=GUI_WIN_CHECK_FLAG)
return STATUS_ERR;
guiEnterWCS();
if( hMsgWnd!=(HNDL)gpTopWindow )
{
guiExitWCS();
return(guiWindow_Delete(hMsgWnd));
}
pMsgWnd = (TGuiWindow *)hMsgWnd;
if( pMsgWnd->checkFlag!=GUI_WIN_CHECK_FLAG )
{
guiExitWCS();
return(guiWindow_Delete(hMsgWnd));
}
pMsgWnd->status = GUIWIN_NOT_ACTIVE; // 置为不活动状态
guiCaret_Disable(); // 关闭光标
guiListbox_Shrink(); // 收起PopList
guiMenu_Shrink(); // 收起Menu
guiHWR_End(); // 停止手写识别线程
gpTopWindow=NULL;
// by zhangxp 2003/06/11
// guiWindow_Show((HNDL)gpBackWindow); // 恢复原顶层窗口
// gpTopWindow->style=gBackWindowStyle;
guiWindow_Show((HNDL)pMsgWnd->pBackWindow); // 恢复原顶层窗口
gpTopWindow->style = pMsgWnd->BackWindowStyle;
guiExitWCS();
return(guiWindow_Delete(hMsgWnd)); // 删除对话框窗口
}
/****************************************************************
// 将菜单回入到窗口中
// 参数:
// pWnd 窗口句柄
// hMenu 菜单句柄
// 返回值:
// 成功 STATUS_OK
// 失败 STATUS_ERR
*****************************************************************/
DLL_EXP(STATUS) guiWindow_AddMenu(HNDL hWnd, HNDL hMenu)
{
TGuiWindow *pWnd;
TGuiMenu *pMenu;
short titleHeight,menuWidth,menuLeft,closeWidth;
WORD style;
guiEnterWCS();
pWnd=(TGuiWindow *)hWnd;
pMenu=(TGuiMenu *)hMenu;
if( pWnd->checkFlag != GUI_WIN_CHECK_FLAG)
{
guiExitWCS();
return STATUS_ERR; // 窗口无效
}
if(pMenu->base.checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return STATUS_ERR; // 菜单无效
}
if(pWnd->tWinSysCtr.hMenu)
{
guiExitWCS();
return STATUS_ERR; // 窗口中已有系统菜单
}
pWnd->style|=GUIWIN_MENU; // 窗口具有系统菜单风格
pMenu->base.style=MENU_SYSTEM; // 菜单风格为系统菜单
guiPushFont(pWnd->font);
titleHeight = guiGetStringHeight() + TITLE_HEIGHT_ADD; // 计算标题条高度
menuWidth=guiGetStringWidth(pMenu->caption)+guiGetStringWidth(RES_STR_MENUFLAG[gLanguage]);
guiPopFont();
if( !(style&GUIWIN_CLOSE_NONE) )
closeWidth=guiGetImageWidth(icon_Gui_Wnd_Close_Up); // 获取关闭按钮宽度
else
closeWidth=0;
pMenu->base.left = closeWidth+2; // 修正菜单位置
pMenu->base.top = 0;
pMenu->base.right=closeWidth+menuWidth+1;
pMenu->base.bottom=titleHeight-1;
pWnd->tWinSysCtr.hMenu = hMenu;
strcpy(pMenu->caption,pWnd->caption);
_guiWindow_PaintCaption(hWnd); // 更新窗口标题显示
return STATUS_OK;
}
/****************************************************************
// 获取窗口中的系统菜单句柄
// 参数:
// hWnd 窗口句柄
// 返回值:
// 成功 菜单句柄
// 失败 NULL
*****************************************************************/
DLL_EXP(HNDL) guiWindow_GetMenu(HNDL hWnd)
{
TGuiWindow *pWnd;
HNDL hMenu;
guiEnterWCS();
pWnd=(TGuiWindow *)hWnd;
if( pWnd->checkFlag != GUI_WIN_CHECK_FLAG)
{
guiExitWCS();
return NULL; // 窗口无效
}
hMenu=pWnd->tWinSysCtr.hMenu;
guiExitWCS();
return hMenu;
}
/****************************************************************
// 自窗口中移出其系统菜单
// 参数:
// hWnd 窗口句柄
// 返回值:
// 成功 STATUS_OK
// 失败 STATUS_ERR
*****************************************************************/
DLL_EXP(void) guiWindow_RemoveMenu(HNDL hWnd, HNDL hMenu)
{
TGuiWindow *pWnd;
guiEnterWCS();
pWnd=(TGuiWindow *)hWnd;
if( pWnd->checkFlag != GUI_WIN_CHECK_FLAG)
{
guiExitWCS();
return; // 窗口无效
}
pWnd->tWinSysCtr.hMenu=NULL;
pWnd->style &= (~GUIWIN_MENU);
_guiWindow_PaintCaption(hWnd); // 更新窗口标题显示
guiExitWCS();
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -