void OnCalendarLButtonDown(HWND hwndDlg, BOOL fDoubleClick, int x, int y, UINT keyFlags)
{
	if(iPreviousHighlight!=-1)
	{
		HDC hDC;
		hDC=GetDC(hwndDlg);				
		Draw3DBorder(hDC,rDateRects[iPreviousHighlight],clrCalendarBackGnd,true); 
		ReleaseDC(hwndDlg,hDC);
	}
}
Exemple #2
0
VOID CSelectSrv::Render(INT	nLoopTime)
{
	INT		i,j;
	RECT	tRect;

	COLORREF nBkColor;
	if(m_fIsActive)
	{
		// Write Texts;
		Draw3DBorder(m_rcWnd,RGB(125,125,125),125);
		for(i = 0 ; i <= ((m_nSrvCount - 1) / COUNT_BUTTON_PER_COLUME) ; i++)
		{
			for(j = i * COUNT_BUTTON_PER_COLUME; (j < m_nSrvCount && j < (COUNT_BUTTON_PER_COLUME * (i + 1))) ; j ++)
			{	nBkColor = m_ppxSrvBtn[j]->dwBkColor;
				SetRect(&tRect,m_rcWnd.left + m_ppxSrvBtn[j]->rcBtn.left, m_rcWnd.top + m_ppxSrvBtn[j]->rcBtn.top, m_rcWnd.left +m_ppxSrvBtn[j]->rcBtn.right ,m_rcWnd.top +m_ppxSrvBtn[j]->rcBtn.bottom);
				if(nBkColor!=RGB(125,125,125))Draw3DBorder(tRect, nBkColor,m_ppxSrvBtn[j]->nAlpha);								
				g_xMainWnd.PutsHan(NULL, tRect,
										m_ppxSrvBtn[j]->dwTxtColor, RGB(0,0,0), m_ppxSrvBtn[j]->szCaption,g_xMainWnd.CreateGameFont("명조",12 ));
			}
		}
	}
}
void OnCalendarLButtonUp(HWND hwndDlg, int x, int y, UINT flags) 
{
	POINT pPoint;
	pPoint.x=x;
	pPoint.y=y;
	//exit
	if(PtInRect(&rDateRects[31],pPoint))
		PostMessage(hwndDlg,WM_CLOSE,0,0);

	if(iPreviousHighlight!=-1 && PtInRect(&rDateRects[iPreviousHighlight],pPoint))
	{
		if (iPreviousHighlight!=32)
		{
			sCurrentDay.wDay=iPreviousHighlight+1;
			InvalidateRect(hwndDlg,NULL,FALSE);
		}
		else
		{					
			char sDay[25];int i;
			HDC hDC;HMENU hYearMenu;
			hDC=GetDC(hwndDlg);
			wsprintf(sDay,"%d-%s-%d",sCurrentDay.wDay,sMonthNames[sCurrentDay.wMonth-1],sCurrentDay.wYear);
			HeighlightText(hDC,sDay,rDateRects[32],clrCalendarDate/6,true);
			Draw3DBorder(hDC,rDateRects[32],clrCalendarBackGnd);
			iPreviousHighlight=32;
			ReleaseDC(hwndDlg,hDC);
			//Create a Popup menu showing +/- 5 years
			hYearMenu=CreatePopupMenu();

			for (i=0;i<10;i++)
			{
				wsprintf(sDay,"%d",sCurrentDay.wYear+i-5); 
				InsertMenu(hYearMenu,i,MF_BYPOSITION|MF_POPUP|MF_STRING,i+5000,sDay);
			}
			ClientToScreen(hwndDlg,&pPoint);
			SetMenuDefaultItem(hYearMenu,5,TRUE);
			TrackPopupMenu(hYearMenu,TPM_LEFTBUTTON,pPoint.x,pPoint.y,0,hwndDlg,NULL);
			i=GetInputState();
		}

	}
	return;
}
/*
 * And the routine to actually write the text into the InfoWindow.  This
 * gets called from events.c as a result of Expose events on the window.
 */
void
draw_info_window(void)
{
	int i;
	const int height = Scr->DefaultFont.height + 2;

	Draw3DBorder(Scr->InfoWindow.win, 0, 0,
	             Scr->InfoWindow.width, Scr->InfoWindow.height,
	             2, Scr->DefaultC, off, true, false);

	FB(Scr->DefaultC.fore, Scr->DefaultC.back);

	for(i = 0; i < Scr->InfoWindow.lines ; i++) {
		XmbDrawString(dpy, Scr->InfoWindow.win, Scr->DefaultFont.font_set,
		              Scr->NormalGC, 5,
		              (i * height) + Scr->DefaultFont.y + 5,
		              Info[i], strlen(Info[i]));
	}
}
void Tooltip::onPaint(PAINTSTRUCT& ps)
{
	int len = (int) wcslen(text);
	RECT rc, textrc = {0};
	GetClientRect( hwnd, &rc );

	Draw3DBorder( ps.hdc, &rc, GetSysColor(COLOR_BTNFACE), GetSysColor(COLOR_3DDKSHADOW), 1);

	SetBkMode( ps.hdc, TRANSPARENT );
	SetTextColor(ps.hdc, GetSysColor(COLOR_INFOTEXT) );
	HGDIOBJ old_font = SelectObject( ps.hdc, GetStockObject(DEFAULT_GUI_FONT));

	SIZE size;
	GetTextExtentPoint32W( ps.hdc, text, len, &size );
	rc.top += (rc.bottom - size.cy)/2;
	rc.left += (rc.right - size.cx)/2;
	ExtTextOutW( ps.hdc, rc.left, rc.top, 0, &textrc, text, len, NULL );

	SelectObject( ps.hdc, old_font );
}
void DrawMonth(HWND hwndDlg,HDC hDC)
{
	RECT rRect,rClientRect;
	int iSaveDCState,iX,iY,iRowHeight,iRowWidth;
	COLORREF clrColor=clrCalendarDate;
	int iDay,iLastDay; SYSTEMTIME dDay;
	char sDay[25];POINT pPoint;

	HDC hMemDC,hTempDC;HBITMAP hBackGnd,hOldBitmap,hOldBitmap1;

	iSaveDCState=SaveDC(hDC);

	GetClientRect(hwndDlg,&rClientRect);

	//Get a plain backgnd
	if (hBackGndBitmap==NULL)
		hBackGndBitmap=GetCalendarBackGnd(hwndDlg,hDC,clrCalendarBackGnd);
	
	hTempDC=CreateCompatibleDC(hDC);
	hOldBitmap1=(HBITMAP)SelectObject(hTempDC,hBackGndBitmap); 

	hMemDC=CreateCompatibleDC(hDC);		
	hBackGnd=CreateCompatibleBitmap(hDC,rClientRect.right-rClientRect.left,rClientRect.bottom-rClientRect.top);
	hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBackGnd);

	BitBlt(hMemDC,rClientRect.left,rClientRect.top,rClientRect.right,rClientRect.bottom,hTempDC,0,0,SRCCOPY);
	SelectObject(hTempDC,hOldBitmap1); 
	DeleteDC(hTempDC);

	//Draw the Calendar on the memory DC
	GetWindowRect(GetDlgItem(hwndDlg,IDC_Calendar),&rRect);	
	MapWindowPoints(NULL,hwndDlg,(POINT*)&rRect,2);

	Draw3DBorder(hMemDC,rRect,clrCalendarBackGnd,false); 

	iRowWidth=(rRect.right-rRect.left)/7;
	iRowHeight=(rRect.bottom-rRect.top)/7;

	
	for (iX=0;iX<7;iX++)
	{
		pPoint.x=long(iX*iRowWidth+iRowWidth);
		pPoint.y=long(1.9*iRowHeight);
		DrawText(hMemDC,sWeekNames[iX],pPoint,clrColor,1.0);
	}

	dDay=sCurrentDay;
	iLastDay=DaysInMonth(dDay);


	for (iY=1,iDay=0;iY<7;iY++)
	{
		for (iX=(iY==1?FirstOftheMonth(dDay):0);iX<7 && iDay<iLastDay;iX++,iDay++)
		{
			//pPoint.x=long(iX*iRowWidth+iRowWidth);
			//pPoint.y=long(iY*iRowHeight+iRowHeight*1.9);			
			rDateRects[iDay].top=long(iY*iRowHeight+iRowHeight*1.4);
			rDateRects[iDay].left=long(iX*iRowWidth+iRowWidth/1.5);
			rDateRects[iDay].bottom=rDateRects[iDay].top+iRowHeight;
			rDateRects[iDay].right=long(rDateRects[iDay].left+iRowWidth/1.5);
			pPoint.x=long(rDateRects[iDay].left+(rDateRects[iDay].right-rDateRects[iDay].left)/2);
			pPoint.y=long(rDateRects[iDay].top+(rDateRects[iDay].bottom-rDateRects[iDay].top)/2);
			wsprintf(sDay,"%d",iDay+1);
			DrawText(hMemDC,sDay,pPoint,clrColor,1.0);		
		}
	}

	//Heilight current day
	dDay=sCurrentDay;
	
