void CXTPCalendarWeekView::ShowDay(const COleDateTime& date, BOOL bSelect)
{
	CXTPCalendarControl::CUpdateContext updateContext(m_pControl, xtpCalendarUpdateRedrawIfNeed);
	CXTPCalendarControl::CViewChangedContext viewChanged(this);

	CXTPCalendarControl::CUpdateContext updateContext2(m_pControl, xtpCalendarUpdateAll);

	SetBeginDate(date);
	Populate();

	if (bSelect)
		SelectDay(CXTPCalendarUtils::ResetTime(date));
}
Esempio n. 2
0
void SvcRec::PrintDays()
{
  QDate top_date;

  //
  // Clear Days
  //
  QPalette weekend_palette=palette();
  weekend_palette.setColor(QPalette::Active,QColorGroup::Background,
			   palette().color(QPalette::Active,
					   QColorGroup::Mid));
  weekend_palette.setColor(QPalette::Inactive,QColorGroup::Background,
			   palette().color(QPalette::Active,
					   QColorGroup::Mid));
  for(int i=0;i<6;i++) {
    for(int j=0;j<5;j++) {
      pick_date_label[i][j]->clear();
      pick_date_label[i][j]->setPalette(palette());
    }
  }
  for(int i=0;i<6;i++) {
    for(int j=5;j<7;j++) {
      pick_date_label[i][j]->clear();
      pick_date_label[i][j]->setPalette(weekend_palette);
    }
  }

  //
  // Get Top of Month
  //
  if(pick_year_box!=NULL) {
    top_date=QDate(pick_low_year+pick_year_box->currentItem(),
		   pick_month_box->currentItem()+1,1);
  }
  else {
    top_date=QDate(pick_year_spin->value(),pick_month_box->currentItem()+1,1);
  }

  //
  // Print Days
  //
  int dow_offset=top_date.dayOfWeek()-1;
  for(int i=1;i<(top_date.daysInMonth()+1);i++) {
    PrintDay(i,dow_offset);
    if(pick_date.day()==i) {
      SelectDay(i,dow_offset,true);
    }
  }
}
Esempio n. 3
0
bool wxDatePickerCtrl::SendClickEvent()
{
    int16_t month = (int16_t)m_dt.GetMonth() + 1;
    int16_t day = m_dt.GetDay();
    int16_t year = m_dt.GetYear();

    if(!SelectDay(selectDayByDay,&month,&day,&year,_T("Pick date")))
        return false;
    wxDateTime dt(m_dt);
    dt.Set((wxDateTime::wxDateTime_t)day,
           (wxDateTime::Month)(month-1),
           (int)year);
    SetValue(dt);
    return true;
}
Esempio n. 4
0
static void
ExamDetailsGetDate(void)
{
  Char *title;
  Boolean clickedOK=false;
  Int16 year=gExamDetailsDate.year+MAC_SHIT_YEAR_CONSTANT, month=gExamDetailsDate.month, day=gExamDetailsDate.day;

  title = MemHandleLock(DmGetResource (strRsc, STRING_ed_title));
  clickedOK=SelectDay(selectDayByDay, &month, &day, &year, title);
  MemPtrUnlock(title);

  if (clickedOK) {
    gExamDetailsDate.year=year-MAC_SHIT_YEAR_CONSTANT;
    gExamDetailsDate.month=month;
    gExamDetailsDate.day=day;
    ExamDetailsSetTriggers(GetObjectPtr(SELECTOR_exd_date), GetObjectPtr(SELECTOR_exd_time));
  }

}
Esempio n. 5
0
/***********************************************************************
 *
 * FUNCTION:    RepeatSelectEndDate
 *
 * DESCRIPTION: This routine selects the end date of a repeating event.
 *
 * PARAMETERS:  event - pointer to a popup select event
 *
 * RETURNED:    nothing
 *
 ***********************************************************************/
static void RepeatSelectEndDate(EventType* event) {
  Int16 month, day, year;
  Char* titleP = NULL;
  MemHandle titleH = NULL;

  /* "No due date" items selected? */
  if (event->data.popSelect.selection == repeatNoEndDateItem)
    DateToInt(d.repeat_end_date) = apptNoEndDate;

  /* "Select date" item selected? */
  else if (event->data.popSelect.selection == repeatChooseDateItem) {
    if (DateToInt (d.repeat_end_date) == apptNoEndDate) {
      year = d.frm_date.year;
      month = d.frm_date.month;
      day = d.frm_date.day;
    } else {
      year = d.repeat_end_date.year + firstYear;
      month = d.repeat_end_date.month;
      day = d.repeat_end_date.day;
    }
    
    titleH = DmGetResource(strRsc, endDateTitleString);
    titleP = MemHandleLock(titleH);
    
    if (SelectDay (selectDayByDay, &month, &day, &year, titleP)) {
      d.repeat_end_date.day = day;
      d.repeat_end_date.month = month;
      d.repeat_end_date.year = year - firstYear;
      
      /* Make sure the end date is not before the start date. */
      if (DateToInt(d.repeat_end_date) < DateToInt (d.frm_date)) {
	SndPlaySystemSound (sndError);
	DateToInt (d.repeat_end_date) = apptNoEndDate;
      }
    }
    
    MemHandleUnlock(titleH);
  }

  RepeatSetDateTrigger(d.repeat_end_date);
}
void CXTPCalendarWeekView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	CSelectionChangedContext selChanged(this);

	TBase::OnKeyDown(nChar, nRepCnt, nFlags);

	if (nChar == VK_LEFT || nChar == VK_RIGHT || nChar == VK_UP || nChar == VK_DOWN ||
			nChar == VK_PRIOR || nChar == VK_NEXT)
	{
		CXTPCalendarControl::CUpdateContext updateContext(m_pControl, xtpCalendarUpdateRedraw);

		BOOL bVKShift = (GetKeyState(VK_SHIFT)  < 0);
		COleDateTimeSpan spDay(1, 0, 0, 0);
		COleDateTimeSpan spWeek(7, 0, 0, 0);

		int nDVCount = GetViewDayCount();
		BOOL bSelReseted = !m_selectedBlock.dtEnd.GetStatus() == COleDateTime::valid;

		COleDateTime dtLastSelDay = GetLastSelectedDate();
		int nLastSelDayIdx = (dtLastSelDay.GetDayOfWeek() - m_nFirstDayOfWeekIndex + 7) % 7;

		COleDateTime dtNewSelDay = dtLastSelDay;

		int nSatDayIdx = 7 - m_nFirstDayOfWeekIndex;
		int nNewIdx = nLastSelDayIdx + 3;
		int nHalfShift = nNewIdx > nSatDayIdx && nLastSelDayIdx <= nSatDayIdx ||
			nNewIdx > nSatDayIdx + 7 && nLastSelDayIdx <= nSatDayIdx + 7 ? 4 : 3;

		COleDateTimeSpan spHalfWeekPlus(nHalfShift, 0, 0, 0);
		COleDateTimeSpan spHalfWeekMinus(7 - nHalfShift, 0, 0, 0);

		CXTPDrawHelpers::KeyToLayout(m_pControl, nChar);

		if (nChar == VK_LEFT)
		{
			dtNewSelDay -= spHalfWeekMinus;
		}
		else if (nChar == VK_RIGHT)
		{
			dtNewSelDay += spHalfWeekPlus;
		}
		else if (nChar == VK_UP)
		{
			dtNewSelDay -= spDay;
		}
		else if (nChar == VK_DOWN)
		{
			dtNewSelDay += spDay;
		}
		else if (nChar == VK_PRIOR)
		{
			dtNewSelDay -= spWeek;
		}
		else if (nChar == VK_NEXT)
		{
			dtNewSelDay += spWeek;
		}
		//---------------------------------------------------------------------------
		COleDateTime dtFirstDay = GetViewDayDate(0);
		COleDateTime dtLastDay = GetViewDayDate(nDVCount-1);

		BOOL bNeedScroll = dtNewSelDay < dtFirstDay || dtNewSelDay > dtLastDay;
		if (bNeedScroll && !m_bScrollV_Disabled)
		{
			if (dtNewSelDay < dtFirstDay)
			{
				ScrollV(m_nCurrPos-1, m_nCurrPos-1);
				bSelReseted = TRUE;
				CXTPCalendarControl::CUpdateContext updateContext1(m_pControl, xtpCalendarUpdateScrollBar);
			}
			if (dtNewSelDay > dtLastDay)
			{
				ScrollV(m_nCurrPos + 1, m_nCurrPos + 1);
				bSelReseted = TRUE;
				CXTPCalendarControl::CUpdateContext updateContext1(m_pControl, xtpCalendarUpdateScrollBar);
			}
		}

		//---------------------------------------------------------------------------
		if (!bNeedScroll || !m_bScrollV_Disabled)
		{
			if (bVKShift && !bSelReseted)
			{
				SelectDays(dtNewSelDay);
			}
			else
			{
				SelectDay(dtNewSelDay);
			}
		}
	}
}
Esempio n. 7
0
// ¶Ô»°¿ò»Øµ÷º¯Êý
inline LRESULT CALLBACK CalendarProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case IDOK:
			{
				EndDialog(hDlg, TRUE);
				return TRUE;
			}
			break;
		case IDM_EATZAC:
			if (fMealMap[m_iDay-1]==M100 || fMealMap[m_iDay-1]==M101 || fMealMap[m_iDay-1]==M110 || fMealMap[m_iDay-1]==M111)
			{
				// <-Ôç²Í>
				fMealMap[m_iDay-1] -= M100;
				fTotalFee += M100;
			}
			else {
				// <+Ôç²Í>
				fMealMap[m_iDay-1] += M100;
				fTotalFee -= M100;
			}
			ShowMealData(hDlg);
			SaveMealMap();
			return TRUE;
			break;
		case IDM_EATWUC:
			if (fMealMap[m_iDay-1]==M010 || fMealMap[m_iDay-1]==M011 || fMealMap[m_iDay-1]==M110 || fMealMap[m_iDay-1]==M111)
			{
				// <-Îç²Í>
				fMealMap[m_iDay-1] -= M010;
				fTotalFee += M010;
			}
			else {
				// <+Îç²Í>
				fMealMap[m_iDay-1] += M010;
				fTotalFee -= M010;
			}
			ShowMealData(hDlg);
			SaveMealMap();
			return TRUE;
			break;
		case IDM_EATWAC:
			if (fMealMap[m_iDay-1]==M001 || fMealMap[m_iDay-1]==M101 || fMealMap[m_iDay-1]==M011 || fMealMap[m_iDay-1]==M111)
			{
				// <-Íí²Í>
				fMealMap[m_iDay-1] -= M001;
				fTotalFee += (M001-(float)0.1);
			}
			else {
				// <+Íí²Í>
				fMealMap[m_iDay-1] += M001;
				fTotalFee -= (M001-(float)0.1);

				//wchar_t szTmp[50] = { 0 };
				//char strTmp[50] = { 0 };
				//sprintf_s(strTmp, "fMealMap[m_iDay-1]: %.1f, fTotalFee: %.1f", fMealMap[m_iDay - 1], fTotalFee);
				//MultiByteToWideChar(CP_OEMCP, NULL, strTmp, 50, szTmp, 50);
				//MessageBox(NULL, szTmp, _T("OK"), MB_OK);
			}
			ShowMealData(hDlg);
			SaveMealMap();
			return TRUE;
			break;
		}
		return FALSE;
		break;
	case WM_RBUTTONDOWN:
	case WM_LBUTTONDOWN:
		{
			POINT pt;
			GetCursorPos(&pt);
			m_iDay = (WORD)SelectDay(hDlg, &pt);
			if (m_iDay == 0) {
				return TRUE;
			}
			PaintCalc(hDlg);
			if (uMsg == WM_RBUTTONDOWN) {
				CString menu1, menu2, menu3, menu4;
				if (fMealMap[m_iDay-1] == M000)
				{
					menu1.Format(_T("+Ôç²Í"));
					menu2.Format(_T("+Îç²Í"));
					menu3.Format(_T("+Íí²Í"));
					menu4.Format(_T("*δ³Ô"));
				}
				else if (fMealMap[m_iDay-1] == M110)
				{
					menu1.Format(_T("-Ôç²Í"));
					menu2.Format(_T("-Îç²Í"));
					menu3.Format(_T("+Íí²Í"));
					menu4.Format(_T("*ÔçÎç"));
				}
				else if (fMealMap[m_iDay-1] == M111)
				{
					menu1.Format(_T("-Ôç²Í"));
					menu2.Format(_T("-Îç²Í"));
					menu3.Format(_T("-Íí²Í"));
					menu4.Format(_T("*È«³Ô"));
				}
				else if (fMealMap[m_iDay-1] == M100)
				{
					menu1.Format(_T("-Ôç²Í"));
					menu2.Format(_T("+Îç²Í"));
					menu3.Format(_T("+Íí²Í"));
					menu4.Format(_T("*Ôç²Í"));
				}
				else if (fMealMap[m_iDay-1] == M010)
				{
					menu1.Format(_T("+Ôç²Í"));
					menu2.Format(_T("-Îç²Í"));
					menu3.Format(_T("+Íí²Í"));
					menu4.Format(_T("*Îç²Í"));
				}
				else if (fMealMap[m_iDay-1] == M001)
				{
					menu1.Format(_T("+Ôç²Í"));
					menu2.Format(_T("+Îç²Í"));
					menu3.Format(_T("-Íí²Í"));
					menu4.Format(_T("*Íí²Í"));
				}
				else if (fMealMap[m_iDay-1] == M101)
				{
					menu1.Format(_T("-Ôç²Í"));
					menu2.Format(_T("+Îç²Í"));
					menu3.Format(_T("-Íí²Í"));
					menu4.Format(_T("*ÔçÍí"));
				}
				else if (fMealMap[m_iDay-1] == M011)
				{
					menu1.Format(_T("+Ôç²Í"));
					menu2.Format(_T("-Îç²Í"));
					menu3.Format(_T("-Íí²Í"));
					menu4.Format(_T("*ÎçÍí"));
				}

				ClientToScreen(hDlg, &pt);
				HMENU hMenu = CreatePopupMenu();
				AppendMenu(hMenu, MF_STRING, IDM_EATZAC, menu1);
				AppendMenu(hMenu, MF_STRING, IDM_EATWUC, menu2);
				AppendMenu(hMenu, MF_STRING, IDM_EATWAC, menu3);
				AppendMenu(hMenu, MF_STRING|MF_DISABLED|MF_GRAYED, IDM_EATNOW, menu4);
				TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, pt.x, pt.y, NULL, hDlg, NULL);
			}
			return TRUE;
		}
		break;
	case WM_WINDOWPOSCHANGED:
		PostMessage(hDlg, WM_SHOWCAL, 0, 0);
		return TRUE;
		break;
	case WM_SHOWCAL:
		PaintCalc(hDlg);
		ShowMealData(hDlg);
		return TRUE;
		break;
	case WM_CLOSE:
		DestroyWindow(hDlg);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	}

	return FALSE;
}