Corretta gestione dei vari modi di uscita da un'applicazione:
Bottone Fine, Menu Fine, Menu Chiudi o ALT-F4 git-svn-id: svn://10.65.10.50/trunk@229 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
5c70586f90
commit
8097b5d8eb
@ -170,7 +170,7 @@ void TApplication::about() const
|
||||
{
|
||||
#include <prassi.ver>
|
||||
const TFilename n(__argv[0]);
|
||||
message_box("PRASSI Versione Beta %g\nProgramma %s\nLibreria del %s",
|
||||
message_box("PRASSI Versione Beta 1.%g\nProgramma %s\nLibreria del %s",
|
||||
VERSION, (const char*)n.name(), __DATE__);
|
||||
}
|
||||
|
||||
@ -196,7 +196,8 @@ long TApplication::handler(WINDOW, EVENT* ep)
|
||||
switch(mt)
|
||||
{
|
||||
case M_FILE_QUIT:
|
||||
stop_run();
|
||||
if (can_close())
|
||||
stop_run();
|
||||
break;
|
||||
case M_FILE_PG_SETUP:
|
||||
printer().set();
|
||||
@ -232,10 +233,9 @@ long TApplication::handler(WINDOW, EVENT* ep)
|
||||
{
|
||||
if (can_close())
|
||||
quit_OK();
|
||||
else
|
||||
error_box("Chiudere la finestra attiva prima di terminare il programma");
|
||||
}
|
||||
else stop_run();
|
||||
else
|
||||
stop_run();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -335,16 +335,11 @@ const char* TApplication::get_module_name() const
|
||||
return module;
|
||||
}
|
||||
|
||||
void TApplication::set_title(const char* t)
|
||||
{ cfg.appl_name = (char*)t; }
|
||||
|
||||
const char* TApplication::title() const
|
||||
{ return cfg.appl_name; }
|
||||
|
||||
void TApplication::run(int argc, char* argv[], const char* title)
|
||||
{
|
||||
TFilename base(argv[0]);
|
||||
base.ext(""); base.lower();
|
||||
_title = title;
|
||||
|
||||
__argc = argc;
|
||||
__argv = (const char**)argv;
|
||||
@ -364,8 +359,8 @@ void TApplication::run(int argc, char* argv[], const char* title)
|
||||
TString80 caption;
|
||||
caption << "PRASSI S.P.A. - " << get_module_name();
|
||||
|
||||
cfg.base_appl_name = (char*) base.name();
|
||||
cfg.appl_name = (char*) title;
|
||||
cfg.base_appl_name = (char*)base.name();
|
||||
cfg.appl_name = (char*)(const char*)_title;
|
||||
cfg.taskwin_title = (char*)(const char*)caption;
|
||||
cfg.menu_bar_ID = TASK_MENUBAR+addbar;
|
||||
cfg.about_box_ID = 0;
|
||||
|
@ -28,7 +28,7 @@ class TApplication
|
||||
int __argc;
|
||||
const char** __argv;
|
||||
|
||||
TString _name;
|
||||
TString80 _name, _title;
|
||||
TPrinter* _printer;
|
||||
|
||||
protected:
|
||||
@ -67,8 +67,8 @@ public:
|
||||
const char* argv(int i) const { return __argv[i]; }
|
||||
int argc() const { return __argc; }
|
||||
|
||||
void set_title(const char* t);
|
||||
const char* title() const;
|
||||
void set_title(const char* t) { _title = t; }
|
||||
const char* title() const { return _title; }
|
||||
|
||||
void wait_for(const char* name);
|
||||
void wake_up_caller() const;
|
||||
|
@ -620,13 +620,13 @@ void TPush_button::draw_pressed(bool pressed) const
|
||||
win_set_fore_color(_hdc, COLOR_WHITE);
|
||||
win_draw_text(_hdc, _dx+p+1, _dy+p+1, (char*)t, -1);
|
||||
if (_accel >= 0)
|
||||
win_draw_text(_hdc, _dx+_accel+p+1, _dy+p+1, "_", 1);
|
||||
win_draw_text(_hdc, _dx+_accel+p+1, _dy+p+3, "_", 1);
|
||||
|
||||
const COLOR c = disabled() ? DISABLED_COLOR : NORMAL_COLOR;
|
||||
win_set_fore_color(_hdc, c);
|
||||
win_draw_text(_hdc, _dx+p, _dy+p, (char*)t, -1);
|
||||
if (_accel >= 0)
|
||||
win_draw_text(_hdc, _dx+_accel+p, _dy+p, "_", 1);
|
||||
win_draw_text(_hdc, _dx+_accel+p, _dy+p+2, "_", 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,16 @@ void TMask::control_handler(EVENT* ep)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == WC_LISTBUTTON)
|
||||
{
|
||||
if (test_focus_change(win))
|
||||
{
|
||||
set_focus_win(win, FALSE);
|
||||
f->on_key(K_SPACE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (ep->v.ctl.ci.v.edit.focus_change)
|
||||
{
|
||||
@ -353,6 +363,14 @@ int TMask::first_focus(short id)
|
||||
return f;
|
||||
}
|
||||
|
||||
bool TMask::can_be_closed() const
|
||||
{
|
||||
bool ok = TRUE;
|
||||
if (!query_mode() && is_running() && dirty())
|
||||
ok = yesno_box("Annullare i dati inseriti?");
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TMask::close()
|
||||
{
|
||||
_open = FALSE;
|
||||
@ -528,12 +546,22 @@ TMask_field& TMask::field(short id) const
|
||||
return fld(pos);
|
||||
}
|
||||
|
||||
TEdit_field& TMask::efield(short id) const
|
||||
{
|
||||
TMask_field& f = field(id);
|
||||
CHECKD(f.is_edit(), "Impossibile trattare come editabile il campo ", id);
|
||||
return (TEdit_field&)f;
|
||||
}
|
||||
|
||||
int TMask::find_field_win(WINDOW win) const
|
||||
{
|
||||
if (fld(_focus).win() == win)
|
||||
return _focus;
|
||||
|
||||
const int max = fields();
|
||||
for (int i = 0; i < max; i++)
|
||||
if (fld(i).win() == win) return i;
|
||||
|
||||
#ifdef DBG
|
||||
yesnofatal_box("Can't find the field given the child window");
|
||||
#endif
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
bool check_fields();
|
||||
void get_mask_fields(); // read screen contents
|
||||
virtual bool stop_run(KEY key); // called to close the mask
|
||||
|
||||
virtual bool can_be_closed() const;
|
||||
|
||||
virtual void open();
|
||||
virtual void close();
|
||||
@ -128,6 +128,7 @@ public:
|
||||
int id2pos(short id) const;
|
||||
TMask_field& fld(int i) const { return (TMask_field&)_field[i]; } // Ritorna il campo i-esimo della maschera
|
||||
TMask_field& field(short id) const; // field with given id
|
||||
TEdit_field& efield(short id) const; // edit-field with given id
|
||||
|
||||
void set(short fld_id, const char* str, bool hit=FALSE);
|
||||
void set(short fld_id, long num, bool hit=FALSE);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// $Id: maskfld.cpp,v 1.16 1994-09-09 15:05:23 alex Exp $
|
||||
// $Id: maskfld.cpp,v 1.17 1994-09-13 16:43:39 guy Exp $
|
||||
#include <xvt.h>
|
||||
|
||||
#include <applicat.h>
|
||||
@ -1843,9 +1843,10 @@ bool TEdit_field::on_key(KEY key)
|
||||
switch(key)
|
||||
{
|
||||
case K_TAB:
|
||||
if (_validate_func == AUTOEXIT_FUNC || _validate_func == NUMCALC_FUNC ||
|
||||
if (_validate_func == AUTOEXIT_FUNC ||
|
||||
_validate_func == NUMCALC_FUNC ||
|
||||
_validate_func == STRCALC_FUNC)
|
||||
set_focusdirty();
|
||||
set_focusdirty(); // Forza validate
|
||||
if (to_check(K_TAB, TRUE))
|
||||
{
|
||||
set(get());
|
||||
|
@ -1 +1 @@
|
||||
#define VERSION 1.2
|
||||
#define VERSION 1.1
|
||||
|
@ -210,14 +210,24 @@ bool TPrefix::set_codditta(long codditta, bool force)
|
||||
put();
|
||||
return TRUE;
|
||||
}
|
||||
else return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// Restituisce il nome di una directory dati
|
||||
// Certified 90%
|
||||
const char* firm2dir(long codditta)
|
||||
{
|
||||
TFixed_string dir(__tmp_string, 256);
|
||||
dir.format("%05lda", codditta);
|
||||
switch (codditta)
|
||||
{
|
||||
case -2: // Dati generali campione
|
||||
case -1: // Dati di studio
|
||||
dir = ""; break;
|
||||
case 0: // Dati comuni
|
||||
dir = "com"; break;
|
||||
default: // Dati ditta
|
||||
dir.format("%05lda", codditta); break;
|
||||
}
|
||||
dir.insert(__ptprf, 0);
|
||||
return __tmp_string;
|
||||
}
|
||||
|
@ -1,189 +1,189 @@
|
||||
#include <printwin.h>
|
||||
#include <xvtility.h>
|
||||
#include <applicat.h>
|
||||
|
||||
|
||||
void TPrintwin::paint_background(long j)
|
||||
{
|
||||
_isbackground = _bg->items() > 0 && MainApp()->printer().isgraphics();
|
||||
if (!_isbackground) return;
|
||||
int rw = (int)(j % _formlen);
|
||||
TString& rwd = (TString&)(*_bg)[rw];
|
||||
int cnt = 0; char ch;
|
||||
|
||||
char curcol = 'n';
|
||||
char curpen = 'n';
|
||||
char curpat = 'n';
|
||||
char curwid = '1';
|
||||
|
||||
unsigned int x1, x2; PNT b, e;
|
||||
while (ch = rwd[cnt++])
|
||||
{
|
||||
switch(ch)
|
||||
{
|
||||
case 'v': // verticale intera
|
||||
x1 = (unsigned char)rwd[cnt++]-1;
|
||||
b.h = e.h = x1*_charx+_charx/2+_hofs;
|
||||
b.v = rw * _chary + _vofs; e.v = rw * _chary + _vofs;
|
||||
win_move_to(win(),b);
|
||||
win_draw_line(win(),e);
|
||||
break;
|
||||
case 'o': // verticale pezzo sopra
|
||||
x1 = (unsigned char)rwd[cnt++]-1;
|
||||
b.h = e.h = x1*_charx+_charx/2 + _hofs;
|
||||
b.v = rw * _chary + _vofs; e.v = rw * _chary - _chary/2 + _vofs;
|
||||
win_move_to(win(),b);
|
||||
win_draw_line(win(),e);
|
||||
break;
|
||||
case 'u': // verticale pezzo sotto
|
||||
x1 = (unsigned char)rwd[cnt++]-1;
|
||||
b.h = e.h = x1*_charx+_charx/2 + _hofs;
|
||||
b.v = rw*_chary + _chary/2 + _vofs; e.v = rw * _chary + _vofs;
|
||||
win_move_to(win(),b);
|
||||
win_draw_line(win(),e);
|
||||
break;
|
||||
case 'h': // orizzontale intera
|
||||
x1 = (unsigned char)rwd[cnt++]-1;
|
||||
x2 = (unsigned char)rwd[cnt++]-1;
|
||||
b.v = e.v = rw*_chary + _chary/2 + _vofs;
|
||||
b.h = x1*_charx+_hofs; e.h = x2*_charx + _hofs;
|
||||
win_move_to(win(),b);
|
||||
win_draw_line(win(),e);
|
||||
break;
|
||||
case 'r': // orizzontale scorciata agli estremi
|
||||
x1 = (unsigned char)rwd[cnt++]-1;
|
||||
x2 = (unsigned char)rwd[cnt++]-1;
|
||||
b.v = e.v = rw*_chary + _chary/2 + _vofs;
|
||||
b.h = x1*_charx+_charx/2 + _hofs; e.h = x2*_charx+_charx/2+_hofs;
|
||||
win_move_to(win(),b);
|
||||
win_draw_line(win(),e);
|
||||
break;
|
||||
case 'W':
|
||||
curwid = rwd[cnt++];
|
||||
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
||||
trans_pen(curpen));
|
||||
break;
|
||||
case 'P':
|
||||
curpen = rwd[cnt++];
|
||||
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
||||
trans_pen(curpen));
|
||||
break;
|
||||
case 'B':
|
||||
curpat = rwd[cnt++];
|
||||
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
||||
trans_pen(curpen));
|
||||
break;
|
||||
case 'C':
|
||||
curcol = rwd[cnt++];
|
||||
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
||||
trans_pen(curpen));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// restore default pen
|
||||
set_pen(COLOR_BLACK);
|
||||
}
|
||||
|
||||
void TPrintwin::paint_row(long j)
|
||||
{
|
||||
const char* cp; int pos = 0;
|
||||
int row = (int)(j % _formlen);
|
||||
_txt.read_line(j);
|
||||
while(cp = _txt.piece())
|
||||
{
|
||||
#if XVT_OS != XVT_OS_SCOUNIX
|
||||
int st = _txt.get_style();
|
||||
long bg = trans_color(_txt.get_background());
|
||||
long fg = trans_color(_txt.get_foreground());
|
||||
set_font(FF_FIXED, st & 0x000f, _char_size);
|
||||
set_color(fg,bg);
|
||||
#else
|
||||
set_color(COLOR_BLACK, COLOR_WHITE);
|
||||
#endif
|
||||
win_draw_text(win(), pos*_charx + _hofs, row*_chary + _chary + _vofs - _descent,
|
||||
(char *)cp, -1);
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
if (st & underlined)
|
||||
{
|
||||
PNT b, e;
|
||||
|
||||
set_pen(COLOR_BLACK);
|
||||
b.h = _charx*pos + _hofs; b.v = row*_chary + _chary + _vofs;
|
||||
e.h = _charx*(pos+strlen(cp)) + _hofs; e.v = b.v;
|
||||
win_move_to (win(),b);
|
||||
win_draw_line(win(),e);
|
||||
}
|
||||
#endif
|
||||
pos += strlen(cp);
|
||||
}
|
||||
paint_background(j);
|
||||
}
|
||||
|
||||
|
||||
bool TPrintwin::print_band(int page, RCT& r)
|
||||
{
|
||||
int j = page*_formlen;
|
||||
int rows = (r.bottom - r.top) / _chary;
|
||||
int top = r.top / _chary;
|
||||
|
||||
for (int k = top; k < top+rows; k++)
|
||||
{
|
||||
if ((j+k) < _txt.lines() && k < _formlen)
|
||||
paint_row(j+k);
|
||||
else break;
|
||||
}
|
||||
return j+k < _txt.lines();
|
||||
}
|
||||
|
||||
|
||||
bool TPrintwin::do_print()
|
||||
{
|
||||
int page = 0;
|
||||
RCT* rct;
|
||||
bool ok = TRUE;
|
||||
|
||||
while (ok && !_aborted)
|
||||
{
|
||||
_aborted = !(bool)start_page(_printrcd);
|
||||
while (!_aborted && ok && (rct = next_band()) != NULL)
|
||||
ok = print_band(page, *rct);
|
||||
finish_page(_printrcd);
|
||||
page++;
|
||||
}
|
||||
return !_aborted;
|
||||
}
|
||||
|
||||
|
||||
TPrintwin::~TPrintwin()
|
||||
{
|
||||
close_print_window(win(), _printrcd);
|
||||
set_win(NULL_WIN);
|
||||
}
|
||||
|
||||
|
||||
TPrintwin::TPrintwin(PRINT_RCD* p, TTextfile& txt, int chsz) :
|
||||
_printrcd(p), _aborted(FALSE), _txt(txt), _char_size(chsz)
|
||||
{
|
||||
WINDOW w = new_print_window(_printrcd, (char*)MainApp()->title());
|
||||
set_win(w);
|
||||
if (w != NULL_WIN)
|
||||
{
|
||||
_bg = MainApp()->printer().getbgdesc();
|
||||
_isbackground = _bg->items() > 0 && MainApp()->printer().isgraphics();
|
||||
_formlen = MainApp()->printer().formlen();
|
||||
|
||||
set_font(FF_SYSTEM,0,_char_size);
|
||||
|
||||
win_get_font_metrics(win(), &_lead, &_ascent, &_descent);
|
||||
_charx = win_get_text_width(win(), "MM", -1) - win_get_text_width(win(), "M", -1);
|
||||
_chary = MainApp()->printer().get_dots_per_line();
|
||||
|
||||
RCT rct; get_client_rect(win(),&rct);
|
||||
|
||||
_vofs = MainApp()->printer().get_vert_offset();
|
||||
_hofs = (rct.right - rct.left) % _charx;
|
||||
}
|
||||
else _aborted = TRUE;
|
||||
}
|
||||
#include <printwin.h>
|
||||
#include <xvtility.h>
|
||||
#include <applicat.h>
|
||||
|
||||
|
||||
void TPrintwin::paint_background(long j)
|
||||
{
|
||||
_isbackground = _bg->items() > 0 && MainApp()->printer().isgraphics();
|
||||
if (!_isbackground) return;
|
||||
int rw = (int)(j % _formlen);
|
||||
TString& rwd = (TString&)(*_bg)[rw];
|
||||
int cnt = 0; char ch;
|
||||
|
||||
char curcol = 'n';
|
||||
char curpen = 'n';
|
||||
char curpat = 'n';
|
||||
char curwid = '1';
|
||||
|
||||
unsigned int x1, x2; PNT b, e;
|
||||
while (ch = rwd[cnt++])
|
||||
{
|
||||
switch(ch)
|
||||
{
|
||||
case 'v': // verticale intera
|
||||
x1 = (unsigned char)rwd[cnt++]-1;
|
||||
b.h = e.h = x1*_charx+_charx/2+_hofs;
|
||||
b.v = rw * _chary + _vofs; e.v = rw * _chary + _vofs;
|
||||
win_move_to(win(),b);
|
||||
win_draw_line(win(),e);
|
||||
break;
|
||||
case 'o': // verticale pezzo sopra
|
||||
x1 = (unsigned char)rwd[cnt++]-1;
|
||||
b.h = e.h = x1*_charx+_charx/2 + _hofs;
|
||||
b.v = rw * _chary + _vofs; e.v = rw * _chary - _chary/2 + _vofs;
|
||||
win_move_to(win(),b);
|
||||
win_draw_line(win(),e);
|
||||
break;
|
||||
case 'u': // verticale pezzo sotto
|
||||
x1 = (unsigned char)rwd[cnt++]-1;
|
||||
b.h = e.h = x1*_charx+_charx/2 + _hofs;
|
||||
b.v = rw*_chary + _chary/2 + _vofs; e.v = rw * _chary + _vofs;
|
||||
win_move_to(win(),b);
|
||||
win_draw_line(win(),e);
|
||||
break;
|
||||
case 'h': // orizzontale intera
|
||||
x1 = (unsigned char)rwd[cnt++]-1;
|
||||
x2 = (unsigned char)rwd[cnt++]-1;
|
||||
b.v = e.v = rw*_chary + _chary/2 + _vofs;
|
||||
b.h = x1*_charx+_hofs; e.h = x2*_charx + _hofs;
|
||||
win_move_to(win(),b);
|
||||
win_draw_line(win(),e);
|
||||
break;
|
||||
case 'r': // orizzontale scorciata agli estremi
|
||||
x1 = (unsigned char)rwd[cnt++]-1;
|
||||
x2 = (unsigned char)rwd[cnt++]-1;
|
||||
b.v = e.v = rw*_chary + _chary/2 + _vofs;
|
||||
b.h = x1*_charx+_charx/2 + _hofs; e.h = x2*_charx+_charx/2+_hofs;
|
||||
win_move_to(win(),b);
|
||||
win_draw_line(win(),e);
|
||||
break;
|
||||
case 'W':
|
||||
curwid = rwd[cnt++];
|
||||
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
||||
trans_pen(curpen));
|
||||
break;
|
||||
case 'P':
|
||||
curpen = rwd[cnt++];
|
||||
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
||||
trans_pen(curpen));
|
||||
break;
|
||||
case 'B':
|
||||
curpat = rwd[cnt++];
|
||||
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
||||
trans_pen(curpen));
|
||||
break;
|
||||
case 'C':
|
||||
curcol = rwd[cnt++];
|
||||
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
|
||||
trans_pen(curpen));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// restore default pen
|
||||
set_pen(COLOR_BLACK);
|
||||
}
|
||||
|
||||
void TPrintwin::paint_row(long j)
|
||||
{
|
||||
const char* cp; int pos = 0;
|
||||
int row = (int)(j % _formlen);
|
||||
_txt.read_line(j);
|
||||
while(cp = _txt.piece())
|
||||
{
|
||||
#if XVT_OS != XVT_OS_SCOUNIX
|
||||
int st = _txt.get_style();
|
||||
long bg = trans_color(_txt.get_background());
|
||||
long fg = trans_color(_txt.get_foreground());
|
||||
set_font(FF_FIXED, st & 0x000f, _char_size);
|
||||
set_color(fg,bg);
|
||||
#else
|
||||
set_color(COLOR_BLACK, COLOR_WHITE);
|
||||
#endif
|
||||
win_draw_text(win(), pos*_charx + _hofs, row*_chary + _chary + _vofs - _descent,
|
||||
(char *)cp, -1);
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
if (st & underlined)
|
||||
{
|
||||
PNT b, e;
|
||||
|
||||
set_pen(COLOR_BLACK);
|
||||
b.h = _charx*pos + _hofs; b.v = row*_chary + _chary + _vofs;
|
||||
e.h = _charx*(pos+strlen(cp)) + _hofs; e.v = b.v;
|
||||
win_move_to (win(),b);
|
||||
win_draw_line(win(),e);
|
||||
}
|
||||
#endif
|
||||
pos += strlen(cp);
|
||||
}
|
||||
paint_background(j);
|
||||
}
|
||||
|
||||
|
||||
bool TPrintwin::print_band(int page, RCT& r)
|
||||
{
|
||||
int j = page*_formlen;
|
||||
int rows = (r.bottom - r.top) / _chary;
|
||||
int top = r.top / _chary;
|
||||
|
||||
for (int k = top; k < top+rows; k++)
|
||||
{
|
||||
if ((j+k) < _txt.lines() && k < _formlen)
|
||||
paint_row(j+k);
|
||||
else break;
|
||||
}
|
||||
return j+k < _txt.lines();
|
||||
}
|
||||
|
||||
|
||||
bool TPrintwin::do_print()
|
||||
{
|
||||
int page = 0;
|
||||
RCT* rct;
|
||||
bool ok = TRUE;
|
||||
|
||||
while (ok && !_aborted)
|
||||
{
|
||||
_aborted = !(bool)start_page(_printrcd);
|
||||
while (!_aborted && ok && (rct = next_band()) != NULL)
|
||||
ok = print_band(page, *rct);
|
||||
finish_page(_printrcd);
|
||||
page++;
|
||||
}
|
||||
return !_aborted;
|
||||
}
|
||||
|
||||
|
||||
TPrintwin::~TPrintwin()
|
||||
{
|
||||
close_print_window(win(), _printrcd);
|
||||
set_win(NULL_WIN);
|
||||
}
|
||||
|
||||
|
||||
TPrintwin::TPrintwin(PRINT_RCD* p, TTextfile& txt, int chsz) :
|
||||
_printrcd(p), _aborted(FALSE), _txt(txt), _char_size(chsz)
|
||||
{
|
||||
WINDOW w = new_print_window(_printrcd, (char*)MainApp()->title());
|
||||
set_win(w);
|
||||
if (w != NULL_WIN)
|
||||
{
|
||||
_bg = MainApp()->printer().getbgdesc();
|
||||
_isbackground = _bg->items() > 0 && MainApp()->printer().isgraphics();
|
||||
_formlen = MainApp()->printer().formlen();
|
||||
|
||||
set_font(FF_SYSTEM,0,_char_size);
|
||||
|
||||
win_get_font_metrics(win(), &_lead, &_ascent, &_descent);
|
||||
_charx = win_get_text_width(win(), "MM", -1) - win_get_text_width(win(), "M", -1);
|
||||
_chary = MainApp()->printer().get_dots_per_line();
|
||||
|
||||
RCT rct; get_client_rect(win(),&rct);
|
||||
|
||||
_vofs = MainApp()->printer().get_vert_offset();
|
||||
_hofs = (rct.right - rct.left) % _charx;
|
||||
}
|
||||
else _aborted = TRUE;
|
||||
}
|
||||
|
@ -1,50 +1,52 @@
|
||||
#ifndef __PRINTWIN_H
|
||||
#define __PRINTWIN_H
|
||||
|
||||
#ifndef __WINDOW_H
|
||||
#include <window.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
#ifndef __TEXT_H
|
||||
#include <text.h>
|
||||
#endif
|
||||
|
||||
class TPrintwin : public TWindow
|
||||
{
|
||||
|
||||
bool _aborted;
|
||||
bool _isbackground;
|
||||
PRINT_RCD* _printrcd;
|
||||
int _formlen;
|
||||
int _formwidth;
|
||||
TArray* _bg;
|
||||
TTextfile& _txt;
|
||||
|
||||
int _lead, _ascent, _descent;
|
||||
int _hofs, _vofs;
|
||||
int _charx, _chary;
|
||||
int _char_size;
|
||||
|
||||
void paint_background(long j);
|
||||
void paint_row(long j);
|
||||
bool print_band(int, RCT&);
|
||||
|
||||
public:
|
||||
|
||||
// check if aborted; also returned by do_print
|
||||
bool aborted() { return _aborted; }
|
||||
// inhibits background printing
|
||||
void print_background(bool b) { _isbackground = b; }
|
||||
// starts printing; FALSE if aborted
|
||||
bool do_print();
|
||||
|
||||
TPrintwin(PRINT_RCD* pr, TTextfile& txt, int chsize = 12);
|
||||
virtual ~TPrintwin();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef __PRINTWIN_H
|
||||
#define __PRINTWIN_H
|
||||
|
||||
#ifndef __WINDOW_H
|
||||
#include <window.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
#ifndef __TEXT_H
|
||||
#include <text.h>
|
||||
#endif
|
||||
|
||||
class TPrintwin : public TWindow
|
||||
{
|
||||
|
||||
bool _aborted;
|
||||
bool _isbackground;
|
||||
PRINT_RCD* _printrcd;
|
||||
int _formlen;
|
||||
int _formwidth;
|
||||
TArray* _bg;
|
||||
TTextfile& _txt;
|
||||
|
||||
int _lead, _ascent, _descent;
|
||||
int _hofs, _vofs;
|
||||
int _charx, _chary;
|
||||
int _char_size;
|
||||
|
||||
void paint_background(long j);
|
||||
void paint_row(long j);
|
||||
bool print_band(int, RCT&);
|
||||
|
||||
public:
|
||||
|
||||
// check if aborted; also returned by do_print
|
||||
bool aborted() const { return _aborted; }
|
||||
|
||||
// inhibits background printing
|
||||
void print_background(bool b) { _isbackground = b; }
|
||||
|
||||
// starts printing; FALSE if aborted
|
||||
bool do_print();
|
||||
|
||||
TPrintwin(PRINT_RCD* pr, TTextfile& txt, int chsize = 12);
|
||||
virtual ~TPrintwin();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,261 +1,267 @@
|
||||
// $Id: progind.cpp,v 1.1.1.1 1994-08-12 10:52:04 alex Exp $
|
||||
|
||||
#include <defmask.h>
|
||||
#include <progind.h>
|
||||
|
||||
const char* const CANCEL_TEXT = "Annulla";
|
||||
const char* const TITLE_TEXT = "Attesa";
|
||||
|
||||
// Certified 70%
|
||||
TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
|
||||
{
|
||||
_cancel = _bar = _text = NULL_WIN;
|
||||
|
||||
_status = 0l;
|
||||
_max = max;
|
||||
if (_max <= 0) _max = 1;
|
||||
_flags = 0x0;
|
||||
|
||||
word maxlen = div, lines;
|
||||
measure_text(txt, maxlen, lines);
|
||||
|
||||
int ver = lines+3;
|
||||
|
||||
int hor = maxlen+2; if (hor > 78) hor = 78;
|
||||
|
||||
if (bar)
|
||||
{
|
||||
_bar = ver * CHARY;
|
||||
ver += 3;
|
||||
}
|
||||
ver += cancel ? 3 : 0;
|
||||
|
||||
create(-1, -1, hor, ver, TITLE_TEXT);
|
||||
|
||||
RCT r; r.left = CHARX; r.top = CHARY; r.right = CHARX*(hor-2); r.bottom = r.top + lines*CHARY+4;
|
||||
_text = create_control(WC_TEXT, &r, (char*)txt, win(), CTL_FLAG_CENTER_JUST, 0l, DLG_NULL);
|
||||
|
||||
if (cancel)
|
||||
_cancel = xvt_create_control(WC_PUSHBUTTON, -11, -1, 9, 2,
|
||||
CANCEL_TEXT, win(), 0, 0l, DLG_CANCEL);
|
||||
open_modal();
|
||||
do_events();
|
||||
}
|
||||
|
||||
void TIndwin::set_text(const char* t)
|
||||
{
|
||||
set_title(_text, (char*)t);
|
||||
}
|
||||
|
||||
TIndwin::~TIndwin()
|
||||
{ close_modal(); }
|
||||
|
||||
|
||||
void TIndwin::measure_text(const char* txt, word& maxlen, word& lines) const
|
||||
{
|
||||
TToken_string s(txt, '\n');
|
||||
lines = 0;
|
||||
for(const char* t = s.get(0); t; t = s.get())
|
||||
{
|
||||
const word l = strlen(t);
|
||||
if (l > maxlen) maxlen = l;
|
||||
lines++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
KEY TIndwin::check_stop()
|
||||
{
|
||||
KEY k = 0;
|
||||
if (_flags & IND_FINISHED || _flags & IND_CANCELLED)
|
||||
{
|
||||
k = (_flags & IND_FINISHED) ? K_ENTER : K_ESC;
|
||||
stop_run(k);
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
void TIndwin::update_bar()
|
||||
{
|
||||
if (_status >= _max)
|
||||
{
|
||||
_status = _max;
|
||||
_flags |= IND_FINISHED;
|
||||
}
|
||||
|
||||
const double prc = (double)_status/_max;
|
||||
|
||||
RCT r; get_client_rect(win(), &r);
|
||||
r.left = CHARX; r.right -= CHARX;
|
||||
r.top = (int)_bar;
|
||||
r.bottom = r.top + 3*CHARY;
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
r.top += 6;
|
||||
r.bottom -= 6;
|
||||
#endif
|
||||
const int width = r.right - r.left;
|
||||
|
||||
RCT b = r;
|
||||
set_brush(COLOR_BLUE);
|
||||
b.right = b.left + int(width*prc);
|
||||
win_draw_rect(win(), &b);
|
||||
|
||||
set_brush(COLOR_WHITE);
|
||||
b.left = b.right; b.right = r.right;
|
||||
win_draw_rect(win(), &b);
|
||||
|
||||
set_mode(M_XOR);
|
||||
win_set_fore_color(win(), COLOR_BLUE);
|
||||
char n[8]; sprintf(n, "%d%%", int(100*prc));
|
||||
win_draw_text(win(), r.left+width/2-CHARX, (r.bottom+r.top+CHARY)/2-3, n, -1);
|
||||
set_mode(M_COPY);
|
||||
|
||||
check_stop();
|
||||
}
|
||||
|
||||
void TIndwin::update()
|
||||
{
|
||||
if (_bar) update_bar();
|
||||
}
|
||||
|
||||
|
||||
void TIndwin::handler(WINDOW w, EVENT* e)
|
||||
{
|
||||
switch(e->type)
|
||||
{
|
||||
case E_UPDATE:
|
||||
clear_window(w, COLOR_WHITE);
|
||||
update();
|
||||
return;
|
||||
case E_CONTROL:
|
||||
if (e->v.ctl.id == DLG_CANCEL)
|
||||
dispatch_e_char(w, K_ESC);
|
||||
break;
|
||||
case E_CHAR:
|
||||
// allowed only if cancel button is there
|
||||
if (e->v.chr.ch == K_ESC)
|
||||
{
|
||||
if (_cancel)
|
||||
{
|
||||
_flags |= IND_CANCELLED;
|
||||
check_stop();
|
||||
}
|
||||
else return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
TWindow::handler(w,e);
|
||||
}
|
||||
|
||||
|
||||
// TProgind --------------------------------------------------------------
|
||||
|
||||
TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)
|
||||
: TIndwin(max, txt, cancel, bar, div)
|
||||
{}
|
||||
|
||||
// TTimerind ------------------------------------------------------------
|
||||
|
||||
long TTimerind::_timer_id = 0L;
|
||||
|
||||
void TTimerind::handler(WINDOW w, EVENT* e)
|
||||
{
|
||||
switch(e->type)
|
||||
{
|
||||
case E_CREATE:
|
||||
case E_UPDATE:
|
||||
if (_status == 0L)
|
||||
_timer_id = set_timer(w, _interval);
|
||||
break;
|
||||
case E_TIMER:
|
||||
if (e->v.timer.id == _timer_id)
|
||||
{
|
||||
_status += _interval;
|
||||
force_update();
|
||||
set_timer(w, _interval);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
TIndwin::handler(w,e);
|
||||
}
|
||||
|
||||
TTimerind::TTimerind(long msec, const char* txt,
|
||||
bool cancel, bool bar, int div, int i) :
|
||||
TIndwin(msec, txt, cancel, bar, div)
|
||||
{
|
||||
_interval = i;
|
||||
_timer_id = 0L;
|
||||
}
|
||||
|
||||
TTimerind::~TTimerind()
|
||||
{ kill_timer(_timer_id); }
|
||||
|
||||
// C-style binding
|
||||
// uses static pointer for single instance of TIndwin
|
||||
|
||||
static TIndwin* __indwin__p = NULL;
|
||||
|
||||
void progind_create(long m, char* t, bool b, bool c, int n)
|
||||
{
|
||||
CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator");
|
||||
__indwin__p = new TProgind(m,t,b,c,n);
|
||||
}
|
||||
|
||||
void progind_set_status(long l)
|
||||
{
|
||||
((TProgind*)__indwin__p)->setstatus(l);
|
||||
}
|
||||
|
||||
void progind_cancel()
|
||||
{
|
||||
__indwin__p->cancel();
|
||||
}
|
||||
|
||||
bool progind_iscancelled()
|
||||
{
|
||||
return __indwin__p->iscancelled();
|
||||
}
|
||||
|
||||
bool progind_isfinished()
|
||||
{
|
||||
return __indwin__p->isfinished();
|
||||
}
|
||||
|
||||
void progind_destroy()
|
||||
{
|
||||
delete __indwin__p;
|
||||
__indwin__p = NULL;
|
||||
}
|
||||
|
||||
void timerind_create(long l, char* title, bool bar, bool cancel,
|
||||
int divisions, int interval)
|
||||
{
|
||||
CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator");
|
||||
__indwin__p = new TTimerind(l,title,bar,cancel,divisions,interval);
|
||||
}
|
||||
|
||||
void timerind_cancel()
|
||||
{
|
||||
__indwin__p->cancel();
|
||||
}
|
||||
|
||||
bool timerind_iscancelled()
|
||||
{
|
||||
return __indwin__p->iscancelled();
|
||||
}
|
||||
|
||||
bool timerind_isfinished()
|
||||
{
|
||||
return __indwin__p->isfinished();
|
||||
}
|
||||
|
||||
void timerind_destroy()
|
||||
{
|
||||
delete __indwin__p;
|
||||
__indwin__p = NULL;
|
||||
}
|
||||
|
||||
// $Id: progind.cpp,v 1.2 1994-09-13 16:43:46 guy Exp $
|
||||
|
||||
#include <defmask.h>
|
||||
#include <progind.h>
|
||||
|
||||
const char* const CANCEL_TEXT = "Annulla";
|
||||
const char* const TITLE_TEXT = "Attesa";
|
||||
|
||||
// Certified 70%
|
||||
TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
|
||||
{
|
||||
_cancel = _bar = _text = NULL_WIN;
|
||||
|
||||
_status = 0l;
|
||||
_max = max;
|
||||
if (_max <= 0) _max = 1;
|
||||
_flags = 0x0;
|
||||
|
||||
word maxlen = div, lines;
|
||||
measure_text(txt, maxlen, lines);
|
||||
|
||||
int ver = lines+3;
|
||||
|
||||
int hor = maxlen+2; if (hor > 78) hor = 78;
|
||||
|
||||
if (bar)
|
||||
{
|
||||
_bar = ver * CHARY;
|
||||
ver += 3;
|
||||
}
|
||||
ver += cancel ? 3 : 0;
|
||||
|
||||
create(-1, -1, hor, ver, TITLE_TEXT);
|
||||
|
||||
RCT r; r.left = CHARX; r.top = CHARY; r.right = CHARX*(hor-2); r.bottom = r.top + lines*CHARY+4;
|
||||
_text = create_control(WC_TEXT, &r, (char*)txt, win(), CTL_FLAG_CENTER_JUST, 0l, DLG_NULL);
|
||||
|
||||
if (cancel)
|
||||
_cancel = xvt_create_control(WC_PUSHBUTTON, -11, -1, 9, 2,
|
||||
CANCEL_TEXT, win(), 0, 0l, DLG_CANCEL);
|
||||
open_modal();
|
||||
do_events();
|
||||
}
|
||||
|
||||
void TIndwin::set_text(const char* t)
|
||||
{
|
||||
set_title(_text, (char*)t);
|
||||
}
|
||||
|
||||
TIndwin::~TIndwin()
|
||||
{ close_modal(); }
|
||||
|
||||
|
||||
void TIndwin::measure_text(const char* txt, word& maxlen, word& lines) const
|
||||
{
|
||||
TToken_string s(txt, '\n');
|
||||
lines = 0;
|
||||
for(const char* t = s.get(0); t; t = s.get())
|
||||
{
|
||||
const word l = strlen(t);
|
||||
if (l > maxlen) maxlen = l;
|
||||
lines++;
|
||||
}
|
||||
}
|
||||
|
||||
bool TIndwin::can_be_closed() const
|
||||
{
|
||||
const bool ok = (_flags & IND_FINISHED) || (_flags & IND_CANCELLED);
|
||||
if (!ok) error_box("Attendere la fine dell'operazione prima di chiudere l'applicazione");
|
||||
return ok;
|
||||
}
|
||||
|
||||
KEY TIndwin::check_stop()
|
||||
{
|
||||
KEY k = 0;
|
||||
if ((_flags & IND_FINISHED) || (_flags & IND_CANCELLED))
|
||||
{
|
||||
k = (_flags & IND_FINISHED) ? K_ENTER : K_ESC;
|
||||
stop_run(k);
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
void TIndwin::update_bar()
|
||||
{
|
||||
if (_status >= _max)
|
||||
{
|
||||
_status = _max;
|
||||
_flags |= IND_FINISHED;
|
||||
}
|
||||
|
||||
const double prc = (double)_status/_max;
|
||||
|
||||
RCT r; get_client_rect(win(), &r);
|
||||
r.left = CHARX; r.right -= CHARX;
|
||||
r.top = (int)_bar;
|
||||
r.bottom = r.top + 3*CHARY;
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
r.top += 6;
|
||||
r.bottom -= 6;
|
||||
#endif
|
||||
const int width = r.right - r.left;
|
||||
|
||||
RCT b = r;
|
||||
set_brush(COLOR_BLUE);
|
||||
b.right = b.left + int(width*prc);
|
||||
win_draw_rect(win(), &b);
|
||||
|
||||
set_brush(COLOR_WHITE);
|
||||
b.left = b.right; b.right = r.right;
|
||||
win_draw_rect(win(), &b);
|
||||
|
||||
set_mode(M_XOR);
|
||||
win_set_fore_color(win(), COLOR_BLUE);
|
||||
char n[8]; sprintf(n, "%d%%", int(100*prc));
|
||||
win_draw_text(win(), r.left+width/2-CHARX, (r.bottom+r.top+CHARY)/2-3, n, -1);
|
||||
set_mode(M_COPY);
|
||||
|
||||
check_stop();
|
||||
}
|
||||
|
||||
void TIndwin::update()
|
||||
{
|
||||
if (_bar) update_bar();
|
||||
}
|
||||
|
||||
|
||||
void TIndwin::handler(WINDOW w, EVENT* e)
|
||||
{
|
||||
switch(e->type)
|
||||
{
|
||||
case E_UPDATE:
|
||||
clear_window(w, COLOR_WHITE);
|
||||
update();
|
||||
return;
|
||||
case E_CONTROL:
|
||||
if (e->v.ctl.id == DLG_CANCEL)
|
||||
dispatch_e_char(w, K_ESC);
|
||||
break;
|
||||
case E_CHAR:
|
||||
// allowed only if cancel button is there
|
||||
if (e->v.chr.ch == K_ESC)
|
||||
{
|
||||
if (_cancel)
|
||||
{
|
||||
_flags |= IND_CANCELLED;
|
||||
check_stop();
|
||||
}
|
||||
else return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
TWindow::handler(w,e);
|
||||
}
|
||||
|
||||
|
||||
// TProgind --------------------------------------------------------------
|
||||
|
||||
TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)
|
||||
: TIndwin(max, txt, cancel, bar, div)
|
||||
{}
|
||||
|
||||
// TTimerind ------------------------------------------------------------
|
||||
|
||||
long TTimerind::_timer_id = 0L;
|
||||
|
||||
void TTimerind::handler(WINDOW w, EVENT* e)
|
||||
{
|
||||
switch(e->type)
|
||||
{
|
||||
case E_CREATE:
|
||||
case E_UPDATE:
|
||||
if (_status == 0L)
|
||||
_timer_id = set_timer(w, _interval);
|
||||
break;
|
||||
case E_TIMER:
|
||||
if (e->v.timer.id == _timer_id)
|
||||
{
|
||||
_status += _interval;
|
||||
force_update();
|
||||
set_timer(w, _interval);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
TIndwin::handler(w,e);
|
||||
}
|
||||
|
||||
TTimerind::TTimerind(long msec, const char* txt,
|
||||
bool cancel, bool bar, int div, int i) :
|
||||
TIndwin(msec, txt, cancel, bar, div)
|
||||
{
|
||||
_interval = i;
|
||||
_timer_id = 0L;
|
||||
}
|
||||
|
||||
TTimerind::~TTimerind()
|
||||
{ kill_timer(_timer_id); }
|
||||
|
||||
// C-style binding
|
||||
// uses static pointer for single instance of TIndwin
|
||||
|
||||
static TIndwin* __indwin__p = NULL;
|
||||
|
||||
void progind_create(long m, char* t, bool b, bool c, int n)
|
||||
{
|
||||
CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator");
|
||||
__indwin__p = new TProgind(m,t,b,c,n);
|
||||
}
|
||||
|
||||
void progind_set_status(long l)
|
||||
{
|
||||
((TProgind*)__indwin__p)->setstatus(l);
|
||||
}
|
||||
|
||||
void progind_cancel()
|
||||
{
|
||||
__indwin__p->cancel();
|
||||
}
|
||||
|
||||
bool progind_iscancelled()
|
||||
{
|
||||
return __indwin__p->iscancelled();
|
||||
}
|
||||
|
||||
bool progind_isfinished()
|
||||
{
|
||||
return __indwin__p->isfinished();
|
||||
}
|
||||
|
||||
void progind_destroy()
|
||||
{
|
||||
delete __indwin__p;
|
||||
__indwin__p = NULL;
|
||||
}
|
||||
|
||||
void timerind_create(long l, char* title, bool bar, bool cancel,
|
||||
int divisions, int interval)
|
||||
{
|
||||
CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator");
|
||||
__indwin__p = new TTimerind(l,title,bar,cancel,divisions,interval);
|
||||
}
|
||||
|
||||
void timerind_cancel()
|
||||
{
|
||||
__indwin__p->cancel();
|
||||
}
|
||||
|
||||
bool timerind_iscancelled()
|
||||
{
|
||||
return __indwin__p->iscancelled();
|
||||
}
|
||||
|
||||
bool timerind_isfinished()
|
||||
{
|
||||
return __indwin__p->isfinished();
|
||||
}
|
||||
|
||||
void timerind_destroy()
|
||||
{
|
||||
delete __indwin__p;
|
||||
__indwin__p = NULL;
|
||||
}
|
||||
|
||||
|
@ -1,143 +1,145 @@
|
||||
/* $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 */
|
||||
/* $Id: progind.h,v 1.2 1994-09-13 16:43:47 guy 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(); }
|
||||
|
||||
virtual bool can_be_closed() const;
|
||||
/* @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 */
|
||||
|
@ -1,4 +1,4 @@
|
||||
// $Id: relapp.cpp,v 1.7 1994-09-02 15:16:50 alex Exp $
|
||||
// $Id: relapp.cpp,v 1.8 1994-09-13 16:43:48 guy Exp $
|
||||
#include <mailbox.h>
|
||||
#include <sheet.h>
|
||||
#include <urldefid.h>
|
||||
@ -482,7 +482,7 @@ bool TRelation_application::test_key(byte k, bool err)
|
||||
if (err)
|
||||
{
|
||||
_mask->first_focus(-c.dlg());
|
||||
error_box("Manca un valore indispensabile");
|
||||
error_box("Manca un valore indispensabile per la ricerca");
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@ -494,7 +494,7 @@ bool TRelation_application::test_key(byte k, bool err)
|
||||
if (k == 1 && !onereq && !onefill)
|
||||
{
|
||||
if (err)
|
||||
error_box("Manca un valore indispensabile");
|
||||
error_box("Manca un valore indispensabile per la ricerca");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
|
||||
TWindow* cur_win() const { return (_current < 0) ? NULL : _window[_current]; } // Ritorna il puntatore alla finestra corrente
|
||||
void destroy();
|
||||
bool can_close() const { return _current < 1; }
|
||||
bool can_close() const;
|
||||
} WinManager;
|
||||
|
||||
|
||||
@ -58,6 +58,15 @@ void TWindow_manager::destroy()
|
||||
}
|
||||
}
|
||||
|
||||
bool TWindow_manager::can_close() const
|
||||
{
|
||||
bool ok = TRUE;
|
||||
if (_current >= 0)
|
||||
ok = cur_win()->can_be_closed();
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
// Dis/abilitazione del menu principale
|
||||
HIDDEN void xvt_menu_enable(MENU_ITEM* m, bool on)
|
||||
{
|
||||
@ -107,10 +116,15 @@ void TWindow_manager::reg(TWindow* m)
|
||||
|
||||
switch (_current)
|
||||
{
|
||||
case 0 : menu_enable(FALSE); break;
|
||||
case 1 : win_menu_enable(TASK_WIN, M_FILE_QUIT, FALSE);
|
||||
default: _window[_current-1]->disable(); break;
|
||||
}
|
||||
case 0 :
|
||||
menu_enable(FALSE);
|
||||
break;
|
||||
case 1 :
|
||||
win_menu_enable(TASK_WIN, M_FILE_QUIT, _current < 1);
|
||||
break;
|
||||
default:
|
||||
_window[_current-1]->disable(); break;
|
||||
}
|
||||
|
||||
_window[_current] = m;
|
||||
}
|
||||
@ -121,20 +135,22 @@ void TWindow_manager::unreg(const TWindow* m)
|
||||
#ifdef DBG
|
||||
if (m != cur_win())
|
||||
{
|
||||
error_box("You can unregister the current window only");
|
||||
yesnofatal_box("You can unregister the current window only");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
_current--;
|
||||
|
||||
if (_current < 0)
|
||||
if (_current <= 0)
|
||||
{
|
||||
menu_enable(TRUE);
|
||||
win_menu_enable(TASK_WIN, M_FILE_QUIT, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_current == 0)
|
||||
win_menu_enable(TASK_WIN, M_FILE_QUIT, TRUE);
|
||||
cur_win()->enable();
|
||||
win_menu_enable(TASK_WIN, M_FILE_QUIT, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,7 +201,7 @@ WINDOW TWindow::create(short x, short y, short dx, short dy,
|
||||
{
|
||||
flags |= WSF_NO_MENUBAR;
|
||||
|
||||
if (parent == NULL_WIN) parent = TASK_WIN;
|
||||
if (parent == NULL_WIN) parent = TASK_WIN;
|
||||
if (parent == TASK_WIN) flags |= WSF_INVISIBLE;
|
||||
|
||||
_win = xvt_create_window(
|
||||
@ -241,7 +257,6 @@ void TWindow::close()
|
||||
void TWindow::close_modal()
|
||||
{
|
||||
WinManager.unreg(this);
|
||||
|
||||
close();
|
||||
_open = FALSE;
|
||||
}
|
||||
@ -253,6 +268,13 @@ bool TWindow::stop_run(KEY key)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TWindow::can_be_closed() const
|
||||
{
|
||||
const bool ok = !is_modal();
|
||||
if (!ok)
|
||||
error_box("Chiudere la finestra attiva prima di uscire dal programma");
|
||||
return ok;
|
||||
}
|
||||
|
||||
KEY TWindow::run()
|
||||
{
|
||||
|
@ -104,6 +104,7 @@ public:
|
||||
|
||||
virtual void open(); // Mostra la finestra
|
||||
virtual void close(); // Nasconde la finestra
|
||||
virtual bool can_be_closed() const; // Puo' essere chiusa brutalmente?
|
||||
|
||||
void iconize() const;
|
||||
void maximize() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user