Patch level : 2.1 nopatch
Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@12133 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
cf2a2b0525
commit
4cfa606fe3
121
ba/ba8300.cpp
121
ba/ba8300.cpp
@ -698,17 +698,21 @@ void TReport_properties_mask::get_report(TReport& r) const
|
||||
class TReport_mask : public TAutomask
|
||||
{
|
||||
TReport _report;
|
||||
TReport_section* _curr_section;
|
||||
|
||||
TReport_tree _tree;
|
||||
TFilename _curr_report;
|
||||
bool _is_dirty;
|
||||
|
||||
protected:
|
||||
virtual TMask_field* parse_field(TScanner& scanner);
|
||||
virtual void notify_focus_field(short id);
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
|
||||
protected:
|
||||
bool select_query();
|
||||
bool select_report();
|
||||
void select_section();
|
||||
void update_report() const;
|
||||
|
||||
TReport_section& curr_section();
|
||||
@ -847,7 +851,7 @@ bool TReport_mask::load_report()
|
||||
TTree_field& sections = tfield(F_SECTIONS);
|
||||
_tree.goto_node('B', 1);
|
||||
sections.select_current();
|
||||
update_report();
|
||||
select_section();
|
||||
}
|
||||
}
|
||||
|
||||
@ -879,9 +883,70 @@ void TReport_mask::on_print()
|
||||
|
||||
TReport_section& TReport_mask::curr_section()
|
||||
{
|
||||
TTree_field& sections = tfield(F_SECTIONS);
|
||||
sections.goto_selected();
|
||||
return _tree.curr_section();
|
||||
return *_curr_section;
|
||||
}
|
||||
|
||||
void TReport_mask::select_section()
|
||||
{
|
||||
TTree_field& tf = tfield(F_SECTIONS);
|
||||
tf.select_current();
|
||||
_curr_section = &_tree.curr_section();
|
||||
|
||||
TReport_drawer& rd = (TReport_drawer&)field(F_REPORT);
|
||||
rd.set_report_section(*_curr_section);
|
||||
|
||||
const char type = _curr_section->type();
|
||||
const int level = _curr_section->level();
|
||||
|
||||
char htype = 'H', ftype = 'F';
|
||||
int hlevel = level, flevel = level;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 'H':
|
||||
{
|
||||
if (level <= 1)
|
||||
hlevel = flevel = 1-level;
|
||||
else
|
||||
{
|
||||
if (_report.find_section('H', level-1))
|
||||
hlevel = flevel = level-1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'B':
|
||||
{
|
||||
if (level >= 1)
|
||||
{
|
||||
hlevel = flevel = _report.find_max_level('H');
|
||||
if (hlevel <= 1)
|
||||
hlevel = flevel = 0;
|
||||
}
|
||||
else
|
||||
hlevel = flevel = 0;
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
{
|
||||
if (level <= 1)
|
||||
hlevel = flevel = 1-level;
|
||||
else
|
||||
{
|
||||
if (_report.find_section('F', level-1))
|
||||
hlevel = flevel = level-1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
TReport_drawer& rdh = (TReport_drawer&)field(F_REPORTH);
|
||||
rdh.set_report_section(_report.section(htype, hlevel));
|
||||
|
||||
TReport_drawer& rdf = (TReport_drawer&)field(F_REPORTF);
|
||||
rdf.set_report_section(_report.section(ftype, flevel));
|
||||
|
||||
update_report();
|
||||
}
|
||||
|
||||
void TReport_mask::update_report() const
|
||||
@ -889,8 +954,14 @@ void TReport_mask::update_report() const
|
||||
TTree_field& tf = tfield(F_SECTIONS);
|
||||
tf.win().force_update();
|
||||
|
||||
TReport_drawer& rdh = (TReport_drawer&)field(F_REPORTH);
|
||||
rdh.win().force_update();
|
||||
|
||||
TReport_drawer& rd = (TReport_drawer&)field(F_REPORT);
|
||||
rd.win().force_update();
|
||||
|
||||
TReport_drawer& rdf = (TReport_drawer&)field(F_REPORTF);
|
||||
rdf.win().force_update();
|
||||
}
|
||||
|
||||
void TReport_mask::add_field()
|
||||
@ -1049,7 +1120,7 @@ void TReport_mask::section_properties()
|
||||
break;
|
||||
}
|
||||
if (_is_dirty)
|
||||
update_report();
|
||||
select_section();
|
||||
}
|
||||
|
||||
void TReport_mask::report_properties()
|
||||
@ -1063,6 +1134,15 @@ void TReport_mask::report_properties()
|
||||
}
|
||||
}
|
||||
|
||||
void TReport_mask::notify_focus_field(short id)
|
||||
{
|
||||
TAutomask::notify_focus_field(id);
|
||||
if (id == F_REPORTH || id == F_REPORTF)
|
||||
{
|
||||
TReport_drawer& rd = (TReport_drawer&)field(id);
|
||||
_curr_section = &rd.curr_section();
|
||||
}
|
||||
}
|
||||
|
||||
bool TReport_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
@ -1091,7 +1171,7 @@ bool TReport_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
|
||||
case F_SECTIONS:
|
||||
if (e == fe_init || e == fe_modify)
|
||||
{
|
||||
update_report();
|
||||
select_section();
|
||||
const TReport_section& rs = _tree.curr_section();
|
||||
const bool ok = strchr("HBF", rs.type()) != NULL;
|
||||
enable(-1, ok);
|
||||
@ -1200,13 +1280,28 @@ TReport_mask::TReport_mask() : _tree(_report), _is_dirty(false)
|
||||
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);
|
||||
|
||||
const short sec[3] = { F_REPORT, F_REPORTH, F_REPORTF };
|
||||
for (int s = 0; s < 3; s++)
|
||||
{
|
||||
TReport_drawer& rd = (TReport_drawer&)field(sec[s]);
|
||||
RCT rct_rep; rd.get_rect(rct_rep);
|
||||
rct_rep.left = rct_sec.right+ROWY;
|
||||
rct_rep.right -= ROWY;
|
||||
rct_rep.bottom -= ROWY;
|
||||
rd.set_rect(rct_rep);
|
||||
|
||||
switch (s)
|
||||
{
|
||||
case 1 : rd.set_report_section(_report.section('H', 0)); break;
|
||||
case 2 : rd.set_report_section(_report.section('F', 0)); break;
|
||||
default:
|
||||
_curr_section = &_report.section('B', 1);
|
||||
rd.set_report_section(*_curr_section);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_tree.goto_node('B',1);
|
||||
const int ih = _tree.image_height();
|
||||
@ -1217,8 +1312,6 @@ TReport_mask::TReport_mask() : _tree(_report), _is_dirty(false)
|
||||
_tree.goto_root();
|
||||
_tree.expand_all();
|
||||
|
||||
TReport_drawer& rd = (TReport_drawer&)field(F_REPORT);
|
||||
rd.set_report(&_report);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
17
ba/ba8300.h
17
ba/ba8300.h
@ -2,12 +2,17 @@
|
||||
#define F_DESCR 102
|
||||
|
||||
#define F_SECTIONS 103
|
||||
#define F_REPORT 104
|
||||
#define F_FLD_ADD 105
|
||||
#define F_FLD_PROPERTIES 106
|
||||
#define F_SEC_ADD 107
|
||||
#define F_SEC_PROPERTIES 108
|
||||
#define F_REP_PROPERTIES 109
|
||||
#define F_REPORTH_TITLE 104
|
||||
#define F_REPORTH 105
|
||||
#define F_REPORT_TITLE 106
|
||||
#define F_REPORT 107
|
||||
#define F_REPORTF_TITLE 108
|
||||
#define F_REPORTF 109
|
||||
#define F_FLD_ADD 110
|
||||
#define F_FLD_PROPERTIES 111
|
||||
#define F_SEC_ADD 112
|
||||
#define F_SEC_PROPERTIES 113
|
||||
#define F_REP_PROPERTIES 114
|
||||
|
||||
#define F_TYPE 120
|
||||
#define F_ID 121
|
||||
|
@ -61,11 +61,37 @@ BEGIN
|
||||
PROMPT 0 1 ""
|
||||
END
|
||||
|
||||
REPORT F_REPORT -3 -3
|
||||
TEXT F_REPORTH_TITLE
|
||||
BEGIN
|
||||
PROMPT 21 1 ""
|
||||
PROMPT 41 1 "Testata di livello 0"
|
||||
END
|
||||
|
||||
REPORT F_REPORTH -3 3
|
||||
BEGIN
|
||||
PROMPT 21 2 ""
|
||||
END
|
||||
|
||||
TEXT F_REPORT_TITLE
|
||||
BEGIN
|
||||
PROMPT 41 5 "Corpo di livello 0"
|
||||
END
|
||||
|
||||
REPORT F_REPORT -3 9
|
||||
BEGIN
|
||||
PROMPT 21 6 ""
|
||||
END
|
||||
|
||||
TEXT F_REPORTF_TITLE
|
||||
BEGIN
|
||||
PROMPT 41 -7 "Coda di livello 0"
|
||||
END
|
||||
|
||||
REPORT F_REPORTF -3 -3
|
||||
BEGIN
|
||||
PROMPT 21 -6 ""
|
||||
END
|
||||
|
||||
|
||||
BUTTON F_FLD_ADD 10 2
|
||||
BEGIN
|
||||
PROMPT -16 -1 "Campo +"
|
||||
|
214
ba/ba8301.cpp
214
ba/ba8301.cpp
@ -12,20 +12,18 @@
|
||||
// TReport_tree
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
bool TReport_tree::get_description(TString& str) const
|
||||
void describe_section(char type, int level, TString& str)
|
||||
{
|
||||
const char type = _curr[0];
|
||||
const int level = atoi(_curr.mid(1));
|
||||
str = " ";
|
||||
if (level <= 0)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 'H': str << TR("Testa"); break;
|
||||
case 'B': str << TR("Sfondo"); break;
|
||||
case 'B': str << TR("Sfondo"); break;
|
||||
case 'F': str << TR("Coda"); break;
|
||||
case 'P': str = TR("Pagina"); break; // Virtual section
|
||||
case 'R': str = TR("Report"); break; // Virtual section
|
||||
case 'P': str = TR("Pagina"); break; // Virtual section
|
||||
case 'R': str = TR("Report"); break; // Virtual section
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
@ -33,9 +31,9 @@ bool TReport_tree::get_description(TString& str) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 'H': str << TR("Testa"); break;
|
||||
case 'B': str << TR("Corpo"); break;
|
||||
case 'F': str << TR("Coda"); break;
|
||||
case 'H': str << TR("Testa"); break;
|
||||
case 'B': str << TR("Corpo"); break;
|
||||
case 'F': str << TR("Coda"); break;
|
||||
default : break;
|
||||
}
|
||||
str << ' ';
|
||||
@ -49,6 +47,13 @@ bool TReport_tree::get_description(TString& str) const
|
||||
else
|
||||
str << level;
|
||||
}
|
||||
}
|
||||
|
||||
bool TReport_tree::get_description(TString& str) const
|
||||
{
|
||||
const char type = _curr[0];
|
||||
const int level = atoi(_curr.mid(1));
|
||||
describe_section(type, level, str);
|
||||
if (type != 'R' && type != 'P')
|
||||
str << " (" << _curr << ')';
|
||||
return true;
|
||||
@ -70,9 +75,12 @@ void TReport_tree::node2id(const TObject* node, TString& id) const
|
||||
TReport_section& TReport_tree::curr_section() const
|
||||
{
|
||||
char type = _curr[0];
|
||||
const int level = _curr[1]-'0';
|
||||
int level = atoi((const char*)_curr + 1);
|
||||
if (type == 'R' || type == 'P')
|
||||
{
|
||||
type = 'B';
|
||||
level = type == 'R';
|
||||
}
|
||||
return _report.section(type, level);
|
||||
}
|
||||
|
||||
@ -93,7 +101,8 @@ bool TReport_tree::goto_firstson()
|
||||
case 'R':
|
||||
nlevel = 1;
|
||||
break;
|
||||
default : break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return goto_node(ntype, nlevel);
|
||||
}
|
||||
@ -303,6 +312,8 @@ int TReport_tree::image_height() const
|
||||
class TReport_window : public TField_window
|
||||
{
|
||||
TReport* _report;
|
||||
char _type;
|
||||
int _level;
|
||||
PNT _dpi;
|
||||
|
||||
int _dragging;
|
||||
@ -320,7 +331,8 @@ protected:
|
||||
|
||||
protected:
|
||||
void draw_grid();
|
||||
void snap_drag(PNT& pnt) const;
|
||||
void snap(TPoint& pnt, bool shift) const;
|
||||
void snap(TRectangle& pnt, bool shift) const;
|
||||
void draw_dragster();
|
||||
void draw_field(const TReport_field& rf);
|
||||
void draw_broken_paper(const TReport_field& rf);
|
||||
@ -336,30 +348,31 @@ protected:
|
||||
public:
|
||||
virtual PNT log2dev(long x, long y) const;
|
||||
virtual TPoint dev2log(const PNT& pt) const;
|
||||
TReport_section& curr_section() const;
|
||||
TReport_section& curr_section() const { return _report->section(_type, _level); }
|
||||
void set_report_section(TReport_section& rs);
|
||||
|
||||
bool get_selection_rect(TRectangle& rct) const;
|
||||
int get_selection_rect(TRectangle& rct) const;
|
||||
bool pick(const TPoint& ptlog) const;
|
||||
void clear_selection();
|
||||
void select(const TRectangle& rct);
|
||||
void offset_selection(const TPoint& p);
|
||||
void resize_selection(const TPoint& p);
|
||||
|
||||
void set_report(TReport* rep) { _report = rep; }
|
||||
bool test_corner(const RCT& rct, const PNT& pt, PNT& opposite) const;
|
||||
TReport_field* first_selected() const;
|
||||
|
||||
TReport_window(int x, int y, int dx, int dy, WINDOW parent, TWindowed_field* owner);
|
||||
virtual ~TReport_window() { }
|
||||
};
|
||||
|
||||
TReport_section& TReport_window::curr_section() const
|
||||
void TReport_window::set_report_section(TReport_section& rs)
|
||||
{
|
||||
TMask& m = owner().mask();
|
||||
TTree_field& sections = m.tfield(F_SECTIONS);
|
||||
sections.goto_selected();
|
||||
TReport_tree& tree = *(TReport_tree*)sections.tree();
|
||||
return tree.curr_section();
|
||||
_report = &rs.report();
|
||||
_type = rs.type();
|
||||
_level = rs.level();
|
||||
}
|
||||
|
||||
|
||||
bool TReport_window::pick(const TPoint& ptlog) const
|
||||
{
|
||||
TReport_section& rs = curr_section();
|
||||
@ -387,10 +400,10 @@ void TReport_window::clear_selection()
|
||||
}
|
||||
}
|
||||
|
||||
bool TReport_window::get_selection_rect(TRectangle& rct) const
|
||||
int TReport_window::get_selection_rect(TRectangle& rct) const
|
||||
{
|
||||
TReport_section& rs = curr_section();
|
||||
bool full = false;
|
||||
int full = 0;
|
||||
FOR_EACH_ARRAY_ITEM(rs, i, o)
|
||||
{
|
||||
const TReport_field& f = *(const TReport_field*)o;
|
||||
@ -398,12 +411,10 @@ bool TReport_window::get_selection_rect(TRectangle& rct) const
|
||||
{
|
||||
const TRectangle& fr = f.get_rect();
|
||||
if (!full)
|
||||
{
|
||||
rct = fr;
|
||||
full = true;
|
||||
}
|
||||
else
|
||||
rct.merge(fr);
|
||||
full++;
|
||||
}
|
||||
}
|
||||
return full;
|
||||
@ -435,6 +446,18 @@ void TReport_window::resize_selection(const TPoint& p)
|
||||
}
|
||||
}
|
||||
|
||||
TReport_field* TReport_window::first_selected() const
|
||||
{
|
||||
TReport_section& rs = curr_section();
|
||||
FOR_EACH_ARRAY_ITEM(rs, i, o)
|
||||
{
|
||||
TReport_field& f = *(TReport_field*)o;
|
||||
if (f.selected())
|
||||
return &f;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TReport_window::select(const TRectangle& rct)
|
||||
{
|
||||
clear_selection();
|
||||
@ -456,14 +479,27 @@ void TReport_window::draw_dragster()
|
||||
set_mode(M_COPY);
|
||||
}
|
||||
|
||||
void TReport_window::snap_drag(PNT& pnt) const
|
||||
void TReport_window::snap(TPoint& pnt, bool shift) const
|
||||
{
|
||||
const int kx = _dpi.h / cpi();
|
||||
const int ky = _dpi.v / (lpi()*2);
|
||||
pnt.h = (pnt.h / kx) * kx;
|
||||
pnt.v = (pnt.v / ky) * ky;
|
||||
const int kx = shift ? 10 : 100;
|
||||
const int ky = shift ? 10 : 50;
|
||||
pnt.x = ((pnt.x+kx/2) / kx) * kx;
|
||||
pnt.y = ((pnt.y+ky/2) / ky) * ky;
|
||||
}
|
||||
|
||||
void TReport_window::snap(TRectangle& rct, bool shift) const
|
||||
{
|
||||
TPoint p0 = rct;
|
||||
snap(p0, shift);
|
||||
|
||||
TPoint p1(rct.right(), rct.bottom());
|
||||
snap(p1, shift);
|
||||
p1 -= p0;
|
||||
|
||||
rct.set(p0, p1);
|
||||
}
|
||||
|
||||
|
||||
#define POPUP_CUT 20883
|
||||
#define POPUP_COPY 20884
|
||||
#define POPUP_PASTE 20885
|
||||
@ -538,7 +574,7 @@ void TReport_window::popup_menu(EVENT* ep)
|
||||
memset(menu, 0, sizeof(menu));
|
||||
|
||||
TRectangle rct;
|
||||
const bool sel = get_selection_rect(rct);
|
||||
const bool sel = get_selection_rect(rct) != 0;
|
||||
const bool clp = _clipboard.items() > 0;
|
||||
|
||||
menu[0].tag = POPUP_CUT; menu[0].text = "Taglia"; menu[0].enabled = sel;
|
||||
@ -605,6 +641,38 @@ void TReport_window::popup_paste()
|
||||
}
|
||||
}
|
||||
|
||||
bool TReport_window::test_corner(const RCT& rct, const PNT& pt, PNT& opposite) const
|
||||
{
|
||||
int test = 0;
|
||||
|
||||
if (pt.h >= rct.left && pt.h < rct.left+4)
|
||||
{
|
||||
opposite.h = rct.right;
|
||||
test = 1;
|
||||
} else
|
||||
if (pt.h > rct.right-4 && pt.h <= rct.right)
|
||||
{
|
||||
opposite.h = rct.left;
|
||||
test = 1;
|
||||
}
|
||||
|
||||
if (test == 1)
|
||||
{
|
||||
if (pt.v >= rct.top && pt.v < rct.top+4)
|
||||
{
|
||||
opposite.v = rct.bottom;
|
||||
test = 2;
|
||||
} else
|
||||
if (pt.v <= rct.bottom && pt.v > rct.bottom-4)
|
||||
{
|
||||
opposite.v = rct.top;
|
||||
test = 2;
|
||||
}
|
||||
}
|
||||
|
||||
return test == 2;
|
||||
}
|
||||
|
||||
void TReport_window::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
switch (ep->type)
|
||||
@ -614,28 +682,39 @@ void TReport_window::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
const TPoint pt = dev2log(ep->v.mouse.where);
|
||||
TRectangle rct;
|
||||
bool full = get_selection_rect(rct);
|
||||
int full = get_selection_rect(rct);
|
||||
if (!full || !rct.contains(pt))
|
||||
{
|
||||
if (full)
|
||||
if (full && !ep->v.mouse.control)
|
||||
clear_selection();
|
||||
pick(pt);
|
||||
full = get_selection_rect(rct);
|
||||
}
|
||||
if (full)
|
||||
if (full > 0)
|
||||
{
|
||||
TWindow::log2dev(rct, _rct_drag);
|
||||
_pt_drag_offset.h = ep->v.mouse.where.h - _rct_drag.left;
|
||||
_pt_drag_offset.v = ep->v.mouse.where.v - _rct_drag.top;
|
||||
_dragging = 2;
|
||||
XinCursor hand = xi_get_pref(XI_PREF_HAND_CURSOR_RID);
|
||||
xvt_win_set_cursor(win, (CURSOR)hand);
|
||||
|
||||
if (full == 1 && test_corner(_rct_drag, ep->v.mouse.where, _pt_drag_offset))
|
||||
{
|
||||
_dragging = 3; // Trascinamento rettangolo elastico
|
||||
XinCursor hand = xi_get_pref(XI_PREF_SIZE_CURSOR_RID);
|
||||
xvt_win_set_cursor(win, (CURSOR)hand);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pt_drag_offset.h = ep->v.mouse.where.h - _rct_drag.left;
|
||||
_pt_drag_offset.v = ep->v.mouse.where.v - _rct_drag.top;
|
||||
_dragging = 2; // Trascinamento rettangolo fisso
|
||||
XinCursor hand = xi_get_pref(XI_PREF_HAND_CURSOR_RID);
|
||||
xvt_win_set_cursor(win, (CURSOR)hand);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const PNT& pnt = ep->v.mouse.where;
|
||||
xvt_rect_set(&_rct_drag, pnt.h, pnt.v, pnt.h, pnt.v);
|
||||
_dragging = 1;
|
||||
_pt_drag_offset.h = _pt_drag_offset.v = 0;
|
||||
_dragging = 1; // Trascinamento rettangolo di selezione
|
||||
}
|
||||
_pt_drag_start.x = rct.left();
|
||||
_pt_drag_start.y = rct.top();
|
||||
@ -646,17 +725,15 @@ void TReport_window::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
popup_menu(ep);
|
||||
}
|
||||
owner().mask().notify_focus_field(owner().dlg());
|
||||
break;
|
||||
case E_MOUSE_MOVE:
|
||||
{
|
||||
TMask& m = owner().mask();
|
||||
const TPoint p = dev2log(ep->v.mouse.where);
|
||||
|
||||
if (true) // Needs an option?
|
||||
{
|
||||
TString16 str; str.format("r:%3d c:%3d", p.y/100, p.x/100);
|
||||
statbar_set_title(TASK_WIN, str);
|
||||
}
|
||||
TString16 str; str.format("r:%3d c:%3d", p.y/100, p.x/100);
|
||||
statbar_set_title(TASK_WIN, str);
|
||||
|
||||
if (_dragging != 0)
|
||||
{
|
||||
@ -669,11 +746,13 @@ void TReport_window::handler(WINDOW win, EVENT* ep)
|
||||
_rct_drag.bottom = pt.v;
|
||||
break;
|
||||
case 2:
|
||||
pt.h -= _pt_drag_offset.h; pt.v -= _pt_drag_offset.v;
|
||||
if (!ep->v.mouse.shift)
|
||||
snap_drag(pt);
|
||||
pt.h -= _pt_drag_offset.h;
|
||||
pt.v -= _pt_drag_offset.v;
|
||||
xvt_rect_set_pos(&_rct_drag, pt);
|
||||
break;
|
||||
case 3:
|
||||
xvt_rect_set(&_rct_drag, _pt_drag_offset.h, _pt_drag_offset.v, pt.h, pt.v);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -699,15 +778,24 @@ void TReport_window::handler(WINDOW win, EVENT* ep)
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
pt.h -= _pt_drag_offset.h; pt.v -= _pt_drag_offset.v;
|
||||
if (!ep->v.mouse.shift)
|
||||
snap_drag(pt);
|
||||
pt.h -= _pt_drag_offset.h;
|
||||
pt.v -= _pt_drag_offset.v;
|
||||
TPoint offset = dev2log(pt);
|
||||
snap(offset, ep->v.mouse.shift != 0);
|
||||
offset.x -= _pt_drag_start.x;
|
||||
offset.y -= _pt_drag_start.y;
|
||||
offset_selection(offset);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
TReport_field* rf = first_selected();
|
||||
TRectangle rct; TWindow::dev2log(_rct_drag, rct);
|
||||
snap(rct, ep->v.mouse.shift != 0);
|
||||
rf->set_pos(rct.x, rct.y);
|
||||
rf->set_size(rct.width(), rct.height());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -870,7 +958,7 @@ void TReport_window::draw_field(const TReport_field& rf)
|
||||
case 'I':
|
||||
{
|
||||
TVariant var;
|
||||
_report->evaluate(rf.field(), var, _alfafld);
|
||||
curr_section().report().evaluate(rf.field(), var, _alfafld);
|
||||
const TString& name = var.as_string();
|
||||
const TImage* img = _images.image(name);
|
||||
if (img != NULL && img->ok())
|
||||
@ -969,14 +1057,14 @@ void TReport_window::update()
|
||||
}
|
||||
|
||||
int TReport_window::cpi() const
|
||||
{ return _report ? _report->cpi() : 12; }
|
||||
{ return _report != NULL ? _report->cpi() : 12; }
|
||||
|
||||
int TReport_window::lpi() const
|
||||
{ return _report ? _report->lpi() : 6; }
|
||||
{ return _report != NULL ? _report->lpi() : 6; }
|
||||
|
||||
|
||||
TReport_window::TReport_window(int x, int y, int dx, int dy, WINDOW parent, TWindowed_field* owner)
|
||||
: TField_window(x, y, dx, dy, parent, owner), _dragging(0), _report(NULL)
|
||||
: TField_window(x, y, dx, dy, parent, owner), _dragging(0), _report(NULL), _type('B'), _level(1)
|
||||
{
|
||||
_dpi.h = _dpi.v = 96;
|
||||
_pixmap = true;
|
||||
@ -992,9 +1080,19 @@ TField_window* TReport_drawer::create_window(int x, int y, int dx, int dy, WINDO
|
||||
return new TReport_window(x, y, dx, dy, parent, this);
|
||||
}
|
||||
|
||||
void TReport_drawer::set_report(TReport* rep)
|
||||
void TReport_drawer::set_report_section(TReport_section& rs)
|
||||
{
|
||||
TReport_window* w = (TReport_window*)_win;
|
||||
w->set_report(rep);
|
||||
w->set_report_section(rs);
|
||||
|
||||
const int pos = mask().id2pos(dlg()) - 1; // Caption field position
|
||||
TString str; describe_section(rs.type(), rs.level(), str);
|
||||
str.insert("@b");
|
||||
mask().fld(pos).set_prompt(str);
|
||||
}
|
||||
|
||||
TReport_section& TReport_drawer::curr_section()
|
||||
{
|
||||
TReport_window* w = (TReport_window*)_win;
|
||||
return w->curr_section();
|
||||
}
|
||||
|
@ -56,6 +56,8 @@ protected:
|
||||
virtual TField_window* create_window(int x, int y, int dx, int dy, WINDOW parent);
|
||||
|
||||
public:
|
||||
void set_report(TReport* rep);
|
||||
void set_report_section(TReport_section& sec);
|
||||
TReport_section& curr_section();
|
||||
|
||||
TReport_drawer(TMask* m) : TWindowed_field(m) { }
|
||||
};
|
||||
|
@ -1,58 +0,0 @@
|
||||
TOOLBAR "Toolbar" 0 -2 0 2
|
||||
|
||||
BUTTON DLG_PRINT 10 2
|
||||
BEGIN
|
||||
PROMPT -16 -1 "~Stampa"
|
||||
PICTURE BMP_PRINT
|
||||
MESSAGE EXIT,K_INS
|
||||
END
|
||||
|
||||
BUTTON DLG_PREVREC 3
|
||||
BEGIN
|
||||
PROMPT -46 -2 ""
|
||||
PICTURE 122
|
||||
END
|
||||
|
||||
BUTTON DLG_FIRSTREC 3
|
||||
BEGIN
|
||||
PROMPT -46 -1 ""
|
||||
PICTURE 121
|
||||
END
|
||||
|
||||
BUTTON DLG_FINDREC 10 2
|
||||
BEGIN
|
||||
PROMPT -46 -1 ""
|
||||
PICTURE 166
|
||||
END
|
||||
|
||||
BUTTON DLG_NEXTREC 3
|
||||
BEGIN
|
||||
PROMPT -46 -2 ""
|
||||
PICTURE 124
|
||||
END
|
||||
|
||||
BUTTON DLG_LASTREC 3
|
||||
BEGIN
|
||||
PROMPT -46 -1 ""
|
||||
PICTURE 125
|
||||
END
|
||||
|
||||
BUTTON DLG_QUIT 10 2
|
||||
BEGIN
|
||||
PROMPT -66 -1 "~Fine"
|
||||
PICTURE BMP_QUIT
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Anteprima" -1 -1 60 13
|
||||
|
||||
PREVIEW DLG_USER -3 -1
|
||||
BEGIN
|
||||
PROMPT 0 0 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
|
@ -169,7 +169,10 @@ void TKlarkKent_app::main_loop()
|
||||
{
|
||||
TFilename report_name;
|
||||
if (argc() > 2)
|
||||
{
|
||||
report_name = argv(2);
|
||||
report_name.ext("rep");
|
||||
}
|
||||
|
||||
if (report_name.empty() || !report_name.custom_path())
|
||||
{
|
||||
@ -197,6 +200,7 @@ void TKlarkKent_app::main_loop()
|
||||
{
|
||||
TReport_book book;
|
||||
book.add(rep);
|
||||
book.print_or_preview();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
111
include/codeb.h
111
include/codeb.h
@ -10,73 +10,62 @@
|
||||
#include <extctype.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _USRDLL
|
||||
#define CBDLL __declspec(dllexport)
|
||||
#else
|
||||
#define CBDLL __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define CBDLL
|
||||
#endif
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
prototipi funzioni
|
||||
--------------------------------------------------------------------------*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
CBDLL void DB_init(void);
|
||||
CBDLL void DB_exit(void);
|
||||
CBDLL int DB_open(const char *filename,int mode,int index);
|
||||
CBDLL int DB_close(int handle);
|
||||
CBDLL char *DB_getrecord(int handle);
|
||||
CBDLL int DB_reclen(int handle);
|
||||
CBDLL int DB_keylen(int handle);
|
||||
CBDLL long int DB_recno(int handle);
|
||||
CBDLL long int DB_reccount(int handle);
|
||||
CBDLL int DB_tagselect(int handle,int index_no);
|
||||
CBDLL int DB_tagget(int handle);
|
||||
CBDLL int DB_first(int handle);
|
||||
CBDLL int DB_last(int handle);
|
||||
CBDLL int DB_next(int handle);
|
||||
CBDLL int DB_prev(int handle);
|
||||
CBDLL int DB_skip(int handle,long int recno);
|
||||
CBDLL int DB_lock(int handle);
|
||||
CBDLL int DB_unlock(int handle);
|
||||
CBDLL int DB_seek(int handle,char *key);
|
||||
CBDLL int DB_eof(int handle);
|
||||
CBDLL int DB_bof(int handle);
|
||||
CBDLL int DB_go(int handle,long int recno);
|
||||
CBDLL int DB_delete(int handle);
|
||||
CBDLL int DB_recall(int handle);
|
||||
CBDLL int DB_delkey(int handle, char* key, long recno);
|
||||
CBDLL int DB_flush(int handle);
|
||||
CBDLL int DB_rewrite(int handle);
|
||||
CBDLL bool DB_has_memo(int handle);
|
||||
CBDLL int DB_add(int handle);
|
||||
CBDLL int DB_lockfile(int handle); /* Per sbloccare il record basta la DB_unlock()*/
|
||||
CBDLL int DB_packfile(short vis, const char * filename, long eod);
|
||||
CBDLL int DB_packmemo(short vis, const char * filename);
|
||||
CBDLL int DB_packindex(short vis, const char * filename, RecDes *r, long *peod, bool ask );
|
||||
CBDLL int DB_build(const char * filename, RecDes *r);
|
||||
CBDLL int DB_recinfo(const char * filename, FileDes *d, RecDes *r, char* keys);
|
||||
CBDLL int DB_get_error(void);
|
||||
CBDLL void DB_zero_error(void);
|
||||
CBDLL int DB_index_seek(int handle, char* from);
|
||||
CBDLL long DB_index_recno(int handle);
|
||||
CBDLL long DB_index_next(int handle);
|
||||
CBDLL char* DB_index_getkey(int handle);
|
||||
CBDLL int DB_index_go(int handle, const char * key, long recno);
|
||||
CBDLL char* DB_memoptr(const int handle, const char * fieldname );
|
||||
CBDLL int DB_memowrite(const int handle, const char * fieldname, const char * data ) ;
|
||||
CBDLL int DB_index_eof(int handle);
|
||||
CBDLL int DB_lock_rec(int handle,long nrec);
|
||||
CBDLL int DB_file_locked(int handle);
|
||||
CBDLL int DB_rec_locked(int handle,long nrec);
|
||||
CBDLL long DB_getconf();
|
||||
CBDLL long DB_changed(int handle); /* returns true if the index of the key is changed */
|
||||
void DB_init(void);
|
||||
void DB_exit(void);
|
||||
int DB_open(const char *filename,int mode,int index);
|
||||
int DB_close(int handle);
|
||||
char *DB_getrecord(int handle);
|
||||
int DB_reclen(int handle);
|
||||
int DB_keylen(int handle);
|
||||
long int DB_recno(int handle);
|
||||
long int DB_reccount(int handle);
|
||||
int DB_tagselect(int handle,int index_no);
|
||||
int DB_tagget(int handle);
|
||||
int DB_first(int handle);
|
||||
int DB_last(int handle);
|
||||
int DB_next(int handle);
|
||||
int DB_prev(int handle);
|
||||
int DB_skip(int handle,long int recno);
|
||||
int DB_lock(int handle);
|
||||
int DB_unlock(int handle);
|
||||
int DB_seek(int handle,char *key);
|
||||
int DB_eof(int handle);
|
||||
int DB_bof(int handle);
|
||||
int DB_go(int handle,long int recno);
|
||||
int DB_delete(int handle);
|
||||
int DB_recall(int handle);
|
||||
int DB_delkey(int handle, char* key, long recno);
|
||||
int DB_flush(int handle);
|
||||
int DB_rewrite(int handle);
|
||||
bool DB_has_memo(int handle);
|
||||
int DB_add(int handle);
|
||||
int DB_lockfile(int handle); /* Per sbloccare il record basta la DB_unlock()*/
|
||||
int DB_packfile(short vis, const char * filename, long eod);
|
||||
int DB_packmemo(short vis, const char * filename);
|
||||
int DB_packindex(short vis, const char * filename, RecDes *r, long *peod, bool ask );
|
||||
int DB_build(const char * filename, RecDes *r);
|
||||
int DB_recinfo(const char * filename, FileDes *d, RecDes *r, char* keys);
|
||||
int DB_get_error(void);
|
||||
void DB_zero_error(void);
|
||||
int DB_index_seek(int handle, char* from);
|
||||
long DB_index_recno(int handle);
|
||||
long DB_index_next(int handle);
|
||||
char* DB_index_getkey(int handle);
|
||||
int DB_index_go(int handle, const char * key, long recno);
|
||||
char* DB_memoptr(const int handle, const char * fieldname );
|
||||
int DB_memowrite(const int handle, const char * fieldname, const char * data ) ;
|
||||
int DB_index_eof(int handle);
|
||||
int DB_lock_rec(int handle,long nrec);
|
||||
int DB_file_locked(int handle);
|
||||
int DB_rec_locked(int handle,long nrec);
|
||||
long DB_getconf();
|
||||
long DB_changed(int handle); /* returns true if the index of the key is changed */
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
@ -1294,114 +1294,6 @@ const TString& TReport_field::formatted_text() const
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
|
||||
/*
|
||||
void TReport_field::draw_rect(TWindow& win) const
|
||||
{
|
||||
RCT r; win.log2dev(get_rect(), r);
|
||||
advanced_draw_rect(win, r, border(), fore_color(), back_color());
|
||||
}
|
||||
|
||||
void TReport_field::draw_text(TWindow& win, const char* text, TReport_draw_mode rdm) const
|
||||
{
|
||||
const TRectangle& rct = get_draw_rect();
|
||||
RCT r; win.log2dev(rct, r);
|
||||
advanced_draw_rect(win, r, border(), fore_color(), back_color());
|
||||
|
||||
if (rdm == rdm_preview && link().not_empty())
|
||||
{
|
||||
XVT_FNTID lnkfont = xvt_font_create();
|
||||
xvt_font_copy(lnkfont, font().get_xvt_font(win), XVT_FA_ALL);
|
||||
xvt_font_set_style(lnkfont, XVT_FS_UNDERLINE);
|
||||
xvt_dwin_set_font(win.win(), lnkfont);
|
||||
xvt_font_destroy(lnkfont);
|
||||
win.set_color(link_color(), back_color());
|
||||
}
|
||||
else
|
||||
{
|
||||
xvt_dwin_set_font(win.win(), font().get_xvt_font(win));
|
||||
win.set_color(fore_color(), back_color());
|
||||
}
|
||||
|
||||
if (rct.height() > 100) // Devo scrivere piu' righe?
|
||||
{
|
||||
const unsigned columns = rct.width() / 100;
|
||||
int rows = rct.height() / 100;
|
||||
TParagraph_string str(text, columns);
|
||||
if (str.items() < rows)
|
||||
rows = str.items();
|
||||
|
||||
int ybase = rct.y;
|
||||
switch (_valign)
|
||||
{
|
||||
case 'C': ybase += (rct.height() - rows*100) / 2; break;
|
||||
case 'B': ybase += rct.height() - rows*100; break;
|
||||
default : break;
|
||||
}
|
||||
char halign = _halign;
|
||||
char valign = 'T';
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
TRectangle rctline = rct;
|
||||
rctline.y = ybase + 100*row;
|
||||
rctline.set_height(100);
|
||||
win.log2dev(rctline, r);
|
||||
const char* line = str.get();
|
||||
if (halign == 'J' && (row == rows-1 || strlen(line) < columns/2))
|
||||
halign = 'L';
|
||||
advanced_draw_text(win, line, r, halign, valign);
|
||||
}
|
||||
}
|
||||
else
|
||||
advanced_draw_text(win, text, r, _halign, _valign);
|
||||
}
|
||||
|
||||
void TReport_field::draw(TWindow& win, TReport_draw_mode rdm) const
|
||||
{
|
||||
if (draw_hidden() || draw_deactivated())
|
||||
return;
|
||||
|
||||
RCT r; win.log2dev(get_draw_rect(), r);
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case 'E':
|
||||
if (advanced_set_draw_tools(win, border(), fore_color(), back_color()))
|
||||
xvt_dwin_draw_oval(win.win(), &r);
|
||||
break;
|
||||
case 'I':
|
||||
{
|
||||
TReport& rep = section().report();
|
||||
const TString& name = get().as_string();
|
||||
const TImage* img = rep.image(name);
|
||||
if (img != NULL && img->ok())
|
||||
img->draw(win.win(), r);
|
||||
draw_rect(win);
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
{
|
||||
advanced_set_draw_tools(win, border(), fore_color(), back_color());
|
||||
const PNT f = { r.top, r.left };
|
||||
xvt_dwin_draw_set_pos(win.win(), f);
|
||||
const PNT t = { r.bottom, r.right };
|
||||
xvt_dwin_draw_line(win.win(), t);
|
||||
}
|
||||
break;
|
||||
case 'R':
|
||||
advanced_draw_rect(win, r, border(), fore_color(), back_color());
|
||||
break;
|
||||
case 'T': draw_text(win, _picture, rdm); break;
|
||||
default :
|
||||
{
|
||||
const TString& str = formatted_text();
|
||||
if (!str.blank())
|
||||
draw_text(win, str, rdm);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
bool TReport_field::print_tools(TBook& book) const
|
||||
{
|
||||
const bool has_pen = border() > 0;
|
||||
@ -1423,9 +1315,20 @@ void TReport_field::print_rect(TBook& book) const
|
||||
|
||||
void TReport_field::print(TBook& book) const
|
||||
{
|
||||
if (draw_hidden() || draw_deactivated())
|
||||
if (draw_deactivated())
|
||||
return;
|
||||
|
||||
if (draw_hidden())
|
||||
{
|
||||
if (link().not_empty()) // Devo "stampare" i link anche se nascosti
|
||||
{
|
||||
TRectangle rct = get_draw_rect();
|
||||
rct.set_height(0); rct.set_width(0);
|
||||
book.draw_link(rct, formatted_text(), link());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_type)
|
||||
{
|
||||
case 'E':
|
||||
@ -1474,6 +1377,8 @@ void TReport_field::print(TBook& book) const
|
||||
book.set_text_align(horizontal_alignment(), vertical_alignment());
|
||||
book.set_text_color(fore_color(), back_color());
|
||||
book.draw_text(get_draw_rect(), str);
|
||||
if (link().not_empty())
|
||||
book.draw_link(get_draw_rect(), str, link());
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1680,63 +1585,6 @@ TReport_field::~TReport_field()
|
||||
delete _font;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TReport_link
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
void TReport_link::set(const char* field, const TVariant& var)
|
||||
{
|
||||
_fields.add(field, var, true);
|
||||
}
|
||||
|
||||
const TVariant& TReport_link::get(const char* field) const
|
||||
{
|
||||
const TVariant* var = (const TVariant*)_fields.objptr(field);
|
||||
return var != NULL ? *var : NULL_VARIANT;
|
||||
}
|
||||
|
||||
void TReport_link::add_rect(const RCT& rct)
|
||||
{
|
||||
// Non memorizzo tutti i rettangoli del link, ma la loro unione
|
||||
if (xvt_rect_is_empty(&_rct))
|
||||
_rct = rct;
|
||||
else
|
||||
{
|
||||
if (rct.left < _rct.left) _rct.left = rct.left;
|
||||
if (rct.top < _rct.top) _rct.top = rct.top;
|
||||
if (rct.right > _rct.right) _rct.right = rct.right;
|
||||
if (rct.bottom > _rct.bottom) _rct.bottom = rct.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
int TReport_link::hit_test(const PNT& p) const
|
||||
{
|
||||
if (p.v < _rct.top)
|
||||
return -1;
|
||||
if (p.v > _rct.bottom)
|
||||
return +1;
|
||||
if (p.h < _rct.left)
|
||||
return -1;
|
||||
if (p.h > _rct.right)
|
||||
return +1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TReport_link::compare(const TSortable& s) const
|
||||
{
|
||||
const TReport_link& lnk = (const TReport_link&)s;
|
||||
int cmp = _rct.top - lnk._rct.top;
|
||||
if (cmp == 0)
|
||||
cmp = _rct.left - lnk._rct.left;
|
||||
return cmp;
|
||||
}
|
||||
|
||||
TReport_link::TReport_link(const char* table)
|
||||
: _table(table)
|
||||
{
|
||||
xvt_rect_set_empty(&_rct);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TReport
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -2556,8 +2404,8 @@ bool TReport::on_link(const TReport_link& lnk)
|
||||
TAssoc_array& fields = lnk.fields();
|
||||
FOR_EACH_ASSOC_OBJECT(fields, h, k, o)
|
||||
{
|
||||
const TVariant* var = (const TVariant*)o;
|
||||
rec.put(k, var->as_string());
|
||||
const TString* var = (const TString*)o;
|
||||
rec.put(k, *var);
|
||||
}
|
||||
return rec.edit();
|
||||
}
|
||||
|
@ -382,8 +382,8 @@ protected:
|
||||
|
||||
public:
|
||||
const TString& table() const { return _table; }
|
||||
void set(const char* field, const TVariant& value);
|
||||
const TVariant& get(const char* field) const;
|
||||
void set(const char* field, const TString& value);
|
||||
const TString& get(const char* field) const;
|
||||
void add_rect(const RCT& rct); // Aggiunge un rettangolo al link
|
||||
int hit_test(const PNT& p) const;
|
||||
|
||||
|
@ -11,32 +11,62 @@
|
||||
|
||||
static bool _print_aborted = false;
|
||||
|
||||
/*
|
||||
const TReport_link* TPage_printer::find_link(const PNT& pnt) const
|
||||
{
|
||||
if (!_links_sorted)
|
||||
{
|
||||
TPage_printer* myself = (TPage_printer*)this;
|
||||
myself->_links.sort();
|
||||
myself->_links_sorted = true;
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
// TReport_link
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
int primo = 0, ultimo = _links.last();
|
||||
while (primo <= ultimo)
|
||||
{
|
||||
const int in_mezzo = (primo+ultimo)/2;
|
||||
const TReport_link* lnk = (const TReport_link*)_links.objptr(in_mezzo);
|
||||
const int cmp = lnk->hit_test(pnt);
|
||||
if (cmp == 0)
|
||||
return lnk;
|
||||
if (cmp < 0)
|
||||
ultimo = in_mezzo-1;
|
||||
else
|
||||
primo = in_mezzo+1;
|
||||
}
|
||||
return NULL;
|
||||
void TReport_link::set(const char* field, const TString& var)
|
||||
{
|
||||
_fields.add(field, var, true);
|
||||
}
|
||||
|
||||
const TString& TReport_link::get(const char* field) const
|
||||
{
|
||||
const TString* var = (const TString*)_fields.objptr(field);
|
||||
return var != NULL ? *var : (const TString&)EMPTY_STRING;
|
||||
}
|
||||
|
||||
void TReport_link::add_rect(const RCT& rct)
|
||||
{
|
||||
// Non memorizzo tutti i rettangoli del link, ma la loro unione
|
||||
if (xvt_rect_is_empty(&_rct))
|
||||
_rct = rct;
|
||||
else
|
||||
{
|
||||
if (rct.left < _rct.left) _rct.left = rct.left;
|
||||
if (rct.top < _rct.top) _rct.top = rct.top;
|
||||
if (rct.right > _rct.right) _rct.right = rct.right;
|
||||
if (rct.bottom > _rct.bottom) _rct.bottom = rct.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
int TReport_link::hit_test(const PNT& p) const
|
||||
{
|
||||
if (p.v < _rct.top)
|
||||
return -1;
|
||||
if (p.v > _rct.bottom)
|
||||
return +1;
|
||||
if (p.h < _rct.left)
|
||||
return -1;
|
||||
if (p.h > _rct.right)
|
||||
return +1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TReport_link::compare(const TSortable& s) const
|
||||
{
|
||||
const TReport_link& lnk = (const TReport_link&)s;
|
||||
int cmp = _rct.top - lnk._rct.top;
|
||||
if (cmp == 0)
|
||||
cmp = _rct.left - lnk._rct.left;
|
||||
return cmp;
|
||||
}
|
||||
|
||||
TReport_link::TReport_link(const char* table)
|
||||
: _table(table)
|
||||
{
|
||||
xvt_rect_set_empty(&_rct);
|
||||
}
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TPrint_preview_window
|
||||
@ -47,10 +77,16 @@ class TPrint_preview_window : public TField_window
|
||||
TBook* _book;
|
||||
word _page;
|
||||
int _zoom;
|
||||
bool _grid;
|
||||
|
||||
TAssoc_array _alinks;
|
||||
TPointer_array _plinks;
|
||||
|
||||
protected:
|
||||
void page_select();
|
||||
void popup_menu(EVENT* ep);
|
||||
const TReport_link* find_link(const PNT& pnt) const;
|
||||
|
||||
virtual void handler(WINDOW win, EVENT* ep);
|
||||
virtual void update();
|
||||
virtual bool on_key(KEY k);
|
||||
@ -60,6 +96,8 @@ protected:
|
||||
|
||||
public:
|
||||
virtual PNT log2dev(long lx, long ly) const;
|
||||
TAssoc_array& alinks() { return _alinks; }
|
||||
TPointer_array& plinks() { return _plinks; }
|
||||
|
||||
TPrint_preview_window(int x, int y, int dx, int dy, WINDOW parent,
|
||||
TWindowed_field* owner, TBook* book);
|
||||
@ -110,6 +148,29 @@ void TPrint_preview_window::update()
|
||||
set_brush(COLOR_WHITE);
|
||||
xvt_dwin_draw_rect(win(), &rct);
|
||||
|
||||
if (_grid)
|
||||
{
|
||||
const TPoint res = _book->page_res();
|
||||
const int lpi = _book->lpi();
|
||||
for (int i = 1; ; i++)
|
||||
{
|
||||
set_pen(i%lpi ? MAKE_COLOR(232,232,255) : MAKE_COLOR(255,192,255));
|
||||
const short y = i * res.y / lpi;
|
||||
if (y > size.y)
|
||||
break;
|
||||
line(0, y, (short)size.x, y);
|
||||
}
|
||||
const int cpi = _book->cpi();
|
||||
for (int j = 1; ; j++)
|
||||
{
|
||||
set_pen(j%10 ? MAKE_COLOR(232,232,255) : MAKE_COLOR(255,192,255));
|
||||
const short x = j * res.x / cpi;
|
||||
if (x > size.x)
|
||||
break;
|
||||
line(x, 0, x, (short)size.y);
|
||||
}
|
||||
}
|
||||
|
||||
_book->print_page(*this, _page);
|
||||
|
||||
TString80 str; str.format(FR("Pagina %u di %u"), _page, _book->pages());
|
||||
@ -129,16 +190,16 @@ void TPrint_preview_window::popup_menu(EVENT* ep)
|
||||
{
|
||||
MENU_ITEM menu[16]; // Stiamo larghi
|
||||
memset(menu, 0, sizeof(menu));
|
||||
menu[0].tag = POPUP_FIRST; menu[0].text = (char*)TR("Prima"); menu[0].enabled = true;
|
||||
menu[0].tag = POPUP_FIRST; menu[0].text = (char*)TR("Prima"); menu[0].enabled = _page > 1;
|
||||
menu[1].tag = POPUP_PREV; menu[1].text = (char*)TR("Indietro"); menu[1].enabled = _page > 1;
|
||||
menu[2].tag = POPUP_NEXT; menu[2].text = (char*)TR("Avanti"); menu[2].enabled = _page < _book->pages();
|
||||
menu[3].tag = POPUP_LAST; menu[3].text = (char*)TR("Ultima"); menu[3].enabled = true;
|
||||
menu[3].tag = POPUP_LAST; menu[3].text = (char*)TR("Ultima"); menu[3].enabled = _page < _book->pages();
|
||||
menu[4].tag = -1; menu[4].separator = true;
|
||||
menu[5].tag = POPUP_ZOOMIN; menu[5].text = (char*)TR("Zoom +"); menu[5].enabled = _zoom < 300;
|
||||
menu[6].tag = POPUP_ZOOMOUT; menu[6].text = (char*)TR("Zoom -"); menu[6].enabled = _zoom > 50;
|
||||
menu[7].tag = -1; menu[7].separator = true;
|
||||
menu[8].tag = POPUP_GRID; menu[8].text = (char*)TR("Griglia"); menu[8].enabled = false;
|
||||
menu[8].checkable = true; menu[8].checked = false;
|
||||
menu[8].tag = POPUP_GRID; menu[8].text = (char*)TR("Griglia"); menu[8].enabled = true;
|
||||
menu[8].checkable = true; menu[8].checked = _grid;
|
||||
|
||||
const PNT& p = ep->v.mouse.where;
|
||||
xvt_menu_popup(menu, win(), p, XVT_POPUP_CENTER, 0);
|
||||
@ -151,16 +212,37 @@ void TPrint_preview_window::page_select()
|
||||
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
|
||||
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
|
||||
if (m.run())
|
||||
{
|
||||
_page = m.get_int(101);
|
||||
if (_page < 1) _page = 1;
|
||||
if (_page > _book->pages()) _page = _book->pages();
|
||||
}
|
||||
}
|
||||
|
||||
const TReport_link* TPrint_preview_window::find_link(const PNT& pnt) const
|
||||
{
|
||||
int primo = 0, ultimo = _plinks.last();
|
||||
while (primo <= ultimo)
|
||||
{
|
||||
const int in_mezzo = (primo+ultimo)/2;
|
||||
const TReport_link* lnk = (const TReport_link*)_plinks.objptr(in_mezzo);
|
||||
const int cmp = lnk->hit_test(pnt);
|
||||
if (cmp == 0)
|
||||
return lnk;
|
||||
if (cmp < 0)
|
||||
ultimo = in_mezzo-1;
|
||||
else
|
||||
primo = in_mezzo+1;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TPrint_preview_window::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
switch (ep->type)
|
||||
{
|
||||
/*
|
||||
case E_MOUSE_MOVE:
|
||||
if (_printer->find_link(ep->v.mouse.where) != NULL)
|
||||
if (find_link(ep->v.mouse.where) != NULL)
|
||||
xvt_win_set_cursor(win, CURSOR_CROSS);
|
||||
else
|
||||
xvt_win_set_cursor(win, CURSOR_ARROW);
|
||||
@ -168,14 +250,13 @@ void TPrint_preview_window::handler(WINDOW win, EVENT* ep)
|
||||
case E_MOUSE_DOWN:
|
||||
if (ep->v.mouse.button == 0)
|
||||
{
|
||||
const TReport_link* lnk = _printer->find_link(ep->v.mouse.where);
|
||||
if (lnk != NULL)
|
||||
_printer->on_link(*lnk);
|
||||
const TReport_link* lnk = find_link(ep->v.mouse.where);
|
||||
if (lnk != NULL && _book != NULL)
|
||||
_book->on_link(*lnk);
|
||||
}
|
||||
else
|
||||
popup_menu(ep);
|
||||
break;
|
||||
*/
|
||||
case E_COMMAND:
|
||||
{
|
||||
bool processed = true;
|
||||
@ -200,20 +281,34 @@ void TPrint_preview_window::handler(WINDOW win, EVENT* ep)
|
||||
break;
|
||||
case POPUP_ZOOMIN : if (_zoom < 300) { _zoom += 25; update_scroll_range(); } break;
|
||||
case POPUP_ZOOMOUT: if (_zoom > 50) { _zoom -= 25; update_scroll_range(); } break;
|
||||
case POPUP_GRID : break;
|
||||
case POPUP_GRID : _grid = !_grid; break;
|
||||
default:processed = false; break;
|
||||
}
|
||||
if (processed)
|
||||
{
|
||||
_print_aborted = false;
|
||||
force_update();
|
||||
}
|
||||
break;
|
||||
case E_HSCROLL:
|
||||
case E_VSCROLL:
|
||||
{
|
||||
int kx = 0, ky = 0;
|
||||
int& k = ep->type == E_HSCROLL ? kx : ky;
|
||||
switch(ep->v.scroll.what)
|
||||
{
|
||||
case SC_PAGE_UP : k = -3; break;
|
||||
case SC_LINE_UP : k = -1; break;
|
||||
case SC_PAGE_DOWN: k = +3; break;
|
||||
case SC_LINE_DOWN: k = +1; break;
|
||||
default : TField_window::handler(win, ep); break;
|
||||
}
|
||||
if (k != 0)
|
||||
do_scroll(kx, ky); break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
TField_window::handler(win, ep);
|
||||
break;
|
||||
}
|
||||
TField_window::handler(win, ep);
|
||||
}
|
||||
|
||||
void TPrint_preview_window::do_scroll(int kx, int ky)
|
||||
@ -259,8 +354,9 @@ bool TPrint_preview_window::on_key(KEY k)
|
||||
|
||||
TPrint_preview_window::TPrint_preview_window(int x, int y, int dx, int dy, WINDOW parent,
|
||||
TWindowed_field* owner, TBook* book)
|
||||
: TField_window(x, y, dx, dy, parent, owner), _book(book), _page(1), _zoom(100)
|
||||
: TField_window(x, y, dx, dy, parent, owner), _book(book), _page(1), _zoom(100), _grid(true)
|
||||
{
|
||||
_pixmap = true;
|
||||
update_scroll_range();
|
||||
}
|
||||
|
||||
@ -297,8 +393,10 @@ protected:
|
||||
virtual bool on_key(KEY k);
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
virtual TMask_field* parse_field(TScanner& scanner);
|
||||
|
||||
virtual void handler(WINDOW win, EVENT* ep);
|
||||
|
||||
public:
|
||||
void export();
|
||||
TPreview_mask(TBook* book);
|
||||
};
|
||||
|
||||
@ -314,6 +412,8 @@ bool TPreview_mask::on_key(KEY k)
|
||||
case K_RIGHT:
|
||||
case K_END :
|
||||
case K_LEND :
|
||||
case K_PREV :
|
||||
case K_NEXT :
|
||||
case 'G' :
|
||||
case 'g' :
|
||||
dispatch_e_char(_pvf->win().win(), k);
|
||||
@ -324,6 +424,22 @@ bool TPreview_mask::on_key(KEY k)
|
||||
return TAutomask::on_key(k);
|
||||
}
|
||||
|
||||
void TPreview_mask::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
// Riflessione eventi di scroll
|
||||
if (ep->type == E_HSCROLL || ep->type == E_VSCROLL)
|
||||
::dispatch_event(_pvf->win().win(), *ep, false);
|
||||
|
||||
TAutomask::handler(win, ep);
|
||||
}
|
||||
|
||||
void TPreview_mask::export()
|
||||
{
|
||||
TFilename n; n.temp(NULL, "txt");
|
||||
if (_book->export_text(n))
|
||||
xvt_sys_goto_url(n, "open");
|
||||
}
|
||||
|
||||
bool TPreview_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
if (e == fe_button)
|
||||
@ -335,6 +451,7 @@ bool TPreview_mask::on_field_event(TOperable_field& o, TField_event e, long joll
|
||||
case DLG_FINDREC : dispatch_e_menu(_pvf->win().win(), POPUP_SEARCH);break;
|
||||
case DLG_NEXTREC : dispatch_e_menu(_pvf->win().win(), POPUP_NEXT); break;
|
||||
case DLG_LASTREC : dispatch_e_menu(_pvf->win().win(), POPUP_LAST); break;
|
||||
case DLG_EDIT : export(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -353,7 +470,7 @@ TMask_field* TPreview_mask::parse_field(TScanner& scanner)
|
||||
|
||||
TPreview_mask::TPreview_mask(TBook* book) : _book(book)
|
||||
{
|
||||
read_mask("ba8303", 0, -1);
|
||||
read_mask("bagn008", 0, -1);
|
||||
set_handlers();
|
||||
|
||||
int pos = id2pos(DLG_FINDREC);
|
||||
@ -518,7 +635,9 @@ void TBook::set_pen(COLOR color, int width, PEN_STYLE style)
|
||||
_tools.pen.color = color;
|
||||
_tools.pen.width = width;
|
||||
_tools.pen.style = style;
|
||||
*_out << "<pen color=" << color << " width=" << width << " style=" << style << " />" << endl;
|
||||
*_out << "<pen color=" << color
|
||||
<< " width=" << width
|
||||
<< " style=" << style << " />" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -534,7 +653,15 @@ void TBook::set_brush(COLOR color, PAT_STYLE pattern)
|
||||
|
||||
void TBook::set_text_color(COLOR fore, COLOR back, bool opaque)
|
||||
{
|
||||
*_out << "<text_color fore=" << fore << " back=" << back << " opaque=" << opaque << " />" << endl;
|
||||
if (_tools.fore_color != fore || _tools.back_color != back || _tools.opaque_text != short(opaque))
|
||||
{
|
||||
_tools.fore_color = fore;
|
||||
_tools.back_color = back;
|
||||
_tools.opaque_text = opaque;
|
||||
*_out << "<text_color fore=" << fore
|
||||
<< " back=" << back
|
||||
<< " opaque=" << opaque << " />" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void TBook::set_text_align(char halign, char valign)
|
||||
@ -567,7 +694,8 @@ void TBook::draw_line(const TRectangle& r)
|
||||
|
||||
void TBook::draw_link(const TRectangle& rect, const char* text, const char* link)
|
||||
{
|
||||
draw_text(rect, text);
|
||||
define_frame(rect);
|
||||
*_out << "<a href=\"" << link << "\" >" << text << "</a>" << endl;
|
||||
}
|
||||
|
||||
void TBook::draw_image(const TRectangle& rect, const char* name)
|
||||
@ -621,6 +749,15 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
{
|
||||
if (page <= 0 || page > pages())
|
||||
return false;
|
||||
|
||||
const bool preview = win.win() != 883;
|
||||
RCT visible;
|
||||
if (preview)
|
||||
{
|
||||
xvt_vobj_get_client_rect(win.win(), &visible);
|
||||
TPrint_preview_window& pw = (TPrint_preview_window&)win;
|
||||
pw.alinks().destroy();
|
||||
}
|
||||
|
||||
TString str(1024);
|
||||
char* buffer = str.get_buffer();
|
||||
@ -629,7 +766,8 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
ifstream ifs(_file);
|
||||
ifs.seekg(pos);
|
||||
|
||||
RCT rct;
|
||||
_rect.set(-1,-1,0,0); // Reset frame
|
||||
RCT rct = { 0,0,0,0 };
|
||||
|
||||
while (!ifs.eof())
|
||||
{
|
||||
@ -637,7 +775,54 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
if (str.starts_with("</page"))
|
||||
break;
|
||||
|
||||
if (str.starts_with("<brush"))
|
||||
if (str.starts_with("<a "))
|
||||
{
|
||||
if (preview && rct.bottom >= visible.top && rct.top <= visible.bottom)
|
||||
{
|
||||
TString link;
|
||||
if (get_xml_string(str, "href", link))
|
||||
{
|
||||
TPrint_preview_window& pw = (TPrint_preview_window&)win;
|
||||
TAssoc_array& links = pw.alinks();
|
||||
|
||||
TToken_string tok(link, '.');
|
||||
TString80 table, field, key;
|
||||
tok.get(0, table); tok.get(1, field);
|
||||
|
||||
key << table << ',' << _rect.y;
|
||||
TReport_link* rl = (TReport_link*)links.objptr(key);
|
||||
if (rl == NULL)
|
||||
{
|
||||
rl = new TReport_link(table);
|
||||
links.add(key, rl);
|
||||
}
|
||||
|
||||
const int inizio = str.find('>')+1;
|
||||
const int fine = str.rfind('<');
|
||||
const TString& stringona = str.sub(inizio, fine);
|
||||
rl->set(field, stringona);
|
||||
rl->add_rect(rct);
|
||||
|
||||
if (!stringona.blank() && rct.right > rct.left) // Possono esserci campi chiave nascosti
|
||||
{
|
||||
DRAW_CTOOLS dct;
|
||||
xvt_dwin_get_draw_ctools(win.win(), &dct);
|
||||
|
||||
XVT_FNTID oldfont = xvt_dwin_get_font(win.win());
|
||||
XVT_FNTID newfont = xvt_font_create();
|
||||
xvt_font_copy(newfont, oldfont, XVT_FA_ALL);
|
||||
xvt_font_set_style(newfont, xvt_font_get_style(oldfont) | XVT_FS_UNDERLINE);
|
||||
xvt_dwin_set_font(win.win(), newfont);
|
||||
win.set_color(COLOR_BLUE, dct.back_color);
|
||||
advanced_draw_text(win, stringona, rct, _horizontal_alignment, _vertical_alignment);
|
||||
win.set_color(dct.fore_color, dct.back_color);
|
||||
xvt_dwin_set_font(win.win(), oldfont);
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<brush "))
|
||||
{
|
||||
COLOR col = COLOR_BLACK;
|
||||
PAT_STYLE pat = PAT_SOLID;
|
||||
@ -653,7 +838,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
xvt_dwin_draw_oval(win.win(), &rct);
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<frame"))
|
||||
if (str.starts_with("<frame "))
|
||||
{
|
||||
long x, y, dx, dy;
|
||||
sscanf(str, "<frame x=%ld y=%ld dx=%ld dy=%ld />", &x, &y, &dx, &dy);
|
||||
@ -661,7 +846,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
win.log2dev(_rect, rct);
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<font"))
|
||||
if (str.starts_with("<font "))
|
||||
{
|
||||
TString name = XVT_FFN_COURIER; get_xml_string(str, "name", name);
|
||||
const int size = get_xml_int(str, "size", 12);
|
||||
@ -673,7 +858,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
xvt_dwin_set_font(win.win(), font.get_preview_font(win, page_res()));
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<image"))
|
||||
if (str.starts_with("<image "))
|
||||
{
|
||||
TString name; get_xml_string(str, "src", name);
|
||||
TImage* img = _images.image(name);
|
||||
@ -687,7 +872,7 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
xvt_dwin_draw_set_pos(win.win(), fr);
|
||||
xvt_dwin_draw_line(win.win(), to);
|
||||
}
|
||||
if (str.starts_with("<pen"))
|
||||
if (str.starts_with("<pen "))
|
||||
{
|
||||
COLOR col = COLOR_BLACK;
|
||||
int width = 0;
|
||||
@ -719,10 +904,10 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
break;
|
||||
stringona << str;
|
||||
}
|
||||
advanced_draw_paragraph(win, stringona, rct, _horizontal_alignment, _vertical_alignment);
|
||||
advanced_draw_text(win, stringona, rct, _horizontal_alignment, _vertical_alignment);
|
||||
continue;
|
||||
}
|
||||
if (str.starts_with("<text_align"))
|
||||
if (str.starts_with("<text_align "))
|
||||
{
|
||||
sscanf(str, "<text_align horizontal=%c vertical=%c />",
|
||||
&_horizontal_alignment, &_vertical_alignment);
|
||||
@ -739,6 +924,89 @@ bool TBook::print_page(TWindow& win, size_t page)
|
||||
}
|
||||
}
|
||||
|
||||
if (preview)
|
||||
{
|
||||
TPrint_preview_window& pw = (TPrint_preview_window&)win;
|
||||
TAssoc_array& alinks = pw.alinks();
|
||||
TPointer_array& plinks = pw.plinks();
|
||||
plinks.destroy();
|
||||
if (alinks.items() > 0)
|
||||
{
|
||||
FOR_EACH_ASSOC_OBJECT(alinks, h, key, l)
|
||||
plinks.add((TReport_link*)l);
|
||||
plinks.sort();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TBook::export_text(const TFilename& fname) const
|
||||
{
|
||||
TString str(1024);
|
||||
char* buffer = str.get_buffer();
|
||||
|
||||
ifstream ifs(_file);
|
||||
ofstream ofs(fname);
|
||||
|
||||
TString_array page;
|
||||
int row, col, wid;
|
||||
|
||||
const TPoint res = page_res();
|
||||
|
||||
while (!ifs.eof())
|
||||
{
|
||||
ifs.getline(buffer, str.size());
|
||||
|
||||
if (str.starts_with("<frame "))
|
||||
{
|
||||
long x, y, dx, dy;
|
||||
sscanf(str, "<frame x=%ld y=%ld dx=%ld dy=%ld />", &x, &y, &dx, &dy);
|
||||
row = y * lpi() / res.y;
|
||||
col = x * cpi() / res.x;
|
||||
wid = dx * cpi() / res.x;
|
||||
} else
|
||||
if (str.starts_with("<page "))
|
||||
{
|
||||
page.destroy();
|
||||
} else
|
||||
if (str.starts_with("</page "))
|
||||
{
|
||||
const int last_row = page.last();
|
||||
for (int i = 0; i <= last_row; i++)
|
||||
{
|
||||
const TString* line = (const TString*)page.objptr(i);
|
||||
if (line != NULL)
|
||||
ofs << *line;
|
||||
ofs << endl;
|
||||
}
|
||||
} else
|
||||
if (str == "<text>")
|
||||
{
|
||||
while (!ifs.eof())
|
||||
{
|
||||
ifs.getline(buffer, str.size());
|
||||
if (str == "</text>")
|
||||
break;
|
||||
if (page.objptr(row) == NULL)
|
||||
page.add("", row);
|
||||
TString& line = page.row(row++);
|
||||
switch (_horizontal_alignment)
|
||||
{
|
||||
case 'C': line.overwrite(str, col+(wid-str.len())/2); break;
|
||||
case 'R': line.overwrite(str, col+wid-str.len()); break;
|
||||
default : line.overwrite(str, col); break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (str.starts_with("<text_align "))
|
||||
{
|
||||
sscanf(str, "<text_align horizontal=%c vertical=%c />",
|
||||
&_horizontal_alignment, &_vertical_alignment);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -844,7 +1112,7 @@ bool TBook::preview()
|
||||
{
|
||||
TPreview_mask msk(this);
|
||||
const KEY k = msk.run();
|
||||
if (k != K_QUIT)
|
||||
if (k != K_QUIT)
|
||||
print();
|
||||
return true;
|
||||
}
|
||||
@ -960,38 +1228,6 @@ bool TReport_book::close_page()
|
||||
return TBook::close_page();
|
||||
}
|
||||
|
||||
void TReport_book::create_links(const TReport_section& rs)
|
||||
{
|
||||
/*
|
||||
TAssoc_array* links = NULL;
|
||||
for (int i = 0; i < rs.items(); i++)
|
||||
{
|
||||
const TReport_field& rf = rs.field(i);
|
||||
if (rf.link().not_empty())
|
||||
{
|
||||
if (links == NULL)
|
||||
links = new TAssoc_array;
|
||||
TToken_string tok(rf.link(), '.');
|
||||
TString table, field;
|
||||
tok.get(0, table); tok.get(1, field);
|
||||
TReport_link* rl = (TReport_link*)links->objptr(table);
|
||||
if (rl == NULL)
|
||||
{
|
||||
rl = new TReport_link(table);
|
||||
links->add(table, rl);
|
||||
}
|
||||
rl->add_rect(rf.get_draw_rect());
|
||||
rl->set(field, rf.get());
|
||||
}
|
||||
}
|
||||
if (links != NULL)
|
||||
{
|
||||
FOR_EACH_ASSOC_OBJECT((*links), h, key, l)
|
||||
add_link((TReport_link*)l);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void TReport_book::reprint_group_headers()
|
||||
{
|
||||
const int max_group = _report->find_max_level('H');
|
||||
@ -1221,6 +1457,20 @@ bool TReport_book::add(TReport& rep)
|
||||
return true;
|
||||
}
|
||||
|
||||
int TReport_book::lpi() const
|
||||
{
|
||||
if (_report != NULL)
|
||||
return _report->lpi();
|
||||
return TBook::lpi();
|
||||
}
|
||||
|
||||
int TReport_book::cpi() const
|
||||
{
|
||||
if (_report != NULL)
|
||||
return _report->cpi();
|
||||
return TBook::cpi();
|
||||
}
|
||||
|
||||
bool TReport_book::print(size_t pagefrom, size_t pageto, size_t copies)
|
||||
{
|
||||
if (pages() <= 0)
|
||||
@ -1254,6 +1504,13 @@ bool TReport_book::print(size_t pagefrom, size_t pageto, size_t copies)
|
||||
return TBook::print(pagefrom, pageto, copies);
|
||||
}
|
||||
|
||||
bool TReport_book::on_link(const TReport_link& lnk)
|
||||
{
|
||||
bool ok = false;
|
||||
if (_report != NULL)
|
||||
ok = _report->on_link(lnk);
|
||||
return ok;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Remote control interface
|
||||
|
@ -51,11 +51,15 @@ public:
|
||||
TPoint page_res() const;
|
||||
size_t page() const { return _page; }
|
||||
size_t pages() const { return _pages; }
|
||||
virtual int lpi() const { return 6; }
|
||||
virtual int cpi() const { return 10; }
|
||||
|
||||
virtual bool print_page(TWindow& win, size_t page);
|
||||
virtual bool on_link(const TReport_link&) { return false; }
|
||||
|
||||
virtual bool print(size_t pagefrom = 0, size_t pageto = 0, size_t copies = 0);
|
||||
virtual bool preview();
|
||||
virtual bool export_text(const TFilename& fname) const;
|
||||
bool print_or_preview(); // Calls one of the above
|
||||
|
||||
TBook(const char* name);
|
||||
@ -77,16 +81,18 @@ protected:
|
||||
|
||||
TPoint log2dev(const TPoint& ptlog) const;
|
||||
virtual void define_frame(const TRectangle& r);
|
||||
virtual bool on_link(const TReport_link& lnk);
|
||||
|
||||
bool init(TReport& rep);
|
||||
void reprint_group_headers();
|
||||
long print_section(TReport_section& rs);
|
||||
long print_section(char type, int level);
|
||||
void create_links(const TReport_section& rs);
|
||||
|
||||
public:
|
||||
bool add(TReport& report);
|
||||
|
||||
virtual int lpi() const;
|
||||
virtual int cpi() const;
|
||||
virtual bool print(size_t pagefrom = 0, size_t pageto = 0, size_t copies = 0);
|
||||
|
||||
TReport_book(const char* name = NULL) : TBook(name) { }
|
||||
|
@ -31,6 +31,7 @@ struct TPoint
|
||||
// @cmember Confronta se due punti sono diversi (TRUE se diversi)
|
||||
bool operator !=(const TPoint& p) const { return p.x != x || p.y != y; }
|
||||
TPoint& operator +=(const TPoint& pnt) { x += pnt.x; y += pnt.y; return *this; }
|
||||
TPoint& operator -=(const TPoint& pnt) { x -= pnt.x; y -= pnt.y; return *this; }
|
||||
void reset() { x = y = 0; }
|
||||
|
||||
// @cmember Costruttori
|
||||
|
Loading…
x
Reference in New Issue
Block a user