Aggiunta gestione oggetti esterni (GOLEM)

Corretto errore per cui la stampante non si ricordava il suo tipo.


git-svn-id: svn://10.65.10.50/trunk@1362 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-05-16 09:35:12 +00:00
parent ef90c9e7dd
commit e694e08d1a
17 changed files with 447 additions and 81 deletions

39
include/bagn006.uml Executable file
View File

@ -0,0 +1,39 @@
#include <bagn006.h>
PAGE "Caratteristiche oggetto" -1, -1, 66, 6
STRING F_CLASSE 8
BEGIN
PROMPT 1 1 "Classe "
FLAGS "DU"
FIELD CLASSE
END
NUMBER F_CODICE 8
BEGIN
PROMPT 48 1 "Codice "
FLAGS "D"
FIELD CHIAVE
END
STRING F_DESC 50
BEGIN
PROMPT 1 3 "Descrizione "
CHECKTYPE REQUIRED
WARNING "E' necessaria una breve descrizione"
FIELD DESC
END
BUTTON DLG_OK 10 2
BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_CANCEL 10 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
ENDMASK

View File

@ -36,5 +36,8 @@
#define CLASS_SHEET_FIELD 28
#define CLASS_BROWSEFILE_FIELD 29
#define CLASS_GOLEM 200
// @END
#endif // __CLASSES_H

View File

