📄 nxschedule.cxx
字号:
_FillDefaults(n, pThis->m_CurrentDay); if (n) { NxApp::Instance()->show_window(detailsWindow->GetWindowPtr(), DEACTIVATE, dayWindow->GetWindowPtr()); pThis->set_date_picker(m_pCalendar); g_EditFlag = CHANGED_NEW; pThis->detailsDeleteButton->deactivate(); pThis->FillDetailForm(n, DESC_NEW); }}voidNxSchedule::mainDatePicked_callback(Fl_Widget * w, void *l){ NxSchedule *pThis = (NxSchedule *) l; pThis->dateWindow->GetWindowPtr()->hide(); pThis->show_window(dayWindow->GetWindowPtr()); if (pCalendar->GetPickedDate()) { pThis->m_CurrentDay = pCalendar->GetPickedDate(); pThis->pCalendar->SetPickedDate(pThis->m_CurrentDay); pThis->UpdateDateDisplay(); }}voidNxSchedule::goto_callback(Fl_Widget * w, void *l){ NxSchedule *pThis = (NxSchedule *) l; pThis->set_date_picker(m_pCalendar); pCalendar->SetPickedDate(pThis->m_CurrentDay); NxApp::Instance()->show_window(dateWindow->GetWindowPtr(), DEACTIVATE, dayWindow->GetWindowPtr()); pCalendar->DateCallback(mainDatePicked_callback);}// Advance the currnet day by a weekvoidNxSchedule::adv_week_callback(Fl_Widget * w, void *l){ NxSchedule *pThis = (NxSchedule *) l; pThis->m_CurrentDay += (86400 * 7); pThis->UpdateDateDisplay();}// Move the current day back by a weekvoidNxSchedule::bak_week_callback(Fl_Widget * w, void *l){ NxSchedule *pThis = (NxSchedule *) l; pThis->m_CurrentDay -= (86400 * 7); pThis->UpdateDateDisplay();}// Callback for the day buttons at the top (not the week arrows)voidNxSchedule::new_day_callback(Fl_Widget * w, void *l){ NxSchedule *pThis = (NxSchedule *) l; int nDOW = -1; // Find which button made the callback. nDOW will become the // day of the week that was selected. for (int i = 0; i < 7; i++) if (pThis->m_DayButtons[i] == w) { nDOW = i; break; } // Just checking... if (nDOW == -1) return; tm *tt = localtime(&pThis->m_CurrentDay); // Calculate the new current day; subtract the old // "current day" day of week from the new day of week, // multiply by 86400, add it to the current day, // and bob's your uncle. pThis->m_CurrentDay += (86400 * (nDOW - tt->tm_wday)); pThis->UpdateDateDisplay();}voidNxSchedule::MakeDayWindow(){ dayWindow = new NxPimWindow(APP_NAME, schedMenuItems, 0, "", SCHEDULE, 0); add_window((Fl_Window *) dayWindow->GetWindowPtr()); { NxButton *o = new NxButton(W_W - 3 - (9 * DAY_S), 7, DAY_S, DAY_S, "@<"); o->movable(false); o->labeltype(FL_SYMBOL_LABEL); o->callback(bak_week_callback, this); o->box(FL_FLAT_BOX); dayWindow->add((Fl_Widget *) o); o = new NxButton(W_W - 3 - (DAY_S), 7, DAY_S, DAY_S, "@>"); o->movable(false); o->labeltype(FL_SYMBOL_LABEL); o->callback(adv_week_callback, this); o->box(FL_FLAT_BOX); dayWindow->add((Fl_Widget *) o); char *_d[] = { "S", "M", "T", "W", "T", "F", "S" }; for (int i = 7; i > 0; i--) { NxButton *o = new NxButton(W_W - 3 - ((i + 1) * DAY_S), 7, DAY_S, DAY_S, _d[7 - i]); o->movable(false); o->box(FL_FLAT_BOX); m_DayButtons[7 - i] = o; o->callback(new_day_callback, this); o->align(FL_ALIGN_CENTER); dayWindow->add((Fl_Widget *) o); } } { NxBox *o = new NxBox(-1, 30, W_W + 2, BUTTON_Y - 32); o->movable(false); o->box(FL_BORDER_BOX); o->color(NxApp::Instance()->getGlobalColor(APP_BG)); dayWindow->add((Fl_Widget *) o); { table = new Flv_Table_Child(0, 31, W_W, BUTTON_Y - 40, 0, 25, 76); table->movable(false); table->SetCols(COLS); table->callback(view_callback, this); dayWindow->add((Fl_Widget *) table); } } { NxBox *o = new NxBox(5, 5, 85, 25, ""); o->color(NxApp::Instance()->getGlobalColor(APP_BG)); o->labelfont(1); dayWindow->add((Fl_Widget *) o); } { NxButton *o = new NxButton(BUTTON_X, BUTTON_Y, BUTTON_WIDTH - 5, BUTTON_HEIGHT, "New"); o->callback(new_callback, this); dayWindow->add((Fl_Widget *) o); } { NxButton *o = new NxButton(BUTTON_X + 58, BUTTON_Y, BUTTON_WIDTH - 5, BUTTON_HEIGHT, "Details"); o->callback(details_callback, this); dayWindow->add((Fl_Widget *) o); } { NxButton *o = new NxButton(BUTTON_X + 116, BUTTON_Y, BUTTON_WIDTH - 5, BUTTON_HEIGHT, "Goto"); o->callback(goto_callback, this); dayWindow->add((Fl_Widget *) o); } { GroupButton *o = new GroupButton(BUTTON_X + 180, BUTTON_Y, 10, BUTTON_HEIGHT, type_daily); o->callback(dailyView_callback, this); dayWindow->add((Fl_Widget *) o); } { GroupButton *o = new GroupButton(BUTTON_X + 193, BUTTON_Y, 10, BUTTON_HEIGHT, type_weekly); o->callback(weeklyView_callback, this); dayWindow->add((Fl_Widget *) o); } { GroupButton *o = new GroupButton(BUTTON_X + 206, BUTTON_Y, 10, BUTTON_HEIGHT, type_monthly); o->callback(monthlyView_callback, this); dayWindow->add((Fl_Widget *) o); } { GroupButton *o = new GroupButton(BUTTON_X + 219, BUTTON_Y, 10, BUTTON_HEIGHT, type_yearly); o->callback(yearlyView_callback, this); dayWindow->add((Fl_Widget *) o); } dayWindow->GetWindowPtr()->end(); //UpdateDateDisplay();}voidNxSchedule::MakeSetTimeWindow(){ setTimeWindow = new NxPimWindow(APP_NAME, schedMenuItems, db, CATEGORY, SCHEDULE, (void (*)(const char *)) 0); add_window((Fl_Window *) setTimeWindow->GetWindowPtr()); { NxScroll *hourScroll = new NxScroll(0, 31, W_W, BUTTON_Y - 38); setTimeWindow->add((Fl_Widget *) hourScroll); } { NxButton *o = new NxButton(4, 90, BUTTON_WIDTH, BUTTON_HEIGHT, "Ok"); // o->callback(doneDetails_callback); setTimeWindow->add((Fl_Widget *) o); } { NxButton *o = new NxButton(64, 90, BUTTON_WIDTH, BUTTON_HEIGHT, "Cancel"); o->box(FL_SHADOW_BOX); // o->callback(cancelDetails_callback); setTimeWindow->add((Fl_Widget *) o); } setTimeWindow->GetWindowPtr()->end();}voidNxSchedule::yesDelEdit_callback(Fl_Widget * w, void *l){ NxSchedule *pThis = (NxSchedule *) l;#ifdef DO_ALARM // delete the alarm for this record pThis->DeleteAlarm(pThis->m_pCurrentItem);#endif delete_note(pThis->m_pCurrentItem); pThis->show_window(dayWindow->GetWindowPtr()); pThis->UpdateDateDisplay();}voidNxSchedule::noDelEdit_callback(Fl_Widget * w, void *l){ NxSchedule *pThis = (NxSchedule *) l; pThis->show_window(detailsWindow->GetWindowPtr()); // this is needed in order for the day window widgets not to be hidden dayWindow->GetWindowPtr()->show(); detailsWindow->GetWindowPtr()->show();}voidNxSchedule::MakeDeleteWindow(){ deleteWindow = new NxPimPopWindow("Delete"); add_window((Fl_Window *) deleteWindow->GetWindowPtr()); { NxBox *o = new NxBox(BUTTON_X, 43, W_W - BUTTON_X - 15, 0, "Delete current event ?"); o->box(FL_FLAT_BOX); o->align(FL_ALIGN_WRAP | FL_ALIGN_TOP | FL_ALIGN_LEFT); NxApp::Instance()->def_font((Fl_Widget *) o); deleteWindow->add((Fl_Widget *) o); } { NxButton *o = new NxButton(BUTTON_X, 90, BUTTON_WIDTH, BUTTON_HEIGHT, "Yes"); o->callback(yesDelEdit_callback, this); deleteWindow->add((Fl_Widget *) o); } { NxButton *o = new NxButton(BUTTON_X + 61, 90, BUTTON_WIDTH, BUTTON_HEIGHT, "No"); o->callback(noDelEdit_callback, this); deleteWindow->add((Fl_Widget *) o); } deleteWindow->GetWindowPtr()->end();}voidNxSchedule::MakeLookupWindow(){ static char fromBuf[30]; static char toBuf[30]; toTime = fromTime = time(0); tm *tt = localtime(&fromTime); //strftime(fromBuf, 29,"%b %d, %y", tt); GetDateString(fromBuf, tt, sizeof(fromBuf), SHORT_YEAR); //strftime(toBuf, 29,"%b %d, %y", tt); GetDateString(toBuf, tt, sizeof(toBuf), SHORT_YEAR); lookupWindow = new NxPimWindow(W_X, W_Y, W_W, W_H); add_window((Fl_Window *) lookupWindow->GetWindowPtr()); { NxCheckButton *o = stringCheck = new NxCheckButton(BUTTON_X, 35, "Only entries containing:"); o->movable(false); lookupWindow->add((Fl_Widget *) o); } { NxInput *o = lookup_input = new NxInput(BUTTON_X + 19, 60, 141, 20); o->movable(false); lookup_input->maximum_size(99); lookupWindow->add((Fl_Widget *) o); } { NxCheckButton *o = dateCheck = new NxCheckButton(BUTTON_X, 85, "Limit by date range:"); o->movable(false); lookupWindow->add((Fl_Widget *) o); } { NxOutput *o = new NxOutput(BUTTON_X + 19, 110, 60, BUTTON_HEIGHT); o->value("From:"); o->movable(false); lookupWindow->add((Fl_Widget *) o); } { NxButton *o = fromDateButton = new NxButton(BUTTON_X + 60, 110, 100, BUTTON_HEIGHT); o->movable(false); o->label(fromBuf); o->callback(fromCalendar_callback, this); o->redraw(); lookupWindow->add((Fl_Widget *) o); } { NxOutput *o = new NxOutput(BUTTON_X + 19, 135, 60, BUTTON_HEIGHT); o->value("To:"); o->movable(false); lookupWindow->add((Fl_Widget *) o); } { NxButton *o = toDateButton = new NxButton(BUTTON_X + 60, 135, 100, BUTTON_HEIGHT); o->label(toBuf); o->movable(false); o->redraw(); o->callback(toCalendar_callback, this); lookupWindow->add((Fl_Widget *) o); } { NxButton *o = new NxButton(BUTTON_X, BUTTON_Y, BUTTON_WIDTH, BUTTON_HEIGHT, "Search"); o->callback(searchLookup_callback, this); lookupWindow->add((Fl_Widget *) o); } { NxButton *o = new NxButton(BUTTON_X + 61, BUTTON_Y, BUTTON_WIDTH, BUTTON_HEIGHT, "Cancel"); o->callback(cancelLookup_callback); lookupWindow->add((Fl_Widget *) o); }}voidNxSchedule::fromDate_callback(Fl_Widget * fl, void *l){ NxSchedule *pThis = (NxSchedule *) l; pThis->dateWindow->GetWindowPtr()->hide(); pThis->show_window(lookupWindow->GetWindowPtr()); if (pCalendar->GetPickedDate()) { pThis->fromTime = pCalendar->GetPickedDate(); pThis->UpdateFromButton(); }}voidNxSchedule::toDate_callback(Fl_Widget * fl, void *l){ NxSchedule *pThis = (NxSchedule *) l; pThis->dateWindow->GetWindowPtr()->hide(); pThis->show_window(lookupWindow->GetWindowPtr()); if (pCalendar->GetPickedDate()) { pThis->toTime = pCalendar->GetPickedDate(); pThis->UpdateToButton(); }}voidNxSchedule::fromCalendar_callback(Fl_Widget * fl, void *l){ NxSchedule *pThis = (NxSchedule *) l; pThis->set_date_picker(m_pCalendar); pCalendar->SetPickedDate(pThis->fromTime); NxApp::Instance()->show_window(dateWindow->GetWindowPtr(), DEACTIVATE, lookupWindow->GetWindowPtr()); pCalendar->DateCallback(fromDate_callback);}voidNxSchedule::toCalendar_callback(Fl_Widget * fl, void *l){ NxSchedule *pThis = (NxSchedule *) l; pThis->set_date_picker(m_pCalendar); pCalendar->SetPickedDate(pThis->fromTime); NxApp::Instance()->show_window(dateWindow->GetWindowPtr(), DEACTIVATE, lookupWindow->GetWindowPtr()); pCalendar->DateCallback(toDate_callback);}char *NxSchedule::formatString(const NxTodo * note, int pixels){ int width = 0; int dot_width = 0; int idx = 0; unsigned int jdx = 0; int date_len = 0; static char temp_date[33]; static char date[33]; char temp_title[DESC + 3]; char title[DESC + 3]; char *new_string = new char[DESC + 33]; char temp_string[DESC + 33]; tm *tt = localtime(¬e->startTime); NxSchedule *pThis = (NxSchedule *) (NxApp::Instance()); fl_font(DEFAULT_TEXT_FONT, DEFAULT_TEXT_SIZE); dot_width = (int) fl_width("..."); memset(temp_title, 0, sizeof(temp_title)); memset(title, 0, sizeof(title)); memset(new_string, 0, DESC + 33); strcpy(temp_title, note->szDescription); for (jdx = 0; jdx <= strlen(temp_title); jdx++) { if ('\n' == temp_title[jdx]) temp_title[jdx] = ' '; } // format description to fit half of width idx = 0; strcpy(title, temp_title); width = (int) fl_width(title); if (width >= (pixels / 2)) { while (width > (pixels / 2)) { idx++; memset(title, 0, sizeof(title)); strncpy(title, temp_title, strlen(temp_title) - idx); width = (int) fl_width(title) + dot_width; } sprintf(title, "%s...", title); } else { while (width < (pixels / 2)) { if (strlen(title) >= DESC + 3) break; sprintf(title, "%s ", title); width = (int) fl_width(title); } } //strftime(date,29,"%b %d, %y",tt); pThis->GetDateString(date, tt, sizeof(date), SHORT_YEAR); date_len = strlen(date); memset(temp_date, 0, sizeof(temp_date)); width = (int) fl_width(date); if (width >= (pixels / 2)) { sprintf(temp_date, "%*.*s", 30, date_len, date); strcpy(date, temp_date); } //strftime(temp_date,29,"%b %d, %y",tt); pThis->GetDateString(temp_date, tt, sizeof(temp_date), SHORT_YEAR); // format date to fit half ot the input left justified idx = 0; jdx = 0; width = (int) fl_width(date); while (width >= (pixels / 2)) { if (isspace(date[0])) { idx++; memmove(date, date + 1, sizeof(date) - idx); width = (int) fl_width(date); } else { jdx++; memset(date, 0, sizeof(date)); strncpy(date, temp_date, strlen(temp_date) - jdx); width = (int) fl_width(date) + dot_width; } } if (0 != jdx) sprintf(date, "%s...", date); sprintf(new_string, "%s%s", title, date); // now align the second string to middle pixel char *pStr = strstr(new_string, date); int len = strlen(new_string) - strlen(pStr); memset(temp_string, 0, sizeof(temp_string)); strncpy(temp_string, new_string, len); width = (int) fl_width(temp_string); while (width <= (pixels / 2 - 1)) { sprintf(temp_string, "%s ", temp_string); width = (int) fl_width(temp_string); } sprintf(new_string, "%s%s", temp_string, date); return (char *) new_string;}NxTodo *NxSchedule::searchString(const char *searchVal){ static int cur_record = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -