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

📄 userinfo.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.                                                 */// System header files#include <stdio.h>#include <stdarg.h>#include <stdlib.h>#include <unistd.h>// Local header files#include <FL/Enumerations.H>#include "nxui.h"#include <pixlib/pixlib.h>#include <sysconf_plugin.h>// Typedef, macro, enum/struct/union definitions#define		VALIDATE_CHAR(c, f)		((((f) & UI_DFLAGS_ALPHA) && isalpha((c))) || \									 (((f) & UI_DFLAGS_NUMERIC) && isdigit((c))) || \									 (((f) & UI_DFLAGS_PUNC) && ispunct((c))) || \									 (((f) & UI_DFLAGS_WHITESP) && isspace((c))) )static const char *ParIds[UI_FLD_MAXFLDS + 1] = { " ",    "Name",    "Company",    "Address",    "Phone",    "Email",    "Notes"};/*******************************************************************************\****	Function:	~NxUserInfo()**	Desc:		Class NxUserInfo destructor, responsible for free()ing dynamic**				memory**	Accepts:	N/A**	Returns:	N/A**\*******************************************************************************/NxUserInfo::~NxUserInfo(){    // Delete the widgets     delete _resetb;    delete _saveb;    // Delete all of the input widgets    for (int i = 0; i < UI_FLD_MAXFLDS; i++)	delete _Inputs[i].input;    delete _userInfog;    delete _notesg;    delete _mainTab;    delete _mainw;}				// end of NxUserInfo::~NxUserInfo()/*******************************************************************************\****	Function:	NxUserInfo()**	Desc:		Class NxUserInfo constructor, handles parsing of commandline**				arguments**	Accepts:	int argc = Number of arguments on instantiation**				char **argv = Argument vector**	Returns:	N/A**\*******************************************************************************/NxUserInfo::NxUserInfo(int X, int Y, int W, int H, char *appname){    _winX = X;    _winY = Y;    // Build the window and widgets    MakeWindow(X, Y, W, H);    // Get the Application preferences from PAR    GetAppPrefs();}/*******************************************************************************\****	Function:	void GetAppPrefs()**	Desc:		Retrieves the current preferences for this application from the**				PAR database, storing the results in the _bl_settings member**	Accepts:	Nothing (void)**	Returns:	Nothing (void)**\*******************************************************************************/voidNxUserInfo::GetAppPrefs(void){    char *pardb,		// name of the default database      par_data[512] = { '\0' };	// Values from the database    int idx,			// Index value      rc;    db_handle *hdb;		// Database handle    // Setup the database    if ((pardb = db_getDefaultDB()) == NULL) {	printf("No default database present!");	return;    }				// end of if    if ((hdb = db_openDB(pardb, PAR_DB_MODE_RDONLY)) == NULL) {	printf("Error opening %s, error=%d", pardb, pardb_errno);	return;    }				// end of if    // Get the User Information from par    for (idx = 0; idx < UI_FLD_MAXFLDS; idx++) {	memset(par_data, 0, sizeof(par_data));	if ((rc =	     par_getGlobalPref(hdb, "UserId",			       const_cast <			       char *>(ParIds[_Inputs[idx].fld_name]),			       PAR_TEXT, par_data, sizeof(par_data) - 1)) > 0	    && par_data[0] >= ' ')	{	    // Handle the different widget cases	    if (_Inputs[idx].dta_flags & UI_DFLAGS_SL) {		NxInput *nxip;	// Input widget ptr		// Note: This uses the "Truman Hack" to hide/show changed input		// box widgets to display properly...		nxip = (NxInput *) _Inputs[idx].input;		nxip->value(par_data, strlen(par_data));		nxip->hide();		nxip->damage(FL_DAMAGE_ALL);		nxip->redraw();		nxip->position(strlen(par_data));		nxip->mark(strlen(par_data));		nxip->show();	    }			// end of if	    else {		Fl_Editor *nxip;	// Editor widget ptr		nxip = (Fl_Editor *) _Inputs[idx].input;		nxip->Clear();		nxip->LoadFrom(par_data);	    }			// end of else	}			// end of if	else {	    if (_Inputs[idx].dta_flags & UI_DFLAGS_SL) {		((NxInput *) _Inputs[idx].input)->value(NULL);		((NxInput *) _Inputs[idx].input)->damage(FL_DAMAGE_ALL);		((NxInput *) _Inputs[idx].input)->redraw();	    }			// end of if	    else {		((Fl_Editor *) _Inputs[idx].input)->Clear();	    }			// end of else	}			// end of else	_Inputs[idx].dta_flags &= ~UI_DFLAGS_DIRTY;    }				// end of for    // Close the database and return    db_closeDB(hdb);    return;}				// end of NxUserInfo::GetAppPrefs(void)/*******************************************************************************\****	Function:	void MakeWindow()**	Desc:		Creates the main fltk window and adds the appropriate widgets to**				it**	Accepts:	Nothing (void)**	Returns:	Nothing (void)**\*******************************************************************************/voidNxUserInfo::MakeWindow(int X, int Y, int W, int H){    int curx,			// Current x coordinate      cury,			// Current y coordinate      mar = 4,			// Left margin      tab_bmar;			// Tab bottom margin    NxApp *instance = sysconf_get_instance();    _mainw = new Fl_Group(X, Y, W, H);    _mainw->color(instance->getGlobalColor(APP_BG));    tab_bmar = _mainw->h() - ((2 * mar) + BUTTON_HEIGHT);    curx = X + BUTTON_X;    cury = Y + BUTTON_Y - _winY;    {	NxButton *o;	o = new NxButton(curx, cury, BUTTON_WIDTH, BUTTON_HEIGHT);	o->label("Save");	o->when(FL_WHEN_RELEASE);	o->callback(save_reset_cb, (void *) this);	o->show();	_saveb = o;	curx += 63;    }    {	NxButton *o;	o = new NxButton(curx, cury, BUTTON_WIDTH, BUTTON_HEIGHT);	o->label("Reset");	o->when(FL_WHEN_RELEASE);	o->callback(save_reset_cb, (void *) this);	_resetb = o;    }    {	double max_lbl_wid = 0;	// Label width	int input_width;	Fl_Tabs *o;		// Tab widget	curx = X + mar;	cury = Y + mar;	fl_font(DEFAULT_TEXT_FONT, DEFAULT_TEXT_SIZE);	for (int i = 1; i <= UI_FLD_MAXFLDS; i++) {	    double tmp_wid;	    if ((tmp_wid = fl_width(ParIds[i])) > max_lbl_wid)		max_lbl_wid = tmp_wid;	}			// end of for	max_lbl_wid += fl_width(": ") + mar;	o = new Fl_Tabs(curx, cury, _mainw->w() - (2 * mar),			tab_bmar - (mar + 10));	o->box(FL_FLAT_BOX);	{	    int grpx, grpy = cury + mar;	    Fl_Group *g1;	// ID Tab Group	    g1 = new Fl_Group(curx, cury + mar, o->w(), o->h() - 20);	    instance->def_font(g1);	    g1->box(FL_FLAT_BOX);	    g1->label("User Id");	    g1->color(_mainw->color());	    grpx = g1->x() + (int) max_lbl_wid;	    input_width = g1->w() - ((int) max_lbl_wid + mar);

⌨️ 快捷键说明

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