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:
guy 1994-09-13 16:43:52 +00:00
parent 5c70586f90
commit 8097b5d8eb
15 changed files with 751 additions and 683 deletions

View File

@ -170,7 +170,7 @@ void TApplication::about() const
{ {
#include <prassi.ver> #include <prassi.ver>
const TFilename n(__argv[0]); 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__); VERSION, (const char*)n.name(), __DATE__);
} }
@ -196,7 +196,8 @@ long TApplication::handler(WINDOW, EVENT* ep)
switch(mt) switch(mt)
{ {
case M_FILE_QUIT: case M_FILE_QUIT:
stop_run(); if (can_close())
stop_run();
break; break;
case M_FILE_PG_SETUP: case M_FILE_PG_SETUP:
printer().set(); printer().set();
@ -232,10 +233,9 @@ long TApplication::handler(WINDOW, EVENT* ep)
{ {
if (can_close()) if (can_close())
quit_OK(); quit_OK();
else
error_box("Chiudere la finestra attiva prima di terminare il programma");
} }
else stop_run(); else
stop_run();
break; break;
default: default:
break; break;
@ -335,16 +335,11 @@ const char* TApplication::get_module_name() const
return module; 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) void TApplication::run(int argc, char* argv[], const char* title)
{ {
TFilename base(argv[0]); TFilename base(argv[0]);
base.ext(""); base.lower(); base.ext(""); base.lower();
_title = title;
__argc = argc; __argc = argc;
__argv = (const char**)argv; __argv = (const char**)argv;
@ -364,8 +359,8 @@ void TApplication::run(int argc, char* argv[], const char* title)
TString80 caption; TString80 caption;
caption << "PRASSI S.P.A. - " << get_module_name(); caption << "PRASSI S.P.A. - " << get_module_name();
cfg.base_appl_name = (char*) base.name(); cfg.base_appl_name = (char*)base.name();
cfg.appl_name = (char*) title; cfg.appl_name = (char*)(const char*)_title;
cfg.taskwin_title = (char*)(const char*)caption; cfg.taskwin_title = (char*)(const char*)caption;
cfg.menu_bar_ID = TASK_MENUBAR+addbar; cfg.menu_bar_ID = TASK_MENUBAR+addbar;
cfg.about_box_ID = 0; cfg.about_box_ID = 0;

View File

@ -28,7 +28,7 @@ class TApplication
int __argc; int __argc;
const char** __argv; const char** __argv;
TString _name; TString80 _name, _title;
TPrinter* _printer; TPrinter* _printer;
protected: protected:
@ -67,8 +67,8 @@ public:
const char* argv(int i) const { return __argv[i]; } const char* argv(int i) const { return __argv[i]; }
int argc() const { return __argc; } int argc() const { return __argc; }
void set_title(const char* t); void set_title(const char* t) { _title = t; }
const char* title() const; const char* title() const { return _title; }
void wait_for(const char* name); void wait_for(const char* name);
void wake_up_caller() const; void wake_up_caller() const;

View File

@ -620,13 +620,13 @@ void TPush_button::draw_pressed(bool pressed) const
win_set_fore_color(_hdc, COLOR_WHITE); win_set_fore_color(_hdc, COLOR_WHITE);
win_draw_text(_hdc, _dx+p+1, _dy+p+1, (char*)t, -1); win_draw_text(_hdc, _dx+p+1, _dy+p+1, (char*)t, -1);
if (_accel >= 0) 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; const COLOR c = disabled() ? DISABLED_COLOR : NORMAL_COLOR;
win_set_fore_color(_hdc, c); win_set_fore_color(_hdc, c);
win_draw_text(_hdc, _dx+p, _dy+p, (char*)t, -1); win_draw_text(_hdc, _dx+p, _dy+p, (char*)t, -1);
if (_accel >= 0) if (_accel >= 0)
win_draw_text(_hdc, _dx+_accel+p, _dy+p, "_", 1); win_draw_text(_hdc, _dx+_accel+p, _dy+p+2, "_", 1);
} }
} }

View File

