2004-04-01 15:42:45 +00:00
|
|
|
#include <xinclude.h>
|
2004-03-08 16:16:28 +00:00
|
|
|
|
|
|
|
#include <applicat.h>
|
|
|
|
#include <automask.h>
|
2004-03-18 14:35:38 +00:00
|
|
|
#include <colors.h>
|
2004-03-11 16:36:30 +00:00
|
|
|
#include <defmask.h>
|
2004-03-08 16:16:28 +00:00
|
|
|
#include <execp.h>
|
|
|
|
#include <prefix.h>
|
2004-03-11 16:36:30 +00:00
|
|
|
#include <printer.h>
|
2004-03-08 16:16:28 +00:00
|
|
|
|
|
|
|
#include "ba8201.h"
|
|
|
|
#include "ba8300.h"
|
2004-03-15 15:41:18 +00:00
|
|
|
#include "ba8301.h"
|
2004-04-01 15:42:45 +00:00
|
|
|
#include "ba8303.h"
|
2004-03-11 16:36:30 +00:00
|
|
|
#include <bagn003.h>
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
2004-03-25 16:36:29 +00:00
|
|
|
// Utility
|
2004-03-11 16:36:30 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
static TString8 _str;
|
2004-03-23 16:39:40 +00:00
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
const TString& num2str(int num)
|
2004-03-23 16:39:40 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
const real n(num / 100.0);
|
|
|
|
_str = n.stringa(0, 2);
|
|
|
|
const int comma = _str.find(',');
|
|
|
|
if (comma > 0)
|
2004-03-23 16:39:40 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
if (_str[comma+2] == '0')
|
2004-03-23 16:39:40 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
if (_str[comma+1] == '0')
|
|
|
|
_str.cut(comma);
|
2004-03-23 16:39:40 +00:00
|
|
|
else
|
2004-03-25 16:36:29 +00:00
|
|
|
_str.cut(comma+2);
|
2004-03-23 16:39:40 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-25 16:36:29 +00:00
|
|
|
return _str;
|
2004-03-11 16:36:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
short str2num(const TString& str)
|
2004-03-11 16:36:30 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
_str = str;
|
|
|
|
_str.replace(',', '.');
|
|
|
|
real n(_str);
|
|
|
|
n *= CENTO;
|
|
|
|
return (short)n.integer();
|
2004-03-11 16:36:30 +00:00
|
|
|
}
|
2004-03-08 16:16:28 +00:00
|
|
|
|
2004-03-09 15:20:36 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
2004-04-28 10:01:32 +00:00
|
|
|
// TReport_base_mask
|
2004-03-09 15:20:36 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
class TReport_base_mask : public TAutomask
|
2004-03-25 16:36:29 +00:00
|
|
|
{
|
|
|
|
TReport_font _font;
|
|
|
|
bool _font_changed;
|
2004-03-18 14:35:38 +00:00
|
|
|
|
2004-03-08 16:16:28 +00:00
|
|
|
protected:
|
2004-05-04 08:25:23 +00:00
|
|
|
TReport& _report;
|
2004-03-25 16:36:29 +00:00
|
|
|
char _halign, _valign;
|
|
|
|
COLOR _fgcolor, _bgcolor;
|
2004-03-18 14:35:38 +00:00
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
virtual void update();
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
2004-03-15 15:41:18 +00:00
|
|
|
|
2004-03-09 15:20:36 +00:00
|
|
|
public:
|
2004-03-25 16:36:29 +00:00
|
|
|
void set_font_info(const TReport_font& font);
|
|
|
|
bool get_font_info(TReport_font& font) const;
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
TReport_base_mask(const char* name, TReport& rep);
|
2004-03-09 15:20:36 +00:00
|
|
|
};
|
2004-03-08 16:16:28 +00:00
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
void TReport_base_mask::update()
|
2004-03-11 16:36:30 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
const TMask_field& fld = field(F_FONT_SELECT);
|
2004-04-07 16:11:18 +00:00
|
|
|
if (fld.active() && win() == fld.parent())
|
2004-03-11 16:36:30 +00:00
|
|
|
{
|
2004-04-01 15:42:45 +00:00
|
|
|
RCT rctfld; fld.get_rect(rctfld);
|
|
|
|
const int x = rctfld.right / CHARX + 1;
|
|
|
|
const int y = rctfld.top / ROWY + 1;
|
|
|
|
RCT& rct = resize_rect(x, y, -3, 2, W_PLAIN, win());
|
|
|
|
rct.top = rctfld.top; rct.bottom = rctfld.bottom;
|
2004-03-25 16:36:29 +00:00
|
|
|
xi_draw_3d_rect((XinWindow)win(), (XinRect*)&rct, TRUE, 2, MASK_LIGHT_COLOR,
|
|
|
|
_bgcolor, MASK_DARK_COLOR);
|
2004-03-11 16:36:30 +00:00
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
rct.left += 2; rct.right -= 2;
|
|
|
|
rct.top += 2; rct.bottom -= 2;
|
|
|
|
xvt_dwin_set_clip(win(), &rct);
|
2004-03-11 16:36:30 +00:00
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
XVT_FNTID fontid = _font.get_xvt_font(*this);
|
|
|
|
xvt_font_set_size(fontid, _font.size());
|
|
|
|
xvt_dwin_set_font(win(), fontid);
|
|
|
|
set_color(_fgcolor, _bgcolor);
|
|
|
|
advanced_draw_text(*this, _font.name(), rct, _halign, _valign);
|
2004-03-11 16:36:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
bool TReport_base_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
2004-03-11 16:36:30 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
switch (o.dlg())
|
2004-03-18 14:35:38 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
case F_FONT_SELECT:
|
|
|
|
if (e == fe_button)
|
2004-03-18 14:35:38 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
XVT_FNTID font = xvt_font_create();
|
|
|
|
xvt_font_copy(font, _font.get_xvt_font(*this), XVT_FA_ALL);
|
|
|
|
xvt_font_set_size(font, _font.size());
|
|
|
|
if (xvt_dm_post_font_sel(win(), font, NULL, 0))
|
2004-03-18 14:35:38 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
TString name;
|
|
|
|
xvt_font_get_family(font, name.get_buffer(), name.size());
|
|
|
|
const int size = xvt_font_get_size(font);
|
|
|
|
const XVT_FONT_STYLE_MASK style = xvt_font_get_style(font);
|
|
|
|
_font.create(name, size, style);
|
2004-03-18 14:35:38 +00:00
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
_font_changed = true;
|
|
|
|
force_update();
|
2004-03-11 16:36:30 +00:00
|
|
|
}
|
2004-03-25 16:36:29 +00:00
|
|
|
xvt_font_destroy(font);
|
2004-03-11 16:36:30 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-03-25 16:36:29 +00:00
|
|
|
case F_HALIGN:
|
|
|
|
case F_VALIGN:
|
|
|
|
if (e == fe_init || e == fe_modify)
|
2004-03-11 16:36:30 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
_halign = get(F_HALIGN)[0];
|
|
|
|
_valign = get(F_VALIGN)[0];
|
2004-03-11 16:36:30 +00:00
|
|
|
force_update();
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-04-28 10:01:32 +00:00
|
|
|
case F_PRESCRIPT:
|
|
|
|
case F_POSTSCRIPT:
|
|
|
|
if (e == fe_close)
|
|
|
|
{
|
|
|
|
TReport_script s;
|
|
|
|
s.set(o.get());
|
|
|
|
s.compile(_report);
|
|
|
|
}
|
|
|
|
break;
|
2004-03-11 16:36:30 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-03-25 16:36:29 +00:00
|
|
|
return true;
|
2004-03-11 16:36:30 +00:00
|
|
|
}
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
void TReport_base_mask::set_font_info(const TReport_font& font)
|
2004-03-11 16:36:30 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
_font = font;
|
2004-03-11 16:36:30 +00:00
|
|
|
}
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
bool TReport_base_mask::get_font_info(TReport_font& font) const
|
2004-03-11 16:36:30 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
const bool ok = _font_changed;
|
|
|
|
if (ok)
|
|
|
|
font = _font;
|
|
|
|
return ok;
|
2004-03-11 16:36:30 +00:00
|
|
|
}
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
TReport_base_mask::TReport_base_mask(const char* name, TReport& rep)
|
|
|
|
: TAutomask(name), _report(rep),
|
|
|
|
_font_changed(false),
|
2004-04-01 15:42:45 +00:00
|
|
|
_halign('C'), _valign('C'),
|
2004-03-25 16:36:29 +00:00
|
|
|
_fgcolor(COLOR_BLACK), _bgcolor(COLOR_WHITE)
|
2004-03-11 16:36:30 +00:00
|
|
|
{
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TReport_field_mask
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
class TReport_field_mask : public TReport_base_mask
|
2004-03-18 14:35:38 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
protected:
|
2004-04-06 16:06:26 +00:00
|
|
|
void vedo_non_vedo();
|
2004-03-18 14:35:38 +00:00
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
2004-03-25 16:36:29 +00:00
|
|
|
virtual void update();
|
2004-03-18 14:35:38 +00:00
|
|
|
|
|
|
|
public:
|
2004-03-26 14:53:58 +00:00
|
|
|
void set_num(short id, long n);
|
|
|
|
long get_num(short id) const;
|
2004-03-18 14:35:38 +00:00
|
|
|
|
|
|
|
void set_field(const TReport_field& rf);
|
|
|
|
void get_field(TReport_field& rf) const;
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
TReport_field_mask(TReport_field& rf);
|
2004-03-18 14:35:38 +00:00
|
|
|
};
|
|
|
|
|
2004-03-26 14:53:58 +00:00
|
|
|
void TReport_field_mask::set_num(short id, long num)
|
2004-03-18 14:35:38 +00:00
|
|
|
{
|
|
|
|
set(id, num2str(num));
|
|
|
|
}
|
|
|
|
|
2004-03-26 14:53:58 +00:00
|
|
|
long TReport_field_mask::get_num(short id) const
|
2004-03-18 14:35:38 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
return str2num(get(id));
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
void TReport_field_mask::update()
|
2004-03-18 14:35:38 +00:00
|
|
|
{
|
2004-04-07 16:11:18 +00:00
|
|
|
for (int i = 0; i < 2; i++)
|
2004-03-18 14:35:38 +00:00
|
|
|
{
|
2004-04-07 16:11:18 +00:00
|
|
|
TMask_field& fld = field(i == 0 ? F_FGCOLOR : F_BGCOLOR);
|
|
|
|
if (fld.active() && fld.parent() == win())
|
2004-03-18 14:35:38 +00:00
|
|
|
{
|
2004-04-07 16:11:18 +00:00
|
|
|
RCT rctfld; fld.get_rect(rctfld);
|
|
|
|
const int x = rctfld.right / CHARX + 1;
|
|
|
|
const int y = rctfld.top / ROWY + 1;
|
|
|
|
RCT& rct = resize_rect(x, y, -3, 1, W_PLAIN, win());
|
|
|
|
rct.top = rctfld.top; rct.bottom = rctfld.bottom;
|
|
|
|
xi_draw_3d_rect((XinWindow)win(), (XinRect*)&rct, TRUE, 2, MASK_LIGHT_COLOR,
|
|
|
|
i == 0 ? _fgcolor : _bgcolor, MASK_DARK_COLOR);
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
}
|
2004-04-28 10:01:32 +00:00
|
|
|
TReport_base_mask::update();
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-06 16:06:26 +00:00
|
|
|
void TReport_field_mask::vedo_non_vedo()
|
|
|
|
{
|
|
|
|
const char type = get(F_TYPE)[0];
|
2004-04-22 15:53:08 +00:00
|
|
|
const bool is_currency = type == 'P' || type == 'V';
|
|
|
|
const bool is_numeric = is_currency || type == 'N';
|
2004-04-27 15:36:39 +00:00
|
|
|
const bool is_text = is_numeric || strchr("ADST", type) != NULL;
|
2004-04-06 16:06:26 +00:00
|
|
|
|
2004-04-22 15:53:08 +00:00
|
|
|
show(F_HIDE_ZEROES, is_numeric || type == 'D'),
|
2004-04-06 16:06:26 +00:00
|
|
|
show(F_HALIGN, is_text);
|
2004-04-22 15:53:08 +00:00
|
|
|
if (is_numeric)
|
|
|
|
{
|
|
|
|
disable(F_HALIGN);
|
|
|
|
set(F_HALIGN, "R"); // Allineo a destra i numeri
|
|
|
|
}
|
|
|
|
else
|
|
|
|
enable(F_HALIGN);
|
|
|
|
|
2004-04-06 16:06:26 +00:00
|
|
|
show(F_VALIGN, is_text);
|
2004-04-22 15:53:08 +00:00
|
|
|
show(F_TEXT, is_text && !is_currency);
|
2004-04-06 16:06:26 +00:00
|
|
|
show(F_FGCOLOR, type != 'I');
|
2004-04-22 15:53:08 +00:00
|
|
|
show(F_BGCOLOR, type != 'L');
|
2004-04-06 16:06:26 +00:00
|
|
|
show(F_FONT_SELECT, is_text);
|
|
|
|
show(F_SOURCE, (is_text || type == 'I') && type != 'T');
|
2004-05-04 08:25:23 +00:00
|
|
|
show(DLG_FINDREC, field(F_SOURCE).active());
|
2004-04-22 15:53:08 +00:00
|
|
|
show(F_CODVAL, is_currency); // Codice valuta di riferimento
|
|
|
|
show(F_LINK, strchr("DNS", type) != NULL); // Chi puo' essere un link?
|
2004-04-27 15:36:39 +00:00
|
|
|
show(F_PRESCRIPT, is_text);
|
|
|
|
show(F_POSTSCRIPT, is_text);
|
|
|
|
enable_page(3, type == 'A');
|
2004-04-06 16:06:26 +00:00
|
|
|
|
|
|
|
if (is_running())
|
|
|
|
force_update();
|
|
|
|
}
|
|
|
|
|
2004-03-18 14:35:38 +00:00
|
|
|
bool TReport_field_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
{
|
|
|
|
switch(o.dlg())
|
|
|
|
{
|
2004-04-06 16:06:26 +00:00
|
|
|
case F_TYPE:
|
|
|
|
if (e == fe_init || e == fe_modify)
|
|
|
|
vedo_non_vedo();
|
|
|
|
break;
|
2004-03-18 14:35:38 +00:00
|
|
|
case F_X:
|
|
|
|
case F_Y:
|
|
|
|
case F_DX:
|
|
|
|
case F_DY:
|
|
|
|
if (e == fe_modify)
|
|
|
|
{
|
|
|
|
const int num = get_num(o.dlg());
|
|
|
|
set_num(o.dlg(), num); // Reformat
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case F_FGCOLOR:
|
|
|
|
if (e == fe_button)
|
|
|
|
{
|
|
|
|
_fgcolor = xvt_dm_post_choose_color(win(), _fgcolor);
|
|
|
|
force_update();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case F_BGCOLOR:
|
|
|
|
if (e == fe_button)
|
|
|
|
{
|
|
|
|
_bgcolor = xvt_dm_post_choose_color(win(), _bgcolor);
|
|
|
|
force_update();
|
|
|
|
}
|
|
|
|
break;
|
2004-04-27 15:36:39 +00:00
|
|
|
case F_LIST:
|
|
|
|
if (e == fe_close)
|
|
|
|
{
|
|
|
|
TSheet_field& sheet = sfield(F_LIST);
|
|
|
|
TAssoc_array ass;
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, i, row)
|
|
|
|
{
|
|
|
|
if (ass.add(row->get(0)))
|
|
|
|
return error_box(TR("E' necessario specificare codici diversi"));
|
|
|
|
}
|
|
|
|
if (ass.items() < 2)
|
|
|
|
return error_box(TR("Specificare almeno due codici"));
|
|
|
|
}
|
|
|
|
break;
|
2004-05-04 08:25:23 +00:00
|
|
|
case DLG_FINDREC:
|
|
|
|
if (e == fe_button)
|
|
|
|
{
|
|
|
|
TRecordset* rex = _report.recordset();
|
|
|
|
if (rex != NULL && rex->columns() > 0)
|
|
|
|
{
|
|
|
|
TArray_sheet sheet(-1, -1, -1, 20, "Colonne Query", "Nome@16|Tipo@8|Dimensoni@R");
|
|
|
|
TToken_string row;
|
|
|
|
for (size_t i = 0; i < rex->columns(); i++)
|
|
|
|
{
|
|
|
|
const TRecordset_column_info& info = rex->column_info(i);
|
|
|
|
row = info._name;
|
|
|
|
switch (info._type)
|
|
|
|
{
|
|
|
|
case _alfafld: row.add("Stringa"); break;
|
|
|
|
case _boolfld: row.add("Logico"); break;
|
|
|
|
case _datefld: row.add("Data"); break;
|
|
|
|
case _memofld: row.add("Memo"); break;
|
|
|
|
default : row.add("Numero"); break;
|
|
|
|
}
|
|
|
|
row.add(info._width);
|
|
|
|
sheet.add(row);
|
|
|
|
}
|
|
|
|
if (sheet.run() == K_ENTER)
|
|
|
|
{
|
|
|
|
row = sheet.row(-1);
|
|
|
|
set(F_SOURCE, row.get(0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
warning_box("Query non definita");
|
|
|
|
}
|
|
|
|
break;
|
2004-03-18 14:35:38 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-04-28 10:01:32 +00:00
|
|
|
return TReport_base_mask::on_field_event(o, e, jolly);
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TReport_field_mask::set_field(const TReport_field& rf)
|
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
char str[2] = { rf.type(), '\0' };
|
2004-04-06 16:06:26 +00:00
|
|
|
set(F_TYPE, str, true);
|
2004-03-18 14:35:38 +00:00
|
|
|
|
2004-03-26 14:53:58 +00:00
|
|
|
const TRectangle& r = rf.get_rect();
|
2004-04-01 15:42:45 +00:00
|
|
|
set(F_ID, rf.id());
|
2004-03-26 14:53:58 +00:00
|
|
|
set_num(F_X, r.left());
|
|
|
|
set_num(F_Y, r.top());
|
|
|
|
set_num(F_DX, r.width());
|
|
|
|
set_num(F_DY, r.height());
|
2004-04-01 15:42:45 +00:00
|
|
|
set(F_HIDDEN, rf.hidden() ? "X" : "");
|
|
|
|
set(F_DISABLED, rf.deactivated() ? "X" : "");
|
2004-04-06 16:06:26 +00:00
|
|
|
set(F_HIDE_ZEROES, rf.zeroes_hidden() ? "X" : "");
|
2004-04-07 16:11:18 +00:00
|
|
|
set(F_GROUPS, rf.groups());
|
2004-04-22 15:53:08 +00:00
|
|
|
set(F_CODVAL, rf.codval());
|
|
|
|
set(F_LINK, rf.link());
|
2004-04-07 16:11:18 +00:00
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
str[0] = rf.horizontal_alignment();
|
|
|
|
set(F_HALIGN, str);
|
|
|
|
str[0] = rf.vertical_alignment();
|
|
|
|
set(F_VALIGN, str);
|
2004-03-18 14:35:38 +00:00
|
|
|
set(F_BORDER, rf.border());
|
|
|
|
_fgcolor = rf.fore_color();
|
|
|
|
_bgcolor = rf.back_color();
|
|
|
|
set(F_TEXT, rf.picture());
|
|
|
|
set(F_SOURCE, rf.field());
|
2004-03-25 16:36:29 +00:00
|
|
|
set_font_info(rf.font());
|
2004-04-07 16:11:18 +00:00
|
|
|
|
2004-04-01 15:42:45 +00:00
|
|
|
set(F_PRESCRIPT, rf.prescript());
|
|
|
|
set(F_POSTSCRIPT, rf.postscript());
|
2004-04-27 15:36:39 +00:00
|
|
|
|
|
|
|
if (rf.type() == 'A')
|
|
|
|
{
|
|
|
|
TSheet_field& list = sfield(F_LIST);
|
|
|
|
rf.get_list(list.rows_array());
|
|
|
|
}
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TReport_field_mask::get_field(TReport_field& rf) const
|
|
|
|
{
|
2004-03-23 16:39:40 +00:00
|
|
|
rf.set_type(get(F_TYPE)[0]);
|
2004-04-01 15:42:45 +00:00
|
|
|
rf.set_id(get_int(F_ID));
|
2004-03-18 14:35:38 +00:00
|
|
|
rf.set_pos(get_num(F_X), get_num(F_Y));
|
|
|
|
rf.set_size(get_num(F_DX), get_num(F_DY));
|
2004-04-01 15:42:45 +00:00
|
|
|
rf.show(!get_bool(F_HIDDEN));
|
|
|
|
rf.activate(!get_bool(F_DISABLED));
|
2004-04-06 16:06:26 +00:00
|
|
|
rf.hide_zeroes(get_bool(F_HIDE_ZEROES));
|
2004-04-07 16:11:18 +00:00
|
|
|
rf.set_groups(get(F_GROUPS));
|
2004-04-22 15:53:08 +00:00
|
|
|
rf.set_codval(get(F_CODVAL));
|
|
|
|
rf.set_link(get(F_LINK));
|
2004-03-18 14:35:38 +00:00
|
|
|
rf.set_horizontal_alignment(get(F_HALIGN)[0]);
|
|
|
|
rf.set_vertical_alignment(get(F_VALIGN)[0]);
|
|
|
|
rf.set_border(get_int(F_BORDER));
|
|
|
|
rf.set_fore_color(_fgcolor);
|
|
|
|
rf.set_back_color(_bgcolor);
|
|
|
|
rf.set_picture(get(F_TEXT));
|
|
|
|
rf.set_field(get(F_SOURCE));
|
2004-03-25 16:36:29 +00:00
|
|
|
TReport_font f;
|
|
|
|
if (get_font_info(f))
|
|
|
|
rf.set_font(f);
|
2004-04-07 16:11:18 +00:00
|
|
|
|
2004-04-01 15:42:45 +00:00
|
|
|
rf.set_prescript(get(F_PRESCRIPT));
|
|
|
|
rf.set_postscript(get(F_POSTSCRIPT));
|
2004-04-27 15:36:39 +00:00
|
|
|
if (rf.type() == 'A')
|
|
|
|
{
|
|
|
|
TSheet_field& list = sfield(F_LIST);
|
|
|
|
rf.set_list(list.rows_array());
|
|
|
|
}
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
TReport_field_mask::TReport_field_mask(TReport_field& rf)
|
|
|
|
: TReport_base_mask("ba8300b", rf.section().report())
|
|
|
|
{
|
|
|
|
set_field(rf);
|
|
|
|
}
|
|
|
|
|
2004-03-18 14:35:38 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TReport_sheet
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TReport_sheet : public TSheet
|
|
|
|
{
|
|
|
|
TReport_section& _section;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual long get_items() const { return _section.items(); }
|
|
|
|
virtual void get_row(long r, TToken_string& row);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual KEY run();
|
|
|
|
int selection(int& first, int& last) const;
|
|
|
|
TReport_sheet(TReport_section& sec);
|
|
|
|
};
|
|
|
|
|
|
|
|
void TReport_sheet::get_row(long r, TToken_string& row)
|
|
|
|
{
|
|
|
|
const TReport_field& rf = (const TReport_field&)_section[r];
|
2004-03-26 14:53:58 +00:00
|
|
|
const TRectangle& rect = rf.get_rect();
|
2004-03-18 14:35:38 +00:00
|
|
|
row.cut(0);
|
|
|
|
row.add(checked(r) ? "X" : " ");
|
2004-03-23 16:39:40 +00:00
|
|
|
row.add(rf.type_name());
|
2004-04-01 15:42:45 +00:00
|
|
|
row.add(rf.id());
|
2004-03-26 14:53:58 +00:00
|
|
|
row.add(num2str(rect.top()));
|
|
|
|
row.add(num2str(rect.left()));
|
|
|
|
row.add(num2str(rect.width()));
|
|
|
|
row.add(num2str(rect.height()));
|
2004-04-01 15:42:45 +00:00
|
|
|
if (rf.field().not_empty())
|
|
|
|
row.add(rf.field());
|
|
|
|
else
|
|
|
|
row.add(rf.picture());
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int TReport_sheet::selection(int& first, int& last) const
|
|
|
|
{
|
|
|
|
int tot = 0;
|
|
|
|
first = items()+1;
|
|
|
|
last = -1;
|
|
|
|
FOR_EACH_ARRAY_ITEM_BACK(_section, i, o)
|
|
|
|
{
|
|
|
|
const TReport_field& rf = *(const TReport_field*)o;
|
|
|
|
if (rf.selected())
|
|
|
|
{
|
|
|
|
if (i < first) first = i;
|
|
|
|
if (i > last) last = i;
|
|
|
|
tot++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tot;
|
|
|
|
}
|
|
|
|
|
|
|
|
KEY TReport_sheet::run()
|
|
|
|
{
|
|
|
|
int first = -1;
|
|
|
|
uncheck(-1);
|
|
|
|
FOR_EACH_ARRAY_ITEM(_section, i, o)
|
|
|
|
{
|
|
|
|
const TReport_field& rf = *(const TReport_field*)o;
|
|
|
|
if (rf.selected())
|
|
|
|
{
|
|
|
|
check(i);
|
|
|
|
if (first < 0)
|
|
|
|
first = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (first > 0)
|
|
|
|
select(first);
|
|
|
|
const KEY k = TSheet::run();
|
|
|
|
if (k != K_ESC)
|
|
|
|
{
|
|
|
|
FOR_EACH_ARRAY_ITEM(_section, i, o)
|
|
|
|
{
|
|
|
|
TReport_field& rf = *(TReport_field*)o;
|
|
|
|
rf.select(checked(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
|
|
|
|
TReport_sheet::TReport_sheet(TReport_section& sec)
|
2004-04-01 15:42:45 +00:00
|
|
|
: TSheet(-1, -1, -2, -4, "Campi", "@1|Tipo@10|ID@4R|Riga@R|Col.@R|Larg.@R|Alt.@R|Testo@50", 0xE),
|
2004-03-18 14:35:38 +00:00
|
|
|
_section(sec)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-03-23 16:39:40 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
2004-03-25 16:36:29 +00:00
|
|
|
// TSection_properties_mask
|
2004-03-23 16:39:40 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
class TSection_properties_mask : public TReport_base_mask
|
2004-03-23 16:39:40 +00:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
2004-04-23 15:53:02 +00:00
|
|
|
void set_num(short id, long num);
|
2004-03-23 16:39:40 +00:00
|
|
|
short get_num(short id) const;
|
|
|
|
|
|
|
|
void vedo_non_vedo();
|
2004-04-28 10:01:32 +00:00
|
|
|
void set_section(const TReport_section& rs);
|
2004-03-23 16:39:40 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
void get_section(TReport_section& rs) const;
|
2004-04-28 10:01:32 +00:00
|
|
|
TSection_properties_mask(TReport_section& rs);
|
2004-03-23 16:39:40 +00:00
|
|
|
};
|
|
|
|
|
2004-04-23 15:53:02 +00:00
|
|
|
void TSection_properties_mask::set_num(short id, long num)
|
2004-03-23 16:39:40 +00:00
|
|
|
{
|
|
|
|
set(id, num2str(num));
|
|
|
|
}
|
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
short TSection_properties_mask::get_num(short id) const
|
2004-03-23 16:39:40 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
return str2num(get(id));
|
2004-03-23 16:39:40 +00:00
|
|
|
}
|
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
void TSection_properties_mask::vedo_non_vedo()
|
2004-03-23 16:39:40 +00:00
|
|
|
{
|
|
|
|
const char type = get(F_TYPE)[0];
|
|
|
|
const int level = get_int(F_LEVEL);
|
2004-04-23 15:53:02 +00:00
|
|
|
show(F_X, level == 0 && type != 'H');
|
|
|
|
show(F_Y, level == 0 && type != 'H');
|
2004-04-01 15:42:45 +00:00
|
|
|
show(F_GROUP_BY, type == 'H' && level > 1);
|
2004-04-27 16:05:40 +00:00
|
|
|
show(F_KEEP_WITH_NEXT, level > 1 && type == 'H');
|
2004-03-23 16:39:40 +00:00
|
|
|
show(F_HIDE_IF_NEEDED, level == 0 && type != 'B');
|
|
|
|
enable(DLG_DELREC, level > 1);
|
|
|
|
}
|
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
bool TSection_properties_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
2004-03-23 16:39:40 +00:00
|
|
|
{
|
|
|
|
switch(o.dlg())
|
|
|
|
{
|
|
|
|
case F_TYPE:
|
|
|
|
case F_LEVEL:
|
|
|
|
if (e == fe_modify)
|
|
|
|
vedo_non_vedo();
|
|
|
|
break;
|
|
|
|
case F_DX:
|
|
|
|
case F_DY:
|
|
|
|
if (e == fe_modify)
|
|
|
|
{
|
|
|
|
const int num = get_num(o.dlg());
|
|
|
|
set_num(o.dlg(), num); // Reformat
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-04-28 10:01:32 +00:00
|
|
|
return TReport_base_mask::on_field_event(o, e, jolly);
|
2004-03-23 16:39:40 +00:00
|
|
|
}
|
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
void TSection_properties_mask::set_section(const TReport_section& rs)
|
2004-03-23 16:39:40 +00:00
|
|
|
{
|
|
|
|
char s[2] = { rs.type(), '\0' };
|
|
|
|
set(F_TYPE, s);
|
|
|
|
set(F_LEVEL, rs.level());
|
|
|
|
|
2004-04-23 15:53:02 +00:00
|
|
|
if (rs.level() == 0)
|
|
|
|
{
|
|
|
|
set_num(F_X, rs.pos().x);
|
|
|
|
set_num(F_Y, rs.pos().y);
|
|
|
|
}
|
2004-03-23 16:39:40 +00:00
|
|
|
set_num(F_DX, rs.width());
|
|
|
|
set_num(F_DY, rs.height());
|
|
|
|
|
|
|
|
set(F_GROUP_BY, rs.grouped_by());
|
|
|
|
set(F_HIDE_IF_NEEDED, rs.hidden_if_needed() ? "X" : "");
|
2004-04-01 15:42:45 +00:00
|
|
|
set(F_HIDDEN, rs.hidden() ? "X" : "");
|
2004-04-27 16:05:40 +00:00
|
|
|
set(F_PAGE_BREAK, rs.page_break());
|
|
|
|
set(F_KEEP_WITH_NEXT, rs.keep_with_next());
|
|
|
|
|
2004-04-01 15:42:45 +00:00
|
|
|
set(F_DISABLED, rs.deactivated() ? "X" : "");
|
2004-03-23 16:39:40 +00:00
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
set_font_info(rs.font());
|
2004-04-01 15:42:45 +00:00
|
|
|
set(F_PRESCRIPT, rs.prescript());
|
|
|
|
set(F_POSTSCRIPT, rs.postscript());
|
|
|
|
|
2004-03-23 16:39:40 +00:00
|
|
|
vedo_non_vedo();
|
|
|
|
}
|
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
void TSection_properties_mask::get_section(TReport_section& rs) const
|
2004-03-23 16:39:40 +00:00
|
|
|
{
|
2004-04-23 15:53:02 +00:00
|
|
|
if (rs.level() == 0)
|
|
|
|
{
|
|
|
|
const TPoint pos(get_num(F_X), get_num(F_Y));
|
|
|
|
rs.set_pos(pos);
|
|
|
|
}
|
2004-03-23 16:39:40 +00:00
|
|
|
rs.set_width(get_num(F_DX));
|
|
|
|
rs.set_height(get_num(F_DY));
|
2004-04-01 15:42:45 +00:00
|
|
|
rs.show(!get_bool(F_HIDDEN));
|
|
|
|
rs.activate(!get_bool(F_DISABLED));
|
|
|
|
|
2004-03-23 16:39:40 +00:00
|
|
|
rs.group_by(get(F_GROUP_BY));
|
|
|
|
rs.hide_if_needed(get_bool(F_HIDE_IF_NEEDED));
|
2004-04-27 16:05:40 +00:00
|
|
|
rs.force_page_break(get_bool(F_PAGE_BREAK));
|
|
|
|
rs.keep_with_next(get_bool(F_KEEP_WITH_NEXT));
|
2004-03-23 16:39:40 +00:00
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
TReport_font f;
|
|
|
|
if (get_font_info(f))
|
|
|
|
rs.set_font(f);
|
2004-04-01 15:42:45 +00:00
|
|
|
|
|
|
|
rs.set_prescript(get(F_PRESCRIPT));
|
|
|
|
rs.set_postscript(get(F_POSTSCRIPT));
|
2004-03-25 16:36:29 +00:00
|
|
|
}
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
TSection_properties_mask::TSection_properties_mask(TReport_section& rs)
|
|
|
|
: TReport_base_mask("ba8300c", rs.report())
|
|
|
|
{
|
|
|
|
set_section(rs);
|
|
|
|
}
|
2004-03-25 16:36:29 +00:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TReport_properties_mask
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2004-04-28 10:01:32 +00:00
|
|
|
class TReport_properties_mask : public TReport_base_mask
|
2004-03-25 16:36:29 +00:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
2004-04-28 10:01:32 +00:00
|
|
|
void set_report(const TReport& r);
|
2004-03-25 16:36:29 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
void get_report(TReport& r) const;
|
2004-04-28 10:01:32 +00:00
|
|
|
TReport_properties_mask(TReport& rep) : TReport_base_mask("ba8300d", rep) { set_report(rep); }
|
2004-03-25 16:36:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool TReport_properties_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
{
|
2004-04-28 10:01:32 +00:00
|
|
|
return TReport_base_mask::on_field_event(o, e, jolly);
|
2004-03-25 16:36:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TReport_properties_mask::set_report(const TReport& r)
|
|
|
|
{
|
|
|
|
set(F_DY, r.lpi());
|
|
|
|
set_font_info(r.font());
|
2004-04-08 15:04:14 +00:00
|
|
|
set(F_PRESCRIPT, r.prescript());
|
|
|
|
set(F_POSTSCRIPT, r.postscript());
|
2004-03-25 16:36:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TReport_properties_mask::get_report(TReport& r) const
|
|
|
|
{
|
|
|
|
r.set_lpi(get_int(F_DY));
|
|
|
|
|
|
|
|
TReport_font f;
|
|
|
|
if (get_font_info(f))
|
|
|
|
r.set_font(f);
|
2004-04-08 15:04:14 +00:00
|
|
|
r.set_prescript(get(F_PRESCRIPT));
|
|
|
|
r.set_postscript(get(F_POSTSCRIPT));
|
2004-03-23 16:39:40 +00:00
|
|
|
}
|
|
|
|
|
2004-03-11 16:36:30 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
2004-03-15 15:41:18 +00:00
|
|
|
// TReport_mask
|
2004-03-11 16:36:30 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
2004-03-15 15:41:18 +00:00
|
|
|
class TReport_mask : public TAutomask
|
2004-03-11 16:36:30 +00:00
|
|
|
{
|
2004-03-15 15:41:18 +00:00
|
|
|
TReport _report;
|
|
|
|
TReport_tree _tree;
|
2004-03-23 16:39:40 +00:00
|
|
|
TFilename _curr_report;
|
|
|
|
bool _is_dirty;
|
2004-03-11 16:36:30 +00:00
|
|
|
|
2004-03-15 15:41:18 +00:00
|
|
|
protected:
|
|
|
|
virtual TMask_field* parse_field(TScanner& scanner);
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
2004-03-11 16:36:30 +00:00
|
|
|
|
2004-03-15 15:41:18 +00:00
|
|
|
protected:
|
|
|
|
bool select_query();
|
|
|
|
bool select_report();
|
2004-03-18 14:35:38 +00:00
|
|
|
void update_report() const;
|
|
|
|
|
|
|
|
TReport_section& curr_section();
|
|
|
|
void add_field();
|
|
|
|
void edit_field(TReport_field& rf);
|
2004-03-23 16:39:40 +00:00
|
|
|
void fields_properties();
|
2004-04-01 15:42:45 +00:00
|
|
|
void add_section();
|
2004-03-23 16:39:40 +00:00
|
|
|
void section_properties();
|
2004-03-25 16:36:29 +00:00
|
|
|
void report_properties();
|
2004-03-11 16:36:30 +00:00
|
|
|
|
2004-03-23 16:39:40 +00:00
|
|
|
bool get_rep_path(TFilename& path) const;
|
|
|
|
void set_num_attr(TXmlItem& item, const char* attr, short num, short def = 0) const;
|
|
|
|
void set_col_attr(TXmlItem& item, const char* attr, COLOR col, COLOR def) const;
|
|
|
|
|
2004-03-15 15:41:18 +00:00
|
|
|
public:
|
2004-03-25 16:36:29 +00:00
|
|
|
void on_print();
|
2004-03-23 16:39:40 +00:00
|
|
|
bool save_report();
|
|
|
|
bool save_if_needed();
|
|
|
|
void global_reset();
|
|
|
|
bool delete_report();
|
|
|
|
bool load_report();
|
|
|
|
|
2004-03-15 15:41:18 +00:00
|
|
|
TReport_tree& sections() { return _tree; }
|
|
|
|
TReport_mask();
|
2004-03-11 16:36:30 +00:00
|
|
|
};
|
|
|
|
|
2004-03-09 15:20:36 +00:00
|
|
|
TMask_field* TReport_mask::parse_field(TScanner& scanner)
|
|
|
|
{
|
|
|
|
if (scanner.token().starts_with("RE"))
|
|
|
|
return new TReport_drawer(this);
|
|
|
|
return TAutomask::parse_field(scanner);
|
|
|
|
}
|
2004-03-08 16:16:28 +00:00
|
|
|
|
2004-03-09 15:20:36 +00:00
|
|
|
bool TReport_mask::select_report()
|
|
|
|
{
|
|
|
|
TFilename path;
|
2004-04-08 15:04:14 +00:00
|
|
|
const bool ok = select_custom_file(path, "rep");
|
2004-03-09 15:20:36 +00:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
path = path.name(); path.ext("");
|
|
|
|
set(F_CODICE, path);
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
2004-03-08 16:16:28 +00:00
|
|
|
|
2004-03-09 15:20:36 +00:00
|
|
|
bool TReport_mask::select_query()
|
|
|
|
{
|
|
|
|
TFilename path;
|
2004-04-08 15:04:14 +00:00
|
|
|
bool ok = select_custom_file(path, "qry");
|
2004-03-09 15:20:36 +00:00
|
|
|
if (ok)
|
2004-03-08 16:16:28 +00:00
|
|
|
{
|
|
|
|
TXmlItem item; item.Load(path);
|
|
|
|
const TXmlItem* sql = item.FindFirst("sql");
|
2004-03-09 15:20:36 +00:00
|
|
|
ok = sql != NULL;
|
|
|
|
if (ok)
|
2004-03-08 16:16:28 +00:00
|
|
|
{
|
|
|
|
TString str; sql->GetEnclosedText(str);
|
2004-03-09 15:20:36 +00:00
|
|
|
set(F_SQL, str, true);
|
2004-03-08 16:16:28 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-09 15:20:36 +00:00
|
|
|
return ok;
|
2004-03-08 16:16:28 +00:00
|
|
|
}
|
|
|
|
|
2004-03-23 16:39:40 +00:00
|
|
|
bool TReport_mask::get_rep_path(TFilename& path) const
|
|
|
|
{
|
|
|
|
const TString& name = get(F_CODICE);
|
|
|
|
const bool ok = name.not_empty();
|
|
|
|
if (ok)
|
|
|
|
{
|
2004-05-04 08:25:23 +00:00
|
|
|
path = name;
|
|
|
|
if (!path.is_absolute_path())
|
|
|
|
{
|
|
|
|
path = firm2dir(-1);
|
|
|
|
path.add("custom");
|
|
|
|
if (!path.exist())
|
|
|
|
xvt_fsys_mkdir(path);
|
|
|
|
path.add(name);
|
|
|
|
}
|
2004-03-23 16:39:40 +00:00
|
|
|
path.ext("rep");
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TReport_mask::save_report()
|
|
|
|
{
|
|
|
|
bool ok = _curr_report.not_empty();
|
|
|
|
if (!ok)
|
|
|
|
ok = get_rep_path(_curr_report);
|
|
|
|
if (!ok)
|
|
|
|
return field(F_CODICE).on_key(K_ENTER); // Segnala errore
|
2004-03-25 16:36:29 +00:00
|
|
|
_report.set_description(get(F_DESCR));
|
|
|
|
_report.set_recordset(get(F_SQL));
|
|
|
|
ok = _report.save(_curr_report);
|
2004-03-23 16:39:40 +00:00
|
|
|
if (ok)
|
2004-03-25 16:36:29 +00:00
|
|
|
_is_dirty = false;
|
2004-03-23 16:39:40 +00:00
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TReport_mask::save_if_needed()
|
|
|
|
{
|
|
|
|
if (!_is_dirty)
|
|
|
|
return true;
|
|
|
|
if (!yesno_box(TR("Si desidera registrare il report?")))
|
|
|
|
return false;
|
|
|
|
return save_report();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TReport_mask::global_reset()
|
|
|
|
{
|
|
|
|
_report.destroy();
|
|
|
|
reset();
|
|
|
|
update_report();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TReport_mask::load_report()
|
|
|
|
{
|
|
|
|
TFilename path; get_rep_path(path);
|
|
|
|
bool ok = path.exist();
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
_curr_report = path;
|
|
|
|
global_reset();
|
|
|
|
ok = _report.load(path);
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
path = path.name(); path.ext("");
|
|
|
|
set(F_CODICE, path);
|
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
const TRecordset* rs = _report.recordset();
|
|
|
|
if (rs != NULL)
|
|
|
|
set(F_SQL, rs->query_text(), true);
|
2004-03-23 16:39:40 +00:00
|
|
|
set(F_DESCR, _report.description());
|
|
|
|
field(F_SQL).set_dirty(false);
|
|
|
|
_is_dirty = false;
|
|
|
|
|
|
|
|
TTree_field& sections = tfield(F_SECTIONS);
|
|
|
|
_tree.goto_node('B', 1);
|
|
|
|
sections.select_current();
|
|
|
|
update_report();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TReport_mask::delete_report()
|
|
|
|
{
|
|
|
|
TFilename path; get_rep_path(path);
|
|
|
|
const bool ok = yesno_box(FR("Si desidera eliminare il file %s"), (const char*)path);
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
::remove(path);
|
|
|
|
global_reset();
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2004-03-11 16:36:30 +00:00
|
|
|
void TReport_mask::on_print()
|
2004-03-08 16:16:28 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
TReport_printer rp(_report);
|
2004-04-08 15:04:14 +00:00
|
|
|
rp.print(printer().printtype() == screenvis);
|
2004-03-08 16:16:28 +00:00
|
|
|
}
|
|
|
|
|
2004-03-18 14:35:38 +00:00
|
|
|
TReport_section& TReport_mask::curr_section()
|
|
|
|
{
|
|
|
|
TTree_field& sections = tfield(F_SECTIONS);
|
|
|
|
sections.goto_selected();
|
|
|
|
return _tree.curr_section();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TReport_mask::update_report() const
|
|
|
|
{
|
2004-03-23 16:39:40 +00:00
|
|
|
TTree_field& tf = tfield(F_SECTIONS);
|
|
|
|
tf.win().force_update();
|
|
|
|
|
2004-03-18 14:35:38 +00:00
|
|
|
TReport_drawer& rd = (TReport_drawer&)field(F_REPORT);
|
|
|
|
rd.win().force_update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TReport_mask::add_field()
|
|
|
|
{
|
|
|
|
TReport_section& rs = curr_section();
|
2004-04-07 16:11:18 +00:00
|
|
|
TReport_field* rf = new TReport_field(&rs);
|
2004-05-04 08:25:23 +00:00
|
|
|
rf->set_pos(0, rs.compute_size().y);
|
2004-04-28 10:01:32 +00:00
|
|
|
TReport_field_mask m(*rf);
|
2004-03-18 14:35:38 +00:00
|
|
|
m.disable(DLG_DELREC);
|
|
|
|
if (m.run() == K_ENTER)
|
|
|
|
{
|
|
|
|
m.get_field(*rf);
|
|
|
|
rs.add(rf);
|
|
|
|
update_report();
|
|
|
|
}
|
2004-04-07 16:11:18 +00:00
|
|
|
else
|
|
|
|
delete rf;
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TReport_mask::edit_field(TReport_field& rf)
|
|
|
|
{
|
2004-04-14 14:21:12 +00:00
|
|
|
TReport_section& rs = rf.section();
|
2004-04-28 10:01:32 +00:00
|
|
|
TReport_field_mask m(rf);
|
2004-03-18 14:35:38 +00:00
|
|
|
const KEY key = m.run();
|
|
|
|
switch(key)
|
|
|
|
{
|
|
|
|
case K_ENTER:
|
|
|
|
m.get_field(rf);
|
|
|
|
break;
|
|
|
|
case K_DEL:
|
|
|
|
{
|
|
|
|
for (int i = rs.last(); i >= 0; i--) if (rs.objptr(i) == &rf)
|
|
|
|
{
|
|
|
|
rs.destroy(i, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
2004-04-06 16:06:26 +00:00
|
|
|
if (key != K_ESC)
|
|
|
|
{
|
2004-04-07 16:11:18 +00:00
|
|
|
_is_dirty = true;
|
2004-04-14 14:21:12 +00:00
|
|
|
rs.sort();
|
2004-04-06 16:06:26 +00:00
|
|
|
update_report();
|
|
|
|
}
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
|
2004-03-23 16:39:40 +00:00
|
|
|
void TReport_mask::fields_properties()
|
2004-03-18 14:35:38 +00:00
|
|
|
{
|
|
|
|
TReport_section& rs = curr_section();
|
|
|
|
TReport_sheet sheet(rs);
|
|
|
|
|
|
|
|
int first, last;
|
|
|
|
int selected = sheet.selection(first, last);
|
|
|
|
if (selected == 1)
|
|
|
|
{
|
2004-03-23 16:39:40 +00:00
|
|
|
TReport_field& rf = rs.field(first);
|
2004-03-18 14:35:38 +00:00
|
|
|
edit_field(rf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
KEY key = K_ENTER;
|
|
|
|
while (key != K_ESC)
|
|
|
|
{
|
|
|
|
key = sheet.run();
|
|
|
|
selected = sheet.selection(first, last);
|
|
|
|
if (selected == 0 && (key == K_ENTER || key == K_DEL))
|
|
|
|
{
|
|
|
|
first = last = sheet.selected();
|
|
|
|
selected = 1;
|
|
|
|
sheet.check(first);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (key)
|
|
|
|
{
|
|
|
|
case K_INS:
|
|
|
|
add_field();
|
|
|
|
break;
|
|
|
|
case K_ENTER:
|
|
|
|
{
|
|
|
|
for (int i = first; i <= last; i++) if (sheet.checked(i))
|
|
|
|
{
|
2004-03-23 16:39:40 +00:00
|
|
|
TReport_field& rf = rs.field(i);
|
2004-03-18 14:35:38 +00:00
|
|
|
edit_field(rf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case K_DEL:
|
|
|
|
if (selected > 0 && yesno_box(FR("Comfermare la cancellazione di %d elementi"), selected))
|
|
|
|
{
|
|
|
|
for (int i = last; i >= first; i--) if (sheet.checked(i))
|
|
|
|
rs.destroy(i, true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
update_report();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-01 15:42:45 +00:00
|
|
|
void TReport_mask::add_section()
|
|
|
|
{
|
|
|
|
TMask m(TR("Nuova sezione"), 1, 32, 5);
|
|
|
|
m.add_radio(101, 0, "", 1, 0, 22, "H|B", TR("Raggruppamento|Corpo alternativo"), "");
|
|
|
|
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
|
|
|
|
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
|
|
|
|
if (m.run() == K_ENTER)
|
|
|
|
{
|
|
|
|
const char type = m.get(101)[0];
|
|
|
|
int level = 0;
|
|
|
|
if (type == 'H')
|
|
|
|
{
|
|
|
|
const int hl = _report.find_max_level('H');
|
|
|
|
const int fl = _report.find_max_level('F');
|
|
|
|
level = max(hl, fl) + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
level = _report.find_max_level('B')+1;
|
|
|
|
|
|
|
|
if (level > 1 && level <= 9)
|
|
|
|
{
|
|
|
|
_tree.goto_node(type, level);
|
|
|
|
tfield(F_SECTIONS).select_current();
|
|
|
|
section_properties();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
error_box(TR("Livello non ammesso: %d"), level);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-23 16:39:40 +00:00
|
|
|
void TReport_mask::section_properties()
|
|
|
|
{
|
|
|
|
TReport_section& rs = curr_section();
|
2004-04-28 10:01:32 +00:00
|
|
|
TSection_properties_mask m(rs);
|
2004-03-23 16:39:40 +00:00
|
|
|
switch (m.run())
|
|
|
|
{
|
|
|
|
case K_ENTER:
|
|
|
|
m.get_section(rs);
|
|
|
|
_is_dirty = true;
|
|
|
|
break;
|
|
|
|
case K_DEL:
|
2004-04-23 15:53:02 +00:00
|
|
|
if (yesno_box(TR("Confermare l'eliminazione della sezione")))
|
2004-04-01 15:42:45 +00:00
|
|
|
{
|
|
|
|
const char t = rs.type();
|
|
|
|
const int l = rs.level();
|
|
|
|
rs.report().kill_section(t, l);
|
|
|
|
_tree.goto_node(t, l-1);
|
|
|
|
tfield(F_SECTIONS).select_current();
|
|
|
|
_is_dirty = true;
|
|
|
|
}
|
2004-03-23 16:39:40 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (_is_dirty)
|
|
|
|
update_report();
|
|
|
|
}
|
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
void TReport_mask::report_properties()
|
|
|
|
{
|
2004-04-28 10:01:32 +00:00
|
|
|
TReport_properties_mask m(_report);
|
2004-03-25 16:36:29 +00:00
|
|
|
if (m.run() == K_ENTER)
|
|
|
|
{
|
|
|
|
m.get_report(_report);
|
|
|
|
_is_dirty = true;
|
|
|
|
update_report();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-08 16:16:28 +00:00
|
|
|
bool TReport_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
{
|
|
|
|
switch (o.dlg())
|
|
|
|
{
|
|
|
|
case F_CODICE:
|
2004-04-06 16:06:26 +00:00
|
|
|
if (e == fe_init)
|
|
|
|
{
|
|
|
|
if (main_app().argc() >= 3)
|
|
|
|
{
|
|
|
|
set(F_CODICE, main_app().argv(2));
|
|
|
|
load_report();
|
|
|
|
}
|
|
|
|
}
|
2004-03-08 16:16:28 +00:00
|
|
|
if (e == fe_button)
|
2004-03-23 16:39:40 +00:00
|
|
|
{
|
|
|
|
if (select_report())
|
|
|
|
e = fe_modify;
|
|
|
|
}
|
|
|
|
if (e == fe_modify)
|
|
|
|
{
|
|
|
|
save_if_needed();
|
|
|
|
load_report();
|
|
|
|
}
|
2004-03-08 16:16:28 +00:00
|
|
|
break;
|
2004-03-11 16:36:30 +00:00
|
|
|
case F_SECTIONS:
|
2004-03-18 14:35:38 +00:00
|
|
|
if (e == fe_init || e == fe_modify)
|
|
|
|
{
|
2004-03-23 16:39:40 +00:00
|
|
|
update_report();
|
2004-03-18 14:35:38 +00:00
|
|
|
const TReport_section& rs = _tree.curr_section();
|
|
|
|
const bool ok = strchr("HBF", rs.type()) != NULL;
|
|
|
|
enable(-1, ok);
|
|
|
|
}
|
|
|
|
break;
|
2004-04-01 15:42:45 +00:00
|
|
|
case F_FLD_ADD:
|
2004-03-18 14:35:38 +00:00
|
|
|
if (e == fe_button && o.active())
|
|
|
|
add_field();
|
|
|
|
break;
|
2004-03-23 16:39:40 +00:00
|
|
|
case F_FLD_PROPERTIES:
|
2004-03-18 14:35:38 +00:00
|
|
|
if (e == fe_button && o.active())
|
2004-03-23 16:39:40 +00:00
|
|
|
fields_properties();
|
|
|
|
break;
|
2004-04-01 15:42:45 +00:00
|
|
|
case F_SEC_ADD:
|
|
|
|
if (e == fe_button && o.active())
|
|
|
|
add_section();
|
|
|
|
break;
|
2004-03-23 16:39:40 +00:00
|
|
|
case F_SEC_PROPERTIES:
|
|
|
|
if (e == fe_button && o.active())
|
|
|
|
section_properties();
|
2004-03-11 16:36:30 +00:00
|
|
|
break;
|
2004-03-25 16:36:29 +00:00
|
|
|
case F_REP_PROPERTIES:
|
|
|
|
if (e == fe_button)
|
|
|
|
report_properties();
|
|
|
|
break;
|
2004-03-09 15:20:36 +00:00
|
|
|
case F_SQL:
|
|
|
|
if (e == fe_init || e == fe_modify)
|
|
|
|
enable(F_SHOW_QRY, !o.empty());
|
|
|
|
break;
|
2004-03-08 16:16:28 +00:00
|
|
|
case F_NEW_QRY:
|
|
|
|
if (e == fe_button)
|
|
|
|
{
|
|
|
|
TExternal_app q("ba8 -1");
|
|
|
|
q.run();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case F_IMPORT_QRY:
|
|
|
|
if (e == fe_button)
|
|
|
|
select_query();
|
|
|
|
break;
|
2004-03-09 15:20:36 +00:00
|
|
|
case F_SHOW_QRY:
|
|
|
|
if (e == fe_button)
|
|
|
|
{
|
2004-05-04 08:25:23 +00:00
|
|
|
TRecordset* rex = NULL;
|
|
|
|
|
|
|
|
const TString& sql = get(F_SQL);
|
|
|
|
if (sql.starts_with("SELECT "))
|
|
|
|
rex = new TSQL_recordset(sql);
|
|
|
|
else
|
|
|
|
rex = new TISAM_recordset(sql);
|
|
|
|
|
|
|
|
if (rex->columns() > 0)
|
2004-03-09 15:20:36 +00:00
|
|
|
{
|
2004-05-04 08:25:23 +00:00
|
|
|
TRecordset_sheet sht(*rex);
|
|
|
|
sht.run();
|
2004-03-09 15:20:36 +00:00
|
|
|
}
|
2004-05-04 08:25:23 +00:00
|
|
|
else
|
|
|
|
warning_box(TR("Nessuna riga risultato"));
|
|
|
|
|
|
|
|
delete rex;
|
2004-03-09 15:20:36 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-03-11 16:36:30 +00:00
|
|
|
case DLG_PRINT:
|
|
|
|
if (e == fe_button)
|
|
|
|
{
|
|
|
|
on_print();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
2004-03-23 16:39:40 +00:00
|
|
|
case DLG_NEWREC:
|
|
|
|
if (e == fe_button)
|
|
|
|
{
|
|
|
|
save_if_needed();
|
|
|
|
global_reset();
|
|
|
|
}
|
2004-03-08 16:16:28 +00:00
|
|
|
break;
|
2004-03-23 16:39:40 +00:00
|
|
|
case DLG_FINDREC:
|
|
|
|
if (e == fe_button)
|
|
|
|
send_key(K_F9, F_CODICE);
|
|
|
|
case DLG_SAVEREC:
|
|
|
|
if (e == fe_button)
|
2004-03-18 14:35:38 +00:00
|
|
|
{
|
2004-03-23 16:39:40 +00:00
|
|
|
get_rep_path(_curr_report);
|
|
|
|
save_report();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DLG_DELREC:
|
|
|
|
if (e == fe_button && jolly == 0) // Elimina della Toolbar
|
|
|
|
{
|
|
|
|
delete_report();
|
|
|
|
return false; // Do not exit!
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
2004-03-23 16:39:40 +00:00
|
|
|
break;
|
|
|
|
case DLG_QUIT:
|
|
|
|
save_if_needed();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
2004-03-23 16:39:40 +00:00
|
|
|
return true;
|
2004-03-18 14:35:38 +00:00
|
|
|
}
|
|
|
|
|
2004-03-23 16:39:40 +00:00
|
|
|
TReport_mask::TReport_mask() : _tree(_report), _is_dirty(false)
|
2004-03-09 15:20:36 +00:00
|
|
|
{
|
|
|
|
read_mask("ba8300a", 0, -1);
|
|
|
|
set_handlers();
|
|
|
|
|
|
|
|
TTree_field& albero = tfield(F_SECTIONS);
|
|
|
|
|
|
|
|
RCT rct_sec; albero.get_rect(rct_sec);
|
|
|
|
RCT rct_rep; field(F_REPORT).get_rect(rct_rep);
|
|
|
|
rct_rep.left = rct_sec.right+ROWY;
|
|
|
|
rct_rep.right -= ROWY;
|
|
|
|
rct_rep.bottom -= ROWY;
|
|
|
|
field(F_REPORT).set_rect(rct_rep);
|
|
|
|
|
2004-03-23 16:39:40 +00:00
|
|
|
_tree.goto_node('B',1);
|
2004-03-11 16:36:30 +00:00
|
|
|
const int ih = _tree.image_height();
|
|
|
|
if (ih > CHARY)
|
|
|
|
albero.set_row_height(ih);
|
|
|
|
albero.set_tree(&_tree);
|
2004-03-09 15:20:36 +00:00
|
|
|
|
|
|
|
_tree.goto_root();
|
2004-03-23 16:39:40 +00:00
|
|
|
_tree.expand_all();
|
2004-03-18 14:35:38 +00:00
|
|
|
|
|
|
|
TReport_drawer& rd = (TReport_drawer&)field(F_REPORT);
|
|
|
|
rd.set_report(&_report);
|
2004-03-09 15:20:36 +00:00
|
|
|
}
|
|
|
|
|
2004-03-08 16:16:28 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TReporter_app
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TReporter_app : public TSkeleton_application
|
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
TReport_mask* _msk;
|
|
|
|
|
2004-03-08 16:16:28 +00:00
|
|
|
protected:
|
2004-05-04 08:25:23 +00:00
|
|
|
virtual bool create();
|
2004-03-08 16:16:28 +00:00
|
|
|
virtual void main_loop();
|
2004-05-04 08:25:23 +00:00
|
|
|
virtual bool destroy();
|
|
|
|
virtual void print();
|
|
|
|
|
|
|
|
public:
|
|
|
|
TReporter_app() : _msk(NULL) { }
|
2004-03-08 16:16:28 +00:00
|
|
|
};
|
|
|
|
|
2004-03-25 16:36:29 +00:00
|
|
|
void TReporter_app::print()
|
|
|
|
{
|
|
|
|
if (_msk != NULL)
|
|
|
|
_msk->on_print();
|
|
|
|
}
|
|
|
|
|
2004-05-04 08:25:23 +00:00
|
|
|
bool TReporter_app::create()
|
2004-03-08 16:16:28 +00:00
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
_msk = new TReport_mask;
|
2004-05-04 08:25:23 +00:00
|
|
|
xvt_sys_sleep(500);
|
|
|
|
return TSkeleton_application::create();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TReporter_app::destroy()
|
|
|
|
{
|
|
|
|
if (_msk != NULL)
|
|
|
|
{
|
|
|
|
delete _msk;
|
|
|
|
_msk = NULL;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TReporter_app::main_loop()
|
|
|
|
{
|
2004-03-25 16:36:29 +00:00
|
|
|
_msk->run();
|
2004-03-08 16:16:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ba8300(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
TReporter_app app;
|
|
|
|
app.run(argc, argv, TR("Report Generator"));
|
|
|
|
return 0;
|
|
|
|
}
|