ba1600.cpp Corretto ordinamento e gestiti "separatori"

ba1600b.uml Cosmesi
ba1700.cpp  Usato un array sheet al posto di una maschera
ba1700a.h   Tolte #define inutili
ba1700a.uml Di prossima cancellazione
ba4200.cpp  Usata edit_url al posto di goto_uro
ba4300.cpp  Usata edit_url al posto di goto_uro


git-svn-id: svn://10.65.10.50/trunk@5692 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1997-12-04 14:07:49 +00:00
parent 46f3255222
commit 859668a090
7 changed files with 155 additions and 111 deletions

View File

@ -3,6 +3,7 @@
#define XVT_INCL_NATIVE #define XVT_INCL_NATIVE
#include <applicat.h> #include <applicat.h>
#include <execp.h> #include <execp.h>
#include <golem.h>
#include <msksheet.h> #include <msksheet.h>
#include <prefix.h> #include <prefix.h>
#include <progind.h> #include <progind.h>
@ -90,14 +91,12 @@ void TInstall_ini::export_paragraph(const char* module, const char* summary)
void TInstall_ini::export_module_paragraphs(const char* module, const char* summary) void TInstall_ini::export_module_paragraphs(const char* module, const char* summary)
{ {
TString mod; TString mod;
for (int sub = -1; ; sub++) for (int sub = -1; sub <= 9; sub++)
{ {
mod = module; mod = module;
if (sub >= 0) mod << sub; if (sub >= 0) mod << sub;
if (set_paragraph(mod)) if (set_paragraph(mod))
export_paragraph(mod, summary); export_paragraph(mod, summary);
else
break;
} }
} }
@ -185,6 +184,7 @@ protected:
static bool sheet_notify(TSheet_field& sf, int row, KEY key); static bool sheet_notify(TSheet_field& sf, int row, KEY key);
static bool missing_notify(TSheet_field& sf, int row, KEY key); static bool missing_notify(TSheet_field& sf, int row, KEY key);
static bool file_handler(TMask_field& f, KEY k); static bool file_handler(TMask_field& f, KEY k);
static bool edit_handler(TMask_field& f, KEY k);
static bool link_handler(TMask_field& f, KEY k); static bool link_handler(TMask_field& f, KEY k);
static bool deselect_handler(TMask_field& f, KEY k); static bool deselect_handler(TMask_field& f, KEY k);
@ -388,6 +388,23 @@ bool TModule_mask::file_handler(TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
bool TModule_mask::edit_handler(TMask_field& f, KEY k)
{
if (k == K_SPACE)
{
TFilename file = f.mask().get(101);
if (stricmp(file.ext(), "exe") == 0)
{
file << " -0";
TExternal_app app(file);
app.run();
}
else
::edit_url(file);
}
return TRUE;
}
bool TModule_mask::link_handler(TMask_field& f, KEY k) bool TModule_mask::link_handler(TMask_field& f, KEY k)
{ {
if (k == K_SPACE) if (k == K_SPACE)
@ -398,7 +415,7 @@ bool TModule_mask::link_handler(TMask_field& f, KEY k)
TSheet_field& sheet = mainmask.sfield(F_SHEET); TSheet_field& sheet = mainmask.sfield(F_SHEET);
TToken_string& newrow = sheet.row(-1); TToken_string& newrow = sheet.row(-1);
newrow = modmask.get(101); // Nome del file newrow = modmask.get(101); // Nome del file
newrow.add(" "); // Non fa' parte dell'aggiornamento newrow.add(" "); // Non e' nell'aggiornamento
newrow.add(mainmask.get(F_MODULE)); // Modulo attuale newrow.add(mainmask.get(F_MODULE)); // Modulo attuale
newrow << '1'; // Sottomodulo standard newrow << '1'; // Sottomodulo standard
if (modmask.is_running()) if (modmask.is_running())
@ -509,7 +526,7 @@ void TModule_mask::save()
TToken_string tmp; TToken_string tmp;
index = 0; index = 0;
FOR_EACH_SHEET_ROW_BACK(sheet, r, row) FOR_EACH_SHEET_ROW(sheet, r, row)
{ {
TString16 sub = row->get(2); TString16 sub = row->get(2);
if (sub.blank()) if (sub.blank())
@ -541,6 +558,7 @@ TModule_mask::TModule_mask()
TSheet_field& s = sfield(F_SHEET); TSheet_field& s = sfield(F_SHEET);
s.set_notify(sheet_notify); s.set_notify(sheet_notify);
s.sheet_mask().set_handler(S_FILE, file_handler); s.sheet_mask().set_handler(S_FILE, file_handler);
s.sheet_mask().set_handler(DLG_EDIT, edit_handler);
TSheet_field& miss = sfield(F_MISSING); TSheet_field& miss = sfield(F_MISSING);
miss.set_notify(missing_notify); miss.set_notify(missing_notify);
@ -712,33 +730,40 @@ void TFascicolator_mask::load()
set(F_DISKSIZE, ini.get("DiskSize")); set(F_DISKSIZE, ini.get("DiskSize"));
set(F_DISKPATH, ini.get("DiskPath")); set(F_DISKPATH, ini.get("DiskPath"));
FOR_EACH_ARRAY_ROW_BACK(modules, m, riga) FOR_EACH_ARRAY_ROW(modules, m, riga)
{ {
const TString& module = *riga; const TString& module = *riga;
if (module.len() == 2) if (module[0] == '_' || module.len() == 2)
{ {
TToken_string& row = s.row(-1); TToken_string& row = s.row(m);
ini.set_paragraph(module); ini.set_paragraph(module);
row = ini.get("Descrizione"); row = ini.get("Descrizione");
row.add(module);
tmp = ini.get("Versione");
row.add(tmp);
tmp = ini.get("Data");
row.add(tmp);
tmp = ini.get("Moduli");
row.add(tmp);
tmp = ini.get("PreProcess"); if (module[0] == '_')
row.add(tmp); {
s.disable_cell(m, -1);
}
else
{
row.add(module);
tmp = ini.get("Versione");
row.add(tmp);
tmp = ini.get("Data");
row.add(tmp);
tmp = ini.get("PostProcess"); tmp = ini.get("Moduli");
row.add(tmp); row.add(tmp);
tmp = ini.get("PreProcess");
row.add(tmp);
tmp = ini.get("PostProcess");
row.add(tmp);
}
} }
} }
s.rows_array().sort();
} }
void TFascicolator_mask::save() void TFascicolator_mask::save()

View File

@ -54,30 +54,36 @@ BEGIN
FLAGS "B" FLAGS "B"
END END
STRING 103 3
BEGIN
PROMPT 30 2 "Sottomodulo "
END
BOOLEAN 102 BOOLEAN 102
BEGIN BEGIN
PROMPT 1 2 "Includi nell'aggiornamento" PROMPT 1 2 "Includi nell'aggiornamento"
END END
STRING 103 3
BEGIN
PROMPT 34 2 "Sottomodulo "
END
BUTTON DLG_OK 10 2 BUTTON DLG_OK 10 2
BEGIN BEGIN
PROMPT -13 -1 "" PROMPT -14 -1 ""
END END
BUTTON DLG_DELREC 10 2 BUTTON DLG_DELREC 10 2
BEGIN BEGIN
PROMPT -23 -1 "~Scollega" PROMPT -24 -1 "~Elimina"
PICTURE BMP_DELREC PICTURE BMP_DELREC
END END
BUTTON DLG_EDIT 10 2
BEGIN
PROMPT -34 -1 "Edit"
PICTURE BMP_EDIT
END
BUTTON DLG_CANCEL 10 2 BUTTON DLG_CANCEL 10 2
BEGIN BEGIN
PROMPT -33 -1 "" PROMPT -44 -1 ""
END END
ENDPAGE ENDPAGE

View File

@ -1,10 +1,11 @@
#include <dos.h> #include <dos.h>
#define XVT_INCL_NATIVE
#include <applicat.h> #include <applicat.h>
#include <colors.h> #include <colors.h>
#include <execp.h> #include <execp.h>
#include <msksheet.h>
#include <progind.h> #include <progind.h>
#include <sheet.h>
#include <utility.h> #include <utility.h>
#include "ba1.h" #include "ba1.h"
@ -27,16 +28,21 @@ HIDDEN int compare_version(const TString& v1, const TString& v2)
// Maschera principale // Maschera principale
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
class TInstaller_mask : public TMask class TInstaller_mask : public TArray_sheet
{ {
static TInstaller_mask* _curr_mask;
protected: // TSheet
bool on_key(KEY key);
protected: protected:
static bool update_handler(TMask_field& fld, KEY key);
static bool path_handler(TMask_field& fld, KEY key); static bool path_handler(TMask_field& fld, KEY key);
static bool sheet_notify(TSheet_field& s, int r, KEY k); static bool sheet_notify(TSheet_field& s, int r, KEY k);
static bool install_handler(TMask_field& fld, KEY key); static bool install_handler(TMask_field& fld, KEY key);
bool add_module(TConfig& ini, const TString& module) const; bool add_module(TConfig& ini, const TString& module);
void update_version(); void update_version();
void install_selection();
bool do_process(TAuto_token_string& commands) const; bool do_process(TAuto_token_string& commands) const;
bool pre_process(TInstall_ini& ini, const char* module) const; bool pre_process(TInstall_ini& ini, const char* module) const;
@ -47,21 +53,24 @@ public:
bool install(const TString& module); bool install(const TString& module);
TInstaller_mask(); TInstaller_mask();
virtual ~TInstaller_mask() { } virtual ~TInstaller_mask();
}; };
TInstaller_mask* TInstaller_mask::_curr_mask = NULL;
// Copia nello sheet i dati di un modulo prendendoli da un .ini // Copia nello sheet i dati di un modulo prendendoli da un .ini
bool TInstaller_mask::add_module(TConfig& ini, const TString& module) const bool TInstaller_mask::add_module(TConfig& ini, const TString& module)
{ {
bool ok = ini.set_paragraph(module); bool ok = ini.set_paragraph(module);
if (ok) if (ok)
{ {
TSheet_field& sheet = sfield(F_SHEET); TToken_string row;
TToken_string& row = sheet.row(-1); row = " "; // Not selected
row = ini.get("Descrizione"); row.add(ini.get("Descrizione"));
row.add(module); row.add(module);
row.add(ini.get("Versione")); row.add(ini.get("Versione"));
row.add(ini.get("Data")); row.add(ini.get("Data"));
add(row);
} }
return ok; return ok;
} }
@ -70,17 +79,18 @@ void TInstaller_mask::update_version()
{ {
TInstall_ini ini; TInstall_ini ini;
TSheet_field& sheet = sfield(F_SHEET); TString_array& array = rows_array();
FOR_EACH_SHEET_ROW_BACK(sheet, m, row) FOR_EACH_ARRAY_ROW_BACK(array, m, row)
{ {
const TString16 module = row->get(1); const TString16 module = row->get(2);
ini.set_paragraph(module); ini.set_paragraph(module);
const TString16 newver = row->get(2); const TString16 newver = row->get(3);
const TString16 oldver = ini.get("Versione"); const TString16 oldver = ini.get("Versione");
row->add(oldver, 4); row->add(oldver, 5);
row->add(ini.get("Data"), 5); row->add(ini.get("Data"), 6);
/*
const int cmp = compare_version(newver, oldver); const int cmp = compare_version(newver, oldver);
if (cmp > 0) if (cmp > 0)
sheet.set_back_and_fore_color(FOCUS_BACK_COLOR, NORMAL_COLOR, m); sheet.set_back_and_fore_color(FOCUS_BACK_COLOR, NORMAL_COLOR, m);
@ -88,8 +98,9 @@ void TInstaller_mask::update_version()
sheet.set_back_and_fore_color(NORMAL_BACK_COLOR, NORMAL_COLOR, m); sheet.set_back_and_fore_color(NORMAL_BACK_COLOR, NORMAL_COLOR, m);
if (cmp < 0) if (cmp < 0)
sheet.set_back_and_fore_color(DISABLED_BACK_COLOR, NORMAL_COLOR, m); sheet.set_back_and_fore_color(DISABLED_BACK_COLOR, NORMAL_COLOR, m);
*/
} }
sheet.force_update(); force_update();
} }
// Cerca nel percorso specificato sulla maschera tutti i possibili files .ini // Cerca nel percorso specificato sulla maschera tutti i possibili files .ini
@ -101,9 +112,7 @@ bool TInstaller_mask::autoload()
return error_box("Specificare un percorso valido"); return error_box("Specificare un percorso valido");
TWait_cursor hourglass; TWait_cursor hourglass;
TSheet_field& sheet = sfield(F_SHEET); destroy();
sheet.destroy();
TFilename ininame; TFilename ininame;
ininame = path; ininame = path;
@ -140,13 +149,13 @@ bool TInstaller_mask::autoload()
} }
} }
sheet.rows_array().sort(); rows_array().sort();
const bool ok = sheet.items() > 0; const bool ok = items() > 0;
if (ok) if (ok)
update_version(); update_version();
else else
sheet.error_box("Non e' stato trovato nessun modulo da installare\n" error_box("Non e' stato trovato nessun modulo da installare\n"
"in %s", (const char*)path); "in %s", (const char*)path);
return ok; return ok;
} }
@ -174,7 +183,8 @@ bool TInstaller_mask::pre_process(TInstall_ini& ini, const char* module) const
TInstall_ini cur_ini; TInstall_ini cur_ini;
TAuto_token_string altri(ini.get("Moduli", module)); TAuto_token_string altri(ini.get("Moduli", module));
altri.add("ba"); // La base e' obbligatoria per tutti if (stricmp(module, "ba") != 0)
altri.add("ba"); // La base e' obbligatoria per tutti
TString submodule, curver, reqver; TString submodule, curver, reqver;
for (const char* mod = altri.get(0); mod && ok; mod = altri.get()) for (const char* mod = altri.get(0); mod && ok; mod = altri.get())
@ -338,16 +348,6 @@ bool TInstaller_mask::install(const TString& module)
return ok; return ok;
} }
bool TInstaller_mask::update_handler(TMask_field& fld, KEY key)
{
if (key == K_SPACE)
{
TInstaller_mask& m = (TInstaller_mask&)fld.mask();
m.autoload();
}
return TRUE;
}
bool TInstaller_mask::path_handler(TMask_field& fld, KEY key) bool TInstaller_mask::path_handler(TMask_field& fld, KEY key)
{ {
bool ok = TRUE; bool ok = TRUE;
@ -360,31 +360,24 @@ bool TInstaller_mask::path_handler(TMask_field& fld, KEY key)
fld.set(path); fld.set(path);
} }
if (fexist(path)) if (fexist(path))
update_handler(fld, K_SPACE); _curr_mask->autoload();
else else
ok = fld.error_box("Specificare un percorso valido"); ok = fld.error_box("Specificare un percorso valido");
} }
return ok; return ok;
} }
bool TInstaller_mask::sheet_notify(TSheet_field& s, int r, KEY k)
{
bool ok = TRUE;
if (k == K_INS) // Impedisci l'inserimento di nuove righe
ok = FALSE;
return ok;
}
bool TInstaller_mask::install_handler(TMask_field& fld, KEY key) void TInstaller_mask::install_selection()
{ {
bool ok = TRUE; TString_array& arr = rows_array();
if (key == K_SPACE) FOR_EACH_ARRAY_ROW(arr, r, row) if (checked(r))
{ {
TMask& m = fld.mask(); const TString modulo = row->get(2);
const TString& modulo = m.get(S_MODULE); const TString newver = row->get(3);
const TString& newver = m.get(S_NEW_VERSION); const TString oldver = row->get(5);
const TString& oldver = m.get(S_CUR_VERSION);
bool ok = TRUE;
const int cmp = compare_version(oldver, newver); const int cmp = compare_version(oldver, newver);
if (cmp < 0) if (cmp < 0)
ok = yesno_box("Si desidera installare la versione %s?", (const char*)newver); ok = yesno_box("Si desidera installare la versione %s?", (const char*)newver);
@ -395,24 +388,47 @@ bool TInstaller_mask::install_handler(TMask_field& fld, KEY key)
"Attenzione: non e' garantito il corretto\n" "Attenzione: non e' garantito il corretto\n"
"funzionamento di tutti i programmi!", (const char*)oldver); "funzionamento di tutti i programmi!", (const char*)oldver);
if (ok) if (ok)
{ install(modulo);
TInstaller_mask& im = (TInstaller_mask&)m.get_sheet()->mask(); else
im.install(modulo); break;
}
} }
return ok; }
bool TInstaller_mask::install_handler(TMask_field& fld, KEY key)
{
if (key == K_SPACE)
{
if (_curr_mask->one_checked())
_curr_mask->install_selection();
else
error_box("Selezionare uno piu' moduli da installare.");
}
return TRUE;
}
bool TInstaller_mask::on_key(KEY key)
{
bool ok = TRUE;
if (key == K_CTRL+'N')
autoload();
else
ok = TArray_sheet::on_key(key);
return ok;
} }
TInstaller_mask::TInstaller_mask() TInstaller_mask::TInstaller_mask()
: TMask("ba1700a") : TArray_sheet(0, 0, 0, 0, "Installazione",
{ "@1|Modulo@30|Cod.|Versione\nda installare@13|Data\nRilascio@10|Versione\nInstallata@10|Data\nInstallazione@13",
0x18, 3)
{
_curr_mask = this;
add_string(F_PATH, 0, "Percorso da cui installare ", 1, 1, 50);
add_string(F_CURPATH, 0, "Percorso in cui installare ", 1, 2, 50, "D");
add_button(F_INSTALL, "Installa", '\0'); // NON mettere 'I'
set_handler(F_PATH, path_handler); set_handler(F_PATH, path_handler);
set_handler(F_UPDATE, update_handler); set_handler(F_INSTALL, install_handler);
TSheet_field& sheet = sfield(F_SHEET);
sheet.set_notify(sheet_notify);
sheet.disable();
TMask& m = sheet.sheet_mask();
m.set_handler(S_INSTALL, install_handler);
TInstall_ini ini; TInstall_ini ini;
TFilename path = ini.get("DiskPath"); TFilename path = ini.get("DiskPath");
@ -420,7 +436,7 @@ TInstaller_mask::TInstaller_mask()
const char lettera = toupper(path[0]); const char lettera = toupper(path[0]);
const bool floppy = (path.len() > 1) && path[1] == ':' && const bool floppy = (path.len() > 1) && path[1] == ':' &&
(lettera == 'A' || lettera == 'B'); GetDriveType(lettera - 'A') == DRIVE_REMOVABLE;
if (path.not_empty() && !floppy) if (path.not_empty() && !floppy)
autoload(); autoload();
@ -430,6 +446,11 @@ TInstaller_mask::TInstaller_mask()
set(F_CURPATH, path); set(F_CURPATH, path);
} }
TInstaller_mask::~TInstaller_mask()
{
_curr_mask = NULL;
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Programma principale // Programma principale
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

View File

@ -1,11 +1,3 @@
#define F_PATH 201 #define F_PATH 201
#define F_CURPATH 202 #define F_CURPATH 202
#define F_UPDATE 203 #define F_INSTALL 203
#define F_SHEET 204
#define S_INSTALL 100
#define S_MODULE 102
#define S_NEW_VERSION 103
#define S_NEW_DATE 104
#define S_CUR_VERSION 105
#define S_CUR_DATE 106

View File

@ -2,12 +2,12 @@
TOOLBAR "" 0 20 0 2 TOOLBAR "" 0 20 0 2
BUTTON F_UPDATE 10 2 BUTTON F_UPDATE 15 2
BEGIN BEGIN
PROMPT -12 -11 "Aggiorna" PROMPT -12 -11 "Aggiorna lista"
END END
BUTTON DLG_QUIT 10 2 BUTTON DLG_QUIT 15 2
BEGIN BEGIN
PROMPT -22 -11 "" PROMPT -22 -11 ""
END END

View File

@ -104,7 +104,7 @@ bool TPersone_app::fax_handler(TMask_field& f, KEY k)
TFilename msg; msg.temp(NULL, "txt"); TFilename msg; msg.temp(NULL, "txt");
ofstream msgf(msg); ofstream msgf(msg);
msgf.close(); msgf.close();
ok = goto_url(msg); ok = edit_url(msg);
if (ok) if (ok)
{ {

View File

@ -175,7 +175,7 @@ bool TDitte_application::fax_handler(TMask_field& f, KEY k)
TFilename msg; msg.temp(NULL, "txt"); TFilename msg; msg.temp(NULL, "txt");
ofstream msgf(msg); ofstream msgf(msg);
msgf.close(); msgf.close();
ok = goto_url(msg); ok = edit_url(msg);
if (ok) if (ok)
{ {