Corretta formattazione
git-svn-id: svn://10.65.10.50/trunk@589 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
a69693ba65
commit
fc18e775ab
@ -1,687 +1,12 @@
|
||||
<<<<<<< applicat.cpp
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <xvt.h>
|
||||
|
||||
#include <extcdecl.h>
|
||||
#include <modaut.h>
|
||||
|
||||
#include <applicat.h>
|
||||
#include <config.h>
|
||||
#include <mask.h>
|
||||
#include <prefix.h>
|
||||
#include <progind.h>
|
||||
#include <relation.h>
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include <bagn002.h>
|
||||
|
||||
#define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0)
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Metodi di accesso globali all'applicazione corrente
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
HIDDEN TApplication* _application = NULL;
|
||||
|
||||
TString16 TApplication::_user;
|
||||
|
||||
TApplication* MainApp()
|
||||
{
|
||||
CHECK(_application, "NULL application!");
|
||||
#ifdef DBG
|
||||
error_box("Ti lascio usare MainApp ancora per pochi giorni!");
|
||||
#endif
|
||||
return _application;
|
||||
}
|
||||
|
||||
TApplication& main_app()
|
||||
{
|
||||
CHECK(_application, "NULL application!");
|
||||
return *_application;
|
||||
}
|
||||
|
||||
bool xvt_running() { return _application != NULL; }
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Gestione dello sfondo della finestra principale
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
HIDDEN long backdrop_eh( WINDOW win, EVENT* ep)
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
clear_window( win, COLOR_GRAY );
|
||||
#else
|
||||
clear_window( win, COLOR_BLUE );
|
||||
#endif
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
HIDDEN void create_backdrop( void )
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
xvt_create_statbar();
|
||||
xvt_statbar_set("");
|
||||
#else
|
||||
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_MENU, COLOR_BLACK, COLOR_WHITE);
|
||||
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_DIALOG, COLOR_BLUE, COLOR_WHITE);
|
||||
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_WINDOW, COLOR_RED, COLOR_WHITE);
|
||||
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_CONTROL, COLOR_BLACK, COLOR_WHITE);
|
||||
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_DISABLED, COLOR_GRAY, COLOR_WHITE);
|
||||
xvt_escape(XVT_ESC_CH_COLOR, XVT_CH_CLR_MNEMONIC, COLOR_RED, COLOR_WHITE);
|
||||
|
||||
RCT rct;
|
||||
get_client_rect( SCREEN_WIN, &rct );
|
||||
create_window(W_PLAIN, &rct, (char*) "BACKDROP", 0, TASK_WIN,
|
||||
WSF_NO_MENUBAR | WSF_CH_BACKDROP , EM_UPDATE,
|
||||
backdrop_eh, 0L );
|
||||
#endif
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Gestione del banner iniziale
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TBanner : public TWindow
|
||||
{
|
||||
protected:
|
||||
virtual void handler(WINDOW win, EVENT* ep);
|
||||
|
||||
public:
|
||||
TBanner();
|
||||
~TBanner();
|
||||
};
|
||||
|
||||
TBanner::TBanner()
|
||||
{
|
||||
create(-1, 6, 72, 6, "BANNER", WSF_NONE, W_PLAIN);
|
||||
hide_brush();
|
||||
open_modal();
|
||||
do_events();
|
||||
}
|
||||
|
||||
TBanner::~TBanner()
|
||||
{
|
||||
close_modal();
|
||||
}
|
||||
|
||||
void TBanner::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
if (ep->type == E_UPDATE)
|
||||
{
|
||||
const int BIGY = CHARY<<1;
|
||||
|
||||
clear(COLOR_LTGRAY);
|
||||
RCT r; get_client_rect(win, &r);
|
||||
|
||||
set_color(COLOR_WHITE, COLOR_LTGRAY);
|
||||
set_font(FF_TIMES, FS_BOLD | FS_ITALIC, BIGY);
|
||||
char* t = (char*)(const char*)main_app().title();
|
||||
int w = win_get_text_width(win, t, -1);
|
||||
int a; win_get_font_metrics(win, NULL, &a, NULL);
|
||||
int x = (r.right-w)>>1, y = (r.bottom+a)>>1 ;
|
||||
win_draw_text(win, x+1, y+1, t, -1);
|
||||
set_color(COLOR_BLACK, COLOR_LTGRAY);
|
||||
win_draw_text(win, x, y, t, -1);
|
||||
|
||||
set_font(FF_TIMES);
|
||||
t = "PRASSI S.p.A.";
|
||||
w = win_get_text_width(win, t, -1);
|
||||
x = (r.right-r.left-w)>>1, y = BIGY;
|
||||
win_draw_text(win, x, y, t, -1);
|
||||
|
||||
t = "Caricamento in corso";
|
||||
w = win_get_text_width(win, t, -1);
|
||||
x = (r.right-r.left-w)>>1, y = r.bottom - CHARY;
|
||||
win_draw_text(win, x, y, t, -1);
|
||||
|
||||
r.left += 4; r.right -= 4;
|
||||
r.top += 4; r.bottom -= 4;
|
||||
set_pen(COLOR_BLACK); win_draw_rect(win, &r);
|
||||
offset_rect(&r, 1, 1);
|
||||
set_pen(COLOR_WHITE); win_draw_rect(win, &r);
|
||||
|
||||
win_draw_icon(win, CHARX<<1, CHARX<<1, ICON_RSRC);
|
||||
}
|
||||
else
|
||||
TWindow::handler(win, ep);
|
||||
}
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Gestione dei processi per Windows(R)
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
const word WM_WAKEUP = RegisterWindowMessage("WAKEUP");
|
||||
DWORD waiting_for = 0;
|
||||
|
||||
HIDDEN BOOLEAN waiting_event_hook(HWND, WORD msg, WORD,
|
||||
DWORD lparam, long far* ret)
|
||||
{
|
||||
if (msg == WM_WAKEUP)
|
||||
{
|
||||
if( lparam == waiting_for || lparam == 0)
|
||||
{
|
||||
waiting_for = 0L;
|
||||
TTemp_window tw(TASK_WIN);
|
||||
tw.maximize();
|
||||
}
|
||||
*ret = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN DWORD name2id(const char* name)
|
||||
{
|
||||
waiting_for = 0L;
|
||||
for (int i = 0; i < 5 && name[i] > ' '; i++)
|
||||
{
|
||||
waiting_for <<= 6;
|
||||
waiting_for |= toupper(name[i]) - '0';
|
||||
}
|
||||
return waiting_for;
|
||||
}
|
||||
|
||||
|
||||
void TApplication::wait_for(const char* command)
|
||||
{
|
||||
TTemp_window tw(TASK_WIN);
|
||||
tw.iconize();
|
||||
name2id(cmd2name(command));
|
||||
|
||||
const long old_hook = get_value(TASK_WIN, ATTR_EVENT_HOOK);
|
||||
set_value(TASK_WIN, ATTR_EVENT_HOOK, (long)waiting_event_hook);
|
||||
while (waiting_for) do_events();
|
||||
|
||||
// We need to restore these things
|
||||
set_value(TASK_WIN, ATTR_EVENT_HOOK, old_hook);
|
||||
xvt_statbar_refresh();
|
||||
}
|
||||
|
||||
void TApplication::wake_up_caller() const
|
||||
{
|
||||
name2id(name());
|
||||
SendMessage(-1, WM_WAKEUP, 0, waiting_for);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
long TApplication::task_eh(WINDOW win, EVENT *ep)
|
||||
{
|
||||
switch (ep->type)
|
||||
{
|
||||
case E_CREATE:
|
||||
create_backdrop();
|
||||
#if defined(DBG) && XVT_OS == XVT_OS_SCOUNIX
|
||||
message_box("Attach to process %d ...", getpid());
|
||||
#endif
|
||||
do_events();
|
||||
break;
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
case E_UPDATE:
|
||||
backdrop_eh(win, ep);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return _application->handler(win, ep);
|
||||
}
|
||||
|
||||
long TApplication::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
switch (ep->type)
|
||||
{
|
||||
case E_CREATE:
|
||||
{
|
||||
TBanner banner;
|
||||
_create_ok = create();
|
||||
if (!_create_ok)
|
||||
stop_run();
|
||||
}
|
||||
break;
|
||||
case E_COMMAND:
|
||||
switch(ep->v.cmd.tag)
|
||||
{
|
||||
case M_FILE_QUIT:
|
||||
if (can_close())
|
||||
stop_run();
|
||||
break;
|
||||
case M_FILE_PG_SETUP:
|
||||
printer().set();
|
||||
break;
|
||||
case M_FILE_PRINT:
|
||||
print();
|
||||
break;
|
||||
case M_FILE_NEW:
|
||||
set_firm();
|
||||
break;
|
||||
case M_FILE_REVERT:
|
||||
config();
|
||||
break;
|
||||
case (M_FILE+11):
|
||||
about();
|
||||
break;
|
||||
default:
|
||||
if (ep->v.cmd.tag >= BAR_ITEM(1))
|
||||
{
|
||||
if(!menu(ep->v.cmd.tag))
|
||||
stop_run();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case E_CLOSE:
|
||||
if (can_close())
|
||||
stop_run();
|
||||
break;
|
||||
case E_QUIT:
|
||||
if (ep->v.query)
|
||||
{
|
||||
if (can_close())
|
||||
quit_OK();
|
||||
}
|
||||
else
|
||||
stop_run();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
|
||||
void TApplication::stop_run()
|
||||
{
|
||||
if (_savefirm) prefhndl->set_codditta(_savefirm);
|
||||
terminate();
|
||||
xvt_terminate();
|
||||
}
|
||||
|
||||
|
||||
TApplication::TApplication() : _printer(NULL), _savefirm(0), _create_ok(FALSE)
|
||||
{
|
||||
init_global_vars();
|
||||
_bar = TASK_MENUBAR;
|
||||
}
|
||||
|
||||
|
||||
TApplication::~TApplication()
|
||||
{}
|
||||
|
||||
|
||||
TPrinter* TApplication::set_printer(TPrinter* p)
|
||||
{
|
||||
TPrinter* printer = _printer;
|
||||
_printer = p;
|
||||
return printer;
|
||||
}
|
||||
|
||||
|
||||
TPrinter& TApplication::printer()
|
||||
{
|
||||
if (_printer == NULL)
|
||||
_printer = new TPrinter;
|
||||
return *_printer;
|
||||
}
|
||||
|
||||
|
||||
bool TApplication::create()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
bool TApplication::destroy()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void TApplication::terminate()
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
wake_up_caller(); // Manda il segnale di risveglio al chiamante
|
||||
#endif
|
||||
|
||||
close_all_dialogs();
|
||||
|
||||
if (_create_ok)
|
||||
{
|
||||
destroy(); // Distruzione files e maschere
|
||||
do_events();
|
||||
|
||||
if (_printer != NULL) // Distruzione dell'eventuale stampante
|
||||
{
|
||||
if (printer().isopen())
|
||||
printer().close();
|
||||
delete _printer;
|
||||
_printer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
free_global_vars(); // Distruzione variabili globali
|
||||
|
||||
customize_controls(FALSE); // Rilascio eventuali DLL
|
||||
}
|
||||
|
||||
|
||||
const char* TApplication::get_module_name() const
|
||||
{
|
||||
TScanner scanner("prassi.aut");
|
||||
|
||||
bool ok = FALSE;
|
||||
for (int aut = 0; scanner.line() != ""; aut++)
|
||||
if (strncmp(scanner.token(), _name, 2) == 0) { ok = TRUE; break; }
|
||||
|
||||
const char* module = scanner.token().mid(3);
|
||||
if (ok) ok = has_module(aut);
|
||||
|
||||
if (!ok)
|
||||
fatal_box("Il modulo '%s' non e' autorizzato", module);
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
|
||||
void TApplication::set_perms()
|
||||
{
|
||||
CGetAut(1);
|
||||
_dongle_aut.set(0, TRUE);
|
||||
for (int i = 1 ; i < ENDAUT; i++)
|
||||
{
|
||||
const int af = i - 1;
|
||||
const bool val = BITTEST(_int_tab0[af / 16], af % 16);
|
||||
_dongle_aut.set(i, val);
|
||||
}
|
||||
_user_aut.set(0, TRUE);
|
||||
if (_user.not_empty())
|
||||
{
|
||||
if (_user == "PRASSI")
|
||||
{
|
||||
for (int i = 1 ; i < ENDAUT; i++)
|
||||
_user_aut.set(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
TLocalisamfile users(LF_USER);
|
||||
|
||||
users.zero();
|
||||
users.put("USERNAME", _user);
|
||||
if (users.read() == NOERR)
|
||||
{
|
||||
const TString80 aut(users.get("AUTSTR"));
|
||||
const int max = aut.len();
|
||||
|
||||
for (int i = 1 ; i < max; i++)
|
||||
_user_aut.set(i, aut[i] == 'X');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TApplication::check_parameters(int & argc, char* argv[])
|
||||
|
||||
{
|
||||
if (strncmp(argv[argc - 1], "-u", 2) == 0)
|
||||
{
|
||||
_user = &argv[argc - 1][2];
|
||||
argc--;
|
||||
}
|
||||
#ifdef DBG
|
||||
else _user = "PRASSI";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void TApplication::run(int argc, char* argv[], const char* title)
|
||||
{
|
||||
TFilename base(argv[0]);
|
||||
|
||||
base.ext(""); base.lower();
|
||||
_title = title;
|
||||
if (_user.empty())
|
||||
check_parameters(argc, argv);
|
||||
|
||||
__argc = argc;
|
||||
__argv = (const char**)argv;
|
||||
|
||||
int addbar;
|
||||
if (argc > 1)
|
||||
{
|
||||
addbar = atoi(argv[1]+1);
|
||||
_name = cmd2name(argv[0], argv[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
addbar = 0;
|
||||
_name = cmd2name(argv[0]);
|
||||
}
|
||||
set_perms();
|
||||
|
||||
TString80 caption;
|
||||
caption << "PRASSI S.p.A. - " << get_module_name();
|
||||
|
||||
static XVT_CONFIG cfg;
|
||||
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;
|
||||
|
||||
customize_controls(TRUE);
|
||||
|
||||
_application = this;
|
||||
xvt_system(argc, argv, 0L, task_eh, &cfg);
|
||||
}
|
||||
|
||||
|
||||
// About box: risposta alla opzione Informazioni del menu File
|
||||
void TApplication::about() const
|
||||
{
|
||||
#include <prassi.ver>
|
||||
const TFilename n(__argv[0]);
|
||||
message_box("PRASSI Versione Beta %4.2f\nProgramma %s\nLibreria del %s",
|
||||
VERSION, (const char*)n.name(), __DATE__);
|
||||
}
|
||||
|
||||
// Risposta alla selezione Stampa del menu File
|
||||
void TApplication::print()
|
||||
{
|
||||
#ifdef DBG
|
||||
error_box("Non saprei bene cosa stampare!");
|
||||
#endif
|
||||
}
|
||||
|
||||
void TApplication::check_menu_item(MENU_TAG item)
|
||||
{
|
||||
win_menu_check(TASK_WIN, item, TRUE);
|
||||
win_update_menu_bar(TASK_WIN);
|
||||
}
|
||||
|
||||
void TApplication::uncheck_menu_item(MENU_TAG item)
|
||||
{
|
||||
win_menu_check(TASK_WIN, item, FALSE);
|
||||
win_update_menu_bar(TASK_WIN);
|
||||
}
|
||||
|
||||
|
||||
void TApplication::enable_menu_item(MENU_TAG item, bool on)
|
||||
{
|
||||
win_menu_enable(TASK_WIN, item, on);
|
||||
win_update_menu_bar(TASK_WIN);
|
||||
}
|
||||
|
||||
|
||||
void TApplication::dispatch_e_menu(MENU_TAG item)
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
HWND w = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW);
|
||||
PostMessage(w, WM_COMMAND, item, 0L);
|
||||
#else
|
||||
EVENT e;
|
||||
e.type = E_COMMAND;
|
||||
e.v.cmd.tag = item;
|
||||
e.v.cmd.shift = e.v.cmd.control = 0;
|
||||
dispatch_event(TASK_WIN, &e);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool TApplication::has_module(int module, int checktype) const
|
||||
{
|
||||
bool ok = TRUE;
|
||||
if (checktype == CHK_ALL || checktype == CHK_DONGLE)
|
||||
ok = _dongle_aut[module];
|
||||
if (ok && checktype == CHK_ALL || checktype == CHK_USER)
|
||||
ok = _user_aut[module];
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
long TApplication::get_firm() const
|
||||
{
|
||||
return prefhndl->get_codditta();
|
||||
}
|
||||
|
||||
const char* TApplication::get_firm_dir() const
|
||||
{
|
||||
return format("%s%s", __ptprf, prefhndl->name());
|
||||
}
|
||||
|
||||
|
||||
bool TApplication::set_firm(long newfirm)
|
||||
{
|
||||
disable_menu_item(M_FILE_NEW);
|
||||
const long oldfirm = get_firm();
|
||||
|
||||
if (newfirm < 1)
|
||||
{
|
||||
TMask mask("bagn002");
|
||||
|
||||
mask.send_key(K_CTRL+K_SHIFT+(extended_firm() ? 's' : 'h'), -2);
|
||||
const KEY k = mask.run();
|
||||
|
||||
enable_menu_item(M_FILE_NEW);
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
newfirm = mask.get_long(F_CODDITTA);
|
||||
const int tipodir = mask.get_int(F_TIPO);
|
||||
|
||||
if (tipodir > 0)
|
||||
{
|
||||
if (_savefirm == 0) _savefirm = oldfirm;
|
||||
prefhndl->set(tipodir == 1 ? "com" : "");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newfirm == oldfirm || newfirm < 1)
|
||||
return newfirm > 0;
|
||||
|
||||
if (prefhndl->test(newfirm))
|
||||
{
|
||||
prefhndl->set_codditta(newfirm);
|
||||
_savefirm = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TApplication::config()
|
||||
// gestisce le voci di configurazione
|
||||
// le si passa il file in cui cercare il proprio
|
||||
// paragrafo (comunque relativo alla ditta)
|
||||
// se non c'e', viene creato copiando il default
|
||||
// la variabile EdMask di quel paragrafo specifica
|
||||
// la maschera da usare
|
||||
{
|
||||
TConfig cnf(CONFIG_DITTA);
|
||||
bool ok = FALSE;
|
||||
|
||||
TFilename maskname(cnf.get("EdMask"));
|
||||
if (!maskname.empty())
|
||||
{
|
||||
TMask m(maskname);
|
||||
|
||||
// carica campi
|
||||
for (int i = 0; i < m.fields(); i++)
|
||||
{
|
||||
TMask_field& f = m.fld(i);
|
||||
const TFieldref* fref = f.field();
|
||||
if (fref != NULL)
|
||||
{
|
||||
const char* fname = fref->name();
|
||||
if (fname != NULL)
|
||||
{
|
||||
TString& oldvl = cnf.get(fname);
|
||||
if (!oldvl.empty())
|
||||
f.set(oldvl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// run mask
|
||||
disable_menu_item(M_FILE_NEW);
|
||||
disable_menu_item(M_FILE_REVERT);
|
||||
|
||||
if (m.run() == K_ENTER)
|
||||
{
|
||||
// aggiusta campi
|
||||
for (i = 0; i < m.fields(); i++)
|
||||
{
|
||||
TMask_field& f = m.fld(i);
|
||||
if (f.dirty())
|
||||
{
|
||||
const TFieldref* fref = f.field();
|
||||
if (fref != NULL)
|
||||
{
|
||||
const char* fname = fref->name();
|
||||
const char* value = f.get();
|
||||
const char* oldvl = cnf.get(fname);
|
||||
if (change_config(fname,oldvl,value))
|
||||
cnf.set(fname, value, NULL, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
ok = TRUE;
|
||||
}
|
||||
else ok = FALSE;
|
||||
enable_menu_item(M_FILE_NEW);
|
||||
enable_menu_item(M_FILE_REVERT);
|
||||
return ok;
|
||||
}
|
||||
return warning_box("Nessun parametro da configurare");
|
||||
}
|
||||
|
||||
bool TApplication::change_config(const char* var, const char* oldv,
|
||||
const char* newv)
|
||||
|
||||
{ return TRUE; }
|
||||
=======
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <xvt.h>
|
||||
|
||||
#include <extcdecl.h>
|
||||
#include <modaut.h>
|
||||
|
||||
#include <applicat.h>
|
||||
#include <config.h>
|
||||
#include <extcdecl.h>
|
||||
#include <lffiles.h>
|
||||
#include <modaut.h>
|
||||
#include <mask.h>
|
||||
#include <prefix.h>
|
||||
#include <progind.h>
|
||||
@ -698,13 +23,15 @@ bool TApplication::change_config(const char* var, const char* oldv,
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
HIDDEN TApplication* _application = NULL;
|
||||
HIDDEN long savefirm = 0;
|
||||
|
||||
TString16 TApplication::_user;
|
||||
|
||||
TApplication* MainApp()
|
||||
{
|
||||
CHECK(_application, "NULL application!");
|
||||
#ifdef DBG
|
||||
error_box("Ti lascio usare MainApp ancora per pochi giorni!");
|
||||
#endif
|
||||
return _application;
|
||||
}
|
||||
|
||||
@ -916,10 +243,9 @@ long TApplication::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
case E_CREATE:
|
||||
{
|
||||
bool ok = FALSE;
|
||||
TBanner banner;
|
||||
ok = create();
|
||||
if (!ok)
|
||||
_create_ok = create();
|
||||
if (!_create_ok)
|
||||
stop_run();
|
||||
}
|
||||
break;
|
||||
@ -977,13 +303,13 @@ default:
|
||||
|
||||
void TApplication::stop_run()
|
||||
{
|
||||
if (savefirm) prefhndl->set_codditta(savefirm);
|
||||
if (_savefirm) prefhndl->set_codditta(_savefirm);
|
||||
terminate();
|
||||
xvt_terminate();
|
||||
}
|
||||
|
||||
|
||||
TApplication::TApplication() : _printer(NULL)
|
||||
TApplication::TApplication() : _printer(NULL), _savefirm(0), _create_ok(FALSE)
|
||||
{
|
||||
init_global_vars();
|
||||
_bar = TASK_MENUBAR;
|
||||
@ -996,7 +322,7 @@ TApplication::~TApplication()
|
||||
|
||||
TPrinter* TApplication::set_printer(TPrinter* p)
|
||||
{
|
||||
TPrinter* printer = _printer;
|
||||
TPrinter* printer = _printer;
|
||||
_printer = p;
|
||||
return printer;
|
||||
}
|
||||
@ -1025,22 +351,26 @@ bool TApplication::destroy()
|
||||
void TApplication::terminate()
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
wake_up_caller(); // Manda il segnale di risveglio al chiamante
|
||||
wake_up_caller(); // Manda il segnale di risveglio al chiamante
|
||||
#endif
|
||||
|
||||
close_all_dialogs();
|
||||
_application->destroy(); // Distruzione files e maschere
|
||||
do_events();
|
||||
|
||||
if (_printer != NULL) // Distruzione dell'eventuale stampante
|
||||
|
||||
if (_create_ok)
|
||||
{
|
||||
if (printer().isopen())
|
||||
printer().close();
|
||||
delete _printer;
|
||||
_printer = NULL;
|
||||
}
|
||||
destroy(); // Distruzione files e maschere
|
||||
do_events();
|
||||
|
||||
free_global_vars(); // Distruzione variabili globali
|
||||
if (_printer != NULL) // Distruzione dell'eventuale stampante
|
||||
{
|
||||
if (printer().isopen())
|
||||
printer().close();
|
||||
delete _printer;
|
||||
_printer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
free_global_vars(); // Distruzione variabili globali
|
||||
|
||||
customize_controls(FALSE); // Rilascio eventuali DLL
|
||||
}
|
||||
@ -1063,8 +393,8 @@ const char* TApplication::get_module_name() const
|
||||
return module;
|
||||
}
|
||||
|
||||
void TApplication::set_perms()
|
||||
|
||||
void TApplication::set_perms()
|
||||
{
|
||||
CGetAut(1);
|
||||
_dongle_aut.set(0, TRUE);
|
||||
@ -1109,10 +439,12 @@ void TApplication::check_parameters(int & argc, char* argv[])
|
||||
_user = &argv[argc - 1][2];
|
||||
argc--;
|
||||
}
|
||||
else
|
||||
_user = "PRASSI";
|
||||
#ifdef DBG
|
||||
else _user = "PRASSI";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void TApplication::run(int argc, char* argv[], const char* title)
|
||||
{
|
||||
TFilename base(argv[0]);
|
||||
@ -1154,6 +486,7 @@ void TApplication::run(int argc, char* argv[], const char* title)
|
||||
xvt_system(argc, argv, 0L, task_eh, &cfg);
|
||||
}
|
||||
|
||||
|
||||
// About box: risposta alla opzione Informazioni del menu File
|
||||
void TApplication::about() const
|
||||
{
|
||||
@ -1251,7 +584,7 @@ bool TApplication::set_firm(long newfirm)
|
||||
return FALSE;
|
||||
if (tipodir > 0)
|
||||
{
|
||||
if (savefirm == 0) savefirm = oldfirm;
|
||||
if (_savefirm == 0) _savefirm = oldfirm;
|
||||
prefhndl->set(tipodir == 1 ? "com" : "");
|
||||
return TRUE;
|
||||
}
|
||||
@ -1264,7 +597,7 @@ bool TApplication::set_firm(long newfirm)
|
||||
if (prefhndl->test(newfirm))
|
||||
{
|
||||
prefhndl->set_codditta(newfirm);
|
||||
savefirm = 0;
|
||||
_savefirm = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -1341,4 +674,3 @@ bool TApplication::change_config(const char* var, const char* oldv,
|
||||
const char* newv)
|
||||
|
||||
{ return TRUE; }
|
||||
>>>>>>> 1.24
|
||||
|
@ -1,106 +1,107 @@
|
||||
#ifndef __APPLICATION_H
|
||||
#define __APPLICATION_H
|
||||
|
||||
#ifndef INCL_XVTH
|
||||
#include <xvt.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
#include <printer.h>
|
||||
#endif
|
||||
|
||||
// @C
|
||||
// Classe TApplication
|
||||
// @END
|
||||
|
||||
#define MSG_AI "AI" // message auto_insert (relapp)
|
||||
#define MSG_FS "FS" // message filtered start (relapp)
|
||||
#define MSG_LN "LN" // message (printapp -> relapp)
|
||||
#define CHK_ALL -1 // all authorization checks
|
||||
#define CHK_DONGLE 0 // dongle authorization checks
|
||||
#define CHK_USER 1 // user authorization checks
|
||||
|
||||
class TApplication
|
||||
{
|
||||
// @DPRIV
|
||||
int _bar;
|
||||
int __argc;
|
||||
const char** __argv;
|
||||
TBit_array _dongle_aut;
|
||||
TBit_array _user_aut;
|
||||
|
||||
TString80 _name, _title;
|
||||
TPrinter* _printer;
|
||||
|
||||
long _savefirm;
|
||||
bool _create_ok;
|
||||
static TString16 _user;
|
||||
|
||||
protected:
|
||||
const char* get_module_name() const;
|
||||
static long task_eh(WINDOW win, EVENT* ep);
|
||||
|
||||
virtual long handler(WINDOW win, EVENT* ep);
|
||||
virtual bool extended_firm() const { return FALSE; } // Extended set_firm dialog box
|
||||
|
||||
virtual bool create(); // Crea la finestra principale
|
||||
virtual bool menu(MENU_TAG) { return TRUE; } // Controlla il menu
|
||||
virtual bool destroy(); // Rimuove l'applicazione
|
||||
virtual void print();
|
||||
|
||||
virtual bool change_config(const char* var, const char* oldv, const char* newv);
|
||||
void set_user(const char * user) { _user = user; }
|
||||
|
||||
void terminate();
|
||||
bool config();
|
||||
void about() const;
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
|
||||
void setbar(int menubar) { _bar = menubar;} // Modifica la menu-bar
|
||||
void run(int argc, char* argv[], const char* name);
|
||||
|
||||
// @DES Queste funzioni possono essere ridefinite da ogni applicazione
|
||||
// @FPUB
|
||||
virtual word class_id() const { return CLASS_APPLICATION; }
|
||||
void stop_run(); // Forza chiusura applicazione
|
||||
|
||||
void check_menu_item(MENU_TAG item); // Check menu
|
||||
void uncheck_menu_item(MENU_TAG item); // Uncheck
|
||||
void enable_menu_item(MENU_TAG item, bool on = TRUE);
|
||||
void disable_menu_item(MENU_TAG item) { enable_menu_item(item, FALSE); }
|
||||
void dispatch_e_menu(MENU_TAG item);
|
||||
|
||||
const TString& name() const { return _name; }
|
||||
const char** argv() const { return __argv; }
|
||||
const char* argv(int i) const { return __argv[i]; }
|
||||
int argc() const { return __argc; }
|
||||
|
||||
void set_title(const char* t) { _title = t; }
|
||||
const TString& title() const { return _title; }
|
||||
|
||||
void wait_for(const char* name);
|
||||
void wake_up_caller() const;
|
||||
|
||||
TPrinter* set_printer(TPrinter* p);
|
||||
TPrinter& printer();
|
||||
|
||||
static void check_parameters(int & argc, char *argv[]);
|
||||
|
||||
void set_perms();
|
||||
const TString& user() const { return _user; }
|
||||
bool has_module(int module, int checktype = CHK_ALL) const;
|
||||
bool set_firm(long cod = -1);
|
||||
long get_firm() const;
|
||||
const char* get_firm_dir() const;
|
||||
|
||||
TApplication();
|
||||
virtual ~TApplication();
|
||||
};
|
||||
|
||||
bool xvt_running(); // xvt is running?
|
||||
TApplication* MainApp(); // main application (old fashioned: will be removed soon
|
||||
TApplication& main_app();
|
||||
|
||||
#endif // __APPLICATION_H
|
||||
#ifndef __APPLICATION_H
|
||||
#define __APPLICATION_H
|
||||
|
||||
#ifndef INCL_XVTH
|
||||
#include <xvt.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
#include <printer.h>
|
||||
#endif
|
||||
|
||||
// @C
|
||||
// Classe TApplication
|
||||
// @END
|
||||
|
||||
#define MSG_AI "AI" // message auto_insert (relapp)
|
||||
#define MSG_FS "FS" // message filtered start (relapp)
|
||||
#define MSG_LN "LN" // message (printapp -> relapp)
|
||||
#define CHK_ALL -1 // all authorization checks
|
||||
#define CHK_DONGLE 0 // dongle authorization checks
|
||||
#define CHK_USER 1 // user authorization checks
|
||||
|
||||
class TApplication
|
||||
{
|
||||
// @DPRIV
|
||||
int _bar;
|
||||
int __argc;
|
||||
const char** __argv;
|
||||
TBit_array _dongle_aut;
|
||||
TBit_array _user_aut;
|
||||
|
||||
TString80 _name, _title;
|
||||
TPrinter* _printer;
|
||||
|
||||
long _savefirm;
|
||||
bool _create_ok;
|
||||
static TString16 _user;
|
||||
|
||||
protected:
|
||||
const char* get_module_name() const;
|
||||
static long task_eh(WINDOW win, EVENT* ep);
|
||||
|
||||
virtual long handler(WINDOW win, EVENT* ep);
|
||||
virtual bool extended_firm() const { return FALSE; } // Extended set_firm dialog box
|
||||
|
||||
virtual bool create(); // Crea la finestra principale
|
||||
virtual bool menu(MENU_TAG) { return TRUE; } // Controlla il menu
|
||||
virtual bool build_firm_data(long cod, bool flagcom = FALSE) { return TRUE;}
|
||||
virtual bool destroy(); // Rimuove l'applicazione
|
||||
virtual void print();
|
||||
|
||||
virtual bool change_config(const char* var, const char* oldv, const char* newv);
|
||||
void set_user(const char * user) { _user = user; }
|
||||
|
||||
void terminate();
|
||||
bool config();
|
||||
void about() const;
|
||||
|
||||
public:
|
||||
// @FPUB
|
||||
|
||||
void setbar(int menubar) { _bar = menubar;} // Modifica la menu-bar
|
||||
void run(int argc, char* argv[], const char* name);
|
||||
|
||||
// @DES Queste funzioni possono essere ridefinite da ogni applicazione
|
||||
// @FPUB
|
||||
virtual word class_id() const { return CLASS_APPLICATION; }
|
||||
void stop_run(); // Forza chiusura applicazione
|
||||
|
||||
void check_menu_item(MENU_TAG item); // Check menu
|
||||
void uncheck_menu_item(MENU_TAG item); // Uncheck
|
||||
void enable_menu_item(MENU_TAG item, bool on = TRUE);
|
||||
void disable_menu_item(MENU_TAG item) { enable_menu_item(item, FALSE); }
|
||||
void dispatch_e_menu(MENU_TAG item);
|
||||
|
||||
const TString& name() const { return _name; }
|
||||
const char** argv() const { return __argv; }
|
||||
const char* argv(int i) const { return __argv[i]; }
|
||||
int argc() const { return __argc; }
|
||||
|
||||
void set_title(const char* t) { _title = t; }
|
||||
const TString& title() const { return _title; }
|
||||
|
||||
void wait_for(const char* name);
|
||||
void wake_up_caller() const;
|
||||
|
||||
TPrinter* set_printer(TPrinter* p);
|
||||
TPrinter& printer();
|
||||
|
||||
static void check_parameters(int & argc, char *argv[]);
|
||||
|
||||
void set_perms();
|
||||
const TString& user() const { return _user; }
|
||||
bool has_module(int module, int checktype = CHK_ALL) const;
|
||||
bool set_firm(long cod = -1);
|
||||
long get_firm() const;
|
||||
const char* get_firm_dir() const;
|
||||
|
||||
TApplication();
|
||||
virtual ~TApplication();
|
||||
};
|
||||
|
||||
bool xvt_running(); // xvt is running?
|
||||
TApplication* MainApp(); // main application (old fashioned: will be removed soon
|
||||
TApplication& main_app();
|
||||
|
||||
#endif // __APPLICATION_H
|
||||
|
@ -1,208 +1,208 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef XVT_OS
|
||||
#include <xvt_os.h>
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
#include <windows.h>
|
||||
#include <keys.h>
|
||||
#else
|
||||
#include <xvtility.h>
|
||||
#endif
|
||||
#include <applicat.h>
|
||||
#endif // XVT_OS
|
||||
|
||||
|
||||
#ifdef FOXPRO
|
||||
#undef XVT_OS
|
||||
#include <pro_ext.h>
|
||||
#endif
|
||||
|
||||
#ifdef XVT_R3_API
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <checks.h>
|
||||
|
||||
#define buildmsg() char msg[256];va_list argptr;va_start(argptr,fmt);vsprintf(msg,fmt,argptr);va_end(argptr)
|
||||
|
||||
#ifdef XVT_OS
|
||||
|
||||
int fatal_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
MessageBeep(MB_ICONHAND);
|
||||
MessageBox(GetFocus(), msg, "ERRORE FATALE", MB_OK | MB_ICONHAND | MB_SYSTEMMODAL);
|
||||
|
||||
if (xvt_running())
|
||||
main_app().stop_run();
|
||||
#else
|
||||
beep();
|
||||
if (xvt_running()) xvt_fatal("%s", msg);
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
getchar();
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int error_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
MessageBeep(MB_ICONEXCLAMATION);
|
||||
MessageBox(GetFocus(), msg, "ERRORE", MB_OK | MB_ICONEXCLAMATION);
|
||||
#else
|
||||
beep();
|
||||
if (xvt_running()) xvt_error("%s", msg);
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
getchar();
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int warning_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
MessageBeep(MB_ICONQUESTION);
|
||||
MessageBox(GetFocus(), msg, "ATTENZIONE", MB_OK | MB_ICONQUESTION);
|
||||
#else
|
||||
beep();
|
||||
xvt_note("%s", msg);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int message_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
MessageBox(GetFocus(), msg, "INFORMAZIONE", MB_OK | MB_ICONINFORMATION);
|
||||
#else
|
||||
xvt_note("%s", msg);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sorry_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
MessageBeep(MB_OK);
|
||||
MessageBox(GetFocus(), msg, "SPIACENTE", MB_OK | MB_ICONINFORMATION);
|
||||
#else
|
||||
xvt_note("%s", msg);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yesno_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
int r = MessageBox(GetFocus(), msg, "RICHIESTA", MB_YESNO | MB_ICONQUESTION);
|
||||
return r == IDYES;
|
||||
#else
|
||||
ASK_RESPONSE r = xvt_ask((char*) "Si", (char*) "No", NULL, "%s", msg);
|
||||
return r == RESP_DEFAULT;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int yesnofatal_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#ifdef DBG
|
||||
char s[256]; sprintf(s, "%s\nContinuare ugualmente?", msg);
|
||||
const int ret = yesno_box("%s", s);
|
||||
if (!ret) fatal_box("");
|
||||
#else
|
||||
fatal_box("%s", msg);
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int yesnocancel_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
int r = MessageBox(GetFocus(), msg, "RICHIESTA", MB_YESNOCANCEL | MB_ICONQUESTION);
|
||||
if (r == IDYES) r = K_YES;
|
||||
else
|
||||
if (r == IDNO) r = K_NO;
|
||||
else
|
||||
r = K_ESC;
|
||||
return r;
|
||||
#else
|
||||
ASK_RESPONSE r = xvt_ask((char*) "Si", (char*) "No", (char*) "Annulla", "%s", msg);
|
||||
if (r == RESP_DEFAULT) r = K_YES;
|
||||
else
|
||||
if (r == RESP_2) r = K_NO;
|
||||
else
|
||||
r = K_ESC;
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // XVT_OS
|
||||
|
||||
|
||||
#ifdef FOXPRO
|
||||
|
||||
int error_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
_UserError(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fatal_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
_UserError(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int message_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
_UserError(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yesnofatal_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
_UserError(msg);
|
||||
return 0;
|
||||
}
|
||||
#endif // FOXPRO
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef XVT_OS
|
||||
#include <xvt_os.h>
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
#include <windows.h>
|
||||
#include <keys.h>
|
||||
#else
|
||||
#include <xvtility.h>
|
||||
#endif
|
||||
#include <applicat.h>
|
||||
#endif // XVT_OS
|
||||
|
||||
|
||||
#ifdef FOXPRO
|
||||
#undef XVT_OS
|
||||
#include <pro_ext.h>
|
||||
#endif
|
||||
|
||||
#ifdef XVT_R3_API
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <checks.h>
|
||||
|
||||
#define buildmsg() char msg[256];va_list argptr;va_start(argptr,fmt);vsprintf(msg,fmt,argptr);va_end(argptr)
|
||||
|
||||
#ifdef XVT_OS
|
||||
|
||||
int fatal_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
MessageBeep(MB_ICONHAND);
|
||||
MessageBox(GetFocus(), msg, "ERRORE FATALE", MB_OK | MB_ICONHAND | MB_SYSTEMMODAL);
|
||||
|
||||
if (xvt_running())
|
||||
main_app().stop_run();
|
||||
#else
|
||||
beep();
|
||||
if (xvt_running()) xvt_fatal("%s", msg);
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
getchar();
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int error_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
MessageBeep(MB_ICONEXCLAMATION);
|
||||
MessageBox(GetFocus(), msg, "ERRORE", MB_OK | MB_ICONEXCLAMATION);
|
||||
#else
|
||||
beep();
|
||||
if (xvt_running()) xvt_error("%s", msg);
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
getchar();
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int warning_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
MessageBeep(MB_ICONQUESTION);
|
||||
MessageBox(GetFocus(), msg, "ATTENZIONE", MB_OK | MB_ICONQUESTION);
|
||||
#else
|
||||
beep();
|
||||
xvt_note("%s", msg);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int message_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
MessageBox(GetFocus(), msg, "INFORMAZIONE", MB_OK | MB_ICONINFORMATION);
|
||||
#else
|
||||
xvt_note("%s", msg);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sorry_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
MessageBeep(MB_OK);
|
||||
MessageBox(GetFocus(), msg, "SPIACENTE", MB_OK | MB_ICONINFORMATION);
|
||||
#else
|
||||
xvt_note("%s", msg);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yesno_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
int r = MessageBox(GetFocus(), msg, "RICHIESTA", MB_YESNO | MB_ICONQUESTION);
|
||||
return r == IDYES;
|
||||
#else
|
||||
ASK_RESPONSE r = xvt_ask((char*) "Si", (char*) "No", NULL, "%s", msg);
|
||||
return r == RESP_DEFAULT;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int yesnofatal_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#ifdef DBG
|
||||
char s[256]; sprintf(s, "%s\nContinuare ugualmente?", msg);
|
||||
const int ret = yesno_box("%s", s);
|
||||
if (!ret) fatal_box("");
|
||||
#else
|
||||
fatal_box("%s", msg);
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int yesnocancel_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
int r = MessageBox(GetFocus(), msg, "RICHIESTA", MB_YESNOCANCEL | MB_ICONQUESTION);
|
||||
if (r == IDYES) r = K_YES;
|
||||
else
|
||||
if (r == IDNO) r = K_NO;
|
||||
else
|
||||
r = K_ESC;
|
||||
return r;
|
||||
#else
|
||||
ASK_RESPONSE r = xvt_ask((char*) "Si", (char*) "No", (char*) "Annulla", "%s", msg);
|
||||
if (r == RESP_DEFAULT) r = K_YES;
|
||||
else
|
||||
if (r == RESP_2) r = K_NO;
|
||||
else
|
||||
r = K_ESC;
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // XVT_OS
|
||||
|
||||
|
||||
#ifdef FOXPRO
|
||||
|
||||
int error_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
_UserError(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fatal_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
_UserError(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int message_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
_UserError(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int yesnofatal_box(const char* fmt, ...)
|
||||
{
|
||||
buildmsg();
|
||||
_UserError(msg);
|
||||
return 0;
|
||||
}
|
||||
#endif // FOXPRO
|
||||
|
||||
|
2052
include/controls.cpp
2052
include/controls.cpp
File diff suppressed because it is too large
Load Diff
2146
include/form.cpp
2146
include/form.cpp
File diff suppressed because it is too large
Load Diff
@ -1,202 +1,202 @@
|
||||
// $Id: mailbox.cpp,v 1.6 1994-11-10 13:44:25 guy Exp $
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <fstream.h>
|
||||
|
||||
#include <applicat.h>
|
||||
#include <mailbox.h>
|
||||
#include <utility.h>
|
||||
|
||||
#if XVT_OS == XVT_OS_DOS || XVT_OS == XVT_OS_WIN
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define DEF_MSGS_CAPACITY 50
|
||||
#define MAX_TXT_LEN 200
|
||||
|
||||
TMessage::TMessage(const char* to, const char* sub, const char* text,
|
||||
const char* from)
|
||||
{
|
||||
_to = to; _subject = sub;
|
||||
_text = text;
|
||||
_from = (from == NULL || *from == '\0' ? main_app().name() : from);
|
||||
_flags = 0x00; _number = -1;
|
||||
}
|
||||
|
||||
void TMessage::send()
|
||||
{
|
||||
TMailbox mail;
|
||||
mail.send(*this);
|
||||
}
|
||||
|
||||
|
||||
void TMailbox::reread()
|
||||
// reads new messages from mailbox;
|
||||
// create messages, put messages in _msgs array in cronological order
|
||||
{
|
||||
char buf[MAX_TXT_LEN];
|
||||
|
||||
ifstream mbox(_path);
|
||||
|
||||
// skip read messages
|
||||
mbox.seekg(_lastpos);
|
||||
while (mbox.getline(buf, MAX_TXT_LEN -1) != NULL)
|
||||
{
|
||||
// process new message
|
||||
TMessage* tmnew = new TMessage (NULL, NULL, NULL, buf);
|
||||
// lines are <from> <subject> <body>
|
||||
mbox.getline(buf, MAX_TXT_LEN -1);
|
||||
tmnew->subject(buf);
|
||||
mbox.getline(buf, MAX_TXT_LEN -1);
|
||||
tmnew->body(buf);
|
||||
_msgs.add(tmnew);
|
||||
tmnew->number(_msgs.items());
|
||||
n_new++;
|
||||
}
|
||||
_lastpos = mbox.tellg();
|
||||
}
|
||||
|
||||
TMessage* TMailbox::next_unread()
|
||||
{
|
||||
// returns next unread message;
|
||||
if (_cnt == _msgs.items())
|
||||
return NULL;
|
||||
while(this->get(_cnt)->isread())
|
||||
{
|
||||
_cnt++;
|
||||
if (_cnt == _msgs.items())
|
||||
return NULL;
|
||||
}
|
||||
n_new --;
|
||||
return this->get(_lastread = _cnt);
|
||||
}
|
||||
|
||||
TMessage* TMailbox::next_read()
|
||||
{
|
||||
// next read/unread message
|
||||
if (_cnt == _msgs.items())
|
||||
return NULL;
|
||||
if (!(this->get(_cnt)->isread()))
|
||||
n_new--;
|
||||
return this->get(_cnt++);
|
||||
}
|
||||
|
||||
TMessage* TMailbox::next(bool read)
|
||||
{
|
||||
// next message, default unread
|
||||
TMessage* m = read ? next_read() : next_unread();
|
||||
if (m)
|
||||
m->setread();
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
TMessage* TMailbox::next_s(char* s, bool read)
|
||||
{
|
||||
// next message with matching subject
|
||||
for (;;)
|
||||
{
|
||||
if (_cnt == _msgs.items())
|
||||
return NULL;
|
||||
if (strcmp(this->get(_cnt)->subject(), s) == 0)
|
||||
{
|
||||
if (read) break;
|
||||
else
|
||||
{
|
||||
if (!(this->get(_cnt)->isread())) break;
|
||||
}
|
||||
}
|
||||
_cnt++;
|
||||
}
|
||||
this->get(_cnt)->setread();
|
||||
if (!read) n_new--;
|
||||
return this->get(_cnt);
|
||||
}
|
||||
|
||||
TMessage* TMailbox::next_f(char* f, bool read)
|
||||
{
|
||||
// next message with matching sender
|
||||
for (;;)
|
||||
{
|
||||
if (_cnt == _msgs.items())
|
||||
return NULL;
|
||||
if (strcmp(this->get(_cnt)->from(), f) == 0)
|
||||
{
|
||||
if (read) break;
|
||||
else { if (!(this->get(_cnt)->isread())) break; }
|
||||
}
|
||||
_cnt++;
|
||||
}
|
||||
this->get(_cnt)->setread();
|
||||
if (!read) n_new--;
|
||||
return this->get(_cnt);
|
||||
}
|
||||
|
||||
void TMailbox::send(TMessage& m)
|
||||
{
|
||||
CHECK(m.from().not_empty() && m.to().not_empty() &&
|
||||
(m.subject().not_empty || m.body().not_empty()),
|
||||
"Can't send partially empty message");
|
||||
|
||||
// strcpy(to_path, getenv("TMPDIR") == NULL ? MAILDIR : getenv("TMPDIR"));
|
||||
TFilename to_path; to_path.tempdir();
|
||||
to_path << "/" << m.to() << ".mbx";
|
||||
|
||||
ofstream fto(to_path, ios::app);
|
||||
CHECK(fto.good(),"send: trouble opening mailbox file");
|
||||
fto << m.from() << '\n'
|
||||
<< m.subject() << '\n'
|
||||
<< m.body() << '\n';
|
||||
fto.close();
|
||||
}
|
||||
|
||||
void TMailbox::sendcmd(int argc, char* argv[], char* to)
|
||||
{
|
||||
CHECK(0,"MAILBOX::COMMANDLINE INTERFACE NOT IMPLEMENTED");
|
||||
for (int i = 0; i < argc; i++)
|
||||
{
|
||||
// parse argv[i]
|
||||
// create new message
|
||||
// send it out
|
||||
}
|
||||
}
|
||||
|
||||
char* TMailbox::readcmd(char*)
|
||||
{
|
||||
// filters all messages to recipient and adds to to_path
|
||||
CHECK(0,"MAILBOX::COMMANDLINE INTERFACE NOT IMPLEMENTED");
|
||||
// TMessage* m;
|
||||
return "NOT YET IMPLEMENTED";
|
||||
}
|
||||
|
||||
TMailbox::TMailbox(const char* appname) : _msgs(DEF_MSGS_CAPACITY)
|
||||
{
|
||||
if (appname == NULL)
|
||||
appname = main_app().name(); // myself; must be global
|
||||
|
||||
_path.tempdir();
|
||||
// strcpy(_path, getenv("TMPDIR") == NULL ? MAILDIR : getenv("TMPDIR"));
|
||||
_path << "/" << appname << ".mbx";
|
||||
|
||||
_lastread =0; _lastpos = 0l;
|
||||
n_new = 0;
|
||||
this->reread();
|
||||
restart();
|
||||
}
|
||||
|
||||
TMailbox::~TMailbox()
|
||||
{
|
||||
TMessage* m;
|
||||
// scan all remaining messages and erase mailbox
|
||||
reread();
|
||||
if (access(_path,0) == 0)
|
||||
remove(_path);
|
||||
// send unread messages to myself
|
||||
while((m = next()) != NULL)
|
||||
{
|
||||
m->to(main_app().name());
|
||||
send(*m);
|
||||
}
|
||||
}
|
||||
// $Id: mailbox.cpp,v 1.7 1994-11-10 14:16:39 alex Exp $
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <fstream.h>
|
||||
|
||||
#include <applicat.h>
|
||||
#include <mailbox.h>
|
||||
#include <utility.h>
|
||||
|
||||
#if XVT_OS == XVT_OS_DOS || XVT_OS == XVT_OS_WIN
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define DEF_MSGS_CAPACITY 50
|
||||
#define MAX_TXT_LEN 200
|
||||
|
||||
TMessage::TMessage(const char* to, const char* sub, const char* text,
|
||||
const char* from)
|
||||
{
|
||||
_to = to; _subject = sub;
|
||||
_text = text;
|
||||
_from = (from == NULL || *from == '\0' ? main_app().name() : from);
|
||||
_flags = 0x00; _number = -1;
|
||||
}
|
||||
|
||||
void TMessage::send()
|
||||
{
|
||||
TMailbox mail;
|
||||
mail.send(*this);
|
||||
}
|
||||
|
||||
|
||||
void TMailbox::reread()
|
||||
// reads new messages from mailbox;
|
||||
// create messages, put messages in _msgs array in cronological order
|
||||
{
|
||||
char buf[MAX_TXT_LEN];
|
||||
|
||||
ifstream mbox(_path);
|
||||
|
||||
// skip read messages
|
||||
mbox.seekg(_lastpos);
|
||||
while (mbox.getline(buf, MAX_TXT_LEN -1) != NULL)
|
||||
{
|
||||
// process new message
|
||||
TMessage* tmnew = new TMessage (NULL, NULL, NULL, buf);
|
||||
// lines are <from> <subject> <body>
|
||||
mbox.getline(buf, MAX_TXT_LEN -1);
|
||||
tmnew->subject(buf);
|
||||
mbox.getline(buf, MAX_TXT_LEN -1);
|
||||
tmnew->body(buf);
|
||||
_msgs.add(tmnew);
|
||||
tmnew->number(_msgs.items());
|
||||
n_new++;
|
||||
}
|
||||
_lastpos = mbox.tellg();
|
||||
}
|
||||
|
||||
TMessage* TMailbox::next_unread()
|
||||
{
|
||||
// returns next unread message;
|
||||
if (_cnt == _msgs.items())
|
||||
return NULL;
|
||||
while(this->get(_cnt)->isread())
|
||||
{
|
||||
_cnt++;
|
||||
if (_cnt == _msgs.items())
|
||||
return NULL;
|
||||
}
|
||||
n_new --;
|
||||
return this->get(_lastread = _cnt);
|
||||
}
|
||||
|
||||
TMessage* TMailbox::next_read()
|
||||
{
|
||||
// next read/unread message
|
||||
if (_cnt == _msgs.items())
|
||||
return NULL;
|
||||
if (!(this->get(_cnt)->isread()))
|
||||
n_new--;
|
||||
return this->get(_cnt++);
|
||||
}
|
||||
|
||||
TMessage* TMailbox::next(bool read)
|
||||
{
|
||||
// next message, default unread
|
||||
TMessage* m = read ? next_read() : next_unread();
|
||||
if (m)
|
||||
m->setread();
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
TMessage* TMailbox::next_s(char* s, bool read)
|
||||
{
|
||||
// next message with matching subject
|
||||
for (;;)
|
||||
{
|
||||
if (_cnt == _msgs.items())
|
||||
return NULL;
|
||||
if (strcmp(this->get(_cnt)->subject(), s) == 0)
|
||||
{
|
||||
if (read) break;
|
||||
else
|
||||
{
|
||||
if (!(this->get(_cnt)->isread())) break;
|
||||
}
|
||||
}
|
||||
_cnt++;
|
||||
}
|
||||
this->get(_cnt)->setread();
|
||||
if (!read) n_new--;
|
||||
return this->get(_cnt);
|
||||
}
|
||||
|
||||
TMessage* TMailbox::next_f(char* f, bool read)
|
||||
{
|
||||
// next message with matching sender
|
||||
for (;;)
|
||||
{
|
||||
if (_cnt == _msgs.items())
|
||||
return NULL;
|
||||
if (strcmp(this->get(_cnt)->from(), f) == 0)
|
||||
{
|
||||
if (read) break;
|
||||
else { if (!(this->get(_cnt)->isread())) break; }
|
||||
}
|
||||
_cnt++;
|
||||
}
|
||||
this->get(_cnt)->setread();
|
||||
if (!read) n_new--;
|
||||
return this->get(_cnt);
|
||||
}
|
||||
|
||||
void TMailbox::send(TMessage& m)
|
||||
{
|
||||
CHECK(m.from().not_empty() && m.to().not_empty() &&
|
||||
(m.subject().not_empty || m.body().not_empty()),
|
||||
"Can't send partially empty message");
|
||||
|
||||
// strcpy(to_path, getenv("TMPDIR") == NULL ? MAILDIR : getenv("TMPDIR"));
|
||||
TFilename to_path; to_path.tempdir();
|
||||
to_path << "/" << m.to() << ".mbx";
|
||||
|
||||
ofstream fto(to_path, ios::app);
|
||||
CHECK(fto.good(),"send: trouble opening mailbox file");
|
||||
fto << m.from() << '\n'
|
||||
<< m.subject() << '\n'
|
||||
<< m.body() << '\n';
|
||||
fto.close();
|
||||
}
|
||||
|
||||
void TMailbox::sendcmd(int argc, char* argv[], char* to)
|
||||
{
|
||||
CHECK(0,"MAILBOX::COMMANDLINE INTERFACE NOT IMPLEMENTED");
|
||||
for (int i = 0; i < argc; i++)
|
||||
{
|
||||
// parse argv[i]
|
||||
// create new message
|
||||
// send it out
|
||||
}
|
||||
}
|
||||
|
||||
char* TMailbox::readcmd(char*)
|
||||
{
|
||||
// filters all messages to recipient and adds to to_path
|
||||
CHECK(0,"MAILBOX::COMMANDLINE INTERFACE NOT IMPLEMENTED");
|
||||
// TMessage* m;
|
||||
return "NOT YET IMPLEMENTED";
|
||||
}
|
||||
|
||||
TMailbox::TMailbox(const char* appname) : _msgs(DEF_MSGS_CAPACITY)
|
||||
{
|
||||
if (appname == NULL)
|
||||
appname = main_app().name(); // myself; must be global
|
||||
|
||||
_path.tempdir();
|
||||
// strcpy(_path, getenv("TMPDIR") == NULL ? MAILDIR : getenv("TMPDIR"));
|
||||
_path << "/" << appname << ".mbx";
|
||||
|
||||
_lastread =0; _lastpos = 0l;
|
||||
n_new = 0;
|
||||
this->reread();
|
||||
restart();
|
||||
}
|
||||
|
||||
TMailbox::~TMailbox()
|
||||
{
|
||||
TMessage* m;
|
||||
// scan all remaining messages and erase mailbox
|
||||
reread();
|
||||
if (access(_path,0) == 0)
|
||||
remove(_path);
|
||||
// send unread messages to myself
|
||||
while((m = next()) != NULL)
|
||||
{
|
||||
m->to(main_app().name());
|
||||
send(*m);
|
||||
}
|
||||
}
|
||||
|
2456
include/msksheet.cpp
2456
include/msksheet.cpp
File diff suppressed because it is too large
Load Diff
@ -1,51 +1,51 @@
|
||||
#ifndef __MSKSHEET_H
|
||||
#define __MSKSHEET_H
|
||||
|
||||
#ifndef __MASK_H
|
||||
#include <mask.h>
|
||||
#endif
|
||||
|
||||
|
||||
class TSpreadsheet;
|
||||
typedef bool (*SPREADSHEET_NOTIFY)(int r, KEY k);
|
||||
|
||||
|
||||
class TSheet_field : public TMask_field
|
||||
{
|
||||
TSpreadsheet* _sheet;
|
||||
TToken_string _head;
|
||||
|
||||
protected:
|
||||
virtual word class_id() const;
|
||||
virtual bool on_hit();
|
||||
virtual bool on_key(KEY k);
|
||||
|
||||
virtual void parse_head(TScanner& scanner);
|
||||
virtual bool parse_item(TScanner& scanner);
|
||||
virtual void create(WINDOW parent);
|
||||
|
||||
virtual void exchange(bool show_value, const real& n);
|
||||
|
||||
public:
|
||||
TToken_string& row(int n); // Get/Create a new row
|
||||
TArray& rows_array() const; // Get all rows
|
||||
int first_empty() const; // First empty row
|
||||
int items() const; // Number of rows
|
||||
int selected() const; // Number of current row
|
||||
|
||||
virtual void reset();
|
||||
void destroy(int r = -1); // Destroy row
|
||||
void force_update(int r = -1);// Update data/screen
|
||||
|
||||
TMask& sheet_mask() const;
|
||||
void set_notify(SPREADSHEET_NOTIFY n);
|
||||
void enable_column(int col, bool on = TRUE);
|
||||
void enable_cell(int row, int column, bool on = TRUE);
|
||||
void disable_cell(int row, int column) { enable_cell(row, column, FALSE); }
|
||||
bool cell_disabled(int row, int column) const;
|
||||
|
||||
TSheet_field(TMask* m);
|
||||
virtual ~TSheet_field();
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef __MSKSHEET_H
|
||||
#define __MSKSHEET_H
|
||||
|
||||
#ifndef __MASK_H
|
||||
#include <mask.h>
|
||||
#endif
|
||||
|
||||
|
||||
class TSpreadsheet;
|
||||
typedef bool (*SPREADSHEET_NOTIFY)(int r, KEY k);
|
||||
|
||||
|
||||
class TSheet_field : public TMask_field
|
||||
{
|
||||
TSpreadsheet* _sheet;
|
||||
TToken_string _head;
|
||||
|
||||
protected:
|
||||
virtual word class_id() const;
|
||||
virtual bool on_hit();
|
||||
virtual bool on_key(KEY k);
|
||||
|
||||
virtual void parse_head(TScanner& scanner);
|
||||
virtual bool parse_item(TScanner& scanner);
|
||||
virtual void create(WINDOW parent);
|
||||
|
||||
virtual void exchange(bool show_value, const real& n);
|
||||
|
||||
public:
|
||||
TToken_string& row(int n); // Get/Create a new row
|
||||
TArray& rows_array() const; // Get all rows
|
||||
int first_empty() const; // First empty row
|
||||
int items() const; // Number of rows
|
||||
int selected() const; // Number of current row
|
||||
|
||||
virtual void reset();
|
||||
void destroy(int r = -1); // Destroy row
|
||||
void force_update(int r = -1);// Update data/screen
|
||||
|
||||
TMask& sheet_mask() const;
|
||||
void set_notify(SPREADSHEET_NOTIFY n);
|
||||
void enable_column(int col, bool on = TRUE);
|
||||
void enable_cell(int row, int column, bool on = TRUE);
|
||||
void disable_cell(int row, int column) { enable_cell(row, column, FALSE); }
|
||||
bool cell_disabled(int row, int column) const;
|
||||
|
||||
TSheet_field(TMask* m);
|
||||
virtual ~TSheet_field();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
3056
include/printer.cpp
3056
include/printer.cpp
File diff suppressed because it is too large
Load Diff
1586
include/sheet.cpp
1586
include/sheet.cpp
File diff suppressed because it is too large
Load Diff
1900
include/strings.cpp
1900
include/strings.cpp
File diff suppressed because it is too large
Load Diff
1182
include/validate.cpp
1182
include/validate.cpp
File diff suppressed because it is too large
Load Diff
3824
include/viswin.cpp
3824
include/viswin.cpp
File diff suppressed because it is too large
Load Diff
1854
include/xvtility.cpp
1854
include/xvtility.cpp
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user