Patch level : 2.1 48

Files correlati     : ba8
Ricompilazione Demo : [ ]
Commento            :

Aggiornamenti vari sui report


git-svn-id: svn://10.65.10.50/trunk@12110 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2004-05-24 12:50:35 +00:00
parent 291e41385b
commit 7e9576ecef
12 changed files with 628 additions and 87 deletions

View File

@ -437,6 +437,9 @@ bool TColor_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
const COLOR color = cid2color(bid);
set_color_entry(name, color);
}
TConfig font(CONFIG_GUI, "Font");
font.set("FontDesc", ""); // Azzera font e lo ricarica alla prossima
xvt_load_default_font();
update();
}
break;
@ -446,7 +449,7 @@ bool TColor_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
XVT_FNTID fontid = xvt_default_font();
if (xvt_dm_post_font_sel(TASK_WIN, fontid, NULL, 0))
{
char font_ser_desc[512];
char font_ser_desc[256];
TConfig font(CONFIG_GUI, "Font");
xvt_font_serialize(fontid, font_ser_desc, sizeof(font_ser_desc));
font.set("FontDesc", font_ser_desc);

View File

@ -9,6 +9,7 @@ int main(int argc, char** argv)
case 1: ba8200(argc, argv); break; // Query Generator
case 2: ba8300(argc, argv); break; // Report Generator
case 3: ba8400(argc, argv); break; // Form Converter
case 4: ba8500(argc, argv); break; // Report Printer
default: ba8100(argc, argv); break; // Record Selector
}
return 0;

View File

@ -2,5 +2,6 @@ int ba8100(int argc, char* argv[]);
int ba8200(int argc, char* argv[]);
int ba8300(int argc, char* argv[]);
int ba8400(int argc, char* argv[]);
int ba8500(int argc, char* argv[]);

View File

