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

📄 nxdetail.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 <stdlib.h>#include <unistd.h>#include <time.h>#include <pixil_config.h>#include "nxschedule.h"/* Please, get rid of this ugly thing */#if defined(CONFIG_APP_ALARM) && defined(CONFIG_COLOSSEUM)#define DO_ALARM 1#endif#ifdef DEBUG#define DPRINT(str, args...) printf("DEBUG: " str, ## args)#else#define DPRINT(args...)#endifextern Fl_Menu_Item schedMenuItems[];#ifdef DO_ALARMFl_Menu_Item alarmMenuItems[] = {    {"Minutes", 0, NxSchedule::chooseAlarmMin_callback},    {"Hours", 0, NxSchedule::chooseAlarmHour_callback},    {"Days", 0, NxSchedule::chooseAlarmDay_callback},    {0}};#endifstatic char *_FormatTimeRange(NxTodo * n){    static char buf[30];    tm startTime;    tm endTime;    memcpy(&startTime, localtime(&n->startTime), sizeof(startTime));    memcpy(&endTime, localtime(&n->endTime), sizeof(endTime));    startTime.tm_sec = 0;    endTime.tm_sec = 0;    sprintf(buf, "%d:%02d%s - %d:%02d%s",	    HR_12(startTime.tm_hour),	    startTime.tm_min,	    AM_PM(startTime.tm_hour),	    HR_12(endTime.tm_hour), endTime.tm_min, AM_PM(endTime.tm_hour));    return buf;}#ifdef DO_ALARMvoidNxSchedule::chooseAlarmMin_callback(Fl_Widget * w, void *l){    NxCheckButton *p_Button = (NxCheckButton *) w;    NxSchedule *pThis = (NxSchedule *) (NxApp::Instance());    p_Button->label("Minutes");    p_Button->hide();    p_Button->show();    pThis->SetAlarmInt(ALARM_MIN);}voidNxSchedule::chooseAlarmHour_callback(Fl_Widget * w, void *l){    NxCheckButton *p_Button = (NxCheckButton *) w;    NxSchedule *pThis = (NxSchedule *) (NxApp::Instance());    p_Button->label("Hours");    p_Button->hide();    p_Button->show();    pThis->SetAlarmInt(ALARM_HOUR);}voidNxSchedule::chooseAlarmDay_callback(Fl_Widget * w, void *l){    NxCheckButton *p_Button = (NxCheckButton *) w;    NxSchedule *pThis = (NxSchedule *) (NxApp::Instance());    p_Button->label("Days");    p_Button->hide();    p_Button->show();    pThis->SetAlarmInt(ALARM_DAY);}voidNxSchedule::SetAlarmInt(int interval){    m_pCurrentItem->alarmFlags = interval;}#endifvoidNxSchedule::detailTimePicked_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    time_t start_time;    time_t end_time;    tm *time;    int start_hour1;    int start_min1;    int start_hour2;    int start_min2;    int end_hour1;    int end_min1;    int end_hour2;    int end_min2;    NxTodo *note;    int rec_array[1];    char c_recno[16];    pThis->timeWindow->GetWindowPtr()->hide();    NxApp::Instance()->show_window(pThis->detailsWindow->GetWindowPtr(),				   DEACTIVATE,				   pThis->dayWindow->GetWindowPtr());    if (w) {	if (!(CHANGED_NEW & g_EditFlag)) {	    note = new NxTodo;	    rec_array[0] = -1;	    sprintf(c_recno, "%d", pThis->m_pCurrentItem->recno);	    pThis->GetTimes(&start_time, &end_time);	    time = localtime(&start_time);	    start_hour1 = time->tm_hour;	    start_min1 = time->tm_min;	    time = localtime(&end_time);	    end_hour1 = time->tm_hour;	    end_min1 = time->tm_min;	    pThis->db->Select(SCHEDULE, c_recno, 0, rec_array, 1);	    pThis->ExtractRecord(note, rec_array[0]);	    time = localtime(&note->startTime);	    start_hour2 = time->tm_hour;	    start_min2 = time->tm_min;	    time = localtime(&note->endTime);	    end_hour2 = time->tm_hour;	    end_min2 = time->tm_min;#ifdef DEBUG	    printf("start_hour1 [%d] start_hour2 [%d]\n", start_hour1,		   start_hour2);	    printf("start_min1 [%d] start_min2 [%d]\n", start_min1,		   start_min2);	    printf("end_hour1 [%d] end_hour2[%d]\n", end_hour1, end_hour2);	    printf("end_min1 [%d] end_min2 [%d]", end_min1, end_min2);#endif	    if (start_hour1 != start_hour2 || start_min1 != start_min2 ||		end_hour1 != end_hour2 || end_min1 != end_min2 &&		!(REPEAT_NONE & pThis->m_pCurrentItem->repeatFlag_1)) {		g_EditFlag |= CHANGED_TIME_FLAG;	    } else {		g_EditFlag = g_EditFlag & ~CHANGED_TIME_FLAG;	    }	    delete note;	}	pThis->GetTimes(&pThis->m_pCurrentItem->startTime,			&pThis->m_pCurrentItem->endTime);	// ok .. we just got a callback from our time picker routines	// update the 	pThis->FillDetailForm(pThis->m_pCurrentItem, DESC_KEEP);    }}voidNxSchedule::detailDatePicked_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    pThis->dateWindow->GetWindowPtr()->hide();    NxApp::Instance()->show_window(pThis->detailsWindow->GetWindowPtr(),				   DEACTIVATE,				   pThis->dayWindow->GetWindowPtr());    time_t t = pCalendar->GetPickedDate();    if (t) {	tm date;	tm startTime;	tm endTime;	tm today;	time_t start_time;	time_t end_time;	memcpy(&date, localtime(&t), sizeof(date));	memcpy(&startTime, localtime(&pThis->m_pCurrentItem->startTime),	       sizeof(startTime));	memcpy(&endTime, localtime(&pThis->m_pCurrentItem->endTime),	       sizeof(endTime));	memcpy(&today, localtime(&pThis->m_CurrentDay), sizeof(today));	startTime.tm_sec = 0;	startTime.tm_mon = date.tm_mon;	startTime.tm_year = date.tm_year;	startTime.tm_mday = date.tm_mday;	endTime.tm_sec = 0;	endTime.tm_mon = date.tm_mon;	endTime.tm_year = date.tm_year;	endTime.tm_mday = date.tm_mday;	start_time = mktime(&startTime);	end_time = mktime(&endTime);	if ((date.tm_year != today.tm_year	     || date.tm_mon != today.tm_mon	     || date.tm_mday != today.tm_mday) &&	    !(REPEAT_NONE & pThis->m_pCurrentItem->repeatFlag_1))	    g_EditFlag |= CHANGED_DATE_FLAG;	else	    g_EditFlag = g_EditFlag & ~CHANGED_DATE_FLAG;#ifdef DEBUG	printf("Date callback g_EditFlag [%d]\n", g_EditFlag);#endif	pThis->m_pCurrentItem->fakeTime = start_time;	pThis->m_pCurrentItem->startTime = start_time;	pThis->m_pCurrentItem->endTime = end_time;	// ok .. we just got a callback from our date picker routines	// update the detail window	pThis->FillDetailForm(pThis->m_pCurrentItem, DESC_KEEP);    }}// Show the date selection windowvoidNxSchedule::detailDate_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    pThis->set_date_picker(m_pCalendar);    if (!(REPEAT_NONE & pThis->m_pCurrentItem->repeatFlag_1))	pCalendar->SetPickedDate(pThis->m_pCurrentItem->fakeTime);    else	pCalendar->SetPickedDate(pThis->m_pCurrentItem->startTime);    pThis->detailsWindow->GetWindowPtr()->deactivate();    NxApp::Instance()->show_window(dateWindow->GetWindowPtr(),				   DEACTIVATE, dayWindow->GetWindowPtr());    pCalendar->DateCallback(detailDatePicked_callback);}#ifdef DO_ALARM// Set the alarm value voidNxSchedule::alarmIntChanged_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    int interval = atoi(pThis->m_pDetailsAlarmInput->value());    pThis->m_pCurrentItem->alarmInt = interval;}// Toggle the alarm button show the alarm input and menuvoidNxSchedule::alarmToggle_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    bool val = pThis->m_pDetailsAlarmCheck->value();    if (true == val) {	pThis->m_pCurrentItem->alarmFlags = ALARM_MIN;	pThis->m_pCurrentItem->alarmInt = 5;	pThis->showAlarmUi();    } else {	pThis->m_pCurrentItem->alarmInt = NO_ALARM;	pThis->hideAlarmUi();    }}#endif// Show the repeat selection windowvoidNxSchedule::detailRepeat_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    pThis->getRepeatData();    pThis->detailsWindow->GetWindowPtr()->deactivate();    NxApp::Instance()->show_window(repeatWindow->GetWindowPtr(),				   DEACTIVATE, dayWindow->GetWindowPtr());}// Show the time selection windowvoidNxSchedule::detailTime_callback(Fl_Widget * w, void *l){    NxSchedule *pThis = (NxSchedule *) l;    pThis->SetTimes(pThis->m_pCurrentItem->startTime,		    pThis->m_pCurrentItem->endTime);    pThis->detailsWindow->GetWindowPtr()->deactivate();    NxApp::Instance()->show_window(timeWindow->GetWindowPtr(),				   DEACTIVATE, dayWindow->GetWindowPtr());

⌨️ 快捷键说明

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