@ -83,6 +83,16 @@ void TMask::control_handler(EVENT* ep)
return; 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) if (ep->v.ctl.ci.v.edit.focus_change)
{ {
if (ep->v.ctl.ci.v.edit.active) if (ep->v.ctl.ci.v.edit.active)
@ -353,6 +363,14 @@ int TMask::first_focus(short id)
return f; 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() void TMask::close()
{ {
_open = FALSE; _open = FALSE;
@ -528,12 +546,22 @@ TMask_field& TMask::field(short id) const
return fld(pos); 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 int TMask::find_field_win(WINDOW win) const
{ {
if (fld(_focus).win() == win)
return _focus;
const int max = fields(); const int max = fields();
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
if (fld(i).win() == win) return i; if (fld(i).win() == win) return i;
#ifdef DBG #ifdef DBG
yesnofatal_box("Can't find the field given the child window"); yesnofatal_box("Can't find the field given the child window");
#endif #endif

View File

@ -119,7 +119,7 @@ public:
bool check_fields(); bool check_fields();
void get_mask_fields(); // read screen contents void get_mask_fields(); // read screen contents
virtual bool stop_run(KEY key); // called to close the mask virtual bool stop_run(KEY key); // called to close the mask
virtual bool can_be_closed() const;
virtual void open(); virtual void open();
virtual void close(); virtual void close();
@ -128,6 +128,7 @@ public:
int id2pos(short id) const; 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& 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 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, const char* str, bool hit=FALSE);
void set(short fld_id, long num, bool hit=FALSE); void set(short fld_id, long num, bool hit=FALSE);

View File

@ -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 <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -1843,9 +1843,10 @@ bool TEdit_field::on_key(KEY key)
switch(key) switch(key)
{ {
case K_TAB: 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) _validate_func == STRCALC_FUNC)
set_focusdirty(); set_focusdirty(); // Forza validate
if (to_check(K_TAB, TRUE)) if (to_check(K_TAB, TRUE))
{ {
set(get()); set(get());

View File

@ -1 +1 @@
#define VERSION 1.2 #define VERSION 1.1

View File

@ -210,14 +210,24 @@ bool TPrefix::set_codditta(long codditta, bool force)
put(); put();
return TRUE; return TRUE;
} }
else return FALSE; return FALSE;
} }
// Restituisce il nome di una directory dati
// Certified 90%
const char* firm2dir(long codditta) const char* firm2dir(long codditta)
{ {
TFixed_string dir(__tmp_string, 256); 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); dir.insert(__ptprf, 0);
return __tmp_string; return __tmp_string;
} }

View File

@ -5,85 +5,85 @@
void TPrintwin::paint_background(long j) void TPrintwin::paint_background(long j)
{ {
_isbackground = _bg->items() > 0 && MainApp()->printer().isgraphics(); _isbackground = _bg->items() > 0 && MainApp()->printer().isgraphics();
if (!_isbackground) return; if (!_isbackground) return;
int rw = (int)(j % _formlen); int rw = (int)(j % _formlen);
TString& rwd = (TString&)(*_bg)[rw]; TString& rwd = (TString&)(*_bg)[rw];
int cnt = 0; char ch; int cnt = 0; char ch;
char curcol = 'n'; char curcol = 'n';
char curpen = 'n'; char curpen = 'n';
char curpat = 'n'; char curpat = 'n';
char curwid = '1'; char curwid = '1';
unsigned int x1, x2; PNT b, e; unsigned int x1, x2; PNT b, e;
while (ch = rwd[cnt++]) while (ch = rwd[cnt++])
{ {
switch(ch) switch(ch)
{ {
case 'v': // verticale intera case 'v': // verticale intera
x1 = (unsigned char)rwd[cnt++]-1; x1 = (unsigned char)rwd[cnt++]-1;
b.h = e.h = x1*_charx+_charx/2+_hofs; b.h = e.h = x1*_charx+_charx/2+_hofs;
b.v = rw * _chary + _vofs; e.v = rw * _chary + _vofs; b.v = rw * _chary + _vofs; e.v = rw * _chary + _vofs;
win_move_to(win(),b); win_move_to(win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
break; break;
case 'o': // verticale pezzo sopra case 'o': // verticale pezzo sopra
x1 = (unsigned char)rwd[cnt++]-1; x1 = (unsigned char)rwd[cnt++]-1;
b.h = e.h = x1*_charx+_charx/2 + _hofs; b.h = e.h = x1*_charx+_charx/2 + _hofs;
b.v = rw * _chary + _vofs; e.v = rw * _chary - _chary/2 + _vofs; b.v = rw * _chary + _vofs; e.v = rw * _chary - _chary/2 + _vofs;
win_move_to(win(),b); win_move_to(win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
break; break;
case 'u': // verticale pezzo sotto case 'u': // verticale pezzo sotto
x1 = (unsigned char)rwd[cnt++]-1; x1 = (unsigned char)rwd[cnt++]-1;
b.h = e.h = x1*_charx+_charx/2 + _hofs; b.h = e.h = x1*_charx+_charx/2 + _hofs;
b.v = rw*_chary + _chary/2 + _vofs; e.v = rw * _chary + _vofs; b.v = rw*_chary + _chary/2 + _vofs; e.v = rw * _chary + _vofs;
win_move_to(win(),b); win_move_to(win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
break; break;
case 'h': // orizzontale intera case 'h': // orizzontale intera
x1 = (unsigned char)rwd[cnt++]-1; x1 = (unsigned char)rwd[cnt++]-1;
x2 = (unsigned char)rwd[cnt++]-1; x2 = (unsigned char)rwd[cnt++]-1;
b.v = e.v = rw*_chary + _chary/2 + _vofs; b.v = e.v = rw*_chary + _chary/2 + _vofs;
b.h = x1*_charx+_hofs; e.h = x2*_charx + _hofs; b.h = x1*_charx+_hofs; e.h = x2*_charx + _hofs;
win_move_to(win(),b); win_move_to(win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
break; break;
case 'r': // orizzontale scorciata agli estremi case 'r': // orizzontale scorciata agli estremi
x1 = (unsigned char)rwd[cnt++]-1; x1 = (unsigned char)rwd[cnt++]-1;
x2 = (unsigned char)rwd[cnt++]-1; x2 = (unsigned char)rwd[cnt++]-1;
b.v = e.v = rw*_chary + _chary/2 + _vofs; b.v = e.v = rw*_chary + _chary/2 + _vofs;
b.h = x1*_charx+_charx/2 + _hofs; e.h = x2*_charx+_charx/2+_hofs; b.h = x1*_charx+_charx/2 + _hofs; e.h = x2*_charx+_charx/2+_hofs;
win_move_to(win(),b); win_move_to(win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
break; break;
case 'W': case 'W':
curwid = rwd[cnt++]; curwid = rwd[cnt++];
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat), set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
trans_pen(curpen)); trans_pen(curpen));
break; break;
case 'P': case 'P':
curpen = rwd[cnt++]; curpen = rwd[cnt++];
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat), set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
trans_pen(curpen)); trans_pen(curpen));
break; break;
case 'B': case 'B':
curpat = rwd[cnt++]; curpat = rwd[cnt++];
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat), set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
trans_pen(curpen)); trans_pen(curpen));
break; break;
case 'C': case 'C':
curcol = rwd[cnt++]; curcol = rwd[cnt++];
set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat), set_pen(trans_color(curcol), curwid- '0', trans_brush(curpat),
trans_pen(curpen)); trans_pen(curpen));
break; break;
default: default:
break; break;
} }
} }
// restore default pen // restore default pen
set_pen(COLOR_BLACK); set_pen(COLOR_BLACK);
} }
void TPrintwin::paint_row(long j) void TPrintwin::paint_row(long j)
@ -92,98 +92,98 @@ void TPrintwin::paint_row(long j)
int row = (int)(j % _formlen); int row = (int)(j % _formlen);
_txt.read_line(j); _txt.read_line(j);
while(cp = _txt.piece()) while(cp = _txt.piece())
{ {
#if XVT_OS != XVT_OS_SCOUNIX #if XVT_OS != XVT_OS_SCOUNIX
int st = _txt.get_style(); int st = _txt.get_style();
long bg = trans_color(_txt.get_background()); long bg = trans_color(_txt.get_background());
long fg = trans_color(_txt.get_foreground()); long fg = trans_color(_txt.get_foreground());
set_font(FF_FIXED, st & 0x000f, _char_size); set_font(FF_FIXED, st & 0x000f, _char_size);
set_color(fg,bg); set_color(fg,bg);
#else #else
set_color(COLOR_BLACK, COLOR_WHITE); set_color(COLOR_BLACK, COLOR_WHITE);
#endif #endif
win_draw_text(win(), pos*_charx + _hofs, row*_chary + _chary + _vofs - _descent, win_draw_text(win(), pos*_charx + _hofs, row*_chary + _chary + _vofs - _descent,
(char *)cp, -1); (char *)cp, -1);
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
if (st & underlined) if (st & underlined)
{ {
PNT b, e; PNT b, e;
set_pen(COLOR_BLACK); set_pen(COLOR_BLACK);
b.h = _charx*pos + _hofs; b.v = row*_chary + _chary + _vofs; b.h = _charx*pos + _hofs; b.v = row*_chary + _chary + _vofs;
e.h = _charx*(pos+strlen(cp)) + _hofs; e.v = b.v; e.h = _charx*(pos+strlen(cp)) + _hofs; e.v = b.v;
win_move_to (win(),b); win_move_to (win(),b);
win_draw_line(win(),e); win_draw_line(win(),e);
} }
#endif #endif
pos += strlen(cp); pos += strlen(cp);
} }
paint_background(j); paint_background(j);
} }
bool TPrintwin::print_band(int page, RCT& r) bool TPrintwin::print_band(int page, RCT& r)
{ {
int j = page*_formlen; int j = page*_formlen;
int rows = (r.bottom - r.top) / _chary; int rows = (r.bottom - r.top) / _chary;
int top = r.top / _chary; int top = r.top / _chary;
for (int k = top; k < top+rows; k++) for (int k = top; k < top+rows; k++)
{ {
if ((j+k) < _txt.lines() && k < _formlen) if ((j+k) < _txt.lines() && k < _formlen)
paint_row(j+k); paint_row(j+k);
else break; else break;
} }
return j+k < _txt.lines(); return j+k < _txt.lines();
} }
bool TPrintwin::do_print() bool TPrintwin::do_print()
{ {
int page = 0; int page = 0;
RCT* rct; RCT* rct;
bool ok = TRUE; bool ok = TRUE;
while (ok && !_aborted) while (ok && !_aborted)
{ {
_aborted = !(bool)start_page(_printrcd); _aborted = !(bool)start_page(_printrcd);
while (!_aborted && ok && (rct = next_band()) != NULL) while (!_aborted && ok && (rct = next_band()) != NULL)
ok = print_band(page, *rct); ok = print_band(page, *rct);
finish_page(_printrcd); finish_page(_printrcd);
page++; page++;
} }
return !_aborted; return !_aborted;
} }
TPrintwin::~TPrintwin() TPrintwin::~TPrintwin()
{ {
close_print_window(win(), _printrcd); close_print_window(win(), _printrcd);
set_win(NULL_WIN); set_win(NULL_WIN);
} }
TPrintwin::TPrintwin(PRINT_RCD* p, TTextfile& txt, int chsz) : TPrintwin::TPrintwin(PRINT_RCD* p, TTextfile& txt, int chsz) :
_printrcd(p), _aborted(FALSE), _txt(txt), _char_size(chsz) _printrcd(p), _aborted(FALSE), _txt(txt), _char_size(chsz)
{ {
WINDOW w = new_print_window(_printrcd, (char*)MainApp()->title()); WINDOW w = new_print_window(_printrcd, (char*)MainApp()->title());
set_win(w); set_win(w);
if (w != NULL_WIN) if (w != NULL_WIN)
{ {
_bg = MainApp()->printer().getbgdesc(); _bg = MainApp()->printer().getbgdesc();
_isbackground = _bg->items() > 0 && MainApp()->printer().isgraphics(); _isbackground = _bg->items() > 0 && MainApp()->printer().isgraphics();
_formlen = MainApp()->printer().formlen(); _formlen = MainApp()->printer().formlen();
set_font(FF_SYSTEM,0,_char_size); set_font(FF_SYSTEM,0,_char_size);
win_get_font_metrics(win(), &_lead, &_ascent, &_descent); win_get_font_metrics(win(), &_lead, &_ascent, &_descent);
_charx = win_get_text_width(win(), "MM", -1) - win_get_text_width(win(), "M", -1); _charx = win_get_text_width(win(), "MM", -1) - win_get_text_width(win(), "M", -1);
_chary = MainApp()->printer().get_dots_per_line(); _chary = MainApp()->printer().get_dots_per_line();
RCT rct; get_client_rect(win(),&rct); RCT rct; get_client_rect(win(),&rct);
_vofs = MainApp()->printer().get_vert_offset(); _vofs = MainApp()->printer().get_vert_offset();
_hofs = (rct.right - rct.left) % _charx; _hofs = (rct.right - rct.left) % _charx;
} }
else _aborted = TRUE; else _aborted = TRUE;
} }

