2005-05-05 15:17:38 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <automask.h>
|
|
|
|
|
#include <sheet.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
|
|
#include <doc.h>
|
|
|
|
|
|
|
|
|
|
#include "ci0.h"
|
|
|
|
|
#include "cilib.h"
|
|
|
|
|
#include "ci0300.h"
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TConfigurazioneIndustriale_mask
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void TConfigurazioneIndustriale_mask::add_element(TToken_string& t, long selrow)
|
|
|
|
|
{
|
|
|
|
|
if (selrow<-1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (selrow>items()-1)
|
|
|
|
|
selrow = -1;
|
|
|
|
|
|
|
|
|
|
rows_array().add(t,selrow);
|
|
|
|
|
force_update();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConfigurazioneIndustriale_mask::add_element(long selrow)
|
|
|
|
|
{
|
|
|
|
|
if (selrow<-1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (selrow>items()-1)
|
|
|
|
|
selrow = -1;
|
|
|
|
|
|
|
|
|
|
sheet().insert(selrow, true, true);
|
|
|
|
|
force_update();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConfigurazioneIndustriale_mask::delete_element(long selrow)
|
|
|
|
|
{
|
|
|
|
|
TToken_string t(40);
|
|
|
|
|
|
|
|
|
|
if (items()<1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (selrow<0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (selrow>items()-1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
rows_array().destroy(selrow);
|
|
|
|
|
force_update();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConfigurazioneIndustriale_mask::moveup_element(long selrow)
|
|
|
|
|
{
|
|
|
|
|
if (items()<=1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (selrow<=0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (selrow>items()-1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
rows_array().swap(selrow,selrow-1);
|
|
|
|
|
sheet().force_update();
|
|
|
|
|
sheet().select(selrow-1);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConfigurazioneIndustriale_mask::movedown_element(long selrow)
|
|
|
|
|
{
|
|
|
|
|
if (items()<=1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (selrow<0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (selrow>=items()-1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
rows_array().swap(selrow,selrow+1);
|
|
|
|
|
sheet().force_update();
|
|
|
|
|
sheet().select(selrow+1);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TConfigurazioneIndustriale_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (o.dlg())
|
|
|
|
|
{
|
|
|
|
|
case F_MOVEUP:
|
|
|
|
|
moveup_element(sheet().selected());
|
|
|
|
|
break;
|
|
|
|
|
case F_MOVEDN:
|
|
|
|
|
movedown_element(sheet().selected());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TConfigurazioneIndustriale_app
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// Overrides
|
|
|
|
|
|
|
|
|
|
bool TConfigurazioneIndustriale_app::create()
|
|
|
|
|
{
|
|
|
|
|
_mask = new TConfigurazioneIndustriale_mask();
|
|
|
|
|
|
|
|
|
|
file_to_sheet();
|
|
|
|
|
|
|
|
|
|
return TSkeleton_application::create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TConfigurazioneIndustriale_app::destroy()
|
|
|
|
|
{
|
|
|
|
|
delete _mask;
|
|
|
|
|
|
|
|
|
|
return TSkeleton_application::destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConfigurazioneIndustriale_app::main_loop()
|
|
|
|
|
{
|
|
|
|
|
KEY exitval;
|
|
|
|
|
|
|
|
|
|
while ((exitval=_mask->run()) != K_QUIT)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
switch(exitval)
|
|
|
|
|
{
|
|
|
|
|
case K_ESC:
|
|
|
|
|
return;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sheet_to_file();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Conversione Array <-> File
|
|
|
|
|
|
|
|
|
|
void TConfigurazioneIndustriale_app::file_to_sheet()
|
|
|
|
|
{
|
|
|
|
|
TConfig configfile(CONFIG_DITTA, "ci");
|
|
|
|
|
int item = 0;
|
|
|
|
|
|
|
|
|
|
while (configfile.exist("Descr",item))
|
|
|
|
|
{
|
|
|
|
|
TToken_string t;
|
|
|
|
|
t.add(configfile.get("Filter", NULL,item, "F01"));
|
|
|
|
|
t.add(configfile.get("Descr", NULL,item, "Fatture"));
|
|
|
|
|
mask().add_element(t);
|
|
|
|
|
item++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TConfigurazioneIndustriale_app::sheet_to_file()
|
|
|
|
|
{
|
|
|
|
|
TConfig configfile(CONFIG_DITTA, "ci");
|
2005-05-05 16:39:19 +00:00
|
|
|
|
int totlen = 0;
|
2005-05-05 15:17:38 +00:00
|
|
|
|
int items;
|
|
|
|
|
|
|
|
|
|
items = mask().items();
|
|
|
|
|
configfile.remove_all();
|
|
|
|
|
|
2005-05-05 16:39:19 +00:00
|
|
|
|
if (items>_maxelem)
|
|
|
|
|
{
|
|
|
|
|
message_box("Il massimo numero di filtri gestibili <20> pari a %d, pertanto verranno considerate solamente le prime %d righe", _maxelem, _maxelem);
|
|
|
|
|
items=16;
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-05 15:17:38 +00:00
|
|
|
|
for (int i=0;i<items;i++)
|
|
|
|
|
{
|
2005-05-05 16:39:19 +00:00
|
|
|
|
TString currdesc(mask().row(i).get(1));
|
2005-05-05 15:17:38 +00:00
|
|
|
|
configfile.set("Filter", mask().row(i).get(0), NULL, true, i);
|
2005-05-05 16:39:19 +00:00
|
|
|
|
configfile.set("Descr", currdesc, NULL, true, i);
|
|
|
|
|
totlen+=currdesc.len();
|
2005-05-05 15:17:38 +00:00
|
|
|
|
}
|
2005-05-05 16:39:19 +00:00
|
|
|
|
|
|
|
|
|
if (totlen>_maxlen)
|
|
|
|
|
message_box("E' probabile che la lunghezza delle descrizioni inserite ne impedisca la totale visualizzazione sullo schermo");
|
2005-05-05 15:17:38 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Main
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
int ci0300(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TConfigurazioneIndustriale_app a ;
|
|
|
|
|
a.run(argc, argv, TR("Contabilit<EFBFBD> Industriale"));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|