📄 nxsunclock.cxx
字号:
/* * 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 <dirent.h>#include <errno.h>#include <stdio.h>#include <stdarg.h>#include <string.h>#include <sys/stat.h>#include <sys/time.h>#include <sys/types.h>#include <time.h>#include <unistd.h>#include <FL/Enumerations.H>#include <FL/x.H>#ifdef NOTUSED#include "hashdb_api.h"#endif#include "nxclock.h"#ifdef NOTUSED#include "scfxn.h"#endif#include <sysconf_plugin.h>// Typedef, macros, enum/struct/union definitions#define SUNCLOCK_TIMEOUT 30.0#define DEG_ADJ_VAL 10#ifdef NOTUSED// File scope variablesstatic char tz_label[2][64]; // Static labels for the tz buttonsstatic bool bQuery = false; // Query is not to be displayed#endifnxSunclock::nxSunclock(int X, int Y, int W, int H, char *appname){ // Query PAR for any known parameters: // This will need to query the default image file name, current tz mode, // and other application preferences#ifdef NOTUSED _grImage = NULL; _zndb = NULL; _ePtMode = tzCTYQUERY; _eCurTzMode = tzHOME;#endif memset(&_app_settings, 0, sizeof(_app_settings));#ifdef NOTUSED GetAppPrefs();#endif#ifdef NOTUSED // Initialize data members to known state _sun_array = _map_array = NULL;#endif _appmode = eNORMAL;#ifdef NOTUSED _sunwin = NULL;#endif _timewin = NULL;#ifdef NOTUSED _sunmap = NULL;#endif _winX = X; _winY = Y;#ifdef NOTUSED _tzbtns[(int) tzHOME] = _tzbtns[(int) tzVISIT] = NULL;#endif _clckedit = 0;#ifdef NOTUSED if (!_zndb) { char buf[255]; getcwd(buf, sizeof(buf)); sprintf(buf + strlen(buf), "/%s", DEFAULT_ZONEDB); _zndb = new char[strlen(buf) + 1]; strcpy(_zndb, buf); }#endif // Setup FLTK MakeWindows(X, Y, W, H); // Set the initial time SetTimes();#ifdef NOTUSED // Set the initial sunclock phase... SetSunclock();#endif // Register a timer to update (redraw) the system clock every minute or so...#ifdef NOTUSED Fl::add_timeout(SUNCLOCK_TIMEOUT, Sunclock_Timeout, (void *) this);#endif Fl::add_timeout(0.5, Timer_Timeout, (void *) this);}/*******************************************************************************\**** Function: ~nxSunclock()** Desc: Destructor for the nxSunclock class** Accepts: N/A** Returns: N/A**\*******************************************************************************/nxSunclock::~nxSunclock(){#ifdef NOTUSED delete[]_grImage; delete[]_zndb; delete[]_sun_array; delete[]_map_array; delete[]_sunmap->array; delete _sunmap; delete _tzbtns[(int) tzHOME]; delete _tzbtns[(int) tzVISIT]; delete _timeui; delete _selcity;#endif delete _timewin;#ifdef NOTUSED delete _sunwin;#endif}// end of nxSunclock::~nxSunclock()voidnxSunclock::ShowWindow(void){ _timewin->show();}voidnxSunclock::HideWindow(void){ _timewin->hide();}voidnxSunclock::GetAppPrefs(void){#ifdef NOTUSED char par_data[512] = { '\0' }, // Node to get#endif char *pardb; // Name of the default database db_handle *parH; // Handle to the par database // Generic Database handling junk.... if ((pardb = db_getDefaultDB()) == NULL) { printf("No default database present!"); return; } // end of if if ((parH = db_openDB(pardb, PAR_DB_MODE_RDONLY)) == NULL) { printf("Error opening %s, error=%d", pardb, pardb_errno); return; } // Low-level application info #ifdef NOTUSED // Query PAR to get the location of the default graphic image par_getAppPref(parH, UTILITY_PAR_NAME, "graphic", "map", par_data, sizeof(par_data)); if (par_data[0]) { _grImage = new char[strlen(par_data) + 1]; strcpy(_grImage, par_data); } // end of if #endif#ifdef NOTUSED // Query PAR to get the location of the default city/zone database file memset(par_data, 0, sizeof(par_data)); par_getAppPref(parH, UTILITY_PAR_NAME, "zoneinfo", "db", par_data, sizeof(par_data)); if (par_data[0]) { _zndb = new char[strlen(par_data) + 1]; strcpy(_zndb, par_data); } // end of if #endif // Global Timezone application info#ifdef NOTUSED // Home timezone location (city,reg,tz) if (par_getGlobalPref(parH, "timezone", "home_tz", PAR_TEXT, par_data, sizeof(par_data)) == -1) { // No such record in the PAR printf("Home Timezone not in par!"); printf("Using default."); // Load up default values. strcpy(_app_settings.cities[(int) tzHOME].name, "London"); strcpy(_app_settings.cities[(int) tzHOME].reg, "EN"); strcpy(_app_settings.cities[(int) tzHOME].tz, "Europe/London"); } // end of if else { parsecity(par_data, &_app_settings.cities[(int) tzHOME]); memset(par_data, 0, sizeof(par_data)); } // end of else#endif#ifdef NOTUSED // Visiting timezone location if (par_getGlobalPref(parH, "timezone", "visit_tz", PAR_TEXT, par_data, sizeof(par_data)) == -1) { // No visit record in the PAR printf("No visiting tz found!"); } // end of if else { parsecity(par_data, &_app_settings.cities[(int) tzVISIT]); memset(par_data, 0, sizeof(par_data)); } // end of else // Is home location active location? if ((par_getGlobalPref(parH, "timezone", "home_active", PAR_BOOL, (char *) &_app_settings.home_current, sizeof(_app_settings.home_current))) == -1) { // Home is not set printf("Forced home tz active");#endif _app_settings.home_current = true;#ifdef NOTUSED } // end of if#endif#ifdef NOTUSED // Set the global state based on this value if (_app_settings.home_current == true) _eCurTzMode = tzHOME; else _eCurTzMode = tzVISIT;#endif#ifdef PROMPT_FOR_DST // Get the home dst usage if ((par_getGlobalPref(parH, "timezone", "h_use_dst", PAR_BOOL, (char *) &_app_settings.use_dst[(int) tzHOME], sizeof(_app_settings.use_dst[(int) tzHOME]))) == -1) { printf("Forcing home dst usage!"); _app_settings.use_dst[(int) tzHOME] = true; } // end of if // Get the visit dst usage value if ((par_getGlobalPref(parH, "timezone", "v_use_dst", PAR_BOOL, (char *) &_app_settings.use_dst[(int) tzVISIT], sizeof(_app_settings.use_dst[(int) tzVISIT]))) == -1) { printf("Forcing visit dst usage!"); _app_settings.use_dst[(int) tzVISIT] = true; } // end of if#endif // PROMPT_FOR_DST db_closeDB(parH); return;}voidnxSunclock::MakeWindows(int X, int Y, int W, int H){#ifdef NOTUSED _mainw = new Fl_Group(X, Y, W, H); MakeSunwin(W, H);#endif MakeTimewin(X, Y, W, H);#ifdef NOTUSED _mainw->end(); _timewin->hide();#endif}void *nxSunclock::GetWindow(void){ return (void *) _timewin;}#ifdef NOTUSED/*******************************************************************************\**** Function: void MakeSunwin()** Desc: Makes the sunclock window and adds all of the necessary widgets** to it.** Accpets: int w = width of the window ** int h = height of the window** Returns: Nothing (void)**\*******************************************************************************/voidnxSunclock::MakeSunwin(int w, int h){ int b_x = _winX, // Bottom row x value b_y, // Botton row y value t_x = _winX, // Top row x value t_y; // Top row y value _sunwin = new Fl_Group(_winX, _winY, w, h, UTILITY_NAME); //_sunwin->color(NxApp::Instance()->getGlobalColor(APP_BG)); // Add the widgets t_y = (h - ((6 * BUTTON_HEIGHT) + gimp_image.height)) / 2; { // TL Button NxButton *o = new NxButton(t_x, t_y, BUTTON_WIDTH, (3 * BUTTON_HEIGHT), "Set Timezone"); o->when(FL_WHEN_RELEASE_ALWAYS); o->callback(set_tz_cb, (void *) this); o->box(FL_BORDER_BOX); t_x += BUTTON_WIDTH; } // end of Home Time Zone button widget { // T text NxButton *o = _tzbtns[(int) tzHOME] = new NxButton(t_x, t_y, (w - (2 * BUTTON_WIDTH)), (3 * BUTTON_HEIGHT)); NxBox *p = new NxBox(t_x, t_y - BUTTON_HEIGHT, (w - (2 * BUTTON_WIDTH)), BUTTON_HEIGHT); o->when(FL_WHEN_RELEASE_ALWAYS); o->callback(Toggle_tz_cb, (void *) this); p->when(FL_WHEN_NEVER); o->box(FL_BORDER_BOX); p->box(FL_FLAT_BOX); //if (_eCurTzMode != tzHOME) // o->labelcolor(NxApp::Instance()->getGlobalColor(APP_FG)); //p->color(NxApp::getGlobalColor(APP_BG)); //p->labelcolor(NxApp::getGlobalColor(APP_FG)); p->label("Home Location");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -