ba0.cpp Aggiunto cambio studio e gestione CONVERTING

ba0.url    Aggiunat voce di menu per cmabio studio
ba1600.cpp Migliorato riconoscimento dei drive rimuovibili


git-svn-id: svn://10.65.10.50/trunk@5684 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1997-12-02 13:12:09 +00:00
parent 83487ad324
commit 74a8b1e097
3 changed files with 113 additions and 31 deletions

View File

@ -14,7 +14,9 @@
#include <stack.h> #include <stack.h>
#include <tabutil.h> #include <tabutil.h>
#include <utility.h> #include <utility.h>
#include <urldefid.h> #include <urldefid.h>
#include <extcdecl.h> // CGetPrawinName
#include <nditte.h> #include <nditte.h>
@ -198,13 +200,8 @@ void TColor_mask::update()
void TColor_mask::save_colors() void TColor_mask::save_colors()
{ {
TConfig colors(CONFIG_USER, "Colors"); TConfig colors(CONFIG_USER, "Colors");
_color.restart(); FOR_EACH_ASSOC_STRING(_color, obj, key, str)
for (THash_object* h = _color.get_hashobj(); h; h = _color.get_hashobj()) colors.set(key, str);
{
const TString& k = h->key();
const TString& s = (const TString&)h->obj();
colors.set(k, s);
}
} }
COLOR TColor_mask::get_color_entry(const char* name) const COLOR TColor_mask::get_color_entry(const char* name) const
@ -445,6 +442,9 @@ class TMenu : public TAssoc_array
TAssoc_array _images; TAssoc_array _images;
TAssoc_array _modules; TAssoc_array _modules;
public: // TObject
virtual bool ok() const { return _current != NULL; }
public: public:
bool read(const char* name); // First call bool read(const char* name); // First call
@ -672,7 +672,8 @@ void TSubmenu::read(TScanner& scanner)
{ {
bool disable = TRUE; bool disable = TRUE;
TToken_string mod(line.mid(equal+1, -1), ','); TToken_string mod(line.mid(equal+1, -1), ',');
for (const char* cod = mod.get(0); cod; cod = mod.get()) // for (const char* cod = mod.get(0); cod; cod = mod.get())
FOR_EACH_TOKEN(mod, cod)
{ {
const int code = atoi(cod); const int code = atoi(cod);
if (code == 0 || main_app().has_module(code)) if (code == 0 || main_app().has_module(code))
@ -942,6 +943,7 @@ protected:
bool choose_colors(); bool choose_colors();
bool choose_editors(); bool choose_editors();
bool choose_study();
public: public:
void reload_images() { _menu.reload_images(); } void reload_images() { _menu.reload_images(); }
@ -1121,11 +1123,12 @@ int TMenu_application::do_level()
const int x = width / 2; const int x = width / 2;
int y = 1; int y = 1;
TString caption;
for (int i = 0; i < curr.items(); i++, y++) for (int i = 0; i < curr.items(); i++, y++)
{ {
const TMenuitem& item = curr[i]; const TMenuitem& item = curr[i];
TString80 caption = item.caption(); caption = item.caption();
if (item.is_submenu() && caption.find("...") < 0) if (item.is_submenu() && caption.find("...") < 0)
caption << "..."; caption << "...";
@ -1261,7 +1264,7 @@ bool TMenu_application::check_user()
users.put("USERDESC", utente); users.put("USERDESC", utente);
users.put("PASSWORD", encode(pwd)); users.put("PASSWORD", encode(pwd));
users.write(); users.write();
err = users.read(_isequal, _lock); err = users.read(_isequal);
} }
ok = utente.not_empty() && pwd.not_empty() && pwd == m.get(F_PASSWORD); ok = utente.not_empty() && pwd.not_empty() && pwd == m.get(F_PASSWORD);
@ -1275,6 +1278,26 @@ bool TMenu_application::check_user()
"Si desidera continuare ugualmente?", (const char*)utente); "Si desidera continuare ugualmente?", (const char*)utente);
} }
if (ok)
{
users.put("USERNAME", "PRASSI");
users.read(_isequal);
if (users.get("AUTSTR") == "CONVERTING")
{
TString msg = "E' in corso una conversione archivi:\n";
if (utente == "PRASSI")
{
msg << "Si desidera continuare ugualmente?";
ok = yesno_box(msg);
}
else
{
msg << "Accesso negato.";
ok = error_box(msg);
}
}
}
if (ok) if (ok)
{ {
user() = utente; user() = utente;
@ -1293,6 +1316,8 @@ bool TMenu_application::check_user()
{ {
if (ok) if (ok)
{ {
users.put("USERNAME", utente);
users.read(_isequal, _lock);
users.put("CONNECTED", "X"); users.put("CONNECTED", "X");
users.rewrite(); users.rewrite();
@ -1301,14 +1326,12 @@ bool TMenu_application::check_user()
customize_colors(); // Aggiorna set di colori customize_colors(); // Aggiorna set di colori
xvt_dwin_invalidate_rect(TASK_WIN, NULL); // Ridisegna sfondo xvt_dwin_invalidate_rect(TASK_WIN, NULL); // Ridisegna sfondo
} }
else
users.read(_isequal, _unlock);
} }
} }
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
if (ok && utente != "PRASSI") if (ok && utente != "PRASSI")
WritePrivateProfileString("User", "Name", utente, "prassi.ini"); WritePrivateProfileString("Main", "User", utente, CGetPrawinName());
#endif #endif
return ok; return ok;
@ -1326,10 +1349,13 @@ bool TMenu_application::create()
TWait_cursor hourglass; TWait_cursor hourglass;
TFilename menu = (argc() < 2) ? "baprassi" : argv(1); if (!_menu.ok())
menu.ext("men"); {
_menu.read(menu); TFilename menu = (argc() < 2) ? "baprassi" : argv(1);
menu.ext("men");
_menu.read(menu);
}
dispatch_e_menu(MENU_ITEM(1)); dispatch_e_menu(MENU_ITEM(1));
return TRUE; return TRUE;
} }
@ -1485,6 +1511,41 @@ bool TMenu_application::choose_editors()
return TRUE; return TRUE;
} }
HIDDEN bool study_handler(TMask_field& f, KEY k)
{
bool ok = TRUE;
if (f.to_check(k))
{
TFilename path(f.get());
path.add("com");
path.add("dir.gen");
if (!fexist(path))
ok = f.error_box("La directory %s non e' uno studio valido!",
(const char*)f.get());
}
return ok;
}
bool TMenu_application::choose_study()
{
TMask m("Scelta studio", 1, 60, 6);
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
m.add_string(DLG_USER, 0, "Studio ", 1, 1, 50);
m.set_handler(DLG_USER, study_handler);
m.set(DLG_USER, prefix().get_studio());
bool ok = m.run() == K_ENTER;
if (ok)
{
_mask->close_modal();
do_events();
destroy();
prefix().set_studio(m.get(DLG_USER));
create();
}
return ok;
}
long TMenu_application::handler(WINDOW win, EVENT* ep) long TMenu_application::handler(WINDOW win, EVENT* ep)
{ {
long ret = TApplication::handler(win, ep); long ret = TApplication::handler(win, ep);
@ -1504,6 +1565,7 @@ bool TMenu_application::menu(MENU_TAG mt)
case MENU_ITEM(1): ok = main_loop(); break; case MENU_ITEM(1): ok = main_loop(); break;
case MENU_ITEM(2): choose_colors(); break; case MENU_ITEM(2): choose_colors(); break;
case MENU_ITEM(3): choose_editors(); break; case MENU_ITEM(3): choose_editors(); break;
case MENU_ITEM(4): choose_study(); break;
default: break; default: break;
} }
return ok; return ok;
@ -1596,7 +1658,7 @@ int main(int argc, char** argv)
if (user().blank()) if (user().blank())
{ {
char u[16]; char u[16];
GetPrivateProfileString("User", "Name", "PRASSI", u, sizeof(u), "prassi.ini"); GetPrivateProfileString("Main", "User", "PRASSI", u, sizeof(u), CGetPrawinName());
user() = u; user() = u;
} }

