Aggiunti 'bookmarks' a printapp, printer e viswin, con generazione
automatica del menu Indice git-svn-id: svn://10.65.10.50/trunk@1245 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
5bb4ea1e2d
commit
1f0d3a4fb7
@ -1,4 +1,4 @@
|
||||
// $Id: printapp.cpp,v 1.20 1995-04-12 15:44:43 alex Exp $
|
||||
// $Id: printapp.cpp,v 1.21 1995-04-13 07:45:10 villa Exp $
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@ -176,6 +176,11 @@ link_item *TPrint_application::_look_print_node (link_item * head, int logicnum)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int TPrint_application::set_bookmark(const char* txt, int father)
|
||||
{
|
||||
return printer().set_bookmark(txt, father);
|
||||
}
|
||||
|
||||
void TPrint_application::add_file (const char *tab, int from)
|
||||
{
|
||||
add_file(TTable::name2log (tab), from);
|
||||
@ -758,7 +763,6 @@ void TPrint_application::set_row (int r, const char *frmt,...)
|
||||
}
|
||||
break;
|
||||
case '\n': // ignore
|
||||
|
||||
break;
|
||||
default:
|
||||
// add to string
|
||||
|
@ -330,6 +330,16 @@ public:
|
||||
void set_translation(int lognum, const char* field,
|
||||
const char* from, const char* to);
|
||||
|
||||
// --------------------------------------------------------
|
||||
// bookmarks for viswin
|
||||
// --------------------------------------------------------
|
||||
// Aggiungere 'bookmarks' causa la comparsa del menu
|
||||
// 'Indice' nella viswin, con la lista dei bookmark inseriti;
|
||||
// questi possono essere legati ad albero n-ario specificando
|
||||
// il bookmark padre, in tal caso il menu sara' gerarchico a
|
||||
// sua volta. Prossima release di XVT il menu indice sara'
|
||||
// pop-up nella finestra
|
||||
int set_bookmark(const char* txt, int father = -1);
|
||||
|
||||
// --------------------------------------------------------
|
||||
// hypertext interface for viswin
|
||||
|
@ -1450,6 +1450,26 @@ void TPrinter::merge_export_file(const char* file, bool header)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int TPrinter::set_bookmark(const char* txt, int father)
|
||||
{
|
||||
if (_printertype == screenvis)
|
||||
{
|
||||
BkDef* bkd = new BkDef;
|
||||
|
||||
bkd->_row = (_currentrow + ((_currentpage - 1)*_formlen)) - 1;
|
||||
bkd->_father_id = father;
|
||||
bkd->_id = _bookmarks.items() + 1;
|
||||
bkd->_txt = txt;
|
||||
|
||||
_bookmarks.add(bkd);
|
||||
|
||||
return _bookmarks.items();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void TPrinter::close ()
|
||||
{
|
||||
const bool isfirstpage = (_currentpage == 1 && _frompage == 0) ||
|
||||
@ -1473,6 +1493,7 @@ void TPrinter::close ()
|
||||
if (_vf->is_open ()) _vf->close_modal ();
|
||||
delete _vf;
|
||||
freeze (FALSE);
|
||||
_bookmarks.destroy();
|
||||
_vf = NULL;
|
||||
|
||||
if (key == K_CTRL+'S')
|
||||
|
@ -99,6 +99,19 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class BkDef : public TObject
|
||||
{
|
||||
public:
|
||||
int _id;
|
||||
int _father_id;
|
||||
TString _txt;
|
||||
long _row;
|
||||
|
||||
BkDef() {}
|
||||
virtual ~BkDef() {}
|
||||
};
|
||||
|
||||
|
||||
class TPrinter;
|
||||
|
||||
typedef void (*PRINTSECTIONHANDLER)(TPrinter& printer);
|
||||
@ -142,8 +155,10 @@ class TPrinter : public TObject
|
||||
TDate _date; // printing date
|
||||
TFilename _printerfile; // filename for printing on file
|
||||
TArray _linksdescr;
|
||||
TArray _bookmarks; // bookmarks
|
||||
bool _multiple_link; //
|
||||
|
||||
|
||||
TString_array _background;
|
||||
TString_array _image_names;
|
||||
|
||||
@ -229,6 +244,7 @@ public:
|
||||
void setbackground(const char* bg);
|
||||
TString_array& image_names() { return _image_names; }
|
||||
TString_array& getbgdesc() { return _background; }
|
||||
TArray& get_bookmarks() { return _bookmarks; }
|
||||
bool frozen() { return _frozen; }
|
||||
void freeze(bool b = TRUE) { _frozen = b; }
|
||||
int n_copies() { return _ncopies; }
|
||||
@ -287,6 +303,9 @@ public:
|
||||
int get_dots_per_line() const { return _dots_per_line; }
|
||||
bool isgraphics() const { return _isgraphics; }
|
||||
int get_char_size() const { return _ch_size; }
|
||||
|
||||
// bookmarks
|
||||
int set_bookmark(const char* txt, int father = -1);
|
||||
};
|
||||
|
||||
|
||||
|
@ -55,6 +55,30 @@ const long E_ADDLINE = 488L;
|
||||
HIDDEN bool in_update;
|
||||
|
||||
|
||||
class _BkMenuItem : public TObject
|
||||
{
|
||||
public:
|
||||
|
||||
TString _txt;
|
||||
TArray* _arr;
|
||||
int _id; // per comodita'
|
||||
|
||||
_BkMenuItem(const char* t = "")
|
||||
{ _txt = t; _arr = NULL; }
|
||||
virtual ~_BkMenuItem()
|
||||
{ if (_arr != NULL) delete _arr; }
|
||||
};
|
||||
|
||||
class _BkMenuDesc : public TObject
|
||||
{
|
||||
public:
|
||||
|
||||
TString_array _menu;
|
||||
int _father_id;
|
||||
_BkMenuDesc() {}
|
||||
virtual ~_BkMenuDesc() {}
|
||||
};
|
||||
|
||||
int TViswin::tabx(int x) const
|
||||
{
|
||||
HIDDEN long w = 0L;
|
||||
@ -84,6 +108,104 @@ void TViswin::enable_menu_item(MENU_TAG item, bool on)
|
||||
xvt_menu_update(win());
|
||||
}
|
||||
|
||||
HIDDEN _BkMenuItem* find_menu_node(TArray& tree, int id)
|
||||
{
|
||||
_BkMenuItem* fnd = NULL;
|
||||
|
||||
for (int m = 0; m < tree.items(); m++)
|
||||
{
|
||||
_BkMenuItem& bkit = (_BkMenuItem&) tree[m];
|
||||
|
||||
if (bkit._id == id)
|
||||
return &bkit;
|
||||
|
||||
else if (bkit._arr != NULL)
|
||||
{
|
||||
if ((fnd = find_menu_node(*(bkit._arr), id)) != NULL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return fnd;
|
||||
}
|
||||
|
||||
HIDDEN void build_menu_tree(TArray& flat, TArray& tree, int level)
|
||||
{
|
||||
// find ID in flat array
|
||||
_BkMenuDesc* bds = NULL;
|
||||
|
||||
for (int i = 0; i < flat.items(); i++)
|
||||
{
|
||||
_BkMenuDesc& bdss = (_BkMenuDesc&)flat[i];
|
||||
if (bdss._father_id == 1000 + level)
|
||||
{
|
||||
bds = &bdss;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bds == NULL)
|
||||
{
|
||||
bds = new _BkMenuDesc;
|
||||
bds->_father_id = 1000 + level;
|
||||
flat.add(bds);
|
||||
}
|
||||
|
||||
for (i = 0; i < tree.items(); i++)
|
||||
{
|
||||
_BkMenuItem& bki = (_BkMenuItem&)tree[i];
|
||||
bds->_menu.add(bki._txt);
|
||||
if (bki._arr != NULL)
|
||||
build_menu_tree(flat, *(bki._arr), bki._id);
|
||||
}
|
||||
}
|
||||
|
||||
void TViswin::build_index_menu()
|
||||
{
|
||||
// builds bk_menu tree and index menu
|
||||
TArray bk_tree;
|
||||
TToken_string tt(128);
|
||||
|
||||
// build tree
|
||||
for (int i = 0; i < _bookmarks->items(); i++)
|
||||
{
|
||||
BkDef& bkd = (BkDef&)(*_bookmarks)[i];
|
||||
|
||||
tt = format("%d", bkd._id + 1000);
|
||||
tt.add(bkd._txt);
|
||||
|
||||
_BkMenuItem* bkit = new _BkMenuItem((const char*)tt);
|
||||
bkit->_id = bkd._id;
|
||||
|
||||
int father_id = bkd._father_id == -1 ? 0 : bkd._father_id;
|
||||
if (father_id == 0) // toplevel
|
||||
bk_tree.add(bkit);
|
||||
else
|
||||
{
|
||||
_BkMenuItem* father = find_menu_node(bk_tree, father_id);
|
||||
if (father != NULL)
|
||||
{
|
||||
if (father->_arr == NULL)
|
||||
father->_arr = new TArray(4);
|
||||
father->_arr->add(bkit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// build menu
|
||||
if (bk_tree.items() > 0)
|
||||
{
|
||||
TString_array top(1); top.add("1000|Indice");
|
||||
add_menu(top);
|
||||
}
|
||||
|
||||
TArray flat(4);
|
||||
build_menu_tree(flat, bk_tree, 0);
|
||||
|
||||
for (i = 0; i < flat.items(); i++)
|
||||
{
|
||||
_BkMenuDesc& bds = (_BkMenuDesc&)flat[i];
|
||||
add_menu(bds._menu, bds._father_id);
|
||||
}
|
||||
}
|
||||
|
||||
void TViswin::exec_link()
|
||||
{
|
||||
@ -1022,7 +1144,14 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
autoscroll (TRUE);
|
||||
break;
|
||||
case E_COMMAND:
|
||||
switch(ep->v.cmd.tag)
|
||||
if (ep->v.cmd.tag > 1000 && ep->v.cmd.tag < 2000)
|
||||
{
|
||||
// bookmark
|
||||
int index = ep->v.cmd.tag - 1001;
|
||||
BkDef& bds = (BkDef&)(*_bookmarks)[index];
|
||||
goto_pos(bds._row, 0l);
|
||||
}
|
||||
else switch(ep->v.cmd.tag)
|
||||
{
|
||||
case M_EDIT_CLIPBOARD: // interrompi
|
||||
dispatch_e_char(win, K_ESC);
|
||||
@ -1975,6 +2104,9 @@ void TViswin::close_print ()
|
||||
enable_menu_item(M_EDIT_CLIPBOARD, FALSE);
|
||||
xvt_enable_control(_print_button, TRUE);
|
||||
enable_menu_item(M_EDIT_SEL_ALL, TRUE);
|
||||
// build bookmark menu tree
|
||||
if (_bookmarks->items() > 0)
|
||||
build_index_menu();
|
||||
}
|
||||
force_update ();
|
||||
}
|
||||
@ -2234,6 +2366,8 @@ TViswin::TViswin(const char *fname,
|
||||
_links = _toplevel ? &(main_app().printer().links()) : &(_brwfld->_links);
|
||||
_multiple = _toplevel ? (main_app().printer ().ismultiplelink()) :
|
||||
(_brwfld->is_multiple_link());
|
||||
_bookmarks = &(main_app().printer().get_bookmarks());
|
||||
|
||||
_bg = _toplevel ? &(main_app().printer().getbgdesc()) : _brwfld->get_bg_desc();
|
||||
_formlen = _toplevel ? main_app().printer().formlen() : maxalt;
|
||||
_linkID = -1;
|
||||
@ -2247,6 +2381,7 @@ TViswin::TViswin(const char *fname,
|
||||
t.restart();
|
||||
_txt.set_hotspots(f, b);
|
||||
}
|
||||
|
||||
_hotspots = &(_txt.hotspots());
|
||||
|
||||
main_app().end_wait();
|
||||
|
@ -72,6 +72,7 @@ class TViswin : public TScroll_window
|
||||
|
||||
TArray* _links; // admitted links
|
||||
TArray* _hotspots; // hotspots
|
||||
TArray* _bookmarks; // bookmarks
|
||||
|
||||
bool need_paint_sel(bool smart = TRUE);
|
||||
|
||||
@ -130,6 +131,7 @@ protected:
|
||||
void display_link(long, long, long, const char*);
|
||||
void freeze() { _frozen = TRUE; }
|
||||
void exec_link();
|
||||
void build_index_menu();
|
||||
|
||||
protected:
|
||||
void scroll_error(long x, long y);
|
||||
|
Loading…
x
Reference in New Issue
Block a user