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,6 +196,7 @@ long TApplication::handler(WINDOW, EVENT* ep)
|
||||
switch(mt)
|
||||
{
|
||||
case M_FILE_QUIT:
|
||||
if (can_close())
|
||||
stop_run();
|
||||
break;
|
||||
case M_FILE_PG_SETUP:
|
||||
@ -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;
|
||||
@ -365,7 +360,7 @@ void TApplication::run(int argc, char* argv[], const char* title)
|
||||
caption << "PRASSI S.P.A. - " << get_module_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.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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,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)
|
||||
{
|
||||
if (ep->v.ctl.ci.v.edit.active)
|
||||
@ -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;
|
||||
}
|
||||
|
@ -36,9 +36,11 @@ class TPrintwin : public TWindow
|
||||
public:
|
||||
|
||||
// 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();
|
||||
|
||||
|
@ -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 <progind.h>
|
||||
@ -63,11 +63,17 @@ 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 k = 0;
|
||||
if (_flags & IND_FINISHED || _flags & IND_CANCELLED)
|
||||
if ((_flags & IND_FINISHED) || (_flags & IND_CANCELLED))
|
||||
{
|
||||
k = (_flags & IND_FINISHED) ? K_ENTER : K_ESC;
|
||||
stop_run(k);
|
||||
|
@ -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
|
||||
progind.h
|
||||
@ -57,6 +57,8 @@ class TIndwin : public TWindow
|
||||
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
|
||||
|
@ -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,9 +116,14 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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