Patch level : 2.2
Files correlati : Ricompilazione Demo : [ ] Commento : Allineato uso ricerche dei reports alle librerie git-svn-id: svn://10.65.10.50/trunk@13374 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b3c9ec4baa
commit
6006b1a1d9
476
ba/ba8300.cpp
476
ba/ba8300.cpp
@ -9,6 +9,7 @@
|
|||||||
#include <prefix.h>
|
#include <prefix.h>
|
||||||
#include <printer.h>
|
#include <printer.h>
|
||||||
#include <reprint.h>
|
#include <reprint.h>
|
||||||
|
#include <utility.h>
|
||||||
|
|
||||||
#include "ba8300.h"
|
#include "ba8300.h"
|
||||||
#include "ba8301.h"
|
#include "ba8301.h"
|
||||||
@ -18,450 +19,6 @@
|
|||||||
// Utility
|
// Utility
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static TString16 _str;
|
|
||||||
|
|
||||||
const TString& num2str(int num)
|
|
||||||
{
|
|
||||||
const real n(num / 100.0);
|
|
||||||
_str = n.stringa(0, 2);
|
|
||||||
const int comma = _str.find(',');
|
|
||||||
if (comma > 0)
|
|
||||||
{
|
|
||||||
if (_str[comma+2] == '0')
|
|
||||||
{
|
|
||||||
if (_str[comma+1] == '0')
|
|
||||||
_str.cut(comma);
|
|
||||||
else
|
|
||||||
_str.cut(comma+2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _str;
|
|
||||||
}
|
|
||||||
|
|
||||||
short str2num(const TString& str)
|
|
||||||
{
|
|
||||||
_str = str;
|
|
||||||
_str.replace(',', '.');
|
|
||||||
real n(_str);
|
|
||||||
n *= CENTO;
|
|
||||||
return (short)n.integer();
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
// TReport_base_mask
|
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class TReport_base_mask : public TAutomask
|
|
||||||
{
|
|
||||||
TReport_font _font;
|
|
||||||
bool _font_changed;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
TReport& _report;
|
|
||||||
char _halign, _valign;
|
|
||||||
COLOR _fgcolor, _bgcolor;
|
|
||||||
|
|
||||||
virtual void update();
|
|
||||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
||||||
|
|
||||||
public:
|
|
||||||
void set_font_info(const TReport_font& font);
|
|
||||||
bool get_font_info(TReport_font& font) const;
|
|
||||||
|
|
||||||
TReport_base_mask(const char* name, TReport& rep);
|
|
||||||
};
|
|
||||||
|
|
||||||
void TReport_base_mask::update()
|
|
||||||
{
|
|
||||||
const TMask_field& fld = field(F_FONT_SELECT);
|
|
||||||
if (fld.active() && win() == fld.parent())
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
xi_draw_3d_rect((XinWindow)win(), (XinRect*)&rct, TRUE, 2, MASK_LIGHT_COLOR,
|
|
||||||
_bgcolor, MASK_DARK_COLOR);
|
|
||||||
|
|
||||||
rct.left += 2; rct.right -= 2;
|
|
||||||
rct.top += 2; rct.bottom -= 2;
|
|
||||||
xvt_dwin_set_clip(win(), &rct);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TReport_base_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
||||||
{
|
|
||||||
switch (o.dlg())
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
case F_PATTERN:
|
|
||||||
if (e == fe_modify)
|
|
||||||
force_update();
|
|
||||||
break;
|
|
||||||
case F_FONT_SELECT:
|
|
||||||
if (e == fe_button)
|
|
||||||
{
|
|
||||||
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))
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
_font_changed = true;
|
|
||||||
force_update();
|
|
||||||
}
|
|
||||||
xvt_font_destroy(font);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case F_HALIGN:
|
|
||||||
case F_VALIGN:
|
|
||||||
if (e == fe_init || e == fe_modify)
|
|
||||||
{
|
|
||||||
_halign = get(F_HALIGN)[0];
|
|
||||||
_valign = get(F_VALIGN)[0];
|
|
||||||
force_update();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case F_PRESCRIPT:
|
|
||||||
case F_POSTSCRIPT:
|
|
||||||
if (e == fe_close)
|
|
||||||
{
|
|
||||||
TReport_script s;
|
|
||||||
s.set(o.get());
|
|
||||||
_report.set_interactive(true);
|
|
||||||
s.compile(_report);
|
|
||||||
_report.set_interactive(false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TReport_base_mask::set_font_info(const TReport_font& font)
|
|
||||||
{
|
|
||||||
_font = font;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TReport_base_mask::get_font_info(TReport_font& font) const
|
|
||||||
{
|
|
||||||
const bool ok = _font_changed;
|
|
||||||
if (ok)
|
|
||||||
font = _font;
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
TReport_base_mask::TReport_base_mask(const char* name, TReport& rep)
|
|
||||||
: TAutomask(name), _report(rep),
|
|
||||||
_font_changed(false),
|
|
||||||
_halign('C'), _valign('C'),
|
|
||||||
_fgcolor(COLOR_BLACK), _bgcolor(COLOR_WHITE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
// TReport_field_mask
|
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class TReport_field_mask : public TReport_base_mask
|
|
||||||
{
|
|
||||||
TReport_field& _rf;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void vedo_non_vedo();
|
|
||||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
||||||
virtual void update();
|
|
||||||
|
|
||||||
public:
|
|
||||||
void set_num(short id, long n);
|
|
||||||
long get_num(short id) const;
|
|
||||||
|
|
||||||
void set_field(const TReport_field& rf);
|
|
||||||
void get_field(TReport_field& rf) const;
|
|
||||||
|
|
||||||
TReport_field_mask(TReport_field& rf);
|
|
||||||
};
|
|
||||||
|
|
||||||
void TReport_field_mask::set_num(short id, long num)
|
|
||||||
{
|
|
||||||
set(id, num2str(num));
|
|
||||||
}
|
|
||||||
|
|
||||||
long TReport_field_mask::get_num(short id) const
|
|
||||||
{
|
|
||||||
return str2num(get(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
void TReport_field_mask::update()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
TMask_field& fld = field(i == 0 ? F_FGCOLOR : F_BGCOLOR);
|
|
||||||
if (fld.active() && fld.parent() == win())
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TReport_base_mask::update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TReport_field_mask::vedo_non_vedo()
|
|
||||||
{
|
|
||||||
const char type = get(F_TYPE)[0];
|
|
||||||
const bool is_currency = type == 'P' || type == 'V';
|
|
||||||
const bool is_numeric = is_currency || type == 'N';
|
|
||||||
const bool is_text = is_numeric || strchr("ADST", type) != NULL;
|
|
||||||
|
|
||||||
show(F_HIDE_ZEROES, is_numeric || type == 'D'),
|
|
||||||
show(F_HALIGN, is_text);
|
|
||||||
if (is_numeric)
|
|
||||||
{
|
|
||||||
disable(F_HALIGN);
|
|
||||||
set(F_HALIGN, "R"); // Allineo a destra i numeri
|
|
||||||
}
|
|
||||||
else
|
|
||||||
enable(F_HALIGN);
|
|
||||||
|
|
||||||
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_PATTERN, type != 'L' && type != 'I');
|
|
||||||
show(F_RADIUS, type != 'E' && type != 'L' && type != 'I');
|
|
||||||
show(F_SHADE_OFFSET,type != 'E' && type != 'L');
|
|
||||||
show(F_FONT_SELECT, is_text);
|
|
||||||
show(F_SOURCE, (is_text || type == 'I') && type != 'T');
|
|
||||||
show(F_SOURCE2, is_text && type != 'T');
|
|
||||||
show(DLG_FINDREC, is_text && type != 'T');
|
|
||||||
show(F_CODVAL, is_currency); // Codice valuta di riferimento
|
|
||||||
show(F_LINK, strchr("DNS", type) != NULL); // Chi puo' essere un link?
|
|
||||||
show(F_PRESCRIPT, is_text);
|
|
||||||
show(F_POSTSCRIPT, is_text);
|
|
||||||
enable_page(3, type == 'A');
|
|
||||||
|
|
||||||
if (is_running())
|
|
||||||
force_update();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TReport_field_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
||||||
{
|
|
||||||
switch(o.dlg())
|
|
||||||
{
|
|
||||||
case F_TYPE:
|
|
||||||
if (e == fe_init || e == fe_modify)
|
|
||||||
{
|
|
||||||
vedo_non_vedo();
|
|
||||||
if (e == fe_modify)
|
|
||||||
{
|
|
||||||
if (strchr("ELR", o.get()[0]) != NULL && get_int(F_BORDER) == 0)
|
|
||||||
set(F_BORDER, 2); // Propongo un bordo visibile per le linee
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case F_X:
|
|
||||||
case F_Y:
|
|
||||||
case F_DX:
|
|
||||||
case F_DY:
|
|
||||||
case F_RADIUS:
|
|
||||||
case F_SHADE_OFFSET:
|
|
||||||
if (e == fe_modify)
|
|
||||||
{
|
|
||||||
const int num = get_num(o.dlg());
|
|
||||||
set_num(o.dlg(), num); // Reformat
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
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;
|
|
||||||
case DLG_FINDREC:
|
|
||||||
if (e == fe_button)
|
|
||||||
{
|
|
||||||
TRecordset* rex = _rf.section().recordset();
|
|
||||||
if (rex == NULL)
|
|
||||||
rex = _report.recordset();
|
|
||||||
if (rex != NULL && rex->columns() > 0)
|
|
||||||
{
|
|
||||||
TArray_sheet sheet(-1, -1, -1, 20, TR("Colonne Query"), HR("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));
|
|
||||||
|
|
||||||
char tipo = row.get_char(1);
|
|
||||||
int width = row.get_int(2);
|
|
||||||
switch (tipo)
|
|
||||||
{
|
|
||||||
case 'D':width = 10; break;
|
|
||||||
case 'L':tipo = 'S'; break;
|
|
||||||
case 'M':tipo = 'S'; width = 50; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
const char str[2] = { tipo, '\0' };
|
|
||||||
set(F_TYPE, str);
|
|
||||||
set(F_DX, width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
warning_box("Query non definita");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return TReport_base_mask::on_field_event(o, e, jolly);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TReport_field_mask::set_field(const TReport_field& rf)
|
|
||||||
{
|
|
||||||
char str[2] = { rf.type(), '\0' };
|
|
||||||
set(F_TYPE, str, true);
|
|
||||||
|
|
||||||
const TRectangle& r = rf.get_rect();
|
|
||||||
set(F_ID, rf.id());
|
|
||||||
set_num(F_X, r.left());
|
|
||||||
set_num(F_Y, r.top());
|
|
||||||
set_num(F_DX, r.width());
|
|
||||||
set_num(F_DY, r.height());
|
|
||||||
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());
|
|
||||||
|
|
||||||
str[0] = rf.horizontal_alignment();
|
|
||||||
set(F_HALIGN, str);
|
|
||||||
str[0] = rf.vertical_alignment();
|
|
||||||
set(F_VALIGN, str);
|
|
||||||
set(F_BORDER, rf.border());
|
|
||||||
set(F_PATTERN, rf.pattern());
|
|
||||||
set_num(F_RADIUS, rf.radius());
|
|
||||||
set_num(F_SHADE_OFFSET, rf.shade_offset());
|
|
||||||
_fgcolor = rf.fore_color();
|
|
||||||
_bgcolor = rf.back_color();
|
|
||||||
set(F_TEXT, rf.picture());
|
|
||||||
set(F_SOURCE, rf.field());
|
|
||||||
set(F_SOURCE2, rf.alternate_field());
|
|
||||||
set_font_info(rf.font());
|
|
||||||
|
|
||||||
set(F_PRESCRIPT, rf.prescript());
|
|
||||||
set(F_POSTSCRIPT, rf.postscript());
|
|
||||||
|
|
||||||
if (rf.type() == 'A')
|
|
||||||
{
|
|
||||||
TSheet_field& list = sfield(F_LIST);
|
|
||||||
rf.get_list(list.rows_array());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TReport_field_mask::get_field(TReport_field& rf) const
|
|
||||||
{
|
|
||||||
rf.set_type(get(F_TYPE)[0]);
|
|
||||||
rf.set_id(get_int(F_ID));
|
|
||||||
rf.set_pos(get_num(F_X), get_num(F_Y));
|
|
||||||
rf.set_size(get_num(F_DX), get_num(F_DY));
|
|
||||||
rf.show(!get_bool(F_HIDDEN));
|
|
||||||
rf.activate(!get_bool(F_DISABLED));
|
|
||||||
rf.hide_zeroes(field(F_HIDE_ZEROES).active() && 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));
|
|
||||||
rf.set_horizontal_alignment(get(F_HALIGN)[0]);
|
|
||||||
rf.set_vertical_alignment(get(F_VALIGN)[0]);
|
|
||||||
rf.set_pattern((PAT_STYLE)get_int(F_PATTERN));
|
|
||||||
rf.set_border(get_int(F_BORDER));
|
|
||||||
rf.set_radius(get_num(F_RADIUS));
|
|
||||||
rf.set_shade_offset(get_num(F_SHADE_OFFSET));
|
|
||||||
rf.set_fore_color(_fgcolor);
|
|
||||||
rf.set_back_color(_bgcolor);
|
|
||||||
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;
|
|
||||||
if (get_font_info(f))
|
|
||||||
rf.set_font(f);
|
|
||||||
|
|
||||||
rf.set_prescript(get(F_PRESCRIPT));
|
|
||||||
rf.set_postscript(get(F_POSTSCRIPT));
|
|
||||||
if (rf.type() == 'A')
|
|
||||||
{
|
|
||||||
TSheet_field& list = sfield(F_LIST);
|
|
||||||
rf.set_list(list.rows_array());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TReport_field_mask::TReport_field_mask(TReport_field& rf)
|
|
||||||
: TReport_base_mask("ba8300b", rf.section().report()), _rf(rf)
|
|
||||||
{
|
|
||||||
set_field(rf);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// TReport_sheet
|
// TReport_sheet
|
||||||
@ -897,6 +454,9 @@ bool TReport_mask::get_rep_path(TFilename& path) const
|
|||||||
if (!path.exist())
|
if (!path.exist())
|
||||||
xvt_fsys_mkdir(path);
|
xvt_fsys_mkdir(path);
|
||||||
path.add(name);
|
path.add(name);
|
||||||
|
path.ext("rep");
|
||||||
|
if (!path.exist() && is_power_station())
|
||||||
|
path = name;
|
||||||
}
|
}
|
||||||
path.ext("rep");
|
path.ext("rep");
|
||||||
}
|
}
|
||||||
@ -912,9 +472,28 @@ bool TReport_mask::save_report()
|
|||||||
return field(F_CODICE).on_key(K_ENTER); // Segnala errore
|
return field(F_CODICE).on_key(K_ENTER); // Segnala errore
|
||||||
_report.set_description(get(F_DESCR));
|
_report.set_description(get(F_DESCR));
|
||||||
_report.set_recordset(get(F_SQL));
|
_report.set_recordset(get(F_SQL));
|
||||||
|
if (is_power_station())
|
||||||
|
{
|
||||||
|
FILE_SPEC fsp; memset(&fsp, 0, sizeof(fsp));
|
||||||
|
xvt_fsys_convert_str_to_dir(_curr_report.path(), &fsp.dir);
|
||||||
|
strcpy(fsp.type, _curr_report.ext());
|
||||||
|
_curr_report.ext("");
|
||||||
|
strcpy(fsp.name, _curr_report.name());
|
||||||
|
strcpy(fsp.creator, "CAMPO");
|
||||||
|
|
||||||
|
ok = xvt_dm_post_file_save(&fsp, TR("Nome report")) == FL_OK;
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
xvt_fsys_convert_dir_to_str(&fsp.dir, _curr_report.get_buffer(), _curr_report.size());
|
||||||
|
_curr_report.add(fsp.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
ok = _report.save(_curr_report);
|
ok = _report.save(_curr_report);
|
||||||
if (ok)
|
if (ok)
|
||||||
_is_dirty = false;
|
_is_dirty = false;
|
||||||
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -979,6 +558,14 @@ bool TReport_mask::delete_report()
|
|||||||
|
|
||||||
void TReport_mask::on_print()
|
void TReport_mask::on_print()
|
||||||
{
|
{
|
||||||
|
const TString& app = _report.command_line();
|
||||||
|
if (app.not_empty() && yesno_box(FR("Si desidera stampare utilizzando '%s'"), (const char*)app))
|
||||||
|
{
|
||||||
|
TExternal_app a(app);
|
||||||
|
a.run();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
TFilename tmp; tmp.tempdir();
|
TFilename tmp; tmp.tempdir();
|
||||||
tmp.add("ba8300.txt");
|
tmp.add("ba8300.txt");
|
||||||
@ -988,6 +575,7 @@ void TReport_mask::on_print()
|
|||||||
#endif
|
#endif
|
||||||
book.add(_report);
|
book.add(_report);
|
||||||
book.print_or_preview();
|
book.print_or_preview();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TReport_section& TReport_mask::curr_section()
|
TReport_section& TReport_mask::curr_section()
|
||||||
|
455
ba/ba8301.cpp
455
ba/ba8301.cpp
@ -4,8 +4,8 @@
|
|||||||
#include <colors.h>
|
#include <colors.h>
|
||||||
#include <diction.h>
|
#include <diction.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <mask.h>
|
|
||||||
#include <reprint.h>
|
#include <reprint.h>
|
||||||
|
#include <defmask.h>
|
||||||
|
|
||||||
#include "ba8300.h"
|
#include "ba8300.h"
|
||||||
#include "ba8301.h"
|
#include "ba8301.h"
|
||||||
@ -386,10 +386,415 @@ int TReport_tree::image_height() const
|
|||||||
return img != NULL ? img->height() : 0;
|
return img != NULL ? img->height() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TReport_base_mask
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TReport_base_mask::update()
|
||||||
|
{
|
||||||
|
const TMask_field& fld = field(F_FONT_SELECT);
|
||||||
|
if (fld.active() && win() == fld.parent())
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
xi_draw_3d_rect((XinWindow)win(), (XinRect*)&rct, TRUE, 2, MASK_LIGHT_COLOR,
|
||||||
|
_bgcolor, MASK_DARK_COLOR);
|
||||||
|
|
||||||
|
rct.left += 2; rct.right -= 2;
|
||||||
|
rct.top += 2; rct.bottom -= 2;
|
||||||
|
xvt_dwin_set_clip(win(), &rct);
|
||||||
|
|
||||||
|
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_line(*this, _font.name(), rct, _halign, _valign);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TReport_base_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||||
|
{
|
||||||
|
switch (o.dlg())
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
case F_PATTERN:
|
||||||
|
if (e == fe_modify)
|
||||||
|
force_update();
|
||||||
|
break;
|
||||||
|
case F_FONT_SELECT:
|
||||||
|
if (e == fe_button)
|
||||||
|
{
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
TString80 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);
|
||||||
|
|
||||||
|
_font_changed = true;
|
||||||
|
force_update();
|
||||||
|
}
|
||||||
|
xvt_font_destroy(font);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case F_HALIGN:
|
||||||
|
case F_VALIGN:
|
||||||
|
if (e == fe_init || e == fe_modify)
|
||||||
|
{
|
||||||
|
_halign = get(F_HALIGN)[0];
|
||||||
|
_valign = get(F_VALIGN)[0];
|
||||||
|
force_update();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case F_PRESCRIPT:
|
||||||
|
case F_POSTSCRIPT:
|
||||||
|
if (e == fe_close)
|
||||||
|
{
|
||||||
|
TReport_script s;
|
||||||
|
s.set(o.get());
|
||||||
|
_report.set_interactive(true);
|
||||||
|
s.compile(_report);
|
||||||
|
_report.set_interactive(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TReport_base_mask::set_font_info(const TReport_font& font)
|
||||||
|
{
|
||||||
|
_font = font;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TReport_base_mask::get_font_info(TReport_font& font) const
|
||||||
|
{
|
||||||
|
const bool ok = _font_changed;
|
||||||
|
if (ok)
|
||||||
|
font = _font;
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
TReport_base_mask::TReport_base_mask(const char* name, TReport& rep)
|
||||||
|
: TAutomask(name), _report(rep),
|
||||||
|
_font_changed(false),
|
||||||
|
_halign('C'), _valign('C'),
|
||||||
|
_fgcolor(COLOR_BLACK), _bgcolor(COLOR_WHITE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TReport_field_mask
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TReport_field_mask::set_num(short id, long num)
|
||||||
|
{
|
||||||
|
set(id, num2str(num));
|
||||||
|
}
|
||||||
|
|
||||||
|
long TReport_field_mask::get_num(short id) const
|
||||||
|
{
|
||||||
|
return str2num(get(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TReport_field_mask::update()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
TMask_field& fld = field(i == 0 ? F_FGCOLOR : F_BGCOLOR);
|
||||||
|
if (fld.active() && fld.parent() == win())
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TReport_base_mask::update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TReport_field_mask::vedo_non_vedo()
|
||||||
|
{
|
||||||
|
const char type = get(F_TYPE)[0];
|
||||||
|
const bool is_currency = type == 'P' || type == 'V';
|
||||||
|
const bool is_numeric = is_currency || type == 'N';
|
||||||
|
const bool is_text = is_numeric || strchr("ADST", type) != NULL;
|
||||||
|
|
||||||
|
show(F_HIDE_ZEROES, is_numeric || type == 'D'),
|
||||||
|
show(F_HALIGN, is_text);
|
||||||
|
if (is_numeric)
|
||||||
|
{
|
||||||
|
disable(F_HALIGN);
|
||||||
|
set(F_HALIGN, "R"); // Allineo a destra i numeri
|
||||||
|
}
|
||||||
|
else
|
||||||
|
enable(F_HALIGN);
|
||||||
|
|
||||||
|
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_PATTERN, type != 'L' && type != 'I');
|
||||||
|
show(F_RADIUS, type != 'E' && type != 'L' && type != 'I');
|
||||||
|
show(F_SHADE_OFFSET,type != 'E' && type != 'L');
|
||||||
|
show(F_FONT_SELECT, is_text);
|
||||||
|
show(F_SOURCE, (is_text || type == 'I') && type != 'T');
|
||||||
|
show(F_SOURCE2, is_text && type != 'T');
|
||||||
|
show(DLG_FINDREC, is_text && type != 'T');
|
||||||
|
show(F_CODVAL, is_currency); // Codice valuta di riferimento
|
||||||
|
show(F_LINK, strchr("DNS", type) != NULL); // Chi puo' essere un link?
|
||||||
|
show(F_PRESCRIPT, is_text);
|
||||||
|
show(F_POSTSCRIPT, is_text);
|
||||||
|
enable_page(3, type == 'A');
|
||||||
|
|
||||||
|
if (is_running())
|
||||||
|
force_update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TReport_field_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||||
|
{
|
||||||
|
switch(o.dlg())
|
||||||
|
{
|
||||||
|
case F_TYPE:
|
||||||
|
if (e == fe_init || e == fe_modify)
|
||||||
|
{
|
||||||
|
vedo_non_vedo();
|
||||||
|
if (e == fe_modify)
|
||||||
|
{
|
||||||
|
if (strchr("ELR", o.get()[0]) != NULL && get_int(F_BORDER) == 0)
|
||||||
|
set(F_BORDER, 2); // Propongo un bordo visibile per le linee
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case F_X:
|
||||||
|
case F_Y:
|
||||||
|
case F_DX:
|
||||||
|
case F_DY:
|
||||||
|
case F_RADIUS:
|
||||||
|
case F_SHADE_OFFSET:
|
||||||
|
if (e == fe_modify)
|
||||||
|
{
|
||||||
|
const int num = get_num(o.dlg());
|
||||||
|
set_num(o.dlg(), num); // Reformat
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
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;
|
||||||
|
case DLG_FINDREC:
|
||||||
|
if (e == fe_button)
|
||||||
|
{
|
||||||
|
TRecordset* rex = _rf.section().recordset();
|
||||||
|
if (rex == NULL)
|
||||||
|
rex = _report.recordset();
|
||||||
|
if (rex != NULL && rex->columns() > 0)
|
||||||
|
{
|
||||||
|
TArray_sheet sheet(-1, -1, -1, 20, TR("Colonne Query"), HR("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));
|
||||||
|
|
||||||
|
char tipo = row.get_char(1);
|
||||||
|
int width = row.get_int(2);
|
||||||
|
switch (tipo)
|
||||||
|
{
|
||||||
|
case 'D':width = 10; break;
|
||||||
|
case 'L':tipo = 'S'; break;
|
||||||
|
case 'M':tipo = 'S'; width = 50; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
const char str[2] = { tipo, '\0' };
|
||||||
|
set(F_TYPE, str);
|
||||||
|
set(F_DX, width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
warning_box("Query non definita");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TReport_base_mask::on_field_event(o, e, jolly);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TReport_field_mask::set_field(const TReport_field& rf)
|
||||||
|
{
|
||||||
|
char str[2] = { rf.type(), '\0' };
|
||||||
|
set(F_TYPE, str, true);
|
||||||
|
|
||||||
|
const TRectangle& r = rf.get_rect();
|
||||||
|
set(F_ID, rf.id());
|
||||||
|
set_num(F_X, r.left());
|
||||||
|
set_num(F_Y, r.top());
|
||||||
|
set_num(F_DX, r.width());
|
||||||
|
set_num(F_DY, r.height());
|
||||||
|
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());
|
||||||
|
|
||||||
|
str[0] = rf.horizontal_alignment();
|
||||||
|
set(F_HALIGN, str);
|
||||||
|
str[0] = rf.vertical_alignment();
|
||||||
|
set(F_VALIGN, str);
|
||||||
|
set(F_BORDER, rf.border());
|
||||||
|
set(F_PATTERN, rf.pattern());
|
||||||
|
set_num(F_RADIUS, rf.radius());
|
||||||
|
set_num(F_SHADE_OFFSET, rf.shade_offset());
|
||||||
|
_fgcolor = rf.fore_color();
|
||||||
|
_bgcolor = rf.back_color();
|
||||||
|
set(F_TEXT, rf.picture());
|
||||||
|
set(F_SOURCE, rf.field());
|
||||||
|
set(F_SOURCE2, rf.alternate_field());
|
||||||
|
set_font_info(rf.font());
|
||||||
|
|
||||||
|
set(F_PRESCRIPT, rf.prescript());
|
||||||
|
set(F_POSTSCRIPT, rf.postscript());
|
||||||
|
|
||||||
|
if (rf.type() == 'A')
|
||||||
|
{
|
||||||
|
TSheet_field& list = sfield(F_LIST);
|
||||||
|
rf.get_list(list.rows_array());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TReport_field_mask::get_field(TReport_field& rf) const
|
||||||
|
{
|
||||||
|
rf.set_type(get(F_TYPE)[0]);
|
||||||
|
rf.set_id(get_int(F_ID));
|
||||||
|
rf.set_pos(get_num(F_X), get_num(F_Y));
|
||||||
|
rf.set_size(get_num(F_DX), get_num(F_DY));
|
||||||
|
rf.show(!get_bool(F_HIDDEN));
|
||||||
|
rf.activate(!get_bool(F_DISABLED));
|
||||||
|
rf.hide_zeroes(field(F_HIDE_ZEROES).active() && 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));
|
||||||
|
rf.set_horizontal_alignment(get(F_HALIGN)[0]);
|
||||||
|
rf.set_vertical_alignment(get(F_VALIGN)[0]);
|
||||||
|
rf.set_pattern((PAT_STYLE)get_int(F_PATTERN));
|
||||||
|
rf.set_border(get_int(F_BORDER));
|
||||||
|
rf.set_radius(get_num(F_RADIUS));
|
||||||
|
rf.set_shade_offset(get_num(F_SHADE_OFFSET));
|
||||||
|
rf.set_fore_color(_fgcolor);
|
||||||
|
rf.set_back_color(_bgcolor);
|
||||||
|
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;
|
||||||
|
if (get_font_info(f))
|
||||||
|
rf.set_font(f);
|
||||||
|
|
||||||
|
rf.set_prescript(get(F_PRESCRIPT));
|
||||||
|
rf.set_postscript(get(F_POSTSCRIPT));
|
||||||
|
if (rf.type() == 'A')
|
||||||
|
{
|
||||||
|
TSheet_field& list = sfield(F_LIST);
|
||||||
|
rf.set_list(list.rows_array());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TReport_field_mask::TReport_field_mask(TReport_field& rf)
|
||||||
|
: TReport_base_mask("ba8300b", rf.section().report()), _rf(rf)
|
||||||
|
{
|
||||||
|
set_field(rf);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// Utility
|
// Utility
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static TString16 _str;
|
||||||
|
|
||||||
|
const TString& num2str(int num)
|
||||||
|
{
|
||||||
|
const real n(num / 100.0);
|
||||||
|
_str = n.stringa(0, 2);
|
||||||
|
const int comma = _str.find(',');
|
||||||
|
if (comma > 0)
|
||||||
|
{
|
||||||
|
if (_str[comma+2] == '0')
|
||||||
|
{
|
||||||
|
if (_str[comma+1] == '0')
|
||||||
|
_str.cut(comma);
|
||||||
|
else
|
||||||
|
_str.cut(comma+2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _str;
|
||||||
|
}
|
||||||
|
|
||||||
|
short str2num(const TString& str)
|
||||||
|
{
|
||||||
|
_str = str;
|
||||||
|
_str.replace(',', '.');
|
||||||
|
real n(_str);
|
||||||
|
n *= CENTO;
|
||||||
|
return (short)n.integer();
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// TReport_window
|
// TReport_window
|
||||||
@ -448,12 +853,13 @@ public:
|
|||||||
int get_selection_rect(TRectangle& rct) const;
|
int get_selection_rect(TRectangle& rct) const;
|
||||||
bool pick(const TPoint& ptlog) const;
|
bool pick(const TPoint& ptlog) const;
|
||||||
void clear_selection();
|
void clear_selection();
|
||||||
void select(const TRectangle& rct);
|
bool select(const TRectangle& rct, bool inter);
|
||||||
void offset_selection(const TPoint& p);
|
void offset_selection(const TPoint& p);
|
||||||
void resize_selection(const TPoint& p);
|
void resize_selection(const TPoint& p);
|
||||||
|
|
||||||
bool test_corner(const RCT& rct, const PNT& pt, PNT& opposite) const;
|
bool test_corner(const RCT& rct, const PNT& pt, PNT& opposite) const;
|
||||||
TReport_field* first_selected() const;
|
TReport_field* first_selected() const;
|
||||||
|
bool add_field(const TRectangle& rct);
|
||||||
|
|
||||||
TReport_window(int x, int y, int dx, int dy, WINDOW parent, TWindowed_field* owner);
|
TReport_window(int x, int y, int dx, int dy, WINDOW parent, TWindowed_field* owner);
|
||||||
virtual ~TReport_window() { }
|
virtual ~TReport_window() { }
|
||||||
@ -554,17 +960,24 @@ TReport_field* TReport_window::first_selected() const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TReport_window::select(const TRectangle& rct)
|
bool TReport_window::select(const TRectangle& rct, bool inter)
|
||||||
{
|
{
|
||||||
|
bool some = false;
|
||||||
clear_selection();
|
clear_selection();
|
||||||
|
|
||||||
TReport_section& rs = curr_section();
|
TReport_section& rs = curr_section();
|
||||||
FOR_EACH_ARRAY_ITEM(rs, i, o)
|
FOR_EACH_ARRAY_ITEM(rs, i, o)
|
||||||
{
|
{
|
||||||
TReport_field& f = *(TReport_field*)o;
|
TReport_field& f = *(TReport_field*)o;
|
||||||
if (rct.intersects(f.get_rect()))
|
const TRectangle& r = f.get_rect();
|
||||||
|
const bool yes = inter ? rct.intersects(r) : rct.contains(r);
|
||||||
|
if (yes)
|
||||||
|
{
|
||||||
|
some = true;
|
||||||
f.select();
|
f.select();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return some;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TReport_window::draw_dragster()
|
void TReport_window::draw_dragster()
|
||||||
@ -818,6 +1231,31 @@ bool TReport_window::do_zoom(int k, bool reflect)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TReport_window::add_field(const TRectangle& rct)
|
||||||
|
{
|
||||||
|
TReport_section& rs = curr_section();
|
||||||
|
TReport_field* rf = new TReport_field(&rs);
|
||||||
|
rf->set_type('S');
|
||||||
|
rf->set_pos(((rct.left()+50)/100)*100, ((rct.top()+50)/100)*100);
|
||||||
|
int w = ((rct.width()+50)/100)*100; if (w < 100) w = 100;
|
||||||
|
int h = ((rct.height()+50)/100)*100; if (h < 100) h = 100;
|
||||||
|
rf->set_size(w, h);
|
||||||
|
|
||||||
|
TReport_field_mask m(*rf);
|
||||||
|
m.disable(DLG_DELREC);
|
||||||
|
const bool ok = m.run() == K_ENTER;
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
m.get_field(*rf);
|
||||||
|
rs.add(rf);
|
||||||
|
force_update();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
delete rf;
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
void TReport_window::handler(WINDOW win, EVENT* ep)
|
void TReport_window::handler(WINDOW win, EVENT* ep)
|
||||||
{
|
{
|
||||||
switch (ep->type)
|
switch (ep->type)
|
||||||
@ -926,7 +1364,9 @@ void TReport_window::handler(WINDOW win, EVENT* ep)
|
|||||||
_rct_drag.right = pt.h;
|
_rct_drag.right = pt.h;
|
||||||
_rct_drag.bottom = pt.v;
|
_rct_drag.bottom = pt.v;
|
||||||
TRectangle rct; TWindow::dev2log(_rct_drag, rct);
|
TRectangle rct; TWindow::dev2log(_rct_drag, rct);
|
||||||
select(rct);
|
const bool something = select(rct, pt.h < _rct_drag.left);
|
||||||
|
if (!something && ep->v.mouse.control)
|
||||||
|
add_field(rct);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@ -1260,8 +1700,7 @@ void TReport_window::draw_field(const TReport_field& rf)
|
|||||||
advanced_draw_rect(r, rf.pattern(), rf.border(), rf.fore_color(), rf.back_color(), rad, off);
|
advanced_draw_rect(r, rf.pattern(), rf.border(), rf.fore_color(), rf.back_color(), rad, off);
|
||||||
xvt_dwin_set_font(win(), rf.font().get_xvt_font(*this));
|
xvt_dwin_set_font(win(), rf.font().get_xvt_font(*this));
|
||||||
set_color(rf.fore_color(), rf.back_color());
|
set_color(rf.fore_color(), rf.back_color());
|
||||||
TString str = rf.picture();
|
advanced_draw_text_line(*this, rf.picture(), r, rf.horizontal_alignment(), rf.vertical_alignment());
|
||||||
advanced_draw_paragraph(*this, str, r, rf.horizontal_alignment(), rf.vertical_alignment(), _default_row_height);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
@ -1295,7 +1734,7 @@ void TReport_window::draw_field(const TReport_field& rf)
|
|||||||
str << rf.id();
|
str << rf.id();
|
||||||
else
|
else
|
||||||
str = rf.field();
|
str = rf.field();
|
||||||
advanced_draw_paragraph(*this, str, r, rf.horizontal_alignment(), rf.vertical_alignment(), _default_row_height);
|
advanced_draw_text_line(*this, str, r, rf.horizontal_alignment(), rf.vertical_alignment());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
54
ba/ba8301.h
54
ba/ba8301.h
@ -1,5 +1,5 @@
|
|||||||
#ifndef __MASKFLD_H
|
#ifndef __AUTOMASK_H
|
||||||
#include <maskfld.h>
|
#include <automask.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __TREE_H
|
#ifndef __TREE_H
|
||||||
@ -64,3 +64,53 @@ public:
|
|||||||
|
|
||||||
TReport_drawer(TMask* m) : TWindowed_field(m) { }
|
TReport_drawer(TMask* m) : TWindowed_field(m) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TReport_field_mask
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TReport_base_mask
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class TReport_base_mask : public TAutomask
|
||||||
|
{
|
||||||
|
TReport_font _font;
|
||||||
|
bool _font_changed;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TReport& _report;
|
||||||
|
char _halign, _valign;
|
||||||
|
COLOR _fgcolor, _bgcolor;
|
||||||
|
|
||||||
|
virtual void update();
|
||||||
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void set_font_info(const TReport_font& font);
|
||||||
|
bool get_font_info(TReport_font& font) const;
|
||||||
|
|
||||||
|
TReport_base_mask(const char* name, TReport& rep);
|
||||||
|
};
|
||||||
|
|
||||||
|
class TReport_field_mask : public TReport_base_mask
|
||||||
|
{
|
||||||
|
TReport_field& _rf;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void vedo_non_vedo();
|
||||||
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||||
|
virtual void update();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void set_num(short id, long n);
|
||||||
|
long get_num(short id) const;
|
||||||
|
|
||||||
|
void set_field(const TReport_field& rf);
|
||||||
|
void get_field(TReport_field& rf) const;
|
||||||
|
|
||||||
|
TReport_field_mask(TReport_field& rf);
|
||||||
|
};
|
||||||
|
|
||||||
|
const TString& num2str(int num);
|
||||||
|
short str2num(const TString& str);
|
||||||
|
@ -90,7 +90,7 @@ void TFormer_mask::parse_field_line(const TString& line, TReport_field& rf) cons
|
|||||||
{
|
{
|
||||||
TToken_string head(line, ' ');
|
TToken_string head(line, ' ');
|
||||||
head.trim();
|
head.trim();
|
||||||
head.strip_d_spaces();
|
head.strip_double_spaces();
|
||||||
|
|
||||||
if (head.starts_with("DR"))
|
if (head.starts_with("DR"))
|
||||||
{
|
{
|
||||||
@ -304,7 +304,7 @@ void TFormer_mask::import_section(TScanner& scan, TReport_section& rs) const
|
|||||||
if (in_field == 1)
|
if (in_field == 1)
|
||||||
{
|
{
|
||||||
head.trim();
|
head.trim();
|
||||||
head.strip_d_spaces();
|
head.strip_double_spaces();
|
||||||
const TString16 str_type = head.get(0);
|
const TString16 str_type = head.get(0);
|
||||||
char type = ' ';
|
char type = ' ';
|
||||||
if (str_type.starts_with("FI"))
|
if (str_type.starts_with("FI"))
|
||||||
@ -382,7 +382,7 @@ void TFormer_mask::import_sections(TScanner& scan, TReport& rep)
|
|||||||
if (line.starts_with("SE"))
|
if (line.starts_with("SE"))
|
||||||
{
|
{
|
||||||
line.trim();
|
line.trim();
|
||||||
line.strip_d_spaces();
|
line.strip_double_spaces();
|
||||||
TToken_string head(line, ' ');
|
TToken_string head(line, ' ');
|
||||||
const TString16 str_name = head.get(1);
|
const TString16 str_name = head.get(1);
|
||||||
const TString16 str_type = head.get();
|
const TString16 str_type = head.get();
|
||||||
@ -451,22 +451,26 @@ void TFormer_mask::import()
|
|||||||
import_use(scan, rep);
|
import_use(scan, rep);
|
||||||
import_sections(scan, rep);
|
import_sections(scan, rep);
|
||||||
if (_doc)
|
if (_doc)
|
||||||
|
{
|
||||||
|
rep.set_command_line("ve1 -2");
|
||||||
rep.set_libraries("ve1300");
|
rep.set_libraries("ve1300");
|
||||||
|
}
|
||||||
rep.save(get(F_REPORT));
|
rep.save(get(F_REPORT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFormer_mask::run_app(const char* app) const
|
void TFormer_mask::run_app(const char* app) const
|
||||||
{
|
{
|
||||||
const TFilename output = get(F_REPORT);
|
TFilename output = get(F_REPORT);
|
||||||
if (output.exist())
|
if (output.custom_path())
|
||||||
{
|
{
|
||||||
TString cmd;
|
TString cmd = app;
|
||||||
cmd << app << ' ' << output;
|
if (cmd.starts_with("ba8"))
|
||||||
|
cmd << ' ' << output.name();
|
||||||
TExternal_app app(cmd);
|
TExternal_app app(cmd);
|
||||||
app.run();
|
app.run();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
::error_box(TR("Il file %s non esiste"), (const char*)output);
|
::error_box(TR("Il file %s non esiste"), output.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TFormer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
bool TFormer_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <execp.h>
|
#include <execp.h>
|
||||||
#include <prefix.h>
|
#include <prefix.h>
|
||||||
#include <reprint.h>
|
#include <reprint.h>
|
||||||
#include <utility.h>
|
|
||||||
|
|
||||||
#include "ba8400.h"
|
#include "ba8400.h"
|
||||||
|
|
||||||
@ -66,15 +65,19 @@ bool rep2app(const char* name, TString& app, TString& desc)
|
|||||||
if (!report_name.custom_path())
|
if (!report_name.custom_path())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TToken_string libraries(50, ',');
|
|
||||||
|
|
||||||
TString stringona;
|
TString stringona;
|
||||||
TScanner scan(report_name);
|
TScanner scan(report_name);
|
||||||
for (int i = 0; i < 3 && scan.good(); i++) // Leggo solo le prime righe
|
for (int i = 0; i < 3 && scan.good(); i++) // Leggo solo le prime righe
|
||||||
stringona << scan.line();
|
stringona << scan.line();
|
||||||
get_xml_attr(stringona, "libraries", libraries);
|
|
||||||
get_xml_child(stringona, "description", desc);
|
get_xml_child(stringona, "description", desc);
|
||||||
|
|
||||||
|
get_xml_attr(stringona, "command", app);
|
||||||
|
if (app.not_empty())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
TToken_string libraries(50, ',');
|
||||||
|
get_xml_attr(stringona, "libraries", libraries);
|
||||||
FOR_EACH_TOKEN(libraries, tok) if (strlen(tok) == 6)
|
FOR_EACH_TOKEN(libraries, tok) if (strlen(tok) == 6)
|
||||||
{
|
{
|
||||||
if (cod2app(tok, app))
|
if (cod2app(tok, app))
|
||||||
@ -105,27 +108,10 @@ bool TKlarkKent_mask::on_field_event(TOperable_field& o, TField_event e, long jo
|
|||||||
case F_REPORT:
|
case F_REPORT:
|
||||||
if (e == fe_button)
|
if (e == fe_button)
|
||||||
{
|
{
|
||||||
TArray_sheet a(-1, -1, 75, 20, "Report", "Nome@16|Progr.|Descrizione@50");
|
TFilename path;
|
||||||
TString_array& arr = a.rows_array();
|
if (select_custom_file(path, "rep"))
|
||||||
|
|
||||||
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);
|
o.set(path);
|
||||||
|
|
||||||
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;
|
e = fe_modify;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user