tree.cpp Migliorata gestione alberi e campi relativi

utility.h    Aggiunta forward declaration di TFilename
validate.cpp Aggiunto validate per filtrare solo le ditte valide
window.h     Nessuna differenza rilevata da diff
xvtility.cpp Migliorata generazione rettangoli per supportare i campi
             di tipo TWindowed_field


git-svn-id: svn://10.65.10.50/trunk@6589 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-05-04 08:17:15 +00:00
parent b86fbf2f4c
commit 4fecfd7f1f
7 changed files with 79 additions and 21 deletions

View File

@ -16,10 +16,8 @@ HIDDEN bool callback_compare_node(TTree& node, void* jolly, word when)
HIDDEN bool callback_expand_node(TTree& node, void* jolly, word when)
{
if (jolly)
if (when == SCAN_PRE_ORDER)
node.expand();
else
node.shrink();
return FALSE;
}
@ -250,10 +248,17 @@ bool TTree::expand_all()
{
bool ok = goto_root();
if (ok)
scan_breadth_first(callback_expand_node, (void*)this);
scan_breadth_first(callback_expand_node, NULL);
return ok;
}
bool TTree::shrink_all()
{
_expanded.destroy();
return goto_root();
}
TImage* TTree::get_res_image(short bmp_id) const
{
TImage* bmp = (TImage*)_image.objptr(bmp_id);
@ -706,12 +711,12 @@ public:
const TNode_info& operator =(const TNode_info& ni)
{
_valid = ni._valid;
_id = ni._id;
_startx = ni._startx;
_endx = ni._endx;
_plusx = ni._plusx;
_expanded = ni._expanded;
_expandable = ni._expandable;
_id = ni._id;
_plusx = ni._plusx;
_startx = ni._startx;
_endx = ni._endx;
return ni;
}
@ -725,6 +730,7 @@ public:
void reset() { _valid = FALSE; }
TNode_info() : _valid(FALSE) { }
virtual ~TNode_info() { }
};
class TNode_info_array : public TObject
@ -807,6 +813,7 @@ public:
TTree* tree() const { return _tree; }
void set_tree(TTree* tree) { _tree = tree; _first_line = -1; }
void hide_leaves(bool yes) { _hide_leaves = yes; }
bool select_current();
TTree_window(int x, int y, int dx, int dy,
WINDOW parent, TTree_field* owner);
@ -832,7 +839,7 @@ bool TTree_window::callback_draw_node(TTree& node, void* jolly, word when)
if (when == SCAN_PRE_ORDER)
{
if (ui->_y >= ui->_firsty && ui->_y < ui->_lasty)
if (ui->_y >= ui->_firsty && ui->_y <= ui->_lasty)
{
node.curr_id(ui->_str);
const bool is_selected = ui->_str == ui->_curr_info->_id;
@ -903,6 +910,8 @@ bool TTree_window::callback_draw_node(TTree& node, void* jolly, word when)
if (when == SCAN_IN_ORDER)
{
ui->_x -= TABX;
if (ui->_y > ui->_lasty)
return TRUE;
}
return FALSE;
@ -1023,6 +1032,13 @@ void TTree_window::update()
_first_line = ui._firsty;
}
bool TTree_window::select_current()
{
if (_tree)
_tree->curr_id(_curr_info._id);
return _tree != NULL;
}
int TTree_window::info2index(const TNode_info& info) const
{
return _node_info.find(info);
@ -1084,6 +1100,24 @@ bool TTree_window::on_key(KEY key)
if (_tree == NULL)
return FALSE;
if (key == K_RIGHT)
{
if (_tree->goto_node(_curr_info._id) &&
!_tree->expanded() && _tree->has_son())
key = K_ENTER;
else
key = K_DOWN;
}
if (key == K_LEFT)
{
if (_tree->goto_node(_curr_info._id) &&
_tree->expanded())
key = K_ENTER;
else
key = K_UP;
}
if (key == K_UP || key == K_DOWN)
{
int index = info2index(_curr_info);
@ -1128,7 +1162,11 @@ bool TTree_window::on_key(KEY key)
else
ok = _tree->expand();
if (ok)
{
force_update();
do_events();
}
owner().on_key(K_CTRL + K_SPACE);
}
}
@ -1161,7 +1199,10 @@ void TTree_window::handler(WINDOW win, EVENT* ep)
}
else
{
owner().on_key(K_SPACE);
KEY key = K_SPACE;
if (ep->type == E_MOUSE_DBL)
key += K_CTRL;
owner().on_key(key);
}
if (ok)
{
@ -1209,6 +1250,7 @@ TTree* TTree_field::tree() const
void TTree_field::set_tree(TTree* tree)
{
tree_win().set_tree(tree);
tree_win().select_current();
}
void TTree_field::hide_leaves(bool yes)
@ -1216,6 +1258,11 @@ void TTree_field::hide_leaves(bool yes)
tree_win().hide_leaves(yes);
}
bool TTree_field::select_current()
{
return tree_win().select_current();
}
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);