View File

@ -16,34 +16,36 @@
class TPrintwin : public TWindow class TPrintwin : public TWindow
{ {
bool _aborted; bool _aborted;
bool _isbackground; bool _isbackground;
PRINT_RCD* _printrcd; PRINT_RCD* _printrcd;
int _formlen; int _formlen;
int _formwidth; int _formwidth;
TArray* _bg; TArray* _bg;
TTextfile& _txt; TTextfile& _txt;
int _lead, _ascent, _descent; int _lead, _ascent, _descent;
int _hofs, _vofs; int _hofs, _vofs;
int _charx, _chary; int _charx, _chary;
int _char_size; int _char_size;
void paint_background(long j); void paint_background(long j);
void paint_row(long j); void paint_row(long j);
bool print_band(int, RCT&); bool print_band(int, RCT&);
public: public:
// check if aborted; also returned by do_print // check if aborted; also returned by do_print
bool aborted() { return _aborted; } 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); // inhibits background printing
virtual ~TPrintwin(); 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();
}; };

View File

@ -1,4 +1,4 @@
// $Id: progind.cpp,v 1.1.1.1 1994-08-12 10:52:04 alex Exp $ // $Id: progind.cpp,v 1.2 1994-09-13 16:43:46 guy Exp $
#include <defmask.h> #include <defmask.h>
#include <progind.h> #include <progind.h>
@ -37,7 +37,7 @@ TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
if (cancel) if (cancel)
_cancel = xvt_create_control(WC_PUSHBUTTON, -11, -1, 9, 2, _cancel = xvt_create_control(WC_PUSHBUTTON, -11, -1, 9, 2,
CANCEL_TEXT, win(), 0, 0l, DLG_CANCEL); CANCEL_TEXT, win(), 0, 0l, DLG_CANCEL);
open_modal(); open_modal();
do_events(); do_events();
} }
@ -63,25 +63,31 @@ void TIndwin::measure_text(const char* txt, word& maxlen, word& lines) const
} }
} }
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 TIndwin::check_stop()
{ {
KEY k = 0; KEY k = 0;
if (_flags & IND_FINISHED || _flags & IND_CANCELLED) if ((_flags & IND_FINISHED) || (_flags & IND_CANCELLED))
{ {
k = (_flags & IND_FINISHED) ? K_ENTER : K_ESC; k = (_flags & IND_FINISHED) ? K_ENTER : K_ESC;
stop_run(k); stop_run(k);
} }
return k; return k;
} }
void TIndwin::update_bar() void TIndwin::update_bar()
{ {
if (_status >= _max) if (_status >= _max)
{ {
_status = _max; _status = _max;
_flags |= IND_FINISHED; _flags |= IND_FINISHED;
} }
const double prc = (double)_status/_max; const double prc = (double)_status/_max;
@ -123,28 +129,28 @@ void TIndwin::handler(WINDOW w, EVENT* e)
{ {
switch(e->type) switch(e->type)
{ {
case E_UPDATE: case E_UPDATE:
clear_window(w, COLOR_WHITE); clear_window(w, COLOR_WHITE);
update(); update();
return; return;
case E_CONTROL: case E_CONTROL:
if (e->v.ctl.id == DLG_CANCEL) if (e->v.ctl.id == DLG_CANCEL)
dispatch_e_char(w, K_ESC); dispatch_e_char(w, K_ESC);
break; break;
case E_CHAR: case E_CHAR:
// allowed only if cancel button is there // allowed only if cancel button is there
if (e->v.chr.ch == K_ESC) if (e->v.chr.ch == K_ESC)
{
if (_cancel)
{ {
if (_cancel) _flags |= IND_CANCELLED;
{ check_stop();
_flags |= IND_CANCELLED; }
check_stop(); else return;
} }
else return; break;
} default:
break; break;
default:
break;
} }
TWindow::handler(w,e); TWindow::handler(w,e);
} }
@ -153,7 +159,7 @@ void TIndwin::handler(WINDOW w, EVENT* e)
// TProgind -------------------------------------------------------------- // TProgind --------------------------------------------------------------
TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div) TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)
: TIndwin(max, txt, cancel, bar, div) : TIndwin(max, txt, cancel, bar, div)
{} {}
// TTimerind ------------------------------------------------------------ // TTimerind ------------------------------------------------------------
@ -164,28 +170,28 @@ void TTimerind::handler(WINDOW w, EVENT* e)
{ {
switch(e->type) switch(e->type)
{ {
case E_CREATE: case E_CREATE:
case E_UPDATE: case E_UPDATE:
if (_status == 0L) if (_status == 0L)
_timer_id = set_timer(w, _interval); _timer_id = set_timer(w, _interval);
break; break;
case E_TIMER: case E_TIMER:
if (e->v.timer.id == _timer_id) if (e->v.timer.id == _timer_id)
{ {
_status += _interval; _status += _interval;
force_update(); force_update();
set_timer(w, _interval); set_timer(w, _interval);
} }
break; break;
default: default:
break; break;
} }
TIndwin::handler(w,e); TIndwin::handler(w,e);
} }
TTimerind::TTimerind(long msec, const char* txt, TTimerind::TTimerind(long msec, const char* txt,
bool cancel, bool bar, int div, int i) : bool cancel, bool bar, int div, int i) :
TIndwin(msec, txt, cancel, bar, div) TIndwin(msec, txt, cancel, bar, div)
{ {
_interval = i; _interval = i;
_timer_id = 0L; _timer_id = 0L;
@ -232,7 +238,7 @@ void progind_destroy()
} }
void timerind_create(long l, char* title, bool bar, bool cancel, void timerind_create(long l, char* title, bool bar, bool cancel,
int divisions, int interval) int divisions, int interval)
{ {
CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator"); CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator");
__indwin__p = new TTimerind(l,title,bar,cancel,divisions,interval); __indwin__p = new TTimerind(l,title,bar,cancel,divisions,interval);

View File

@ -1,4 +1,4 @@
/* $Id: progind.h,v 1.1.1.1 1994-08-12 10:52:04 alex Exp $ */ /* $Id: progind.h,v 1.2 1994-09-13 16:43:47 guy Exp $ */
/* @N /* @N
progind.h progind.h
@ -6,7 +6,7 @@
fv 20/8/93 fv 20/8/93
works for both C and C++ works for both C and C++
@END @END
*/ */
#ifdef __cplusplus #ifdef __cplusplus
#ifndef __PROGIND_H #ifndef __PROGIND_H
@ -21,24 +21,24 @@
#endif #endif
/* /*
@C @C
class TIndwin : public TWindow class TIndwin : public TWindow
@END @END
*/ */
class TIndwin : public TWindow class TIndwin : public TWindow
{ {
/* @DPRIV */ /* @DPRIV */
enum { IND_CANCELLED = 0x01, IND_FINISHED= 0x02 }; enum { IND_CANCELLED = 0x01, IND_FINISHED= 0x02 };
WINDOW _text; // Static text WINDOW _text; // Static text
WINDOW _cancel; // CANCEL button WINDOW _cancel; // CANCEL button
WINDOW _bar; // Moving bar and percentage WINDOW _bar; // Moving bar and percentage
byte _flags; byte _flags;
/* @END */ /* @END */
protected: protected:
/* @FPROT */ /* @FPROT */
long _max; // maximum value to reach long _max; // maximum value to reach
long _status; // current status (set by user) long _status; // current status (set by user)
@ -51,13 +51,15 @@ class TIndwin : public TWindow
void update_bar(); void update_bar();
KEY check_stop(); KEY check_stop();
public: public:
/* @FPUB */ /* @FPUB */
bool iscancelled() const { return _flags & IND_CANCELLED; } bool iscancelled() const { return _flags & IND_CANCELLED; }
bool isfinished() const { return _flags & IND_FINISHED; } bool isfinished() const { return _flags & IND_FINISHED; }
long status() const { return _status; } long status() const { return _status; }
void cancel() { _flags |= IND_CANCELLED; check_stop(); } void cancel() { _flags |= IND_CANCELLED; check_stop(); }
/* @END */
virtual bool can_be_closed() const;
/* @END */
/* @LONGDES /* @LONGDES
si puo' chiamare settext() per cambiare il testo, ma si puo' chiamare settext() per cambiare il testo, ma
@ -67,50 +69,50 @@ class TIndwin : public TWindow
@END */ @END */
void set_text(const char* t); void set_text(const char* t);
/* FPUB */ /* FPUB */
TIndwin(long max, const char* txt, bool cancel = TRUE, bool bar = TRUE, int div = 16); TIndwin(long max, const char* txt, bool cancel = TRUE, bool bar = TRUE, int div = 16);
virtual ~TIndwin(); virtual ~TIndwin();
}; };
/* /*
@C @C
class TProgind : public TIndwin class TProgind : public TIndwin
@END @END
*/ */
class TProgind : public TIndwin class TProgind : public TIndwin
{ {
public: public:
/* @FPUB */ /* @FPUB */
void setmax(long m) { _max = m; } void setmax(long m) { _max = m; }
void setstatus(long l) { _status = l; update_bar(); do_events(); } void setstatus(long l) { _status = l; update_bar(); do_events(); }
void addstatus(long l) { setstatus(_status+l); } void addstatus(long l) { setstatus(_status+l); }
TProgind(long max, const char* txt = NULL, bool cancel = TRUE, TProgind(long max, const char* txt = NULL, bool cancel = TRUE,
bool bar = TRUE, int div = 10); bool bar = TRUE, int div = 10);
virtual ~TProgind() {} virtual ~TProgind() {}
}; };
/* /*
@C @C
class TTimerind : public TIndwin class TTimerind : public TIndwin
@END @END
*/ */
class TTimerind : public TIndwin class TTimerind : public TIndwin
{ {
/* @DPRIV */ /* @DPRIV */
int _interval; int _interval;
static long _timer_id; static long _timer_id;
protected: protected:
/* @FPROT */ /* @FPROT */
virtual void handler(WINDOW w, EVENT* e); virtual void handler(WINDOW w, EVENT* e);
public: public:
/* @FPUB */ /* @FPUB */
TTimerind(long msec, const char* txt = NULL, bool cancel = TRUE, TTimerind(long msec, const char* txt = NULL, bool cancel = TRUE,
bool bar = TRUE, int div = 10, int interval = 1000); bool bar = TRUE, int div = 10, int interval = 1000);
virtual ~TTimerind(); virtual ~TTimerind();
}; };
@ -124,9 +126,9 @@ class TTimerind : public TIndwin
extern "C" { extern "C" {
#endif #endif
void progind_create(long, char*, bool, bool, int); void progind_create(long, char*, bool, bool, int);
void progind_set_status(long); void progind_set_status(long);
void progind_cancel(); void progind_cancel();
bool progind_iscancelled(); bool progind_iscancelled();
bool progind_isfinished(); bool progind_isfinished();
void progind_destroy(); void progind_destroy();

View File

@ -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 <mailbox.h>
#include <sheet.h> #include <sheet.h>
#include <urldefid.h> #include <urldefid.h>
@ -482,7 +482,7 @@ bool TRelation_application::test_key(byte k, bool err)
if (err) if (err)
{ {
_mask->first_focus(-c.dlg()); _mask->first_focus(-c.dlg());
error_box("Manca un valore indispensabile"); error_box("Manca un valore indispensabile per la ricerca");
} }
return FALSE; return FALSE;
} }
@ -494,7 +494,7 @@ bool TRelation_application::test_key(byte k, bool err)
if (k == 1 && !onereq && !onefill) if (k == 1 && !onereq && !onefill)
{ {
if (err) if (err)
error_box("Manca un valore indispensabile"); error_box("Manca un valore indispensabile per la ricerca");
return FALSE; return FALSE;
} }
return TRUE; return TRUE;

View File

@ -40,7 +40,7 @@ public:
TWindow* cur_win() const { return (_current < 0) ? NULL : _window[_current]; } // Ritorna il puntatore alla finestra corrente TWindow* cur_win() const { return (_current < 0) ? NULL : _window[_current]; } // Ritorna il puntatore alla finestra corrente
void destroy(); void destroy();
bool can_close() const { return _current < 1; } bool can_close() const;
} WinManager; } 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 // Dis/abilitazione del menu principale
HIDDEN void xvt_menu_enable(MENU_ITEM* m, bool on) HIDDEN void xvt_menu_enable(MENU_ITEM* m, bool on)
{ {
@ -107,10 +116,15 @@ void TWindow_manager::reg(TWindow* m)
switch (_current) switch (_current)
{ {
case 0 : menu_enable(FALSE); break; case 0 :
case 1 : win_menu_enable(TASK_WIN, M_FILE_QUIT, FALSE); menu_enable(FALSE);
default: _window[_current-1]->disable(); break; break;
} case 1 :
win_menu_enable(TASK_WIN, M_FILE_QUIT, _current < 1);
break;
default:
_window[_current-1]->disable(); break;
}
_window[_current] = m; _window[_current] = m;
} }
@ -121,20 +135,22 @@ void TWindow_manager::unreg(const TWindow* m)
#ifdef DBG #ifdef DBG
if (m != cur_win()) if (m != cur_win())
{ {
error_box("You can unregister the current window only"); yesnofatal_box("You can unregister the current window only");
return; return;
} }
#endif #endif
_current--; _current--;
if (_current < 0) if (_current <= 0)
{
menu_enable(TRUE); menu_enable(TRUE);
win_menu_enable(TASK_WIN, M_FILE_QUIT, TRUE);
}
else else
{ {
if (_current == 0)
win_menu_enable(TASK_WIN, M_FILE_QUIT, TRUE);
cur_win()->enable(); 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; 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; if (parent == TASK_WIN) flags |= WSF_INVISIBLE;
_win = xvt_create_window( _win = xvt_create_window(
@ -241,7 +257,6 @@ void TWindow::close()
void TWindow::close_modal() void TWindow::close_modal()
{ {
WinManager.unreg(this); WinManager.unreg(this);
close(); close();
_open = FALSE; _open = FALSE;
} }
@ -253,6 +268,13 @@ bool TWindow::stop_run(KEY key)
return TRUE; 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() KEY TWindow::run()
{ {

View File

@ -104,6 +104,7 @@ public:
virtual void open(); // Mostra la finestra virtual void open(); // Mostra la finestra
virtual void close(); // Nasconde la finestra virtual void close(); // Nasconde la finestra
virtual bool can_be_closed() const; // Puo' essere chiusa brutalmente?
void iconize() const; void iconize() const;
void maximize() const; void maximize() const;