From ab3cf55295c484626052c35c00dc1e0468aa26c0 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 7 Oct 1997 14:29:35 +0000 Subject: [PATCH] bagn006.h Aggiunti identificatori per maschera golem bagn006.uml Maschera per gestire i golem controls.* Aggiunto il metodo set_icon per i TPushbutton_control default.url Rinnovato il set di icone standard execp.* Aggiunta la funzione ext2app e print_url golem.* Rivoluzionati completamente i golem mask.cpp Aggiunto il riconmoscimento del nuo campo TGolem maskfld.* Aggiunto nuovo tipo di campo golem e tolto il vecchio strings.h Modificata la derivazione della classe TFilename urldefid.h Aggiunto identificatore icona dei golem utility.cpp Migliorata la fexist per riconoscere i nomi lunghi validate.cpp Migliorato il valdate FILENAME_FUNC window.* Aggiunto nuovo costruttore per la classe TImage git-svn-id: svn://10.65.10.50/trunk@5336 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/bagn006.h | 11 +- include/bagn006.uml | 103 +++++++-- include/controls.cpp | 35 ++- include/controls.h | 4 +- include/default.url | 5 +- include/execp.cpp | 58 +++-- include/execp.h | 8 +- include/golem.cpp | 510 +++++++++++++++++++++++++++---------------- include/golem.h | 79 ------- include/mask.cpp | 3 +- include/maskfld.cpp | 36 +-- include/maskfld.h | 27 ++- include/strings.h | 17 +- include/urldefid.h | 8 +- include/utility.cpp | 62 ++---- include/validate.cpp | 2 +- include/window.cpp | 6 + include/window.h | 3 +- 18 files changed, 568 insertions(+), 409 deletions(-) diff --git a/include/bagn006.h b/include/bagn006.h index b7d09c3a8..3a533e31b 100755 --- a/include/bagn006.h +++ b/include/bagn006.h @@ -1,3 +1,8 @@ -#define F_CLASSE 101 -#define F_CODICE 102 -#define F_DESC 103 +#define F_NEWREC 201 +#define F_LINK 202 +#define F_PRINT 203 +#define F_SHEET 300 + +#define S_FILE 101 +#define S_ALIAS 102 +#define S_LINK 103 \ No newline at end of file diff --git a/include/bagn006.uml b/include/bagn006.uml index d49415211..8623847b0 100755 --- a/include/bagn006.uml +++ b/include/bagn006.uml @@ -1,37 +1,92 @@ #include -PAGE "Caratteristiche oggetto" -1, -1, 66, 6 +PAGE "Oggetti esterni" -1, -1, 76, 16 -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 +SPREADSHEET F_SHEET 0 -3 +BEGIN + PROMPT 1 1 "Lista" + ITEM "File@35" + ITEM "Nome@15" + ITEM "Collegamento" +END BUTTON DLG_OK 10 2 BEGIN -PROMPT -12 -1 "" + PROMPT -15 -1 "" +END + +BUTTON F_NEWREC 10 2 +BEGIN + PROMPT -25 -1 "" + PICTURE BMP_NEWREC +END + +BUTTON F_LINK 10 2 +BEGIN + PROMPT -35 -1 "" + PICTURE BMP_LINK +END + +BUTTON F_PRINT 10 2 +BEGIN + PROMPT -45 -1 "" + PICTURE BMP_PRINT END BUTTON DLG_CANCEL 10 2 BEGIN -PROMPT -22 -1 "" + PROMPT -55 -1 "" +END + +ENDPAGE + +ENDMASK + +PAGE "Oggetto esterno" -1, -1, 60, 6 + +STRING S_FILE 256 50 +BEGIN + PROMPT 1 1 "File " + FLAGS "B" +END + +STRING S_ALIAS 50 +BEGIN + PROMPT 1 2 "Alias " + FLAGS "DG" +END + +BOOLEAN S_LINK +BEGIN + PROMPT 1 3 "Collegamento esterno" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -15 -1 "" +END + +BUTTON F_NEWREC 10 2 +BEGIN + PROMPT -25 -1 "" + PICTURE BMP_NEWREC +END + +BUTTON F_LINK 10 2 +BEGIN + PROMPT -35 -1 "" + PICTURE BMP_LINK +END + +BUTTON F_PRINT 10 2 +BEGIN + PROMPT -45 -1 "" + PICTURE BMP_PRINT +END + +BUTTON DLG_CANCEL 10 2 +BEGIN + PROMPT -55 -1 "" END ENDPAGE diff --git a/include/controls.cpp b/include/controls.cpp index 8f994963e..5407c78a3 100755 --- a/include/controls.cpp +++ b/include/controls.cpp @@ -1363,7 +1363,7 @@ TPushbutton_control::TPushbutton_control(WINDOW win, short cid, short left, short top, short width, short height, const char* flags, const char* text, short bmp_up, short bmp_dn) - : _bmp_up(bmp_up), _bmp_dn(bmp_dn) + : _bmp_up(bmp_up), _bmp_dn(bmp_dn), _hicon(0) { bool bold; @@ -1383,6 +1383,26 @@ TPushbutton_control::TPushbutton_control(WINDOW win, short cid, set_bmp(bmp_up, bmp_dn); } +TPushbutton_control::~TPushbutton_control() +{ + if (_hicon) + DestroyIcon((HICON)_hicon); +} + +void TPushbutton_control::set_icon(word hicon) +{ + if (_hicon) + { + DestroyIcon((HICON)_hicon); + _hicon = NULL; + } + if (hicon) + { + _hicon = hicon; + set_bmp(0, 0); + } +} + void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn) { if (bmp_up > 0) @@ -1392,6 +1412,7 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn) _picture->add(_bmp_dn = bmp_dn); else _bmp_dn = _bmp_up; + set_icon(NULL); } else { @@ -1405,7 +1426,17 @@ void TPushbutton_control::update() const WINDOW win = parent(); if (attrib & XI_ATR_VISIBLE) - { + { + if (_hicon) + { + HDC hdc = (HDC)xvt_vobj_get_attr(win, ATTR_NATIVE_GRAPHIC_CONTEXT); + const RCT& rct = _obj->v.btn->rct; + int x = rct.left + (rct.right - rct.left - 32) / 2; + int y = rct.top + (rct.bottom - rct.top - 32) / 2; + DrawIcon(hdc, x, y, (HICON)_hicon); + return; + } + const short bmp = (_bmp_dn > 0 && _obj->v.btn->down) ? _bmp_dn : _bmp_up; if (bmp > 0) { diff --git a/include/controls.h b/include/controls.h index 9279aa780..745a78387 100755 --- a/include/controls.h +++ b/include/controls.h @@ -203,6 +203,7 @@ class TPushbutton_control : public TButton_control TString _caption; int _underscore; short _bmp_up, _bmp_dn; + word _hicon; protected: virtual bool event_handler(XI_OBJ* itf, XI_EVENT* xiev); @@ -212,12 +213,13 @@ public: virtual void update(); void set_bmp(short up, short dn); + void set_icon(word hicon); TPushbutton_control(WINDOW win, short cid, short left, short top, short width, short height, const char* flags, const char* text, short bmp_up = 0, short _bmp_dn = 0); - virtual ~TPushbutton_control() {} + virtual ~TPushbutton_control(); }; class TRadiobutton_control : public TButton_control diff --git a/include/default.url b/include/default.url index 8994f6721..8531f97e3 100755 --- a/include/default.url +++ b/include/default.url @@ -117,10 +117,7 @@ image BMP_LINK QRESDIR"link.bmp" image BMP_PRINT QRESDIR"print.bmp" image BMP_SETPRINT QRESDIR"setprint.bmp" image BMP_RECALC QRESDIR"recalc.bmp" -image BMP_BMP QRESDIR"bmp.bmp" -image BMP_XLS QRESDIR"xls.bmp" -image BMP_WAV QRESDIR"wav.bmp" -image BMP_DOC QRESDIR"doc.bmp" +image BMP_OLE QRESDIR"ole.bmp" image BMP_LENTE QRESDIR"lente.bmp" image BMP_FAX QRESDIR"fax.bmp" diff --git a/include/execp.cpp b/include/execp.cpp index f180a4d39..7a90620e6 100755 --- a/include/execp.cpp +++ b/include/execp.cpp @@ -380,31 +380,48 @@ static long get_reg_key(HKEY key, const char* subkey, TString& retdata) return retval; } +bool ext2app(const char* ext, TString& app) +{ + bool ok = FALSE; + TString key(_MAX_PATH); + + key = ext; + if (key[0] != '.') + key.insert(".", 0); + + if (get_reg_key(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS) + { + key << "\\shell\\open\\command"; + if (get_reg_key(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS) + { + key.strip("\""); + int pos = key.find("%1"); + if (pos > 0) + key.cut(pos); + key.trim(); + app = key; + ok = TRUE; + } + } + return ok; +} + bool goto_url(const char* url) { - TString key(MAX_PATH*2); bool retflag = FALSE; HINSTANCE hinst = ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL); DWORD winst = DWORD((DWORD*)hinst); UINT error = UINT(winst); // Tutto 'sto giro per evitare un warning - if (error < 32) + if (error <= 32) { - if (get_reg_key(HKEY_CLASSES_ROOT, ".htm", key) == ERROR_SUCCESS) + TString app(_MAX_PATH); + if (ext2app(".htm", app)) { - key << "\\shell\\open\\command"; - if (get_reg_key(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS) - { - int pos = key.find("\"%1\""); - if (pos < 0) - pos = key.find("%1"); - if (pos > 0) - key.cut(pos); - key << ' ' << url; - error = WinExec(key, SW_SHOWNORMAL); - if (error > 31) - retflag = TRUE; - } + app << ' ' << url; + error = WinExec(app, SW_SHOWNORMAL); + if (error > 32) + retflag = TRUE; } } else @@ -412,3 +429,12 @@ bool goto_url(const char* url) return retflag; } + + +bool print_url(const char* url) +{ + HINSTANCE hinst = ShellExecute(NULL, "print", url, NULL, NULL, SW_SHOWNORMAL); + DWORD winst = DWORD((DWORD*)hinst); + UINT error = UINT(winst); // Tutto 'sto giro per evitare un warning + return error >= 32; +} diff --git a/include/execp.h b/include/execp.h index 106d59476..1cf7184d7 100755 --- a/include/execp.h +++ b/include/execp.h @@ -1,8 +1,8 @@ #ifndef __EXECP_H #define __EXECP_H -#ifndef __OBJECT_H -#include +#ifndef __STRINGS_H +#include #endif // @doc EXTERNAL @@ -51,7 +51,11 @@ public: TExternal_app(const char* p); }; +// Estrae lapplicazione associata all'estensione +bool ext2app(const char* ext, TString& app); // Va ad un URl qualsiasi bool goto_url(const char* url); +// Stampa un URl qualsiasi +bool print_url(const char* url); #endif diff --git a/include/golem.cpp b/include/golem.cpp index 4345a6148..8ad190442 100755 --- a/include/golem.cpp +++ b/include/golem.cpp @@ -1,212 +1,354 @@ #define STRICT #define XVT_INCL_NATIVE -#include -#include +#include #include #include -#include +#include #include #include #include #include -#include +#include -long TGolem::_count = 0; -TFilename* TGolem::_path = NULL; -TConfig* TGolem::_config = NULL; -TRelation* TGolem::_golem = NULL; +#include "bagn006.h" -TGolem::TGolem(const char* cls, long id) -: _class(cls), _id(id) -{ - CHECK(_class.not_empty() && id >= 0, "Invalid Golem creation"); - _class.upper(); +/////////////////////////////////////////////////////////// +// Campi GOLEM +/////////////////////////////////////////////////////////// - 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++; +TString& TGolem_field::get_window_data() +{ + return _str; } -TGolem::~TGolem() -{ - _count--; - if (_count == 0) +void TGolem_field::set_window_data(const char* data) +{ + TFilename app(_MAX_PATH); + if (*data > ' ') { - 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; + TFilename file(data); + const int pipe = file.find('|'); + if (pipe > 0) file.cut(pipe); - TExternal_app app(e); - ok = app.run(FALSE, FALSE) == 0; + HINSTANCE hinst = FindExecutable(file, ".", app.get_buffer()); + DWORD* pinst = (DWORD*)hinst; + UINT err = LOWORD(pinst); + if (err <= 32) + ext2app(".htm", app); + if (err > 32 && !fexist(app)) + { + warning_box("Il file %s e' associato all'applicazione\n" + "%s, che non e' presente sul sistema", + file.get_buffer(), app.get_buffer()); + } + } + TPushbutton_control* btn = (TPushbutton_control*)_ctl; + if (app.not_empty()) + { + HINSTANCE hInst = (HINSTANCE)xvt_vobj_get_attr(NULL_WIN, ATTR_WIN_INSTANCE); + HICON hicon = ExtractIcon(hInst, app, 0); + DWORD dwicon = DWORD((DWORD*)hicon); + WORD icon = LOWORD(dwicon); + if (icon) + btn->set_icon(icon); + else + { +#ifdef DBG + warning_box("Can't extract %s icon!", app.get_buffer()); +#endif + btn->set_bmp(BMP_OLE, 0); + } } - + else + { + btn->set_bmp(BMP_OLE, 0); + } + + RCT rct; btn->get_rect(rct); + xi_invalidate_rect(btn->parent(), &rct); +} + +bool TGolem_field::is_editable() const +{ return FALSE; } + +void TGolem_field::parse_head(TScanner& scanner) +{ + _ctl_data._width = scanner.integer(); + if (_ctl_data._width <= 0) _ctl_data._width = 10; + _ctl_data._height = scanner.integer(); // Height + if (_ctl_data._height <= 0) _ctl_data._height = 1; + _ctl_data._bmp_up = BMP_OLE; +} + +void TGolem_field::create(WINDOW parent) +{ + _ctl = new TPushbutton_control(parent, _ctl_data._dlg, + _ctl_data._x, _ctl_data._y, + _ctl_data._width+2, _ctl_data._height, + _ctl_data._flags, _ctl_data._prompt, + _ctl_data._bmp_up, _ctl_data._bmp_dn); +} + +bool TGolem_field::autoload(const TRelation& r) +{ + const bool ok = TEditable_field::autoload(r); + if (ok) + _old_value = get(); + else + _old_value.cut(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) +bool TGolem_field::autosave(TRelation& r) +{ + if (field() != NULL) { - 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) + TToken_string new_value(get(), '\n'); + if (new_value != _old_value) + { + TFilename golem_path(_MAX_PATH); + TDir dir; dir.get(r.lfile().num()); + const long ditta = dir.is_com() ? 0 : prefix().get_codditta(); + golem_path = firm2dir(ditta); + golem_path.add("golem"); + if (!fexist(golem_path)) + make_dir(golem_path); + + const int old_items = _old_value.items(); + const int new_items = new_value.items(); + const int items = new_items > old_items ? new_items : old_items; + + TToken_string old_row, new_row; + TFilename old_file, new_file; + for (int i = 0; i < items; i++) { - 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; + old_row = _old_value.get(i); // Devo usare l'indice ogni volta ... + new_row = new_value.get(i); // ... perche' le TToken_string cambiano! - } - - return ok == FL_OK; + old_file = old_row.get(0); + new_file = new_row.get(0); + + if (old_file != new_file) + { + const was_stored = old_row.get_char(2) <= ' '; + const is_stored = new_row.get_char(2) <= ' '; + if (was_stored && fexist(old_file)) + ::remove(old_file); + if (is_stored && !new_file.blank()) + { + char ext[_MAX_EXT]; + _splitpath(new_file, NULL, NULL, NULL, ext); + + // Very childish! I can do much better + for (long n = 1; ; n++) + { + TString16 name; name.format("%08ld%s", n, ext); + old_file = golem_path; + old_file.add(name); + if (!fexist(old_file)) + break; + } + fcopy(new_file, old_file); + new_row.add(old_file, 0); + new_value.add(new_row, i); + + // Cancella il file originale se temporaneo + TFilename tmp; tmp.tempdir(); + if (tmp.compare(new_file, tmp.len(), TRUE) == 0) + ::remove(new_file); + } + } + } + _old_value = new_value; + } + } + return TEditable_field::autosave(r); } +static bool file_handler(TMask_field& f, KEY k) +{ + TMask& m = f.mask(); + + if (k == K_F9) + { + FILE_SPEC fs; + xvt_fsys_convert_str_to_dir(".", &fs.dir); + strcpy(fs.type, ""); + strcpy(fs.name, "*.*"); + strcpy(fs.creator, "GOLEM"); + + xvt_fsys_save_dir(); + FL_STATUS ok = xvt_dm_post_file_open(&fs, "Selezionare il file ..."); + if (ok == FL_OK) + { + xvt_fsys_restore_dir(); + + TFilename file; + xvt_fsys_convert_dir_to_str(&fs.dir, file.get_buffer(), file.size()); + file.add(fs.name); + file.ext(fs.type); + f.set(file); + k = K_TAB; + } + } + + if (k == K_TAB && f.focusdirty()) + { + TFilename file = m.get(S_FILE); + if (fexist(file)) + { + char ext[_MAX_EXT]; + char name[_MAX_FNAME]; + _splitpath(file, NULL, NULL, name, ext); + file = name; file.ext(ext); + m.enable(S_LINK); + m.disable(F_NEWREC); + m.enable(F_LINK); + m.enable(F_PRINT); + } + else + { + const bool full = file.not_empty(); + m.set(S_LINK, full ? "X" : ""); + m.disable(S_LINK); + m.enable(F_NEWREC, full); + m.enable(F_LINK, full); + m.disable(F_PRINT); + file.cut(0); + } + m.set(S_ALIAS, file); + } + + return TRUE; +} + +static bool link_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TMask& m = f.mask(); + TFilename url = m.get(S_FILE); + short id = f.dlg(); + if (id == F_NEWREC && url.not_empty()) + { + if (!fexist(url)) + { + TFilename name; + char ext[_MAX_EXT]; + _splitpath(url, NULL, NULL, name.get_buffer(), ext); + if (name.not_empty() && *ext) + { + name.ext(ext); + url.tempdir(); + url.add(name); + ofstream out(url); // Crea un file vuoto + } + else + url.cut(0); + m.set(S_FILE, url, TRUE); // ... memorizza il suo nome ... + m.reset(S_LINK); // Non puo' essere un collegamento + } + else + id = F_LINK; + } + + if (url.not_empty()) + { + bool open = TRUE; + if (id == DLG_PRINT) + open = !print_url(url); + if (open) + goto_url(url); + } + } + return TRUE; +} + +static bool main_link_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TSheet_field& sheet = f.mask().sfield(F_SHEET); + if (sheet.items() > 0) + { + sheet.check_row(sheet.selected()); + TMask& sm = sheet.sheet_mask(); + TMask_field& link = sm.field(f.dlg()); + link_handler(link, K_SPACE); + } + } + return TRUE; +} + +bool TGolem_field::on_key(KEY key) +{ + bool ok = TRUE; + if (key == K_SPACE) + { + TMask* msk = new TMask("bagn006"); + TSheet_field& sheet = msk->sfield(F_SHEET); + + TMask& sm = sheet.sheet_mask(); + sm.set_handler(S_FILE, file_handler); + sm.set_handler(F_NEWREC, link_handler); + sm.set_handler(F_LINK, link_handler); + sm.set_handler(F_PRINT, link_handler); + + TToken_string tmp = get(); + + if (roman()) + { + tmp.separator('\n'); + for (const char* row = tmp.get(0); row; row = tmp.get()) + { + if (*row > ' ') + sheet.row(-1) = row; + } + msk->set_handler(F_NEWREC, main_link_handler); + msk->set_handler(F_LINK, main_link_handler); + msk->set_handler(F_PRINT, main_link_handler); + if (msk->run() == K_ENTER) + { + tmp.cut(0); + for (int r = 0; r < sheet.items(); r++) + { + TToken_string& row = sheet.row(r); + if (row[0] > ' ') + tmp.add(row); + } + set(tmp); + } + } + else + { + for (int i = 0; i < 3; i++) + sm.set(S_FILE+i, tmp.get()); + + if (sm.run() == K_ENTER) + { + tmp.cut(0); + for (int i = 0; i < 3; i++) + tmp.add(sm.get(S_FILE+i)); + set(tmp); + } + } + + delete msk; + } + return ok; +} + +TGolem_field::TGolem_field(TMask* m) + : TEditable_field(m), _old_value(80, '\n') +{ } + +TGolem_field::~TGolem_field() +{ } + +/////////////////////////////////////////////////////////// +// Obsolete DDE management +/////////////////////////////////////////////////////////// #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 diff --git a/include/golem.h b/include/golem.h index a946f0816..8f20e68c5 100755 --- a/include/golem.h +++ b/include/golem.h @@ -1,89 +1,10 @@ #ifndef __GOLEM_H #define __GOLEM_H -#ifndef __WINDOW_H -#include -#endif - -#ifndef __CONFIG_H -class TConfig; -#endif - #ifndef __STRINGS_H #include #endif -#ifndef __RELATION_H -class TRelation; -#endif - -// @doc EXTERNAL - -// @class TGolem | Classe per le gestione del Generic Object Linking & Embedding Mechanism -// -// @base public | TSortable -class TGolem : public TSortable - -// @author:(INTERNAL) Guido - -// @access:(INTERNAL) Private Member -{ - // @cmember:(INTERNAL) Numero di GOLEM costruiti fin'ora - static long _count; - // @cmember:(INTERNAL) di appoggio per leggere i paramentri - static TConfig* _config; - // @cmember:(INTERNAL) Nome del file di config - static TFilename* _path; - // @cmember:(INTERNAL) dei GOLEM - static TRelation* _golem; - - // @cmember:(INTERNAL) Nome della classe del GOLEM - TString16 _class; - // @cmember:(INTERNAL) Identificatore del GOLEM - long _id; - -// @access Protected Member -protected: - // @cmember Ritorna il path completo dell'oggetto inserito.

