campo-sirio/include/progind.h

144 lines
3.0 KiB
C++
Executable File

/* $Id: progind.h,v 1.1.1.1 1994-08-12 10:52:04 alex Exp $ */
/* @N
progind.h
program status and timer boxes
fv 20/8/93
works for both C and C++
@END
*/
#ifdef __cplusplus
#ifndef __PROGIND_H
#define __PROGIND_H
#ifndef __WINDOW_H
#include <window.h>
#endif
#ifndef __STRINGS_H
#include <strings.h>
#endif
/*
@C
class TIndwin : public TWindow
@END
*/
class TIndwin : public TWindow
{
/* @DPRIV */
enum { IND_CANCELLED = 0x01, IND_FINISHED= 0x02 };
WINDOW _text; // Static text
WINDOW _cancel; // CANCEL button
WINDOW _bar; // Moving bar and percentage
byte _flags;
/* @END */
protected:
/* @FPROT */
long _max; // maximum value to reach
long _status; // current status (set by user)
void draw_window();
void measure_text(const char* t, word& len, word& lin) const;
virtual void handler(WINDOW w, EVENT* e);
virtual void update();
void update_bar();
KEY check_stop();
public:
/* @FPUB */
bool iscancelled() const { return _flags & IND_CANCELLED; }
bool isfinished() const { return _flags & IND_FINISHED; }
long status() const { return _status; }
void cancel() { _flags |= IND_CANCELLED; check_stop(); }
/* @END */
/* @LONGDES
si puo' chiamare settext() per cambiare il testo, ma
le dimensioni della finestra sono calcolate sul primo
passato, quindi occorre dare spazi se se ne prevede
uno piu' lungo
@END */
void set_text(const char* t);
/* FPUB */
TIndwin(long max, const char* txt, bool cancel = TRUE, bool bar = TRUE, int div = 16);
virtual ~TIndwin();
};
/*
@C
class TProgind : public TIndwin
@END
*/
class TProgind : public TIndwin
{
public:
/* @FPUB */
void setmax(long m) { _max = m; }
void setstatus(long l) { _status = l; update_bar(); do_events(); }
void addstatus(long l) { setstatus(_status+l); }
TProgind(long max, const char* txt = NULL, bool cancel = TRUE,
bool bar = TRUE, int div = 10);
virtual ~TProgind() {}
};
/*
@C
class TTimerind : public TIndwin
@END
*/
class TTimerind : public TIndwin
{
/* @DPRIV */
int _interval;
static long _timer_id;
protected:
/* @FPROT */
virtual void handler(WINDOW w, EVENT* e);
public:
/* @FPUB */
TTimerind(long msec, const char* txt = NULL, bool cancel = TRUE,
bool bar = TRUE, int div = 10, int interval = 1000);
virtual ~TTimerind();
};
/* @DPRIV */
/* extern TIndwin* __indwin__p; */
/* @FPUB */
#endif
#ifdef __cplusplus
extern "C" {
#endif
void progind_create(long, char*, bool, bool, int);
void progind_set_status(long);
void progind_cancel();
bool progind_iscancelled();
bool progind_isfinished();
void progind_destroy();
void timerind_create(long, char*, bool, bool, int, int);
void timerind_cancel();
bool timerind_iscancelled();
bool timerind_isfinished();
void timerind_destroy();
#ifdef __cplusplus
}
#endif
#endif /* __PROGIND_H */