@ -127,7 +127,6 @@ protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
protected:
int name2num(const TString& name) const;
int father_logicnum() const;
const char* find_linked_field(int logicnum, const RecFieldDes& fd) const;
@ -139,34 +138,14 @@ public:
~TTable_mask();
};
// Converte un nome di tabella nel suo numero logico
int TTable_mask::name2num(const TString& name) const
{
int num = 0;
if (name.not_empty())
{
TList_sheet& sht = *efield(F_SON).sheet();
TString_array& arr = sht.rows_array();
FOR_EACH_ARRAY_ROW(arr, i, row)
{
if (name == row->get(0))
{
num = row->get_int(1);
break;
}
}
}
return num;
}
int TTable_mask::father_logicnum() const
{
return name2num(get(F_FATHER));
return table2logic(get(F_FATHER));
}
int TTable_mask::son_logicnum() const
{
return name2num(get(F_SON));
return table2logic(get(F_SON));
}
// Dato il numero logico di una tabella ed un campo (di un'altra tabella)
@ -830,14 +809,22 @@ void TQuery_mask::save_as(TRecordsetExportFormat fmt)
xvt_fsys_convert_dir_to_str(&fs.dir, path.get_buffer(), path.size());
path.add(fs.name);
TSQL_recordset qry(get(F_SQL));
bool ok = qry.items() > 0;
const TString& sql = get(F_SQL);
TRecordset* rex = NULL;
if (sql.starts_with("SELECT "))
rex = new TSQL_recordset(sql);
else
rex = new TISAM_recordset(sql);
bool ok = rex->items() > 0;
if (ok)
{
ok = qry.save_as(path, fmt);
ok = rex->save_as(path, fmt);
if (ok)
xvt_sys_goto_url(path, "open");
}
delete rex;
}
}
@ -963,7 +950,7 @@ bool TQuery_mask::save_query()
bool TQuery_mask::save_if_needed()
{
if (!_is_dirty)
if (!_is_dirty || !field(DLG_SAVEREC).active())
return true;
if (!yesno_box(TR("Si desidera registrare la query?")))
return false;
@ -1125,7 +1112,7 @@ bool TQuery_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
if (select_query())
e = fe_modify;
}
if (e == fe_modify)
if (e == fe_init || e == fe_modify)
{
save_if_needed();
load_query();
@ -1341,12 +1328,20 @@ public:
bool TSQL_recordset_app::create()
{
_msk = new TQuery_mask;
xvt_sys_sleep(500);
xvt_sys_sleep(500); // Lasciamo il tempo di leggere il titolo
return TSkeleton_application::create();
}
void TSQL_recordset_app::main_loop()
{
if (argc() > 2)
{
_msk->set(F_CODICE, argv(2)); // Carico la query da riga di comando
_msk->disable(DLG_SAVEREC); // Non permetto modifiche di alcun genere
_msk->disable(DLG_NEWREC);
_msk->disable(DLG_DELREC);
_msk->disable(DLG_FINDREC);
}
_msk->run();
}

View File

@ -172,7 +172,6 @@ TReport_base_mask::TReport_base_mask(const char* name, TReport& rep)
class TReport_field_mask : public TReport_base_mask
{
protected:
void vedo_non_vedo();
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
@ -236,6 +235,8 @@ void TReport_field_mask::vedo_non_vedo()
show(F_VALIGN, is_text);
show(F_TEXT, is_text && !is_currency);
show(F_HIDE_DOTS, is_currency);
show(F_DYNAMIC_HEIGHT, type == 'S');
show(F_FGCOLOR, type != 'I');
show(F_BGCOLOR, type != 'L');
show(F_FONT_SELECT, is_text);
@ -350,6 +351,8 @@ void TReport_field_mask::set_field(const TReport_field& rf)
set(F_HIDDEN, rf.hidden() ? "X" : "");
set(F_DISABLED, rf.deactivated() ? "X" : "");
set(F_HIDE_ZEROES, rf.zeroes_hidden() ? "X" : "");
set(F_HIDE_DOTS, rf.picture().find('.') < 0);
set(F_DYNAMIC_HEIGHT, rf.dynamic_height() ? "X" : "");
set(F_GROUPS, rf.groups());
set(F_CODVAL, rf.codval());
set(F_LINK, rf.link());
@ -385,6 +388,7 @@ void TReport_field_mask::get_field(TReport_field& rf) const
rf.show(!get_bool(F_HIDDEN));
rf.activate(!get_bool(F_DISABLED));
rf.hide_zeroes(get_bool(F_HIDE_ZEROES));
rf.set_dynamic_height(get_bool(F_DYNAMIC_HEIGHT));
rf.set_groups(get(F_GROUPS));
rf.set_codval(get(F_CODVAL));
rf.set_link(get(F_LINK));
@ -393,7 +397,10 @@ void TReport_field_mask::get_field(TReport_field& rf) const
rf.set_border(get_int(F_BORDER));
rf.set_fore_color(_fgcolor);
rf.set_back_color(_bgcolor);
rf.set_picture(get(F_TEXT));
if (strchr("VP", rf.type()) != NULL)
rf.set_picture(get_bool(F_HIDE_DOTS) ? "#########,@@" : "###.###.###,@@");
else
rf.set_picture(get(F_TEXT));
rf.set_field(get(F_SOURCE));
rf.set_alternate_field(get(F_SOURCE2));
TReport_font f;
@ -882,6 +889,7 @@ void TReport_mask::add_field()
{
TReport_section& rs = curr_section();
TReport_field* rf = new TReport_field(&rs);
rf->set_type('S');
rf->set_pos(0, rs.compute_size().y);
TReport_field_mask m(*rf);
m.disable(DLG_DELREC);

View File

@ -35,6 +35,8 @@
#define F_INCLUDE 143
#define F_PARAMS 144
#define F_SOURCE2 145
#define F_HIDE_DOTS 146
#define F_DYNAMIC_HEIGHT 147
#define F_LEVEL 160
#define F_GROUP_BY 161

View File

@ -63,12 +63,23 @@ BEGIN
PROMPT 53 1 "Nascosto se zero"
END
BOOLEAN F_HIDE_DOTS
BEGIN
PROMPT 53 2 "Nascondi . migliaia"
END
BOOLEAN F_DYNAMIC_HEIGHT
BEGIN
PROMPT 53 2 "Altezza automatica"
END
STRING F_GROUPS 50
BEGIN
PROMPT 1 3 "Gruppi "
END
STRING F_CODVAL 32 8
STRING F_CODVAL 32 16
BEGIN
PROMPT 1 4 "Divisa "
FLAGS "U"
@ -201,8 +212,9 @@ SPREADSHEET F_LIST -1 -3
BEGIN
PROMPT 1 1 ""
ITEM "Codice"
ITEM "Decodifica@50"
FLAGS "H"
ITEM "Decodifica@20"
ITEM "Script@50"
FLAGS "H|"
END
BUTTON DLG_CANCEL 10 2
@ -219,7 +231,7 @@ ENDPAGE
ENDMASK
PAGE "List" -1 -1 72 11
PAGE "List" -1 -1 66 7
STRING 101 3
BEGIN
@ -228,7 +240,12 @@ END
STRING 102 50
BEGIN
PROMPT 13 0 "Decodifica "
PROMPT 14 0 ""
END
MEMO 103 64 4
BEGIN
PROMPT 1 1 "Script"
END
BUTTON DLG_CANCEL 10 2

View File

@ -321,6 +321,8 @@ protected:
void draw_grid();
void snap_drag(PNT& pnt) const;
void draw_dragster();
void draw_field(const TReport_field& rf);
void draw_broken_paper(const TReport_field& rf);
void popup_menu(EVENT* ep);
void popup_cut();
@ -392,7 +394,7 @@ bool TReport_window::get_selection_rect(TRectangle& rct) const
const TReport_field& f = *(const TReport_field*)o;
if (f.selected())
{
const TRectangle fr = f.get_draw_rect();
const TRectangle& fr = f.get_rect();
if (!full)
{
rct = fr;
@ -431,10 +433,9 @@ void TReport_window::select(const TRectangle& rct)
void TReport_window::draw_dragster()
{
set_mode(M_XOR);
set_pen(COLOR_CYAN);
set_brush(COLOR_WHITE, PAT_NONE);
xvt_dwin_draw_rect(win(), &_rct_drag);
set_mode(M_NOT_XOR);
set_pen(COLOR_BLACK);
xvt_dwin_draw_dotted_rect(win(), &_rct_drag);
set_mode(M_COPY);
}
@ -731,20 +732,177 @@ void TReport_window::draw_grid()
{
clear(COLOR_WHITE);
const int max = 192;
const int max = 196;
const int k = 100;
for (int i = 1; i < max; i++)
{
set_pen(i%10 ? MAKE_COLOR(232,232,232) : COLOR_LTGRAY);
set_pen(i%10 ? MAKE_COLOR(232,232,255) : MAKE_COLOR(255,192,255));
line(0, i*k, max*k, i*k);
line(i*k, 0, i*k, max*k);
}
}
void TReport_window::draw_broken_paper(const TReport_field& rf)
{
set_pen(COLOR_LTGRAY);
const TRectangle& dr = rf.get_rect();
const int b = dr.bottom()-100;
line(short(dr.x), short(b), short(dr.x), short(dr.y));
line(short(dr.x), short(dr.y), short(dr.right()), short(dr.y));
line(short(dr.right()), short(dr.y), short(dr.right()), short(b));
for (int x = dr.left(); x < dr.right(); )
{
const int deltay = rand()%100;
int deltax = 200;
int ex = x + deltax;
if (ex > dr.right())
{
ex = dr.right();
deltax = ex-x;
}
line(short(x), short(b), short(x+deltax/2), short(b+deltay));
line(short(x+deltax/2), short(b+deltay), short(x+deltax), short(b));
x = ex;
}
}
void TReport_window::draw_field(const TReport_field& rf)
{
RCT r; TWindow::log2dev(rf.get_rect(), r);
PAT_STYLE back_pattern = PAT_HOLLOW;
const int k = (rf.hidden() ? 1 : 0) + (rf.deactivated() ? 2 : 0);
switch (k)
{
case 1: back_pattern = PAT_FDIAG; break;
case 2: back_pattern = PAT_BDIAG; break;
case 3: back_pattern = PAT_DIAGCROSS; break;
default: back_pattern = PAT_HOLLOW; break;
}
switch (rf.type())
{
case 'E':
if (advanced_set_draw_tools(*this, rf.border(), rf.fore_color(), rf.back_color()))
xvt_dwin_draw_oval(win(), &r);
back_pattern = PAT_HOLLOW;
break;
case 'I':
{
TVariant var;
_report->evaluate(rf.field(), var, _alfafld);
const TString& name = var.as_string();
const TImage* img = _report->image(name);
if (img != NULL && img->ok())
img->draw(win(), r);
advanced_draw_rect(*this, r, rf.border(), rf.fore_color(), COLOR_WHITE);
}
break;
case 'L':
if (advanced_set_draw_tools(*this, rf.border(), rf.fore_color(), COLOR_WHITE))
{
const PNT f = { r.top, r.left };
xvt_dwin_draw_set_pos(win(), f);
const PNT t = { r.bottom, r.right };
xvt_dwin_draw_line(win(), t);
}
back_pattern = PAT_HOLLOW;
break;
case 'R':
advanced_draw_rect(*this, r, rf.border(), rf.fore_color(), rf.back_color());
break;
case 'T':
advanced_draw_rect(*this, r, rf.border(), rf.fore_color(), rf.back_color());
xvt_dwin_set_font(win(), rf.font().get_xvt_font(*this));
set_color(rf.fore_color(), rf.back_color());
advanced_draw_text(*this, rf.picture(), r, rf.horizontal_alignment(), rf.vertical_alignment());
break;
default :
if (rf.dynamic_height())
draw_broken_paper(rf);
else
{
if (rf.border() <= 0) // Rendi piu' visibile il bordo dei campi che non ce l'hanno
advanced_draw_rect(*this, r, 1, COLOR_LTGRAY, COLOR_WHITE);
else
advanced_draw_rect(*this, r, rf.border(), rf.fore_color(), rf.back_color());
}
if (rf.link().not_empty())
{
XVT_FNTID lnkfont = xvt_font_create();
xvt_font_copy(lnkfont, rf.font().get_xvt_font(*this), XVT_FA_ALL);
xvt_font_set_style(lnkfont, XVT_FS_UNDERLINE);
xvt_dwin_set_font(win(), lnkfont);
xvt_font_destroy(lnkfont);
set_color(rf.link_color(), rf.back_color());
}
else
{
xvt_dwin_set_font(win(), rf.font().get_xvt_font(*this));
set_color(rf.fore_color(), rf.back_color());
}
TString str;
if (rf.id() > 0)
str << rf.id();
else
str = rf.field();
advanced_draw_text(*this, str, r, rf.horizontal_alignment(), rf.vertical_alignment());
break;
}
if (back_pattern != PAT_HOLLOW)
{
set_pen(COLOR_LTGRAY);
set_brush(COLOR_LTGRAY, back_pattern);
xvt_dwin_draw_rect(win(), &r);
}
if (rf.selected())
{
advanced_set_draw_tools(*this, 0, COLOR_WHITE, COLOR_LTGRAY);
const int k = 5;
RCT s = r; s.right = s.left+k; s.bottom = s.top+k;
xvt_dwin_draw_rect(win(), &s);
s = r; s.left = s.right-k; s.bottom = s.top+k;
xvt_dwin_draw_rect(win(), &s);
s = r; s.right = s.left+k; s.top = s.bottom-k;
xvt_dwin_draw_rect(win(), &s);
s = r; s.left = s.right-k; s.top = s.bottom-k;
xvt_dwin_draw_rect(win(), &s);
}
}
void TReport_window::update()
{
draw_grid();
curr_section().draw(*this, rdm_edit);
draw_grid(); // Disegna griglia
const TReport_section& rs = curr_section();
int y = rs.height();
const bool is_dynamic = y <= 0; // Sezione ad altezza variabile
for (int i = 0; i < rs.items(); i++)
{
const TReport_field& rf = rs.field(i);
draw_field(rf);
if (is_dynamic)
{
const int fy = rf.get_rect().bottom();
if (fy > y) y = fy;
}
}
if (y > 0) // Disegna barra di fine sezione
{
if (is_dynamic)
{
const int mod = y % 100;
if (mod != 0) y += 100-mod;
}
hide_pen();
set_brush(COLOR_LTGRAY, PAT_DIAGCROSS);
bar(0, y, 19600, 6600);
}
}
int TReport_window::cpi() const

View File

@ -17,15 +17,17 @@
class TFormer_mask : public TAutomask
{
bool _doc;
int _qta_decimals;
protected:
void run_app(const char* app) const;
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
void add_array_message(const TString& msg, TReport_field& rf) const;
void parse_field_line(const TString& line, TReport_field& rf) const;
void import_section(TScanner& scan, TReport_section& rs) const;
void import_general(TScanner& scan, TReport& rep) const;
void import_sections(TScanner& scan, TReport& rep) const;
void import_general(TScanner& scan, TReport& rep);
void import_sections(TScanner& scan, TReport& rep);
void import_use(TScanner& scan, TReport& rep) const;
void import();
@ -62,12 +64,38 @@ void TFormer_mask::import_use(TScanner& scan, TReport& rep) const
rep.set_recordset(use);
}
void TFormer_mask::add_array_message(const TString& line, TReport_field& rf) const
{
TToken_string head(line, ' ');
TString_array list;
rf.get_list(list);
const int index = list.last();
TToken_string item = list.row(index);
head.add("MESSAGE", 0);
TString msg = item.get(2);
msg.trim();
if (!msg.empty())
item << '\n';
msg << head;
item.add(msg,2);
list.add(item, index);
rf.set_list(list);
}
void TFormer_mask::parse_field_line(const TString& line, TReport_field& rf) const
{
TToken_string head(line, ' ');
head.trim();
head.strip_d_spaces();
if (head.starts_with("DR"))
{
if (rf.type() == 'V' || rf.type() == 'P')
rf.set_codval(head.get(1));
} else
if (head.starts_with("FI"))
{
TString fld = head.get(1);
@ -106,6 +134,51 @@ void TFormer_mask::parse_field_line(const TString& line, TReport_field& rf) cons
for (int i = head.items()-1; i > 0; i--)
g << ' ' << head.get(i);
rf.set_groups(g);
if (_doc && rf.type() == 'N')
{
if (rf.in_group(29)) // PREZZO
{
rf.set_type('P');
rf.set_codval("33.CODVAL");
} else
if (rf.in_group(30)) // QTA
{
TString pic = rf.picture().before(",");
if (_qta_decimals > 0)
{
pic << ',';
for (int d = 0; d < _qta_decimals; d++)
pic << '@';
}
const int extra = pic.len() - rf.get_rect().width() / 100;
if (extra > 0)
pic = pic.mid(extra);
rf.set_picture(pic);
} else
if (rf.in_group(31)) // IMPORTO
{
rf.set_type('V');
rf.set_codval("33.CODVAL");
}
}
} else
if (head.starts_with("IT"))
{
const int apicia = head.find('"')+1;
if (apicia > 0 && rf.type() == 'A')
{
const int apicic = head.find('"', apicia);
TToken_string item(head.sub(apicia, apicic), SAFE_PIPE_CHR);
item.replace('|', SAFE_PIPE_CHR);
TString_array list;
rf.get_list(list);
list.add(item);
rf.set_list(list);
const int msg = head.find(" ME", apicic);
if (msg > 0)
add_array_message(head.mid(msg+1), rf);
}
} else
if (head.starts_with("ME"))
{
@ -116,12 +189,17 @@ void TFormer_mask::parse_field_line(const TString& line, TReport_field& rf) cons
}
else
{
head.add("MESSAGE", 0);
TString me = rf.prescript();
if (me.not_empty())
me << '\n';
me << head;
rf.set_prescript(me);
if (rf.type() == 'A')
add_array_message(head, rf);
else
{
head.add("MESSAGE", 0);
TString me = rf.prescript();
if (me.not_empty())
me << '\n';
me << head;
rf.set_prescript(me);
}
}
} else
if (head.starts_with("PI"))
@ -155,7 +233,7 @@ void TFormer_mask::parse_field_line(const TString& line, TReport_field& rf) cons
}
}
void TFormer_mask::import_general(TScanner& scan, TReport& rep) const
void TFormer_mask::import_general(TScanner& scan, TReport& rep)
{
TString expr;
while (scan.ok())
@ -163,23 +241,30 @@ void TFormer_mask::import_general(TScanner& scan, TReport& rep) const
TString& line = scan.line();
if (line.empty() || line.starts_with("EN"))
break;
if (_doc && line.starts_with("EXCLUDE"))
if (_doc)
{
TToken_string exclude(50, ',');
exclude = line.after('"');
exclude.strip("\""); exclude.trim();
TString cond, codart;
cond << "(34.TIPORIGA='" << exclude.get(0) << "\')";
codart = exclude.get(1);
if (!codart.blank())
if (line.starts_with("EXCLUDE"))
{
cond.insert("(");
cond << "&&(34.CODART?='" << codart << "')";
cond << ')';
TToken_string exclude(50, ',');
exclude = line.after('"');
exclude.strip("\""); exclude.trim();
TString cond, codart;
cond << "(34.TIPORIGA='" << exclude.get(0) << "\')";
codart = exclude.get(1);
if (!codart.blank())
{
cond.insert("(");
cond << "&&(34.CODART?='" << codart << "')";
cond << ')';
}
if (expr.not_empty())
expr << "||";
expr << cond;
} else
if (line.starts_with("QTA_DECIMALS"))
{
_qta_decimals = atoi(line.mid(13));
}
if (expr.not_empty())
expr << "||";
expr << cond;
}
}
@ -214,7 +299,9 @@ void TFormer_mask::import_section(TScanner& scan, TReport_section& rs) const
const TString16 str_type = head.get(0);
char type = ' ';
if (str_type.starts_with("FI"))
type = 'I';
type = 'I'; else
if (str_type.starts_with("LI"))
type = 'A';
else
type = str_type[0];
@ -222,8 +309,7 @@ void TFormer_mask::import_section(TScanner& scan, TReport_section& rs) const
{
const int id = head.get_int(1);
const int width = 100*head.get_int();
int height = 100*head.get_int();
if (height <= 0) height = 100;
const int height = 100*head.get_int();
cur_field = new TReport_field(&rs);
cur_field->set_type(type);
@ -231,10 +317,12 @@ void TFormer_mask::import_section(TScanner& scan, TReport_section& rs) const
cur_field->set_id(id);
if (width > 0)
cur_field->set_width(width);
if (_doc && type == 'S' && height >= 500 && rs.type() == 'B')
cur_field->set_height(0); // Altezaa descrizione automatica
else
if (height > 0)
{
cur_field->set_height(height);
if (_doc && type == 'S' && height >= 500 && rs.type() == 'B')
cur_field->set_dynamic_height(true); // Altezza descrizione automatica
}
if (strchr("NVP", type) != NULL)
{
cur_field->set_horizontal_alignment('R');
@ -252,7 +340,8 @@ void TFormer_mask::import_section(TScanner& scan, TReport_section& rs) const
if (cur_field != NULL)
{
// Trasforma in testi fissi i campi stringa senza sorgente
if (cur_field->type() == 'S' && cur_field->field().blank() && cur_field->prescript().blank())
if (cur_field->type() == 'S' && !cur_field->picture().blank() &&
cur_field->field().blank() && cur_field->prescript().blank())
cur_field->set_type('T');
}
in_field--; // END of field
@ -270,7 +359,7 @@ void TFormer_mask::import_section(TScanner& scan, TReport_section& rs) const
}
}
void TFormer_mask::import_sections(TScanner& scan, TReport& rep) const
void TFormer_mask::import_sections(TScanner& scan, TReport& rep)
{
while (scan.ok())
{
@ -376,7 +465,7 @@ bool TFormer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
switch (o.dlg())
{
case F_FORM:
if (e == fe_modify)
if (e == fe_modify || (e == fe_init && !o.empty()))
{
TFilename output = get(F_REPORT);
TFilename path = output.path();
@ -389,17 +478,21 @@ bool TFormer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
input.ext("frm");
input.custom_path();
o.set(input);
const TString name = input.name();
output = path;
output.add(input.name());
output.add(name);
output.ext("rep");
output.lower();
set(F_REPORT, output, true);
enable(DLG_ELABORA, input.exist());
set(F_DOC, isdigit(name[2]) ? "" : "X");
}
break;
case F_REPORT:
if (e == fe_modify)
if (e == fe_modify || e == fe_init)
{
const TFilename output = get(F_REPORT);
const bool yes = output.exist();
@ -439,8 +532,12 @@ bool TFormer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
return true;
}
TFormer_mask::TFormer_mask() : TAutomask("ba8400a")
TFormer_mask::TFormer_mask()
: TAutomask("ba8400a"), _qta_decimals(0)
{
#ifdef DBG
set(F_FORM, "d:/clienti/dipiu/custom/fatdipiu.frm");
#endif
}
///////////////////////////////////////////////////////////

209
ba/ba8500.cpp Executable file
View File

@ -0,0 +1,209 @@
#include <applicat.h>
#include <automask.h>
#include <defmask.h>
#include <execp.h>
#include <printer.h>
#include <reprint.h>
#include <utility.h>
#include "ba8400.h"
///////////////////////////////////////////////////////////
// Utility
///////////////////////////////////////////////////////////
bool cod2app(const char* tok, TString& app)
{
if (isalpha(tok[0]) && isalpha(tok[1]) && atoi(tok+2) > 1000)
{
app.strncpy(tok, 3);
app << " -" << char(tok[3]-1);
return true;
}
return false;
}
bool get_xml_attr(const TString& line, const char* attr, TString& value)
{
TString str; str << ' ' << attr << "=\"";
const int pos = line.find(str);
if (pos >= 0)
{
const int apicia = line.find('"', pos)+1;
const int apicic = line.find('"', apicia);
if (apicic > apicia)
{
value = line.sub(apicia, apicic);
return true;
}
}
return false;
}
bool get_xml_child(const TString& line, const char* tag, TString& value)
{
TString str; str << '<' << tag << '>';
const int pos = line.find(str);
if (pos >= 0)
{
const int apicia = line.find('>', pos)+1;
const int apicic = line.find('<', apicia);
if (apicic > apicia)
{
value = line.sub(apicia, apicic);
return true;
}
}
return false;
}
bool rep2app(const char* name, TString& app, TString& desc)
{
app = desc = "";
TFilename report_name(name);
report_name.ext("rep");
if (!report_name.custom_path())
return false;
TToken_string libraries(50, ',');
TString stringona;
TScanner scan(report_name);
for (int i = 0; i < 3 && scan.good(); i++) // Leggo solo le prime righe
stringona << scan.line();
get_xml_attr(stringona, "libraries", libraries);
get_xml_child(stringona, "description", desc);
FOR_EACH_TOKEN(libraries, tok) if (strlen(tok) == 6)
{
if (cod2app(tok, app))
return true;
}
cod2app(report_name.name(), app);
return true;
}
///////////////////////////////////////////////////////////
// TKlarkKent_mask
///////////////////////////////////////////////////////////
class TKlarkKent_mask : public TAutomask
{
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TKlarkKent_mask() : TAutomask("ba8500a") { }
};
bool TKlarkKent_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch (o.dlg())
{
case F_REPORT:
if (e == fe_button)
{
TArray_sheet a(-1, -1, 75, 20, "Report", "Nome@16|Progr.|Descrizione@50");
TString_array& arr = a.rows_array();
list_files("*.rep", arr);
TFilename dir = firm2dir(-1); dir.add("custom"); dir.add("*.rep");
list_files(dir, arr);
TString app, desc;
FOR_EACH_ARRAY_ROW(arr, i, row)
{
rep2app(*row, app, desc);
TFilename n = *row; n = n.name(); n.ext("");
*row = n;
row->add(app);
row->add(desc);
}
if (a.run() == K_ENTER)
{
o.set(a.row(-1).get(0));
e = fe_modify;
}
}
if (e == fe_init || e == fe_modify)
{
TFilename name = o.get();
TString app, desc;
const bool ok = rep2app(name, app, desc);
set(F_FORM, desc);
set(F_DOC, app);
enable(DLG_PRINT, ok);
}
break;
case DLG_EDIT:
if (e == fe_button && !field(F_REPORT).empty())
{
TString str;
str << "ba8 -2 " << get(F_REPORT);
TExternal_app app(str);
app.run(true);
}
break;
default:
break;
}
return true;
}
///////////////////////////////////////////////////////////
// TKlarkKent_app
///////////////////////////////////////////////////////////
class TKlarkKent_app : public TSkeleton_application
{
protected:
virtual void main_loop();
};
void TKlarkKent_app::main_loop()
{
TFilename report_name;
if (argc() > 2)
report_name = argv(2);
if (report_name.empty() || !report_name.custom_path())
{
TKlarkKent_mask m;
m.set(F_REPORT, report_name);
if (m.run() == K_ENTER)
{
report_name = m.get(F_REPORT);
report_name.custom_path();
}
}
TString appname, desc;
rep2app(report_name, appname, desc);
if (appname.not_empty())
{
appname << ' ' << report_name;
TExternal_app app(appname);
app.run(true);
}
else
{
TReport rep;
if (rep.load(report_name))
{
TReport_printer rp(rep);
rp.print(printer().printtype() == screenvis);
}
}
}
int ba8500(int argc, char* argv[])
{
TKlarkKent_app app;
app.run(argc, argv, TR("Stampa Report"));
return 0;
}

43
ba/ba8500a.uml Executable file
View File

@ -0,0 +1,43 @@
#include "ba8400.h"
PAGE "Stampa Report" -1 -1 62 5
STRING F_REPORT 256 50
BEGIN
PROMPT 1 1 "Report "
FLAGS "B"
END
STRING F_FORM 256 45
BEGIN
PROMPT 1 2 "Descrizione "
FLAGS "D"
END
STRING F_DOC 256 45
BEGIN
PROMPT 1 3 "Applicazione "
FLAGS "D"
END
BUTTON DLG_PRINT 10 2
BEGIN
PROMPT -13 -1 "~Stampa"
PICTURE BMP_PRINT
FLAGS "D"
END
BUTTON DLG_EDIT 10 2
BEGIN
PROMPT -23 -1 "~Edit"
PICTURE BMP_EDIT
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -33 -1 ""
END
ENDPAGE
ENDMASK

View File

@ -72,7 +72,8 @@
\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
: MESSAGE_ADD ( f1 -- )
#THIS @ SWAP +! \ Incrementa f1 col contenuto del campo corrente
#THIS @ \ Leggo il valore del campo corrente
SWAP +! \ Incrementa f1 col contenuto del campo corrente
;
: MESSAGE_ALIGN ( s1 f1 -- )
@ -82,7 +83,11 @@
;
: MESSAGE_APPEND ( f1 -- )
MESSAGE_ADD \ Incrementa f1 col contenuto del campo corrente
" " \ Inserisco uno spazio
#THIS @ \ Leggo il valore del campo corrente
+ \ Sommo uno spazio all'inizio della stringa
SWAP \ Riporto in primo piano f1
+! \ Incrementa f1 col contenuto della stringa
;
: MESSAGE_COPY ( f1 ... fn -- )
@ -91,7 +96,6 @@
WHILE
#THIS @ SWAP ! \ Copia il campo corrente
REPEAT
DROP \ Butta via il NULL generato automaticamente
;
: MESSAGE_DEBUG ( NULL -- )
@ -134,8 +138,9 @@
ISAM_READ
;
: MESSAGE_PAGENO ( -- ) \ Numero di pagina corrente
#REPORT.PAGE @ #THIS !
: MESSAGE_PAGENO ( -- ) \ Numero di pagina corrente
#REPORT.PAGE @ \ Leggo il numero di pagina
#THIS ! \ Setto il campo corrente col numero
;
: MESSAGE_RESET ( f1 ... fn -- )
@ -155,7 +160,9 @@
;
: MESSAGE_SUB ( f1 -- )
#THIS @ -1 * SWAP +! \ Decrementa f1 col contenuto del campo corrente
#THIS @ \ Leggo il campo corrente
-1 * \ Lo cambio di segno
SWAP +! \ Decrementa f1 col contenuto del campo corrente
;
: MESSAGE_TABLEREAD ( s1 s2 s3 -- )