verifica se esiste - const TFilename& path(bool test = FALSE) const; - // @cmember Ritorna l'estensione del GOLEM - const char* ext() const; - // @cmember Ritorna il di appoggio per leggere i paramentri - TConfig& config() const; - // @cmember Genera il prossimo identificatore libero - long new_id() const; - -protected:// TSortable - // @cmember Confronta due GOLEM (vedi ) - virtual int compare(const TSortable& o) const; - -// @access Public Member -public: // TObject - // @cmember Ritorna il nome della classe - virtual const char* class_name() const; - // @cmember Ritorna l'identificatore della classe - virtual word class_id() const; - // @cmember Ritorna se si tratta di un oggetto valido - virtual bool ok() const; - -public: - // @cmember Ritorna l'identificatore dell'icona del GOLEM - virtual short icon() const; - // @cmember Chiama il programma di moifica del GOLEM - virtual bool edit(); - // @cmember Mostra il dialog box di selezione del file - virtual bool import(); - - // @cmember Ritorna l'identificatore del GOLEM - long id() const - { return _id; } - - // @cmember Costruttore - TGolem(const char* cls, long id); - // @cmember Distruttore - virtual ~TGolem(); -}; - // @doc EXTERNAL // @class TDDE | Classe per la gestione del DDE diff --git a/include/mask.cpp b/include/mask.cpp index d5934357a..01b2c000e 100755 --- a/include/mask.cpp +++ b/include/mask.cpp @@ -836,7 +836,8 @@ TMask_field* TMask::parse_field(TScanner& scanner) if (k == "LI") return new TList_field(this); if (k == "RA") return new TRadio_field(this); if (k == "ME") return new TMemo_field(this); - if (k == "ZO") return new TZoom_field(this); + if (k == "ZO") return new TZoom_field(this); + if (k == "GO") return new TGolem_field(this); if (k == "BR") return new TBrowsefile_field(this); if (k == "SP") { diff --git a/include/maskfld.cpp b/include/maskfld.cpp index 3afc803cc..a87df700e 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -1755,13 +1754,6 @@ void TBrowse::parse_input(TScanner& scanner) scanner.push(); 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 { @@ -2392,30 +2384,11 @@ KEY TBrowse::run() switch (k) { case K_CTRL+'G': - if (_insert[0] == 'G') - { - field().set(format("%ld", selected+1)); - TGolem golem(&_insert[1], atol(field().get())); - k = golem.edit() ? K_ENTER : K_ESC; - if (k = K_ESC) - error_box("Impossibile modificare l'oggetto"); - } - else - { - *_cursor = selected; - k = do_link(FALSE) ? K_ENTER : K_ESC; - } + *_cursor = selected; + k = do_link(FALSE) ? K_ENTER : K_ESC; break; case K_INS: - if (_insert[0] == 'G') - { - TGolem gol(&_insert[1], 0); - if (gol.import()) - field().set(format("%ld", gol.id())); - k = K_ENTER; - } - else - k = do_link(TRUE) ? K_ENTER : K_ESC; + k = do_link(TRUE) ? K_ENTER : K_ESC; break; case K_ENTER: *_cursor = selected; @@ -4201,3 +4174,6 @@ const char* TZoom_field::win2raw(const char* data) const const char* TZoom_field::get_first_line() const { return raw2win(_str); } + + + diff --git a/include/maskfld.h b/include/maskfld.h index 11b4b33ef..058c57bdc 100755 --- a/include/maskfld.h +++ b/include/maskfld.h @@ -653,7 +653,6 @@ public: // @cmember Ritorna TRUE se il campo e' di tipo editable virtual bool is_editable() const { return TRUE; } - TEditable_field(TMask* m); virtual ~TEditable_field(); }; @@ -1386,6 +1385,32 @@ public: virtual ~TZoom_field(); }; +class TGolem_field : public TEditable_field +{ + TToken_string _old_value; + +protected: // TEditable_field + virtual TString& get_window_data(); + virtual void set_window_data(const char* data); + + virtual bool on_key(KEY k); + + // @cmember Ritorna FALSE in quanto il campo non e' realmente editable + virtual bool is_editable() const; + + virtual void parse_head(TScanner& scanner); + virtual void create(WINDOW parent); + + // @cmember Legge dalla relazione il valore del campo + virtual bool autoload(const TRelation& r); + // @cmember Scrive sulla relazione il valore del campo + virtual bool autosave(TRelation& r); + +public: + TGolem_field(TMask* m); + virtual ~TGolem_field(); +}; + #endif // __MASKFLD_H diff --git a/include/strings.h b/include/strings.h index 8df7c8db2..23f40f38e 100755 --- a/include/strings.h +++ b/include/strings.h @@ -379,25 +379,24 @@ public: // @class TFilename | Classe per la gestione dei nome dei file // -// @base public | TString80 -class TFilename : public TString80 +// @base public | TString +class TFilename : public TString // @author:(INTERNAL) Guido { - // @comm Nel caso di utilizzo di Windows 95 occorre cambiare le classe base in // @access Public Member public: // @cmember Costruttore - TFilename(const char* n = "") : TString80(n) - {} + TFilename(const char* n = "") : TString(256) + { set(n); } // @cmember Costruttore - TFilename(const TString& n) : TString80((const char*)n) - {} + TFilename(const TString& n) : TString(256) + { set(n); } // @cmember Costruttore - TFilename(const TFilename& n) : TString80((const char*)n) - {} + TFilename(const TFilename& n) : TString(256) + { set(n); } // @cmember Assegnazione tra TFile e stringa const TString& operator =(const char* s) diff --git a/include/urldefid.h b/include/urldefid.h index 6e7a3f10a..9edc9322e 100755 --- a/include/urldefid.h +++ b/include/urldefid.h @@ -66,10 +66,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_OLE 135 +#define BMP_1 136 +#define BMP_2 137 +#define BMP_3 138 #define BMP_SAVERECDN 153 #define BMP_DELRECDN 154 #define BMP_NEWRECDN 155 diff --git a/include/utility.cpp b/include/utility.cpp index 7e24ed771..dab58f530 100755 --- a/include/utility.cpp +++ b/include/utility.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -78,8 +79,8 @@ bool fcopy( bool ok = TRUE; while (ok) { - const word letti = fread((char*)(const char*)buffer, 1, size, i); - ok = fwrite((char*)(const char*)buffer, 1, letti, o) == letti; + const word letti = fread(buffer.get_buffer(), 1, size, i); + ok = fwrite(buffer.get_buffer(), 1, letti, o) == letti; if (letti < size) break; } @@ -101,8 +102,18 @@ bool fcopy( // @flag FALSE | Se il file non esiste bool fexist( const char* file) // @parm Nome del file di cui contrallarne l'esistenza -{ - return access(file, F_OK) == 0; +{ + int err = access(file, F_OK); + if (err) // Se la access fallisce provo con la _lopen + { + HFILE hf = _lopen(file, READ); + if (hf != HFILE_ERROR) + { + _lclose(hf); + err = 0; + } + } + return err == 0; } // @doc EXTERNAL @@ -433,46 +444,3 @@ os_type get_os_type() #endif } -#ifdef __WATCOMC__ - -// @doc EXTERNAL - -// @func Costruisce il percorso per un file temporaneo -// -// @rdesc Ritorna il nome assoluto del file temporaneo -char * tempnam( - const char * dir , // @parm Nome della directory nel quale inserire il file temporaneo - const char * prefix) // @parm Evenutale prefisso da dare al file temporaneo - - // @comm Il nome della directory viene letto dalla variabile d'ambiente chiamata - // TMP, solo nel caso questa non esista viene utilizzato il nome passato - // in

