⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winnc.c

📁 lgui_0.3.0.rar
💻 C
📖 第 1 页 / 共 4 页
字号:
/*	Copyright (C) 2004-2005 Li Yudong*//*** This program is free software; you can redistribute it and/or modify** it under the terms of the GNU General Public License as published by** the Free Software Foundation; either version 2 of the License, or** (at your option) any later version.**** This program is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the** GNU General Public License for more details.**** You should have received a copy of the GNU General Public License** along with this program; if not, write to the Free Software** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#include "../include/common.h"#include "../include/blockheap.h"#include "../include/mouse.h"#include "../include/keyboard.h"#include "../include/framebuffer.h"#include "../include/rect.h"#include "../include/invalidregion.h"	#include "../include/clipregion.h" #include "../include/hdc.h"#include "../include/lguiapp.h"#include "../include/ipcmsg.h"#include "../include/message.h"#include "../include/gdi.h"#include "../include/regclass.h"#include "../include/shmem.h"#include "../include/caret.h"#include "../include/winnc.h"#include "../include/winbase.h"#include "../include/window.h"#include "../include/scrollbar.h"#include "../include/button.h"#include "../include/system.h"#include "../include/text.h"static void CalVScrollCurState(	LPRECT lpRect,	LPSCROLLINFO 	pScrollInfo,	LPSCROLLCURSTATE pCurState);static void CalHScrollCurState(	LPRECT lpRect,	LPSCROLLINFO pScrollInfo,	LPSCROLLCURSTATE pCurState);static LPSCROLLINFO wndGetScrollBar (	HWND hWnd, 	int iSBar);static BOOL ScrollBarIsEnable(	LPSCROLLINFO lpsi);void wndGetBoundRect(	HWND hWnd,	LPRECT lpRectLeft, 	LPRECT lpRectTop,	LPRECT lpRectRight,	LPRECT lpRectBottom){	RECT rcWin;	BOOL bVScroll, bHScroll;	int iBorder,iCaption;	int iVScrollBarWidth,iHScrollBarHeight;	if(IsVScrollBar(hWnd)){		iVScrollBarWidth = GetSystemMetrics(SM_CXVSCROLL);		bVScroll = true;	}	if(IsHScrollBar(hWnd)){		iHScrollBarHeight = GetSystemMetrics(SM_CYHSCROLL);		bHScroll = true;	}	iBorder=wndGetBorder(hWnd);	if(IsCaption(hWnd))		iCaption = WIN_CAPTION_HEIGHT;	else		iCaption = 0;	GetWindowRect(hWnd,&rcWin);	if(!iBorder){		SetRect(lpRectLeft,0,0,0,0);	}	else{		SetRect(lpRectLeft,rcWin.left,rcWin.top+iBorder,			rcWin.left+iBorder,rcWin.bottom - iHScrollBarHeight);	}	if(!iBorder && !iCaption){		SetRect(lpRectTop,0,0,0,0);	}	else{		SetRect(lpRectTop,rcWin.left,rcWin.top,			rcWin.right,rcWin.top + iBorder + iCaption);	}	if(!iBorder && !bVScroll)		SetRect(lpRectRight,0,0,0,0);	else		SetRect(lpRectRight,rcWin.right-iBorder-iVScrollBarWidth+1,rcWin.top+iBorder+iCaption+1,			rcWin.right,rcWin.bottom-iBorder-iHScrollBarHeight-1);	if(!iBorder && !bHScroll)		SetRect(lpRectBottom,0,0,0,0);	else		SetRect(lpRectBottom,rcWin.left,			rcWin.bottom-iHScrollBarHeight-iBorder,rcWin.right,rcWin.bottom);}//Get Caption rect screen coordsysvoid wndGetCaptionRect(	HWND hWnd,	LPRECT lpRect){	PWindowsTree pWin;	RECT rcWin;	int iBorder;	pWin = (PWindowsTree)hWnd;	GetWindowRect(hWnd,&rcWin);	if(!IsCaption(hWnd)){		SetRect(lpRect,0,0,0,0);		return;	}	else{		iBorder = wndGetBorder(hWnd);		SetRect(lpRect,rcWin.left+iBorder,rcWin.top+iBorder,			rcWin.right-iBorder,rcWin.top+iBorder+WIN_CAPTION_HEIGHT-1);			}}////===================================Pen Down=======================================//vscroll pendown procedurevoid VScrollBarPenDownProc(	HWND hWnd,	int x, 	int y){	int iArrowHeight,iBarWidth,iBarHeight,iSliderBarHeight,iPos,iTotalBarHeight;	RECT rc,rcDownButton,rcUpButton,rcTotalBar,rcSliderBar;	LPSCROLLCURSTATE pCurState;	LPSCROLLINFO pScrollInfo;	unsigned long iRetMsg;	PWindowsTree pWin;	pWin=(PWindowsTree)hWnd;	if(!ScrollBarIsEnable(pWin->pVScroll))		return;	iArrowHeight=GetSystemMetrics(SM_CYVSCROLL);	wndGetVScrollBarRect(hWnd,&rc);	pScrollInfo=pWin->pVScroll;	pCurState = pWin->pVCurState;	iBarWidth	=rc.right - rc.left + 1;	iBarHeight	=rc.bottom - rc.top + 1;	//cal sliderbar value	iSliderBarHeight =	pCurState->iSliderBarLen;	iPos = pCurState->iSliderBarVal;	iTotalBarHeight = iBarHeight- 2 * iArrowHeight;	//DownButton	SetRect(&rcDownButton,rc.left,rc.bottom-iArrowHeight,rc.right,rc.bottom);	//UpButton	SetRect(&rcUpButton,rc.left,rc.bottom-2*iArrowHeight,rc.right,rc.bottom-iArrowHeight);	//TotalBar	SetRect(&rcTotalBar,rc.left,rc.top,rc.right,rc.bottom-2*iArrowHeight);	//SliderBar	SetRect(&rcSliderBar,rc.left,rc.top+iPos,rc.right,rc.top+iPos+iSliderBarHeight);	if(PtInRect(&rcDownButton,x,y)){		pWin->pVScroll->dwStatus |=SS_DOWNRIGHT_PRESSDOWN;		//pWin->dwStyle=pWin->dwStyle | SS_DOWNRIGHT_PRESSDOWN;		scrInvalidateRect(hWnd,&rcDownButton,true);		if((pScrollInfo->nPos + pScrollInfo->nPage -1) < pScrollInfo->nMax){			pScrollInfo->nPos+=1;			iPos = (pScrollInfo->nPos - pScrollInfo->nMin) * iTotalBarHeight/(pScrollInfo->nMax - pScrollInfo->nMin + 1);			if((iTotalBarHeight- iPos)< iSliderBarHeight)				iPos=iTotalBarHeight - iSliderBarHeight;			pCurState->iSliderBarVal = iPos;			scrInvalidateRect(hWnd,&rcTotalBar,true);			iRetMsg=SB_LINEDOWN;			if(IsControl(hWnd)){				SendMessage(hWnd,LMSG_VSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL);			}			else{				SendNotifyMessage(hWnd,LMSG_VSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL);			}		}		else if(pCurState->iSliderBarVal + pCurState->iSliderBarLen < iTotalBarHeight -1){			pCurState->iSliderBarVal = iTotalBarHeight - pCurState->iSliderBarLen;			scrInvalidateRect(hWnd,&rcTotalBar,true);		}	}	else if(PtInRect(&rcUpButton,x,y)){		pWin->pVScroll->dwStatus |=SS_UPLEFT_PRESSDOWN;		scrInvalidateRect(hWnd,&rcUpButton,true);		if(pScrollInfo->nPos > pScrollInfo->nMin){			pScrollInfo->nPos-=1;			iPos = (pScrollInfo->nPos - pScrollInfo->nMin) * iTotalBarHeight/(pScrollInfo->nMax - pScrollInfo->nMin + 1);			pCurState->iSliderBarVal = iPos;			scrInvalidateRect(hWnd,&rcTotalBar,true);			iRetMsg=SB_LINEUP;			if(IsControl(hWnd)){				SendMessage(hWnd,LMSG_VSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL);			}			else{				SendNotifyMessage(hWnd,LMSG_VSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL);			}		}	}	else if(PtInRect(&rcSliderBar,x,y)){		pWin->dwStyle=pWin->dwStyle | SS_BAR_PRESSDOWN;		pCurState->iClickPos = y - rcSliderBar.top;	}	else{		pCurState->iClickPos = 0;	}}//hscroll pendown procedurevoid HScrollBarPenDownProc(	HWND hWnd,	int x, 	int y){	int iArrowWidth,iBarWidth,iBarHeight,iSliderBarWidth,iPos,iTotalBarWidth;	RECT rc,rcRightButton,rcLeftButton,rcTotalBar,rcSliderBar;	LPSCROLLCURSTATE pCurState;	LPSCROLLINFO pScrollInfo;	unsigned long iRetMsg;	PWindowsTree pWin;	pWin=(PWindowsTree)hWnd;	if(!ScrollBarIsEnable(pWin->pHScroll))		return;	iArrowWidth=GetSystemMetrics(SM_CXHSCROLL);	wndGetHScrollBarRect(hWnd,&rc);	pScrollInfo=pWin->pHScroll;	pCurState = pWin->pHCurState;	iBarWidth	=rc.right - rc.left + 1;	iBarHeight	=rc.bottom - rc.top + 1;	iSliderBarWidth =	pCurState->iSliderBarLen;	iPos = pCurState->iSliderBarVal;	iTotalBarWidth = iBarWidth- 2 * iArrowWidth;	//RightButton	SetRect(&rcRightButton,rc.right-iArrowWidth,rc.top,rc.right,rc.bottom);	//LeftButton	SetRect(&rcLeftButton,rc.right-2*iArrowWidth,rc.top,rc.right-iArrowWidth,rc.bottom);	//TotalBar	SetRect(&rcTotalBar,rc.left,rc.top,rc.right-2*iArrowWidth,rc.bottom);	//SliderBar	SetRect(&rcSliderBar,rc.left+iPos,rc.top,rc.left+iPos+iSliderBarWidth,rc.bottom);	//	if(PtInRect(&rcRightButton,x,y)){		pWin->pHScroll->dwStatus |=SS_DOWNRIGHT_PRESSDOWN;		scrInvalidateRect(hWnd,&rcRightButton,true);		if((pScrollInfo->nPos + pScrollInfo->nPage -1) < pScrollInfo->nMax){			pScrollInfo->nPos+=1;			iPos = (pScrollInfo->nPos - pScrollInfo->nMin) * iTotalBarWidth/(pScrollInfo->nMax - pScrollInfo->nMin + 1);			if((rcTotalBar.right - iPos)< iSliderBarWidth)				iPos=rcTotalBar.right - iSliderBarWidth;			pCurState->iSliderBarVal = iPos;			scrInvalidateRect(hWnd,&rcTotalBar,true);			iRetMsg=SB_LINERIGHT;			if(IsControl(hWnd)){				SendMessage(hWnd,LMSG_HSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL);			}			else{				SendNotifyMessage(hWnd,LMSG_HSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL);			}		}		else if(pCurState->iSliderBarVal + pCurState->iSliderBarLen < iTotalBarWidth - 1){			pCurState->iSliderBarVal = iTotalBarWidth - pCurState->iSliderBarLen;			scrInvalidateRect(hWnd,&rcTotalBar,true);		}	}	else if(PtInRect(&rcLeftButton,x,y)){		pWin->pHScroll->dwStatus |=SS_UPLEFT_PRESSDOWN;		scrInvalidateRect(hWnd,&rcLeftButton,true);		if(pScrollInfo->nPos > pScrollInfo->nMin){			pScrollInfo->nPos-=1;			iPos = (pScrollInfo->nPos - pScrollInfo->nMin) * iTotalBarWidth/(pScrollInfo->nMax - pScrollInfo->nMin + 1);			pCurState->iSliderBarVal = iPos;			scrInvalidateRect(hWnd,&rcTotalBar,true);			iRetMsg=SB_LINELEFT;			if(IsControl(hWnd)){				SendMessage(hWnd,LMSG_HSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL);			}			else{				SendNotifyMessage(hWnd,LMSG_HSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL);			}		}	}	else if(PtInRect(&rcSliderBar,x,y)){		pWin->dwStyle=pWin->dwStyle | SS_BAR_PRESSDOWN;		pCurState->iClickPos = x - rcSliderBar.left;	}	else{		pCurState->iClickPos = 0;	}}////===================================Pen Up=========================================//vscroll penup procedurevoid VScrollBarPenUpProc(	HWND hWnd){	PWindowsTree pWin;	int iArrowHeight,iBarHeight,iBarWidth;	RECT rc,rcDownButton,rcUpButton;	pWin=(PWindowsTree)hWnd;	if(!ScrollBarIsEnable(pWin->pVScroll))		return;	iArrowHeight=GetSystemMetrics(SM_CYVSCROLL);	//GetClientRect(hWnd,&rc);	//GetWindowRect(hWnd,&rc);	wndGetVScrollBarRect(hWnd,&rc);	iBarWidth	=rc.right - rc.left + 1;	iBarHeight	=rc.bottom - rc.top + 1;	//DownButton	SetRect(&rcDownButton,rc.left,rc.bottom-iArrowHeight,rc.right,rc.bottom);	//UpButton	SetRect(&rcUpButton,rc.left,rc.bottom-2*iArrowHeight,rc.right,rc.bottom-iArrowHeight);	//restore  the clicked button	if((pWin->pVScroll->dwStatus & SS_DOWNRIGHT_PRESSDOWN) !=0){		pWin->pVScroll->dwStatus = pWin->pVScroll->dwStatus & ~SS_DOWNRIGHT_PRESSDOWN;		scrInvalidateRect(hWnd,&rcDownButton,true);	}	else if((pWin->pVScroll->dwStatus & SS_UPLEFT_PRESSDOWN) !=0){		pWin->pVScroll->dwStatus = pWin->pVScroll->dwStatus & ~SS_UPLEFT_PRESSDOWN;		scrInvalidateRect(hWnd,&rcUpButton,true);	}	else if((pWin->pVScroll->dwStatus & SS_BAR_PRESSDOWN) !=0){		pWin->pVScroll->dwStatus =pWin->pVScroll->dwStatus & ~SS_BAR_PRESSDOWN;	}}//hscroll penup procedurevoid HScrollBarPenUpProc(	HWND hWnd){	PWindowsTree pWin;	int iArrowWidth,iBarHeight,iBarWidth;	RECT rc,rcRightButton,rcLeftButton;	pWin=(PWindowsTree)hWnd;	if(!ScrollBarIsEnable(pWin->pHScroll))		return;	iArrowWidth=GetSystemMetrics(SM_CXHSCROLL);	wndGetHScrollBarRect(hWnd,&rc);	iBarWidth	=rc.right - rc.left + 1;	iBarHeight	=rc.bottom - rc.top + 1;	//RightButton	SetRect(&rcRightButton,rc.right-iArrowWidth,rc.top,rc.right,rc.bottom);	//LeftButton	SetRect(&rcLeftButton,rc.right-2*iArrowWidth,rc.top,rc.right-iArrowWidth,rc.bottom);	//restore  the clicked button	if((pWin->pHScroll->dwStatus & SS_DOWNRIGHT_PRESSDOWN) !=0){		pWin->pHScroll->dwStatus = pWin->pHScroll->dwStatus & ~SS_DOWNRIGHT_PRESSDOWN;		scrInvalidateRect(hWnd,&rcRightButton,true);	}	else if((pWin->pHScroll->dwStatus & SS_UPLEFT_PRESSDOWN) !=0){		pWin->pHScroll->dwStatus = pWin->pHScroll->dwStatus & ~SS_UPLEFT_PRESSDOWN;		scrInvalidateRect(hWnd,&rcLeftButton,true);	}	else if((pWin->pHScroll->dwStatus & SS_BAR_PRESSDOWN) !=0){		pWin->pHScroll->dwStatus = pWin->pHScroll->dwStatus & ~SS_BAR_PRESSDOWN;	}}////===================================Pen Move=======================================//vscroll penmove procedurevoid VScrollBarPenMoveProc(	HWND hWnd,	int x, 	int y){	int iArrowHeight,iBarWidth,iBarHeight,iSliderBarHeight,iPos,iTotalBarHeight;	RECT rc,rcDownButton,rcUpButton,rcTotalBar,rcSliderBar;	LPSCROLLCURSTATE pCurState;	LPSCROLLINFO pScrollInfo;	unsigned long iRetMsg;	PWindowsTree pWin;	pWin=(PWindowsTree)hWnd;	if(!ScrollBarIsEnable(pWin->pVScroll))		return;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -