static void day_btn_cb(Widget w, XtPointer client, XtPointer call) { XmMonthPanelCallbackStruct *cbs = (XmMonthPanelCallbackStruct *) call; Calendar *c = (Calendar *)client; int monthno, year; int date = c->view->date; invalidate_cache(c); XtVaGetValues(w, XmNmonth, &monthno, XmNyear, &year, NULL); if (cbs->type == MONTH_SELECTION) { XtUnmapWidget(c->canvas); /* * Date update: * if month chosen is not current month * set date to 1st of new month, otherwise * don't change date. */ if (month(c->view->date) != monthno) { calendar_deselect (c); c->view->olddate = c->view->date; c->view->date = monthdayyear(monthno, 1, year); c->view->nwks = numwks(c->view->date); calendar_select (c, monthSelect, NULL); } /* switch to month view */ c->view->glance = monthGlance; cleanup_after_dayview(c); prepare_to_paint_monthview(c, NULL); XtMapWidget(c->canvas); } else { /* type == DAY_SELECTION */ c->view->olddate = c->view->date; c->view->date = monthdayyear(monthno, cbs->day, year); gr_clear_area(c->xcontext, 0, 0, c->view->winw, c->view->winh); paint_dayview(c, True, NULL, False); calendar_select(c, hourSelect, (caddr_t)NULL); } }
extern void day_event(XEvent *event) { static int lastcol, lastrow; static XEvent lastevent; pr_pos xy; int x, y, i, j; int boxw, boxh, margin, id; Calendar *c = calendar; Tick date = c->view->date; Boolean in_mbox = False; /* in month boxes ? */ Editor *e = (Editor*)c->editor; ToDo *t = (ToDo*)c->todo; GEditor *ge = (GEditor*)c->geditor; Day *day_info = (Day *)c->view->day_info; boxw = c->view->boxw; boxh = c->view->boxh; margin = c->view->outside_margin; x = event->xbutton.x; y = event->xbutton.y; /* boundary conditions */ if ((!(in_mbox = in_moboxes(c, x, y)) && x < MOBOX_AREA_WIDTH+2) || (x > MOBOX_AREA_WIDTH+2 && y < c->view->topoffset)) { lastcol=0; lastrow=0; return; } if (in_mbox) { xy.x = (x - margin)/ day_info->col_w; xy.y = (x - c->view->topoffset)/ day_info->row_h; } else { xy.x = boxw; xy.y = (y - c->view->topoffset)/boxh; } switch(event->type) { case MotionNotify: if (!in_mbox) { if (xy.x !=lastcol || xy.y !=lastrow) { calendar_deselect(c); j = day_xytoclock(c, xy.x, xy.y, date); if (j >= 0) { c->view->olddate = c->view->date; c->view->date = j; calendar_select(c, hourSelect, (caddr_t)&xy); } lastcol=xy.x; lastrow=xy.y; } } break; case ButtonPress: if (ds_is_double_click(&lastevent, event)) { _DtTurnOnHourGlass(c->frame); j = day_xytoclock(c, xy.x, xy.y, date); if (lastcol == xy.x && lastrow == xy.y) show_editor(c, j, next_nhours(j, 1), xy.y == 0 ? True : False); if (in_mbox) { monthbox_deselect(c); monthbox_xytodate(c, x, y); monthbox_select(c); } else show_editor(c, j, next_nhours(j, 1), xy.y == 0 ? True : False); _DtTurnOffHourGlass(c->frame); } else { if (in_mbox) { monthbox_deselect(c); monthbox_xytodate(c, x, y); paint_dayview(c, False, NULL, True); calendar_select(c, hourSelect, (caddr_t)NULL); monthbox_select(c); j = day_xytoclock(c, xy.x, xy.y, date); if (editor_showing(e)) { set_editor_defaults(e, j, next_nhours(j, 1), False); add_all_appt(e); } if (todo_showing(t)) { set_todo_defaults(t); add_all_todo(t); } if (geditor_showing(ge)) { set_geditor_defaults(ge, j, next_nhours(j, 1)); add_all_gappt(ge); } } else { calendar_deselect(c); j = day_xytoclock(c, xy.x, xy.y, date); if (j >= 0) { c->view->olddate = c->view->date; c->view->date = j; calendar_select(c, hourSelect, (caddr_t)&xy); if (editor_showing(e)) { set_editor_defaults(e, j, next_nhours(j, 1), xy.y == 0 ? True : False); add_all_appt(e); } if (todo_showing(t)) { set_todo_defaults(t); add_all_todo(t); } if (geditor_showing(ge)) { set_geditor_defaults(ge, j, next_nhours(j, 1)); add_all_gappt(ge); } } } } lastcol=xy.x; lastrow=xy.y; break; default: break; }; /* switch */ lastevent = *event; }
extern void week_event(XEvent *event) { Calendar *c = calendar; Props *p = (Props*)c->properties; static int lastdate; static XEvent lastevent; int x, y, i, j, hr, id; Week *w = (Week *)c->view->week_info; Selection *wsel; Editor *e = (Editor *)c->editor; ToDo *t = (ToDo*)c->todo; GEditor *ge = (GEditor*)c->geditor; static int lastrow, lastcol; int row, col; x = event->xbutton.x; y = event->xbutton.y; wsel = (Selection *)w->current_selection; switch(event->type) { case MotionNotify: j = week_xytoclock(w, x, y); (col = dow(j)) == 0 ? col = 6 : col--; if (inchart(w, x, y)) row = (double)(y - w->chart_y) / (double)(w->chart_hour_height+ w->add_pixels); else row = wsel->row; if (j != lastdate || lastcol != col || lastrow != row) { calendar_deselect(c); wsel->row = row; wsel->col = col; if (j > 0) { c->view->olddate = c->view->date; c->view->date = j; calendar_select(c, weekdaySelect, NULL); } } lastcol = wsel->col; lastrow = wsel->row; lastdate = c->view->date; break; case ButtonPress: j = week_xytoclock(w, x, y); if (j == -1) return; hr = (inchart(w, x, y)) ? week_xytohour(w, x, y) : (wsel->row + w->begin_hour); if (ds_is_double_click(&lastevent, event)) { _DtTurnOnHourGlass(c->frame); if (j == lastdate) { show_editor(c, next_nhours(j, hr), next_nhours(j, hr + 1), False); } else if (editor_showing(e)) { set_editor_defaults(e, next_nhours(j, hr), next_nhours(j, hr + 1), False); add_all_appt(e); } _DtTurnOffHourGlass(c->frame); } else { calendar_deselect(c); (wsel->col = dow(j)) == 0 ? wsel->col = 6 : wsel->col--; if (inchart(w, x, y)) wsel->row = (double)(y - w->chart_y) / (double)(w->chart_hour_height + w->add_pixels); if (j > 0) { c->view->olddate = c->view->date; c->view->date = j; calendar_select(c, weekdaySelect, NULL); } if (editor_showing(e)) { set_editor_defaults(e, next_nhours(j, hr), next_nhours(j, hr + 1), False); add_all_appt(e); } if (todo_showing(t)) { set_todo_defaults(t); add_all_todo(t); } if (geditor_showing(ge)) { set_geditor_defaults(ge, 0, 0); add_all_gappt(ge); } } lastdate = c->view->date; lastcol = wsel->col; lastrow = wsel->row; break; default: break; }; /* switch */ lastevent = *event; }