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
#include <applicat.h>
#include <execp.h>
#include <golem.h>
#include <msksheet.h>
#include <prefix.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)
{
TString mod;
for (int sub = -1; ; sub++)
for (int sub = -1; sub <= 9; sub++)
{
mod = module;
if (sub >= 0) mod << sub;
if (set_paragraph(mod))
export_paragraph(mod, summary);
else
break;
}
}
@ -185,6 +184,7 @@ protected:
static bool sheet_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 edit_handler(TMask_field& f, KEY k);
static bool link_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;
}
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)
{
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);
TToken_string& newrow = sheet.row(-1);
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 << '1'; // Sottomodulo standard
if (modmask.is_running())
@ -509,7 +526,7 @@ void TModule_mask::save()
TToken_string tmp;
index = 0;
FOR_EACH_SHEET_ROW_BACK(sheet, r, row)
FOR_EACH_SHEET_ROW(sheet, r, row)
{
TString16 sub = row->get(2);
if (sub.blank())
@ -541,6 +558,7 @@ TModule_mask::TModule_mask()
TSheet_field& s = sfield(F_SHEET);
s.set_notify(sheet_notify);
s.sheet_mask().set_handler(S_FILE, file_handler);
s.sheet_mask().set_handler(DLG_EDIT, edit_handler);
TSheet_field& miss = sfield(F_MISSING);
miss.set_notify(missing_notify);
@ -712,33 +730,40 @@ void TFascicolator_mask::load()
set(F_DISKSIZE, ini.get("DiskSize"));
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;
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);
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");
row.add(tmp);
if (module[0] == '_')
{
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");
row.add(tmp);
tmp = ini.get("Moduli");
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()

View File

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

View File

@ -1,10 +1,11 @@
#include <dos.h>
#define XVT_INCL_NATIVE
#include <applicat.h>
#include <colors.h>
#include <execp.h>
#include <msksheet.h>
#include <progind.h>
#include <sheet.h>
#include <utility.h>
#include "ba1.h"
@ -27,16 +28,21 @@ HIDDEN int compare_version(const TString& v1, const TString& v2)
// 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:
static bool update_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 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 install_selection();
bool do_process(TAuto_token_string& commands) const;
bool pre_process(TInstall_ini& ini, const char* module) const;
@ -47,21 +53,24 @@ public:
bool install(const TString& module);
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
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);
if (ok)
{
TSheet_field& sheet = sfield(F_SHEET);
TToken_string& row = sheet.row(-1);
row = ini.get("Descrizione");
TToken_string row;
row = " "; // Not selected
row.add(ini.get("Descrizione"));
row.add(module);
row.add(ini.get("Versione"));
row.add(ini.get("Data"));
add(row);
}
return ok;
}
@ -70,17 +79,18 @@ void TInstaller_mask::update_version()
{
TInstall_ini ini;
TSheet_field& sheet = sfield(F_SHEET);
FOR_EACH_SHEET_ROW_BACK(sheet, m, row)
TString_array& array = rows_array();
FOR_EACH_ARRAY_ROW_BACK(array, m, row)
{
const TString16 module = row->get(1);
const TString16 module = row->get(2);
ini.set_paragraph(module);
const TString16 newver = row->get(2);
const TString16 newver = row->get(3);
const TString16 oldver = ini.get("Versione");
row->add(oldver, 4);
row->add(ini.get("Data"), 5);
row->add(oldver, 5);
row->add(ini.get("Data"), 6);
/*
const int cmp = compare_version(newver, oldver);
if (cmp > 0)
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);
if (cmp < 0)
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
@ -101,9 +112,7 @@ bool TInstaller_mask::autoload()
return error_box("Specificare un percorso valido");
TWait_cursor hourglass;
TSheet_field& sheet = sfield(F_SHEET);
sheet.destroy();
destroy();
TFilename ininame;
ininame = path;
@ -140,13 +149,13 @@ bool TInstaller_mask::autoload()
}
}
sheet.rows_array().sort();
const bool ok = sheet.items() > 0;
rows_array().sort();
const bool ok = items() > 0;
if (ok)
update_version();
else
sheet.error_box("Non e' stato trovato nessun modulo da installare\n"
"in %s", (const char*)path);
error_box("Non e' stato trovato nessun modulo da installare\n"
"in %s", (const char*)path);
return ok;
}
@ -174,7 +183,8 @@ bool TInstaller_mask::pre_process(TInstall_ini& ini, const char* module) const
TInstall_ini cur_ini;
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;
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;
}
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 ok = TRUE;
@ -360,31 +360,24 @@ bool TInstaller_mask::path_handler(TMask_field& fld, KEY key)
fld.set(path);
}
if (fexist(path))
update_handler(fld, K_SPACE);
_curr_mask->autoload();
else
ok = fld.error_box("Specificare un percorso valido");
}
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)
{
bool ok = TRUE;
if (key == K_SPACE)
{
TMask& m = fld.mask();
const TString& modulo = m.get(S_MODULE);
const TString& newver = m.get(S_NEW_VERSION);
const TString& oldver = m.get(S_CUR_VERSION);
void TInstaller_mask::install_selection()
{
TString_array& arr = rows_array();
FOR_EACH_ARRAY_ROW(arr, r, row) if (checked(r))
{
const TString modulo = row->get(2);
const TString newver = row->get(3);
const TString oldver = row->get(5);
bool ok = TRUE;
const int cmp = compare_version(oldver, newver);
if (cmp < 0)
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"
"funzionamento di tutti i programmi!", (const char*)oldver);
if (ok)
{
TInstaller_mask& im = (TInstaller_mask&)m.get_sheet()->mask();
im.install(modulo);
}
install(modulo);
else
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()
: 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_UPDATE, update_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);
set_handler(F_INSTALL, install_handler);
TInstall_ini ini;
TFilename path = ini.get("DiskPath");
@ -420,7 +436,7 @@ TInstaller_mask::TInstaller_mask()
const char lettera = toupper(path[0]);
const bool floppy = (path.len() > 1) && path[1] == ':' &&
(lettera == 'A' || lettera == 'B');
GetDriveType(lettera - 'A') == DRIVE_REMOVABLE;
if (path.not_empty() && !floppy)
autoload();
@ -430,6 +446,11 @@ TInstaller_mask::TInstaller_mask()
set(F_CURPATH, path);
}
TInstaller_mask::~TInstaller_mask()
{
_curr_mask = NULL;
}
///////////////////////////////////////////////////////////
// Programma principale
///////////////////////////////////////////////////////////

View File

@ -1,11 +1,3 @@
#define F_PATH 201
#define F_CURPATH 202
#define F_UPDATE 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
#define F_INSTALL 203

View File

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

View File

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

View File

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