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 <ctype.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
@ -176,9 +176,14 @@ link_item *TPrint_application::_look_print_node (link_item * head, int logicnum)
|
|||||||
return NULL;
|
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)
|
void TPrint_application::add_file (const char *tab, int from)
|
||||||
{
|
{
|
||||||
add_file (TTable ::name2log (tab), from);
|
add_file(TTable::name2log (tab), from);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::add_file (int file, int from)
|
void TPrint_application::add_file (int file, int from)
|
||||||
@ -414,7 +419,7 @@ void TPrint_application::reset_print ()
|
|||||||
_print_defined = FALSE;
|
_print_defined = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::set_header (int r, const char *fmt,...)
|
void TPrint_application::set_header (int r, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
CHECK (r >= 1, "Header rows start at 1");
|
CHECK (r >= 1, "Header rows start at 1");
|
||||||
va_list vl;
|
va_list vl;
|
||||||
@ -422,12 +427,12 @@ void TPrint_application::set_header (int r, const char *fmt,...)
|
|||||||
vsprintf (__tmp_string, fmt, vl);
|
vsprintf (__tmp_string, fmt, vl);
|
||||||
va_end (vl);
|
va_end (vl);
|
||||||
|
|
||||||
TPrintrow *pp = (TPrintrow *) _header.objptr (r - 1);
|
TPrintrow *pp = (TPrintrow *)_header.objptr(r - 1);
|
||||||
if (!pp)
|
if (!pp)
|
||||||
{
|
{
|
||||||
pp = new TPrintrow;
|
pp = new TPrintrow;
|
||||||
_header.add (pp, r - 1);
|
_header.add (pp, r - 1);
|
||||||
}
|
}
|
||||||
pp->put (__tmp_string);
|
pp->put (__tmp_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,10 +445,10 @@ void TPrint_application::set_footer (int r, const char *fmt,...)
|
|||||||
va_end (vl);
|
va_end (vl);
|
||||||
TPrintrow *pp = (TPrintrow *) _footer.objptr (r - 1);
|
TPrintrow *pp = (TPrintrow *) _footer.objptr (r - 1);
|
||||||
if (pp == NULL)
|
if (pp == NULL)
|
||||||
{
|
{
|
||||||
pp = new TPrintrow;
|
pp = new TPrintrow;
|
||||||
_footer.add (pp, r - 1);
|
_footer.add (pp, r - 1);
|
||||||
}
|
}
|
||||||
pp->put (__tmp_string);
|
pp->put (__tmp_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,10 +468,10 @@ void TPrint_application::fill_page (int from)
|
|||||||
{
|
{
|
||||||
from--;
|
from--;
|
||||||
for (int i = (from == -1 ? _maxrow : from); i <= printer().formlen (); i++)
|
for (int i = (from == -1 ? _maxrow : from); i <= printer().formlen (); i++)
|
||||||
{
|
{
|
||||||
reset_row (i);
|
reset_row (i);
|
||||||
set_row (i, "");
|
set_row (i, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::merge_export_file(const char* file, bool header, bool direct)
|
void TPrint_application::merge_export_file(const char* file, bool header, bool direct)
|
||||||
@ -511,27 +516,27 @@ void TPrint_application::set_row (int r, const char *frmt,...)
|
|||||||
|
|
||||||
// parse format string
|
// parse format string
|
||||||
while ((ch = *fmt++) != '\0')
|
while ((ch = *fmt++) != '\0')
|
||||||
{
|
{
|
||||||
if (ch == '@')
|
if (ch == '@')
|
||||||
{
|
{
|
||||||
// check for pending string
|
// check for pending string
|
||||||
if (strind)
|
if (strind)
|
||||||
{
|
{
|
||||||
strbuf[strind] = '\0';
|
strbuf[strind] = '\0';
|
||||||
_rows.add (new _PrintfTok (_currow, strbuf));
|
_rows.add (new _PrintfTok (_currow, strbuf));
|
||||||
strind = 0;
|
strind = 0;
|
||||||
}
|
}
|
||||||
ch = *fmt++;
|
ch = *fmt++;
|
||||||
if (isdigit (ch))
|
if (isdigit (ch))
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
digbuf[i++] = ch;
|
digbuf[i++] = ch;
|
||||||
while (isdigit (ch = *fmt++))
|
while (isdigit (ch = *fmt++))
|
||||||
digbuf[i++] = ch;
|
digbuf[i++] = ch;
|
||||||
digbuf[i] = '\0';
|
digbuf[i] = '\0';
|
||||||
size = atoi (digbuf);
|
size = atoi (digbuf);
|
||||||
flags |= PAD_FLAG;
|
flags |= PAD_FLAG;
|
||||||
if (ch == '.')
|
if (ch == '.')
|
||||||
{
|
{
|
||||||
// decimal size follows
|
// decimal size follows
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -543,7 +548,7 @@ void TPrint_application::set_row (int r, const char *frmt,...)
|
|||||||
flags |= DEC_FLAG;
|
flags |= DEC_FLAG;
|
||||||
// ch = *fmt++;
|
// ch = *fmt++;
|
||||||
}
|
}
|
||||||
else if (ch == ',')
|
else if (ch == ',')
|
||||||
{
|
{
|
||||||
// aligment spec follows
|
// aligment spec follows
|
||||||
align = (ch = *fmt++);
|
align = (ch = *fmt++);
|
||||||
@ -552,95 +557,95 @@ void TPrint_application::set_row (int r, const char *frmt,...)
|
|||||||
flags |= ALIGN_FLAG;
|
flags |= ALIGN_FLAG;
|
||||||
ch = *fmt++;
|
ch = *fmt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
// modifiers
|
// modifiers
|
||||||
case 'l':
|
case 'l':
|
||||||
case 'L':
|
case 'L':
|
||||||
flags |= LONG_FLAG;
|
flags |= LONG_FLAG;
|
||||||
ch = *fmt++;
|
ch = *fmt++;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
case 'P':
|
case 'P':
|
||||||
flags |= PICTURE_FLAG;
|
flags |= PICTURE_FLAG;
|
||||||
ch = *fmt++;
|
ch = *fmt++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
// codes
|
// codes
|
||||||
case '@':
|
case '@':
|
||||||
_rows.add (new _PrintfTok (_currow, "@"));
|
_rows.add (new _PrintfTok (_currow, "@"));
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'u':
|
case 'u':
|
||||||
case 'r':
|
case 'r':
|
||||||
{
|
{
|
||||||
char *xxxx = new char[2];
|
char *xxxx = new char[2];
|
||||||
xxxx[0] = ch;
|
xxxx[0] = ch;
|
||||||
xxxx[1] = '\0';
|
xxxx[1] = '\0';
|
||||||
_rows.add (new _FieldTok (_currow, xxxx, FONT_FLAG));
|
_rows.add (new _FieldTok (_currow, xxxx, FONT_FLAG));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'j':
|
case 'j':
|
||||||
{
|
{
|
||||||
const char *xxx = format ("%c %d", ch, size);
|
const char *xxx = format ("%c %d", ch, size);
|
||||||
char *xxxx = new char[strlen (xxx) + 1];
|
char *xxxx = new char[strlen (xxx) + 1];
|
||||||
strcpy (xxxx, xxx);
|
strcpy (xxxx, xxx);
|
||||||
_rows.add (new _FieldTok (_currow, xxxx, JUMP_FLAG));
|
_rows.add (new _FieldTok (_currow, xxxx, JUMP_FLAG));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
flags |= IGNORE_FILL;
|
flags |= IGNORE_FILL;
|
||||||
case 't':
|
case 't':
|
||||||
flags |= TRANS_FLAG;
|
flags |= TRANS_FLAG;
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
flags |= IGNORE_FILL;
|
flags |= IGNORE_FILL;
|
||||||
case 'd':
|
case 'd':
|
||||||
flags |= DATE_FLAG;
|
flags |= DATE_FLAG;
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
flags |= IGNORE_FILL;
|
flags |= IGNORE_FILL;
|
||||||
case 'f':
|
case 'f':
|
||||||
flags |= BOOLEAN_FLAG;
|
flags |= BOOLEAN_FLAG;
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
flags |= IGNORE_FILL;
|
flags |= IGNORE_FILL;
|
||||||
case 's':
|
case 's':
|
||||||
flags |= STRING_FLAG;
|
flags |= STRING_FLAG;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
flags |= IGNORE_FILL;
|
flags |= IGNORE_FILL;
|
||||||
case 'c':
|
case 'c':
|
||||||
flags |= RECNO_FLAG;
|
flags |= RECNO_FLAG;
|
||||||
break;
|
break;
|
||||||
case 'N':
|
case 'N':
|
||||||
flags |= IGNORE_FILL;
|
flags |= IGNORE_FILL;
|
||||||
case 'n':
|
case 'n':
|
||||||
flags |= NUMBER_FLAG;
|
flags |= NUMBER_FLAG;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CHECK (0, "TPrint_application::set_row: invalid @ code");
|
CHECK (0, "TPrint_application::set_row: invalid @ code");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (flags & NUMBER_FLAG ||
|
if (flags & NUMBER_FLAG ||
|
||||||
flags & DATE_FLAG ||
|
flags & DATE_FLAG ||
|
||||||
flags & TRANS_FLAG ||
|
flags & TRANS_FLAG ||
|
||||||
flags & BOOLEAN_FLAG ||
|
flags & BOOLEAN_FLAG ||
|
||||||
flags & STRING_FLAG)
|
flags & STRING_FLAG)
|
||||||
{
|
{
|
||||||
char *xxx = va_arg (params, char *);
|
char *xxx = va_arg (params, char *);
|
||||||
_rows.add (new _FieldTok (_currow, xxx,
|
_rows.add (new _FieldTok (_currow, xxx,
|
||||||
flags, align, size, dec));
|
flags, align, size, dec));
|
||||||
}
|
}
|
||||||
flags = 0x0000;
|
flags = 0x0000;
|
||||||
align = 'l';
|
align = 'l';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TString t;
|
TString t;
|
||||||
switch (ch)
|
switch (ch)
|
||||||
@ -729,7 +734,7 @@ void TPrint_application::set_row (int r, const char *frmt,...)
|
|||||||
{
|
{
|
||||||
// no format specifications
|
// no format specifications
|
||||||
// use default picture
|
// use default picture
|
||||||
q = rrr->string (_picture);
|
q = rrr->string(_picture);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -758,7 +763,6 @@ void TPrint_application::set_row (int r, const char *frmt,...)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\n': // ignore
|
case '\n': // ignore
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// add to string
|
// add to string
|
||||||
@ -870,46 +874,46 @@ bool TPrint_application::print_tree (link_item * head)
|
|||||||
{
|
{
|
||||||
bool go = TRUE;
|
bool go = TRUE;
|
||||||
while (head)
|
while (head)
|
||||||
{
|
{
|
||||||
head->_cnt = 0;
|
head->_cnt = 0;
|
||||||
if (_cur->is_first_match (head->_logicnum))
|
if (_cur->is_first_match (head->_logicnum))
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!preprocess_print (head->_logicnum, head->_cnt))
|
if (!preprocess_print (head->_logicnum, head->_cnt))
|
||||||
break;
|
break;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// set print rows according to current file
|
// set print rows according to current file
|
||||||
if (_force_setpage || _cur_file != head->_logicnum
|
if (_force_setpage || _cur_file != head->_logicnum
|
||||||
|| !_print_defined)
|
|| !_print_defined)
|
||||||
{
|
{
|
||||||
reset_print ();
|
reset_print ();
|
||||||
set_page(head->_logicnum, head->_cnt);
|
set_page(head->_logicnum, head->_cnt);
|
||||||
_cur_file = head->_logicnum;
|
_cur_file = head->_logicnum;
|
||||||
}
|
}
|
||||||
int cnt2 = 0;
|
int cnt2 = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!preprocess_page (head->_logicnum, cnt2))
|
if (!preprocess_page (head->_logicnum, cnt2))
|
||||||
break;
|
break;
|
||||||
go = print_one (head->_logicnum);
|
go = print_one (head->_logicnum);
|
||||||
if (go && head->_son)
|
if (go && head->_son)
|
||||||
go = print_tree (head->_son);
|
go = print_tree (head->_son);
|
||||||
}
|
}
|
||||||
while (go && postprocess_page (head->_logicnum, cnt2++) ==
|
while (go && postprocess_page (head->_logicnum, cnt2++) ==
|
||||||
REPEAT_PAGE);
|
REPEAT_PAGE);
|
||||||
}
|
}
|
||||||
while (go && _cur->next_match (head->_logicnum));
|
while (go && _cur->next_match (head->_logicnum));
|
||||||
}
|
}
|
||||||
while (go && postprocess_print (head->_logicnum, head->_cnt++)
|
while (go && postprocess_print (head->_logicnum, head->_cnt++)
|
||||||
== REPEAT_PAGE);
|
== REPEAT_PAGE);
|
||||||
}
|
}
|
||||||
if (!go)
|
if (!go)
|
||||||
break;
|
break;
|
||||||
go = TRUE;
|
go = TRUE;
|
||||||
head = head->_brother;
|
head = head->_brother;
|
||||||
}
|
}
|
||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1226,7 +1230,7 @@ bool TPrint_application::print_one (int file)
|
|||||||
for (i = 0; i <= /*_maxrow*/ last; i++)
|
for (i = 0; i <= /*_maxrow*/ last; i++)
|
||||||
{
|
{
|
||||||
TPrintrow *pr = (TPrintrow *) & rw[i];
|
TPrintrow *pr = (TPrintrow *) & rw[i];
|
||||||
if (!(printer().print (*pr)))
|
if (!(printer().print(*pr)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (_auto_ff && _maxrow < printer().formlen ())
|
if (_auto_ff && _maxrow < printer().formlen ())
|
||||||
@ -1251,9 +1255,9 @@ bool TPrint_application::menu(MENU_TAG m)
|
|||||||
return xvt_test_menu_tag (BAR_ITEM (2));
|
return xvt_test_menu_tag (BAR_ITEM (2));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TPrint_application::create ()
|
bool TPrint_application::create()
|
||||||
{
|
{
|
||||||
TApplication ::create ();
|
TApplication::create();
|
||||||
printer().setfooterhandler (_pp_footer);
|
printer().setfooterhandler (_pp_footer);
|
||||||
printer().setheaderhandler (_pp_header);
|
printer().setheaderhandler (_pp_header);
|
||||||
printer().setlinkhandler (_pp_link);
|
printer().setlinkhandler (_pp_link);
|
||||||
|
@ -330,6 +330,16 @@ public:
|
|||||||
void set_translation(int lognum, const char* field,
|
void set_translation(int lognum, const char* field,
|
||||||
const char* from, const char* to);
|
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
|
// hypertext interface for viswin
|
||||||
|
@ -967,7 +967,7 @@ bool TPrinter::printrow(TPrintrow* rowtoprint)
|
|||||||
if (_printertype == screenvis)
|
if (_printertype == screenvis)
|
||||||
{
|
{
|
||||||
if (!_vf->frozen ())
|
if (!_vf->frozen ())
|
||||||
_vf->add_line (rw);
|
_vf->add_line(rw);
|
||||||
else
|
else
|
||||||
_frozen = TRUE;
|
_frozen = TRUE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -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 ()
|
void TPrinter::close ()
|
||||||
{
|
{
|
||||||
const bool isfirstpage = (_currentpage == 1 && _frompage == 0) ||
|
const bool isfirstpage = (_currentpage == 1 && _frompage == 0) ||
|
||||||
@ -1472,7 +1492,8 @@ void TPrinter::close ()
|
|||||||
const KEY key = _vf->run ();
|
const KEY key = _vf->run ();
|
||||||
if (_vf->is_open ()) _vf->close_modal ();
|
if (_vf->is_open ()) _vf->close_modal ();
|
||||||
delete _vf;
|
delete _vf;
|
||||||
freeze (FALSE);
|
freeze (FALSE);
|
||||||
|
_bookmarks.destroy();
|
||||||
_vf = NULL;
|
_vf = NULL;
|
||||||
|
|
||||||
if (key == K_CTRL+'S')
|
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;
|
class TPrinter;
|
||||||
|
|
||||||
typedef void (*PRINTSECTIONHANDLER)(TPrinter& printer);
|
typedef void (*PRINTSECTIONHANDLER)(TPrinter& printer);
|
||||||
@ -142,8 +155,10 @@ class TPrinter : public TObject
|
|||||||
TDate _date; // printing date
|
TDate _date; // printing date
|
||||||
TFilename _printerfile; // filename for printing on file
|
TFilename _printerfile; // filename for printing on file
|
||||||
TArray _linksdescr;
|
TArray _linksdescr;
|
||||||
|
TArray _bookmarks; // bookmarks
|
||||||
bool _multiple_link; //
|
bool _multiple_link; //
|
||||||
|
|
||||||
|
|
||||||
TString_array _background;
|
TString_array _background;
|
||||||
TString_array _image_names;
|
TString_array _image_names;
|
||||||
|
|
||||||
@ -161,7 +176,7 @@ class TPrinter : public TObject
|
|||||||
int _horz_offset;
|
int _horz_offset;
|
||||||
int _dots_per_line;
|
int _dots_per_line;
|
||||||
|
|
||||||
void _get_windows_printer_names(TToken_string& t);
|
void _get_windows_printer_names(TToken_string& t);
|
||||||
bool _multiple_copies;
|
bool _multiple_copies;
|
||||||
bool _export_header;
|
bool _export_header;
|
||||||
|
|
||||||
@ -227,8 +242,9 @@ public:
|
|||||||
void resetheader();
|
void resetheader();
|
||||||
void resetfooter();
|
void resetfooter();
|
||||||
void setbackground(const char* bg);
|
void setbackground(const char* bg);
|
||||||
TString_array& image_names() { return _image_names; }
|
TString_array& image_names() { return _image_names; }
|
||||||
TString_array& getbgdesc() { return _background; }
|
TString_array& getbgdesc() { return _background; }
|
||||||
|
TArray& get_bookmarks() { return _bookmarks; }
|
||||||
bool frozen() { return _frozen; }
|
bool frozen() { return _frozen; }
|
||||||
void freeze(bool b = TRUE) { _frozen = b; }
|
void freeze(bool b = TRUE) { _frozen = b; }
|
||||||
int n_copies() { return _ncopies; }
|
int n_copies() { return _ncopies; }
|
||||||
@ -287,6 +303,9 @@ public:
|
|||||||
int get_dots_per_line() const { return _dots_per_line; }
|
int get_dots_per_line() const { return _dots_per_line; }
|
||||||
bool isgraphics() const { return _isgraphics; }
|
bool isgraphics() const { return _isgraphics; }
|
||||||
int get_char_size() const { return _ch_size; }
|
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;
|
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
|
int TViswin::tabx(int x) const
|
||||||
{
|
{
|
||||||
HIDDEN long w = 0L;
|
HIDDEN long w = 0L;
|
||||||
@ -84,6 +108,104 @@ void TViswin::enable_menu_item(MENU_TAG item, bool on)
|
|||||||
xvt_menu_update(win());
|
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()
|
void TViswin::exec_link()
|
||||||
{
|
{
|
||||||
@ -1021,8 +1143,15 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
|||||||
_textcolumns = TEXTCOLUMNS;
|
_textcolumns = TEXTCOLUMNS;
|
||||||
autoscroll (TRUE);
|
autoscroll (TRUE);
|
||||||
break;
|
break;
|
||||||
case E_COMMAND:
|
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
|
case M_EDIT_CLIPBOARD: // interrompi
|
||||||
dispatch_e_char(win, K_ESC);
|
dispatch_e_char(win, K_ESC);
|
||||||
@ -1975,6 +2104,9 @@ void TViswin::close_print ()
|
|||||||
enable_menu_item(M_EDIT_CLIPBOARD, FALSE);
|
enable_menu_item(M_EDIT_CLIPBOARD, FALSE);
|
||||||
xvt_enable_control(_print_button, TRUE);
|
xvt_enable_control(_print_button, TRUE);
|
||||||
enable_menu_item(M_EDIT_SEL_ALL, TRUE);
|
enable_menu_item(M_EDIT_SEL_ALL, TRUE);
|
||||||
|
// build bookmark menu tree
|
||||||
|
if (_bookmarks->items() > 0)
|
||||||
|
build_index_menu();
|
||||||
}
|
}
|
||||||
force_update ();
|
force_update ();
|
||||||
}
|
}
|
||||||
@ -2233,7 +2365,9 @@ TViswin::TViswin(const char *fname,
|
|||||||
|
|
||||||
_links = _toplevel ? &(main_app().printer().links()) : &(_brwfld->_links);
|
_links = _toplevel ? &(main_app().printer().links()) : &(_brwfld->_links);
|
||||||
_multiple = _toplevel ? (main_app().printer ().ismultiplelink()) :
|
_multiple = _toplevel ? (main_app().printer ().ismultiplelink()) :
|
||||||
(_brwfld->is_multiple_link());
|
(_brwfld->is_multiple_link());
|
||||||
|
_bookmarks = &(main_app().printer().get_bookmarks());
|
||||||
|
|
||||||
_bg = _toplevel ? &(main_app().printer().getbgdesc()) : _brwfld->get_bg_desc();
|
_bg = _toplevel ? &(main_app().printer().getbgdesc()) : _brwfld->get_bg_desc();
|
||||||
_formlen = _toplevel ? main_app().printer().formlen() : maxalt;
|
_formlen = _toplevel ? main_app().printer().formlen() : maxalt;
|
||||||
_linkID = -1;
|
_linkID = -1;
|
||||||
@ -2246,7 +2380,8 @@ TViswin::TViswin(const char *fname,
|
|||||||
char b = *(t.get (2));
|
char b = *(t.get (2));
|
||||||
t.restart();
|
t.restart();
|
||||||
_txt.set_hotspots(f, b);
|
_txt.set_hotspots(f, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
_hotspots = &(_txt.hotspots());
|
_hotspots = &(_txt.hotspots());
|
||||||
|
|
||||||
main_app().end_wait();
|
main_app().end_wait();
|
||||||
|
@ -72,6 +72,7 @@ class TViswin : public TScroll_window
|
|||||||
|
|
||||||
TArray* _links; // admitted links
|
TArray* _links; // admitted links
|
||||||
TArray* _hotspots; // hotspots
|
TArray* _hotspots; // hotspots
|
||||||
|
TArray* _bookmarks; // bookmarks
|
||||||
|
|
||||||
bool need_paint_sel(bool smart = TRUE);
|
bool need_paint_sel(bool smart = TRUE);
|
||||||
|
|
||||||
@ -130,6 +131,7 @@ protected:
|
|||||||
void display_link(long, long, long, const char*);
|
void display_link(long, long, long, const char*);
|
||||||
void freeze() { _frozen = TRUE; }
|
void freeze() { _frozen = TRUE; }
|
||||||
void exec_link();
|
void exec_link();
|
||||||
|
void build_index_menu();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void scroll_error(long x, long y);
|
void scroll_error(long x, long y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user