Adattamento ai nuovi sheet

git-svn-id: svn://10.65.10.50/trunk@2781 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-05-08 11:02:26 +00:00
parent 9c26c9ce76
commit a049f284d9
8 changed files with 137 additions and 221 deletions

View File

@ -10,7 +10,7 @@
#include <tabutil.h>
#include <utility.h>
#include <urldefid.h>
#include <lffiles.h>
#include <nditte.h>
#include "ba0.h"
@ -24,8 +24,8 @@ class TPicture_mask : public TMask
{
TImage& _image;
protected:
virtual void handler(WINDOW win, EVENT* ep);
protected: // TMask
virtual void update();
public:
TPicture_mask(const char* name, int dx, int dy, TImage& image);
@ -40,28 +40,10 @@ TPicture_mask::TPicture_mask(const char* name, int dx, int dy, TImage& image)
_image.set_palette(win());
}
void TPicture_mask::handler(WINDOW win, EVENT* ep)
void TPicture_mask::update()
{
TMask::handler(win, ep);
if (ep->type == E_UPDATE)
{
#if XVT_OS == XVT_OS_WIN
if (_image.ok())
{
_image.draw(win);
}
else
#endif
{
TTemp_window w(win);
const int max = 16;
for (int i = 0; i < max; i++)
w.rect(i*2, i, max-i*2, max-i);
}
}
_image.draw(win());
}
///////////////////////////////////////////////////////////
@ -83,24 +65,26 @@ class TMenu_application : public TApplication
static int _last_button;
static bool _find_button;
protected: // TApplication
virtual bool create();
virtual bool destroy();
virtual bool menu(MENU_TAG m);
virtual bool build_firm_data(long cod, bool flagcom = FALSE);
protected:
void test_temp();
void load_menu();
int do_level();
int find_menu(const char* s) const;
bool check_user();
virtual bool create();
virtual bool destroy();
virtual bool menu(MENU_TAG m);
virtual bool build_firm_data(long cod, bool flagcom = FALSE);
static bool menu_item_handler(TMask_field&f, KEY k);
static bool menu_find_handler(TMask_field&f, KEY k);
bool module_enabled(const char * program) const;
bool module_enabled(int module) const { return has_module(module);}
public:
TMenu_application(const char* name) : _name(name) /*, _ditta_asked(FALSE) */ {}
TMenu_application(const char* name) : _name(name) {}
virtual ~TMenu_application() {}
};
int TMenu_application::_last_button = 0;
@ -345,6 +329,7 @@ bool TMenu_application::menu_find_handler(TMask_field&f, KEY k)
if (_last_button >= 0)
{
_find_button = TRUE;
f.set_focusdirty(FALSE);
f.mask().stop_run(K_AUTO_ENTER);
}
else
@ -394,12 +379,6 @@ int TMenu_application::do_level()
int y = 1;
#if XVT_OS == XVT_OS_WIN
TString16 t(format("#%d", BMP_STOPREC));
#else
TString16 t;
#endif
for (int i = first+1; i < last; i++, y++)
{
TToken_string& row = (TToken_string&)_menu[i];
@ -407,7 +386,7 @@ int TMenu_application::do_level()
if (isdigit(*row.get())) item << "...";
menu.add_static(-1, 0, item, x+4, y);
const short id = 100+y;
menu.add_button(id, 0, t, x, y, 1, 1);
menu.add_button(id, 0, "", x, y, 1, 1, "", BMP_STOPREC);
menu.set_handler(id, menu_item_handler);
if (!_enabled[i]) menu.disable(id);
}
@ -415,8 +394,8 @@ int TMenu_application::do_level()
menu.add_string(99, 0, "", -12, -3, 50, "", bwidth+1);
menu.set_handler(99, menu_find_handler);
t = first ? "Menu precedente" : "Fine";
menu.add_button(first ? DLG_CANCEL : DLG_QUIT, 0, t, -22, -1, bwidth, 2);
menu.add_button(first ? DLG_CANCEL : DLG_QUIT, 0,
first ? "Menu precedente" : "Fine", -22, -1, bwidth, 2);
if (first)
menu.add_button(DLG_QUIT, 0, "Fine", -12, -1, bwidth, 2);

View File

@ -803,27 +803,40 @@ void TManutenzione_app::convert_dir()
void TManutenzione_app::update()
{
bool lock_users = FALSE;
bool ok = TRUE;
TIsamfile utenti(LF_USER, FALSE);
utenti.open(_excllock);
if (utenti.curr().exist("CONNECTED"))
{
for (int err = utenti.first(); err == NOERR; err = utenti.next())
{
const TString16 u = utenti.get("USERNAME");
if (u != "PRASSI" && utenti.get_bool("CONNECTED"))
if (u == "PRASSI")
{
error_box("La conversione non puo' essere effettuata\n"
"se ci sono utenti collegati: %s", (const char*)u);
if (utenti.get("AUTSTR") == "CONVERTING")
{
ok = error_box("Impossibile proseguire: esiste gia' conversione in corso");
break;
}
else
{
utenti.put("AUTSTR", "CONVERTING");
utenti.rewrite();
}
}
else
{
if (utenti.get_bool("CONNECTED"))
{
ok = error_box("La conversione non puo' essere effettuata\n"
"mentre l'utente %s e' collegato", (const char*)u);
break;
}
}
}
utenti.close();
if (!ok)
return;
}
}
lock_users = TRUE;
}
utenti.close();
long firm = get_firm();
TString pref;
@ -836,7 +849,6 @@ void TManutenzione_app::update()
if (prefix().filelevel() <= 199502L)
{
TExternal_app app("bacnv 4 0");
app.run();
}
@ -866,8 +878,22 @@ void TManutenzione_app::update()
if (firm > 0) set_firm(firm);
else prefix().set(pref);
if (lock_users)
ok = FALSE;
while (!ok)
{
utenti.open(_excllock);
ok = utenti.ok();
do_events();
}
utenti.put("USER", "PRASSI");
if (utenti.read() == NOERR)
{
utenti.zero("AUTSTR");
utenti.rewrite();
}
utenti.close();
end_wait();
}
@ -881,7 +907,6 @@ bool TManutenzione_app::menu(MENU_TAG m)
while (!done)
{
disable_menu_item(M_FILE_NEW);
KEY key = _browse->run();

View File

@ -27,19 +27,20 @@ class TDir_sheet : public TSheet
long _items;
protected:
virtual void page_build(long first, byte rows);
virtual long get_items() const { return _items; }
virtual void get_row(long n, TToken_string& r);
virtual bool on_key(KEY k);
public:
TDir_sheet(const char* title,byte buttons=0x8,const char* col = "N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Formula@33|Flags@7");
~TDir_sheet();
TDir* dir() const { return _dir; }
TTrec* rec() const { return _rec; }
void set_items(long items) { _items = items; }
void add();
void rebuild() { _items = _dir->items();}
long items() const { return (_items);}
TDir_sheet(const char* title,byte buttons=0x8,const char* col = "N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Formula@33|Flags@7");
~TDir_sheet();
};
class TRec_sheet : public TObject
@ -58,32 +59,29 @@ protected:
static bool key_notify(TSheet_field& s, int r, KEY k);
static bool fld_notify(TSheet_field& s, int r, KEY k);
void save();
virtual long items() const { return _rec->fields(); }
virtual long get_items() const { return _rec->fields(); }
public:
TRec_sheet(int logicnum, const char * tab);
~TRec_sheet();
TDir* dir() const { return _dir; }
TTrec* rec() const { return _rec; }
const char * descfname() const { return _descfname;}
const char * tab() const { return _tab; }
void edit();
TRec_sheet(int logicnum, const char * tab);
virtual ~TRec_sheet();
};
class TEdit_file : public TObject
{
static bool memo_handler(TMask_field& f, KEY k);
protected:
KEY edit_record(TRectype& rec, bool readonly = FALSE);
public:
bool browse(int num, const char* name);
TEdit_file() {}
virtual ~TEdit_file() {}
};
#endif

