📄 window.c
字号:
free(pWin->pVScroll); if(pWin->pHScroll) free(pWin->pHScroll); if(pWin->pHCurState) free(pWin->pHCurState); if(pWin->pVCurState) free(pWin->pVCurState); switch(GetWinType(pWin)){ case WS_DESKTOP: case WS_MAIN: SendMessage(hWnd,LMSG_DESTROY,(WPARAM)NULL,(LPARAM)NULL); break; case WS_CHILD: SendMessage(hWnd,LMSG_DESTROY,(WPARAM)NULL,(LPARAM)NULL); break; case WS_CONTROL: DestroyControl(pWin); break; break; case WS_IMEWIN: DestroyImeWin(pWin); break; case WS_SKBWIN: DestroySkbWin(pWin); break; case WS_MENUWIN: DestroyMenuWin(pWin); break; }}//call this function to destroy window data structure//it will be called by getmessage in the module message.cvoid ExitWindow( HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; switch(GetWinType(pWin)){ case WS_DESKTOP: DestroyDesktop(pWin); break; case WS_MAIN: DestroyMain(pWin); break; case WS_CHILD: DestroyChild(pWin); break; }}void DestroyDesktop( HWND hWnd){ PlGUIAppStat pStat; PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if(_lGUI_pAppStat){ pStat=_lGUI_pAppStat->pNext; while(_lGUI_pAppStat){ SendSigTerm((pid_t)(_lGUI_pAppStat->pAppName)); //SendMsgByServer(pStat,LSMG_IPC_EXITSERVER,NULL,0); EmptyClipRegion(_lGUI_pAppStat->pClipRgn); free(_lGUI_pAppStat->pClipRgn); close(_lGUI_pAppStat->fdSocket); pthread_cancel(_lGUI_pAppStat->tdSocket); pthread_join(_lGUI_pAppStat->tdSocket,NULL); free(_lGUI_pAppStat); _lGUI_pAppStat=pStat; pStat=_lGUI_pAppStat->pNext; } } EmptyClipRegion(pWin->pClipRgn); EmptyClipRegion(pWin->pBackClipRgn); free(pWin->pClipRgn); free(pWin->pBackClipRgn); DestroyMsgQueue((HWND)pWin); free(pWin);}void DestroyMain( HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; //Destroy Child Window while(pWin->pChildHead) DestroyChild_Process(pWin->pChildHead,true); //Destroy Control while(pWin->pControlHead) DestroyControl_Process(pWin->pControlHead,true); EmptyClipRegion(pWin->pClipRgn); EmptyClipRegion(pWin->pBackClipRgn); free(pWin->pBackClipRgn); free(pWin->pClipRgn); DestroyMsgQueue((HWND)pWin); free(pWin);}void DestroyChild( HWND hWnd){ DestroyChild_Process(hWnd,false);}void DestroyChild_Process( HWND hWnd, BOOL bByParent){ PWindowsTree pBrother; PWindowsTree pWin; PWindowsTree pParent; PWindowsTree pControl; pWin=(PWindowsTree)hWnd; if(!pWin) return; pParent=pWin->pParent; pBrother=pWin->pNext; //Set Active Window if(IsActive(hWnd)){ _lGUI_pActiveWin = NULL; if(pBrother){ ActiveWindow(pBrother); } else{ ActiveWindow(pParent); } } if(!bByParent){ pthread_cancel(pWin->threadid); pthread_join(pWin->threadid,NULL); } while(pWin->pControlHead) DestroyControl_Process((HWND)(pWin->pControlHead),true); if(pParent->pChildHead==pParent->pChildTail){ pParent->pChildHead=NULL; pParent->pChildTail=NULL; //free(pWin); } else if(pWin==pParent->pChildHead){ pWin->pNext->pPrev=NULL; pParent->pChildHead=pWin->pNext; //free(pWin); } else if(pWin==pParent->pChildTail){ pWin->pPrev->pNext=NULL; pParent->pChildTail=pWin->pPrev; //free(pWin); } else{ pWin->pPrev->pNext=pWin->pNext; pWin->pNext->pPrev=pWin->pPrev; //free(pWin); } if(!bByParent){ ReCalClipRegion(pParent); pControl = pParent->pControlHead; while(pControl){ ReCalClipRegion(pControl); pControl = pControl->pNext; } while(pBrother){ if(IsIntersect(&(pWin->rect),&(pBrother->rect))) ReCalClipRegion(pBrother); pControl = pBrother->pControlHead; while(pControl){ ReCalClipRegion(pControl); pControl = pControl->pNext; } pBrother=pBrother->pNext; } RePaintCoveredWindow(pWin); } if(pWin->pMsgQueue){ DestroyMsgQueue((HWND)pWin); } EmptyClipRegion(pWin->pClipRgn); free(pWin->pClipRgn); EmptyClipRegion(pWin->pBackClipRgn); free(pWin->pBackClipRgn); free(pWin);}void DestroyControl( HWND hWnd){ DestroyControl_Process(hWnd,false);}void DestroyControl_Process( HWND hWnd, BOOL bByParent){ PWindowsTree pBrother; PWindowsTree pWin; PWindowsTree pParent; BOOL bFocus; RECT rect; pWin=(PWindowsTree)hWnd; if(!pWin) return; pParent = pWin->pParent; pBrother = pWin->pNext; CopyRect(&rect,&(pWin->rect)); bFocus = IsFocus(hWnd); SendMessage(hWnd,LMSG_DESTROY,(WPARAM)NULL,(LPARAM)NULL); EmptyClipRegion(pWin->pClipRgn); EmptyClipRegion(pWin->pBackClipRgn); free(pWin->pClipRgn); free(pWin->pBackClipRgn); if(pParent->pControlHead==pParent->pControlTail){ pParent->pControlHead=NULL; pParent->pControlTail=NULL; free(pWin); } else if(pWin==pParent->pControlHead){ pWin->pNext->pPrev=NULL; pParent->pControlHead=pWin->pNext; free(pWin); } else if(pWin==pParent->pControlTail){ pWin->pPrev->pNext=NULL; pParent->pControlTail=pWin->pPrev; free(pWin); } else{ pWin->pPrev->pNext=pWin->pNext; pWin->pNext->pPrev=pWin->pPrev; free(pWin); } if(!bByParent){ ReCalClipRegion(pParent); while(pBrother){ if(IsIntersect(&rect,&(pBrother->rect))) ReCalClipRegion(pBrother); pBrother=pBrother->pNext; } RePaintCoveredWindow(pWin); if(bFocus) _lGUI_pFocus = NULL; }}void DestroyMenuWin( HWND hWnd){ PWindowsTree pWin; PWindowsTree pControl; PlGUIAppStat pCurStat; RECT rc; pWin=(PWindowsTree)hWnd; CopyRect(&rc,&(pWin->rect)); ReCalClipRegion(_lGUI_pWindowsTree); InvalidateRect((HWND)_lGUI_pWindowsTree,NULL,true); pControl=_lGUI_pWindowsTree->pControlHead; while(pControl){ ReCalClipRegion(pControl); pControl=pControl->pNext; } pControl=_lGUI_pWindowsTree->pControlHead; while(pControl){ if(IsVisible(pControl)) InvalidateRect((HWND)pControl,NULL,true); pControl=pControl->pNext; } //imewindow if(IsVisible((HWND)_lGUI_pImeWindow)) if(IsIntersect(&_lGUI_pImeWindow->rect,&pWin->rect)) scrInvalidateRect((HWND)_lGUI_pImeWindow,&pWin->rect,true); //skbwindow if(IsVisible((HWND)_lGUI_pSkbWindow)) if(IsIntersect(&_lGUI_pSkbWindow->rect,&pWin->rect)) scrInvalidateRect((HWND)_lGUI_pSkbWindow,&pWin->rect,true); pCurStat = _lGUI_pAppStat; RecalClipRgnUnderThis(pCurStat); while(pCurStat){ SendClipRgnChangeMsg(pCurStat); pCurStat=pCurStat->pNext; } pCurStat = _lGUI_pAppStat; while(pCurStat){ //SendMsgByServer(pCurStat,LMSG_IPC_REDRAW,NULL,0); SendMsgByServer(pCurStat,LMSG_IPC_REDRAW,(void*)&rc,sizeof(RECT)); pCurStat=pCurStat->pNext; } EmptyClipRegion(pWin->pClipRgn); EmptyClipRegion(pWin->pBackClipRgn); free(pWin->pBackClipRgn); free(pWin->pClipRgn); free(pWin); _lGUI_pStartMenuWindow = NULL;}voidDestroyImeWin( HWND hWnd){ PWindowsTree pWin; PWindowsTree pControl; PlGUIAppStat pCurStat; RECT rc; pWin=(PWindowsTree)hWnd; CopyRect(&rc,&(pWin->rect)); ReCalClipRegion(_lGUI_pWindowsTree); InvalidateRect((HWND)_lGUI_pWindowsTree,NULL,true); pControl=_lGUI_pWindowsTree->pControlHead; while(pControl){ ReCalClipRegion(pControl); pControl=pControl->pNext; } pControl=_lGUI_pWindowsTree->pControlHead; while(pControl){ if(IsVisible(pControl)) InvalidateRect((HWND)pControl,NULL,true); pControl=pControl->pNext; } pCurStat = _lGUI_pAppStat; RecalClipRgnUnderThis(pCurStat); while(pCurStat){ SendClipRgnChangeMsg(pCurStat); pCurStat=pCurStat->pNext; } pCurStat = _lGUI_pAppStat; while(pCurStat){ //SendMsgByServer(pCurStat,LMSG_IPC_REDRAW,NULL,0); SendMsgByServer(pCurStat,LMSG_IPC_REDRAW,(void*)&rc,sizeof(RECT)); pCurStat=pCurStat->pNext; } EmptyClipRegion(pWin->pClipRgn); EmptyClipRegion(pWin->pBackClipRgn); free(pWin->pBackClipRgn); free(pWin->pClipRgn); free(pWin); _lGUI_pImeWindow = NULL;}void DestroySkbWin( HWND hWnd){ PWindowsTree pWin; PWindowsTree pControl; PlGUIAppStat pCurStat; RECT rc; pWin=(PWindowsTree)hWnd; CopyRect(&rc,&(pWin->rect)); ReCalClipRegion(_lGUI_pWindowsTree); InvalidateRect((HWND)_lGUI_pWindowsTree,NULL,true); pControl=_lGUI_pWindowsTree->pControlHead; while(pControl){ ReCalClipRegion(pControl); pControl=pControl->pNext; } pControl=_lGUI_pWindowsTree->pControlHead; while(pControl){ if(IsVisible(pControl)) InvalidateRect((HWND)pControl,NULL,true); pControl=pControl->pNext; } pCurStat = _lGUI_pAppStat; RecalClipRgnUnderThis(pCurStat); while(pCurStat){ SendClipRgnChangeMsg(pCurStat); pCurStat=pCurStat->pNext; } pCurStat = _lGUI_pAppStat; while(pCurStat){ //SendMsgByServer(pCurStat,LMSG_IPC_REDRAW,NULL,0); SendMsgByServer(pCurStat,LMSG_IPC_REDRAW,(void*)&rc,sizeof(RECT)); pCurStat=pCurStat->pNext; } EmptyClipRegion(pWin->pClipRgn); EmptyClipRegion(pWin->pBackClipRgn); free(pWin->pBackClipRgn); free(pWin->pClipRgn); free(pWin); _lGUI_pSkbWindow = NULL;}BOOL GUIAPI MoveWindow( HWND hWnd, int x, int y){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if(IsVisible(hWnd)){ ShowWindow(hWnd,false); pWin->rect.left+=x; pWin->rect.right+=x; pWin->rect.top+=y; pWin->rect.bottom+=y; ShowWindow(hWnd,true); } else{ pWin->rect.left+=x; pWin->rect.right+=x; pWin->rect.top+=y; pWin->rect.bottom+=y; } return true;}BOOL MoveWindowTo( HWND hWnd, int x, int y){ PWindowsTree pWin; int iWidth,iHeight; pWin=(PWindowsTree)hWnd; iWidth = pWin->rect.right - pWin->rect.left + 1; iHeight = pWin->rect.bottom - pWin->rect.top + 1; if(IsVisible(hWnd)){ ShowWindow(hWnd,false); pWin->rect.left =x; pWin->rect.right =x + iWidth - 1; pWin->rect.top =y; pWin->rect.bottom =y + iHeight -1; ShowWindow(hWnd,true); } else{ pWin->rect.left =x; pWin->rect.right =x + iWidth - 1; pWin->rect.top =y; pWin->rect.bottom =y + iHeight -1; } return true;}//Move Main Window//for we can't control the show operation order of the main windows //when clip region changed//this function is designed for solving this problem.BOOL MoveMainWindow( HWND hWnd, int x, int y){ PWindowsTree pWin,pControl; PlGUIAppStat pCurStat; RECT rc; pWin=(PWindowsTree)hWnd; if(!pWin) return false; pWin->rect.left+=x; pWin->rect.right+=x; pWin->rect.top+=y; pWin->rect.bottom+=y; CopyRect(&rc,&pWin->rect); if(IsVisible(hWnd)){ pWin->dwStyle = pWin->dwStyle | WS_VISIBLE; SetInitRectClipRegion(pWin->pClipRgn,&(pWin->rect)); ReCalClipRegion(_lGUI_pWindowsTree); InvalidateRect((HWND)_lGUI_pWindowsTree,NULL,true); pControl=_lGUI_pWindowsTree->pControlHead; while(pControl){ ReCalClipRegion(pControl); pControl=pControl->pNext; } pControl=_lGUI_pWindowsTree->pControlHead; while(pControl){ scrInvalidateRect((HWND)pControl,NULL,true); pControl=pControl->pNext; } pCurStat = _lGUI_pAppStat; RecalClipRgnUnderThis(pCurStat); while(pCurStat){ SendClipRgnChangeMsg(pCurStat); pCurStat=pCurStat->pNext; } pCurStat = _lGUI_pAppStat; while(pCurStat){ //SendMsgByServer(pCurStat,LMSG_IPC_REDRAW,NULL,0); SendMsgByServer(pCurStat,LMSG_IPC_REDRAW,(void*)&rc,sizeof(RECT)); pCurStat=pCurStat->pNext; } //paint winInvalidateRect(hWnd,NULL,true); } return true;}BOOL GUIAPI ResizeWindow( HWND hWnd, LPRECT lpRect){ PWindowsTree pWin; pWin = (PWindowsTree)hWnd; if(!pWin) return false; if(IsVisible(hWnd)){ ShowWindow(hWnd,false); memcpy((void*)&(pWin->rect),(void*)lpRect,sizeof(RECT)); ShowWindow(hWnd,true); } else{ memcpy((void*)&(pWin->rect),(void*)lpRect,sizeof(RECT)); } return true;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -