📄 uiwnd.c
字号:
message.messageType = WIN_IS_TOP;
message.handle = hWnd;
_guiEnqueue(pWnd->messageQueue, &message);
guiExitWCS();
return STATUS_OK;
}
/*************************************************************************/
// 显示窗口框架
// 参数:
// hWnd 窗口句柄
// 返回值:
// STATUS_OK: 成功
// STATUS_ERR: 失败
/*************************************************************************/
DLL_EXP(STATUS) guiWindow_ShowFrame(HNDL hWnd )
{
TGuiWindow *pWnd;
TGuiMessage message;
WORD style;
BYTE *backBitmap;
short left,top,right,bottom;
guiEnterWCS();
pWnd = (TGuiWindow *)hWnd;
if(pWnd->checkFlag!=GUI_WIN_CHECK_FLAG) // 1112
{
guiExitWCS();
return STATUS_ERR; // 窗口无效
}
if(gpTopWindow) // 处理前一个窗口
{
style=gpTopWindow->style;
if(style & GUIWIN_DIALOG)
{
guiExitWCS();
return STATUS_ERR; // 顶层窗口为对话框时,不能再显示窗口
}
guiCaret_Disable(); // 禁止光标
guiMenu_Shrink(); // 收回已展开的菜单
guiListbox_Shrink(); // 收回已展开的PopList
guiHWR_End(); // 停止手写识别线程
if( style&GUIWIN_IMAGE_SAVE ) // 保存窗口背景
{
left=gpTopWindow->left;
top=gpTopWindow->top;
right=gpTopWindow->right;
bottom=gpTopWindow->bottom;
backBitmap = (BYTE *)kernelMalloc(guiGetImageSize(left,top,right,bottom));// 分配背景存储空间
if( !backBitmap )
{
guiExitWCS();
return STATUS_ERR;
}
if( gpTopWindow->screenBuffer )
kernelFree(gpTopWindow->screenBuffer); // 释放前一次所分配的背景存储空间
guiGetImage(0,left,top,right,bottom,backBitmap); // 保存背景
gpTopWindow->screenBuffer=backBitmap;
}
gpTopWindow->status = GUIWIN_NOT_ACTIVE; // 将窗口设置为不活动
}
style = pWnd->style;
pWnd->status = GUIWIN_NOT_ACTIVE; // 激活新窗口
gpTopWindow = pWnd; // 新窗口为顶层窗口
if( (style&GUIWIN_IMAGE_SAVE) && (pWnd->screenBuffer) )
kernelFree(pWnd->screenBuffer); // 释放前一次所分配的背景存储空间
_guiWindow_PaintFrame(hWnd); // 重绘窗口框架
message.messageType = WIN_IS_TOP;
message.handle = hWnd;
_guiEnqueue(pWnd->messageQueue, &message);
guiExitWCS();
return STATUS_OK;
}
/*************************************************************************/
// 显示窗口中的所有控件
// 参数:
// hWnd 窗口句柄
// 返回值:
// STATUS_OK: 成功
// STATUS_ERR: 失败
/*************************************************************************/
DLL_EXP(STATUS) guiWindow_ShowAllControl(HNDL hWnd )
{
TGuiWindow *pWnd;
TGuiControl *pControl;
struct dLinkList *pControlList;
guiEnterWCS();
pWnd = (TGuiWindow *)hWnd;
if(pWnd!=gpTopWindow) // 非顶层窗口,不进行处理
{
guiExitWCS();
return STATUS_ERR;
}
if(pWnd->checkFlag!=GUI_WIN_CHECK_FLAG) // 检查窗口合法性
{
guiExitWCS();
return STATUS_ERR;
}
if( pWnd->status==GUIWIN_NOT_ACTIVE ) // 窗口不活动时,不进行处理
{
guiExitWCS();
return STATUS_ERR;
}
pControlList = &(pWnd->controlList);
while(1)
{
pControlList = pControlList->back;
if(!pControlList)
break;
guiControl_Show( (HNDL)pControlList->elementPointer);
}
guiExitWCS();
return STATUS_OK;
}
/*************************************************************************/
// 清除窗口标题
// 参数:
// hWnd 窗口句柄
// 返回值: 无
/*************************************************************************/
void _guiWindow_ClearCaption(HNDL hWnd)
{
TGuiWindow *pWnd;
short captionWidth,captionLeft,left,titleHeight;
char caption[GUI_WIN_CAPTION_SIZE];
pWnd=(TGuiWindow *)hWnd;
if(pWnd != gpTopWindow) // 非顶层窗口,不清除
return;
strcpy(caption,pWnd->caption);
if(pWnd->style&GUIWIN_MENU)
strcat(caption,RES_STR_MENUFLAG[gLanguage]);
guiPushFont(pWnd->font);
captionWidth=guiGetStringWidth(pWnd->caption); // 显示宽度
titleHeight=guiGetStringHeight()+ TITLE_HEIGHT_ADD;
guiPopFont();
if(!captionWidth) // 没有caption时,返回
return;
if(pWnd->style & GUIWIN_CLOSE_NONE) // 没有close button
left=1;
else // 有close button
left=guiGetImageWidth(icon_Gui_Wnd_Close_Up)+2;
if(pWnd->style & GUIWIN_CAPTION_CENTER)
{
captionLeft= (pWnd->right-pWnd->left+1-captionWidth)/2;
if(captionLeft<left)
captionLeft=left;
}
else
captionLeft= left;
guiClearBlock(hWnd,captionLeft,0,captionLeft+captionWidth-1,titleHeight-1,GUI_BLACK,0);
}
/*************************************************************************/
// 设置窗口标题
// 参数:
// hWnd 窗口句柄
// caption:窗口标题
// 返回值:
// STATUS_OK: 成功
// STATUS_ERR: 失败
/*************************************************************************/
DLL_EXP(STATUS) guiWindow_SetCaption(HNDL hWnd, const char* caption)
{
TGuiWindow *pWnd;
TGuiMenu *pMenu;
HNDL hMenu;
short captionLeft,captionRight;
short menuLeft, menuWidth;
guiEnterWCS();
pWnd = (TGuiWindow *)hWnd;
if( pWnd->checkFlag!=GUI_WIN_CHECK_FLAG ) //1112
{
guiExitWCS();
return STATUS_ERR;
}
_guiWindow_ClearCaption(hWnd); // 清除原标题
if(caption) // 更改标题内容
{
strncpy(pWnd->caption, caption, GUI_WIN_CAPTION_SIZE);
pWnd->caption[GUI_WIN_CAPTION_SIZE] = 0;
}
else
pWnd->caption[0] = 0;
if(pWnd->style&GUIWIN_MENU) // 如果窗口具有菜单,则将菜单名修改为与窗口标题相同
{
// by zhangxp 2003/08/05
menuWidth=guiGetStringWidth(caption)+guiGetStringWidth(RES_STR_MENUFLAG[gLanguage]);
hMenu = pWnd->tWinSysCtr.hMenu;
pMenu = (TGuiMenu *)hMenu;
menuLeft = pMenu->base.left;
pMenu->base.right= menuLeft+menuWidth-1;
guiMenu_SetCaption(pWnd->tWinSysCtr.hMenu,caption);
}
_guiWindow_PaintCaption(hWnd); // 显示新标题
guiExitWCS();
return STATUS_OK;
}
/*************************************************************************/
// 获取窗口标题
// 参数:
// hWnd 窗口句柄
// caption:窗口标题
// 返回值:
// STATUS_OK: 成功
// STATUS_ERR: 失败
/*************************************************************************/
DLL_EXP(STATUS) guiWindow_GetCaption(HNDL hWnd, char* caption)
{
TGuiWindow *pWnd;
guiEnterWCS();
pWnd = (TGuiWindow *)hWnd;
if( pWnd->checkFlag!=GUI_WIN_CHECK_FLAG ) //1112
{
guiExitWCS();
return STATUS_ERR;
}
strcpy(caption,pWnd->caption);
guiExitWCS();
return STATUS_OK;
}
/*************************************************************************/
// 清除窗口
// 参数:
// hWnd 窗口句柄
// 返回值:
// STATUS_OK: 成功
// STATUS_ERR: 失败
/*************************************************************************/
DLL_EXP(STATUS) guiWindow_Clear(HNDL hWnd)
{
TGuiWindow *pWnd;
guiEnterWCS();
if(hWnd != (HNDL)gpTopWindow)
{
guiExitWCS();
return STATUS_ERR; // 非顶层窗口
}
pWnd = (TGuiWindow *)hWnd;
if(pWnd->checkFlag!=GUI_WIN_CHECK_FLAG) //1112
{
guiExitWCS();
return STATUS_ERR; // 窗口无效
}
if(pWnd->status==GUIWIN_NOT_ACTIVE)
{
guiExitWCS();
return STATUS_ERR; // 窗口不活动
}
guiClearBlock(0,pWnd->left, pWnd->top, pWnd->right, pWnd->bottom, pWnd->backColor, 0); // 用背景色清除窗口
guiExitWCS();
return STATUS_OK;
}
/*************************************************************************/
// 设置窗口背景色(不会自动重绘窗口)
// 参数:
// hWnd 窗口句柄
// backColor: 背景颜色
// 返回值:
// STATUS_OK: 成功
// STATUS_ERR: 失败
/*************************************************************************/
DLL_EXP(STATUS) guiWindow_SetBackColor(HNDL hWnd, short backColor)
{
TGuiWindow *pWnd;
guiEnterWCS();
pWnd = (TGuiWindow *)hWnd;
if(pWnd->checkFlag!=GUI_WIN_CHECK_FLAG) //1112
{
guiExitWCS();
return STATUS_ERR;
}
pWnd->backColor = backColor;
guiExitWCS();
return STATUS_OK;
}
/*************************************************************************/
// 获取窗口背景色
// 参数:
// hWnd 窗口句柄
// backColor: 背景颜色
// 返回值:
// STATUS_OK: 成功
// STATUS_ERR: 失败
/*************************************************************************/
DLL_EXP(STATUS) guiWindow_GetBackColor(HNDL hWnd, short *backColor)
{
TGuiWindow *pWnd;
guiEnterWCS();
pWnd = (TGuiWindow *)hWnd;
if(pWnd->checkFlag!=GUI_WIN_CHECK_FLAG) //1112
{
guiExitWCS();
return STATUS_ERR;
}
*backColor=pWnd->backColor;
guiExitWCS();
return STATUS_OK;
}
/*************************************************************************/
// 设置窗口字体(不会自动重绘窗口)
// 参数:
// hWnd 窗口句柄
// font: 窗口的字体
// 返回值:
// STATUS_OK: 成功
// STATUS_ERR: 失败
/*************************************************************************/
DLL_EXP(STATUS) guiWindow_SetFont(HNDL hWnd, BYTE font)
{
TGuiWindow *pWnd;
guiEnterWCS();
pWnd = (TGuiWindow *)hWnd;
if(pWnd->checkFlag!=GUI_WIN_CHECK_FLAG) //1112
{
guiExitWCS();
return STATUS_ERR;
}
pWnd->font = font;
guiExitWCS();
return STATUS_OK;
}
/*************************************************************************/
// 获取窗口字体
// 参数:
// hWnd 窗口句柄
// font: 窗口的字体
// 返回值:
// STATUS_OK: 成功
// STATUS_ERR: 失败
/*************************************************************************/
DLL_EXP(STATUS) guiWindow_GetFont(HNDL hWnd, BYTE *font)
{
TGuiWindow *pWnd;
guiEnterWCS();
pWnd = (TGuiWindow *)hWnd;
if(pWnd->checkFlag!=GUI_WIN_CHECK_FLAG) //1112
{
guiExitWCS();
return STATUS_ERR;
}
*font=pWnd->font;
guiExitWCS();
return STATUS_OK;
}
/*************************************************************
* bIsMainWin: TRUE if mainWin, else FALSE *
* function: remove all control and timer, *
* remove all subwin if mainwin *
**************************************************************/
void _guiWindow_ReleaseResource(TGuiWindow *pWnd, BOOL bIsMainWin)
{
TGuiWindow *pPreWnd;
struct dLinkList *pControlList;
TGuiControl *pControl;
TGuiTimer *pCurTimer, *pPreTimer;
if( (HNDL)pWnd==0 )
return; // 窗口不存在
// delete node of hWnd in gpWindowsList
if( pWnd->prev==NULL ) // 窗口链表中的第一个窗口
{
gpWindowsList = pWnd->back;
if( gpWindowsList )
gpWindowsList->prev = NULL;
}
else // 不是窗口链表中的第一个窗口
{
pWnd->prev->back = pWnd->back;
if(pWnd->back)
pWnd->back->prev = pWnd->prev;
}
pControlList = &(pWnd->controlList); // 删除窗口中的控件
while(1)
{
pControlList = pControlList->back;
if(pControlList==NULL)
break; // 控件链表尾
pControl = (TGuiControl *)pControlList->elementPointer;
pControl->delFun(pControl->handle); // 删除控件
}
freeDLinkList(&(pWnd->controlList)); // 释放控件链表资源
if(pWnd->screenBuffer)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -