Exemplo n.º 1
0
void WeekView::Draw(const Period& period,
							int weekNumber,CDC* pDC)
{
	CString strWeekNumber;
	strWeekNumber.Format(_T("Week Number: %d"),m_weekNumber+1);
	CRect rcNames(40,10,40,10);
	CRect rcHeight(rcNames);
	pDC->DrawText(strWeekNumber,&rcHeight,DT_NOCLIP | DT_CALCRECT);
	int height = rcHeight.Height()+2;
	pDC->DrawText(strWeekNumber,rcNames,DT_NOCLIP);
	rcNames.OffsetRect(0,height);

	vector<vector<Slot> > cached(7);
	CString names(_T("Names"));
	pDC->DrawText(names,rcNames,DT_NOCLIP);
	


	CRect rcHoursNeeded(rcNames);
	rcHoursNeeded.OffsetRect(200,0);
	pDC->DrawText(_T("Hours Needed"),rcHoursNeeded,DT_NOCLIP);
	CRect rcHoursUsed(rcHoursNeeded);
	rcHoursUsed.OffsetRect(200,0);
	pDC->DrawText(_T("Hours Used"),rcHoursUsed,DT_NOCLIP);
	
	for(int i=0;i<period.m_data.m_nurses.Size();i++)
	{
		rcNames.OffsetRect(0,height);
		rcHoursNeeded.OffsetRect(0,height);
		rcHoursUsed.OffsetRect(0,height);

		const Nurse& nurse = period.m_data.m_nurses[i];
		

		int weeklyHours = nurse.GetWeeklyHours();
		CString strWeeklyHours;
		strWeeklyHours.Format(_T("%d\n"),weeklyHours);
		
		int numberOfHours = GetNumberOfHoursPerWeek(period,nurse,weekNumber,cached);
		CString strHoursUsed;
		strHoursUsed.Format(_T("%d\n"),numberOfHours);
		
		if (weeklyHours > 0)
		{
			if (weeklyHours < numberOfHours)
				pDC->SetTextColor(RGB(0,0,255));
			else
			if (weeklyHours > numberOfHours)
				pDC->SetTextColor(RGB(255,0,0));
		}

		pDC->DrawText(nurse.GetName().FullName(),rcNames,DT_NOCLIP);
		pDC->DrawText(strWeeklyHours,rcHoursNeeded,DT_NOCLIP);
		pDC->DrawText(strHoursUsed,rcHoursUsed,DT_NOCLIP);
		pDC->SetTextColor(RGB(0,0,0));
	}

	SetScrollSizes(MM_TEXT,CSize(rcHoursUsed.right,rcHoursUsed.bottom));
}
Exemplo n.º 2
0
	/// WM_PAINT
	int wmPaint() {
		PAINTSTRUCT ps;
		HDC hdc = BeginPaint(m_hwnd, &ps);
		ASSERT(hdc);

		if (GetCapture() != m_hwnd) {
			RECT rc;
			CHECK_TRUE( GetClientRect(m_hwnd, &rc) );
			CHECK_TRUE(
				DrawIcon(hdc, (rcWidth(&rc) - GetSystemMetrics(SM_CXICON)) / 2,
						 (rcHeight(&rc) - GetSystemMetrics(SM_CYICON)) / 2,
						 m_hCursor) );
		}

		EndPaint(m_hwnd, &ps);
		return 0;
	}
Exemplo n.º 3
0
	static void invertFrame(HWND i_hwnd) {
		HDC hdc = GetWindowDC(i_hwnd);
		ASSERT(hdc);
		int rop2 = SetROP2(hdc, R2_XORPEN);
		if (rop2) {
			RECT rc;
			CHECK_TRUE( GetWindowRect(i_hwnd, &rc) );
			int width = rcWidth(&rc);
			int height = rcHeight(&rc);

			HANDLE hpen = SelectObject(hdc, GetStockObject(WHITE_PEN));
			HANDLE hbr  = SelectObject(hdc, GetStockObject(NULL_BRUSH));
			CHECK_TRUE( Rectangle(hdc, 0, 0, width    , height    ) );
			CHECK_TRUE( Rectangle(hdc, 1, 1, width - 1, height - 1) );
			CHECK_TRUE( Rectangle(hdc, 2, 2, width - 2, height - 2) );
			SelectObject(hdc, hpen);
			SelectObject(hdc, hbr);
			// no need to DeleteObject StockObject
			SetROP2(hdc, rop2);
		}
		CHECK_TRUE( ReleaseDC(i_hwnd, hdc) );
	}