. - // E' definita solo nel caso si utilizzi il WATCOM C/C++. - -{ - TFilename tmpdir(getenv("TMP")); - static word counter = 1; - - if (tmpdir.empty() || !fexist(tmpdir)) - { - tmpdir = dir; - if (tmpdir.empty() || !fexist(tmpdir)) - tmpdir = ""; - } - if (is_not_slash(tmpdir.right(1)[0])) - tmpdir << '/'; - tmpdir << prefix ; - const int lastpos = tmpdir.len() ; - tmpdir << format("%ud", counter); - - while (!fexist(tmpdir)) - { - counter++; - if (counter == 0) counter = 1; - tmpdir.cut(lastpos); - tmpdir << format("%ud", counter); - } - return strdup(tmpdir); -} -#endif - diff --git a/include/validate.cpp b/include/validate.cpp index b2fe4b6c6..3e8b4735f 100755 --- a/include/validate.cpp +++ b/include/validate.cpp @@ -617,7 +617,7 @@ HIDDEN bool _chkfld_val(TMask_field& f, KEY k) HIDDEN bool _filename_val(TMask_field& f, KEY) { const TFilename fn(f.get()); - return fn.ok(); + return fn.blank() || fn.ok(); } HIDDEN bool _zerofill_val(TMask_field& f, KEY k) diff --git a/include/window.cpp b/include/window.cpp index e2ca517e7..cdf3dcc9b 100755 --- a/include/window.cpp +++ b/include/window.cpp @@ -389,6 +389,12 @@ TImage::TImage(const TImage& im, short w, short h) : _image(NULL) } } +// Certified 90% +TImage::TImage(short w, short h, XVT_IMAGE_FORMAT fmt) : _image(NULL) +{ + set(xvt_image_create(fmt, w, h, NULL)); +} + // Certified 100% TImage::~TImage() { diff --git a/include/window.h b/include/window.h index e9a7c7d65..3afcc4bbe 100755 --- a/include/window.h +++ b/include/window.h @@ -132,7 +132,8 @@ public: TImage(short id); // @cmember Costruttore. Viene passata l'immagine e le sue diemsioni TImage(const TImage& i, short width, short height); - + // @cmember Costruttore. Viene passata l'immagine e le sue diemsioni + TImage(short width, short height, XVT_IMAGE_FORMAT fmt = XVT_IMAGE_CL8); // @cmember Distruttore virtual ~TImage(); };