@ -109,7 +109,7 @@ void TConfig::_write_file()
}
void TConfig::_check_paragraph(const char* section)
void TConfig::set_paragraph(const char* section)
{
if (section != NULL && section != _paragraph)
{
@ -145,7 +145,7 @@ TString& TConfig::get(const char* var, const char* section, int index, const cha
v = s;
}
_check_paragraph(section);
set_paragraph(section);
if (_data.is_key(v))
s = (TString&)_data[v];
@ -217,7 +217,7 @@ bool TConfig::set(const char* var, const char* value, const char* section,
// se force == TRUE crea la variabile se non esiste; altrimenti
// da' errore; ritorna TRUE se la variabile c'era, FALSE diversamente
_check_paragraph(section);
set_paragraph(section);
TString vvar(var); if (index != -1) vvar << '(' << index << ')';
bool itwas = _data.is_key(vvar);
@ -241,7 +241,7 @@ bool TConfig::set(const char* var, long value, const char* section,
word TConfig::items(const char* var, const char* section)
{
_check_paragraph(section);
set_paragraph(section);
TString vvar(16);
for (int cnt = 0; /* uncazzo */ ;cnt++)
{
@ -297,11 +297,21 @@ TConfig::TConfig(int which_config, const char* paragraph)
_file << "config";
if (!fexist(_file))
make_dir(_file);
_file << '/' << (which_config == CONFIG_USER ? user() : "print") << ".ini";
switch (which_config)
{
case CONFIG_STAMPE:
_file.add("print.ini"); break;
default:
_file << '/' << user() << ".ini"; break;
}
break;
case CONFIG_FCONV:
_file = "fconv.ini";
break;
case CONFIG_GOLEM:
_file.add("golem.ini");
break;
default:
_file = "prassi.ini";
break;

View File

@ -23,6 +23,8 @@ class ofstream;
#define CONFIG_USER 4
// file parametri stampe
#define CONFIG_STAMPE 5
// file parametri golem
#define CONFIG_GOLEM 6
class TConfig : public TObject
{
@ -31,10 +33,10 @@ class TConfig : public TObject
bool _dirty, _ispresent;
TString _paragraph;
protected:
bool _read_paragraph();
void _write_paragraph(ofstream&);
void _write_file();
void _check_paragraph(const char*);
void init(const char *fn, const char* pa);
public:
@ -74,6 +76,10 @@ public:
// non si risponde di eventuali "buchi" causati da set() errate
word items(const char* var, const char* section);
// Setta il paragrafo corrente
void set_paragraph(const char* par);
// il paragrafo iniziale e' il modulo corrente salvo diversa indicazione
TConfig(int which_config = CONFIG_GENERAL, const char* paragraph = NULL);
TConfig(const char* file, const char* paragraph = NULL);

View File

@ -563,10 +563,12 @@ TPush_button::TPush_button(short left, short top, short right, short bottom,
capt = format("#%d", BMP_FINDREC);
break;
case DLG_F9:
capt = format("#%d", BMP_SEARCH);
if (*capt != '#')
capt = format("#%d", BMP_SEARCH);
break;
case DLG_LINK:
capt = format("#%d", BMP_LINK);
if (strcmp("~Collega", caption()) == 0)
capt = format("#%d", BMP_LINK);
break;
case DLG_EDIT:
capt = format("#%d", BMP_EDIT);

View File

@ -90,6 +90,10 @@ image BMP_LINK "f:/p.due/bmp/link.bmp"
image BMP_PRINT "f:/p.due/bmp/print.bmp"
image BMP_SETPRINT "f:/p.due/bmp/setprint.bmp"
image BMP_RECALC "f:/p.due/bmp/recalc.bmp"
image BMP_BMP "f:/p.due/bmp/bmp.bmp"
image BMP_XLS "f:/p.due/bmp/xls.bmp"
image BMP_WAV "f:/p.due/bmp/wav.bmp"
image BMP_DOC "f:/p.due/bmp/doc.bmp"
#scan <xil.h>
#transparent $$$

View File

@ -61,7 +61,7 @@ int TExternal_app::run(bool async, bool utente)
if (!async)
{
TTemp_window tw(TASK_WIN);
tw.iconize();
if (utente) tw.iconize();
HTASK child = NULL;
TASKENTRY te; te.dwSize = sizeof(TASKENTRY);
@ -82,7 +82,7 @@ int TExternal_app::run(bool async, bool utente)
xvt_app_process_pending_events();
}
tw.maximize();
if (utente) tw.maximize();
}
xvt_statbar_refresh();
}

View File

@ -139,7 +139,6 @@ protected:
void string_at(int x, int y, const char* s);
public:
// permissions
@ -555,7 +554,6 @@ class TForm_subsection : public TForm_item
TString _name;
protected:
virtual void print_on(ostream& out) const;
public:
@ -1724,7 +1722,7 @@ bool TForm::print(long from, long to)
{
_form = this; // Setta il form corrente
TPrinter& pr = printer(); // Setta handlers
TPrinter& pr = printer(); // Setta handlers
pr.setheaderhandler(header_handler);
pr.setfooterhandler(footer_handler);
pr.formlen(height());

205
include/golem.cpp Executable file
View File

@ -0,0 +1,205 @@
#include <config.h>
#include <execp.h>
#include <golem.h>
#include <mask.h>
#include <prefix.h>
#include <relation.h>
#include <urldefid.h>
#include <utility.h>
#include <bagn006.h>
long TGolem::_count = 0;
TFilename* TGolem::_path = NULL;
TConfig* TGolem::_config = NULL;
TRelation* TGolem::_golem = NULL;
TGolem::TGolem(const char* cls, long id)
: _class(cls), _id(id)
{
CHECK(_class.not_empty() && id >= 0, "Invalid Golem creation");
_class.upper();
if (_count == 0)
{
CHECK(_path == NULL, "Golem construction count error");
_path = new TFilename;
_config = new TConfig(CONFIG_GOLEM, _class);
_golem = new TRelation(LF_GOLEM);
}
_count++;
}
TGolem::~TGolem()
{
_count--;
if (_count == 0)
{
CHECK(_path != NULL, "Golem destruction count error");
delete _golem; _golem = NULL;
delete _config; _config = NULL;
delete _path; _path = NULL;
}
}
TConfig& TGolem::config() const
{
_config->set_paragraph(_class);
return *_config;
}
bool TGolem::ok() const
{
return _id > 0 && fexist(path());
}
const char* TGolem::class_name() const
{
*_path = "GOLEM_";
*_path << _class << "_CLASS";
return *_path;
}
word TGolem::class_id() const
{
return CLASS_GOLEM;
}
short TGolem::icon() const
{
const short id = config().get_int("Icon", NULL, -1, DLG_F9);
return id;
}
const char* TGolem::ext() const
{
return config().get("Extension", NULL, -1, _class.left(3));
}
const TFilename& TGolem::path(bool test) const
{
const char* e = ext();
*_path = firm2dir(-1); // C:\PRASSI\DATI
_path->add("golem"); // C:\PRASSI\DATI\GOLEM
if (test && !fexist(*_path))
make_dir(*_path);
_path->add(_class); // C:\PRASSI\DATI\GOLEM\BITMAP
if (test && !fexist(*_path))
make_dir(*_path);
if (_id > 0)
{
_path->add(format("%ld", _id));// C:\PRASSI\DATI\GOLEM\BMP\883
_path->ext(e); // C:\PRASSI\DATI\GOLEM\BMP\883.BMP
}
return *_path;
}
int TGolem::compare(const TSortable& s) const
{
if (s.class_id() != class_id())
return UNDEFINED;
const TGolem& g = (const TGolem&)s;
return int(_id - g._id);
}
bool TGolem::edit()
{
const TFilename& p = path();
bool ok = fexist(p);
if (ok)
{
TFilename e(config().get("Editor"));
e << ' ' << p;
TExternal_app app(e);
ok = app.run(FALSE, FALSE) == 0;
}
return ok;
}
long TGolem::new_id() const
{
long id = 0;
TLocalisamfile& gol = _golem->lfile();
gol.zero();
gol.put("CLASSE", _class);
gol.put("CHIAVE", "99999999");
const int err = gol.read(_isgteq);
switch (err)
{
case NOERR:
id = 0; break;
case _isemptyfile:
id = 1; break;
default:
if (gol.get("CLASSE") != _class)
gol.prev();
if (gol.get("CLASSE") == _class)
id = gol.get_long("CHIAVE")+1;
else
id = 1;
break;
}
return id;
}
bool TGolem::import()
{
FILE_SPEC fs;
const char* const e = ext();
xvt_fsys_convert_str_to_dir(".", &fs.dir);
strcpy(fs.type, e);
sprintf(fs.name, "*.%s", e);
strcpy(fs.creator, "GOLEM");
xvt_fsys_save_dir();
FL_STATUS ok = xvt_dm_post_file_open(&fs, "Selezionare il file ...");
xvt_fsys_restore_dir();
if (ok == FL_OK)
{
TFilename from;
xvt_fsys_convert_dir_to_str(&fs.dir, (char*)(const char*)from, 80);
from.add(fs.name); from.ext(e);
TMask msk("bagn006");
msk.set(F_CLASSE, _class);
msk.set(F_CODICE, new_id());
bool correct = msk.run() == K_ENTER;
if (correct)
{
_id = msk.get_long(F_CODICE);
correct = fcopy(from, path(TRUE));
if (correct)
{
msk.autosave(_golem);
int err = _golem->write();
if (err == _isreinsert)
err = _golem->rewrite();
if (err != NOERR)
{
error_box("Errore nell'aggiornamento del file degli oggetti");
ok = FL_BAD;
}
}
else
{
error_box("Spazio su disco insufficiente per l'oggetto");
ok = FL_BAD;
}
}
else ok = FL_CANCEL;
}
return ok == FL_OK;
}

53
include/golem.h Executable file
View File

@ -0,0 +1,53 @@
#ifndef __GOLEM_H
#define __GOLEM_H
#ifndef __STRINGS_H
#include <strings.h>
#endif
#ifndef __CONFIG_H
class TConfig;
#endif
#ifndef __RELATION_H
class TRelation;
#endif
// Generic Object Linking & Embedding Mechanism
class TGolem : public TSortable
{
static long _count;
static TConfig* _config;
static TFilename* _path;
static TRelation* _golem;
TString16 _class;
long _id;
protected:
const TFilename& path(bool test = FALSE) const;
const char* ext() const;
TConfig& config() const;
long new_id() const;
protected:// TSortable
virtual int compare(const TSortable& o) const;
public: // TObject
virtual const char* class_name() const;
virtual word class_id() const;
virtual bool ok() const;
public:
virtual short icon() const;
virtual bool edit();
virtual bool import();
long id() const { return _id; }
TGolem(const char* cls, long id);
virtual ~TGolem();
};
#endif

View File

@ -50,7 +50,11 @@
#define LF_DIPEND 45
#define LF_DETH 46
#define LF_PROF 50
#define LF_DESLIN 51
#define LF_CONTR 52
#define LF_RCONT 53
#define LF_FORMS 54
#define LF_GOLEM 55
#define CNF_GENERAL 10000
#define CNF_STUDIO CNF_GENERAL + 1

View File

@ -3,6 +3,7 @@
#include <applicat.h>
#include <defmask.h>
#include <execp.h>
#include <golem.h>
#include <mailbox.h>
#include <mask.h>
#include <prefix.h>
@ -817,6 +818,7 @@ bool TMask_field::on_key(KEY key)
HWND hwnd = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW);
WinHelp(hwnd, hlp, HELP_MULTIKEY, (DWORD)&mk);
set_focus();
break;
}
#endif
@ -1122,7 +1124,15 @@ void TBrowse::parse_input(TScanner& scanner)
if (*s == '"') // Constant string
{
scanner.push();
_inp_id.add(scanner.line());
TString& str = scanner.line();
_inp_id.add(str);
if (_cursor->file().num() == LF_GOLEM) // GOLEM 2 detected!
{
str.strip("\"");
_insert = "G";
_insert << str;
}
}
else // Field on the mask
{
@ -1239,26 +1249,15 @@ void TBrowse::parse_join(TScanner& scanner)
void TBrowse::parse_insert(TScanner& scanner)
{
const TString16 key(scanner.popkey());
if (key == "NO") _insert = "";
else
const TString& key = scanner.popkey();
_insert.cut(0);
if (key != "NO")
{
if (key == "RU")
{
_insert = "R";
_insert << scanner.line();
}
else
{
_insert = "M";
_insert << scanner.line();
}
_insert << key[0] << scanner.line();
_insert.trim();
}
}
// Certified 100%
TMask_field& TBrowse::field(short n) const
{ return _fld->mask().field(n); }
@ -1406,7 +1405,6 @@ void TBrowse::do_clear()
}
bool TBrowse::do_insert()
{
bool ok = FALSE;
@ -1422,16 +1420,17 @@ bool TBrowse::do_insert()
app = format("ba3 -3 %s %d", (const char*)nm, _cursor->file().num());
// Obbligatorio usare la format globale
}
else if (_insert[0] == 'G')
{
TGolem golem(&_insert[1], atol(field().get()));
const bool ok = golem.edit();
return ok ? TRUE : error_box("Impossibile modificare l'oggetto");
}
else
{
app = _insert.mid(1);
app = &_insert[1];
}
/*
#if XVT_OS == XVT_OS_WIN
if (strnicmp(app, main_app().name(), 3) == 0)
app.insert("a", 3);
#endif
*/
TMailbox mail;
TMessage msg(app, MSG_AI, "");
mail.send(msg);
@ -1536,13 +1535,20 @@ KEY TBrowse::run()
{
buttons = 1; // Mette il bottone di gestione, a meno che ...
const TString& maskname = _fld->mask().source_file();
if (maskname.compare("batb", 4, TRUE) == 0 && _fld->in_key(0))
if (_insert[0] == 'G')
{
const char* tabname = _cursor->file().name();
if (maskname.mid(4, 3).compare(tabname, 3, TRUE) == 0)
buttons = 0;
buttons |= 2;
}
else
{
const TString& maskname = _fld->mask().source_file();
if (maskname.compare("batb", 4, TRUE) == 0 && _fld->in_key(0))
{
const char* tabname = _cursor->file().name();
if (maskname.mid(4, 3).compare(tabname, 3, TRUE) == 0)
buttons = 0;
}
}
}
TBrowse_sheet s(_cursor, _items, caption, _head, buttons, _fld, sib);
@ -1552,25 +1558,35 @@ KEY TBrowse::run()
switch (k)
{
case K_INS:
case K_INS:
if (_insert[0] == 'G')
field().set(format("%ld", selected+1));
k = do_insert() ? K_ENTER : K_ESC;
break;
case K_CTRL+'N':
{
TGolem gol(&_insert[1], 0);
if (gol.import())
field().set(format("%ld", gol.id()));
}
k = K_ENTER;
break;
case K_ENTER:
*_cursor = selected;
do_output();
break;
*_cursor = selected;
do_output();
break;
default:
if (k >= K_CTRL)
{
const TMask& m = _fld->mask();
const short id = siblings.get_int((k - K_CTRL) << 1);
TEdit_field& ef = m.efield(id);
ef.set_focus();
k = K_F9;
if (m.is_running())
ef.send_key(k, 0);
}
break;
if (k >= K_CTRL)
{
const TMask& m = _fld->mask();
const short id = siblings.get_int((k - K_CTRL) << 1);
TEdit_field& ef = m.efield(id);
ef.set_focus();
k = K_F9;
if (m.is_running())
ef.send_key(k, 0);
}
break;
}
return k;
@ -1934,9 +1950,17 @@ void TEdit_field::create(WINDOW parent)
{
flags &= ~CTL_FLAG_DISABLED;
flags |= CTL_FLAG_INVISIBLE;
}
TString16 ico("*");
if (_browse && _browse->get_insert()[0] == 'G')
{
const char* g = _browse->get_insert();
TGolem golem(g+1, 0);
ico.format("#%d", golem.icon());
}
_buttonwin = xvt_create_control(WC_PUSHBUTTON, _x+_width+delta, _y,
2, 1, "*", parent, flags, PTR_LONG(this), DLG_F9);
2, 1, ico, parent, flags, PTR_LONG(this), DLG_F9);
}
}

View File

@ -983,10 +983,14 @@ void TPrinter::read_configuration(const char* parag)
case 1: // file
_printertype = fileprinter;
break;
case 2: // video
case 4: // video
_printertype = screenvis;
_curcode = 0;
break;
case 6: // export
_printertype = export;
_curcode = 0;
break;
default:
break;
}

View File

@ -79,13 +79,13 @@ TSheet::TSheet(short x, short y, short dx, short dy,
{
_visible_rows = rows()- head_on() - 3;
add_button(DLG_SELECT, "Selezione" );
add_button(DLG_SELECT, "Selezione", K_ENTER);
if (_checkable) add_button(DLG_USER, "Tutti");
if (buttons & 0x1) add_button(DLG_NEWREC, "Gestione");
if (buttons & 0x2) add_button(DLG_NEWREC, "Nuovo");
if (buttons & 0x4) add_button(DLG_DELREC, "Elimina");
if (buttons & 0x8) add_button(DLG_QUIT, "Fine");
else add_button(DLG_CANCEL, "Annulla");
if (buttons & 0x1) add_button(DLG_LINK, "Gestione", K_INS);
if (buttons & 0x2) add_button(DLG_NEWREC, "~Nuovo", K_CTRL+'N');
if (buttons & 0x4) add_button(DLG_DELREC, "Elimina", K_DEL);
if (buttons & 0x8) add_button(DLG_QUIT, "Fine", K_ESC);
else add_button(DLG_CANCEL, "Annulla", K_ESC);
}
}
@ -222,16 +222,20 @@ void TSheet::handler(WINDOW win, EVENT* ep)
case E_CONTROL:
switch(ep->v.ctl.id)
{
case DLG_OK :
case DLG_SELECT:
dispatch_e_char(win, K_ENTER); break;
case DLG_CANCEL:
case DLG_QUIT :
dispatch_e_char(win, K_ESC); break;
case DLG_NEWREC:
dispatch_e_char(win, K_INS); break;
case DLG_DELREC:
dispatch_e_char(win, K_DEL); break;
/*
case DLG_OK :
case DLG_SELECT:
dispatch_e_char(win, K_ENTER); break;
case DLG_CANCEL:
case DLG_QUIT :
dispatch_e_char(win, K_ESC); break;
case DLG_NEWREC:
dispatch_e_char(win, K_CTRL+'N'); break;
case DLG_LINK:
dispatch_e_char(win, K_INS); break;
case DLG_DELREC:
dispatch_e_char(win, K_DEL); break;
*/
case DLG_USER:
dispatch_e_char(win, one_checked() ? K_F2 : K_F3); break;
default:
@ -288,8 +292,12 @@ bool TSheet::on_key(KEY key)
stop_run(key);
break;
case K_INS:
if (_buttonmask & 0x3)
stop_run(K_INS);
if (_buttonmask & 0x1)
stop_run(key);
break;
case K_CTRL+'N':
if (_buttonmask & 0x2)
stop_run(key);
break;
case K_LHOME:
select(0);
@ -885,7 +893,7 @@ KEY TBrowse_sheet::run()
const KEY key = TCursor_sheet::run();
if (key == K_ESC || key == K_INS || key >= K_CTRL)
if (key != K_ENTER)
{
field().set(old); // Restore field status
field().set_dirty(spork);

View File

@ -851,7 +851,8 @@ const char* TFilename::path() const
TFilename& TFilename::add(const char* n)
{
if (not_empty()) *this << SLASH;
if (not_empty() && is_not_slash(_str[len()-1]))
*this << SLASH;
*this << n;
return *this;
}

View File

@ -56,6 +56,10 @@
#define BMP_BOOK2 132
#define BMP_BOOK3 133
#define BMP_MODULE 134
#define BMP_BMP 135
#define BMP_WAV 136
#define BMP_XLS 137
#define BMP_DOC 138
#define BMP_SAVERECDN 153
#define BMP_DELRECDN 154
#define BMP_NEWRECDN 155

View File

@ -808,7 +808,8 @@ WINDOW xvt_create_control(WIN_TYPE wt,
#endif
if (win == NULL_WIN)
{
{
#if XVT_OS == XVT_OS_SCOUNIX
if (wt == WC_PUSHBUTTON)
{
if (dy == 2) r.bottom -= ROWY;
@ -816,7 +817,7 @@ WINDOW xvt_create_control(WIN_TYPE wt,
{ wt = WC_TEXT; r.right = r.left+CHARX; caption = "*"; }
else if (*caption == '*') caption = "";
}
#endif
while (*caption == '@') caption += 2;
win = xvt_ctl_create(wt, &r, (char*)caption, parent,
flags, app_data, id);