ba0.* Gestione menu ad albero
ba1.cpp Aggiunti commenti ba1300.cpp Nessuna differenza ba2* Gestione backup con pkzip ba3* e b4* Aggiornata get_next_key git-svn-id: svn://10.65.10.50/trunk@6594 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
36a51e5877
commit
fdbdc4c011
554
ba/ba0.cpp
554
ba/ba0.cpp
@ -9,6 +9,7 @@
|
||||
#include <prefix.h>
|
||||
#include <progind.h>
|
||||
#include <stack.h>
|
||||
#include <tree.h>
|
||||
#include <utility.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
@ -39,54 +40,117 @@ public:
|
||||
|
||||
class TPicture_mask : public TMask
|
||||
{
|
||||
TImage& _image;
|
||||
TImage* _image;
|
||||
|
||||
static TString _last_string;
|
||||
|
||||
protected: // TMask
|
||||
virtual void update();
|
||||
virtual bool on_key(KEY k);
|
||||
|
||||
public:
|
||||
virtual bool stop_run(KEY key) ;
|
||||
TPicture_mask(const char* name, int dx, int dy, TImage& image);
|
||||
virtual bool stop_run(KEY key);
|
||||
|
||||
void set_last_search_string(const char* str) { _last_string = str; }
|
||||
void set_image(TImage* image);
|
||||
|
||||
TPicture_mask(const char* name, int dx, int dy, TImage* image, int x = -1, int y = -1);
|
||||
virtual ~TPicture_mask() {}
|
||||
};
|
||||
|
||||
TPicture_mask::TPicture_mask(const char* name, int dx, int dy, TImage& image)
|
||||
: TMask(name, 1, dx, dy), _image(image)
|
||||
TString TPicture_mask::_last_string;
|
||||
|
||||
TPicture_mask::TPicture_mask(const char* name, int dx, int dy,
|
||||
TImage* image, int x, int y)
|
||||
: TMask(name, 1, dx, dy, x, y)
|
||||
{
|
||||
if (_image.ok())
|
||||
_image.set_palette(win());
|
||||
set_image(image);
|
||||
}
|
||||
|
||||
void TPicture_mask::set_image(TImage* image)
|
||||
{
|
||||
if (image && image->ok())
|
||||
{
|
||||
_image = image;
|
||||
_image->set_palette(win());
|
||||
}
|
||||
else
|
||||
_image = NULL;
|
||||
}
|
||||
|
||||
bool TPicture_mask::stop_run(KEY key)
|
||||
{
|
||||
if (key==K_FORCE_CLOSE)
|
||||
key=K_QUIT;
|
||||
if (key == K_FORCE_CLOSE)
|
||||
key = K_QUIT;
|
||||
return TWindow::stop_run(key);
|
||||
}
|
||||
|
||||
void TPicture_mask::update()
|
||||
{
|
||||
if (_image.ok())
|
||||
if (_image && _image->ok())
|
||||
{
|
||||
RCT cli; field(101).get_rect(cli);
|
||||
const int topx = cli.left;
|
||||
|
||||
RCT cli;
|
||||
field(DLG_USER).get_rect(cli);
|
||||
const int topy = cli.top;
|
||||
|
||||
const double ratiox = double(topx) / _image.width();
|
||||
const double ratioy = double(topy) / _image.height();
|
||||
int vy = cli.top;
|
||||
|
||||
const TMask_field& fld = field(101);
|
||||
fld.get_rect(cli);
|
||||
int vx = cli.left;
|
||||
if (fld.class_id() == CLASS_TREE_FIELD)
|
||||
{
|
||||
vx = -cli.right;
|
||||
::xvt_vobj_get_client_rect(win(), &cli);
|
||||
vx += cli.right - CHARX;
|
||||
vy = cli.bottom;
|
||||
}
|
||||
|
||||
const double ratiox = double(vx) / _image->width();
|
||||
const double ratioy = double(vy) / _image->height();
|
||||
const double ratio = min(ratiox, ratioy);
|
||||
const int maxx = int(ratio * _image.width());
|
||||
const int maxy = int(ratio * _image.height());
|
||||
const int maxx = int(ratio * _image->width());
|
||||
const int maxy = int(ratio * _image->height());
|
||||
int x = 1;
|
||||
int y = 1;
|
||||
if (fld.class_id() == CLASS_TREE_FIELD)
|
||||
{
|
||||
x = cli.right - maxx + 1;
|
||||
y = (cli.bottom - maxy) / 2;
|
||||
}
|
||||
|
||||
RCT dst; xvt_rect_set(&dst, 1, 1, maxx, maxy);
|
||||
RCT dst;
|
||||
::xvt_rect_set(&dst, x, y, x+maxx-1, y+maxy-1);
|
||||
|
||||
if (xvt_dwin_is_update_needed(win(), &dst))
|
||||
_image.draw(win(), dst);
|
||||
if (::xvt_dwin_is_update_needed(win(), &dst))
|
||||
_image->draw(win(), dst);
|
||||
}
|
||||
}
|
||||
|
||||
bool TPicture_mask::on_key(KEY k)
|
||||
{
|
||||
switch (k)
|
||||
{
|
||||
case K_F3:
|
||||
case K_F8:
|
||||
set(DLG_USER, _last_string, TRUE);
|
||||
return TRUE;
|
||||
case K_ENTER:
|
||||
case K_UP:
|
||||
case K_DOWN:
|
||||
case K_LEFT:
|
||||
case K_RIGHT:
|
||||
if (focus_field().is_kind_of(CLASS_TREE_FIELD))
|
||||
{
|
||||
TTree_field& tf = (TTree_field&)focus_field();
|
||||
return tf.win().on_key(k);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TMask::on_key(k);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Color Mask
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -458,6 +522,7 @@ class TMenu : public TAssoc_array
|
||||
TStack _stack;
|
||||
|
||||
TFilename _default_bmp;
|
||||
TString _default_menu;
|
||||
|
||||
TAssoc_array _images;
|
||||
TAssoc_array _modules;
|
||||
@ -472,6 +537,7 @@ public:
|
||||
TSubmenu& current() const { return *_current; }
|
||||
TSubmenu* find(const char* name) const { return (TSubmenu*)objptr(name); }
|
||||
bool jumpto(TSubmenu *next);
|
||||
bool jumpto_root();
|
||||
|
||||
TSubmenu& pop();
|
||||
bool at_top() const { return _stack.count() == 0; }
|
||||
@ -801,10 +867,11 @@ bool TMenu::read(const char* name, TString& root)
|
||||
|
||||
bool TMenu::read(const char* name)
|
||||
{
|
||||
TString root(50);
|
||||
TString root;
|
||||
bool ok = read(name, root);
|
||||
if (ok && _current == NULL)
|
||||
{
|
||||
_default_menu = root;
|
||||
_current = find(root);
|
||||
_item = 0;
|
||||
}
|
||||
@ -841,6 +908,12 @@ bool TMenu::jumpto(TSubmenu* next)
|
||||
return next != NULL;
|
||||
}
|
||||
|
||||
bool TMenu::jumpto_root()
|
||||
{
|
||||
TSubmenu* sm = find(_default_menu);
|
||||
return jumpto(sm);
|
||||
}
|
||||
|
||||
TSubmenu& TMenu::pop()
|
||||
{
|
||||
TSubmenu* sm = _current;
|
||||
@ -938,14 +1011,9 @@ void TMenu::reload_images()
|
||||
for (THash_object* h = _images.get_hashobj(); h; h = _images.get_hashobj())
|
||||
{
|
||||
const TString& name = h->key();
|
||||
if (name == _default_bmp)
|
||||
{
|
||||
TImage& i = (TImage&)h->obj();
|
||||
i.load(name);
|
||||
i.convert_transparent_color(MASK_BACK_COLOR);
|
||||
}
|
||||
else
|
||||
_images.remove(name);
|
||||
TImage& i = (TImage&)h->obj();
|
||||
i.load(name);
|
||||
i.convert_transparent_color(MASK_BACK_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -984,6 +1052,7 @@ class TMenu_application : public TApplication
|
||||
const char* _name;
|
||||
|
||||
TMenu _menu;
|
||||
bool _tree_view;
|
||||
|
||||
TPicture_mask* _mask;
|
||||
|
||||
@ -1001,9 +1070,14 @@ protected:
|
||||
void test_temp();
|
||||
void load_menu();
|
||||
int do_level();
|
||||
int do_tree();
|
||||
bool check_user();
|
||||
static bool menu_item_handler(TMask_field&f, KEY k);
|
||||
static bool menu_find_handler(TMask_field&f, KEY k);
|
||||
|
||||
static bool menu_item_handler(TMask_field& f, KEY k);
|
||||
static bool menu_find_handler(TMask_field& f, KEY k);
|
||||
static bool tree_handler(TMask_field& f, KEY k);
|
||||
static bool tree_find_handler(TMask_field& f, KEY k);
|
||||
static bool tree_shrink_handler(TMask_field& f, KEY k);
|
||||
|
||||
bool choose_colors();
|
||||
bool choose_editors();
|
||||
@ -1042,7 +1116,9 @@ bool TMenu_application::menu_find_handler(TMask_field&f, KEY k)
|
||||
{
|
||||
const TString& v = f.get();
|
||||
if (v.not_empty())
|
||||
{
|
||||
{
|
||||
TPicture_mask& m = (TPicture_mask&)f.mask();
|
||||
m.set_last_search_string(v);
|
||||
if (app()._menu.find_string(v))
|
||||
{
|
||||
f.set_focusdirty(FALSE);
|
||||
@ -1068,7 +1144,7 @@ int TMenu_application::do_level()
|
||||
|
||||
TImage& image = _menu.image(curr.picture());
|
||||
|
||||
TPicture_mask mask(curr.caption(), width, height, image);
|
||||
TPicture_mask mask(curr.caption(), width, height, &image);
|
||||
CHECK(_mask == NULL, "Two masks are better than one?");
|
||||
_mask = &mask;
|
||||
|
||||
@ -1281,10 +1357,16 @@ bool TMenu_application::check_user()
|
||||
}
|
||||
}
|
||||
|
||||
if (ok && utente != "PRASSI")
|
||||
if (ok)
|
||||
{
|
||||
TConfig prawin(CONFIG_INSTALL, "Main");
|
||||
prawin.set("User", utente);
|
||||
if (utente != "PRASSI")
|
||||
{
|
||||
TConfig prawin(CONFIG_INSTALL, "Main");
|
||||
prawin.set("User", utente);
|
||||
}
|
||||
|
||||
TConfig userini(CONFIG_USER, "ba0");
|
||||
_tree_view = userini.get_bool("TreeView");
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -1347,7 +1429,7 @@ bool TMenu_application::main_loop()
|
||||
bool run = TRUE;
|
||||
while (run)
|
||||
{
|
||||
const int m = do_level();
|
||||
const int m = _tree_view ? do_tree() : do_level();
|
||||
if (m > 0)
|
||||
_menu.perform();
|
||||
else
|
||||
@ -1487,7 +1569,7 @@ HIDDEN bool study_handler(TMask_field& f, KEY k)
|
||||
TFilename path(f.get());
|
||||
path.add("com");
|
||||
path.add("dir.gen");
|
||||
if (!fexist(path))
|
||||
if (!path.exist())
|
||||
ok = f.error_box("La directory %s non e' uno studio valido!",
|
||||
(const char*)f.get());
|
||||
}
|
||||
@ -1621,6 +1703,394 @@ HIDDEN bool convert(const char* menuname)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TMenu_tree
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TMenu_tree : public TBidirectional_tree
|
||||
{
|
||||
TMenu* _menu;
|
||||
const TSubmenu* _submenu;
|
||||
int _menuitem;
|
||||
|
||||
TString _root_id, _curr_id;
|
||||
|
||||
protected: // TTree
|
||||
virtual void node2id(const TObject* node, TString& id) const;
|
||||
|
||||
public: // TTree
|
||||
virtual bool goto_root();
|
||||
virtual bool goto_firstson();
|
||||
virtual bool goto_rbrother();
|
||||
virtual bool goto_node(const TString &id);
|
||||
virtual bool has_son() const;
|
||||
virtual bool has_rbrother() const;
|
||||
virtual TObject* curr_node() const;
|
||||
|
||||
virtual bool has_root() const;
|
||||
virtual bool has_father() const;
|
||||
virtual bool has_lbrother() const;
|
||||
virtual bool goto_father();
|
||||
virtual bool goto_lbrother();
|
||||
|
||||
virtual void curr_id(TString& id) const { id = _curr_id; }
|
||||
virtual bool get_description(TString& desc) const;
|
||||
virtual TImage* image(bool selected) const;
|
||||
|
||||
public:
|
||||
const TSubmenu& curr_submenu() const;
|
||||
const TMenuitem& curr_item() const;
|
||||
bool find_string(const TString& str);
|
||||
|
||||
TMenu_tree(TMenu& menu);
|
||||
virtual ~TMenu_tree() { }
|
||||
};
|
||||
|
||||
const TSubmenu& TMenu_tree::curr_submenu() const
|
||||
{
|
||||
CHECKS(_submenu, "NULL submenu ", (const char*)_curr_id);
|
||||
return *_submenu;
|
||||
}
|
||||
|
||||
const TMenuitem& TMenu_tree::curr_item() const
|
||||
{
|
||||
const TSubmenu& sm = curr_submenu();
|
||||
CHECKD(_menuitem >= 0 && _menuitem < sm.items(), "Invalid submenu item ", _menuitem);
|
||||
return sm.item(_menuitem);
|
||||
}
|
||||
|
||||
struct TFind_string_data
|
||||
{
|
||||
TString _str;
|
||||
TString _ignore;
|
||||
};
|
||||
|
||||
HIDDEN bool find_string_callback(TTree& tree, void* jolly, word flags)
|
||||
{
|
||||
if (flags == SCAN_PRE_ORDER)
|
||||
{
|
||||
TMenu_tree& mt = (TMenu_tree&)tree;
|
||||
TFind_string_data& data = *(TFind_string_data*)jolly;
|
||||
|
||||
const TSubmenu& sm = mt.curr_submenu();
|
||||
if (sm.name() == data._ignore)
|
||||
return FALSE;
|
||||
|
||||
TString desc; mt.get_description(desc);
|
||||
desc.upper();
|
||||
if (desc.find(data._str) >= 0)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
struct TFind_node_data
|
||||
{
|
||||
TString _id;
|
||||
long _count;
|
||||
};
|
||||
|
||||
HIDDEN bool find_node_callback(TTree& tree, void* jolly, word flags)
|
||||
{
|
||||
if (flags == SCAN_PRE_ORDER)
|
||||
{
|
||||
TFind_node_data& data = *(TFind_node_data*)jolly;
|
||||
data._count++;
|
||||
TString id; tree.curr_id(id);
|
||||
if (id == data._id)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TMenu_tree::find_string(const TString& str)
|
||||
{
|
||||
static TFind_string_data data;
|
||||
data._str = str; data._str.upper();
|
||||
|
||||
goto_root();
|
||||
bool ok = scan_depth_first(find_string_callback, &data,
|
||||
SCAN_PRE_ORDER);
|
||||
if (ok)
|
||||
data._ignore = curr_submenu().name();
|
||||
else
|
||||
data._ignore.cut(0);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TMenu_tree::node2id(const TObject* node, TString& id) const
|
||||
{
|
||||
TString* str = (TString*)node;
|
||||
id = *str;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_root()
|
||||
{
|
||||
TSubmenu* sm = _menu->find(_root_id);
|
||||
if (sm)
|
||||
{
|
||||
_curr_id = _root_id;
|
||||
_curr_id << ".0";
|
||||
_submenu = sm;
|
||||
_menuitem = 0;
|
||||
}
|
||||
return sm != NULL;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_firstson()
|
||||
{
|
||||
const TMenuitem& mi = curr_item();
|
||||
if (mi.is_submenu())
|
||||
{
|
||||
const TSubmenu* sm = _menu->find(mi.action());
|
||||
if (sm && sm->items() > 0)
|
||||
{
|
||||
_curr_id << '/' << mi.action() << ".0";
|
||||
_submenu = sm;
|
||||
_menuitem = 0;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_rbrother()
|
||||
{
|
||||
if (_menuitem < _submenu->items()-1)
|
||||
{
|
||||
const int dot = _curr_id.rfind('.');
|
||||
_curr_id.cut(dot+1);
|
||||
_curr_id << (++_menuitem);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_node(const TString &id)
|
||||
{
|
||||
const int dot = id.rfind('.');
|
||||
_menuitem = atoi(id.mid(dot+1));
|
||||
_curr_id = id.left(dot);
|
||||
const int slash = _curr_id.rfind('/');
|
||||
|
||||
_curr_id = _curr_id.mid(slash+1);
|
||||
_submenu = _menu->find(_curr_id);
|
||||
_curr_id = id;
|
||||
|
||||
return _submenu != NULL;
|
||||
}
|
||||
|
||||
bool TMenu_tree::has_son() const
|
||||
{
|
||||
const TMenuitem& mi = curr_item();
|
||||
return mi.is_submenu();
|
||||
}
|
||||
|
||||
bool TMenu_tree::has_rbrother() const
|
||||
{
|
||||
return _menuitem < _submenu->items()-1;
|
||||
}
|
||||
|
||||
bool TMenu_tree::has_root() const
|
||||
{
|
||||
return _root_id.not_empty();
|
||||
}
|
||||
|
||||
bool TMenu_tree::has_father() const
|
||||
{
|
||||
return _curr_id.find('/') > 0;
|
||||
}
|
||||
|
||||
bool TMenu_tree::has_lbrother() const
|
||||
{
|
||||
return _menuitem > 0;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_father()
|
||||
{
|
||||
const int slash = _curr_id.rfind('/');
|
||||
if (slash > 0)
|
||||
{
|
||||
const TString id = _curr_id.left(slash);
|
||||
return goto_node(id);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_lbrother()
|
||||
{
|
||||
if (_menuitem > 0)
|
||||
{
|
||||
const int dot = _curr_id.rfind('.');
|
||||
_curr_id.cut(dot+1);
|
||||
_curr_id << (--_menuitem);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
TObject* TMenu_tree::curr_node() const
|
||||
{
|
||||
return &((TMenu_tree*)this)->_curr_id;
|
||||
}
|
||||
|
||||
bool TMenu_tree::get_description(TString& desc) const
|
||||
{
|
||||
const TMenuitem& mi = curr_item();
|
||||
desc = mi.caption();
|
||||
return desc.not_empty();
|
||||
}
|
||||
|
||||
TImage* TMenu_tree::image(bool selected) const
|
||||
{
|
||||
const TMenuitem& mi = curr_item();
|
||||
if (mi.disabled())
|
||||
return get_res_image(BMP_STOP);
|
||||
return TTree::image(selected);
|
||||
}
|
||||
|
||||
TMenu_tree::TMenu_tree(TMenu& menu)
|
||||
: _menu(&menu), _curr_id(128, '/')
|
||||
{
|
||||
_root_id = _menu->current().name();
|
||||
goto_root();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Tree view implementation
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
bool TMenu_application::tree_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_CTRL + K_SPACE)
|
||||
{
|
||||
TTree_field& tf = (TTree_field&)f;
|
||||
TMenu_tree& mt = *(TMenu_tree*)tf.tree();
|
||||
const TMenuitem& mi = mt.curr_item();
|
||||
mi.perform();
|
||||
if (mi.is_submenu() && mt.expanded())
|
||||
{
|
||||
TMenu& menu = mt.curr_submenu().menu();
|
||||
TImage& image = menu.image(menu.current().picture());
|
||||
TPicture_mask& pm = (TPicture_mask&)f.mask();
|
||||
pm.set_image(&image);
|
||||
pm.force_update();
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TMenu_application::tree_find_handler(TMask_field&f, KEY k)
|
||||
{
|
||||
if (k == K_TAB && f.focusdirty() && !f.empty())
|
||||
{
|
||||
const TString& v = f.get();
|
||||
|
||||
TPicture_mask& m = (TPicture_mask&)f.mask();
|
||||
m.set_last_search_string(v);
|
||||
|
||||
TTree_field& tf = (TTree_field&)m.field(101);
|
||||
TMenu_tree& mt = *(TMenu_tree*)tf.tree();
|
||||
if (mt.find_string(v))
|
||||
{
|
||||
tf.select_current();
|
||||
|
||||
TString id; mt.curr_id(id);
|
||||
do { mt.expand(); } while (mt.goto_father());
|
||||
|
||||
TFind_node_data data;
|
||||
data._id = id;
|
||||
data._count = 0;
|
||||
mt.goto_root();
|
||||
mt.scan_depth_first(find_node_callback, &data,
|
||||
SCAN_PRE_ORDER | SCAN_IGNORING_UNEXPANDED);
|
||||
|
||||
TField_window& win = tf.win();
|
||||
const TPoint& range = win.range();
|
||||
if (data._count > range.y)
|
||||
win.set_scroll_max(win.columns(), data._count+win.rows());
|
||||
|
||||
const int dot = id.rfind('.');
|
||||
const int pos = atoi(id.mid(dot+1));
|
||||
|
||||
win.update_thumb(-1, data._count-pos-2);
|
||||
win.force_update();
|
||||
tf.set_focus();
|
||||
}
|
||||
else
|
||||
beep();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TMenu_application::tree_shrink_handler(TMask_field&f, KEY k)
|
||||
{
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
TTree_field& tf = (TTree_field&)f.mask().field(101);
|
||||
TMenu_tree& mt = *(TMenu_tree*)tf.tree();
|
||||
mt.shrink_all();
|
||||
mt.goto_root();
|
||||
tf.select_current();
|
||||
tf.win().update_thumb(0,0);
|
||||
tf.win().force_update();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HIDDEN void left_align_field(TMask_field& fld, int x)
|
||||
{
|
||||
RCT rct;
|
||||
fld.get_rect(rct);
|
||||
rct.left = x;
|
||||
fld.set_rect(rct);
|
||||
}
|
||||
|
||||
int TMenu_application::do_tree()
|
||||
{
|
||||
_menu.jumpto_root();
|
||||
const TSubmenu& curr = _menu.current();
|
||||
|
||||
TImage& image = _menu.image(curr.picture());
|
||||
TPicture_mask mask(curr.caption(), 0, 0, &image, 0, 0);
|
||||
CHECK(_mask == NULL, "Two masks are better than one?");
|
||||
_mask = &mask;
|
||||
|
||||
TMenu_tree tree(_menu);
|
||||
TTree_field& tree_fld = mask.add_tree(101, 0, 0, 0, 60, -1);
|
||||
tree_fld.set_tree(&tree);
|
||||
tree_fld.set_handler(tree_handler);
|
||||
RCT rct; tree_fld.get_rect(rct);
|
||||
const int x = rct.right + CHARX;
|
||||
const int bwidth = 20;
|
||||
|
||||
TMask_field& sf = mask.add_static(DLG_NULL, 0, "Cerca", -1, 0);
|
||||
left_align_field(sf, x);
|
||||
|
||||
TEdit_field& ef = mask.add_string(DLG_USER, 0, "", -2, 1, 50, "", bwidth);
|
||||
ef.set_handler(tree_find_handler);
|
||||
left_align_field(ef, x);
|
||||
|
||||
TButton_field& mf = mask.add_button(102, 0, "Menu principale", -1, 2, bwidth, 2);
|
||||
mf.set_handler(tree_shrink_handler);
|
||||
left_align_field(mf, x);
|
||||
|
||||
TButton_field& bf = mask.add_button(DLG_QUIT, 0, "Fine", -1, -1, bwidth, 2);
|
||||
left_align_field(bf, x);
|
||||
|
||||
mask.first_focus(101);
|
||||
KEY key = mask.run();
|
||||
_mask = NULL;
|
||||
|
||||
return key == K_QUIT ? -2 : 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Main program
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
TApplication::check_parameters(argc, argv);
|
||||
@ -1634,7 +2104,7 @@ int main(int argc, char** argv)
|
||||
TFilename menu = (argc < 2) ? "baprassi.men" : argv[1];
|
||||
TString ext = menu.ext(); ext.lower();
|
||||
|
||||
if (ext == "men" && !fexist(menu))
|
||||
if (ext == "men" && !menu.exist())
|
||||
ext.cut(0);
|
||||
|
||||
if (ext != "men")
|
||||
@ -1650,7 +2120,7 @@ int main(int argc, char** argv)
|
||||
menu = newmenu;
|
||||
}
|
||||
|
||||
if (!fexist(menu))
|
||||
if (!menu.exist())
|
||||
{
|
||||
error_box("Non esiste il menu %s", (const char*)menu);
|
||||
exit(1);
|
||||
|
2
ba/ba0.h
2
ba/ba0.h
@ -1,6 +1,6 @@
|
||||
#ifndef __BA0_H
|
||||
#define __BA0_H
|
||||
|
||||
#define BA0_PICTURE 883
|
||||
#define BMP_STOP 883
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <default.url>
|
||||
#include "ba0.h"
|
||||
|
||||
MENUBAR MENU_BAR(0)
|
||||
|
||||
@ -13,3 +14,6 @@ MENU M_FONT
|
||||
ITEM MENU_ITEM(2) "~Colori"
|
||||
ITEM MENU_ITEM(3) "~Editors"
|
||||
ITEM MENU_ITEM(4) "~Studio"
|
||||
|
||||
image BMP_STOP QRESDIR"stop.bmp"
|
||||
|
||||
|
@ -11,11 +11,11 @@ int main(int argc,char** argv)
|
||||
switch (r)
|
||||
{
|
||||
case 1:
|
||||
ba1200(argc,argv); break;
|
||||
ba1200(argc,argv); break; // Test file
|
||||
case 2:
|
||||
ba1300(argc,argv); break;
|
||||
ba1300(argc,argv); break; // Pack files
|
||||
case 3:
|
||||
ba1400(argc,argv); break;
|
||||
ba1400(argc,argv); break; // Set users
|
||||
case 4:
|
||||
ba1500(argc,argv); break;
|
||||
case 5:
|
||||
@ -25,7 +25,7 @@ int main(int argc,char** argv)
|
||||
case 7:
|
||||
ba1800(argc,argv); break;
|
||||
default:
|
||||
ba1100(argc,argv); break;
|
||||
ba1100(argc,argv); break; // Manutenzione
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "ba1.h"
|
||||
|
||||
|
||||
class TPackFiles_application:public TApplication
|
||||
{
|
||||
TArray_sheet * _selsheet;
|
||||
|
@ -16,7 +16,7 @@ int main(int argc, char** argv)
|
||||
case 0:
|
||||
rt = ba2100(argc, argv); break;
|
||||
case 1:
|
||||
rt = ba2200(argc, argv); break;
|
||||
rt = ba2200(argc, argv); break; // Backup
|
||||
case 3:
|
||||
rt = ba2400(argc, argv) ; break;
|
||||
case 4:
|
||||
|
@ -18,7 +18,7 @@ protected:
|
||||
virtual bool create();
|
||||
virtual void main_loop();
|
||||
static bool test_firm(TMask_field& f, KEY k);
|
||||
KEY query(long& firm, char& floppy, TString& desc, bool& tmp) const;
|
||||
KEY query(long& firm, char& floppy, TString& desc, bool& tmp, bool& zip) const;
|
||||
|
||||
public:
|
||||
void stop_job();
|
||||
@ -62,7 +62,7 @@ bool TArchive_app::test_firm(TMask_field& f, KEY k)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
KEY TArchive_app::query(long& firm, char& floppy, TString& desc, bool& temp) const
|
||||
KEY TArchive_app::query(long& firm, char& floppy, TString& desc, bool& temp, bool& zip) const
|
||||
{
|
||||
TMask m("ba2200");
|
||||
|
||||
@ -79,6 +79,7 @@ KEY TArchive_app::query(long& firm, char& floppy, TString& desc, bool& temp) con
|
||||
floppy = m.get(F_FLOPPY)[0];
|
||||
desc = m.get(F_DESCR);
|
||||
temp = m.get_bool(F_TEMP);
|
||||
zip = m.get_bool(F_ZIP);
|
||||
}
|
||||
|
||||
return k;
|
||||
@ -91,11 +92,24 @@ void TArchive_app::main_loop()
|
||||
char floppy;
|
||||
TString desc(80);
|
||||
bool temp;
|
||||
bool zip;
|
||||
|
||||
while ((k = query(firm, floppy, desc, temp)) != K_QUIT)
|
||||
{
|
||||
if (k == K_SAVE) _arc.backup(firm, floppy, desc);
|
||||
else _arc.restore(firm, floppy, temp);
|
||||
while ((k = query(firm, floppy, desc, temp, zip)) != K_QUIT)
|
||||
{
|
||||
if (k == K_SAVE)
|
||||
{
|
||||
if (zip)
|
||||
_arc.zip(firm, floppy, desc);
|
||||
else
|
||||
_arc.backup(firm, floppy, desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (zip)
|
||||
_arc.unzip(firm, floppy, temp);
|
||||
else
|
||||
_arc.restore(firm, floppy, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,3 +6,4 @@
|
||||
#define F_TEMP 106
|
||||
#define F_SALVA 107
|
||||
#define F_RIPR 108
|
||||
#define F_ZIP 109
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ba2200.h"
|
||||
|
||||
PAGE "Salvataggio / Ripristino archivi" -1 -1 72 7
|
||||
PAGE "Salvataggio / Ripristino archivi" -1 -1 72 8
|
||||
|
||||
LIST F_FLOPPY 1 5
|
||||
BEGIN
|
||||
@ -48,9 +48,15 @@ BEGIN
|
||||
PROMPT 1 3 "Descrizione "
|
||||
END
|
||||
|
||||
BOOLEAN F_ZIP
|
||||
BEGIN
|
||||
PROMPT 1 4 "Usare compressione compatibile PKZIP"
|
||||
END
|
||||
|
||||
|
||||
BOOLEAN F_TEMP
|
||||
BEGIN
|
||||
PROMPT 1 4 "Usare direttorio temporaneo durante il ripristino"
|
||||
PROMPT 1 5 "Usare direttorio temporaneo durante il ripristino"
|
||||
END
|
||||
|
||||
BUTTON F_SALVA 15 2
|
||||
|
@ -10,8 +10,6 @@ class TIndici_app : public TRelation_application
|
||||
TRelation* _indici;
|
||||
TMask* _maschera;
|
||||
|
||||
TString _tmp;
|
||||
|
||||
protected:
|
||||
virtual bool user_create();
|
||||
virtual bool user_destroy();
|
||||
@ -20,7 +18,7 @@ protected:
|
||||
virtual TMask* get_mask(int) { return _maschera; }
|
||||
virtual TRelation* get_relation() const { return _indici; }
|
||||
|
||||
virtual const char* get_next_key();
|
||||
virtual bool get_next_key(TToken_string& key);
|
||||
virtual bool save_and_new() const { return TRUE; }
|
||||
virtual int read(TMask& m);
|
||||
virtual void init_query_mode(TMask& m);
|
||||
@ -29,7 +27,7 @@ protected:
|
||||
static TIndici_app& app() { return (TIndici_app&) main_app(); }
|
||||
|
||||
public:
|
||||
TIndici_app() : _tmp(80) { }
|
||||
TIndici_app() { }
|
||||
virtual ~TIndici_app() { }
|
||||
};
|
||||
|
||||
@ -122,12 +120,12 @@ bool TIndici_app::user_destroy()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const char* TIndici_app::get_next_key()
|
||||
bool TIndici_app::get_next_key(TToken_string& key)
|
||||
{
|
||||
const int anno = _maschera->get_int(F_ANNO);
|
||||
const TString16 libro = _maschera->get(F_CODLIB);
|
||||
if (anno == 0 || libro.empty())
|
||||
return "";
|
||||
return TRUE;
|
||||
|
||||
TLocalisamfile index(LF_INDLIB);
|
||||
index.zero();
|
||||
@ -157,11 +155,9 @@ const char* TIndici_app::get_next_key()
|
||||
}
|
||||
|
||||
if (cod > 0)
|
||||
_tmp.format("%d|%d|%d|%s|%d|%ld", F_ANNO, anno, F_CODLIB, (const char*)libro, F_INDEX, cod);
|
||||
else
|
||||
_tmp.cut(0);
|
||||
key.format("%d|%d|%d|%s|%d|%ld", F_ANNO, anno, F_CODLIB, (const char*)libro, F_INDEX, cod);
|
||||
|
||||
return _tmp;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,10 +18,9 @@ class TPersone_app : public TRelation_application
|
||||
bool _reset_uff_conc;
|
||||
char _next_ana;
|
||||
bool _reset_codreg;
|
||||
TString16 _cod_ana ;
|
||||
TString16 _next_key;
|
||||
TMask* _msk[2] ;
|
||||
TRelation* _rel[2];
|
||||
TString16 _cod_ana;
|
||||
TMask* _msk[2];
|
||||
TRelation* _rel[2];
|
||||
TLocalisamfile* _comuni;
|
||||
TLocalisamfile* _tabcom;
|
||||
|
||||
@ -34,7 +33,7 @@ protected:
|
||||
virtual void init_insert_mode(TMask& m);
|
||||
virtual void init_modify_mode(TMask& m);
|
||||
virtual bool changing_mask(int mode) {return _tip_ana != _next_ana;}
|
||||
virtual const char* get_next_key();
|
||||
virtual bool get_next_key(TToken_string& key);
|
||||
virtual TMask* get_mask(int mode) ;
|
||||
virtual void write_enable(bool on = TRUE);
|
||||
|
||||
@ -153,7 +152,7 @@ void TPersone_app::init_query_mode(TMask& m)
|
||||
m.enable(DLG_CHGTIP);
|
||||
}
|
||||
|
||||
const char* TPersone_app::get_next_key()
|
||||
bool TPersone_app::get_next_key(TToken_string& key)
|
||||
{
|
||||
TLocalisamfile& anag = get_relation()->lfile() ;
|
||||
long cod_anagr = 1;
|
||||
@ -183,8 +182,8 @@ const char* TPersone_app::get_next_key()
|
||||
}
|
||||
}
|
||||
_cod_ana.format("%ld", cod_anagr);
|
||||
_next_key.format("%d|%ld", FLD_CODANAGR, cod_anagr);
|
||||
return _next_key;
|
||||
key.format("%d|%ld", FLD_CODANAGR, cod_anagr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -512,11 +512,11 @@ bool TAnaprint_app::user_create()
|
||||
|
||||
p.addstatus(1);
|
||||
|
||||
_cfis1 = add_cursor(new TCursor(_rel_fis, "" , 1));
|
||||
_cgiu1 = add_cursor(new TCursor(_rel_giu, "" , 1));
|
||||
_cfis1 = add_cursor(new TCursor(_rel_fis, "", 1));
|
||||
_cgiu1 = add_cursor(new TCursor(_rel_giu, "", 1));
|
||||
_cdit1 = add_cursor(new TCursor(_rel_dit, "", 1));
|
||||
_cfis2 = add_cursor(new TCursor(_rel_fis, "" , 2));
|
||||
_cgiu2 = add_cursor(new TCursor(_rel_giu, "" , 2));
|
||||
_cfis2 = add_cursor(new TCursor(_rel_fis, "", 2));
|
||||
_cgiu2 = add_cursor(new TCursor(_rel_giu, "", 2));
|
||||
_cdit2 = add_cursor(new TCursor(_rel_dit, "", 2));
|
||||
|
||||
p.addstatus(1);
|
||||
@ -546,8 +546,7 @@ bool TAnaprint_app::user_create()
|
||||
set_translation(LF_NDITTE,"DATLAV","3","Lavoro Agricolo");
|
||||
set_translation(LF_ANAGGIU,"STATOSOC","1","Normale attivita'");
|
||||
set_translation(LF_ANAGGIU,"STATOSOC","2","Liquidazione cessata attivita'");
|
||||
set_translation(LF_ANAGGIU,"STATOSOC","3",
|
||||
"Fallimento o Liquidazione coatta amm.");
|
||||
set_translation(LF_ANAGGIU,"STATOSOC","3","Fallimento o Liquidazione coatta amm.");
|
||||
set_translation(LF_ANAGGIU,"STATOSOC","4","Estinto");
|
||||
set_translation(LF_ANAGGIU,"SITSOC","1","Inizio");
|
||||
set_translation(LF_ANAGGIU,"SITSOC","2","Liquidazione");
|
||||
|
326
ba/ba883.cpp
326
ba/ba883.cpp
@ -3,7 +3,307 @@
|
||||
#include <browfile.h>
|
||||
#include <relapp.h>
|
||||
#include <tree.h>
|
||||
#include <urldefid.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
class TPianoconti_tree : public TBidirectional_tree
|
||||
{
|
||||
TArray _cursor; // Gruppi, Conti, Sottoconti, Clienti, Fornitori
|
||||
int _curindex;
|
||||
TToken_string _curnode;
|
||||
|
||||
private:
|
||||
TCursor& cursor() const { return (TCursor&)_cursor[_curindex]; }
|
||||
TCursor& cursor(int n) const { return (TCursor&)_cursor[n]; }
|
||||
bool update_curr();
|
||||
void restore_curr();
|
||||
|
||||
protected:
|
||||
virtual void node2id(const TObject* node, TString& id) const;
|
||||
|
||||
public:
|
||||
virtual bool has_root() const;
|
||||
virtual bool goto_root();
|
||||
virtual bool has_son() const;
|
||||
virtual bool goto_firstson();
|
||||
virtual bool has_rbrother() const;
|
||||
virtual bool goto_rbrother();
|
||||
virtual bool has_father() const;
|
||||
virtual bool goto_father();
|
||||
virtual bool has_lbrother() const;
|
||||
virtual bool goto_lbrother();
|
||||
|
||||
virtual bool goto_node(const TString &id);
|
||||
virtual TObject* curr_node() const;
|
||||
virtual bool get_description(TString& desc) const;
|
||||
|
||||
TPianoconti_tree();
|
||||
virtual ~TPianoconti_tree();
|
||||
};
|
||||
|
||||
TPianoconti_tree::TPianoconti_tree()
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
TRelation* rel = new TRelation(i < 3 ? LF_PCON : LF_CLIFO);
|
||||
TCursor* cur = NULL;
|
||||
switch (i)
|
||||
{
|
||||
case 0: cur = new TCursor(rel, "CONTO==0"); break;
|
||||
case 1: cur = new TCursor(rel, "(CONTO!=0)&&(SOTTOCONTO==0)"); break;
|
||||
case 2: cur = new TCursor(rel, "SOTTOCONTO!=0"); break;
|
||||
case 3:
|
||||
case 4:
|
||||
{
|
||||
TRectype rec(rel->curr());
|
||||
rec.put("TIPOCF", i == 3 ? "C" : "F");
|
||||
cur = new TCursor(rel, "", 1, &rec, &rec);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
CHECK(cur, "Invalid tree cursor");
|
||||
_cursor.add(cur);
|
||||
}
|
||||
goto_root();
|
||||
}
|
||||
|
||||
TPianoconti_tree::~TPianoconti_tree()
|
||||
{
|
||||
for (int i = _cursor.last(); i >= 0; i--)
|
||||
{
|
||||
TRelation* rel = cursor(i).relation();
|
||||
delete rel;
|
||||
}
|
||||
_cursor.destroy();
|
||||
}
|
||||
|
||||
bool TPianoconti_tree::update_curr()
|
||||
{
|
||||
_curnode.cut(0);
|
||||
_curnode.add(_curindex);
|
||||
_curnode.add(cursor(0).pos());
|
||||
if (_curindex > 0)
|
||||
_curnode.add(cursor(1).pos());
|
||||
if (_curindex > 1)
|
||||
_curnode.add(cursor().pos());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TPianoconti_tree::restore_curr()
|
||||
{
|
||||
_curindex = _curnode.get_int(0);
|
||||
cursor(0) = _curnode.get_long();
|
||||
if (_curindex > 0)
|
||||
cursor(1) = _curnode.get_long();
|
||||
if (_curindex > 1)
|
||||
cursor() = _curnode.get_long();
|
||||
}
|
||||
|
||||
void TPianoconti_tree::node2id(const TObject* node, TString& id) const
|
||||
{
|
||||
id = *(const TToken_string*)node;
|
||||
}
|
||||
|
||||
TObject* TPianoconti_tree::curr_node() const
|
||||
{
|
||||
return &((TPianoconti_tree*)this)->_curnode;
|
||||
}
|
||||
|
||||
bool TPianoconti_tree::goto_root()
|
||||
{
|
||||
for (int c = _cursor.last(); c >= 0; c--)
|
||||
{
|
||||
TCursor& cur = cursor(c);
|
||||
cur.freeze(FALSE);
|
||||
cur = 0L;
|
||||
cur.freeze(TRUE);
|
||||
}
|
||||
_curindex = 0;
|
||||
update_curr();
|
||||
return cursor().items() > 0;
|
||||
}
|
||||
|
||||
bool TPianoconti_tree::goto_firstson()
|
||||
{
|
||||
bool ok = _curindex < 2;
|
||||
if (ok)
|
||||
{
|
||||
if (_curindex == 0)
|
||||
{
|
||||
TCursor& cur = cursor(1);
|
||||
TRectype& curr = cur.curr();
|
||||
const TString16 gruppo = cursor().curr().get("GRUPPO");
|
||||
curr.zero();
|
||||
curr.put("GRUPPO", gruppo);
|
||||
TRecnotype pos = cur.read(_isgteq);
|
||||
ok = pos >= 0 && curr.get("GRUPPO") == gruppo;
|
||||
if (ok)
|
||||
{
|
||||
_curindex = 1;
|
||||
update_curr();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char tipo = cursor().curr().get_char("TMCF");
|
||||
if (tipo <= ' ')
|
||||
{
|
||||
TCursor& cur = cursor(2);
|
||||
TRectype& curr = cur.curr();
|
||||
const TString16 gruppo = cursor().curr().get("GRUPPO");
|
||||
const TString16 conto = cursor().curr().get("CONTO");
|
||||
curr.zero();
|
||||
curr.put("GRUPPO", gruppo);
|
||||
curr.put("CONTO", conto);
|
||||
TRecnotype pos = cur.read(_isgteq);
|
||||
ok = pos >= 0 && curr.get("GRUPPO") == gruppo && curr.get("CONTO") == conto;
|
||||
if (ok)
|
||||
{
|
||||
_curindex = 2;
|
||||
update_curr();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const int i = tipo == 'C' ? 3 : 4;
|
||||
ok = cursor(i).items() > 0;
|
||||
if (ok)
|
||||
{
|
||||
_curindex = i;
|
||||
cursor() = 0;
|
||||
update_curr();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TPianoconti_tree::has_son() const
|
||||
{
|
||||
return _curindex < 2;
|
||||
}
|
||||
|
||||
bool TPianoconti_tree::goto_rbrother()
|
||||
{
|
||||
TCursor& cur = cursor();
|
||||
bool ok = cur.pos() < cur.items()-1;
|
||||
if (ok)
|
||||
{
|
||||
TRectype& curr = cur.curr();
|
||||
TString16 gruppo, conto;
|
||||
if (_curindex == 1 || _curindex == 2)
|
||||
gruppo = curr.get("GRUPPO");
|
||||
if (_curindex == 2)
|
||||
conto = curr.get("CONTO");
|
||||
|
||||
++cur;
|
||||
|
||||
if (_curindex == 1 || _curindex == 2)
|
||||
ok = curr.get("GRUPPO") == gruppo;
|
||||
if (ok && _curindex == 2)
|
||||
ok = curr.get("CONTO") == conto;
|
||||
|
||||
if (ok)
|
||||
update_curr();
|
||||
else
|
||||
--cur;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TPianoconti_tree::has_rbrother() const
|
||||
{
|
||||
const TString old = _curnode;
|
||||
bool ok = ((TPianoconti_tree*)this)->goto_rbrother();
|
||||
if (ok)
|
||||
((TPianoconti_tree*)this)->goto_node(old);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TPianoconti_tree::has_root() const
|
||||
{ return cursor(0).items() > 0; }
|
||||
|
||||
bool TPianoconti_tree::has_father() const
|
||||
{ return _curindex > 0; }
|
||||
|
||||
bool TPianoconti_tree::has_lbrother() const
|
||||
{
|
||||
const TString old = _curnode;
|
||||
bool ok = ((TPianoconti_tree*)this)->goto_lbrother();
|
||||
if (ok)
|
||||
((TPianoconti_tree*)this)->goto_node(old);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TPianoconti_tree::goto_father()
|
||||
{
|
||||
bool ok = _curindex > 0;
|
||||
if (ok)
|
||||
{
|
||||
if (_curindex >= 2)
|
||||
_curindex = 1;
|
||||
else
|
||||
_curindex = 0;
|
||||
update_curr();
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TPianoconti_tree::goto_lbrother()
|
||||
{
|
||||
TCursor& cur = cursor();
|
||||
bool ok = cur.pos() > 0;
|
||||
if (ok)
|
||||
{
|
||||
TRectype& curr = cur.curr();
|
||||
TString16 gruppo, conto;
|
||||
if (_curindex == 1 || _curindex == 2)
|
||||
gruppo = curr.get("GRUPPO");
|
||||
if (_curindex == 2)
|
||||
conto = curr.get("CONTO");
|
||||
|
||||
--cur;
|
||||
|
||||
if (_curindex == 1 || _curindex == 2)
|
||||
ok = curr.get("GRUPPO") == gruppo;
|
||||
if (ok && _curindex == 2)
|
||||
ok = curr.get("CONTO") == conto;
|
||||
|
||||
if (ok)
|
||||
update_curr();
|
||||
else
|
||||
++cur;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TPianoconti_tree::goto_node(const TString &id)
|
||||
{
|
||||
_curnode = id;
|
||||
restore_curr();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TPianoconti_tree::get_description(TString& desc) const
|
||||
{
|
||||
desc = cursor(0).curr().get("GRUPPO");
|
||||
if (_curindex > 0)
|
||||
desc << '.' << cursor(1).curr().get("CONTO");
|
||||
const TRectype& curr = cursor().curr();
|
||||
if (_curindex == 2)
|
||||
desc << '.' << curr.get("SOTTOCONTO");
|
||||
else
|
||||
{
|
||||
if (_curindex > 2)
|
||||
desc << '.' << curr.get("CODCF");
|
||||
}
|
||||
if (_curindex <= 2)
|
||||
desc << ' ' << curr.get("DESCR");
|
||||
else
|
||||
desc << ' ' << curr.get("RAGSOC");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
@ -181,9 +481,7 @@ bool TTest_application::tree_handler(TMask_field& f, KEY k)
|
||||
TBrowsefile_field& bf = (TBrowsefile_field&)next_field;
|
||||
TString str;
|
||||
tf.tree()->get_description(str);
|
||||
str.insert("You clicked on ", 0);
|
||||
if (k == K_CTRL+K_SPACE)
|
||||
str.insert("double ", 4);
|
||||
str.insert(k == K_CTRL+K_SPACE ? "** " : "* ", 0);
|
||||
bf.add_line(str);
|
||||
}
|
||||
}
|
||||
@ -196,25 +494,9 @@ void TTest_application::fill_trees(TMask& msk)
|
||||
{
|
||||
if (msk.fld(f).is_kind_of(CLASS_TREE_FIELD))
|
||||
{
|
||||
TString_tree* st = new TString_tree;
|
||||
st->add_son("Root");
|
||||
st->add_son("son 1");
|
||||
st->add_son("child 1");
|
||||
for (int i = 2; i <= 10; i++)
|
||||
{
|
||||
TString16 str; str.format("child %d", i);
|
||||
st->add_rbrother(str);
|
||||
}
|
||||
st->add_son("Nephew 1");
|
||||
st->add_rbrother("Nephew 2");
|
||||
st->goto_father();
|
||||
st->goto_father();
|
||||
st->add_rbrother("son 2");
|
||||
st->add_son("child 1");
|
||||
st->add_rbrother("child 2");
|
||||
st->expand_all();
|
||||
TTree* t = new TPianoconti_tree;
|
||||
TTree_field& tf = (TTree_field&)msk.fld(f);
|
||||
tf.set_tree(st);
|
||||
tf.set_tree(t);
|
||||
// tf.hide_leaves();
|
||||
tf.set_handler(tree_handler);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user