⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nxrepeat.cxx

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CXX
📖 第 1 页 / 共 2 页
字号:
/*                                                                        * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.      *                                                                        * This file is part of the PIXIL Operating Environment                  *                                                                        * The use, copying and distribution of this file is governed by one     * of two licenses, the PIXIL Commercial License, or the GNU General     * Public License, version 2.                                            *                                                                        * Licensees holding a valid PIXIL Commercial License may use this file  * in accordance with the PIXIL Commercial License Agreement provided    * with the Software. Others are governed under the terms of the GNU    * General Public License version 2.                                     *                                                                        * This file may be distributed and/or modified under the terms of the   * GNU General Public License version 2 as published by the Free         * Software Foundation and appearing in the file LICENSE.GPL included    * in the packaging of this file.                                       *                                                                        * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING   * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A             * PARTICULAR PURPOSE.                                                   *                                                                        * RESTRICTED RIGHTS LEGEND                                              *                                                                      * Use, duplication, or disclosure by the government is subject to       * restriction as set forth in paragraph (b)(3)(b) of the Rights in      * Technical Data and Computer Software clause in DAR 7-104.9(a).        *                                                                       * See http://www.pixil.org/gpl/ for GPL licensing        * information.                                                          *                                                                       * See http://www.pixil.org/license.html or               * email cetsales@centurysoftware.com for information about the PIXIL    * Commercial License Agreement, or if any conditions of this licensing  * are not clear to you.                                                 */#include <stdio.h>#include "nxschedule.h"Fl_Menu_Item repeatMenuItems[] = {    {"No End Date", 0, NxSchedule::noDate_callback}    ,    {"Choose Date...", 0, NxSchedule::chooseDate_callback}    ,    {0}};voidNxSchedule::MakeRepeatWindow(){    //repeatWindow = new NxPimPopWindow("Change Repeat", DEF_FG, 0, 0, W_W, W_H);    repeatWindow = new NxPimWindow(W_X, W_Y, W_W, W_H);    add_window((Fl_Window *) repeatWindow->GetWindowPtr());    {	NxButton *o = no_repeat =	    new NxButton(8, 5, 44, BUTTON_HEIGHT, "None");	o->box(FL_FLAT_BOX);	o->type(FL_TOGGLE_BUTTON);	o->value(1);	o->callback(repeatNoneButton_callback, this);	o->movable(false);	repeatWindow->add(o);    }    {	NxButton *o = day_repeat =	    new NxButton(53, 5, 44, BUTTON_HEIGHT, "Day");	o->box(FL_FLAT_BOX);	o->type(FL_TOGGLE_BUTTON);	o->callback(repeatDayButton_callback, this);	o->movable(false);	repeatWindow->add(o);    }    {	NxButton *o = week_repeat =	    new NxButton(98, 5, 44, BUTTON_HEIGHT, "Week");	o->box(FL_FLAT_BOX);	o->type(FL_TOGGLE_BUTTON);	o->callback(repeatWeekButton_callback, this);	o->movable(false);	repeatWindow->add(o);    }    {	NxButton *o = month_repeat =	    new NxButton(143, 5, 44, BUTTON_HEIGHT, "Month");	o->box(FL_FLAT_BOX);	o->type(FL_TOGGLE_BUTTON);	o->callback(repeatMonthButton_callback, this);	o->movable(false);	repeatWindow->add(o);    }    {	NxButton *o = year_repeat =	    new NxButton(188, 5, 44, BUTTON_HEIGHT, "Year");	o->box(FL_FLAT_BOX);	o->type(FL_TOGGLE_BUTTON);	o->callback(repeatYearButton_callback, this);	o->movable(false);	repeatWindow->add(o);    }    {	NxBox *o = repeat_output = new NxBox(BUTTON_X, BUTTON_Y - 70,					     W_W - (2 * BUTTON_X), 55);	//NxBox *o = repeat_output = new NxBox(0, 100, W_W, 55);	o->label("No Repeat.");	o->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_TOP);	//      o->movable(false);	o->box(FL_BORDER_BOX);	o->color(NxApp::Instance()->getGlobalColor(APP_BG));	repeatWindow->add(o);    }    {	NxIntInput *o = every_input = new NxIntInput(53, 30 + BUTTON_HEIGHT,						     30, 25, "Every:");	o->maximum_size(2);	o->align(FL_ALIGN_LEFT);	o->callback(repeatEveryInput_callback, this);	o->when(FL_WHEN_CHANGED);	repeatWindow->add(o);	o->hide();    }    {	NxBox *o = every_box = new NxBox(85, 33 + BUTTON_HEIGHT,					 50, 25, "Day(s)");	repeatWindow->add(o);	o->hide();    }    {	NxBox *o = list_box =	    new NxBox(28, 75 + BUTTON_HEIGHT, 20, BUTTON_HEIGHT);	o->label("End on:");	repeatWindow->add(o);	o->hide();    }    {	NxMenuButton *o = end_list = new NxMenuButton(63, 76 + BUTTON_HEIGHT,						      100, BUTTON_HEIGHT);	o->label("No End Date");	o->movable(true);	o->menu(repeatMenuItems);	repeatWindow->add(o);	o->hide();    }    {	NxBox *o = week_box =	    new NxBox(22, 108 + BUTTON_HEIGHT, 50, BUTTON_HEIGHT);	o->label("Repeat on:");	repeatWindow->add(o);	o->hide();    }    {	char *_d[] = { "S", "M", "T", "W", "T", "F", "S" };	for (int idx = 0; idx < 7; idx++) {	    NxButton *o = new NxButton(BUTTON_X + ((idx + 1) * DAY_S),				       135 + BUTTON_HEIGHT,				       DAY_S, DAY_S, _d[idx]);	    m_WeekButtons[idx] = o;	    o->box(FL_FLAT_BOX);	    o->callback(weekDay_callback, this);	    o->align(FL_ALIGN_CENTER);	    o->type(FL_TOGGLE_BUTTON);	    o->hide();	    repeatWindow->add(o);	}    }    {	NxBox *o = month_box =	    new NxBox(22, 125 + BUTTON_HEIGHT, 50, BUTTON_HEIGHT);	o->label("Repeat by:");	repeatWindow->add(o);	o->hide();    }    {	NxButton *o = month_day =	    new NxButton(BUTTON_X + 73, 127 + BUTTON_HEIGHT,			 44, BUTTON_HEIGHT, "Day");	o->box(FL_FLAT_BOX);	o->type(FL_TOGGLE_BUTTON);	o->callback(monthDayDate_callback, this);	repeatWindow->add(o);	o->hide();    }    {	NxButton *o = month_date =	    new NxButton(BUTTON_X + 118, 127 + BUTTON_HEIGHT,			 44, BUTTON_HEIGHT, "Date");	o->box(FL_FLAT_BOX);	o->type(FL_TOGGLE_BUTTON);	o->callback(monthDayDate_callback, this);	repeatWindow->add(o);	o->hide();    }    {	NxBox *o = message_output = new NxBox(BUTTON_X, 30 + BUTTON_HEIGHT,					      W_W - (2 * BUTTON_X), 55);	o->label("Tap one of the above buttons\n to set repeat interval");	o->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);	repeatWindow->add(o);    }    {	NxButton *o =	    new NxButton(BUTTON_X, BUTTON_Y, BUTTON_WIDTH - 5, BUTTON_HEIGHT,			 "Ok");	o->callback(repeatOk_callback, this);	repeatWindow->add(o);    }    {	NxButton *o = new NxButton(BUTTON_X + 56, BUTTON_Y, BUTTON_WIDTH - 5,				   BUTTON_HEIGHT, "Cancel");	o->callback(repeatCancel_callback, this);	repeatWindow->add(o);    }    repeatWindow->GetWindowPtr()->end();}voidNxSchedule::noDate_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) (NxApp::Instance());    pThis->end_list->label("No End Date");    pThis->repeatDate = 0;    pThis->end_list->hide();    pThis->end_list->show();}voidNxSchedule::repeatDate_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    static char date_buf[30];    tm *tt;    int year;    int mon;    int m_day;    pThis->dateWindow->GetWindowPtr()->hide();    pThis->show_window(repeatWindow->GetWindowPtr());    if (pCalendar->GetPickedDate()) {	tt = localtime(&pThis->m_pCurrentItem->startTime);	year = tt->tm_year;	mon = tt->tm_mon;	m_day = tt->tm_mday;	time_t picked_date = pCalendar->GetPickedDate();	tt = localtime(&picked_date);	if (tt->tm_year < year || tt->tm_mon < mon || tt->tm_mday < m_day) {	    pThis->end_list->label("No End Date");	    pThis->end_list->hide();	    pThis->end_list->show();	    pThis->repeatDate = 0;	    return;	}	pThis->repeatDate = pCalendar->GetPickedDate();	pThis->m_pCurrentItem->repeatFlag_3 = pThis->repeatDate;	strftime(date_buf, 29, "%a %m/%d/%Y",		 localtime(&(pThis->repeatDate)));	pThis->end_list->label(date_buf);	pThis->end_list->hide();	pThis->end_list->show();    }}voidNxSchedule::chooseDate_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) (NxApp::Instance());    pThis->set_date_picker(m_pCalendar);    if (pThis->m_pCurrentItem->repeatFlag_3)	pCalendar->SetPickedDate(pThis->m_pCurrentItem->repeatFlag_3);    else	pCalendar->SetPickedDate(pThis->m_pCurrentItem->startTime);    pThis->show_window(dateWindow->GetWindowPtr(),		       DEACTIVATE, repeatWindow->GetWindowPtr());    pCalendar->DateCallback(repeatDate_callback);}voidNxSchedule::repeatOk_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    pThis->m_pCurrentItem->repeatFlag_1 = pThis->getRepeatValue();    if (0 == strcmp("", pThis->every_input->value()) ||	(0 == strcmp("1", pThis->every_input->value())) ||	(0 == strcmp("0", pThis->every_input->value())) ||	(0 == strcmp("00", pThis->every_input->value())))	every_input->value("1");    if (pThis->no_repeat->value()) {	pThis->m_pCurrentItem->repeatFlag_2 = 0;	pThis->m_pCurrentItem->repeatFlag_3 = 0;    } else {	pThis->m_pCurrentItem->repeatFlag_2 =	    strtol(every_input->value(), NULL, 10);	pThis->m_pCurrentItem->repeatFlag_3 = pThis->repeatDate;    }    if (pThis->week_repeat->value())	pThis->m_pCurrentItem->repeatWkMonFlag = pThis->getWeekValue();    else if (pThis->month_repeat->value())	pThis->m_pCurrentItem->repeatWkMonFlag = pThis->getMonthValue();    else	pThis->m_pCurrentItem->repeatWkMonFlag = 0;    pThis->FillDetailForm(pThis->m_pCurrentItem, DESC_KEEP);    pThis->show_window(dayWindow->GetWindowPtr());    pThis->show_window(detailsWindow->GetWindowPtr(),		       DEACTIVATE, dayWindow->GetWindowPtr());}voidNxSchedule::repeatCancel_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    pThis->show_window(dayWindow->GetWindowPtr());    pThis->show_window(detailsWindow->GetWindowPtr(),		       DEACTIVATE, dayWindow->GetWindowPtr());}voidNxSchedule::noRepeat_Ui(){    list_box->hide();    end_list->hide();    every_input->hide();    every_box->hide();    for (int idx = 0; idx < 7; idx++)	m_WeekButtons[idx]->hide();    week_box->hide();    month_box->hide();    month_day->hide();    month_date->hide();}voidNxSchedule::repeatShow_ui(){    message_output->hide();    every_input->show();    every_box->hide();    every_box->show();    end_list->show();    list_box->show();    for (int idx = 0; idx < 7; idx++)	m_WeekButtons[idx]->hide();    week_box->hide();    month_box->hide();    month_day->hide();    month_date->hide();}voidNxSchedule::defaultUi(){    every_input->value("1");    end_list->label("No End Date");    repeatDate = 0;}voidNxSchedule::resetUi(long repeat){    static char val[4];    static char date[30];    if (0 >= m_pCurrentItem->repeatFlag_3)	strcpy(date, "No End Date");    else	strftime(date, 29, "%a %m/%d/%Y",		 localtime(&(m_pCurrentItem->repeatFlag_3)));    defaultUi();    switch (repeat) {    case REPEAT_DAILY:	if (REPEAT_DAILY == m_pCurrentItem->repeatFlag_1) {	    sprintf(val, "%d", m_pCurrentItem->repeatFlag_2);	    every_input->value(val);	    end_list->label(date);	}	break;    case REPEAT_WEEKLY:	if (REPEAT_WEEKLY == m_pCurrentItem->repeatFlag_1) {	    sprintf(val, "%d", m_pCurrentItem->repeatFlag_2);	    every_input->value(val);	    end_list->label(date);	}	break;    case REPEAT_MONTHLY:	if (REPEAT_MONTHLY == m_pCurrentItem->repeatFlag_1) {	    sprintf(val, "%d", m_pCurrentItem->repeatFlag_2);	    every_input->value(val);	    end_list->label(date);	}	break;    case REPEAT_YEARLY:	if (REPEAT_YEARLY == m_pCurrentItem->repeatFlag_1) {	    sprintf(val, "%d", m_pCurrentItem->repeatFlag_2);	    every_input->value(val);	    end_list->label(date);	}	break;    default:	defaultUi();	break;    }}voidNxSchedule::repeatNoneButton_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    pThis->noRepeat_Ui();    pThis->message_output->show();    pThis->repeat_output->label("No Repeat.");    pThis->no_repeat->value(1);    pThis->day_repeat->value(0);    pThis->week_repeat->value(0);    pThis->month_repeat->value(0);    pThis->year_repeat->value(0);    pThis->every_input->do_callback();    pThis->repeatDate = 0;}voidNxSchedule::repeatDayButton_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    pThis->resetUi(REPEAT_DAILY);    pThis->every_box->label("Day(s)");    pThis->no_repeat->value(0);    pThis->day_repeat->value(1);    pThis->week_repeat->value(0);    pThis->month_repeat->value(0);    pThis->year_repeat->value(0);    pThis->repeatShow_ui();    pThis->every_input->do_callback();}voidNxSchedule::repeatWeekButton_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    pThis->resetUi(REPEAT_WEEKLY);    pThis->every_box->label("Week(s)");    pThis->no_repeat->value(0);    pThis->day_repeat->value(0);    pThis->week_repeat->value(1);    pThis->month_repeat->value(0);    pThis->year_repeat->value(0);    pThis->repeatShow_ui();    pThis->setWeekValue();    for (int idx = 0; idx < 7; idx++)	pThis->m_WeekButtons[idx]->show();    pThis->week_box->show();    pThis->every_input->do_callback();}voidNxSchedule::repeatMonthButton_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -