dslinux/user/pixil/apps/fltk/sysconfig/clock Makefile README nxclock.cxx nxclock.h nxsunclock.cxx nxsunclock.h sunclock.h
amadeus
dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:24:33 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/pixil/apps/fltk/sysconfig/clock
In directory antilope:/tmp/cvs-serv11916/apps/fltk/sysconfig/clock
Added Files:
Makefile README nxclock.cxx nxclock.h nxsunclock.cxx
nxsunclock.h sunclock.h
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it
--- NEW FILE: README ---
Note:
the old/ directory contains the unmodified code for the clock widget
with the sunclock built in. We should merge that in gradually
--- NEW FILE: nxclock.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 at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include "nxsunclock.h"
#include "nxclock.h"
#define PLUGIN_CLASS nxSunclock
static PLUGIN_CLASS *plugin = 0;
static void
PLUGIN_CLASS_new(int x, int y, int w, int h)
{
if (!plugin)
plugin = new PLUGIN_CLASS(x, y, w, h, UTILITY_NAME);
}
static void
PLUGIN_CLASS_show(void)
{
if (plugin)
plugin->ShowWindow();
}
static void
PLUGIN_CLASS_hide(void)
{
if (plugin)
plugin->HideWindow();
}
static void
PLUGIN_CLASS_del(void)
{
if (plugin)
delete plugin;
}
extern "C" void
plugin_create(int x, int y, int w, int h)
{
PLUGIN_CLASS_new(x, y, w, h);
}
extern "C" void
plugin_show(void)
{
PLUGIN_CLASS_show();
}
extern "C" void
plugin_hide(void)
{
PLUGIN_CLASS_hide();
}
extern "C" void
plugin_info(char *str, int size)
{
strncpy(str, UTILITY_NAME, size);
}
extern "C" void
plugin_close(void)
{
PLUGIN_CLASS_del();
}
--- NEW FILE: nxclock.h ---
/*
* 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 at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#ifndef NXCLOCK_HEADER_INCLUDED
#define NXCLOCK_HEADER_INCLUDED 1
/* System header files */
/* Local header files */
#include <ipc/colosseum.h>
#include <nxapp.h>
#include "nxsunclock.h"
#include <par/par.h>
/* Typedef, macros, enum/struct/union definitions */
#define UTILITY_NAME "Time and Date"
#define UTILITY_VERSION "1.0.0"
#define DEFAULT_MAP_FILE "sunclock_map.gif"
#define DEFAULT_ZONEDB "cityzones.db"
#define DPRINTF(str, arg...) fprintf(stderr, str, ## arg)
/* Global Scope variables */
#endif // NXCLOCK_HEADER_INCLUDED
--- NEW FILE: sunclock.h ---
/*
* 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 at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
/*
* Sun clock definitions.
*/
#define XK_MISCELLANY
#define XK_LATIN1
#ifndef NANO_X
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysymdef.h>
#include <X11/keysym.h>
#include <X11/xpm.h>
#endif // NANO_X
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
#define MENU_WIDTH 38
#define SEL_WIDTH 28
#define SEL_HEIGHT 10
#define abs(x) ((x) < 0 ? (-(x)) : x) /* Absolute value */
#define sgn(x) (((x) < 0) ? -1 : ((x) > 0 ? 1 : 0)) /* Extract sign */
#define dtr(x) ((x) * (PI / 180.0)) /* Degree->Radian */
#define rtd(x) ((x) / (PI / 180.0)) /* Radian->Degree */
#define fixangle(a) ((a) - 360.0 * (floor((a) / 360.0))) /* Fix angle */
#define PI 3.14159265358979323846
#define ZFACT 1.2
#define COLORLENGTH 48 /* maximum length of color names */
#define TERMINC 100 /* Circle segments for terminator */
#define PROJINT (60 * 10) /* Frequency of seasonal recalculation
in seconds. */
#define RECOVER "Trying to recover.\n"
#define FAILFONT "fixed"
#define EARTHRADIUS_KM 6378.125
#define EARTHRADIUS_ML 3963.180
#define SUN_APPRADIUS 0.266 /* Sun apparent radius, in degrees */
#define ATM_REFRACTION 0.100 /* Atmospheric refraction, in degrees */
#define ATM_DIFFUSION 3.0 /* Atmospheric diffusion, in degrees */
#define SP " "
#define COORDINATES 'c'
#define DISTANCES 'd'
#define EXTENSION 'e'
#define LEGALTIME 'l'
#define SOLARTIME 's'
#define TIMECOUNT 25
#define TIMESTEP 10000
enum
{ RANDOM = 0, FIXED, CENTER, NW, NE, SW, SE };
/* Geometry structure */
typedef struct Geometry
{
int mask;
int x;
int y;
unsigned int width;
unsigned int height;
unsigned int w_mini;
unsigned int h_mini;
}
Geometry;
typedef struct Flags
{
short update; /* update image (=-1 full update) */
short last_hint; /* is hint changed ? */
short firsttime; /* is it first window mapping ? */
short bottom; /* bottom strip to be cleaned */
short hours_shown; /* hours in extension mode shown? */
short map_mode; /* are we in C, D, E, L, S mode? */
short clock_mode; /* clock mode */
short progress; /* special progress time ? */
short shading; /* shading mode */
short dms; /* degree, minute, second mode */
short sunpos; /* is Sun to be shown ? */
short cities; /* are cities to be shown ? */
short meridian; /* are meridian to be shown ? */
short parallel; /* are parallel to be shown ? */
short tropics; /* are tropics to be shown ? */
}
Flags;
typedef struct ZoomSettings
{
double fx; /* zoom factor along width */
double fy; /* zoom factor along height */
double fdx; /* translation factor along width */
double fdy; /* translation factor along height */
int mode; /* zoom behaviour mode=0,1,2,3 */
int width; /* width of full extent zoomed area */
int height; /* height of full extent zoomed area */
int dx; /* translation along width */
int dy; /* translation along height */
}
ZoomSettings;
#ifndef NANO_X
typedef struct GClist
{
GC store;
GC invert;
GC smallfont;
GC bigfont;
GC dirfont;
GC imagefont;
GC citycolor0;
GC citycolor1;
GC citycolor2;
GC markcolor1;
GC markcolor2;
GC linecolor;
GC tropiccolor;
GC suncolor;
}
GClist;
typedef struct Pixlist
{
Pixel black;
Pixel white;
Pixel textbgcolor;
Pixel textfgcolor;
Pixel dircolor;
Pixel imagecolor;
Pixel citycolor0;
Pixel citycolor1;
Pixel citycolor2;
Pixel markcolor1;
Pixel markcolor2;
Pixel linecolor;
Pixel tropiccolor;
Pixel suncolor;
}
Pixlist;
#endif // NANO_X
/* Records to hold cities */
typedef struct City
{
char *name; /* Name of the city */
double lat, lon; /* Latitude and longitude of city */
char *tz; /* Timezone of city */
int mode;
struct City *next; /* Pointer to next record */
}
City;
/* Records to hold marks */
typedef struct Mark
{
City *city;
double save_lat, save_lon;
int status, pulse, full;
struct tm sr, ss, dl;
}
Mark;
#ifndef NANO_X
/* Sundata structure */
typedef struct Sundata
{
Window win; /* window id */
Colormap cmap; /* window private colormap */
GClist gclist; /* window GCs */
Pixlist pixlist; /* special color pixels */
int wintype; /* is window map or clock ? */
int hstrip; /* height of bottom strip */
Geometry geom; /* geometry */
Geometry prevgeom; /* previous geometry */
ZoomSettings zoom; /* Zoom settings of window */
ZoomSettings newzoom; /* New zoom settings */
Flags flags; /* window behavioral flags */
char *clock_img_file; /* name of clock xpm file */
char *map_img_file; /* name of map xpm file */
char *bits; /* pointer to char * bitmap bits */
short *tr1; /* pointer to day/night transition 1 */
short *tr2; /* pointer to day/night transition 2 */
int south; /* color code (0 / -1) at South pole */
double *wave; /* pointer to sine, cosine values */
Pixmap pix; /* pixmap */
XImage *xim; /* ximage of map */
char *ximdata; /* ximage data copy */
unsigned char *daypixel; /* pointer to day pixels */
unsigned char *nightpixel; /* pointer to night pixels */
int ncolors; /* number of colors in day pixels */
long time; /* time - real or fake, see flags */
long projtime; /* last time projected illumination */
long progress; /* time progression (in sec) */
long jump; /* time jump (in sec) */
double fnoon; /* position of noon, double prec */
int noon; /* position of noon, integer */
int local_day; /* previous local day */
int solar_day; /* previous solar day */
int textx; /* x where to draw the text */
int texty; /* y where to draw the text */
int count; /* number of time iterations */
double sundec; /* Sun declination */
double sunlon; /* Sun longitude */
double shadefactor; /* shading factor */
struct City pos1; /* first position */
struct City pos2; /* second position */
struct Mark mark1; /* first mark */
struct Mark mark2; /* second mark */
struct Sundata *next; /* pointer to next structure */
}
Sundata;
#endif // NANO_X
/* Which OS are we using ? */
#if defined(linux) || defined(__linux) || defined(__linux__)
#define _OS_LINUX_
#elif defined(hpux) || defined(__hpux) || defined(__hpux__)
#define _OS_HPUX_
#endif
#if defined(__powerpc__)
#define BIGENDIAN
#endif
--- NEW FILE: Makefile ---
# apps/sysconfig/about/Makefile
TARGET_SO=clock.so
INSTALL_SODIR=$(INSTALL_DIR)/share/sysconfig
SRC=${shell ls *.cxx}
OBJS=${SRC:.cxx=.o}
INCLUDES=-I../include
CFLAGS ?=
CFLAGS += -DPIXIL
include $(BASE_DIR)/Rules.make
--- NEW FILE: nxsunclock.h ---
/*
* 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 at centurysoftware.com for information about the PIXIL
* Commercial License Agreement, or if any conditions of this licensing
* are not clear to you.
*/
#ifndef NXSUNCLOCK_INCLUDED
#define NXSUNCLOCK_INCLUDED 1
// System header files
// Local header files
#include <FL/Fl.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Clock.H>
#include <Flek/Fl_Calendar.H>
#include <FL/Fl_Image.H>
#include <nximage.h>
#include <nxapp.h>
#include <nxbutton.h>
#include <nxmenubutton.h>
#include <nxoutput.h>
#include <nxtminput.h>
#include "sysconf.h"
#include <sysconfig.h>
#ifdef NOTUSED
// Typedefs, macro, enum/struct/union definitions
typedef struct
{
unsigned char red, // Red pixel value
green, // Green pixel value
blue, // Blue pixel value
alpha; // Alpha blend value
}
RGBpixel;
typedef enum
{
tzCTYQUERY = 0, // Query the time at the specified city
tzCTYSET // Sets the current timezone (either home/visiting)
}
tz_ptmode_enum;
typedef enum
{
tzHOME = 0, // Affects the home timezone only
tzVISIT // Affects the Visiting timezone only
}
tz_mode_enum;
typedef struct
{
char name[25 + 1], // City name
reg[2 + 1], // State/Country 2 char value
tz[64]; // Timezone stuff
}
city_rec_t;
#endif
typedef struct
{
#ifdef NOTUSED
city_rec_t cities[2]; // Home/Visiting city records
#endif
bool home_current; // Flag detailing which is current
unsigned char dirty_flgs; // Flags indicating what has changed and needs
// to be written back out to PAR
}
app_value_t;
// Values for app_value_t.dirty_flgs
#define APP_DFLGS_HOME 0x01 // Home city info has changed
#define APP_DFLGS_VISIT 0x02 // Visit city info has changed
#define APP_DFLGS_CUR 0x04 // Current active city has changed
#define UTILITY_PAR_NAME "worldclock"
//#define UTILITY_NAME "WorldClock"
// Class definition
class nxSunclock
{
public:
// Constructor // destructor
~nxSunclock(); // Class destructor
nxSunclock(int X, int Y, int W, int H, char *appname); // Class constructor
void *GetWindow(void);
void ShowWindow(void);
void HideWindow(void);
private:
#ifdef NOTUSED
// Private data
unsigned char *_sun_array, // Buffer of modified day/night map data
*_map_array; // Buffer of original map data
char *_grImage, // Ptr to the image path
*_zndb; // Ptr to the zone database
tz_ptmode_enum _ePtMode; // Current point mode (query/set)
tz_mode_enum _eCurTzMode; // Current mode (home/visiting)
#endif
AppMode_t _appmode; // Current app mode
int _clckedit, // clock edit mode
_winX, // Windows TL X value
_winY; // Windows TL Y value
app_value_t _app_settings; // Application settings
// Fltk widgets/windows
Fl_Group *_timewin; // Window for setting date/time
#ifdef NOTUSED
Fl_Group *_sunwin; // Main window
Fl_Group *_mainw;
#endif
Fl_Calendar *_cal; // Calendar widget
// Fl_Check_Button *_dstbtn; // Dst button
Fl_Clock_Output *_tclock; // Time clock
// NxImage *_sunmap; // Sun map image
#ifdef NOTUSED
Fl_Image *_sunmap; // Sun map image
Fl_Button *_sunbutton;
NxButton *_tzbtns[2]; // Home/Visiting timezone buttons
#endif
NxTmInput *_timeui; // Widget to set the time
#ifdef NOTUSED
NxMenuButton *_selcity; // "Popup" menu button
#endif
// Private methods
void GetAppPrefs(void); // Get the application preferences
void MakeWindows(int, int, int, int); // Creates the fltk windows
#ifdef NOTUSED
void MakeSunwin(int w, int h); // Creates the sunclock window
#endif
void MakeTimewin(int x, int y, int w, int h); // Creates the time window
void SetAppPrefs(void); // Saves the App prefences
#ifdef NOTUSED
void SetSunclock(); // Creates the sunclock image
#endif
void SetTimes(); // Sets the time
public:
// Static Methods
static void adj_tm_cb(Fl_Widget * w, void *d); // Inc/Dec the time unit
static void map_click_cb(Fl_Widget * w, void *d); // Callback for a click on the map
static void save_exit_cb(Fl_Widget * w, void *d); // Save/Exit callback
static void sel_city_cb(Fl_Widget * w, void *d); // Call back for the city selection
static void set_dt_tm_cb(Fl_Widget * w, void *d); // Callback to set the date/time
static void set_tz_cb(Fl_Widget * w, void *d); // Change tz for active zone
static void show_sc_win_cb(Fl_Widget * w, void *d); // Call back to return to sunclock
static void Sunclock_Timeout(void *d); // Callback to update (refresh) the map
static void Timer_Timeout(void *d); // Callback to update the current time
static void Toggle_tz_cb(Fl_Widget * w, void *d); // Callback to make a timezone active
static void upd_tm_cb(Fl_Widget * w, void *d); // Update the clock's time
}; // end of nxSunclock definition
#endif // NXSUNCLOCK_INCLUDED
--- NEW FILE: 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.
*
[...1509 lines suppressed...]
(city_size +
5) * sizeof(record));
if (tmp == NULL)
return (-1);
city_list = tmp;
} // end of else
city_size += 5;
} // end of if
memcpy(&city_list[cnt], &record, sizeof(h_data_rec));
cnt++;
} /* end of if */
} /* end of while */
} /* end of for */
h_closedb(hdbd);
// Possibly sort the list???
return (cnt);
} // end of void GetCityList(char *, int, int)
#endif
More information about the dslinux-commit
mailing list