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

📄 interface.cpp

📁 jedit 一个小型java编译器的源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		Start+=Container[i].GetNameLength();
	}
}
void DockCtrl::OnDraw(HDC hdc)
{
	POINT point[3];
	Draw3DBar(hdc,0,0,9+GetCtrlWndLength(),19,RGB(255,255,255),
		RGB(128,128,128));

	HBRUSH hBrush=CreateSolidBrush(RGB(0,128,0));
	if(Focus==0)
		SelectObject(hdc,hBrush);
	else
		SelectObject(hdc,(HBRUSH)GetStockObject(BLACK_BRUSH));
	if(State==STATE_IN)
	{
		point[0].x=7;
		point[0].y=5;
		point[1].x=7;
		point[1].y=15;
		point[2].x=2;
		point[2].y=10;
	}
	else
	{
		point[0].x=2;
		point[0].y=5;
		point[1].x=2;
		point[1].y=15;
		point[2].x=7;
		point[2].y=10;
	}
	Polygon(hdc,point,3);

	SetBkMode(hdc,TRANSPARENT);
	char *Name;
	RECT txtRect;
	txtRect.left=10;
	txtRect.top=0;
	txtRect.right=10;
	txtRect.bottom=20;
	for(int i=0;i<Container.length();i++)
	{
		if(Focus==i+1)
			SetTextColor(hdc,RGB(0,0,255));
		else
			SetTextColor(hdc,RGB(0,0,128));
		DrawSeparetor(hdc,txtRect.right);
		txtRect.left=txtRect.right;
		txtRect.right+=Container[i].GetNameLength();
		Name=Container[i].GetName();
		DrawText(hdc,Name,strlen(Name),&txtRect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
	}
	DeleteObject(hBrush);
}
int DockCtrl::GetCtrlWndLength()
{
	int Width=10;
	int NameWidth=0;
	for(int i=0;i<Container.length();i++)
	{
		NameWidth=Container[i].GetNameLength();
		Width+=NameWidth;
	}
	return Width;
}
void DockCtrl::PopIn(HWND hwnd)
{
	KillTimer(hwnd,1001);

	WndInfo* WI;
	WI=GetWI(hwnd);
	int i;

	RECT rect,PRect;
	GetWindowRect(hwnd,&rect);
	GetClientRect(PRect);
	POINT lt;
	lt.x=rect.left;
	lt.y=rect.top;
	ScreenToClient(Parent,&lt);

	int Height,Width;
	Height=WI->Height;
	Width=WI->Width;
	switch(WI->DockType)
	{
	case DOCK_LEFT:
		if(WI->State==DOCK_POPUP)
		{
			if(Height>PRect.bottom-lt.y)
				Height=PRect.bottom-lt.y;
			for(i= Width;i>15;i-=20)
			{
				MoveWindow(hwnd,rect.left,rect.top,i, Height,true);
				Sleep(50);
			}
			MoveWindow(hwnd,rect.left,rect.top,15, Height,true);
			WI->State=DOCK_HIDE;
		}
		break;
	case DOCK_RIGHT:
		if(WI->State==DOCK_POPUP)
		{
			if(Height>PRect.bottom-lt.y)
				Height=PRect.bottom-lt.y;
			for(i= Width;i>5;i-=20)
			{
				MoveWindow(hwnd,rect.right-i,rect.top,i, Height,true);
				Sleep(50);
			}
			MoveWindow(hwnd,rect.right-6,rect.top,5, Height,true);
			WI->State=DOCK_HIDE;
		}
		break;
	case DOCK_TOP:
		if(WI->State==DOCK_POPUP)
		{
			if(Width>PRect.right-lt.x)
			Width=PRect.right-lt.x;
			for(i= Height;i>3;i-=20)
			{
				MoveWindow(hwnd,rect.left,rect.top, Width,i,true);
				Sleep(50);
			}
			MoveWindow(hwnd,rect.left,rect.top, Width,3,true);
			WI->State=DOCK_HIDE;
		}
		break;
	case DOCK_BOTTOM:
		if(WI->State==DOCK_POPUP)
		{
			if(Width>PRect.right-lt.x)
			Width=PRect.right-lt.x;
			WI->State=DOCK_HIDE;
			for(i= Height;i>15;i-=20)
			{
				MoveWindow(hwnd,rect.left,rect.bottom-i, Width,i,true);
				Sleep(50);
			}
			MoveWindow(hwnd,rect.left,rect.bottom-15, Width,15,true);
		}
		break;
	}
	if(!WI->AutoHide)
		SendMessage(Parent,WM_DWPOSCHANGED,0,0);
	InvalidateRect(hwnd,NULL,true);
}
void DockCtrl::PopUp(HWND hwnd)
{
	WndInfo* WI;
	WI=GetWI(hwnd);
	int i;

	RECT rect,PRect;
	GetWindowRect(hwnd,&rect);
	GetClientRect(PRect);
	POINT lt;
	lt.x=rect.left;
	lt.y=rect.top;
	ScreenToClient(Parent,&lt);

	int Height,Width;
	Height=WI->Height;
	Width=WI->Width;

	switch(WI->DockType)
	{
	case DOCK_LEFT:
		if(WI->State==DOCK_HIDE)
		{
			if(Height>PRect.bottom-lt.y)
			Height=PRect.bottom-lt.y;
			for(i=0;i<Width;i+=20)
			{
				MoveWindow(hwnd,rect.left,rect.top,i,Height,true);
				Sleep(50);
			}
			MoveWindow(hwnd,rect.left,rect.top,Width,Height,true);
			WI->State=DOCK_POPUP;
		}
		break;
	case DOCK_RIGHT:
		if(WI->State==DOCK_HIDE)
		{
			if(Height>PRect.bottom-lt.y)
			Height=PRect.bottom-lt.y;
			for(i=6;i<Width;i+=20)
			{
				MoveWindow(hwnd,rect.right-i,rect.top,i,Height,true);
				Sleep(50);
			}
			MoveWindow(hwnd,rect.right-Width,rect.top,Width,Height,true);
			WI->State=DOCK_POPUP;
		}
		break;
	case DOCK_TOP:
		if(WI->State==DOCK_HIDE)
		{
			if(Width>PRect.right-lt.x)
			Width=PRect.right-lt.x;
			for(i=0;i< Height;i+=20)
			{
				MoveWindow(hwnd,rect.left,rect.top, Width,i,true);
				Sleep(50);
			}
			MoveWindow(hwnd,rect.left,rect.top, Width, Height,true);
			WI->State=DOCK_POPUP;
		}
		break;
	case DOCK_BOTTOM:
		if(WI->State==DOCK_HIDE)
		{
			if(Width>PRect.right-lt.x)
			Width=PRect.right-lt.x;
			WI->State=DOCK_POPUP;
			for(i=6;i< Height;i+=20)
			{
				MoveWindow(hwnd,rect.left,rect.bottom-i, Width,i,true);
				Sleep(50);
			}
			MoveWindow(hwnd,rect.left,rect.bottom- Height, Width, Height,true);
			InvalidateRect(hwnd,NULL,true);
		}
		break;
	}
	SetTimer(hwnd,1001,2000,NULL);
	if(!WI->AutoHide)
		SendMessage(Parent,WM_DWPOSCHANGED,0,0);
}
void DockCtrl::OnDWDraw(HDC hdc,HWND hwnd)
{
	WndInfo* WI;
	WI=GetWI(hwnd);
	POINT point[3];

	HBRUSH hBrush;
	hBrush=CreateSolidBrush(RGB(0,0,64));
	SelectObject(hdc,hBrush);
	if(WI->State==DOCK_POPUP)
	{
		Rectangle(hdc,0,0,WI->Width,20);
		SetTextColor(hdc,RGB(255,255,255));
		SetBkMode(hdc,TRANSPARENT);
		TextOut(hdc,5,0,WI->Name,strlen(WI->Name));
	}
	if(WI->State==DOCK_HIDE)
	{
		switch(WI->DockType)
		{
		case DOCK_BOTTOM:
			point[0].x=WI->Width/2-20;
			point[0].y=4;
			point[1].x=WI->Width/2+20;
			point[1].y=4;
			point[2].x=WI->Width/2;
			point[2].y=0;
			Rectangle(hdc,WI->Width/2-20,6,WI->Width/2+20,9);
			break;
		case DOCK_LEFT:
			point[0].x=5;
			point[0].y=WI->Height/2-20;
			point[1].x=5;
			point[1].y=WI->Height/2+20;
			point[2].x=9;
			point[2].y=WI->Height/2;
			Rectangle(hdc,0,WI->Height/2-20,3,WI->Height/2+20);
			break;
		}
		Polygon(hdc,point,3);
		
	}
	DeleteObject(hBrush);
}
void DockCtrl::OnDWLButtonDown(HWND hwnd,WPARAM wParam,LPARAM lParam)
{
	WndInfo *WI;
	WI=GetWI(hwnd);
	int x,y;
	POINT point;
	GetCursorPos(&point);
	ScreenToClient(hwnd,&point);
	x=point.x;
	y=point.y;
	if(WI->State==DOCK_HIDE)
	{
		switch(WI->DockType)
		{
		case DOCK_BOTTOM:
		case DOCK_TOP:
			if(x>=WI->Width/2-20&&x<=WI->Width/2+20)
				PopUp(hwnd);
			return;
		case DOCK_LEFT:
		case DOCK_RIGHT:
			if(y>=WI->Height/2-20&&y<=WI->Height/2+20)
				PopUp(hwnd);
			return;
		}
	}
	else
	{
		DWLButtonFlag=true;
		SetCapture(hwnd);

		ClientToScreen(hwnd,&point);
		DWLx=point.x;
		DWLy=point.y;
		Prevx=point.x;
		Prevy=point.y;
		DrawDragBorder(hwnd,Prevx,Prevy);
	}
}
void DockCtrl::OnDWMouseMove(HWND hwnd,WPARAM wParam,LPARAM lParam)
{
	DrawDragBorder(hwnd,Prevx,Prevy);
	
	POINT point;
	GetCursorPos(&point);
	Prevx=point.x;
	Prevy=point.y;

	DrawDragBorder(hwnd,point.x,point.y);
}
void DockCtrl::OnDWLButtonUp(HWND hwnd,WPARAM wParam,LPARAM lParam)
{
	DrawDragBorder(hwnd,Prevx,Prevy);
	
	POINT point;
	GetCursorPos(&point);

	RECT WRect;
	GetBRect(hwnd,point.x,point.y,WRect);
	MoveWindow(hwnd,WRect.left,WRect.top,
		WRect.right-WRect.left,WRect.bottom-WRect.top,true);

	WndInfo *WI;
	WI=GetWI(hwnd);
	WI->X=WRect.left;
	WI->Y=WRect.top;
	ReleaseCapture();
	DWLButtonFlag=false;
}
bool DockCtrl::GetBRect(HWND hwnd,int x,int y,RECT &Brect)
{
	bool DockFlag=true;

	RECT rect,Wrect;
	GetClientRect(rect);
	GetWindowRect(hwnd,&Wrect);

	POINT point;
	point.x=x;
	point.y=y;
	ScreenToClient(Parent,&point);

	WndInfo* WI;
	WI=GetWI(hwnd);

	if(WI->State==DOCK_HIDE)
		return true;

	POINT	p;
	if(point.x<200&&point.x>-200)
	{
		p.x=rect.left;
		p.y=0;
		ClientToScreen(Parent,&p);
		Brect.left=p.x;

		Brect.right=Brect.left+WI->Width;
	
		p.x=0;
		p.y=Wrect.top+y-DWLy;
		ScreenToClient(Parent,&p);
		if(p.y<0) p.y=0;
		if(p.y>rect.bottom-WI->Height) p.y=rect.bottom-WI->Height;
		ClientToScreen(Parent,&p);
		Brect.top=p.y;
		Brect.bottom=Brect.top+WI->Height;
		if(WI->DockStyle&DOCK_LEFT)
		{
			WI->DockType=DOCK_LEFT;
			return true;
		}
	}
	if(point.x>rect.right-200&&point.x<rect.right+200)
	{
		p.x=rect.right;
		p.y=0;
		ClientToScreen(Parent,&p);
		Brect.right=p.x;

		Brect.left=Brect.right-WI->Width;
		

		p.x=0;
		p.y=Wrect.top+y-DWLy;
		ScreenToClient(Parent,&p);
		if(p.y<0) p.y=0;
		if(p.y>rect.bottom-WI->Height) p.y=rect.bottom-WI->Height;
		ClientToScreen(Parent,&p);
		Brect.top=p.y;
		Brect.bottom=Brect.top+WI->Height;
		if(WI->DockStyle&DOCK_RIGHT)
		{
			WI->DockType=DOCK_RIGHT;
			return true;
		}
	}
	if(point.y>-200&&point.y<200)
	{
		Brect.left=Wrect.left+x-DWLx;
		Brect.right=Brect.left+WI->Width;
		
		p.y=rect.top;
		p.x=0;
		ClientToScreen(Parent,&p);
		Brect.top=p.y;

		Brect.bottom=Brect.top+WI->Height;
		if(WI->DockStyle&DOCK_TOP)
		{
			WI->DockType=DOCK_TOP;
			return true;
		}
	}
	if(point.y>rect.bottom-200&&point.y<rect.bottom+200)
	{
		p.x=0;
		p.y=0;
		ClientToScreen(Parent,&p);
		Brect.left=p.x;
		Brect.right=p.x+rect.right;
		p.x=0;
		p.y=rect.bottom;
		ClientToScreen(Parent,&p);
		Brect.bottom=p.y;

		Brect.top=Brect.bottom-WI->Height;
		if(WI->DockStyle&DOCK_BOTTOM)
		{
			WI->DockType=DOCK_BOTTOM;
			return true;
		}
	}
	
	Brect.left=Wrect.left+x-DWLx;
	Brect.right=Brect.left+WI->Width;
	Brect.top=Wrect.top+y-DWLy;
	Brect.bottom=Brect.top+WI->Height;
	if(WI->DockStyle&NODOCK)
		WI->DockType=NODOCK;
	return false;
}
void DockCtrl::DrawDragBorder(HWND hwnd,int x,int y)
{
	if(!DWLButtonFlag)
		return;
	RECT Brect;
	bool DockFlag=GetBRect(hwnd,x,y,Brect);
	
	DrawXorFrame(Brect,DockFlag);
}

void DockCtrl::DrawXorFrame( RECT rect, BOOL fDocked)
{
	static WORD _dotPatternBmp1[] = 
	{
		0x00aa, 0x0055, 0x00aa, 0x0055, 0x00aa, 0x0055, 0x00aa, 0x0055
	};

	static WORD _dotPatternBmp2[] = 
	{
		0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
	};

	HBITMAP hbm;
	HBRUSH  hbr;
	HANDLE  hbrushOld;
	WORD    *bitmap;

	int width, height, x, y;
	int border;

	HDC hdc = GetDC(0);

	if(fDocked)
	{
		border = 1;
		bitmap = _dotPatternBmp2;
	}
	else
	{
		border = 3;
		bitmap = _dotPatternBmp1;
	}
	
	x = rect.left;
	y = rect.top;
	width  = rect.right-rect.left;
	height = rect.bottom-rect.top;

	hbm = CreateBitmap(8, 8, 1, 1, bitmap);
	hbr = CreatePatternBrush(hbm);

	SetBrushOrgEx(hdc, x, y, 0);
	hbrushOld = SelectObject(hdc, hbr);

	PatBlt(hdc, x+border,       y,               width-border,  border,        PATINVERT);
	PatBlt(hdc, x+width-border, y+border,        border,        height-border, PATINVERT);
	PatBlt(hdc, x,              y+height-border, width-border,  border,        PATINVERT);
	PatBlt(hdc, x,              y,               border,        height-border, PATINVERT);

	SelectObject(hdc, hbrushOld);
	DeleteObject(hbr);
	DeleteObject(hbm);
	ReleaseDC(0, hdc);
}
WndInfo* DockCtrl::GetWI(char *wndname)
{
	int i;
	for(i=0;i<Container.length();i++)
		if(strcmp(wndname,Container[i].Name)==0)
			return &Container[i];
	return NULL;
}
void	DockCtrl::GetRect(RECT &rect)
{
		int i;
		for(i=0;i<Container.length();i++)
		{
			switch(Container[i].DockType)
			{
			case DOCK_LEFT:
				if(Container[i].State==DOCK_HIDE)
					rect.left+=15;
				else
				{
					if(!Container[i].AutoHide)
						rect.left+=Container[i].Width;
				}
				break;
			case DOCK_RIGHT:
				if(Container[i].State==DOCK_HIDE)
					rect.right-=6;
				else
				{
					if(!Container[i].AutoHide)
						rect.left-=Container[i].Width;
				}
				break;
			case DOCK_TOP:
				if(Container[i].State==DOCK_HIDE)
					rect.top+=6;
				else
				{
					if(!Container[i].AutoHide)
						rect.top+=Container[i].Height;
				}
				break;
			case DOCK_BOTTOM:
				if(Container[i].State==DOCK_HIDE)
					rect.bottom-=15;
				else
				{
					if(!Container[i].AutoHide)
						rect.bottom-=Container[i].Height;
				}
				break;
			}
		}
}

⌨️ 快捷键说明

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