ba0.cpp Gestita abilitazione delle voci di menu in base ai moduli attivati
ba1600?.* Continua l'epopea delle installazioni! git-svn-id: svn://10.65.10.50/trunk@5571 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									4df4b96b08
								
							
						
					
					
						commit
						e5350ebd43
					
				
							
								
								
									
										34
									
								
								ba/ba0.cpp
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								ba/ba0.cpp
									
									
									
									
									
								
							@ -444,6 +444,8 @@ class TMenu : public TAssoc_array
 | 
			
		||||
  
 | 
			
		||||
  TAssoc_array _images;
 | 
			
		||||
  
 | 
			
		||||
  TAssoc_array _modules;
 | 
			
		||||
 | 
			
		||||
public:                                  
 | 
			
		||||
  bool read(const char* name);                     // First call
 | 
			
		||||
  bool read(const char* name, TString& root);
 | 
			
		||||
@ -464,6 +466,8 @@ public:
 | 
			
		||||
  TImage& image(const char* name);
 | 
			
		||||
  void reload_images();
 | 
			
		||||
  
 | 
			
		||||
  bool has_module(const char* mod);
 | 
			
		||||
  
 | 
			
		||||
  TMenu() : _current(NULL), _item(0) { }
 | 
			
		||||
  TMenu(const char* name) { read(name); }
 | 
			
		||||
  virtual ~TMenu() { }
 | 
			
		||||
@ -507,6 +511,9 @@ void TMenuitem::create(const char* t)
 | 
			
		||||
    if (_action.empty())
 | 
			
		||||
      _enabled = FALSE;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  if (_enabled && is_program())
 | 
			
		||||
    _enabled = menu().has_module(_action);
 | 
			
		||||
} 
 | 
			
		||||
 | 
			
		||||
bool TMenuitem::enabled() const
 | 
			
		||||