/*
	for (iY=1,iDay=(8-FirstOftheMonth(dDay));iY<7;iY++,iDay+=7)
	{
		if (iDay>dDay.wDay) 
			break;
	}		
	rRect.top=long((iY)*iRowHeight+iRowHeight*1.4);
	rRect.left=long((DayOfTheWeek(dDay))*iRowWidth+iRowWidth/1.5);
	rRect.bottom=rRect.top+iRowHeight;
	rRect.right=long(rRect.left+iRowWidth/1.5);
	//give some 3D 
	Draw3DBorder(hMemDC,rRect,clrCalendarBackGnd);
*/
	Draw3DBorder(hMemDC,rDateRects[dDay.wDay-1],clrCalendarBackGnd);
	
	//Print the date dd-mm-yyyy
	pPoint.x=long(rDateRects[32].left+(rDateRects[32].right-rDateRects[32].left)/2);
	pPoint.y=long(rDateRects[32].top+(rDateRects[32].bottom-rDateRects[32].top)/2);
	wsprintf(sDay,"%d-%s-%d",dDay.wDay,sMonthNames[dDay.wMonth-1],dDay.wYear);
	DrawText(hMemDC,sDay,pPoint,clrColor/6,1.0);			

	//Blt it to the real DC
	BitBlt(hDC,rClientRect.left,rClientRect.top,rClientRect.right-rClientRect.left,rClientRect.bottom-rClientRect.top,hMemDC,0,0,SRCCOPY);  

	//clean up and return
	RestoreDC(hDC,iSaveDCState);
	SelectObject(hMemDC,hOldBitmap);
	DeleteObject(hBackGnd);
	DeleteDC(hMemDC);

}
void OnCalendarMouseMove(HWND hwndDlg, int x, int y, UINT keyFlags)	
{
	int i=0;
	if (!(keyFlags&MK_LBUTTON))
	{
		POINT pPoint;HDC hDC;
		pPoint.x=x;
		pPoint.y=y;
		//if still within old select area then simply exit
		if(iPreviousHighlight>=0 && PtInRect(&rDateRects[iPreviousHighlight],pPoint))
			return;
		if(PtInRect(&rDateRects[31],pPoint)&&iPreviousHighlight==-1)
		{					
			hDC=GetDC(hwndDlg);
			HeighlightText(hDC,TEXT("X"),rDateRects[31],clrCalendarDate/3,true,1.3);						
			Draw3DBorder(hDC,rDateRects[31],clrCalendarBackGnd);
			iPreviousHighlight=31;
			ReleaseDC(hwndDlg,hDC);
			return;
		}

		if(PtInRect(&rDateRects[32],pPoint)&&iPreviousHighlight==-1)
		{					
			char sDay[25];
			hDC=GetDC(hwndDlg);
			wsprintf(sDay,"%d-%s-%d",sCurrentDay.wDay,sMonthNames[sCurrentDay.wMonth-1],sCurrentDay.wYear);
			HeighlightText(hDC,sDay,rDateRects[32],clrCalendarDate/6,true);	
			Draw3DBorder(hDC,rDateRects[32],clrCalendarBackGnd);
			iPreviousHighlight=32;
			ReleaseDC(hwndDlg,hDC);
			return;
		}

		for (i=0;i<31;i++)
			if(PtInRect(&rDateRects[i],pPoint))
			{
				//revert back for previous highlight
				if(iPreviousHighlight>=0&&iPreviousHighlight!=i)
				{
					hDC=GetDC(hwndDlg);
					if (iPreviousHighlight==31)
						HeighlightText(hDC,TEXT("X"),rDateRects[iPreviousHighlight],clrCalendarDate/3,false,1.3,false);
					else if (iPreviousHighlight>=32)		
					{
						char sDay[25];
						wsprintf(sDay,"%d-%s-%d",sCurrentDay.wDay,sMonthNames[sCurrentDay.wMonth-1],sCurrentDay.wYear);
						HeighlightText(hDC,sDay,rDateRects[32],clrCalendarDate/6,false,1.0,false);	
					}
					else
						HeighlightDate(hDC,iPreviousHighlight,rDateRects[iPreviousHighlight],clrCalendarDate,false);
					iPreviousHighlight=-1;
					ReleaseDC(hwndDlg,hDC);

				}
			
				hDC=GetDC(hwndDlg);
				HeighlightDate(hDC,i,rDateRects[i],clrCalendarDate,true);						
				iPreviousHighlight=i;
				ReleaseDC(hwndDlg,hDC);
				return;
			}

		if (i>=31 && iPreviousHighlight>=0 &&(pPoint.x<rDateRects[iPreviousHighlight].left-2||pPoint.x>rDateRects[iPreviousHighlight].right+2||pPoint.y<rDateRects[iPreviousHighlight].top-2||pPoint.y>rDateRects[iPreviousHighlight].bottom+2))
		{
			//revert back for previous highlight
			hDC=GetDC(hwndDlg);
			if (iPreviousHighlight==31)
				HeighlightText(hDC,TEXT("X"),rDateRects[iPreviousHighlight],clrCalendarDate/3,false,1.3,false);
			else if (iPreviousHighlight>=32)		
			{
				char sDay[25];
				wsprintf(sDay,"%d-%s-%d",sCurrentDay.wDay,sMonthNames[sCurrentDay.wMonth-1],sCurrentDay.wYear);
				HeighlightText(hDC,sDay,rDateRects[32],clrCalendarDate/6,false,1.0,false);	
			}
			else
				HeighlightDate(hDC,iPreviousHighlight,rDateRects[iPreviousHighlight],clrCalendarDate,false);
			iPreviousHighlight=-1;
			ReleaseDC(hwndDlg,hDC);
		}
	}
	else if(keyFlags&MK_LBUTTON)
	{
		if (iPreviousHighlight!=-1)
			InvalidateRect(hwndDlg,NULL,FALSE);
		else
			PostMessage(hwndDlg,WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM(x,y));
	}
	return;
}