c6a02882e8
Files correlati : ba8.exe Ricompilazione Demo : [ ] Commento : Salvataggio situazione attuale generazione report: stato avanzamento lavori 50% git-svn-id: svn://10.65.10.50/trunk@11899 c028cbd2-c16b-5b4b-a496-9718f37d4682
222 lines
5.9 KiB
C++
Executable File
222 lines
5.9 KiB
C++
Executable File
#ifndef __PAGEPRNT_H
|
|
#define __PAGEPRNT_H
|
|
|
|
#ifndef __ASSOC_H
|
|
#include <assoc.h>
|
|
#endif
|
|
|
|
#ifndef __WINDOW_H
|
|
#include <window.h>
|
|
#endif
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TReport_font
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TReport_font : public TObject
|
|
{
|
|
enum { DEFAULT_FONT_SIZE = 10 };
|
|
|
|
TString _name;
|
|
int _size, _cpi;
|
|
XVT_FONT_STYLE_MASK _style;
|
|
|
|
WINDOW _win_mapped;
|
|
XVT_FNTID _fontid;
|
|
|
|
protected:
|
|
void copy(const TReport_font& f);
|
|
|
|
public:
|
|
const TString& name() const { return _name; }
|
|
int size() const { return _size; }
|
|
XVT_FONT_STYLE_MASK style() const { return _style; }
|
|
int cpi() const { return _cpi; }
|
|
XVT_FNTID get_xvt_font(const TWindow& win) const;
|
|
|
|
void create(const char* name, int size, XVT_FONT_STYLE_MASK style);
|
|
TReport_font& operator=(const TReport_font& f) { copy(f); return *this; }
|
|
TReport_font();
|
|
TReport_font(const TReport_font& f) { copy(f); }
|
|
virtual ~TReport_font();
|
|
};
|
|
|
|
class TReport;
|
|
class TReport_field;
|
|
|
|
class TReport_section : public TArray
|
|
{
|
|
TReport& _report;
|
|
|
|
char _type; // Head,Body,Tail
|
|
int _level; // 0,1,2,...
|
|
short _width, _height; // In centesimi
|
|
TString _groupby;
|
|
bool _hidden_if_needed;
|
|
|
|
TReport_font* _font;
|
|
|
|
protected:
|
|
TReport_section* father_section() const;
|
|
|
|
public:
|
|
virtual int add(TObject* obj);
|
|
virtual int add(TObject& obj);
|
|
TReport_field& field(int i) { return *(TReport_field*)objptr(i); }
|
|
const TReport_field& field(int i) const { return *(TReport_field*)objptr(i); }
|
|
TReport& report() { return _report; }
|
|
|
|
char type() const { return _type; }
|
|
int level() const { return _level; }
|
|
const TReport_font& font() const;
|
|
|
|
short width() const { return _width; }
|
|
short height() const { return _height; }
|
|
void set_width(short w) { _width = w; }
|
|
void set_height(short h) { _height = h; }
|
|
bool get_rect(RCT& rct) const;
|
|
|
|
const TString& grouped_by() const { return _groupby; }
|
|
void group_by(const char* gb) { _groupby = gb; }
|
|
|
|
bool hidden_if_needed() const { return _hidden_if_needed; }
|
|
void hide_if_needed(bool h) { _hidden_if_needed = h; }
|
|
|
|
void set_font(const char* name, int size, XVT_FONT_STYLE_MASK style);
|
|
|
|
TReport_section(TReport& r, char t, int l);
|
|
virtual ~TReport_section();
|
|
};
|
|
|
|
class TReport_field : public TObject
|
|
{
|
|
TReport_section* _section;
|
|
char _type; // Text, String, Numeric, Date, Line, Rectangle, Image
|
|
short _x, _y; // Coordinate in centesimi
|
|
short _width, _height; // Dimensioni in centesimi
|
|
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 char* type_name() const;
|
|
|
|
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_row(short y) { _y = y; }
|
|
void set_column(short x) { _x = x; }
|
|
void set_size(short w, short h);
|
|
void set_width(short dx) { _width = dx; }
|
|
void set_height(short dy) { _height = dy; }
|
|
void get_rect(RCT& rct) const;
|
|
|
|
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);
|
|
|
|
virtual void draw_rect(TWindow& win) const;
|
|
virtual void draw_text(TWindow& win, const char* text) const;
|
|
virtual void draw(TWindow& win) const;
|
|
|
|
TReport_field();
|
|
TReport_field(const TXmlItem& item);
|
|
TReport_field(const TReport_field& rf) { copy(rf); }
|
|
};
|
|
|
|
class TReport : public TObject
|
|
{
|
|
TAssoc_array _sections;
|
|
TFilename _path;
|
|
TString _description, _sql;
|
|
TReport_font _font;
|
|
int _lpi; // Lines per inch
|
|
|
|
protected:
|
|
void build_section_key(char type, int level, TString& key) const;
|
|
void load_sections(const TXmlItem& xml);
|
|
short get_num_attr(const TXmlItem& item, const char* attr, short def = 0) const;
|
|
COLOR get_col_attr(const TXmlItem& item, const char* attr, COLOR defcol = COLOR_BLACK) const;
|
|
|
|
public:
|
|
TReport_section* find_section(char type, int level) const;
|
|
TReport_section& section(char type, int level);
|
|
bool kill_section(char type, int level);
|
|
int find_max_level() const;
|
|
|
|
TReport_font& font() { return _font; }
|
|
int cpi() const { return _font.cpi(); }
|
|
int lpi() const { return _lpi; }
|
|
|
|
void set_sql(const char* sql);
|
|
const TString& sql() const { return _sql; }
|
|
|
|
void set_description(const char* d);
|
|
const TString& description() const { return _description; }
|
|
|
|
bool load(const char* fname);
|
|
|
|
void destroy();
|
|
TReport();
|
|
};
|
|
|
|
class TPage_printer : public TWindow
|
|
{
|
|
protected:
|
|
long _pw, _ph, _phr, _pvr; // Printer width, height, horizontal and vertical resolution
|
|
|
|
word _copies;
|
|
word _pagefrom;
|
|
word _pageto;
|
|
bool _aborted;
|
|
|
|
|
|
public:
|
|
virtual int pages() const pure;
|
|
virtual bool print_page(int p) pure;
|
|
|
|
virtual const char* form_name() const;
|
|
virtual const char* font_name() const;
|
|
virtual int font_size() const;
|
|
virtual bool ask_pages();
|
|
|
|
virtual bool print();
|
|
|
|
TPage_printer();
|
|
virtual ~TPage_printer();
|
|
};
|
|
|
|
#endif
|