home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
g
/
gina15.zip
/
demos
/
clock.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-27
|
2KB
|
82 lines
/* @(#)clock.C 1.5 7/29/91 */
/*
Dies ist eine 'Clock'-Anwendung.
*/
#include <Gina/Gina.h>
#ifdef INCLUDE_SRC
#include "Gina.C"
#endif
//---------------------------------------------------------------------
class clock_document;
class clock_application : public GnApplication {
public:
GnDocument *create_document ();
char * app_class () { return "Clock" ; }
char * app_signature() { return "clock" ; }
char * app_file_type() { return NULL ; }
void idle_action();
clock_document *cl_doc;
};
class clock_document : public GnDocument {
public:
virtual void create_windows (int new_width = 0, int new_height = 0);
void tick();
GnLabel *digi_clock;
};
//---------------------------------------------------------------------
GnDocument * clock_application ::
create_document () { return new clock_document; }
void clock_application ::
idle_action()
{
cl_doc->tick();
}
//---------------------------------------------------------------------
void clock_document ::
create_windows(int new_width, int new_height)
{
Gina_Debug_NL ("clock_document :: create_windows");
main_shell = new GnDocumentShell( this, new_width, new_height, False );
main_shell->create(GnApplication::get()->get_application_shell(), "shell");
digi_clock = new GnLabel(" 00:00:00 ");
digi_clock->create(main_shell, "digi_clock");
((clock_application*)GnApplication::get())->cl_doc = this;
}
void clock_document::
tick()
{
time_t t = time((time_t)0);
char *ts = ctime(&t);
char *tss = new char [11];
strncpy(tss, &ts[10], 10);
tss[10] = '\0';
digi_clock->setR_labelString( tss );
digi_clock->SetValues();
}
//---------------------------------------------------------------------
int main (unsigned int argc, char ** argv)
{
clock_application clock;
#ifdef GINA_DEBUG
clock.set_sync();
#endif
clock.set_idle_timeout(1000);
clock.run ( argc, argv );
}