void dialCalendar::MessageReceived(BMessage *Message) { switch (Message->what) { case BUT_PREVY: year--; RefreshCalendar(); break; case BUT_PREVM: month--; if (month==0) { month = 12; year--; } RefreshCalendar(); break; case BUT_NEXTM: month++; if (month==13) { month = 1; year++; } RefreshCalendar(); break; case BUT_NEXTY: year++; RefreshCalendar(); break; case BUT_CAL: { int32 x,y; if (Message->FindInt32("_x", &x) == B_OK) { if (Message->FindInt32("_y", &y) == B_OK) { day = caldaytab[x][y]; RefreshCalendar(); } } break; } case BUT_OK: { // set new value dateField->Looper()->Lock(); dateField->SetText(makeDateString()); dateField->Looper()->Unlock(); // notify owner handler->Looper()->PostMessage(new BMessage(msgdc)); Quit(); break; } default: BWindow::MessageReceived(Message); break; } }
void COCalendar::OnBnClickedButtonNewr() { COleDateTime dt=COleDateTime::GetCurrentTime(); COleDateTime dtTmp=m_WMCtrl.GetLastClicked(); if(dtTmp.GetStatus()==COleDateTime::valid){ dt.SetDateTime(dtTmp.GetYear(),dtTmp.GetMonth(),dtTmp.GetDay(),dt.GetHour(),dt.GetMinute(),dt.GetSecond()); } CreateNewReminder(dt,pCallback,this); RefreshCalendar(); }
dialCalendar::dialCalendar(const char *inidate, BTextControl *ptr, int32 msg, BHandler *hr) : BWindow( BRect(100+20, 100+20, 295+20, 320+20+25), NULL, B_TITLED_WINDOW, B_NOT_RESIZABLE ) { msgdc = msg; dateField = ptr; handler = hr; // split inidate into y/m/d BString tmp; tmp = inidate; tmp.Remove(4,tmp.Length()-4); year = toint(tmp.String()); tmp = inidate; tmp.Remove(0,5); tmp.Remove(2,tmp.Length()-2); month = toint(tmp.String()); tmp = inidate; tmp.Remove(0,8); day = toint(tmp.String()); this->SetTitle("Wybierz datę"); this->SetFeel(B_FLOATING_APP_WINDOW_FEEL); view = new BView(this->Bounds(), "calendarView", B_FOLLOW_ALL_SIDES, 0); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); this->AddChild(view); view->AddChild(monthyear = new BStringView(BRect(60,5,135,25), "calendarMonthYear", NULL)); monthyear->SetAlignment(B_ALIGN_CENTER); view->AddChild(but_prevy = new BButton(BRect(10,5,30,25), "calendarButPrevy", "<<", new BMessage(BUT_PREVY))); view->AddChild(but_prevm = new BButton(BRect(35,5,55,25), "calendarButPrevm", "<", new BMessage(BUT_PREVM))); view->AddChild(but_nextm = new BButton(BRect(140,5,160,25), "calendarButNextm", ">", new BMessage(BUT_NEXTM))); view->AddChild(but_nexty = new BButton(BRect(165,5,185,25), "calendarButNexty", ">>", new BMessage(BUT_NEXTY))); int i,j; for (i=0;i<=6;i++) { view->AddChild(new BStringView(BRect(10+i*25,30,30+i*25,50), NULL, shortweekdays[i])); } BMessage *msg; for (j=0;j<=5;j++) { for (i=0;i<=6;i++) { msg = new BMessage(BUT_CAL); msg->AddInt32("_x", i); msg->AddInt32("_y", j); view->AddChild(caltab[i][j] = new BButton(BRect(10+i*25,55+j*25,30+i*25,75+j*25), NULL, "33", msg)); } } view->AddChild(but_ok = new BButton(BRect(120,210,165,230), "calendarButOk", "OK", new BMessage(BUT_OK))); but_ok->MakeDefault(true); but_ok->ResizeToPreferred(); RefreshCalendar(); }
void COCalendar::OnCellRClick(NMHDR *pNotifyStruct, LRESULT* pResult) { CCriticalSectionGuard l(&cs); NM_WVCELLDATA *pData = (NM_WVCELLDATA *)pNotifyStruct; int iIndex=-1; if(pData && pData->pItem){ iIndex=pData->pItem->GetItemData(); } if(pData->pCell){ COleDateTime dtTmp=pData->pCell->GetCellDate(); CallContextOnDate(dtTmp); } RefreshCalendar(); }
void COCalendar::OnCellDblClick(NMHDR *pNotifyStruct, LRESULT* pResult) { CCriticalSectionGuard l(&cs); NM_WVCELLDATA *pData = (NM_WVCELLDATA *)pNotifyStruct; int iIndex=-1; if(pData && pData->pItem){ iIndex=pData->pItem->GetItemData(); } if(iIndex>=0 && iIndex<aReminders.GetSize()){ CallModifyReminderX(aReminders[iIndex].szKey,this,0); }else{ if(pData->pCell){ COleDateTime dtTmp=pData->pCell->GetCellDate(); CallDialogOnDate(dtTmp); } } RefreshCalendar(); }
void COCalendar::WalkDays(int i) { COleDateTime dt=m_WMCtrl.GetLastClicked(); if(i>0){ dt+=COleDateTimeSpan(i,0,0,0); }else{ dt-=COleDateTimeSpan(-i,0,0,0); } COleDateTime dt1; COleDateTime dt2; m_WMCtrl.GetDateRange(&dt1,&dt2); if(m_WMCtrl.GetCellByDate(dt) && dt>=dt1 && dt<=dt2){ m_WMCtrl.HightlightCellByDate(dt); }else{ m_WMCtrl.SetCurrentDate(dt, FALSE, bMonView?WV_MONTHVIEW:WV_WEEKVIEW); m_WMCtrl.HightlightCellByDate(dt); RefreshCalendar(); } }
BOOL COCalendar::OnInitDialog() { CResizeableDialog::OnInitDialog(); ModifyStyleEx(0,WS_EX_COMPOSITED,SWP_FRAMECHANGED); RegisterControl(IDC_CALCTRL, ATTACH_TO_HORIZONTAL_EDGES | ATTACH_TO_VERTICAL_EDGES); RegisterControl(IDC_BUTTON_VIEW, ATTACH_TO_BOTTOM_EDGE | ATTACH_TO_LEFT_EDGE); RegisterControl(IDC_BUTTON_NEWR, ATTACH_TO_BOTTOM_EDGE | ATTACH_TO_LEFT_EDGE); RegisterControl(IDC_BUTTON_CLOSE, ATTACH_TO_BOTTOM_EDGE | ATTACH_TO_RIGHT_EDGE); RegisterControl(IDC_BUTTON_PREV, ATTACH_TO_BOTTOM_EDGE | ATTACH_TO_LEFT_EDGE); RegisterControl(IDC_BUTTON_NEXT, ATTACH_TO_BOTTOM_EDGE | ATTACH_TO_LEFT_EDGE); COleDateTime dtS = COleDateTime::GetCurrentTime(); // Display Calendar in Month View il.Create(16,16,ILC_COLOR32 | ILC_MASK,0,1); il.Add(AfxGetApp()->LoadIcon(IDI_ICON2)); m_WMCtrl.SetImageList(&il); m_WMCtrl.SetCurrentDate(dtS, FALSE, bMonView?WV_MONTHVIEW:WV_WEEKVIEW); HICON m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON1); SetIcon(m_hIcon, TRUE); SetIcon(m_hIcon, FALSE); SetWindowText(_lx("RMX.UI.CALENDAR","Calendar")); GetDlgItem(IDC_BUTTON_VIEW)->SetWindowText(_lx("RMX.UI.CALENDAR.VIEW","Change view")); GetDlgItem(IDC_BUTTON_NEWR)->SetWindowText(_lx("RMX.UI.CALENDAR.NEW","New reminder")); GetDlgItem(IDC_BUTTON_CLOSE)->SetWindowText(_lx("RMX.UI.CALENDAR.CLOSE","Close")); m_tooltip.Create(this); m_tooltip.Activate(TRUE); m_tooltip.AddTool(GetDlgItem(IDC_CALCTRL), _lx("RMX.UI.CALENDAR","Calendar")); m_tooltip.AddTool(GetDlgItem(IDC_BUTTON_VIEW), _lx("RMX.UI.CALENDAR.VIEW","Change view")); m_tooltip.AddTool(GetDlgItem(IDC_BUTTON_NEWR), _lx("RMX.UI.CALENDAR.NEW","New reminder")); m_tooltip.AddTool(GetDlgItem(IDC_BUTTON_CLOSE), _lx("RMX.UI.CALENDAR.CLOSE","Close")); CRect rtThis; GetWindowRect(&rtThis); int iW=int(rtThis.Width()*0.7); if(iW<250){ iW=250; } m_tooltip.SetMaxTipWidth(iW); RefreshCalendar(); return FALSE; }
BOOL COCalendar::PreTranslateMessage(MSG* pMsg) { // CG: The following block was added by the ToolTips component. { // Let the ToolTip process this message. m_tooltip.RelayEvent(pMsg); } if(pMsg->message==WM_MOUSEWHEEL){ if((pMsg->wParam)&0x80000000){ OnBnClickedButtonNext(); }else{ OnBnClickedButtonPrev(); } return 0; } if(pMsg->message==WM_MOUSEMOVE){ CPoint pt; GetCursorPos(&pt); GetDlgItem(IDC_CALCTRL)->ScreenToClient(&pt); CWVCellData* pCell=m_WMCtrl.HitTest(pt); if(pCell){ CString sText=DateFormat(pCell->GetCellDate(),0); sText+="\n"; sText+=m_WMCtrl.GetCellDsk(pCell); sText.Replace("\n","\r\n"); sText.TrimRight(); sText.TrimLeft(); m_tooltip.UpdateTipText(sText,GetDlgItem(IDC_CALCTRL)); } } if(pMsg->message==WM_KEYDOWN){ if(pMsg->wParam==33){//p up OnBnClickedButtonPrev(); return TRUE; } if(pMsg->wParam==34){//p down OnBnClickedButtonNext(); return TRUE; } if(pMsg->wParam==VK_UP){ if(bMonView){ WalkDays(-7); }else{ WalkDays(-1); } return TRUE; } if(pMsg->wParam==VK_DOWN){ if(bMonView){ WalkDays(7); }else{ WalkDays(1); } return TRUE; } if(pMsg->wParam==VK_RIGHT){ WalkDays(1); return TRUE; } if(pMsg->wParam==VK_LEFT){ WalkDays(-1); return TRUE; } if(pMsg->wParam==VK_SPACE){ OnBnClickedButtonView(); return TRUE; } if(pMsg->wParam==VK_RETURN){ CallDialogOnDate(m_WMCtrl.GetLastClicked()); RefreshCalendar(); return TRUE; } } return CResizeableDialog::PreTranslateMessage(pMsg); }