tree.cpp Aggiunta possibilita' di non disegnare le foglie
utility.cpp Migliorata leggibilita' delle funzioni encode/decode viswin.* Derivata la TViswin da TField_window, non piu' da TScroll_window window.* Reso pubblico il metodo parent() usato ora da TWindowed_field git-svn-id: svn://10.65.10.50/trunk@6187 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									d38dca6338
								
							
						
					
					
						commit
						f464012520
					
				| @ -1,5 +1,3 @@ | ||||
| #include <stdio.h> | ||||
|              | ||||
| #include <colors.h>             | ||||
| #include <tree.h> | ||||
| #include <urldefid.h> | ||||
| @ -672,11 +670,9 @@ bool TString_tree::get_description(TString& str) const | ||||
| } | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| // TTree_window
 | ||||
| // TNode_info
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| #include <maskfld.h> | ||||
| 
 | ||||
| class TNode_info : public TSortable | ||||
| { | ||||
| public: | ||||
| @ -757,11 +753,17 @@ int TNode_info_array::find(const TNode_info& ni) const | ||||
|   return i; | ||||
| } | ||||
| 
 | ||||
| class TTree_window : public TScroll_window | ||||
| {    | ||||
|   TTree_field* _owner; | ||||
|   TTree* _tree; | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| // TTree_window
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| #include <maskfld.h> | ||||
| 
 | ||||
| class TTree_window : public TField_window | ||||
| {    | ||||
|   TTree* _tree; | ||||
|   bool _hide_leaves; | ||||
|   long _first_line;        // Prima riga disegnata
 | ||||
|   TNode_info_array _node_info; | ||||
|   TNode_info _curr_info;   // Nodo attualmente selezionato
 | ||||
| @ -781,6 +783,7 @@ protected: // Internal use | ||||
| public:         | ||||
|   TTree* tree() const { return _tree; } | ||||
|   void set_tree(TTree* tree) { _tree = tree; _first_line = -1; } | ||||
|   void hide_leaves(bool yes) { _hide_leaves = yes; } | ||||
| 
 | ||||
|   TTree_window(int x, int y, int dx, int dy,  | ||||
|                WINDOW parent, TTree_field* owner); | ||||
| @ -913,7 +916,8 @@ void TTree_window::draw_plus_minus() | ||||
| 
 | ||||
| void TTree_window::update() | ||||
| {  | ||||
|   xvt_dwin_clear(win(), NORMAL_BACK_COLOR); | ||||
|   TField_window::update(); | ||||
| 
 | ||||
|   if (_tree == NULL) | ||||
|     return; | ||||
| 
 | ||||
| @ -947,7 +951,9 @@ void TTree_window::update() | ||||
|    | ||||
|   _node_info.reset(); | ||||
|    | ||||
|   const word flags = SCAN_IGNORING_UNEXPANDED | SCAN_PRE_ORDER | SCAN_IN_ORDER; | ||||
|   word flags = SCAN_PRE_ORDER | SCAN_IN_ORDER | SCAN_IGNORING_UNEXPANDED; | ||||
|   if (_hide_leaves) flags |= SCAN_IGNORING_LEAVES; | ||||
|    | ||||
|   _tree->scan_depth_first(callback_draw_node, &ui, flags); | ||||
|   while (ui._y < ui._lasty) | ||||
|   { | ||||
| @ -1042,14 +1048,14 @@ bool TTree_window::on_key(KEY key) | ||||
|     if (ok && _curr_info != ni)  | ||||
|     { | ||||
|       _tree->curr_id(_curr_info._id); | ||||
|       _owner->on_key(K_SPACE); | ||||
|       owner().on_key(K_SPACE); | ||||
|       if (!scroll) | ||||
|         force_update(); | ||||
|     }   | ||||
|     if (!scroll) | ||||
|       return TRUE; | ||||
|   } | ||||
|   return TScroll_window::on_key(key); | ||||
|   return TField_window::on_key(key); | ||||
| } | ||||
| 
 | ||||
| void TTree_window::handler(WINDOW win, EVENT* ep) | ||||
| @ -1074,11 +1080,11 @@ void TTree_window::handler(WINDOW win, EVENT* ep) | ||||
|           else   | ||||
|             ok = _tree->expand(); | ||||
|           if (ok) | ||||
|             _owner->on_key(K_CTRL + K_SPACE); | ||||
|             owner().on_key(K_CTRL + K_SPACE); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|           _owner->on_key(K_SPACE); | ||||
|           owner().on_key(K_SPACE); | ||||
|         }   | ||||
|         if (ok) | ||||
|         { | ||||
| @ -1089,22 +1095,15 @@ void TTree_window::handler(WINDOW win, EVENT* ep) | ||||
|     }   | ||||
|     break; | ||||
|   default: | ||||
|     TScroll_window::handler(win, ep); | ||||
|     TField_window::handler(win, ep); | ||||
|     break; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| TTree_window::TTree_window(int x, int y, int dx, int dy,  | ||||
|                            WINDOW parent, TTree_field* owner)           | ||||
|             : _owner(owner), _tree(NULL) | ||||
|             : TField_window(x, y, dx, dy, parent, owner), _tree(NULL), _hide_leaves(FALSE) | ||||
| {                                | ||||
|   create(x, y, dx, dy, "", WSF_HSCROLL | WSF_VSCROLL, W_PLAIN, parent); | ||||
|   set_font(); | ||||
|   activate(owner->enabled()); | ||||
|   if (owner->shown())  | ||||
|     open(); | ||||
|   else | ||||
|     close();   | ||||
| } | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| @ -1135,10 +1134,12 @@ void TTree_field::set_tree(TTree* tree) | ||||
|   tree_win().set_tree(tree); | ||||
| } | ||||
| 
 | ||||
