Files correlati : ba0.exe Ricompilazione Demo : [ ] Commento : AO21002 Se da questa videata vado su File - Impostazione Stampante e cambio le impostazioni, non ne tiene conto in quanto se esco dalla videata vedo che c'è impostata ancora la vecchia stampante. Nb ERA COSI ANCHE SULLA 1,07 git-svn-id: svn://10.65.10.50/trunk@12221 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			1223 lines
		
	
	
		
			29 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1223 lines
		
	
	
		
			29 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <xinclude.h>
 | 
						|
#include <statbar.h>
 | 
						|
 | 
						|
#include <diction.h>
 | 
						|
#include <image.h>
 | 
						|
#include <mask.h>
 | 
						|
#include <reprint.h>
 | 
						|
 | 
						|
#include "ba8300.h"
 | 
						|
#include "ba8301.h"
 | 
						|
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
// TReport_tree
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
 | 
						|
void describe_section(char type, int level, TString& str)
 | 
						|
{
 | 
						|
  str = "     ";
 | 
						|
  if (level <= 0)
 | 
						|
  {
 | 
						|
    switch (type)
 | 
						|
    {
 | 
						|
    case 'H': str << TR("Testa");  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
 | 
						|
    default : break;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    switch (type)
 | 
						|
    {
 | 
						|
    case 'H': str << TR("Testa"); break;
 | 
						|
    case 'B': str << TR("Corpo"); break;
 | 
						|
    case 'F': str << TR("Coda");  break;
 | 
						|
    default : break;
 | 
						|
    }
 | 
						|
    str << ' ';
 | 
						|
    if (type == 'H' || type == 'F')
 | 
						|
    {
 | 
						|
      if (level <= 1)
 | 
						|
        str << TR("Report");
 | 
						|
      else
 | 
						|
        str << TR("Gruppo") << ' ' << (level-1);
 | 
						|
    }
 | 
						|
    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;
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_tree::goto_node(char type, int level)
 | 
						|
{
 | 
						|
  const bool ok = type > ' ' && level >= 0;
 | 
						|
  if (ok)
 | 
						|
    _curr.format("%c%d", type, level);
 | 
						|
  return ok;
 | 
						|
}
 | 
						|
 | 
						|
void TReport_tree::node2id(const TObject* node, TString& id) const
 | 
						|
{
 | 
						|
  id = *(TString*)node;
 | 
						|
}
 | 
						|
 | 
						|
TReport_section& TReport_tree::curr_section() const
 | 
						|
{
 | 
						|
  char type = _curr[0];
 | 
						|
  int level = atoi((const char*)_curr + 1);
 | 
						|
  if (type == 'R' || type == 'P')
 | 
						|
  {
 | 
						|
    type = 'B';
 | 
						|
    level = type == 'R';
 | 
						|
  }
 | 
						|
  return _report.section(type, level);
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_tree::goto_root()
 | 
						|
{
 | 
						|
  return goto_node('P', 0);
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_tree::goto_firstson()
 | 
						|
{
 | 
						|
  char ntype = 'H';
 | 
						|
  int nlevel = -1;
 | 
						|
  switch (_curr[0])
 | 
						|
  {
 | 
						|
  case 'P':
 | 
						|
    nlevel = 0;
 | 
						|
    break;
 | 
						|
  case 'R': 
 | 
						|
    nlevel = 1; 
 | 
						|
    break;
 | 
						|
  default: 
 | 
						|
    break;
 | 
						|
  }
 | 
						|
  return goto_node(ntype, nlevel);
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_tree::goto_rbrother()
 | 
						|
{
 | 
						|
  const char type = _curr[0];
 | 
						|
  const int level = _curr[1]-'0';  
 | 
						|
  char ntype = ' ';
 | 
						|
  int nlevel = -1;
 | 
						|
  if (level <= 0) // Page
 | 
						|
  {
 | 
						|
    switch (type)
 | 
						|
    {
 | 
						|
    case 'H': ntype = 'B'; break;
 | 
						|
    case 'B': ntype = 'F'; break;
 | 
						|
    case 'P': ntype = 'R'; break;
 | 
						|
    default : break;
 | 
						|
    }
 | 
						|
    nlevel = level;
 | 
						|
  }
 | 
						|
  else // Report
 | 
						|
  {
 | 
						|
    switch (type)
 | 
						|
    {
 | 
						|
    case 'H':
 | 
						|
      if (level < _report.find_max_level('H'))
 | 
						|
      {
 | 
						|
        ntype = 'H';
 | 
						|
        nlevel = level+1;
 | 
						|
      }
 | 
						|
      else
 | 
						|
      {
 | 
						|
        ntype = 'B';
 | 
						|
        nlevel = 1;
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    case 'B':
 | 
						|
      if (level < _report.find_max_level('B'))
 | 
						|
      {
 | 
						|
        ntype = 'B';
 | 
						|
        nlevel = level+1;
 | 
						|
      }
 | 
						|
      else
 | 
						|
      {
 | 
						|
        ntype = 'F';
 | 
						|
        nlevel = _report.find_max_level('F');
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    case 'F':
 | 
						|
      if (level > 1)
 | 
						|
      {
 | 
						|
        ntype = 'F';
 | 
						|
        nlevel = level-1;
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    default: 
 | 
						|
      break;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  return goto_node(ntype, nlevel);
 | 
						|
} 
 | 
						|
 | 
						|
bool TReport_tree::goto_node(const TString &id)
 | 
						|
{
 | 
						|
  return goto_node(id[0], id[1]-'0');
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_tree::has_son() const
 | 
						|
{
 | 
						|
  bool yes = false;
 | 
						|
  switch (_curr[0])
 | 
						|
  {
 | 
						|
  case 'P':
 | 
						|
  case 'R':
 | 
						|
    yes = true;
 | 
						|
    break;
 | 
						|
  default:
 | 
						|
    break;
 | 
						|
  }
 | 
						|
  return yes;
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_tree::has_rbrother() const
 | 
						|
{
 | 
						|
  const TString4 old = _curr;
 | 
						|
  TReport_tree* myself = (TReport_tree*)this;
 | 
						|
  const bool ok = myself->goto_rbrother();
 | 
						|
  myself->_curr = old;
 | 
						|
  return ok;
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_tree::has_root() const
 | 
						|
{
 | 
						|
  return true; // In realta' ci sono 3 root: Pagina, Report, Speciali
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_tree::has_father() const
 | 
						|
{
 | 
						|
  return !has_son();
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_tree::goto_father()
 | 
						|
{
 | 
						|
  bool yes = has_father();
 | 
						|
  if (yes)
 | 
						|
  {
 | 
						|
    const char ntype = _curr[1] == '0' ? 'P' : 'R';
 | 
						|
    yes = goto_node(ntype, 0);
 | 
						|
  }
 | 
						|
  return yes;
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_tree::has_lbrother() const
 | 
						|
{
 | 
						|
  const TString4 old = _curr;
 | 
						|
  TReport_tree* myself = (TReport_tree*)this;
 | 
						|
  const bool ok = myself->goto_lbrother();
 | 
						|
  myself->_curr = old;
 | 
						|
  return ok;
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_tree::goto_lbrother()
 | 
						|
{
 | 
						|
  const char type = _curr[0];
 | 
						|
  const int level = _curr[1]-'0';  
 | 
						|
  char ntype = ' ';
 | 
						|
  int nlevel = -1;
 | 
						|
  if (level == 0) // Page
 | 
						|
  {
 | 
						|
    switch (type)
 | 
						|
    {
 | 
						|
    case 'B': ntype = 'H'; break;
 | 
						|
    case 'F': ntype = 'B'; break;
 | 
						|
    case 'R': ntype = 'P'; break;
 | 
						|
    default : break;
 | 
						|
    }
 | 
						|
    nlevel = level;
 | 
						|
  }
 | 
						|
  else // Report
 | 
						|
  {
 | 
						|
    switch (type)
 | 
						|
    {
 | 
						|
    case 'F':
 | 
						|
      if (level < _report.find_max_level('F'))
 | 
						|
      {
 | 
						|
        ntype = 'F';
 | 
						|
        nlevel = level+1;
 | 
						|
      }
 | 
						|
      else
 | 
						|
      {
 | 
						|
        ntype = 'B';
 | 
						|
        nlevel = _report.find_max_level('B');
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    case 'B':
 | 
						|
      if (level > 1)
 | 
						|
      {
 | 
						|
        ntype = 'B';
 | 
						|
        nlevel = level-1;
 | 
						|
      }
 | 
						|
      else
 | 
						|
      {
 | 
						|
        ntype = 'H';
 | 
						|
        nlevel = 1;
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    case 'H':
 | 
						|
      if (level > 1)
 | 
						|
      {
 | 
						|
        ntype = 'H';
 | 
						|
        nlevel = level-1;
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    default: 
 | 
						|
      break;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  return goto_node(ntype, nlevel);
 | 
						|
}
 | 
						|
 | 
						|
TImage* TReport_tree::image(bool selected) const
 | 
						|
{
 | 
						|
  int id = 0;
 | 
						|
  switch (_curr[0])
 | 
						|
  {
 | 
						|
  case 'H': id = 1810; break;
 | 
						|
  case 'B': id = 1811; break;
 | 
						|
  case 'F': id = 1812; break;
 | 
						|
  default : break; 
 | 
						|
  }
 | 
						|
  if (id > 0)
 | 
						|
    return get_res_image(id);
 | 
						|
  return TTree::image(selected);
 | 
						|
}
 | 
						|
 | 
						|
int TReport_tree::image_height() const
 | 
						|
{
 | 
						|
  const TImage* img = image(false);
 | 
						|
  return img != NULL ? img->height() : 0; 
 | 
						|
}
 | 
						|
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
// TReport_window
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
 | 
						|
class TReport_window : public TField_window
 | 
						|
{   
 | 
						|
  TReport* _report;
 | 
						|
  char _type;
 | 
						|
  int _level;
 | 
						|
  PNT _dpi;
 | 
						|
 | 
						|
  int _dragging;
 | 
						|
  TPoint _pt_drag_start;
 | 
						|
  PNT _pt_click, _pt_drag_offset;
 | 
						|
  RCT _rct_drag;
 | 
						|
 | 
						|
  TReport_image_cache _images;
 | 
						|
 | 
						|
  static TArray _clipboard;
 | 
						|
 | 
						|
protected:
 | 
						|
  virtual void handler(WINDOW win, EVENT* ep);
 | 
						|
  virtual void update();
 | 
						|
  virtual bool on_key(KEY k);
 | 
						|
  
 | 
						|
protected:
 | 
						|
  void draw_grid();
 | 
						|
  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);
 | 
						|
 | 
						|
  void popup_menu();
 | 
						|
  void popup_cut();
 | 
						|
  void popup_copy();
 | 
						|
  void popup_paste();
 | 
						|
  bool do_zoom(int k, bool reflect);
 | 
						|
 | 
						|
  int cpi() const;
 | 
						|
  int lpi() const;
 | 
						|
 | 
						|
public:
 | 
						|
  virtual PNT log2dev(long x, long y) const;
 | 
						|
  virtual TPoint dev2log(const PNT& pt) const;
 | 
						|
  TReport_section& curr_section() const { return _report->section(_type, _level); }
 | 
						|
  void set_report_section(TReport_section& rs);
 | 
						|
 | 
						|
  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);
 | 
						|
 | 
						|
  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() { }
 | 
						|
};
 | 
						|
 | 
						|
TArray TReport_window::_clipboard;
 | 
						|
 | 
						|
void TReport_window::set_report_section(TReport_section& rs)
 | 
						|
{
 | 
						|
  _report = &rs.report();
 | 
						|
  _type = rs.type();
 | 
						|
  _level = rs.level();
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_window::pick(const TPoint& ptlog) const
 | 
						|
{
 | 
						|
  TReport_section& rs = curr_section();
 | 
						|
 | 
						|
  FOR_EACH_ARRAY_ITEM_BACK(rs, i, o)
 | 
						|
  {
 | 
						|
    TReport_field& f = *(TReport_field*)o;
 | 
						|
    const TRectangle& rct = f.get_rect();
 | 
						|
    if (rct.contains(ptlog))
 | 
						|
    {
 | 
						|
      f.select();
 | 
						|
      return true;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  return false;
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::clear_selection()
 | 
						|
{
 | 
						|
  TReport_section& rs = curr_section();
 | 
						|
  FOR_EACH_ARRAY_ITEM(rs, i, o)
 | 
						|
  {
 | 
						|
    TReport_field* f = (TReport_field*)o;
 | 
						|
    f->select(false);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
int TReport_window::get_selection_rect(TRectangle& rct) const
 | 
						|
{
 | 
						|
  TReport_section& rs = curr_section();
 | 
						|
  int full = 0;
 | 
						|
  FOR_EACH_ARRAY_ITEM(rs, i, o)
 | 
						|
  {
 | 
						|
    const TReport_field& f = *(const TReport_field*)o;
 | 
						|
    if (f.selected())
 | 
						|
    {
 | 
						|
      const TRectangle& fr = f.get_rect();
 | 
						|
      if (!full)
 | 
						|
        rct = fr;
 | 
						|
      else
 | 
						|
        rct.merge(fr);
 | 
						|
      full++;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  return full;
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::offset_selection(const TPoint& p)
 | 
						|
{
 | 
						|
  TReport_section& rs = curr_section();
 | 
						|
  FOR_EACH_ARRAY_ITEM(rs, i, o)
 | 
						|
  {
 | 
						|
    TReport_field& f = *(TReport_field*)o;
 | 
						|
    if (f.selected())
 | 
						|
      f.offset(p);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::resize_selection(const TPoint& p)
 | 
						|
{
 | 
						|
  TReport_section& rs = curr_section();
 | 
						|
  FOR_EACH_ARRAY_ITEM(rs, i, o)
 | 
						|
  {
 | 
						|
    TReport_field& f = *(TReport_field*)o;
 | 
						|
    if (f.selected())
 | 
						|
    {
 | 
						|
      TPoint s = f.get_rect().size(); s += p;
 | 
						|
      if (s.x > 0 && s.y > 0)
 | 
						|
        f.set_size(s.x, s.y);
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
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();
 | 
						|
  
 | 
						|
  TReport_section& rs = curr_section();
 | 
						|
  FOR_EACH_ARRAY_ITEM(rs, i, o)
 | 
						|
  {
 | 
						|
    TReport_field& f = *(TReport_field*)o;
 | 
						|
    if (rct.intersects(f.get_rect()))
 | 
						|
      f.select();
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::draw_dragster()
 | 
						|
{
 | 
						|
  set_mode(M_NOT_XOR);
 | 
						|
  set_pen(COLOR_BLACK);
 | 
						|
  xvt_dwin_draw_dotted_rect(win(), &_rct_drag);
 | 
						|
  set_mode(M_COPY);
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::snap(TPoint& pnt, bool shift) const
 | 
						|
{
 | 
						|
  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
 | 
						|
#define POPUP_DUP        20886
 | 
						|
#define POPUP_CLEAR      20887
 | 
						|
#define POPUP_ZOOMIN     20888
 | 
						|
#define POPUP_ZOOMOUT    20889
 | 
						|
#define POPUP_SELALL     20890
 | 
						|
#define POPUP_UNSELALL   20891
 | 
						|
#define POPUP_PROPERTIES 20892
 | 
						|
#define POPUP_NEWFIELD   20893
 | 
						|
 | 
						|
bool TReport_window::on_key(KEY k)
 | 
						|
{
 | 
						|
  switch (k)
 | 
						|
  {
 | 
						|
  case K_LEFT:
 | 
						|
    offset_selection(TPoint(-50, 0));
 | 
						|
    force_update();
 | 
						|
    return true;
 | 
						|
  case K_LEFT+K_SHIFT:
 | 
						|
    resize_selection(TPoint(-50, 0));
 | 
						|
    force_update();
 | 
						|
    return true;
 | 
						|
  case K_RIGHT:
 | 
						|
    offset_selection(TPoint(+50, 0));
 | 
						|
    force_update();
 | 
						|
    return true;
 | 
						|
  case K_RIGHT+K_SHIFT:
 | 
						|
    resize_selection(TPoint(+50, 0));
 | 
						|
    force_update();
 | 
						|
    return true;
 | 
						|
  case K_DOWN:
 | 
						|
    offset_selection(TPoint(0, +25));
 | 
						|
    force_update();
 | 
						|
    return true;
 | 
						|
  case K_DOWN+K_SHIFT:
 | 
						|
    resize_selection(TPoint(0, +25));
 | 
						|
    force_update();
 | 
						|
    return true;
 | 
						|
  case K_UP:  
 | 
						|
    offset_selection(TPoint(0, -25));
 | 
						|
    force_update();
 | 
						|
    return true;
 | 
						|
  case K_UP+K_SHIFT:
 | 
						|
    resize_selection(TPoint(0, -25));
 | 
						|
    force_update();
 | 
						|
    return true;
 | 
						|
  case K_DEL:  
 | 
						|
    dispatch_e_menu(win(), POPUP_CUT);
 | 
						|
    return true;
 | 
						|
  case '+':
 | 
						|
    dispatch_e_menu(win(), POPUP_ZOOMIN);
 | 
						|
    return true;
 | 
						|
  case '-':
 | 
						|
    dispatch_e_menu(win(), POPUP_ZOOMOUT);
 | 
						|
    return true;
 | 
						|
  case K_ENTER:
 | 
						|
    owner().mask().send_key(K_SPACE, F_FLD_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);
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::popup_menu()
 | 
						|
{
 | 
						|
  MENU_ITEM menu[16];  // Stiamo larghi
 | 
						|
  memset(menu, 0, sizeof(menu));
 | 
						|
 | 
						|
  TRectangle rct;
 | 
						|
  const bool ful = curr_section().items() > 0;
 | 
						|
  const bool sel = ful && get_selection_rect(rct) != 0;
 | 
						|
  const bool clp = _clipboard.items() > 0;
 | 
						|
 | 
						|
  menu[ 0].tag = POPUP_CUT;        menu[ 0].text = (char*)TR("Taglia");   menu[0].enabled = sel;
 | 
						|
  menu[ 1].tag = POPUP_COPY;       menu[ 1].text = (char*)TR("Copia");    menu[1].enabled = sel;
 | 
						|
  menu[ 2].tag = POPUP_PASTE;      menu[ 2].text = (char*)TR("Incolla");  menu[2].enabled = clp;
 | 
						|
  menu[ 3].tag = POPUP_DUP;        menu[ 3].text = (char*)TR("Duplica");  menu[3].enabled = sel;
 | 
						|
  menu[ 4].tag = POPUP_CLEAR;      menu[ 4].text = (char*)TR("Cancella"); menu[4].enabled = sel;
 | 
						|
  menu[ 5].tag = -1;               menu[ 5].separator = true;
 | 
						|
  menu[ 6].tag = POPUP_ZOOMIN;     menu[ 6].text = (char*)TR("Zoom +");   menu[6].enabled = _dpi.v < 300;
 | 
						|
  menu[ 7].tag = POPUP_ZOOMOUT;    menu[ 7].text = (char*)TR("Zoom -");   menu[7].enabled = _dpi.v > 48;
 | 
						|
  menu[ 8].tag = -1;               menu[ 8].separator = true;
 | 
						|
  menu[ 9].tag = POPUP_SELALL;     menu[ 9].text = (char*)TR("Seleziona tutto");   menu[ 9].enabled = ful;
 | 
						|
  menu[10].tag = POPUP_UNSELALL;   menu[10].text = (char*)TR("Deseleziona tutto"); menu[10].enabled = ful;
 | 
						|
  menu[11].tag = -1;               menu[11].separator = true;
 | 
						|
  menu[12].tag = POPUP_PROPERTIES; menu[12].text = "Proprieta'";          menu[12].enabled = true;
 | 
						|
  menu[13].tag = POPUP_NEWFIELD;   menu[13].text = "Nuovo";               menu[13].enabled = true;
 | 
						|
 | 
						|
  _pt_drag_start = dev2log(_pt_click);
 | 
						|
  xvt_menu_popup(menu, win(), _pt_click, 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())
 | 
						|
    {
 | 
						|
      TReport_field* obj = (TReport_field*)rs.remove(i, true);
 | 
						|
      obj->set_section(NULL);
 | 
						|
      _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())
 | 
						|
    {
 | 
						|
      TReport_field* cp = new TReport_field(f);
 | 
						|
      cp->set_section(NULL);
 | 
						|
      _clipboard.add(cp);
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::popup_paste()
 | 
						|
{
 | 
						|
  if (_clipboard.items() > 0)
 | 
						|
  {
 | 
						|
    const TRectangle& rct = ((TReport_field&)_clipboard[0]).get_rect();
 | 
						|
    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)
 | 
						|
    {
 | 
						|
      const TReport_field& oldf = *(TReport_field*)o;
 | 
						|
      TReport_field* newf = new TReport_field(oldf);
 | 
						|
      newf->select();
 | 
						|
      newf->offset(off);
 | 
						|
      rs.add(newf);
 | 
						|
    }
 | 
						|
    force_update();
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
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;
 | 
						|
}
 | 
						|
 | 
						|
bool TReport_window::do_zoom(int k, bool reflect)
 | 
						|
{
 | 
						|
  const int n = _dpi.v+k;
 | 
						|
  const bool ok = n >= 48 && n < 300;
 | 
						|
  if (ok)
 | 
						|
  {
 | 
						|
    _dpi.h = _dpi.v = n;
 | 
						|
 | 
						|
    curr_section().unmap_font();
 | 
						|
    force_update();
 | 
						|
 | 
						|
    if (reflect)
 | 
						|
    {
 | 
						|
      const short buddy = owner().dlg() == F_REPORT ? F_REPORTH : F_REPORT;
 | 
						|
      TWindowed_field& fld = (TWindowed_field&)owner().mask().field(buddy);
 | 
						|
      TReport_window& win = (TReport_window&)fld.win();
 | 
						|
      win.do_zoom(k, false);
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  return ok;
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::handler(WINDOW win, EVENT* ep)
 | 
						|
{
 | 
						|
  switch (ep->type)
 | 
						|
  {
 | 
						|
  case E_MOUSE_DOWN:
 | 
						|
    _pt_click = ep->v.mouse.where;
 | 
						|
    switch (ep->v.mouse.button)
 | 
						|
    {
 | 
						|
    case 0:
 | 
						|
      {
 | 
						|
        const TPoint pt = dev2log(_pt_click);
 | 
						|
        TRectangle rct; 
 | 
						|
        int full = get_selection_rect(rct);
 | 
						|
        if (!full || !rct.contains(pt))
 | 
						|
        {
 | 
						|
          if (full && !ep->v.mouse.control)
 | 
						|
            clear_selection();
 | 
						|
          pick(pt);
 | 
						|
          full = get_selection_rect(rct);
 | 
						|
        }
 | 
						|
        if (full > 0)
 | 
						|
        {
 | 
						|
          TWindow::log2dev(rct, _rct_drag);
 | 
						|
 | 
						|
          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);
 | 
						|
          _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();
 | 
						|
        draw_dragster();
 | 
						|
        xvt_win_trap_pointer(win);
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    case 1:
 | 
						|
      popup_menu();
 | 
						|
      break;
 | 
						|
    default:
 | 
						|
      break;
 | 
						|
    }
 | 
						|
    owner().mask().notify_focus_field(owner().dlg());
 | 
						|
    break;
 | 
						|
  case E_MOUSE_MOVE:
 | 
						|
    {
 | 
						|
      TMask& m = owner().mask();
 | 
						|
      const TPoint p = dev2log(ep->v.mouse.where);
 | 
						|
 | 
						|
      TString16 str; str.format("r:%3d c:%3d", p.y/100, p.x/100);
 | 
						|
      statbar_set_title(TASK_WIN, str);
 | 
						|
 | 
						|
      if (_dragging != 0)
 | 
						|
      {
 | 
						|
        draw_dragster();
 | 
						|
        PNT pt = ep->v.mouse.where;
 | 
						|
        switch (_dragging)
 | 
						|
        {
 | 
						|
        case 1:
 | 
						|
          _rct_drag.right = pt.h;
 | 
						|
          _rct_drag.bottom = pt.v;
 | 
						|
          break;
 | 
						|
        case 2:
 | 
						|
          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;
 | 
						|
        }
 | 
						|
        draw_dragster();
 | 
						|
      }
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  case E_MOUSE_UP:
 | 
						|
    if (_dragging != 0)
 | 
						|
    {
 | 
						|
      draw_dragster();
 | 
						|
      PNT pt = ep->v.mouse.where;
 | 
						|
 | 
						|
      if (abs(pt.h-_pt_click.h) > 2 || abs(pt.v-_pt_click.v) > 2)  // Mi sono veramente spostato?
 | 
						|
      {
 | 
						|
        switch (_dragging)
 | 
						|
        {
 | 
						|
        case 1:
 | 
						|
          {
 | 
						|
            _rct_drag.right = pt.h;
 | 
						|
            _rct_drag.bottom = pt.v;
 | 
						|
            TRectangle rct; TWindow::dev2log(_rct_drag, rct);
 | 
						|
            select(rct);
 | 
						|
          }
 | 
						|
          break;
 | 
						|
        case 2:
 | 
						|
          {
 | 
						|
            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;
 | 
						|
        }
 | 
						|
      }
 | 
						|
      force_update();
 | 
						|
      _dragging = 0;
 | 
						|
      xvt_win_release_pointer();
 | 
						|
      xvt_win_set_cursor(win, CURSOR_ARROW);
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  case E_MOUSE_DBL:
 | 
						|
    owner().mask().send_key(K_SPACE, F_FLD_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;
 | 
						|
    case POPUP_ZOOMIN:
 | 
						|
      do_zoom(+24, true);
 | 
						|
      break;
 | 
						|
    case POPUP_ZOOMOUT:
 | 
						|
      do_zoom(-24, true);
 | 
						|
      break;
 | 
						|
    case POPUP_SELALL:
 | 
						|
      {
 | 
						|
        TReport_section& rs = curr_section();
 | 
						|
        FOR_EACH_ARRAY_ITEM(rs, i, o)
 | 
						|
        {
 | 
						|
          TReport_field& f = *(TReport_field*)o;
 | 
						|
          f.select();
 | 
						|
        }
 | 
						|
        force_update();
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    case POPUP_UNSELALL:
 | 
						|
      {
 | 
						|
        TReport_section& rs = curr_section();
 | 
						|
        FOR_EACH_ARRAY_ITEM(rs, i, o)
 | 
						|
        {
 | 
						|
          TReport_field& f = *(TReport_field*)o;
 | 
						|
          f.select(false);
 | 
						|
        }
 | 
						|
        force_update();
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    case POPUP_PROPERTIES:
 | 
						|
      {
 | 
						|
        clear_selection();
 | 
						|
        const bool full = pick(_pt_drag_start);
 | 
						|
        if (full)
 | 
						|
          owner().mask().send_key(K_SPACE, F_FLD_PROPERTIES);
 | 
						|
        else
 | 
						|
          owner().mask().send_key(K_SPACE, F_SEC_PROPERTIES);
 | 
						|
      }
 | 
						|
      break;
 | 
						|
    case POPUP_NEWFIELD:
 | 
						|
      owner().mask().send_key(K_SPACE, F_FLD_ADD);
 | 
						|
      break;
 | 
						|
    default: 
 | 
						|
      break;
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  case E_HSCROLL:
 | 
						|
    { // Riflette l'evento E_HSCROLL sull'altra finestra di anteprima spacciandolo per E_USER
 | 
						|
      const short buddy = owner().dlg() == F_REPORT ? F_REPORTH : F_REPORT;
 | 
						|
      TWindowed_field& fld = (TWindowed_field&)owner().mask().field(buddy);
 | 
						|
      ep->type = E_USER;
 | 
						|
      dispatch_event(fld.win().win(), *ep, false);
 | 
						|
      ep->type = E_HSCROLL;
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  case E_USER:
 | 
						|
    // Mi e' arrivato un E_HSCROLL camuffato E_USER dall'altra finestra di anteprima
 | 
						|
    ep->type = E_HSCROLL;
 | 
						|
    break;
 | 
						|
  default:
 | 
						|
    break;
 | 
						|
  }
 | 
						|
  TField_window::handler(win, ep);
 | 
						|
}
 | 
						|
 | 
						|
PNT TReport_window::log2dev(long x, long y) const
 | 
						|
{
 | 
						|
  x -= origin().x * 100L;
 | 
						|
  y -= origin().y * 100L;
 | 
						|
  PNT p;
 | 
						|
  p.h = short((x * _dpi.h) / (cpi() * 100L));
 | 
						|
  p.v = short((y * _dpi.v) / (lpi() * 100L));
 | 
						|
  return p;
 | 
						|
}
 | 
						|
 | 
						|
TPoint TReport_window::dev2log(const PNT& pt) const
 | 
						|
{
 | 
						|
  TPoint p;
 | 
						|
  p.x = pt.h * 100L * cpi() / _dpi.h; 
 | 
						|
  p.y = pt.v * 100L * lpi() / _dpi.v; 
 | 
						|
  p.x += origin().x * 100L;
 | 
						|
  p.y += origin().y * 100L;
 | 
						|
  return p;
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::draw_grid()
 | 
						|
{
 | 
						|
  const int k = 100;
 | 
						|
 | 
						|
  clear(COLOR_WHITE);
 | 
						|
 | 
						|
  const TReport_section& rs = curr_section();
 | 
						|
  int x = rs.width();
 | 
						|
  int y = rs.height();
 | 
						|
  if (x <= 0) x = 196*k;
 | 
						|
  if (y <= 0)  // Sezione ad altezza variabile
 | 
						|
  {
 | 
						|
    for (int i = 0; i < rs.items(); i++)
 | 
						|
    {
 | 
						|
      const TReport_field& rf = rs.field(i);
 | 
						|
      const TRectangle& rct = rf.get_rect();
 | 
						|
      const int fy = rct.bottom();
 | 
						|
      if (fy > y) y = fy;
 | 
						|
    }
 | 
						|
    const int mod = y % k;
 | 
						|
    if (mod != 0) y += k-mod;
 | 
						|
  }
 | 
						|
  
 | 
						|
  if (rs.type() == 'B' && rs.level() == 0)
 | 
						|
    x = y = 196*k;
 | 
						|
  
 | 
						|
  // Disegna l'eventuale sfondo di sezione
 | 
						|
  const bool draw_back = y > 0 && (rs.border() > 0 
 | 
						|
                               || (rs.pattern() >= PAT_SOLID && rs.back_color() != COLOR_WHITE));
 | 
						|
  if (draw_back)
 | 
						|
  {
 | 
						|
    const PNT p = log2dev(x, y);;
 | 
						|
    RCT rct; xvt_rect_set(&rct, 0, 0, p.h, p.v);
 | 
						|
    int rad = 0;
 | 
						|
    if (rs.radius() > 0)
 | 
						|
    {
 | 
						|
      const PNT p0 = log2dev(0,0); 
 | 
						|
      const PNT pr = log2dev(rs.radius(),rs.radius());
 | 
						|
      rad = min(pr.h-p0.h, pr.v-p0.v);
 | 
						|
    }
 | 
						|
    advanced_draw_rect(*this, rct, rs.pattern(), rs.border(), rs.fore_color(), rs.back_color(), rad);
 | 
						|
  }
 | 
						|
 | 
						|
  for (int i = x/k; i > 0; i--)
 | 
						|
  {
 | 
						|
    set_pen(i%10 ? MAKE_COLOR(232,232,255) : MAKE_COLOR(255,192,255));
 | 
						|
    line(0, i*k, x, i*k);
 | 
						|
    line(i*k, 0, i*k, y <= 0 ? x : y);
 | 
						|
  }
 | 
						|
 | 
						|
  if (y > 0)   // Disegna barra di fine sezione
 | 
						|
  {
 | 
						|
    const PNT p = log2dev(x, y);
 | 
						|
    RCT rct; xvt_vobj_get_client_rect(win(), &rct);
 | 
						|
    if (p.v < rct.bottom)
 | 
						|
    {
 | 
						|
      hide_pen();
 | 
						|
      set_brush(COLOR_LTGRAY, PAT_DIAGCROSS);
 | 
						|
      rct.top = p.v;
 | 
						|
      xvt_dwin_draw_rect(win(), &rct);
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::draw_broken_paper(const TReport_field& rf)
 | 
						|
{
 | 
						|
  set_pen(COLOR_LTGRAY);
 | 
						|
  const TRectangle& dr = rf.get_rect();
 | 
						|
  const int b = dr.bottom()-100;
 | 
						|
  line(short(dr.x), short(b), short(dr.x), short(dr.y));
 | 
						|
  line(short(dr.x), short(dr.y), short(dr.right()), short(dr.y));
 | 
						|
  line(short(dr.right()), short(dr.y), short(dr.right()), short(b));
 | 
						|
  for (int x = dr.left(); x < dr.right(); )
 | 
						|
  {
 | 
						|
    const int deltay = rand()%100;
 | 
						|
    int deltax = 200;
 | 
						|
    int ex = x + deltax;
 | 
						|
    if (ex > dr.right())
 | 
						|
    {
 | 
						|
      ex = dr.right();
 | 
						|
      deltax = ex-x;
 | 
						|
    }
 | 
						|
    line(short(x), short(b), short(x+deltax/2), short(b+deltay));
 | 
						|
    line(short(x+deltax/2), short(b+deltay), short(x+deltax), short(b));
 | 
						|
    x = ex;
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::draw_field(const TReport_field& rf)
 | 
						|
{
 | 
						|
  RCT r; TWindow::log2dev(rf.get_rect(), r);
 | 
						|
  int rad = 0;
 | 
						|
  if (rf.radius() > 0)
 | 
						|
  {
 | 
						|
    const int width = r.right - r.left;
 | 
						|
    rad = rf.radius() * width / rf.get_rect().width();
 | 
						|
  }
 | 
						|
 | 
						|
  PAT_STYLE back_pattern = PAT_HOLLOW;
 | 
						|
  const int k = (rf.hidden() ? 1 : 0) + (rf.deactivated() ? 2 : 0);
 | 
						|
  switch (k)
 | 
						|
  {
 | 
						|
  case  1: back_pattern = PAT_FDIAG; break;
 | 
						|
  case  2: back_pattern = PAT_BDIAG; break;
 | 
						|
  case  3: back_pattern = PAT_DIAGCROSS; break;
 | 
						|
  default: back_pattern = PAT_HOLLOW; break;
 | 
						|
  }
 | 
						|
 | 
						|
  switch (rf.type())
 | 
						|
  {
 | 
						|
  case 'E':
 | 
						|
    if (advanced_set_draw_tools(*this, rf.pattern(), rf.border(), rf.fore_color(), rf.back_color()))
 | 
						|
      xvt_dwin_draw_oval(win(), &r);  
 | 
						|
    back_pattern = PAT_HOLLOW;
 | 
						|
    break;
 | 
						|
  case 'I':
 | 
						|
    {
 | 
						|
      TVariant var;
 | 
						|
      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())
 | 
						|
        img->draw(win(), r);
 | 
						|
      advanced_draw_rect(*this, r, PAT_HOLLOW, rf.border(), rf.fore_color(), COLOR_WHITE, 0);
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  case 'L':
 | 
						|
    if (advanced_set_draw_tools(*this, PAT_SOLID, rf.border(), rf.fore_color(), COLOR_WHITE))
 | 
						|
    {
 | 
						|
      const PNT f = { r.top, r.left };
 | 
						|
      xvt_dwin_draw_set_pos(win(), f);
 | 
						|
      const PNT t = { r.bottom, r.right };
 | 
						|
      xvt_dwin_draw_line(win(), t);
 | 
						|
    }
 | 
						|
    back_pattern = PAT_HOLLOW;
 | 
						|
    break;
 | 
						|
  case 'R': 
 | 
						|
    advanced_draw_rect(*this, r, rf.pattern(), rf.border(), rf.fore_color(), rf.back_color(), rad);
 | 
						|
    break;
 | 
						|
  case 'T': 
 | 
						|
    {
 | 
						|
      advanced_draw_rect(*this, r, rf.pattern(), rf.border(), rf.fore_color(), rf.back_color(), rad);
 | 
						|
      xvt_dwin_set_font(win(), rf.font().get_xvt_font(*this));
 | 
						|
      set_color(rf.fore_color(), rf.back_color());
 | 
						|
      TString str = rf.picture();
 | 
						|
      advanced_draw_paragraph(*this, str, r, rf.horizontal_alignment(), rf.vertical_alignment()); 
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  default : 
 | 
						|
    if (rf.dynamic_height())
 | 
						|
      draw_broken_paper(rf);
 | 
						|
    else
 | 
						|
    {
 | 
						|
      if (rf.border() <= 0) // Rendi piu' visibile il bordo dei campi che non ce l'hanno
 | 
						|
        advanced_draw_rect(*this, r, PAT_HOLLOW, 1, COLOR_LTGRAY, COLOR_WHITE, 0);
 | 
						|
      else
 | 
						|
        advanced_draw_rect(*this, r, rf.pattern(), rf.border(), rf.fore_color(), rf.back_color(), rad);
 | 
						|
    }
 | 
						|
 | 
						|
    if (rf.link().not_empty())
 | 
						|
    {
 | 
						|
      XVT_FNTID lnkfont = xvt_font_create();
 | 
						|
      xvt_font_copy(lnkfont, rf.font().get_xvt_font(*this), XVT_FA_ALL);
 | 
						|
      xvt_font_set_style(lnkfont, XVT_FS_UNDERLINE);
 | 
						|
      xvt_dwin_set_font(win(), lnkfont);
 | 
						|
      xvt_font_destroy(lnkfont);
 | 
						|
      set_color(rf.link_color(), rf.back_color());
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      xvt_dwin_set_font(win(), rf.font().get_xvt_font(*this));
 | 
						|
      set_color(rf.fore_color(), rf.back_color());
 | 
						|
    }
 | 
						|
 | 
						|
    TString str;
 | 
						|
    if (rf.id() > 0)
 | 
						|
      str << rf.id();
 | 
						|
    else
 | 
						|
      str = rf.field();
 | 
						|
    advanced_draw_paragraph(*this, str, r, rf.horizontal_alignment(), rf.vertical_alignment()); 
 | 
						|
    break;
 | 
						|
  }
 | 
						|
 | 
						|
  if (back_pattern != PAT_HOLLOW)
 | 
						|
  {
 | 
						|
    set_pen(COLOR_LTGRAY);
 | 
						|
    set_brush(COLOR_LTGRAY, back_pattern);
 | 
						|
    xvt_dwin_draw_rect(win(), &r);
 | 
						|
  }
 | 
						|
  if (rf.selected())
 | 
						|
  {
 | 
						|
    advanced_set_draw_tools(*this, PAT_SOLID, 0, COLOR_WHITE, COLOR_GRAY);
 | 
						|
    const int k = 5;
 | 
						|
    RCT s = r; s.right = s.left+k; s.bottom = s.top+k;
 | 
						|
    xvt_dwin_draw_rect(win(), &s);  
 | 
						|
    s = r; s.left = s.right-k; s.bottom = s.top+k;
 | 
						|
    xvt_dwin_draw_rect(win(), &s);  
 | 
						|
    s = r; s.right = s.left+k; s.top = s.bottom-k;
 | 
						|
    xvt_dwin_draw_rect(win(), &s);  
 | 
						|
    s = r; s.left = s.right-k; s.top = s.bottom-k;
 | 
						|
    xvt_dwin_draw_rect(win(), &s);  
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void TReport_window::update()
 | 
						|
{
 | 
						|
  draw_grid(); // Disegna griglia
 | 
						|
 | 
						|
  const TReport_section& rs = curr_section();
 | 
						|
  for (int i = 0; i < rs.items(); i++)
 | 
						|
  {
 | 
						|
    const TReport_field& rf = rs.field(i);
 | 
						|
    draw_field(rf);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
int TReport_window::cpi() const 
 | 
						|
{ return _report != NULL ? _report->cpi() : 12; }
 | 
						|
 | 
						|
int TReport_window::lpi() const 
 | 
						|
{ 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), _type('B'), _level(1)
 | 
						|
{
 | 
						|
  _dpi.h = _dpi.v = 96;
 | 
						|
  _pixmap = true;
 | 
						|
  set_scroll_max(196,196);
 | 
						|
}
 | 
						|
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
// TReport_drawer
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
 | 
						|
TField_window* TReport_drawer::create_window(int x, int y, int dx, int dy, WINDOW parent)
 | 
						|
{
 | 
						|
  return new TReport_window(x, y, dx, dy, parent, this);
 | 
						|
}
 | 
						|
 | 
						|
void TReport_drawer::set_report_section(TReport_section& rs) 
 | 
						|
{ 
 | 
						|
  TReport_window* w = (TReport_window*)_win;
 | 
						|
  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();
 | 
						|
}
 |