View File

@ -8,3 +8,4 @@ MENU M_FONT
ITEM M_FONT_SELECT "~Font" ITEM M_FONT_SELECT "~Font"
ITEM MENU_ITEM(2) "~Colori" ITEM MENU_ITEM(2) "~Colori"
ITEM MENU_ITEM(3) "~Editors" ITEM MENU_ITEM(3) "~Editors"
ITEM MENU_ITEM(4) "~Studio"

View File

@ -1,5 +1,6 @@
#include <dos.h> #include <dos.h>
#define XVT_INCL_NATIVE
#include <applicat.h> #include <applicat.h>
#include <execp.h> #include <execp.h>
#include <msksheet.h> #include <msksheet.h>
@ -164,7 +165,7 @@ TAuto_token_string& TAuto_token_string::create(const char* ts)
// Calcola il separatore // Calcola il separatore
for (const char* s = get_buffer(); *s; s++) for (const char* s = get_buffer(); *s; s++)
{ {
if (strchr("|;,!^&+", *s) != NULL) if (strchr("|;,!^&+\t\n", *s) != NULL)
{ {
separator(*s); separator(*s);
break; break;
@ -536,7 +537,8 @@ TModule_mask::TModule_mask()
class TFascicolator_mask : public TMask class TFascicolator_mask : public TMask
{ {
protected: protected:
static bool sheet_notify(TSheet_field& f, int row, KEY k);
static bool list_handler(TMask_field& f, KEY k); static bool list_handler(TMask_field& f, KEY k);
static bool save_handler(TMask_field& f, KEY k); static bool save_handler(TMask_field& f, KEY k);
static bool import_export_handler(TMask_field& f, KEY k); static bool import_export_handler(TMask_field& f, KEY k);
@ -555,7 +557,15 @@ public:
TFascicolator_mask(); TFascicolator_mask();
virtual ~TFascicolator_mask() { } virtual ~TFascicolator_mask() { }
}; };
bool TFascicolator_mask::sheet_notify(TSheet_field& f, int row, KEY k)
{
bool ok = TRUE;
if (k == K_INS || k == K_DEL)
ok = FALSE;
return ok;
}
bool TFascicolator_mask::list_handler(TMask_field& f, KEY k) bool TFascicolator_mask::list_handler(TMask_field& f, KEY k)
{ {
if (k == K_SPACE) if (k == K_SPACE)
@ -652,15 +662,22 @@ const TFilename& TFascicolator_mask::build_export_path(TFilename& path) const
{ {
CHECK(path.not_empty(), "Please, specify the module"); CHECK(path.not_empty(), "Please, specify the module");
const TString module(path); const TString module(path);
path.cut(0); path.cut(0);
path << SLASH << 'u' << SLASH << user() << SLASH << "src" << SLASH << module; path << SLASH << "src" << SLASH << module;
if (!fexist(path)) if (!fexist(path))
{ {
path.cut(0); path.cut(0);
path << SLASH << 'u' << SLASH << user() << SLASH << "p.due" << SLASH << module; path << SLASH << 'u' << SLASH << user() << SLASH << "src" << SLASH << module;
} if (!fexist(path))
if (!fexist(path)) {
path.tempdir(); path.cut(0);
path << SLASH << 'u' << SLASH << user() << SLASH << "p.due" << SLASH << module;
if (!fexist(path))
path.tempdir();
}
}
path.lower();
return path; return path;
} }
@ -783,7 +800,7 @@ bool TFascicolator_mask::move_file(const TFilename& file, const char* dir) const
{ {
TString msg(128); TString msg(128);
msg << "Lo spazio sull'unita' e' insufficiente"; msg << "Lo spazio sull'unita' e' insufficiente";
if (disk == 1 || disk == 2) if (GetDriveType(disk-1) == DRIVE_REMOVABLE)
{ {
msg << ":\nInserire un nuovo disco e ritentare?"; msg << ":\nInserire un nuovo disco e ritentare?";
if (!yesno_box(msg)) if (!yesno_box(msg))
@ -930,7 +947,7 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
return TRUE; return TRUE;
const char drive = toupper(path[0]); const char drive = toupper(path[0]);
const bool floppy = (drive == 'A' || drive == 'B') && path[1] == ':'; const bool floppy = (GetDriveType(drive - 'A') == DRIVE_REMOVABLE) && (path[1] == ':');
for (int d = 1; d <= disks && !aborted; d++) for (int d = 1; d <= disks && !aborted; d++)
{ {
@ -964,6 +981,8 @@ TFascicolator_mask::TFascicolator_mask()
: TMask("ba1600a") : TMask("ba1600a")
{ {
TSheet_field& s = sfield(F_SHEET); TSheet_field& s = sfield(F_SHEET);
s.set_notify(sheet_notify);
TMask& m = s.sheet_mask(); TMask& m = s.sheet_mask();
m.set_handler(S_LIST, list_handler); m.set_handler(S_LIST, list_handler);
m.set_handler(S_SAVE, save_handler); m.set_handler(S_SAVE, save_handler);