View File

@ -55,13 +55,14 @@ public:
virtual bool kill_node() { return FALSE; }
virtual void curr_id(TString& id) const { node2id(curr_node(), id); }
virtual bool get_description(TString& desc) const { curr_id(desc); return desc.not_empty(); }
virtual bool expand();
virtual bool shrink();
virtual bool expanded() const;
virtual bool shrunk() const { return !expanded(); }
virtual bool expand_all();
virtual bool shrink_all();
virtual TImage* image(bool selected) const;
virtual bool scan_depth_first(NODE_HANDLER nh, void* jolly, word flags = SCAN_PRE_ORDER);

View File

@ -6,6 +6,7 @@
#endif
class TString_array;
class TFilename;
char* format (const char* fmt, ...);
const char* cmd2name(const char* argv0, const char* argv1 = "");

View File

@ -772,9 +772,19 @@ HIDDEN bool _ora_val(TMask_field& f, KEY key)
return TRUE;
}
HIDDEN bool _firm_val(TMask_field& f, KEY key)
{
bool ok = TRUE;
if (f.to_check(key))
{
const long firm = atol(f.get());
if (firm > 0 && !prefix().exist(firm))
ok = f.error_box("Non esistono gli archivi della ditta %ld.", firm);
}
return ok;
}
#define MAX_FUNC 24
#define MAX_FUNC 25
HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] =
{
@ -802,7 +812,7 @@ HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] =
_not_empty_chkfld_val,
_ora_val,
_sconto_val,
_firm_val,
};
// @doc INTERNAL

View File

@ -143,14 +143,12 @@ TVariable_rectype::TVariable_rectype(const TBaseisamfile* i)
TVariable_rectype::TVariable_rectype(const TRectype& r)
: TRectype(r), _memo_fld_to_load(FALSE)
{
}
TVariable_rectype::TVariable_rectype(const TVariable_rectype& r)
: TRectype((const TRectype &) r), _memo_fld_to_load(FALSE)
{
_virtual_fields = r._virtual_fields;
_memo_fld = r._memo_fld;
@ -208,8 +206,8 @@ void TVariable_rectype::set_memo_fld( const char * fieldname)
{
if (fieldname && *fieldname)
{
CHECK(exist(fieldname), "Unknown memo field");
CHECK(type(fieldname) == _memofld, "Incorrect field type");
CHECKS(exist(fieldname), "Unknown memo field", fieldname);
CHECKS(type(fieldname) == _memofld, "Incorrect field type", fieldname);
_memo_fld = fieldname;
}
else

View File

@ -396,14 +396,15 @@ protected:
// @cmember Converte le coordinate logiche (caratteri) in coordinate fisiche (pixel)
virtual PNT log2dev(long x, long y) const;
// @cmember Gestice la pressione del tasto
virtual bool on_key(KEY key);
// @access Public Member
public:
// @cmember Costruttore
TScroll_window();
// @cmember Gestice la pressione del tasto
virtual bool on_key(KEY key);
// @cmember Gestisce l'handler della finestra (vedi <mf TWindow::handler>)
virtual void handler(WINDOW win, EVENT* ep);

View File

@ -58,7 +58,7 @@ RCT& resize_rect(
if (parent != m->toolwin())
y++;
}
if (x > 0 || (wt != WO_TE && x == 0))
if (x > 0 || (wt != WO_TE && wt != W_PLAIN && x == 0))
{
RCT pc; xvt_vobj_get_client_rect(parent, &pc); // Get parent window size
const int width = pc.right;