| void TTree_field::create(WINDOW parent) | ||||
| void TTree_field::hide_leaves(bool yes) | ||||
| { | ||||
|   TWindowed_field::create(parent); | ||||
|   set_win(new TTree_window(_ctl_data._x, _ctl_data._y,  | ||||
|                            _ctl_data._width, _ctl_data._size,  | ||||
|                            parent, this)); | ||||
|   tree_win().hide_leaves(yes); | ||||
| } | ||||
| 
 | ||||
| TField_window* TTree_field::create_window(int x, int y, int dx, int dy, WINDOW parent) | ||||
| { | ||||
|   return new TTree_window(x, y, dx, dy, parent, this); | ||||
| }            | ||||
|  | ||||
| @ -429,7 +429,7 @@ const char *esc( | ||||
|   return(__tmp_string); | ||||
| } | ||||
| 
 | ||||
| HIDDEN const char * const key = "QSECOFR-"; | ||||
| HIDDEN const char * const encryption_key = "QSECOFR-"; | ||||
| 
 | ||||
| // @doc EXTERNAL
 | ||||
| 
 | ||||
| @ -442,7 +442,7 @@ const char * encode( | ||||
|   // @xref <f decode>
 | ||||
| { | ||||
|   for (int i = 0; data[i]; i++) | ||||
|     __tmp_string[i] = data[i] + (i < 8 ? key[i] : data[i - 8]); | ||||
|     __tmp_string[i] = data[i] + (i < 8 ? encryption_key[i] : data[i - 8]); | ||||
|   __tmp_string[i] = '\0'; | ||||
|   return __tmp_string;  | ||||
| } | ||||
| @ -458,7 +458,7 @@ const char * decode( | ||||
|   // @xref <f encode>
 | ||||
| { | ||||
|   for (int i = 0; data[i]; i++) | ||||
|     __tmp_string[i] = data[i] - (i < 8 ? key[i] : __tmp_string[i - 8]); | ||||
|     __tmp_string[i] = data[i] - (i < 8 ? encryption_key[i] : __tmp_string[i - 8]); | ||||
|   __tmp_string[i] = '\0'; | ||||
|   return __tmp_string;  | ||||
| } | ||||
|  | ||||
| @ -1187,6 +1187,9 @@ void TViswin::update () | ||||
| //  }
 | ||||
|   if (_need_update) | ||||
|   {                       | ||||
|     if (!_toplevel) | ||||
|       TField_window::update(); | ||||
|    | ||||
|     check_link(); | ||||
|     if (_isselection) | ||||
|       erase_selection (); | ||||
| @ -2463,6 +2466,7 @@ TViswin::TViswin(const char *fname, | ||||
|                  bool rulers,    // overridden by config parms
 | ||||
|                  WINDOW parent, | ||||
|                  TBrowsefile_field* brwfld): | ||||
|                  TField_window(x, y, width, height, parent, brwfld), | ||||
|                  _filename (fname), _txt (fname, BUFFERSIZE), _islink (linkbutton), _isedit (editbutton), | ||||
|                  _isprint (printbutton), _isbar (FALSE), _istimer (FALSE), _iscross (FALSE), | ||||
|                  _isselection (FALSE), _sel_displayed (FALSE), _cross_displayed (FALSE), | ||||
| @ -2500,34 +2504,30 @@ TViswin::TViswin(const char *fname, | ||||
|       _rulers = cnf.get_bool("Righelli", NULL, -1,TRUE);   | ||||
|   } | ||||
|    | ||||
|   const int larg = 76; | ||||
|   const int alt = 20; | ||||
| 
 | ||||
|   RCT r; | ||||
| 
 | ||||
|   xvt_vobj_get_client_rect (parent, &r); | ||||
|   int maxlarg = width == 0 ? (r.right / CHARX - 6)  : width;    | ||||
|   int maxalt = height == 0 ? (r.bottom / CHARY - 6) : height;   | ||||
| 
 | ||||
|   if (_toplevel) | ||||
|   { | ||||
|     const int larg = 76; | ||||
|     const int alt = 20; | ||||
|      | ||||
|     if (_toplevel && larg > maxlarg) | ||||
|       maxlarg = larg; | ||||
|     if (_toplevel && alt > maxalt) | ||||
|       maxalt = alt; | ||||
|    | ||||
|     long flags = WSF_HSCROLL | WSF_VSCROLL | WSF_SIZE; | ||||
|     create(x, y, maxlarg, maxalt, title, flags, W_DOC, parent, | ||||
|             _toplevel ? VISWIN_BAR : 0); | ||||
|   } | ||||
|    | ||||
|   for (int i = 0; i < 4; i++) | ||||
|     _modules.add(new TImage(BMP_MODULE1 + i), i); | ||||
|   _modules.add(new TImage(BMP_MODULE), i); | ||||
| 
 | ||||
|   long flags = WSF_HSCROLL | WSF_VSCROLL; | ||||
|   if (_toplevel)  | ||||
|   { | ||||
|     flags |= WSF_SIZE /* | WSF_CLOSE */;                     | ||||
|   }   | ||||
|    | ||||
|   WIN_TYPE rt = _toplevel ? W_DOC : W_PLAIN; | ||||
|   create(x, y, maxlarg, maxalt, title, flags, rt, parent, | ||||
|           _toplevel ? VISWIN_BAR : 0); | ||||
| 
 | ||||
|   attach_interface(win(), BACKGROUND); | ||||
| 
 | ||||
|   set_opaque_text (TRUE); | ||||
| @ -2610,7 +2610,7 @@ TViswin ::~TViswin () | ||||
| 
 | ||||
| // Certified 100%
 | ||||
| TBrowsefile_field::TBrowsefile_field(TMask* m) | ||||
| : TOperable_field(m), _viswin(NULL), _m_link(FALSE), _background(36), _lh(NULL) | ||||
|                  : TWindowed_field(m), _m_link(FALSE), _background(36), _lh(NULL) | ||||
| {} | ||||
| 
 | ||||
| // Certified 100%
 | ||||
| @ -2622,34 +2622,13 @@ word TBrowsefile_field::class_id() const | ||||
| // Certified 100%
 | ||||
| TBrowsefile_field::~TBrowsefile_field() | ||||
| { | ||||
|   delete _viswin; | ||||
| } | ||||
| 
 | ||||
| void TBrowsefile_field::parse_head(TScanner& scanner) | ||||
| { | ||||
|   _ctl_data._width = scanner.integer(); | ||||
|   _ctl_data._size  = scanner.integer(); | ||||
| } | ||||
| 
 | ||||
| void TBrowsefile_field::set_vis_win(TViswin* viswin) | ||||
| { | ||||
|   if (_viswin != NULL) | ||||
|     delete _viswin; | ||||
|   _viswin = viswin;   | ||||
| } | ||||
| 
 | ||||
| // Certified 100%
 | ||||
| void TBrowsefile_field::create(WINDOW parent) | ||||
| TField_window* TBrowsefile_field::create_window(int x, int y, int dx, int dy, WINDOW parent) | ||||
| {                             | ||||
|   if (_viswin == NULL) | ||||
|     _viswin = new TViswin(_ctl_data._prompt, _ctl_data._prompt, FALSE, FALSE, FALSE,  | ||||
|                           _ctl_data._x, _ctl_data._y, _ctl_data._size, _ctl_data._width,  | ||||
|                           _flags.rightjust ? TRUE : FALSE, parent, this); | ||||
|   _dlg    = _ctl_data._dlg; | ||||
|   _parent = parent; | ||||
|   WINDOW win = _viswin->win(); | ||||
|   xvt_vobj_set_enabled(win, enabled()); | ||||
|   xvt_vobj_set_visible(win, shown()); | ||||
|   return new TViswin(_ctl_data._prompt, _ctl_data._prompt, FALSE, FALSE, FALSE,  | ||||
|                      x, y, dy, dx, _flags.rightjust ? TRUE : FALSE, parent, this); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| @ -2685,7 +2664,7 @@ long TBrowsefile_field::set_text(const char* file, const char* line) | ||||
|   }                          | ||||
|   fclose(instr);          | ||||
|    | ||||
|   _viswin->close_print();                                     | ||||
|   vis_win().close_print();                                     | ||||
|    | ||||
|   return ret; | ||||
| }                                   | ||||
| @ -2715,7 +2694,7 @@ int TBrowsefile_field::enable_link(const char *descr, char fg, char bg) | ||||
|     b[0] = bg; | ||||
|     tt->add(b); | ||||
|     lnk = _links.add(tt); | ||||
|     _viswin->_txt.set_hotspots(fg, bg); | ||||
|     vis_win()._txt.set_hotspots(fg, bg); | ||||
|   } | ||||
| 
 | ||||
|   return lnk; | ||||
| @ -2744,42 +2723,42 @@ void TBrowsefile_field::set_background(const char* bg) | ||||
|    | ||||
| void TBrowsefile_field::add_line(const char* l)             | ||||
| {  | ||||
|   _viswin->add_line(l); | ||||
|   vis_win().add_line(l); | ||||
| }  | ||||
| 
 | ||||
| void TBrowsefile_field::close()  | ||||
| {  | ||||
|   _viswin->close_print();  | ||||
|   vis_win().close_print();  | ||||
| } | ||||
| 
 | ||||
| void TBrowsefile_field::goto_pos(long r, long c) | ||||
| { | ||||
|   _viswin->goto_pos(r,c,TRUE); | ||||
|   vis_win().goto_pos(r,c,TRUE); | ||||
| } | ||||
| 
 | ||||
| void  TBrowsefile_field::goto_top()            | ||||
| {  | ||||
|   _viswin->goto_top();   | ||||
|   vis_win().goto_top();   | ||||
| } | ||||
| 
 | ||||
| void  TBrowsefile_field::goto_end()            | ||||
| {  | ||||
|   _viswin->goto_end();  | ||||
|   vis_win().goto_end();  | ||||
| }                        | ||||
| 
 | ||||
| void  TBrowsefile_field::refresh() | ||||
| { | ||||
|   _viswin->refresh(); | ||||
|   vis_win().refresh(); | ||||
| } | ||||
| 
 | ||||
| const char* TBrowsefile_field::get_text(long line, int column, int len) | ||||
| {  | ||||
|   return _viswin->_txt.line(line,(long)column, len);  | ||||
|   return vis_win()._txt.line(line,(long)column, len);  | ||||
| } | ||||
| 
 | ||||
| long TBrowsefile_field::lines() | ||||
| { | ||||
|   return _viswin->_txt.lines(); | ||||
|   return vis_win()._txt.lines(); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -5,8 +5,8 @@ | ||||
| class TPushbutton_control; | ||||
| #endif | ||||
| 
 | ||||
| #ifndef __WINDOW_H | ||||
| #include <window.h> | ||||
| #ifndef __MASK_H | ||||
| #include <mask.h> | ||||
| #endif | ||||
| 
 | ||||
| #ifndef __TEXTFILE_H | ||||
| @ -20,7 +20,7 @@ class TBrowsefile_field; | ||||
| // @class TViswin | Classe per la gestione della finestra video di anteprima di stampa
 | ||||
| //
 | ||||
| // @base public | TScroll_window
 | ||||
| class TViswin : public TScroll_window | ||||
| class TViswin : public TField_window | ||||
| 
 | ||||
| // @author:(INTERNAL) Villa
 | ||||
| 
 | ||||
|  | ||||
| @ -1056,7 +1056,6 @@ void TWindow::line(short x0, short y0, short x1, short y1) | ||||
|   PNT f = log2dev(x0,y0); | ||||
|   PNT t = log2dev(x1,y1); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 | ||||
|   if (!_pixmap)  | ||||
|   { | ||||
|     if (f.h == 0) f.h = -CHARX; else f.h += CHARX>>1; | ||||
| @ -1064,7 +1063,6 @@ void TWindow::line(short x0, short y0, short x1, short y1) | ||||
|     if (t.h == 0) t.h = -CHARX; else t.h += CHARX>>1; | ||||
|     if (t.v == 0) t.v = -CHARY; else t.v += CHARY>>1; | ||||
|   } | ||||
| #endif | ||||
| 
 | ||||
|   xvt_dwin_draw_set_pos(win(), f); | ||||
|   xvt_dwin_draw_line(win(), t); | ||||
|  | ||||
| @ -193,9 +193,6 @@ protected: | ||||
|   void set_modal(bool m) | ||||
|   { _modal = m; } | ||||
| 
 | ||||
|   // @cmember Ritorna l'handler della finestra padre
 | ||||
|   WINDOW parent() const; | ||||
| 
 | ||||
|   // @cmember Fa' l'update della finstra
 | ||||
|   virtual void update() | ||||
|   {} | ||||
| @ -221,6 +218,8 @@ public: | ||||
|   // @cmember Ritorna il descrittore della finestra
 | ||||
|   virtual WINDOW win() const | ||||
|   { return _win; }    | ||||
|   // @cmember Ritorna il descrittore della finestra padre
 | ||||
|   WINDOW parent() const; | ||||
| 
 | ||||
|   // @cmember Gestisce la pressione del tasto
 | ||||
|   virtual bool on_key(KEY) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user