Patch level : 2.1 nopatch
Files correlati : ba8 Ricompilazione Demo : [ ] Commento : Gestione clipboard in editor di form git-svn-id: svn://10.65.10.50/trunk@11887 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
6d32436f9e
commit
ad8820eada
@ -1564,14 +1564,12 @@ void TManutenzione_app::main_loop()
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
enable_menu_item(M_FILE_NEW);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int ba1100(int argc, char** argv)
|
||||
{
|
||||
{
|
||||
TManutenzione_app a;
|
||||
a.run(argc, argv, TR("Gestione files"));
|
||||
return 0;
|
||||
|
@ -1320,6 +1320,7 @@ void TQuery_mask::handler(WINDOW wnd, EVENT* ep)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
TAutomask::handler(wnd, ep);
|
||||
}
|
||||
|
||||
TQuery_mask::TQuery_mask() : TAutomask("ba8200a"), _curr_num(0), _is_dirty(false)
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ba8200.h"
|
||||
|
||||
PAGE "Nuova tabella" -1 -1 50 15
|
||||
PAGE "Tabella" -1 -1 50 15
|
||||
|
||||
GROUP DLG_NULL 24 4
|
||||
BEGIN
|
||||
|
584
ba/ba8300.cpp
584
ba/ba8300.cpp
@ -2,6 +2,7 @@
|
||||
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <colors.h>
|
||||
#include <defmask.h>
|
||||
#include <execp.h>
|
||||
#include <image.h>
|
||||
@ -92,17 +93,26 @@ class TReport_window : public TField_window
|
||||
PNT _pt_drag_offset;
|
||||
RCT _rct_drag;
|
||||
|
||||
TArray _clipboard;
|
||||
|
||||
protected:
|
||||
virtual void handler(WINDOW win, EVENT* ep);
|
||||
virtual void update();
|
||||
virtual bool on_key(KEY k);
|
||||
|
||||
void draw_square(int x, int y, int dx, int dy);
|
||||
protected:
|
||||
void draw_square(int x, int y, int s);
|
||||
void draw_field(const TReport_field& f);
|
||||
void draw_grid();
|
||||
void draw_fields();
|
||||
void snap_drag(PNT& pnt) const;
|
||||
void draw_dragster();
|
||||
|
||||
void popup_menu(EVENT* ep);
|
||||
void popup_cut();
|
||||
void popup_copy();
|
||||
void popup_paste();
|
||||
|
||||
int cpi() const;
|
||||
int lpi() const;
|
||||
|
||||
@ -119,6 +129,8 @@ public:
|
||||
void select(const RCT& rct);
|
||||
void offset_selection(const TPoint& p);
|
||||
|
||||
void set_report(TReport* rep) { _report = rep; }
|
||||
|
||||
TReport_window(int x, int y, int dx, int dy, WINDOW parent, TWindowed_field* owner);
|
||||
virtual ~TReport_window() { }
|
||||
};
|
||||
@ -132,34 +144,44 @@ TReport_section& TReport_window::curr_section() const
|
||||
return tree.curr_section();
|
||||
}
|
||||
|
||||
void TReport_window::draw_square(int x, int y, int dx, int dy)
|
||||
void TReport_window::draw_square(int x, int y, int s)
|
||||
{
|
||||
RCT rct; rct.left = x; rct.top = y; rct.right = x+dx; rct.bottom = y+dy;
|
||||
RCT rct; rct.left = x; rct.top = y; rct.right = x+s; rct.bottom = y+s;
|
||||
xvt_dwin_draw_rect(win(), &rct);
|
||||
}
|
||||
|
||||
void TReport_window::draw_field(const TReport_field& f)
|
||||
{
|
||||
set_pen(f.color());
|
||||
RCT r; f.get_rect(r);
|
||||
log2dev(r, r);
|
||||
|
||||
if (f.type() != 'L')
|
||||
{
|
||||
set_brush(COLOR_WHITE, PAT_HOLLOW);
|
||||
if (f.border() > 0)
|
||||
set_pen(f.fore_color(), f.border());
|
||||
else
|
||||
set_pen(COLOR_LTGRAY);
|
||||
set_brush(f.back_color(), PAT_SOLID);
|
||||
xvt_dwin_draw_rect(win(), &r);
|
||||
}
|
||||
|
||||
switch (f.type())
|
||||
{
|
||||
case 'L':
|
||||
{
|
||||
set_pen(f.fore_color());
|
||||
PNT f = { r.top, r.left };
|
||||
PNT t = { r.bottom, r.right };
|
||||
xvt_dwin_draw_set_pos(win(), f);
|
||||
xvt_dwin_draw_line(win(), t);
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
case 'N':
|
||||
case 'S':
|
||||
case 'T':
|
||||
{
|
||||
set_color(f.color(), COLOR_WHITE);
|
||||
set_color(f.fore_color(), f.back_color());
|
||||
XVT_FNTID fid = f.font().get_xvt_font(win(), _dpi.h);
|
||||
xvt_dwin_set_font(win(), fid);
|
||||
const int delta = (r.bottom-r.top)/4;
|
||||
@ -170,15 +192,13 @@ void TReport_window::draw_field(const TReport_field& f)
|
||||
break;
|
||||
}
|
||||
|
||||
if (f.type() != 'L' && f.selected())
|
||||
if (f.selected())
|
||||
{
|
||||
set_pen(COLOR_BLACK);
|
||||
set_brush(COLOR_BLACK);
|
||||
const int s = 5;
|
||||
draw_square(r.left, r.top, s, s);
|
||||
draw_square(r.right-s, r.top, s, s);
|
||||
draw_square(r.right-s, r.bottom-s, s, s);
|
||||
draw_square(r.left, r.bottom-s, s, s);
|
||||
draw_square(r.left, r.top, s);
|
||||
draw_square(r.right-s, r.bottom-s, s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,6 +298,7 @@ void TReport_window::draw_dragster()
|
||||
{
|
||||
set_mode(M_XOR);
|
||||
set_pen(COLOR_CYAN);
|
||||
set_brush(COLOR_WHITE, PAT_NONE);
|
||||
xvt_dwin_draw_rect(win(), &_rct_drag);
|
||||
set_mode(M_COPY);
|
||||
}
|
||||
@ -290,11 +311,112 @@ void TReport_window::snap_drag(PNT& pnt) const
|
||||
pnt.v = (pnt.v / ky) * ky;
|
||||
}
|
||||
|
||||
bool TReport_window::on_key(KEY k)
|
||||
{
|
||||
switch (k)
|
||||
{
|
||||
case K_ENTER:
|
||||
owner().mask().send_key(K_SPACE, F_PROPERTIES);
|
||||
break;
|
||||
case K_ESC:
|
||||
{
|
||||
TReport_section& rs = curr_section();
|
||||
FOR_EACH_ARRAY_ITEM(rs, i, o)
|
||||
{
|
||||
TReport_field& f = *(TReport_field*)o;
|
||||
if (f.selected())
|
||||
f.select(false);
|
||||
}
|
||||
force_update();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TField_window::on_key(k);
|
||||
}
|
||||
|
||||
#define POPUP_CUT 20883
|
||||
#define POPUP_COPY 20884
|
||||
#define POPUP_PASTE 20885
|
||||
#define POPUP_DUP 20886
|
||||
#define POPUP_CLEAR 20887
|
||||
|
||||
void TReport_window::popup_menu(EVENT* ep)
|
||||
{
|
||||
MENU_ITEM menu[6];
|
||||
memset(menu, 0, sizeof(menu));
|
||||
|
||||
RCT rct;
|
||||
const bool sel = get_selection_rect(rct);
|
||||
const bool clp = _clipboard.items() > 0;
|
||||
|
||||
menu[0].tag = POPUP_CUT; menu[0].text = "Taglia"; menu[0].enabled = sel;
|
||||
menu[1].tag = POPUP_COPY; menu[1].text = "Copia"; menu[1].enabled = sel;
|
||||
menu[2].tag = POPUP_PASTE; menu[2].text = "Incolla"; menu[2].enabled = clp;
|
||||
menu[3].tag = POPUP_DUP; menu[3].text = "Duplica"; menu[3].enabled = sel;
|
||||
menu[4].tag = POPUP_CLEAR; menu[4].text = "Cancella"; menu[4].enabled = sel;
|
||||
|
||||
const PNT& p = ep->v.mouse.where;
|
||||
_pt_drag_start = dev2log(p);
|
||||
xvt_menu_popup(menu, win(), p, XVT_POPUP_CENTER, 0);
|
||||
}
|
||||
|
||||
void TReport_window::popup_cut()
|
||||
{
|
||||
_clipboard.destroy();
|
||||
TReport_section& rs = curr_section();
|
||||
FOR_EACH_ARRAY_ITEM_BACK(rs, i, o)
|
||||
{
|
||||
TReport_field& f = *(TReport_field*)o;
|
||||
if (f.selected())
|
||||
{
|
||||
TObject* obj = rs.remove(i, true);
|
||||
_clipboard.add(obj);
|
||||
}
|
||||
}
|
||||
force_update();
|
||||
}
|
||||
|
||||
void TReport_window::popup_copy()
|
||||
{
|
||||
_clipboard.destroy();
|
||||
TReport_section& rs = curr_section();
|
||||
FOR_EACH_ARRAY_ITEM(rs, i, o)
|
||||
{
|
||||
TReport_field& f = *(TReport_field*)o;
|
||||
if (f.selected())
|
||||
_clipboard.add(f);
|
||||
}
|
||||
}
|
||||
|
||||
void TReport_window::popup_paste()
|
||||
{
|
||||
if (_clipboard.items() > 0)
|
||||
{
|
||||
RCT rct;
|
||||
((TReport_field&)_clipboard[0]).get_rect(rct);
|
||||
const TPoint off(_pt_drag_start.x-rct.left, _pt_drag_start.y-rct.top);
|
||||
clear_selection();
|
||||
TReport_section& rs = curr_section();
|
||||
FOR_EACH_ARRAY_ITEM(_clipboard, i, o)
|
||||
{
|
||||
TReport_field& f = *(TReport_field*)o;
|
||||
f.set_section(&rs);
|
||||
f.select();
|
||||
f.offset(off);
|
||||
rs.add(f);
|
||||
}
|
||||
force_update();
|
||||
}
|
||||
}
|
||||
|
||||
void TReport_window::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
switch (ep->type)
|
||||
{
|
||||
case E_MOUSE_DOWN:
|
||||
if (ep->v.mouse.button == 0)
|
||||
{
|
||||
const TPoint pt = dev2log(ep->v.mouse.where);
|
||||
const PNT p = { short(pt.y), short(pt.x) };
|
||||
@ -328,6 +450,10 @@ void TReport_window::handler(WINDOW win, EVENT* ep)
|
||||
xvt_win_trap_pointer(win);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
popup_menu(ep);
|
||||
}
|
||||
break;
|
||||
case E_MOUSE_MOVE:
|
||||
{
|
||||
@ -394,6 +520,30 @@ void TReport_window::handler(WINDOW win, EVENT* ep)
|
||||
xvt_win_set_cursor(win, CURSOR_ARROW);
|
||||
}
|
||||
break;
|
||||
case E_MOUSE_DBL:
|
||||
owner().mask().send_key(K_SPACE, F_PROPERTIES);
|
||||
break;
|
||||
case E_COMMAND:
|
||||
switch(ep->v.cmd.tag)
|
||||
{
|
||||
case POPUP_CUT:
|
||||
case POPUP_CLEAR:
|
||||
popup_cut();
|
||||
break;
|
||||
case POPUP_COPY:
|
||||
popup_copy();
|
||||
break;
|
||||
case POPUP_PASTE:
|
||||
popup_paste();
|
||||
break;
|
||||
case POPUP_DUP:
|
||||
popup_copy();
|
||||
popup_paste();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -445,12 +595,11 @@ void TReport_window::draw_grid()
|
||||
|
||||
RCT rct; xvt_vobj_get_client_rect(win(), &rct);
|
||||
const int max = 192;
|
||||
const int kx = 100;
|
||||
const int ky = 100;
|
||||
const int k = 100;
|
||||
for (int i = 1; i < max; i++)
|
||||
{
|
||||
line(0, i*ky, max*kx, i*ky);
|
||||
line(i*kx, 0, i*kx, max*ky);
|
||||
line(0, i*k, max*k, i*k);
|
||||
line(i*k, 0, i*k, max*k);
|
||||
}
|
||||
}
|
||||
|
||||
@ -481,6 +630,7 @@ protected:
|
||||
virtual TField_window* create_window(int x, int y, int dx, int dy, WINDOW parent);
|
||||
|
||||
public:
|
||||
void set_report(TReport* rep);
|
||||
TReport_drawer(TMask* m) : TWindowed_field(m) { }
|
||||
};
|
||||
|
||||
@ -489,6 +639,249 @@ 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)
|
||||
{
|
||||
TReport_window* w = (TReport_window*)_win;
|
||||
w->set_report(rep);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Utility
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
const TString& num2str(int num)
|
||||
{
|
||||
static TString8 _str;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TReport_field_mask
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TReport_field_mask : public TAutomask
|
||||
{
|
||||
COLOR _fgcolor, _bgcolor;
|
||||
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
virtual void handler(WINDOW win, EVENT* ep);
|
||||
|
||||
public:
|
||||
void set_num(short id, short n);
|
||||
short get_num(short id) const;
|
||||
|
||||
void set_field(const TReport_field& rf);
|
||||
void get_field(TReport_field& rf) const;
|
||||
|
||||
TReport_field_mask() :TAutomask("ba8300b") { }
|
||||
};
|
||||
|
||||
void TReport_field_mask::set_num(short id, short num)
|
||||
{
|
||||
set(id, num2str(num));
|
||||
}
|
||||
|
||||
short TReport_field_mask::get_num(short id) const
|
||||
{
|
||||
TString8 str = get(id);
|
||||
str.replace(',', '.');
|
||||
real n(str);
|
||||
n *= CENTO;
|
||||
return (short)n.integer();
|
||||
}
|
||||
|
||||
void TReport_field_mask::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
if (ep->type == E_UPDATE)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
RCT rct; field(i == 0 ? F_FGCOLOR : F_BGCOLOR).get_rect(rct);
|
||||
xvt_rect_offset(&rct, rct.right-rct.left + 4*CHARX, 0);
|
||||
xi_draw_3d_rect((XinWindow)win, (XinRect*)&rct, TRUE, 2, MASK_LIGHT_COLOR,
|
||||
i == 0 ? _fgcolor : _bgcolor, MASK_DARK_COLOR);
|
||||
}
|
||||
}
|
||||
TAutomask::handler(win, ep);
|
||||
}
|
||||
|
||||
bool TReport_field_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
switch(o.dlg())
|
||||
{
|
||||
case F_X:
|
||||
case F_Y:
|
||||
case F_DX:
|
||||
case F_DY:
|
||||
if (e == fe_modify)
|
||||
{
|
||||
const int num = get_num(o.dlg());
|
||||
set_num(o.dlg(), num); // Reformat
|
||||
}
|
||||
break;
|
||||
case F_FGCOLOR:
|
||||
if (e == fe_button)
|
||||
{
|
||||
_fgcolor = xvt_dm_post_choose_color(win(), _fgcolor);
|
||||
force_update();
|
||||
}
|
||||
break;
|
||||
case F_BGCOLOR:
|
||||
if (e == fe_button)
|
||||
{
|
||||
_bgcolor = xvt_dm_post_choose_color(win(), _bgcolor);
|
||||
force_update();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TReport_field_mask::set_field(const TReport_field& rf)
|
||||
{
|
||||
const char str[2] = { rf.type(), '\0' };
|
||||
set(F_FIELD, str);
|
||||
|
||||
RCT r; rf.get_rect(r);
|
||||
set_num(F_X, r.left);
|
||||
set_num(F_Y, r.top);
|
||||
set_num(F_DX, r.right-r.left);
|
||||
set_num(F_DY, r.bottom-r.top);
|
||||
set(F_HALIGN, rf.horizontal_alignment());
|
||||
set(F_VALIGN, rf.vertical_alignment());
|
||||
set(F_BORDER, rf.border());
|
||||
_fgcolor = rf.fore_color();
|
||||
_bgcolor = rf.back_color();
|
||||
set(F_TEXT, rf.picture());
|
||||
set(F_SOURCE, rf.field());
|
||||
}
|
||||
|
||||
void TReport_field_mask::get_field(TReport_field& rf) const
|
||||
{
|
||||
rf.set_type(get(F_FIELD)[0]);
|
||||
rf.set_pos(get_num(F_X), get_num(F_Y));
|
||||
rf.set_size(get_num(F_DX), get_num(F_DY));
|
||||
rf.set_horizontal_alignment(get(F_HALIGN)[0]);
|
||||
rf.set_vertical_alignment(get(F_VALIGN)[0]);
|
||||
rf.set_border(get_int(F_BORDER));
|
||||
rf.set_fore_color(_fgcolor);
|
||||
rf.set_back_color(_bgcolor);
|
||||
rf.set_picture(get(F_TEXT));
|
||||
rf.set_field(get(F_SOURCE));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TReport_sheet
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TReport_sheet : public TSheet
|
||||
{
|
||||
TReport_section& _section;
|
||||
|
||||
protected:
|
||||
virtual long get_items() const { return _section.items(); }
|
||||
virtual void get_row(long r, TToken_string& row);
|
||||
|
||||
public:
|
||||
virtual KEY run();
|
||||
int selection(int& first, int& last) const;
|
||||
TReport_sheet(TReport_section& sec);
|
||||
};
|
||||
|
||||
void TReport_sheet::get_row(long r, TToken_string& row)
|
||||
{
|
||||
const TReport_field& rf = (const TReport_field&)_section[r];
|
||||
RCT rect; rf.get_rect(rect);
|
||||
row.cut(0);
|
||||
row.add(checked(r) ? "X" : " ");
|
||||
switch (rf.type())
|
||||
{
|
||||
case 'D': row.add("Data"); break;
|
||||
case 'I': row.add("Immagine"); break;
|
||||
case 'L': row.add("Linea"); break;
|
||||
case 'N': row.add("Numero"); break;
|
||||
case 'R': row.add("Rettangolo"); break;
|
||||
case 'S': row.add("Stringa"); break;
|
||||
case 'T': row.add("Testo"); break;
|
||||
default : row.add("Extra"); break;
|
||||
}
|
||||
row.add(num2str(rect.top));
|
||||
row.add(num2str(rect.left));
|
||||
row.add(num2str(rect.right-rect.left));
|
||||
row.add(num2str(rect.bottom-rect.top));
|
||||
row.add(rf.picture());
|
||||
row.add(rf.field());
|
||||
}
|
||||
|
||||
int TReport_sheet::selection(int& first, int& last) const
|
||||
{
|
||||
int tot = 0;
|
||||
first = items()+1;
|
||||
last = -1;
|
||||
FOR_EACH_ARRAY_ITEM_BACK(_section, i, o)
|
||||
{
|
||||
const TReport_field& rf = *(const TReport_field*)o;
|
||||
if (rf.selected())
|
||||
{
|
||||
if (i < first) first = i;
|
||||
if (i > last) last = i;
|
||||
tot++;
|
||||
}
|
||||
}
|
||||
return tot;
|
||||
}
|
||||
|
||||
KEY TReport_sheet::run()
|
||||
{
|
||||
int first = -1;
|
||||
uncheck(-1);
|
||||
FOR_EACH_ARRAY_ITEM(_section, i, o)
|
||||
{
|
||||
const TReport_field& rf = *(const TReport_field*)o;
|
||||
if (rf.selected())
|
||||
{
|
||||
check(i);
|
||||
if (first < 0)
|
||||
first = i;
|
||||
}
|
||||
}
|
||||
if (first > 0)
|
||||
select(first);
|
||||
const KEY k = TSheet::run();
|
||||
if (k != K_ESC)
|
||||
{
|
||||
FOR_EACH_ARRAY_ITEM(_section, i, o)
|
||||
{
|
||||
TReport_field& rf = *(TReport_field*)o;
|
||||
rf.select(checked(i));
|
||||
}
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
TReport_sheet::TReport_sheet(TReport_section& sec)
|
||||
: TSheet(-1, -1, -2, -4, "Campi", "@1|Tipo@10|Riga@R|Col.@R|Larg.@R|Alt.@R|Testo@30|Campo@30", 0xE),
|
||||
_section(sec)
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TReport_mask
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -501,23 +894,24 @@ class TReport_mask : public TAutomask
|
||||
protected:
|
||||
virtual TMask_field* parse_field(TScanner& scanner);
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
virtual void handler(WINDOW win, EVENT* ep);
|
||||
|
||||
protected:
|
||||
bool select_query();
|
||||
bool select_report();
|
||||
void update_report() const;
|
||||
|
||||
TReport_section& curr_section();
|
||||
void add_field();
|
||||
void edit_field(TReport_field& rf);
|
||||
void properties();
|
||||
void on_print();
|
||||
|
||||
public:
|
||||
TReport_tree& sections() { return _tree; }
|
||||
|
||||
TReport_mask();
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TReport_mask
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TMask_field* TReport_mask::parse_field(TScanner& scanner)
|
||||
{
|
||||
if (scanner.token().starts_with("RE"))
|
||||
@ -559,6 +953,114 @@ void TReport_mask::on_print()
|
||||
{
|
||||
}
|
||||
|
||||
TReport_section& TReport_mask::curr_section()
|
||||
{
|
||||
TTree_field& sections = tfield(F_SECTIONS);
|
||||
sections.goto_selected();
|
||||
return _tree.curr_section();
|
||||
}
|
||||
|
||||
void TReport_mask::update_report() const
|
||||
{
|
||||
TReport_drawer& rd = (TReport_drawer&)field(F_REPORT);
|
||||
rd.win().force_update();
|
||||
}
|
||||
|
||||
void TReport_mask::add_field()
|
||||
{
|
||||
TReport_section& rs = curr_section();
|
||||
TReport_field_mask m;
|
||||
m.set(F_DX, 10); m.set(F_DY, 1);
|
||||
m.disable(DLG_DELREC);
|
||||
if (m.run() == K_ENTER)
|
||||
{
|
||||
TReport_field* rf = new TReport_field(&rs);
|
||||
m.get_field(*rf);
|
||||
rs.add(rf);
|
||||
update_report();
|
||||
}
|
||||
}
|
||||
|
||||
void TReport_mask::edit_field(TReport_field& rf)
|
||||
{
|
||||
TReport_field_mask m;
|
||||
m.set_field(rf);
|
||||
const KEY key = m.run();
|
||||
switch(key)
|
||||
{
|
||||
case K_ENTER:
|
||||
m.get_field(rf);
|
||||
break;
|
||||
case K_DEL:
|
||||
{
|
||||
TReport_section& rs = rf.section();
|
||||
for (int i = rs.last(); i >= 0; i--) if (rs.objptr(i) == &rf)
|
||||
{
|
||||
rs.destroy(i, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
update_report();
|
||||
}
|
||||
|
||||
|
||||
void TReport_mask::properties()
|
||||
{
|
||||
TReport_section& rs = curr_section();
|
||||
TReport_sheet sheet(rs);
|
||||
|
||||
int first, last;
|
||||
int selected = sheet.selection(first, last);
|
||||
if (selected == 1)
|
||||
{
|
||||
TReport_field& rf = (TReport_field&)rs[first];
|
||||
edit_field(rf);
|
||||
return;
|
||||
}
|
||||
|
||||
KEY key = K_ENTER;
|
||||
while (key != K_ESC)
|
||||
{
|
||||
key = sheet.run();
|
||||
selected = sheet.selection(first, last);
|
||||
if (selected == 0 && (key == K_ENTER || key == K_DEL))
|
||||
{
|
||||
first = last = sheet.selected();
|
||||
selected = 1;
|
||||
sheet.check(first);
|
||||
}
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case K_INS:
|
||||
add_field();
|
||||
break;
|
||||
case K_ENTER:
|
||||
{
|
||||
for (int i = first; i <= last; i++) if (sheet.checked(i))
|
||||
{
|
||||
TReport_field& rf = (TReport_field&)rs[i];
|
||||
edit_field(rf);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case K_DEL:
|
||||
if (selected > 0 && yesno_box(FR("Comfermare la cancellazione di %d elementi"), selected))
|
||||
{
|
||||
for (int i = last; i >= first; i--) if (sheet.checked(i))
|
||||
rs.destroy(i, true);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
update_report();
|
||||
}
|
||||
}
|
||||
|
||||
bool TReport_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
switch (o.dlg())
|
||||
@ -568,8 +1070,21 @@ bool TReport_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
|
||||
select_report();
|
||||
break;
|
||||
case F_SECTIONS:
|
||||
if (e == fe_modify)
|
||||
if (e == fe_init || e == fe_modify)
|
||||
{
|
||||
((TReport_drawer&)field(F_REPORT)).win().force_update();
|
||||
const TReport_section& rs = _tree.curr_section();
|
||||
const bool ok = strchr("HBF", rs.type()) != NULL;
|
||||
enable(-1, ok);
|
||||
}
|
||||
break;
|
||||
case F_FIELD:
|
||||
if (e == fe_button && o.active())
|
||||
add_field();
|
||||
break;
|
||||
case F_PROPERTIES:
|
||||
if (e == fe_button && o.active())
|
||||
properties();
|
||||
break;
|
||||
case F_SQL:
|
||||
if (e == fe_init || e == fe_modify)
|
||||
@ -610,6 +1125,28 @@ bool TReport_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
|
||||
return true;
|
||||
}
|
||||
|
||||
void TReport_mask::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
if (ep->type == E_COMMAND)
|
||||
{
|
||||
switch(ep->v.cmd.tag)
|
||||
{
|
||||
case M_EDIT_COPY:
|
||||
case M_EDIT_CUT:
|
||||
case M_EDIT_PASTE:
|
||||
{
|
||||
// Ridirigo l'editing a chi di dovere
|
||||
TWindow& w = ((TReport_drawer&)field(F_REPORT)).win();
|
||||
w.handler(w.win(), ep);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
TAutomask::handler(win, ep);
|
||||
}
|
||||
|
||||
TReport_mask::TReport_mask() : _tree(_report)
|
||||
{
|
||||
read_mask("ba8300a", 0, -1);
|
||||
@ -677,6 +1214,9 @@ TReport_mask::TReport_mask() : _tree(_report)
|
||||
|
||||
_tree.goto_root();
|
||||
_tree.expand();
|
||||
|
||||
TReport_drawer& rd = (TReport_drawer&)field(F_REPORT);
|
||||
rd.set_report(&_report);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
15
ba/ba8300.h
15
ba/ba8300.h
@ -3,8 +3,19 @@
|
||||
|
||||
#define F_SECTIONS 103
|
||||
#define F_REPORT 104
|
||||
#define F_X 105
|
||||
#define F_Y 106
|
||||
#define F_FIELD 105
|
||||
#define F_PROPERTIES 106
|
||||
#define F_X 111
|
||||
#define F_Y 112
|
||||
#define F_DX 113
|
||||
#define F_DY 114
|
||||
#define F_TEXT 115
|
||||
#define F_SOURCE 116
|
||||
#define F_HALIGN 117
|
||||
#define F_VALIGN 118
|
||||
#define F_BORDER 119
|
||||
#define F_FGCOLOR 120
|
||||
#define F_BGCOLOR 121
|
||||
|
||||
#define F_SQL 201
|
||||
#define F_IMPORT_QRY 202
|
||||
|
@ -66,11 +66,23 @@ BEGIN
|
||||
PROMPT 0 3 ""
|
||||
END
|
||||
|
||||
REPORT F_REPORT -3 -1
|
||||
REPORT F_REPORT -3 -3
|
||||
BEGIN
|
||||
PROMPT 21 3 ""
|
||||
END
|
||||
|
||||
BUTTON F_FIELD 10 2
|
||||
BEGIN
|
||||
PROMPT -16 -1 "Campo"
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
BUTTON F_PROPERTIES 10 2
|
||||
BEGIN
|
||||
PROMPT -26 -1 "Proprieta'"
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
NUMBER F_Y 3
|
||||
BEGIN
|
||||
PROMPT 58 -1 "Riga "
|
||||
|
@ -169,11 +169,26 @@ const TReport_font& TReport_field::font() const
|
||||
return _font != NULL ? *_font : _section->font();
|
||||
}
|
||||
|
||||
void TReport_field::copy(const TReport_field& rf)
|
||||
{
|
||||
_section = rf._section;
|
||||
_type = rf.type();
|
||||
_x = rf._x; _y = rf._y;
|
||||
_width = rf._width; _height = rf._height;
|
||||
_fgcolor = rf._fgcolor; _bgcolor = rf._bgcolor;
|
||||
_border = rf._border;
|
||||
_halign = rf._halign; _valign = rf._valign;
|
||||
_picture = rf._picture; _field = rf._field;
|
||||
_selected = false;
|
||||
_font = NULL;
|
||||
}
|
||||
|
||||
TReport_field::TReport_field(TReport_section* sec)
|
||||
: _section(sec), _type('T'), _selected(false), _font(NULL), _color(COLOR_BLACK)
|
||||
: _section(sec), _type('T'), _selected(false), _font(NULL),
|
||||
_fgcolor(COLOR_BLACK), _bgcolor(COLOR_WHITE)
|
||||
{
|
||||
set_pos(0,0);
|
||||
set_size(1200,100);
|
||||
set_size(1600,100);
|
||||
_picture = "###.###.##@,@@";
|
||||
}
|
||||
|
||||
|
35
ba/ba8301.h
35
ba/ba8301.h
@ -40,7 +40,6 @@ public:
|
||||
char type() const { return _type; }
|
||||
int level() const { return _level; }
|
||||
void description(TString& str) const;
|
||||
|
||||
const TReport_font& font() const;
|
||||
|
||||
TReport_section(const TReport_section* f, char t, int l);
|
||||
@ -50,30 +49,58 @@ public:
|
||||
class TReport_field : public TObject
|
||||
{
|
||||
TReport_section* _section;
|
||||
char _type; // Text, String, Numeric, Date, Line, Rectangle, Image
|
||||
char _type; // Text, String, Numeric, Date, Line, Rectangle, Image
|
||||
short _x, _y; // Coordinate in centesimi
|
||||
short _width, _height; // Dimensioni in centesimi
|
||||
COLOR _color;
|
||||
COLOR _fgcolor, _bgcolor;
|
||||
short _border;
|
||||
char _halign, _valign;
|
||||
TString _picture, _field;
|
||||
|
||||
TReport_font* _font;
|
||||
bool _selected;
|
||||
|
||||
protected:
|
||||
void copy(const TReport_field& rf);
|
||||
|
||||
public:
|
||||
virtual TObject* dup() const { return new TReport_field(*this); }
|
||||
TReport_field& operator=(const TReport_field& rf) { copy(rf); return *this; }
|
||||
|
||||
TReport_section& section() { return *_section; }
|
||||
void set_section(TReport_section* sec) { _section = sec; }
|
||||
|
||||
char type() const { return _type; }
|
||||
const TReport_font& font() const;
|
||||
|
||||
const TString& picture() const { return _picture; }
|
||||
void set_picture(const char* str) { _picture = str; }
|
||||
|
||||
const TString& field() const { return _field; }
|
||||
void set_field(const char* str) { _field = str; }
|
||||
|
||||
void set_type(char t) { _type = t; }
|
||||
void set_pos(short x, short y);
|
||||
void set_size(short w, short h);
|
||||
void get_rect(RCT& rct) const;
|
||||
COLOR color() const { return _color; }
|
||||
|
||||
void set_fore_color(COLOR c) { _fgcolor = c; }
|
||||
COLOR fore_color() const { return _fgcolor; }
|
||||
void set_back_color(COLOR c) { _bgcolor = c; }
|
||||
COLOR back_color() const { return _bgcolor; }
|
||||
void set_border(short b) { _border = b; }
|
||||
short border() const { return _border; }
|
||||
void set_horizontal_alignment(char a) { _halign = a; }
|
||||
char horizontal_alignment() const { return _halign; }
|
||||
void set_vertical_alignment(char a) { _valign = a; }
|
||||
char vertical_alignment() const { return _valign; }
|
||||
|
||||
void select(bool ok = true) { _selected = ok; }
|
||||
bool selected() const { return _selected; }
|
||||
|
||||
void offset(const TPoint& pt);
|
||||
TReport_field(TReport_section* sec);
|
||||
TReport_field(const TReport_field& rf) { copy(rf); }
|
||||
};
|
||||
|
||||
class TReport : public TObject
|
||||
|
Loading…
x
Reference in New Issue
Block a user