@ -876,6 +883,32 @@ void TMenu::reload_images()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TMenu::has_module(const char* mod)
 | 
			
		||||
{
 | 
			
		||||
  TString16 key;
 | 
			
		||||
 | 
			
		||||
  if (_modules.items() == 0)
 | 
			
		||||
  {
 | 
			
		||||
    TScanner scanner("prassi.aut");
 | 
			
		||||
    TString16 val;
 | 
			
		||||
    for (int aut = 0; scanner.line() != ""; aut++)
 | 
			
		||||
    {              
 | 
			
		||||
      key.strncpy(scanner.token(), 2);
 | 
			
		||||
      key.lower();
 | 
			
		||||
      val.format("%d", aut);
 | 
			
		||||
      _modules.add(key, val);
 | 
			
		||||
    }  
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  key.strncpy(mod, 2);
 | 
			
		||||
  key.lower();
 | 
			
		||||
  
 | 
			
		||||
  int module = 0;
 | 
			
		||||
  TString* cod = (TString*)_modules.objptr(key);
 | 
			
		||||
  if (cod) module = atoi(*cod);
 | 
			
		||||
  return main_app().has_module(module);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// Menu application
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
@ -1408,6 +1441,7 @@ bool TMenu_application::choose_editors()
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string& row = sheet.row(-1);
 | 
			
		||||
    row = hobj->key();      
 | 
			
		||||
    row.lower();
 | 
			
		||||
    if (row.compare("txt", -1, TRUE) == 0)
 | 
			
		||||
      sheet.disable_cell(sheet.items()-1, 0);
 | 
			
		||||
    row.add((TString&)hobj->obj());
 | 
			
		||||
 | 
			
		||||
@ -11,9 +11,6 @@
 | 
			
		||||
#include "ba1600.h"
 | 
			
		||||
#include "ba1600a.h"
 | 
			
		||||
 | 
			
		||||
#define FOR_EACH_SHEET_ROW(__sheet, __r, __riga) TToken_string* __riga; for (int __r = 0; __r < __sheet.items() && (const char*)(__riga = &__sheet.row(__r)); __r++)
 | 
			
		||||
#define FOR_EACH_SHEET_ROW_BACK(__sheet, __r, __riga) TToken_string* __riga; for (int __r = __sheet.items()-1; __r >= 0  && (const char*)(__riga = &__sheet.row(__r)); __r--)
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
// Configurazione per installazione
 | 
			
		||||
///////////////////////////////////////////////////////////
 | 
			
		||||
@ -70,12 +67,10 @@ int TInstall_ini::build_complete_list(const TString& module, TString_array& a,
 | 
			
		||||
                                      const char* sommario, bool agg)
 | 
			
		||||
{
 | 
			
		||||
  build_list(module, a, sommario, agg);
 | 
			
		||||
  
 | 
			
		||||
  TAuto_token_string altri(get("Moduli", module));
 | 
			
		||||
  TString submodule;
 | 
			
		||||
  for (const char* mod = altri.get(0); mod; mod = altri.get())
 | 
			
		||||
  FOR_EACH_TOKEN(altri, mod)
 | 
			
		||||
  {
 | 
			
		||||
    submodule = mod;
 | 
			
		||||
    const TString submodule = mod;
 | 
			
		||||
    copy_paragraph(submodule, sommario);
 | 
			
		||||
  }
 | 
			
		||||
  return a.items();
 | 
			
		||||
@ -85,13 +80,8 @@ void TInstall_ini::copy_paragraph(const char* module, const char* summary)
 | 
			
		||||
{                             
 | 
			
		||||
  TConfig sum(summary, module);
 | 
			
		||||
  TAssoc_array& ass = (TAssoc_array&)list_variables(module);
 | 
			
		||||
  ass.restart();
 | 
			
		||||
  for (THash_object* ho = ass.get_hashobj(); ho; ho = ass.get_hashobj())
 | 
			
		||||
  {
 | 
			
		||||
    const char* key = ho->key();
 | 
			
		||||
    const TString& str = (TString&)ho->obj();
 | 
			
		||||
  FOR_EACH_ASSOC_STRING(ass, obj, key, str)
 | 
			
		||||
    sum.set(key, str);
 | 
			
		||||
  }
 | 
			
		||||
}   
 | 
			
		||||
 | 
			
		||||
void TInstall_ini::copy_module_paragraphs(const char* module, const char* summary)
 | 
			
		||||
@ -399,9 +389,9 @@ void TModule_mask::load(const char* module)
 | 
			
		||||
  const char* bad_ext[] = { "bsc", "mak", "obj", "pdb", "rc", 
 | 
			
		||||
                            "res", "sbr", "vcw", "wsp", NULL };
 | 
			
		||||
  
 | 
			
		||||
  for (int index = arr.items()-1; index >= 0; index--)
 | 
			
		||||
  FOR_EACH_ARRAY_ROW_BACK(arr, index, row)
 | 
			
		||||
  { 
 | 
			
		||||
    mask = arr.row(index);   
 | 
			
		||||
    mask = *row;   
 | 
			
		||||
    mask.lower();
 | 
			
		||||
    const TString16 ext = mask.ext();
 | 
			
		||||
 | 
			
		||||
@ -417,10 +407,9 @@ void TModule_mask::load(const char* module)
 | 
			
		||||
    
 | 
			
		||||
    if (ok)
 | 
			
		||||
    {
 | 
			
		||||
      TString_array& sarr = s.rows_array();
 | 
			
		||||
      for (int i = sarr.items()-1; i >= 0; i--)
 | 
			
		||||
      FOR_EACH_SHEET_ROW_BACK(s, i, row)
 | 
			
		||||
      {
 | 
			
		||||
        if (mask.compare(sarr.row(i).get(0), -1, TRUE) == 0)
 | 
			
		||||
        if (mask.compare(row->get(0), -1, TRUE) == 0)
 | 
			
		||||
          break;
 | 
			
		||||
      }   
 | 
			
		||||
      ok = i < 0;
 | 
			
		||||
@ -457,14 +446,14 @@ void TModule_mask::save()
 | 
			
		||||
 | 
			
		||||
  TToken_string tmp;    
 | 
			
		||||
  index = 0;
 | 
			
		||||
  for (int r = 0; r < sheet.items(); r++)
 | 
			
		||||
  
 | 
			
		||||
  FOR_EACH_SHEET_ROW_BACK(sheet, r, row)
 | 
			
		||||
  {
 | 
			
		||||
    TToken_string& row = sheet.row(r);
 | 
			
		||||
    TString16 sub = row.get(2);
 | 
			
		||||
    TString16 sub = row->get(2);
 | 
			
		||||
    if (isdigit(sub[0]) || sub.left(2) == module)
 | 
			
		||||
    {
 | 
			
		||||
      tmp = row.get(0);       // Nome del file
 | 
			
		||||
      const bool agg = *row.get() > ' ';
 | 
			
		||||
      tmp = row->get(0);       // Nome del file
 | 
			
		||||
      const bool agg = row->get_char() > ' ';
 | 
			
		||||
      if (agg) tmp.add("X");  // Flag aggiornamento
 | 
			
		||||
      ini.set("File", tmp, sub, TRUE, index++);
 | 
			
		||||
    }
 | 
			
		||||
@ -560,9 +549,9 @@ void TFascicolator_mask::load()
 | 
			
		||||
  set(F_DISKSIZE, ini.get("DiskSize"));
 | 
			
		||||
  set(F_DISKPATH, ini.get("DiskPath"));
 | 
			
		||||
  
 | 
			
		||||
  for (int m = modules.items()-1; m >= 0; m--)
 | 
			
		||||
  FOR_EACH_ARRAY_ROW_BACK(modules, m, riga)
 | 
			
		||||
  {
 | 
			
		||||
    const TString& module = modules.row(m);
 | 
			
		||||
    const TString& module = *riga;
 | 
			
		||||
    if (module.len() == 2)
 | 
			
		||||
    {
 | 
			
		||||
      TToken_string& row = s.row(-1);
 | 
			
		||||
@ -600,32 +589,31 @@ void TFascicolator_mask::save()
 | 
			
		||||
  ini.set("DiskPath", get(F_DISKPATH));
 | 
			
		||||
  
 | 
			
		||||
  TString tmp;
 | 
			
		||||
  for (int r = s.items()-1; r >= 0; r--)
 | 
			
		||||
  FOR_EACH_SHEET_ROW_BACK(s, r, row)
 | 
			
		||||
  {          
 | 
			
		||||
    pi.addstatus(1);
 | 
			
		||||
    TToken_string& row = s.row(r);
 | 
			
		||||
  
 | 
			
		||||
    tmp = row.get(1);
 | 
			
		||||
    tmp = row->get(1);
 | 
			
		||||
    if (tmp.not_empty() && tmp != "xx")
 | 
			
		||||
    {
 | 
			
		||||
      ini.set_paragraph(tmp);
 | 
			
		||||
      
 | 
			
		||||
      tmp = row.get(0);
 | 
			
		||||
      tmp = row->get(0);
 | 
			
		||||
      ini.set("Descrizione", tmp);
 | 
			
		||||
      
 | 
			
		||||
      tmp = row.get(2);
 | 
			
		||||
      tmp = row->get(2);
 | 
			
		||||
      ini.set("Versione", tmp);
 | 
			
		||||
 | 
			
		||||
      tmp = row.get();
 | 
			
		||||
      tmp = row->get();
 | 
			
		||||
      ini.set("Data", tmp);
 | 
			
		||||
      
 | 
			
		||||
      tmp = row.get();
 | 
			
		||||
      tmp = row->get();
 | 
			
		||||
      ini.set("Moduli", tmp);
 | 
			
		||||
 | 
			
		||||
      tmp = row.get();
 | 
			
		||||
      tmp = row->get();
 | 
			
		||||
      ini.set("PreProcess", tmp);
 | 
			
		||||
 | 
			
		||||
      tmp = row.get();
 | 
			
		||||
      tmp = row->get();
 | 
			
		||||
      ini.set("PostProcess", tmp);
 | 
			
		||||
    }  
 | 
			
		||||
  }  
 | 
			
		||||
@ -774,7 +762,8 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
 | 
			
		||||
 | 
			
		||||
  TProgind pi(arr.items(), msg, TRUE, TRUE); 
 | 
			
		||||
  TFilename cmd;
 | 
			
		||||
  for (int i = arr.items()-1; i >= 0; i--)
 | 
			
		||||
  
 | 
			
		||||
  FOR_EACH_ARRAY_ROW_BACK(arr, i, row)
 | 
			
		||||
  {                    
 | 
			
		||||
    pi.addstatus(1);
 | 
			
		||||
    if (pi.iscancelled())
 | 
			
		||||
@ -783,10 +772,8 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    TToken_string& row = arr.row(i);
 | 
			
		||||
      
 | 
			
		||||
    // Aggiungo il nome corrente alla lista dei files da compattare
 | 
			
		||||
    cmd << ' ' << row.get(0);
 | 
			
		||||
    cmd << ' ' << row->get(0);
 | 
			
		||||
    
 | 
			
		||||
    if (cmd.len() > 80)         // Se la riga ha raggiunto la dimensione giusta...
 | 
			
		||||
    {                              
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										27
									
								
								ba/ba1600.h
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								ba/ba1600.h
									
									
									
									
									
								
							@ -39,4 +39,31 @@ public:
 | 
			
		||||
  virtual ~TAuto_token_string() { }
 | 
			
		||||
};    
 | 
			
		||||
 | 
			
		||||
#define FOR_EACH_SHEET_ROW(__sheet, __r, __riga)                           \
 | 
			
		||||
  TToken_string* __riga;                                                   \
 | 
			
		||||
  for (int __r = 0;                                                        \
 | 
			
		||||
       __r < __sheet.items() && (const char*)(__riga = &__sheet.row(__r)); \
 | 
			
		||||
       __r++)
 | 
			
		||||
 | 
			
		||||
#define FOR_EACH_SHEET_ROW_BACK(__sheet, __r, __riga)                      \
 | 
			
		||||
  TToken_string* __riga;                                                   \
 | 
			
		||||
  for (int __r = __sheet.items()-1;                                        \
 | 
			
		||||
       __r >= 0  && (const char*)(__riga = &__sheet.row(__r));             \
 | 
			
		||||
       __r--)
 | 
			
		||||
 | 
			
		||||
#define FOR_EACH_ARRAY_ROW_BACK(__arr, __r, __riga)          \
 | 
			
		||||
  TToken_string* __riga;                                     \
 | 
			
		||||
  for (int __r = __arr.last();                               \
 | 
			
		||||
       __r >= 0  && (const char*)(__riga = &__arr.row(__r)); \
 | 
			
		||||
       __r = __arr.pred(__r))
 | 
			
		||||
 | 
			
		||||
#define FOR_EACH_ASSOC_STRING(__ass, __obj, __key, __str)                     \
 | 
			
		||||
  const char *__key, *__str; __ass.restart;                                   \
 | 
			
		||||
  for (THash_object* __obj = __ass.get_hashobj();                             \
 | 
			
		||||
       __obj && (__str = (const TString&)__obj->obj(), __key = __obj->key()); \
 | 
			
		||||
       __obj = __ass.get_hashobj()) 
 | 
			
		||||
 | 
			
		||||
#define FOR_EACH_TOKEN(__tok, __str) \
 | 
			
		||||
  for (const char* __str = __tok.get(0); __str; __str = __tok.get())
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -91,9 +91,9 @@ BEGIN
 | 
			
		||||
  PROMPT -13 -3 ""
 | 
			
		||||
END
 | 
			
		||||
 | 
			
		||||
BUTTON DLG_CANCEL 14 2
 | 
			
		||||
BUTTON S_LIST 14 2
 | 
			
		||||
BEGIN
 | 
			
		||||
  PROMPT -13 -1 ""
 | 
			
		||||
  PROMPT -13 -1 "Lista file"
 | 
			
		||||
END
 | 
			
		||||
 | 
			
		||||
BUTTON S_SAVE 14 2
 | 
			
		||||
@ -106,9 +106,14 @@ BEGIN
 | 
			
		||||
  PROMPT -23 -1 "&Aggiornamento"
 | 
			
		||||
END
 | 
			
		||||
 | 
			
		||||
BUTTON S_LIST 14 2
 | 
			
		||||
BUTTON S_IMPORT 14 2
 | 
			
		||||
BEGIN
 | 
			
		||||
  PROMPT -33 -1 "Lista file"
 | 
			
		||||
  PROMPT -33 -3 "&Versione"
 | 
			
		||||
END
 | 
			
		||||
 | 
			
		||||
BUTTON S_EXPORT 14 2
 | 
			
		||||
BEGIN
 | 
			
		||||
  PROMPT -33 -1 "&Aggiornamento"
 | 
			
		||||
END
 | 
			
		||||
 | 
			
		||||
ENDPAGE
 | 
			
		||||
 | 
			
		||||
@ -71,20 +71,19 @@ void TInstaller_mask::update_version()
 | 
			
		||||
  TInstall_ini ini;
 | 
			
		||||
  
 | 
			
		||||
  TSheet_field& sheet = sfield(F_SHEET);
 | 
			
		||||
  for (int m = sheet.items()-1; m >= 0; m--)
 | 
			
		||||
  FOR_EACH_SHEET_ROW_BACK(sheet, m, row)
 | 
			
		||||
  {                               
 | 
			
		||||
    TToken_string& row = sheet.row(m);
 | 
			
		||||
    const TString16 module = row.get(1);
 | 
			
		||||
    const TString16 module = row->get(1);
 | 
			
		||||
    ini.set_paragraph(module);
 | 
			
		||||
      
 | 
			
		||||
    const TString newver = row.get(2);
 | 
			
		||||
    const TString oldver = ini.get("Versione");
 | 
			
		||||
    row.add(oldver, 4);
 | 
			
		||||
    row.add(ini.get("Data"), 5);
 | 
			
		||||
    const TString16 newver = row->get(2);
 | 
			
		||||
    const TString16 oldver = ini.get("Versione");
 | 
			
		||||
    row->add(oldver, 4);
 | 
			
		||||
    row->add(ini.get("Data"), 5);
 | 
			
		||||
      
 | 
			
		||||
    const int cmp = compare_version(newver, oldver);
 | 
			
		||||
    if (cmp > 0)
 | 
			
		||||
      sheet.set_back_and_fore_color(FOCUS_BACK_COLOR, FOCUS_COLOR, m);
 | 
			
		||||
      sheet.set_back_and_fore_color(FOCUS_BACK_COLOR, NORMAL_COLOR, m);
 | 
			
		||||
    if (cmp == 0)  
 | 
			
		||||
      sheet.set_back_and_fore_color(NORMAL_BACK_COLOR, NORMAL_COLOR, m);
 | 
			
		||||
    if (cmp < 0)
 | 
			
		||||
@ -116,9 +115,10 @@ bool TInstaller_mask::autoload()
 | 
			
		||||
  {
 | 
			
		||||
    TInstall_ini ini(ininame);
 | 
			
		||||
    ini.list_paragraphs(modules);
 | 
			
		||||
    for (int i = modules.items()-1; i >= 0; i--)
 | 
			
		||||
 | 
			
		||||
    FOR_EACH_ARRAY_ROW_BACK(modules, i, row)
 | 
			
		||||
    {
 | 
			
		||||
      const TString& module = modules.row(i);
 | 
			
		||||
      const TString& module = *row;
 | 
			
		||||
      if (module.len() == 2 && module != "xx")
 | 
			
		||||
        add_module(ini, module);
 | 
			
		||||
    }
 | 
			
		||||
@ -127,10 +127,10 @@ bool TInstaller_mask::autoload()
 | 
			
		||||
  {
 | 
			
		||||
    ininame = path;  
 | 
			
		||||
    ininame.add("??inst.ini");
 | 
			
		||||
    const int files = list_files(ininame, modules);
 | 
			
		||||
    for (int m = files-1; m >= 0; m--)
 | 
			
		||||
    list_files(ininame, modules);
 | 
			
		||||
    FOR_EACH_ARRAY_ROW_BACK(modules, m, row)
 | 
			
		||||
    {               
 | 
			
		||||
      TString& ininame = modules.row(m);
 | 
			
		||||
      TString& ininame = *row;
 | 
			
		||||
      ininame.lower();
 | 
			
		||||
      const int pos = ininame.find("inst.ini");
 | 
			
		||||
      CHECKS(pos > 2, "Invalid installation configuration: ", (const char*)ininame);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user