View File

@ -2,26 +2,20 @@
#include <stdio.h>
#include <fstream.h>
#include <applicat.h>
#include <files.h>
#include <utility.h>
#include <expr.h>
#include <isam.h>
#include <mask.h>
#include <msksheet.h>
#include <progind.h>
#include <sheet.h>
#include <msksheet.h>
#include <urldefid.h>
#include <utility.h>
#include <validate.h>
#include "ba1100.h"
TMask* TRec_sheet::_mask = NULL;
HIDDEN TToken_string s(256);
void TDir_sheet::add ()
{
_dir->get(LF_DIR, _lock, _nordir, _sysdirop);
const int nitems = (int)_dir->eod() + 1;
@ -35,18 +29,14 @@ void TDir_sheet::add ()
d.zero();
d.put(nitems, _nordir, _sysdirop);
_items = nitems;
build_page(first() + 1);
update();
}
TDir_sheet::TDir_sheet(const char* title, byte buttons, const char* colonne)
:TSheet(-1,-1, 0, 0, title, colonne, buttons)
:TSheet(0, 0, 0, 0, title, colonne, buttons)
{
_dir = new TDir;
_rec = new TTrec;
maximize();
rebuild();
}
@ -78,29 +68,18 @@ bool TDir_sheet::on_key(KEY key)
return TSheet::on_key(key);
}
void TDir_sheet::page_build(long first, byte rows)
void TDir_sheet::get_row(long n, TToken_string& l)
{
TToken_string l(128);
for (byte i = 0; i < rows; i++)
{
const int n = int(i+first+1);
_dir->get (n,_nolock,_nordir,_sysdirop);
l = format("%3d", n); // Numero progressivo del file
n++;
_dir->get ((int)n,_nolock,_nordir,_sysdirop);
l.format("%3d", n); // Numero progressivo del file
l.add(_dir->name());
const TRecnotype eod = _dir->eod();
l.add(eod);
const TRecnotype eox = _dir->eox();
l.add(eox);
const word len = _dir->len();
l.add(format("%u", len));
l.add(_dir->eod());
l.add(_dir->eox());
l.add(format("%u", _dir->len()));
l.add(_dir->des());
l.add(_dir->expr());
l.add(_dir->flags());
set_row(l, i);
}
}
@ -298,7 +277,7 @@ void TRec_sheet::edit()
case K_ESC:
return;
case K_ENTER:
main_app().dispatch_e_menu(M_FILE_PRINT);
dispatch_e_menu(TASK_WIN, M_FILE_PRINT);
break;
case K_F6:
{
@ -310,12 +289,10 @@ void TRec_sheet::edit()
m.set(F_NOMEF, nout);
if (m.run() == K_ENTER)
{
TString80 nf(m.get(F_NOMEF));
const TFilename nf(m.get(F_NOMEF));
if (nf.not_empty())
{
ofstream out((const char*) nf);
ofstream out(nf);
out << *_rec;
}
}
@ -331,12 +308,10 @@ void TRec_sheet::edit()
m.set(F_NOMEF, nout);
if (m.run() == K_ENTER)
{
TString80 nf(m.get(F_NOMEF));
const TFilename nf(m.get(F_NOMEF));
if (nf.not_empty())
{
ifstream in((const char*) nf);
ifstream in(nf);
in >> *_rec;
nfields = _rec->fields();
f1.reset();

View File

@ -1,5 +1,4 @@
#include <defmask.h>
#include <mask.h>
#include <relation.h>
#include <prefix.h>
#include <progind.h>
@ -13,57 +12,6 @@ HIDDEN TRectype* __rec;
HIDDEN TRelation* __rel;
HIDDEN TMask* __msk;
bool TEdit_file::memo_handler(TMask_field& f, KEY k)
{
bool ok = TRUE;
if (k == K_SPACE)
{
const int memoidx = f.dlg() - 400;
// recuperate memo id and god (it.: godi)
int mcnt = 0;
long val = -1l;
for (int i = 0; i < __rec->items(); i++)
{
if (__rec->type(__rec->fieldname(i)) == _memofld)
{
if (memoidx == mcnt++)
{
val = __rec->get_long(__rec->fieldname(i));
break;
}
}
}
ok = val != -1l;
if (ok)
{
// edit memo with apposit maskerings
TMask mm("Edit campo memo", 1, 78, 20);
mm.add_memo(501, 0, __rec->fieldname(i), 1, 1, 76,16);
mm.add_button(DLG_OK, 0, "", -12, -1, 9, 2);
mm.add_button(DLG_CANCEL, 0, "", -22, -1, 9, 2);
// build fieldref
TString80 fref;
// UARNIN! Non funziona necessariamente per le tabelle
// ma non abbiamo tabelle coi memo e quindi camm' ifottamme'
fref << __rec->num() << "->" << __rec->fieldname(i);
mm.field(501).set_field(fref);
// se tutto va bene basta fare cosi'
mm.autoload(__rel);
if (mm.run() == K_ENTER)
{
mm.autosave(__rel);
__msk->set (f.dlg() - 1,__rec->get(__rec->fieldname(i)));
}
// se invece va male, l'e' istes
}
}
return ok;
}
bool TEdit_file::browse(int logicnum, const char* name)
{
TRelation relation(logicnum);
@ -89,8 +37,14 @@ bool TEdit_file::browse(int logicnum, const char* name)
TString16 name(n); name.lower(); name[0] = toupper(name[0]);
head.add(name);
TFieldtypes t = curr.type(n);
const int len = (t == _datefld) ? 10 : curr.length(n);
const TFieldtypes t = curr.type(n);
int len = 0;
switch (t)
{
case _datefld: len = 10; break;
case _memofld: len = 50; break;
default : len = curr.length(n); break;
}
head << '@' << max(len, (int)strlen(n));
if (t == _realfld || t == _intfld || t == _longfld || t == _wordfld || t == _realfld)
head << 'R';
@ -100,7 +54,6 @@ bool TEdit_file::browse(int logicnum, const char* name)
KEY ch;
TCursor_sheet sheet(&cursor, trac, name, head, superprassi ? 6 : 0);
sheet.maximize();
while ((ch = sheet.run()) != K_ESC)
{
@ -195,11 +148,14 @@ KEY TEdit_file::edit_record(TRectype& rec, bool readonly)
const int rows = recs > fpp ? 20 : recs+4;
const int pages = recs/fpp + (recs % fpp ? 1 : 0);
TMask m("Modifica record", pages, 78, rows);
if (pages > 1) m.add_default_tag_buttons();
int curpage = 0, currow = 1, nid = 100;
const char* cp;
int mcnt =0;
const char* flags = readonly ? "D" : "";
for(int i = 0; (cp = rec.fieldname(i)) != NULL; i++)
{
// add fields ONE by ONE
@ -214,26 +170,26 @@ KEY TEdit_file::edit_record(TRectype& rec, bool readonly)
case _longfld:
case _wordfld:
case _realfld:
m.add_number(nid++, curpage, s, 3, currow, len, "R", rec.ndec(cp));
m.add_number(nid++, curpage, s, 3, currow, len, flags, rec.ndec(cp));
break;
case _datefld:
m.add_date(nid++, curpage, s, 3, currow);
m.add_date(nid++, curpage, s, 3, currow, flags);
break;
case _charfld:
m.add_string(nid++, curpage, s, 3, currow, 1, flags);
break;
case _boolfld:
m.add_string(nid++,curpage, s, 3, currow, 1);
m.add_boolean(nid++, curpage, s, 3, currow, flags);
break;
case _intzerofld:
case _longzerofld:
m.add_number(nid++, curpage, s, 3, currow, len, "Z", 0);
{
TString16 f; f << flags << 'Z';
m.add_number(nid++, curpage, s, 3, currow, len, f, 0);
}
break;
case _memofld:
m.add_zoom( nid++, curpage, s, 3, currow, 50, "", 50 );
// memo del caz: add bottone per l'editing etc
// m.add_button (400+(mcnt++), curpage, "Edit", 35, currow, 9, 1);
// __rec = &rec;
// __msk = &m;
// m.set_handler(400+(mcnt-1), memo_handler);
m.add_zoom( nid++, curpage, s, 3, currow, 50, flags, 50 );
break;
default:
break;
@ -250,19 +206,7 @@ KEY TEdit_file::edit_record(TRectype& rec, bool readonly)
else currow++;
}
if (readonly)
{
const int max = m.fields();
for (int i = 0; i < max; i++)
{
TMask_field& f = m.fld(i);
if (f.class_id() != CLASS_BUTTON_FIELD)
f.disable();
}
}
const KEY k = m.run();
if (k == K_ENTER && !readonly)
{
nid = 100;

View File

@ -33,7 +33,7 @@ public:
TTestSheet * get_sheet() {return _testsheet;}
TTestProc * get_test() {return _test;}
TMask * get_mask() {return _mask;}
TArray_sheet * field_sheet(TMask *);
TString_array& field_sheet(TMask *);
};
@ -78,11 +78,10 @@ bool BA1300_application::destroy() // releasev e arrmask
return TApplication::destroy() ;
}
TArray_sheet * BA1300_application::field_sheet(TMask * m)
TString_array& BA1300_application::field_sheet(TMask * m)
{
TEdit_field& f=(TEdit_field&) m->field(F_FILE);
TArray_sheet * s=(TArray_sheet*) f.sheet()->sheet();
return s;
TEdit_field& f = m->efield(F_FILE);
return f.sheet()->rows_array();
}
bool BA1300_application::menu(MENU_TAG m)
@ -112,7 +111,7 @@ bool BA1300_application::menu(MENU_TAG m)
riga.add(format("%ld",cdir->eox()));
riga.add(format("%u",cdir->len()));
riga.add(cdir->des());
field_sheet(msk)->add(riga);
field_sheet(msk).add(riga);
}
msk->set_handler(F_SEQUENZA,seq_handler);
if (msk->run()==K_ENTER)

View File

@ -17,11 +17,13 @@ class TTestSheet : public TDir_sheet
{
TBit_array _oldstatus; // Previous status of selected files
protected:
void page_build(long first, byte rows);
void get_row(long n, TToken_string& r);
public:
TTestSheet(const char* titolo, byte bottoni = 0x0);
~TTestSheet() ;
void sr_status(bool save=TRUE);
TTestSheet(const char* titolo, byte bottoni = 0x0);
virtual ~TTestSheet() ;
};
class TTestFile : public TBaseisamfile

View File

@ -29,28 +29,22 @@ TTestSheet::TTestSheet(const char* titolo, byte bottoni)
TTestSheet::~TTestSheet()
{}
void TTestSheet::page_build(long first, byte rows)
void TTestSheet::get_row(long n, TToken_string& l)
{
TToken_string l(128);
for (byte i = 0; i < rows; i++)
{
const int n = int(i+first+1);
dir()->get (n,_nolock,_nordir,_sysdirop);
dir()->get((int)n,_nolock,_nordir,_sysdirop);
l.cut(0);
l.add("");
l.add(format("%3d", n)); // Numero progressivo del file
l.add(n); // Numero progressivo del file
l.add(dir()->name());
const TRecnotype eod = dir()->eod();
l.add(format("%ld", eod));
l.add(eod);
const TRecnotype eox = dir()->eox();
l.add(format("%ld", eox));
l.add(eox);
const word len = dir()->len();
l.add(format("%u", len));
l.add(dir()->des());
l.add(format("%ld", dir()->flags()));
set_row(l, i);
}
}
void TTestSheet::sr_status(bool save)