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

📄 regional.cxx

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CXX
📖 第 1 页 / 共 2 页
字号:
    }				// end of line    {	double max_width = 0.0, tmp_width;	int lblw, lblx, dtaw, dtax;	NxBox *lbls[REG_NUM_TMDT],	// Array of sample labels	 *dta[REG_NUM_NMBRS];	// Array of sample data	for (int i = 0; i < REG_NUM_TMDT; i++) {	    if ((tmp_width = fl_width(tmdt_lbls[i])) > max_width)		max_width = tmp_width;	}			// end of for	lblx = mar;	lblw = (int) max_width;	dtax = lblx + lblw + mar;	dtaw = _mainw->w() - (dtax + mar);	for (int i = 0; i < REG_NUM_TMDT; cury += BUTTON_HEIGHT, i++) {	    lbls[i] =		new NxBox(lblx, cury, lblw, BUTTON_HEIGHT, tmdt_lbls[i]);	    lbls[i]->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT);	    dta[i] =		new NxBox(dtax, cury, dtaw, BUTTON_HEIGHT, "Sample Data");	    dta[i]->box(FL_FLAT_BOX);	    dta[i]->color(def_bg);	    dta[i]->labelcolor(def_fg);	    dta[i]->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT);	    _regtmdt[i].nb = dta[i];	}			// end of for 	cury += (int) (0.5 * BUTTON_HEIGHT);    }    {	double max_width = 0.0, tmp_width;	int lblw, lblx, dtaw, dtax;	NxBox *lbls[REG_NUM_NMBRS], *dta[REG_NUM_NMBRS];	for (int i = 0; i < REG_NUM_NMBRS; i++) {	    if ((tmp_width = fl_width(nmbrs_lbls[i])) > max_width)		max_width = tmp_width;	}			// end of for	lblx = mar;	lblw = (int) max_width;	dtax = lblx + lblw + mar;	dtaw = _mainw->w() - (dtax + mar);	for (int i = 0; i < REG_NUM_NMBRS; cury += BUTTON_HEIGHT, i++) {	    lbls[i] =		new NxBox(lblx, cury, lblw, BUTTON_HEIGHT, nmbrs_lbls[i]);	    lbls[i]->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT);	    dta[i] =		new NxBox(dtax, cury, dtaw, BUTTON_HEIGHT, "Sample Data");	    dta[i]->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT);	    dta[i]->box(FL_FLAT_BOX);	    dta[i]->color(def_bg);	    dta[i]->labelcolor(def_fg);	    _regnmbrs[i].nb = dta[i];	}			// end of for     }    _mainw->end();    _mainw->hide();    return;}				// end of NxRegional::MakeWindow(void)/*******************************************************************************\****	Function:	void SetAppPrefs()**	Desc:		Stores any changed values into the PAR database**	Accepts:	Nothing (void)**	Returns:	Nothing (void)**	\*******************************************************************************/voidNxRegional::SetAppPrefs(void){    char *pardb;		// Database name    db_handle *hdb;		// Database handle    if ((pardb = db_getDefaultDB()) == NULL) {	printf("No Default database! Changes lost");	return;    }				// end of if    if ((hdb = db_openDB(pardb, PAR_DB_MODE_RW)) == NULL) {	printf("Unable to open %s, error=%d", pardb, pardb_errno);	return;    }				// end of if    // Write out changes    if ((_nregidx != _oregidx) &&	par_setGlobalPref(hdb, "language", "default", PAR_TEXT,			  locale_info[_nregidx].locale_cd,			  strlen(locale_info[_nregidx].locale_cd) + 1) <= 0) {	printf("Unable to store node global.language.default="	       "%s, error=%d", locale_info[_nregidx].locale_cd, pardb_errno);    }				// end of if     // TODO: Make the collosseum call...    char col_msg[CL_MAX_MSG_LEN];    int col_len = sprintf(col_msg, "sc_regional^SYSCON_REG_CHANGE");    sysconf_ipc_write(CL_MSG_BROADCAST_ID, col_msg, col_len);    // Close the database    db_closeDB(hdb);    return;}				// end of NxRegional::SetAppPrefs(void)/*******************************************************************************\****	Function:	void SetNmbrs()**	Desc:		Sets the _regnmbrs[idx] member up correctly and sets the widget**				for a redraw status**	Accepts:	int idx = Index into _regnmbrs to process**				char *value = label value**	Returns:	Nothing (void)**\*******************************************************************************/voidNxRegional::SetNmbrs(int idx, char *value){    // Validate the incoming parameters    if (value == NULL || *value == '\0')	return;    if (idx < 0 || idx >= REG_NUM_NMBRS)	return;    delete[]_regnmbrs[idx].label;    _regnmbrs[idx].label = new char[strlen(value) + 1];    strcpy(_regnmbrs[idx].label, value);    _regnmbrs[idx].nb->label(_regnmbrs[idx].label);    _regnmbrs[idx].nb->damage(FL_DAMAGE_ALL);    _regnmbrs[idx].nb->redraw();    return;}				// end of NxRegional::SetNmbrs(int, char *)/*******************************************************************************\****	Function:	void SetTmdt()**	Desc:		Sets the _regtmdt[idx] member up correctly and sets the widget**				for a redraw status**	Accepts:	int idx = Index into _regtmdt to process**				char *value = label value**	Returns:	Nothing (void)**\*******************************************************************************/voidNxRegional::SetTmdt(int idx, char *value){    // Validate the incoming parameters    if (value == NULL || *value == '\0')	return;    if (idx < 0 || idx >= REG_NUM_TMDT)	return;    // delete[] performs the "if (ptr)" test....    delete[]_regtmdt[idx].label;    _regtmdt[idx].label = new char[strlen(value) + 1];    strcpy(_regtmdt[idx].label, value);    _regtmdt[idx].nb->label(_regtmdt[idx].label);    _regtmdt[idx].nb->damage(FL_DAMAGE_ALL);    _regtmdt[idx].nb->redraw();    return;}				// end of NxRegional::SetTmdt(int, char *)/*******************************************************************************\****	Function:	void SetValues()**	Desc:		Sets the widgets values based upon the current state of the **				application (_mode)**	Accpets:	Nothing (void)**	Returns:	Nothing (void)**\*******************************************************************************/voidNxRegional::SetValues(void){    char *cp1, *olocale, tmp_data[128];    double conv_val = 123456789.0;    // TODO: Set the curret locale to what was selected and redisplay values    if (_nregidx == -1)	return;    // Set the locale and get the formatting info//      set_locale_dir();    if ((olocale =	 setlocale(LC_ALL, locale_info[_nregidx].locale_cd)) == NULL) {	printf("setlocale() failed for %s\n",	       locale_info[_nregidx].locale_cd);//              return;    }    _mbreg->label(locale_info[_nregidx].locale_nm);    _mbreg->damage(FL_DAMAGE_ALL);    _mbreg->redraw();    // Convert the date/time values    time_t now = time(NULL);    struct tm *ptm = localtime(&now);    strftime(tmp_data, sizeof(tmp_data), nl_langinfo(T_FMT), ptm);    SetTmdt(REG_TMDT_TIME, tmp_data);    strftime(tmp_data, sizeof(tmp_data), nl_langinfo(D_FMT), ptm);    SetTmdt(REG_TMDT_SDT, tmp_data);    strftime(tmp_data, sizeof(tmp_data), "%c", ptm);    if ((cp1 = strchr(tmp_data, ':')) != NULL	|| (cp1 = strchr(tmp_data, '.')) != NULL) {	while (cp1 >= tmp_data && *cp1 != ' ')	    cp1--;	*cp1 = '\0';	cp1++;    }				// end of if     SetTmdt(REG_TMDT_LDT, tmp_data);#ifndef __UCLIBC__    // Convert the numeric values    strfmon(tmp_data, sizeof(tmp_data), "%+!n", conv_val);    SetNmbrs(REG_NMBRS_PN, tmp_data);    strfmon(tmp_data, sizeof(tmp_data), "%+!n", -conv_val);    SetNmbrs(REG_NMBRS_NN, tmp_data);    // Format the currency values    strfmon(tmp_data, sizeof(tmp_data), "%n", conv_val);    SetNmbrs(REG_NMBRS_PC, tmp_data);    strfmon(tmp_data, sizeof(tmp_data), "%n", -conv_val);    SetNmbrs(REG_NMBRS_NC, tmp_data);#endif    return;}				// end of NxRegional::SetValues(void)#if 0/*******************************************************************************\****	Function:	void set_locale_dir()**	Desc:		Makes sure that the locale information is available (untarred), **				that corresponds to the locale name at idx _nregidx.**	Accepts:	Nothing (void)**	Returns:	Nothing (void)**\*******************************************************************************/voidNxRegional::set_locale_dir(void){    char sysbuf[1024];		// Buffer for system()    pid_t chld_pid;    struct stat statbuf;	// Stat buffer    sprintf(sysbuf, "%s/%s", locale_dir, locale_info[_nregidx].locale_cd);    if (stat(sysbuf, &statbuf)) {	strcat(sysbuf, ".tar.gz");	if (stat(sysbuf, &statbuf))	    return;    }				// end of if    sprintf(sysbuf, "cd %s; tar -zxf %s.tar.gz", locale_dir,	    locale_info[_nregidx].locale_cd);    if ((chld_pid = fork()) == 0) {	char *argv[4];	argv[0] = "sh";	argv[1] = "-c";	argv[2] = sysbuf;	argv[3] = 0;	execv("/bin/sh", argv);	_exit(127);    }				// end of if     else if (chld_pid > 0) {	// Wait around for the child to die	int csts;	waitpid(chld_pid, &csts, 0);    }				// end of if//      system(sysbuf);}				// end of NxRegional::set_locale_dir(void)#endif//-------------------------------------------------------------------------------////      Private static callback methods//              void mb_cb(Fl_Widget *, void *)//              void save_reset_cb(Fl_Widget *, void *)////-------------------------------------------------------------------------------/*******************************************************************************\****	Function:	void mb_cb()**	Desc:		Callback for the regional selection menu button**	Accepts:	Fl_Widget *w = Ptr to the widget responsible for the branch**				void *d = Ptr to any ancillary data**	Returns:	Nothing (void)**\*******************************************************************************/voidNxRegional::mb_cb(Fl_Widget * w, void *d){    NxRegional *me = (NxRegional *) d;    NxMenuButton *nxmb = (NxMenuButton *) w;    int idx, saveidx = me->_nregidx;    idx = nxmb->value();    if (idx == me->_nregidx)	return;    me->_nregidx = idx;    // Set the values    if (me->_nregidx != saveidx) {	DPRINTF("Loading new values!\n");	me->SetValues();    }				// end of if    return;}				// end of NxRegional::mb_cb(Fl_Widget *, void *)/*******************************************************************************\****	Function:	void save_reset_cb()**	Desc:		Handles the save/reset of this application/utility**	Accepts:	Fl_Widget *w = Ptr to the widget responsible for the branch**				void *d = Ptr to any ancillary data**	Returns:	Nothing (void)**\*******************************************************************************/voidNxRegional::save_reset_cb(Fl_Widget * w, void *d){    NxRegional *me = (NxRegional *) d;    NxButton *nxb = (NxButton *) w;    if (!strcmp(nxb->label(), "Save") && me->_nregidx != me->_oregidx) {	DPRINTF("Saving any changed data!\n");	me->SetAppPrefs();    }				// end of if    else if (!strcmp(nxb->label(), "Reset")) {	DPRINTF("Reseting data!\n");	me->_nregidx = me->_oregidx;	me->SetValues();    }				// end of else-if}				// end of NxRegional::save_exit_cb(Fl_Widget *, void *)

⌨️ 快捷键说明

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