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

📄 nxsunclock.cxx

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CXX
📖 第 1 页 / 共 4 页
字号:
    memcpy(_sun_array, gimp_image.pixel_data, isize);    nxsunimage((unsigned char *) gimp_image.pixel_data, _sun_array,	       gimp_image.height, gimp_image.width,	       gimp_image.bytes_per_pixel);    cnt++;#endif    _sunbutton->damage(FL_DAMAGE_ALL);    _sunbutton->redraw();    return;}				// end of nxSunclock::SetSunclock(void)#endif/*******************************************************************************\****	Function:	void SetTimes()**	Desc:		Calculates the current time for both timezone (home/visit) and**				properly formats the time on the button label**	Accepts:	Nothing (void)**	Returns:	Nothing (void)**\*******************************************************************************/voidnxSunclock::SetTimes(void){#ifdef NOTUSED    char timefmt[64];		// Time format    time_t nowtime = time(NULL);	// Current gmt (utc) time    struct tm act_time,		// Active time struct      inact_time;		// Inactive time struct#endif#ifdef NOTUSED    tz_mode_enum acttz,		// Active time zone index      inacttz;			// Inactive time zone index#endif#ifdef NOTUSED    // Determine active/inactive widgets    if (_eCurTzMode == tzHOME) {	acttz = tzHOME;	inacttz = tzVISIT;    }				// end of if    else {	acttz = tzVISIT;	inacttz = tzHOME;    }				// end of else#endif    // Set the user-editable clock    if (_clckedit == 0) {	time_t timeval;	struct tm *tmptm;	time(&timeval);	tmptm = localtime(&timeval);#ifdef PROMPT_FOR_DST	if (!_dstbtn->value() && tmptm->tm_isdst) {	    timeval -= (60 * 60);	    tmptm = localtime(&timeval);	}			// end of if#endif // PROMPT_FOR_DST	_tclock->value(tmptm->tm_hour, tmptm->tm_min, tmptm->tm_sec);	_timeui->SetTime(tmptm);    }				// end of if#ifdef NOTUSED    // switch timezones to the inactive to get it's time...    if (bQuery == true) {	if (query_rec.name[0] > ' ') {	    setenv("TZ", query_rec.tz, 1);	    tzset();	    memcpy(&inact_time, localtime(&nowtime), sizeof(inact_time));	    sprintf(timefmt, "%s, %s\n%%a, %%b %%d, %%Y\n%%H:%%M:%%S",		    query_rec.name, query_rec.reg);	    strftime(tz_label[(int) inacttz], sizeof(tz_label[(int) inacttz]),		     timefmt, &inact_time);	}			// end of if	else {	    sprintf(tz_label[(int) inacttz], "No selection");	}			// end of else    }				// end of if    else {	if (_app_settings.cities[(int) inacttz].name[0] > ' ') {	    setenv("TZ", _app_settings.cities[(int) inacttz].tz, 1);	    tzset();	    memcpy(&inact_time, localtime(&nowtime), sizeof(inact_time));	    sprintf(timefmt, "%s, %s\n%%a, %%b %%d, %%Y\n%%H:%%M:%%S",		    _app_settings.cities[(int) inacttz].name,		    _app_settings.cities[(int) inacttz].reg);	    strftime(tz_label[(int) inacttz], sizeof(tz_label[(int) inacttz]),		     timefmt, &inact_time);	}			// end of if	else {	    sprintf(tz_label[(int) inacttz], "Not Set");	}			// end of else    }				// end of else    _tzbtns[(int) inacttz]->label(tz_label[(int) inacttz]);    _tzbtns[(int) inacttz]->redraw();    // Switch timezones back to the current value    memcpy(&act_time, localtime(&nowtime), sizeof(act_time));    if (_app_settings.cities[(int) acttz].name[0] > ' ') {	setenv("TZ", _app_settings.cities[(int) acttz].tz, 1);	tzset();	memcpy(&act_time, localtime(&nowtime), sizeof(act_time));	sprintf(timefmt, "%s, %s\n%%a, %%b %%d, %%Y\n%%H:%%M:%%S",		_app_settings.cities[(int) acttz].name,		_app_settings.cities[(int) acttz].reg);	strftime(tz_label[(int) acttz], sizeof(tz_label[(int) acttz]),		 timefmt, &act_time);    }				// end of if    else {	sprintf(tz_label[(int) acttz], "Not set");    }				// end of else    _tzbtns[(int) acttz]->label(tz_label[(int) acttz]);    _tzbtns[(int) acttz]->redraw();#endif    return;}				// end of nxSunclock::SetTimes(void)voidnxSunclock::save_exit_cb(Fl_Widget * w, void *d){    nxSunclock *me = (nxSunclock *) d;    NxButton *nxb = (NxButton *) w;    if (!strcmp(nxb->label(), "Save")) {	DPRINTF("Saving any changed data!\n");#ifdef NOTUSED	me->SetAppPrefs();#endif    }				// end of if    // Update as needed (incase of a reset)#ifdef NOTUSED    me->GetAppPrefs();#endif    me->SetTimes();    return;}				// end of NxPowerman::save_exit_cb(Fl_Widget *, void *)/*******************************************************************************\****	Function:	void adj_tm_cb()**	Desc:		Increments/Decrements the time unit value and sets the clock **				accordingly**	Accepts:	Fl_Widget *w = Ptr to the widget responsible for branch**				void *d = Ptr to any andcillary data**	Returns:	Nothing (void);**\*******************************************************************************/voidnxSunclock::adj_tm_cb(Fl_Widget * w, void *d){    int adj_val,		// Value to adjust by      indx = -1;		// Index into Unit array    nxSunclock *me = (nxSunclock *) d;    NxButton *nxb = (NxButton *) w;    NxTmUnit *tu = NULL;	// Time unit    NxTmUnit *f = (NxTmUnit *) Fl::focus();    // Set the adjustment value    if (!(memcmp(nxb->label(), "+", 1)))	adj_val = 1;    else	adj_val = -1;    // Get the selection widget and adjust it    for (int idx = 0; idx < me->_timeui->GetUnits(); idx++) {	if (me->_timeui->Units[idx] == f) {	    tu = (NxTmUnit *) f;	    indx = idx;	    break;	}			// end of if    }				// end of for    // Adjust the value    if (tu) {	int val;		// Clock value	char ubuf[3];		// unit buffer	strcpy(ubuf, tu->value());	val = atoi(ubuf);	val += adj_val;	if (val > max_val[indx])	    val = 0;	if (val < 0)	    val = max_val[indx];	sprintf(ubuf, "%2.2d", val);	tu->value(ubuf);	tu->do_callback();    }				// end of if    return;}				// end of void nxSunclock::adj_time_cb(Fl_Widget *, void *)#ifdef NOTUSED/*******************************************************************************\****	Function:	void map_click_cb()**	Desc:		Callback function for a click on the map image button.  Functionality**				is based on the current mode (i.e. City time query or timezone**				selection), and current home/visiting selection.**	Accepts:	Fl_Widget *w = widget responsible for branching to this callback**				void *d = Any ancillary data**	Returns:	Nothing (void)**\*******************************************************************************/voidnxSunclock::map_click_cb(Fl_Widget * W, void *d){    double lat,			// Latitude      lon;			// Longitude    int ccnt,			// City count      h,			// Height      mw,			// Max width       w,			// Width      x = Fl::event_x(), y = Fl::event_y(), xpos,	// mouse X position      ypos;			// mouse Y position    NxButton *nxb = (NxButton *) W;	// Button widget    nxSunclock *me = (nxSunclock *) d;    // Adjust the X and Y mouse clicks to be relative to the widget...    xpos = x - nxb->x();    ypos = y - nxb->y();    w = nxb->w();    h = nxb->h();    // Correction for the map?    xpos += 6;    // Convert the x/y coordinate's into relative latitude and longitude values    lat = (((-180.0 * ypos) + (180.0 * h)) / h) - 90.0;    lon = (((360.0 * (double) xpos) / (double) w) - 180.0);    if (lon > 180.0)	lon -= 360.0;    fl_font(DEFAULT_TEXT_FONT, DEFAULT_TEXT_SIZE);    mw = 0;    me->_selcity->clear();    if ((ccnt = GetCityList(me->_zndb, (int) lat, (int) lon)) > 0) {	// Load up a Fl_SelectBrowser widget	for (int i = 0; i < ccnt; i++) {	    double tmp;	    char buf[25];	    sprintf(buf, "%s, %s", city_list[i].city_name, city_list[i].reg);	    if ((tmp = fl_width(buf) + 5) > mw)		mw = (int) tmp;	    me->_selcity->add(buf);	}			// end of for	if ((x + mw) > nxb->w()) {	    x = nxb->w() - (mw + 2);	}			// end of if 	me->_selcity->popup(x, y);    }				// end of if    else {#ifdef NOTUSED	me->SetAppPrefs();#endif    }				// end of if    // Reset the data#ifdef NOTUSED    me->GetAppPrefs();#endif    me->SetTimes();    return;}				// end of nxSunclock::save_exit_cb(Fl_Widget *, void *)/*******************************************************************************\****	Function:	void sel_city_cb()**	Desc:		The user has selected an item from the list, determine which**				one, and how to process it.**	Accepts:	Fl_Widget *w = Ptr to the widget responsible for the branch**				void *d = Ptr to any ancillary data**	Returns:	Nothing (void)**\*******************************************************************************/voidnxSunclock::sel_city_cb(Fl_Widget * w, void *d){    nxSunclock *me = (nxSunclock *) d;    NxMenuButton *nxmb = (NxMenuButton *) w;    int idx;    idx = nxmb->value();    if (idx <= -1)	return;    if (me->_ePtMode == tzCTYSET) {	// Set the value for the selected timezone	memcpy(me->_app_settings.cities[(int) me->_eCurTzMode].name,	       city_list[idx].city_name,	       sizeof(me->_app_settings.cities[(int) me->_eCurTzMode].name) -	       1);	memcpy(me->_app_settings.cities[(int) me->_eCurTzMode].reg,	       city_list[idx].reg,	       sizeof(me->_app_settings.cities[(int) me->_eCurTzMode].reg) -	       1);	ExpandTimeZone(me->_app_settings.cities[(int) me->_eCurTzMode].tz,		       city_list[idx].zinfo,		       sizeof(me->_app_settings.cities[(int) me->_eCurTzMode].			      tz) - 1);	if (me->_eCurTzMode == tzHOME)	    me->_app_settings.dirty_flgs |= APP_DFLGS_HOME;	else	    me->_app_settings.dirty_flgs |= APP_DFLGS_VISIT;    } /* end of if */    else {	// Set the value for a city query	memset(&query_rec, 0, sizeof(query_rec));	memcpy(query_rec.name, city_list[idx].city_name,	       sizeof(query_rec.name) - 1);	memcpy(query_rec.reg, city_list[idx].reg, sizeof(query_rec.reg) - 1);	ExpandTimeZone(query_rec.tz, city_list[idx].zinfo,		       sizeof(query_rec.tz) - 1);	bQuery = true;    }				// end of else    return;}				// end of nxSunclock::sel_city_cb(Fl_Widget *, void *)/*******************************************************************************\****	Function:	void set_dt_tm_cb()**	Desc:		Causes the window that allows the user to set the current date **				and time to be shown**	Accepts:	Fl_Widget *w = Ptr to the widget responsible for the branch**				void *d = Ptr to any ancillary data**	Returns:	Nothing (void)**\*******************************************************************************/voidnxSunclock::set_dt_tm_cb(Fl_Widget * w, void *d){    nxSunclock *me = (nxSunclock *) d;    me->_sunwin->hide();    me->_timewin->show();    Fl::focus(me->_timeui->Units[0]);    return;}				// end of nxSunclock::set_dt_tm_cb(Fl_Widget *, void *)#endif#ifdef NOTUSED/*******************************************************************************\****	Function:	void set_tz_cb()**	Desc:		Allows the user to select/set the timezone for the active mode**				(i.e. home/visit) on the next map click.**	Accepts:	Fl_Widget *w = Ptr to the widget responsible for the branch**				void *d = Ptr to any ancillary data**	Returns:	Nothing (void)**\*******************************************************************************/voidnxSunclock::set_tz_cb(Fl_Widget * w, void *d){    static char *button_label[2] = { {"Set Timezone"},    {"View Time"}    };    NxButton *nxb = (NxButton *) w;    nxSunclock *me = (nxSunclock *) d;    if (me->_ePtMode == tzCTYSET) {	me->_ePtMode = tzCTYQUERY;    }				// end of if    else {	me->_ePtMode = tzCTYSET;	bQuery = false;    }				// end of else

⌨️ 快捷键说明

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