Aggiunto controllo BROWSEFILE alle mask (che e' una viswin) e handlers
del caso git-svn-id: svn://10.65.10.50/trunk@708 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
acea285fff
commit
b04fedfea8
@ -5,22 +5,58 @@
|
||||
#include <mask.h>
|
||||
#endif
|
||||
|
||||
class TViswin;
|
||||
class TViswin;
|
||||
|
||||
// viene chiamato sia al semplice passaggio del cursore sul testo
|
||||
// (con doubleclick = FALSE) o alla pressione di tasti o balle per
|
||||
// collegare (doubleclick = TRUE)
|
||||
// se non ritorna NULL, il testo usato per linkare viene sostituito
|
||||
// dal testo ritornato
|
||||
typedef const char* (*MASK_LINKHANDLER)(TMask&, int, const char*, bool doubleclick);
|
||||
|
||||
class TBrowsefile_field : public TMask_field
|
||||
{
|
||||
TViswin* _viswin;
|
||||
|
||||
{
|
||||
friend class TViswin;
|
||||
|
||||
TViswin* _viswin;
|
||||
MASK_LINKHANDLER _lh;
|
||||
TArray _links;
|
||||
TArray _background;
|
||||
bool _m_link;
|
||||
|
||||
protected:
|
||||
virtual word class_id() const;
|
||||
|
||||
virtual void parse_head(TScanner& scanner);
|
||||
virtual bool parse_item(TScanner& scanner);
|
||||
virtual void create(WINDOW parent);
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
TViswin* vis_win() const { return _viswin; }
|
||||
|
||||
void add_line(const char* l);
|
||||
void set_text(const char* file);
|
||||
// TBI posiziona su riga e colonna passate
|
||||
void goto_pos(long r, long c);
|
||||
void goto_top();
|
||||
void goto_end();
|
||||
void close();
|
||||
|
||||
// link processor
|
||||
void set_link_handler(MASK_LINKHANDLER lh) { _lh = lh; }
|
||||
MASK_LINKHANDLER get_link_handler() { return _lh; }
|
||||
TArray& links() { return _links; }
|
||||
void set_multiple_link(bool on) { _m_link = on; }
|
||||
bool is_multiple_link() { return _m_link; }
|
||||
int find_link(const char* descr);
|
||||
int enable_link (const char* descr, char fg, char bg = 'w');
|
||||
void disable_link(char fg, char bg = 'w');
|
||||
void disable_links() { _links.destroy(); }
|
||||
|
||||
// print background
|
||||
void set_background(const char* bg);
|
||||
TArray* get_bg_desc() { return &_background; }
|
||||
|
||||
TBrowsefile_field(TMask* m);
|
||||
virtual ~TBrowsefile_field();
|
||||
};
|
||||
|
@ -100,7 +100,7 @@ void TPrinter::set_win_formlen ()
|
||||
}
|
||||
#endif
|
||||
|
||||
void TPrinter::_parse_background ()
|
||||
void TPrinter::parse_background(const char* bg_desc, TArray& background)
|
||||
{
|
||||
char op;
|
||||
int x1, x2, y1, y2;
|
||||
@ -110,7 +110,7 @@ void TPrinter::_parse_background ()
|
||||
char ch;
|
||||
int cnt = 0;
|
||||
|
||||
while ((ch = _bg_desc[cnt++]) != '\0')
|
||||
while ((ch = bg_desc[cnt++]) != '\0')
|
||||
{
|
||||
op = ch;
|
||||
tt = "";
|
||||
@ -131,10 +131,10 @@ void TPrinter::_parse_background ()
|
||||
case 'r': // round box
|
||||
|
||||
cnt++;
|
||||
read_int (_bg_desc, x1, cnt);
|
||||
read_int (_bg_desc, y1, cnt);
|
||||
read_int (_bg_desc, x2, cnt);
|
||||
read_int (_bg_desc, y2, cnt);
|
||||
read_int (bg_desc, x1, cnt);
|
||||
read_int (bg_desc, y1, cnt);
|
||||
read_int (bg_desc, x2, cnt);
|
||||
read_int (bg_desc, y2, cnt);
|
||||
cnt++;
|
||||
tt << op;
|
||||
tt.add (x1 - 1);
|
||||
@ -145,11 +145,11 @@ void TPrinter::_parse_background ()
|
||||
case 't': // text
|
||||
|
||||
cnt++;
|
||||
read_int (_bg_desc, x1, cnt);
|
||||
read_int (_bg_desc, y1, cnt);
|
||||
read_int (bg_desc, x1, cnt);
|
||||
read_int (bg_desc, y1, cnt);
|
||||
cnt++;
|
||||
txt = "";
|
||||
while ((ch = _bg_desc[cnt++]) != '}')
|
||||
while ((ch = bg_desc[cnt++]) != '}')
|
||||
txt << ch;
|
||||
tt << op;
|
||||
tt.add (x1 - 1);
|
||||
@ -165,7 +165,7 @@ void TPrinter::_parse_background ()
|
||||
case 'C': // set pen color
|
||||
|
||||
tt << op;
|
||||
bf[0] = _bg_desc[cnt++];
|
||||
bf[0] = bg_desc[cnt++];
|
||||
tt.add (bf);
|
||||
break;
|
||||
default:
|
||||
@ -187,10 +187,10 @@ void TPrinter::_parse_background ()
|
||||
for (int l = 0; l < _formlen; l++)
|
||||
{
|
||||
|
||||
TString *rwd = (TString *) _background.objptr (l);
|
||||
TString *rwd = (TString *) background.objptr (l);
|
||||
if (rwd == NULL)
|
||||
{
|
||||
_background.add (rwd = new TString, l);
|
||||
background.add (rwd = new TString, l);
|
||||
if (curcol != 'n')
|
||||
(*rwd) << 'C' << curcol;
|
||||
if (curpat != 'n')
|
||||
@ -283,10 +283,10 @@ void TPrinter::_parse_background ()
|
||||
|
||||
void TPrinter::setbackground(const char *b)
|
||||
{
|
||||
_background.destroy ();
|
||||
_background.destroy();
|
||||
_bg_desc = b;
|
||||
if (b != NULL)
|
||||
_parse_background ();
|
||||
parse_background(_bg_desc, _background);
|
||||
}
|
||||
|
||||
bool printers_on_key(TMask_field & f, KEY key);
|
||||
|
@ -170,7 +170,6 @@ class TPrinter : public TObject
|
||||
int _horz_offset;
|
||||
int _dots_per_line;
|
||||
|
||||
void _parse_background();
|
||||
void _get_windows_printer_names(TToken_string& t);
|
||||
bool _multiple_copies;
|
||||
bool _export_header;
|
||||
@ -205,6 +204,11 @@ public:
|
||||
void set_to_page (word to) { _topage = to; }
|
||||
void set_hwff (bool hwff) { _hwformfeed = hwff; }
|
||||
|
||||
// resa pubblica per farsi usare dagli altri
|
||||
// la stampante e' un servizio, se non si fa usare
|
||||
// che servizio e'?
|
||||
void parse_background(const char* bgdesc, TArray& bg);
|
||||
|
||||
int descriptions()
|
||||
{ return _printers.items(); }
|
||||
const PrinterDef& get_description(word i) const
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: progind.h,v 1.3 1994-11-11 18:04:25 guy Exp $ */
|
||||
/* $Id: progind.h,v 1.4 1994-12-01 14:49:33 villa Exp $ */
|
||||
|
||||
/* @N
|
||||
progind.h
|
||||
@ -53,10 +53,10 @@ protected:
|
||||
|
||||
public:
|
||||
/* @FPUB */
|
||||
bool iscancelled() const { return _flags & IND_CANCELLED; }
|
||||
bool isfinished() const { return _flags & IND_FINISHED; }
|
||||
long status() const { return _status; }
|
||||
void cancel() { _flags |= IND_CANCELLED; check_stop(); }
|
||||
bool iscancelled() const { do_events(); return _flags & IND_CANCELLED; }
|
||||
bool isfinished() const { do_events(); return _flags & IND_FINISHED; }
|
||||
long status() const { do_events(); return _status; }
|
||||
void cancel() { _flags |= IND_CANCELLED; do_events(); check_stop(); }
|
||||
|
||||
virtual bool can_be_closed() const;
|
||||
/* @END */
|
||||
|
@ -353,7 +353,7 @@ bool TTextfile::append (const char *l)
|
||||
|
||||
void TTextfile::close ()
|
||||
{
|
||||
CHECK (_isopen, "Attempt operation on closed file");
|
||||
CHECK (_isopen,"Attempt operation on closed file");
|
||||
fclose (_instr);
|
||||
fclose (_index);
|
||||
_instr = _index = NULL;
|
||||
@ -443,6 +443,7 @@ _hotspots (4), _accept (TRUE)
|
||||
_filename.temp ();
|
||||
_istemp = TRUE;
|
||||
}
|
||||
_isopen = TRUE;
|
||||
|
||||
_instr = fopen (_filename, "a+");
|
||||
_indname.temp ();
|
||||
@ -453,20 +454,30 @@ _hotspots (4), _accept (TRUE)
|
||||
yesnofatal_box ("Impossibile aprire files temporanei");
|
||||
freeze ();
|
||||
}
|
||||
if (file != NULL)
|
||||
while (!feof (_instr))
|
||||
if (!_istemp)
|
||||
while (!feof(_instr))
|
||||
{
|
||||
const long l = ftell (_instr);
|
||||
fwrite (&l, sizeof (long), 1, _index);
|
||||
if (ferror (_index) || ferror (_instr))
|
||||
if (ferror(_index) || ferror(_instr))
|
||||
{
|
||||
error_box ("Errore di scrittura file temporaneo: scrittura interrotta");
|
||||
freeze ();
|
||||
}
|
||||
fgets (mytmpstr, sizeof (mytmpstr), _instr);
|
||||
if (fgets (mytmpstr, sizeof (mytmpstr), _instr) == NULL)
|
||||
break;
|
||||
if (mytmpstr[strlen(mytmpstr)-1] == '\n')
|
||||
mytmpstr[strlen(mytmpstr)-1] = '\0';
|
||||
if ((_lines) < (_page_start + _page_size))
|
||||
{
|
||||
TString *ll = new TString (mytmpstr);
|
||||
_page.add(ll);
|
||||
_page_end++;
|
||||
|
||||
// TBI process links
|
||||
}
|
||||
_lines++;
|
||||
}
|
||||
_isopen = TRUE;
|
||||
}
|
||||
|
||||
TTextfile::~TTextfile ()
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <utility.h>
|
||||
#include <viswin.h>
|
||||
#include <xvtility.h>
|
||||
#include <colors.h>
|
||||
|
||||
#ifndef __PRINTER_H
|
||||
typedef void (*LINKHANDLER) (int, const char *);
|
||||
@ -21,13 +22,11 @@ extern "C"
|
||||
}
|
||||
#endif
|
||||
|
||||
#define BUTTONROW_SIZE 3
|
||||
#define W_X1 (origin().x+5)
|
||||
#define W_Y1 (origin().y+1)
|
||||
#define W_X2 (origin().x+columns())
|
||||
#define W_Y2 (origin().y+rows()+1-BUTTONROW_SIZE)
|
||||
#define TEXTROWS (rows() - 1 - BUTTONROW_SIZE)
|
||||
#define TEXTCOLUMNS (columns() - 6)
|
||||
#define BUTTONROW_SIZE (_toplevel ? 3 : 0)
|
||||
#define X_OFFSET (_rulers ? 6 : 1)
|
||||
#define Y_OFFSET (_rulers ? 1 : 0)
|
||||
#define TEXTROWS (rows() - Y_OFFSET - BUTTONROW_SIZE)
|
||||
#define TEXTCOLUMNS (columns() - X_OFFSET)
|
||||
|
||||
#define DLG_QUIT_TITLE "Fine"
|
||||
#define DLG_EDIT_TITLE "~Edit"
|
||||
@ -35,8 +34,8 @@ extern "C"
|
||||
#define DLG_PRINT_TITLE "~Stampa"
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
#define BACKGROUND MASK_BACK_COLOR
|
||||
#define FOREGROUND COLOR_BLACK
|
||||
#define BACKGROUND (_toplevel ? MASK_BACK_COLOR : COLOR_GRAY)
|
||||
#define FOREGROUND (_toplevel ? COLOR_BLACK : COLOR_WHITE)
|
||||
#else
|
||||
#define BACKGROUND COLOR_BLACK
|
||||
#define FOREGROUND COLOR_WHITE
|
||||
@ -64,39 +63,47 @@ void TViswin::exec_link()
|
||||
{
|
||||
if (_linkID != -1)
|
||||
{
|
||||
LINKHANDLER pl = main_app().printer().getlinkhandler();
|
||||
if (pl)
|
||||
pl(_linkID, _multiple ? (const char*)_multiple_link : (const char*)_linktxt);
|
||||
|
||||
// dai opzione per rifare la stampa se e' arrivato un messaggio
|
||||
// dall'applicazione chiamata
|
||||
// schiaffa indi il tutto in una funzione
|
||||
TMailbox m;
|
||||
if (m.next_s(MSG_LN) != NULL)
|
||||
if (!_toplevel)
|
||||
{
|
||||
if (yesno_box("Si desidera riaggiornare la stampa?"))
|
||||
// link da browsefile_field
|
||||
MASK_LINKHANDLER pl = _brwfld->_lh;
|
||||
if (pl != NULL)
|
||||
pl(_brwfld->mask(), _linkID,
|
||||
_multiple ? (const char*)_multiple_link : (const char*)_linktxt, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
LINKHANDLER pl = main_app().printer().getlinkhandler();
|
||||
if (pl)
|
||||
pl(_linkID, _multiple ? (const char*)_multiple_link :
|
||||
(const char*)_linktxt);
|
||||
// dai opzione per rifare la stampa se e' arrivato un messaggio
|
||||
// dall'applicazione chiamata
|
||||
// schiaffa indi il tutto in una funzione
|
||||
TMailbox m;
|
||||
if (m.next_s(MSG_LN) != NULL)
|
||||
{
|
||||
((TPrint_application&)main_app()).repeat_print();
|
||||
if (yesno_box("Si desidera riaggiornare la stampa?"))
|
||||
{
|
||||
((TPrint_application&)main_app()).repeat_print();
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
xvt_statbar_refresh ();
|
||||
xvt_statbar_refresh ();
|
||||
#endif
|
||||
stop_run(K_ENTER);
|
||||
}
|
||||
}
|
||||
|
||||
stop_run(K_ENTER);
|
||||
}
|
||||
}
|
||||
} // _toplevel
|
||||
set_focus();
|
||||
check_link();
|
||||
_need_update = TRUE;
|
||||
force_update();
|
||||
do_events();
|
||||
check_link (&_point);
|
||||
}
|
||||
else
|
||||
beep();
|
||||
} // linkID != -1
|
||||
else beep();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TViswin::display_link (long y, long x1, long x2, const char *d)
|
||||
{
|
||||
if (!_link_displayed)
|
||||
@ -104,8 +111,7 @@ void TViswin::display_link (long y, long x1, long x2, const char *d)
|
||||
paint_link (y, x1, x2);
|
||||
_link_displayed = TRUE;
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
xvt_statbar_set (d);
|
||||
xvt_statbar_refresh ();
|
||||
xvt_statbar_set(d);
|
||||
#endif
|
||||
xvt_enable_control (_link_button, TRUE);
|
||||
}
|
||||
@ -129,7 +135,8 @@ void TViswin::erase_link (long y, long x1, long x2)
|
||||
void TViswin::paint_link (long y, long x1, long x2)
|
||||
{
|
||||
if (adjust_box (x1, x2, y))
|
||||
invert_bar ((int) (x1 + 6l), (int) (y + 1l), (int) (x2 + 6l), (int) (y + 2l));
|
||||
invert_bar ((int)(x1 + (long)X_OFFSET), (int)(y + (long)Y_OFFSET),
|
||||
(int)(x2 + (long)X_OFFSET), (int)(y + (long)Y_OFFSET+1l));
|
||||
}
|
||||
|
||||
bool TViswin::adjust_box (long &x1, long &x2, long y)
|
||||
@ -235,6 +242,16 @@ bool TViswin::check_link (TPoint * p)
|
||||
y = py;
|
||||
strcpy (descr, pdescr);
|
||||
display_link (y, x1, x2, descr);
|
||||
|
||||
if (!_toplevel)
|
||||
{
|
||||
// chiama l'handler per maschere con FALSE come terzo parametro
|
||||
MASK_LINKHANDLER pl = _brwfld->_lh;
|
||||
if (pl != NULL)
|
||||
pl(_brwfld->mask(), _linkID,
|
||||
_multiple ? (const char*)_multiple_link : (const char*)_linktxt, FALSE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@ -242,7 +259,7 @@ bool TViswin::check_link (TPoint * p)
|
||||
|
||||
bool TViswin::in_text (const TPoint & p) const
|
||||
{
|
||||
if (p.x > 5 && p.x < columns () && p.y > 0 && p.y < (rows () - 3))
|
||||
if (p.x > 5 && p.x < columns () && p.y > 0 && p.y < (rows () - BUTTONROW_SIZE))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@ -301,13 +318,15 @@ void TViswin::shift_screen (scroll dir)
|
||||
{
|
||||
case up:
|
||||
case down:
|
||||
set_rect (&r, 0, CHARY + 2, (int) (CHARX * (_textcolumns + 6)), (int) (CHARY * (_textrows + 1)));
|
||||
set_rect (&r, 0, (CHARY*Y_OFFSET) + 2, (int) (CHARX * (_textcolumns + X_OFFSET)),
|
||||
(int)(CHARY * (_textrows + Y_OFFSET)));
|
||||
win_scroll_rect (win (), &r, 0, dir == down ? CHARY : -CHARY);
|
||||
paint_row (dir == up ? origin ().y + _textrows - 1 : origin ().y);
|
||||
break;
|
||||
case left:
|
||||
case right:
|
||||
set_rect (&r, CHARX * 6, 0, (int) (CHARX * (_textcolumns + 6) + 2), (int) (CHARY * (_textrows + 1) - 2));
|
||||
set_rect (&r, CHARX * X_OFFSET, 0, (int) (CHARX * (_textcolumns + X_OFFSET) + 2),
|
||||
(int) (CHARY * (_textrows + 1) - 2));
|
||||
win_scroll_rect (win (), &r, dir == right ? CHARX : -CHARX, 0);
|
||||
paint_column (dir == left ? origin ().x + _textcolumns - 1 : origin ().x,
|
||||
dir == left);
|
||||
@ -340,7 +359,10 @@ WINDOW TViswin::add_button (short id, const char *caption)
|
||||
}
|
||||
|
||||
void TViswin::repos_buttons ()
|
||||
{
|
||||
{
|
||||
|
||||
if (!_toplevel) return;
|
||||
|
||||
for (int buttons = 0; _button[buttons] != NULL_WIN; buttons++)
|
||||
if (buttons == MAXBUT - 1)
|
||||
{
|
||||
@ -353,8 +375,8 @@ void TViswin::repos_buttons ()
|
||||
|
||||
autoscroll (FALSE);
|
||||
set_mode (M_COPY);
|
||||
set_brush (MASK_BACK_COLOR);
|
||||
bar (5, rows () - 3, columns () + 1, rows () + 1);
|
||||
set_brush (BACKGROUND);
|
||||
bar (5, rows () - BUTTONROW_SIZE, columns () + 1, rows () + 1);
|
||||
autoscroll (TRUE);
|
||||
|
||||
RCT wr;
|
||||
@ -403,7 +425,7 @@ void TViswin::paint_screen ()
|
||||
|
||||
PNT b, e;
|
||||
b.h = CHARX * 5;
|
||||
b.v = (CHARY * (int) (j + 1l - origin ().y)) - 2;
|
||||
b.v = (CHARY * (int) (j + (long)Y_OFFSET - origin ().y)) - 2;
|
||||
e.h = CHARX * columns ();
|
||||
e.v = b.v;
|
||||
win_move_to (win (), b);
|
||||
@ -414,7 +436,8 @@ void TViswin::paint_screen ()
|
||||
win_move_to (win (), b);
|
||||
win_draw_line (win (), e);
|
||||
set_brush (COLOR_DKGRAY);
|
||||
bar (5, (int) (j + 1l - origin ().y), (int) columns (), (int) (rows () - 3l));
|
||||
bar (5, (int)(j+(long)Y_OFFSET-origin().y),(int)columns(),
|
||||
(int)(rows()-(long)BUTTONROW_SIZE));
|
||||
autoscroll (TRUE);
|
||||
break;
|
||||
#endif
|
||||
@ -427,7 +450,7 @@ void TViswin::paint_background (long j, int row)
|
||||
if (!_isbackground)
|
||||
return;
|
||||
int rw = (int) (j % (long) _formlen);
|
||||
TString & rwd = (TString &) (*_bg)[rw];
|
||||
TString & rwd = (TString &)(*_bg)[rw];
|
||||
int cnt = 0;
|
||||
char ch;
|
||||
|
||||
@ -444,7 +467,7 @@ void TViswin::paint_background (long j, int row)
|
||||
{
|
||||
case 'v': // verticale intera
|
||||
|
||||
x1 = (unsigned char) rwd[cnt++] + 5;
|
||||
x1 = (unsigned char) rwd[cnt++] + (X_OFFSET -1);
|
||||
b.h = e.h = x1 * CHARX + CHARX / 2;
|
||||
b.v = row * CHARY;
|
||||
e.v = (row + 1) * CHARY;
|
||||
@ -453,7 +476,7 @@ void TViswin::paint_background (long j, int row)
|
||||
break;
|
||||
case 'o': // verticale pezzo sopra
|
||||
|
||||
x1 = (unsigned char) rwd[cnt++] + 5;
|
||||
x1 = (unsigned char) rwd[cnt++] + (X_OFFSET -1);
|
||||
b.h = e.h = x1 * CHARX + CHARX / 2;
|
||||
b.v = row * CHARY;
|
||||
e.v = (row + 1) * CHARY - CHARY / 2;
|
||||
@ -462,7 +485,7 @@ void TViswin::paint_background (long j, int row)
|
||||
break;
|
||||
case 'u': // verticale pezzo sotto
|
||||
|
||||
x1 = (unsigned char) rwd[cnt++] + 5;
|
||||
x1 = (unsigned char) rwd[cnt++] + (X_OFFSET -1);
|
||||
b.h = e.h = x1 * CHARX + CHARX / 2;
|
||||
b.v = row * CHARY + CHARY / 2;
|
||||
e.v = (row + 1) * CHARY;
|
||||
@ -471,8 +494,8 @@ void TViswin::paint_background (long j, int row)
|
||||
break;
|
||||
case 'h': // orizzontale intera
|
||||
|
||||
x1 = (unsigned char) rwd[cnt++] + 5;
|
||||
x2 = (unsigned char) rwd[cnt++] + 5;
|
||||
x1 = (unsigned char) rwd[cnt++] + (X_OFFSET -1);
|
||||
x2 = (unsigned char) rwd[cnt++] + (X_OFFSET -1);
|
||||
b.v = e.v = row * CHARY + CHARY / 2;
|
||||
b.h = x1 * CHARX;
|
||||
e.h = (x2 + 1) * CHARX;
|
||||
@ -481,8 +504,8 @@ void TViswin::paint_background (long j, int row)
|
||||
break;
|
||||
case 'r': // orizzontale scorciata agli estremi
|
||||
|
||||
x1 = (unsigned char) rwd[cnt++] + 5;
|
||||
x2 = (unsigned char) rwd[cnt++] + 5;
|
||||
x1 = (unsigned char) rwd[cnt++] + (X_OFFSET -1);
|
||||
x2 = (unsigned char) rwd[cnt++] + (X_OFFSET -1);
|
||||
b.v = e.v = row * CHARY + CHARY / 2;
|
||||
b.h = x1 * CHARX + CHARX / 2;
|
||||
e.h = x2 * CHARX + CHARX / 2;
|
||||
@ -524,28 +547,32 @@ void TViswin::paint_row (long j)
|
||||
TPoint p1, p2;
|
||||
if (need_paint_sel (FALSE))
|
||||
adjust_selection (p1, p2);
|
||||
int row = (int) (j + 1l - y);
|
||||
int row = (int) (j + (long)Y_OFFSET - y);
|
||||
static char fill[] = " "
|
||||
" ";
|
||||
autoscroll (FALSE);
|
||||
set_font (FF_FIXED, 0);
|
||||
set_mode (M_COPY);
|
||||
set_opaque_text (TRUE);
|
||||
set_color (FOREGROUND, BACKGROUND);
|
||||
printat (0, row, "%05ld", j + 1);
|
||||
autoscroll(FALSE);
|
||||
set_font(FF_FIXED, 0);
|
||||
set_mode(M_COPY);
|
||||
set_opaque_text(TRUE);
|
||||
if (_rulers)
|
||||
{
|
||||
set_color(FOREGROUND, BACKGROUND);
|
||||
set_brush(BACKGROUND);
|
||||
printat(0, row, "%05ld", j + 1);
|
||||
}
|
||||
if (_scrolling)
|
||||
{
|
||||
hide_pen ();
|
||||
set_brush (COLOR_WHITE);
|
||||
RCT r;
|
||||
r.top = row * CHARY;
|
||||
r.left = CHARX * 5,
|
||||
r.left = CHARX * (X_OFFSET -1),
|
||||
r.bottom = r.top + CHARY + 2;
|
||||
r.right = CHARX * 255;
|
||||
win_draw_rect (win (), &r);
|
||||
}
|
||||
const char *cp;
|
||||
int pos = 0;
|
||||
int pos = 0;
|
||||
_txt.read_line (j, origin ().x);
|
||||
while (cp = _txt.piece ())
|
||||
{
|
||||
@ -559,17 +586,17 @@ void TViswin::paint_row (long j)
|
||||
#else
|
||||
set_color (COLOR_BLACK, COLOR_WHITE);
|
||||
#endif
|
||||
printat (6 + pos, row, "%s", cp);
|
||||
printat (X_OFFSET + pos, row, "%s", cp);
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
if (st & underlined)
|
||||
{
|
||||
PNT b, e;
|
||||
|
||||
set_pen (COLOR_BLACK);
|
||||
b.h = CHARX * (6 + pos);
|
||||
b.v = (row + 1) * CHARY;
|
||||
e.h = CHARX * (6 + pos + strlen (cp));
|
||||
e.v = (row + 1) * CHARY;
|
||||
b.h = CHARX*(X_OFFSET + pos);
|
||||
b.v = (row+Y_OFFSET) * CHARY;
|
||||
e.h = CHARX*(X_OFFSET + pos + strlen (cp));
|
||||
e.v = (row+Y_OFFSET)*CHARY;
|
||||
win_move_to (win (), b);
|
||||
win_draw_line (win (), e);
|
||||
}
|
||||
@ -579,21 +606,21 @@ void TViswin::paint_row (long j)
|
||||
if (_scrolling && (pos < _textcolumns))
|
||||
{
|
||||
set_color (COLOR_BLACK, COLOR_WHITE);
|
||||
printat (6 + pos, row, "%s", fill);
|
||||
printat (X_OFFSET + pos, row, "%s", fill);
|
||||
}
|
||||
#if XVT_OS == XVT_OS_WIN // paint page limits
|
||||
if ((j % _formlen) == (_formlen - 1)) // last row
|
||||
if ((j % _formlen) == (_formlen - 1) && _toplevel) // last row
|
||||
|
||||
{
|
||||
PNT b, e;
|
||||
|
||||
b.h = CHARX * 5;
|
||||
b.v = (row + 1) * CHARY - 1;
|
||||
b.h = CHARX * (X_OFFSET -1);
|
||||
b.v = (row + Y_OFFSET) * CHARY - 1;
|
||||
e.h = CHARX * 132;
|
||||
e.v = (row + 1) * CHARY - 1;
|
||||
e.v = (row + Y_OFFSET) * CHARY - 1;
|
||||
set_pen (COLOR_LTGRAY, 2, PAT_SOLID, P_DASH);
|
||||
win_move_to (win (), b);
|
||||
win_draw_line (win (), e);
|
||||
win_move_to (win(), b);
|
||||
win_draw_line (win(), e);
|
||||
}
|
||||
#endif
|
||||
paint_background (j, row);
|
||||
@ -621,8 +648,8 @@ void TViswin::paint_column (long j, bool end)
|
||||
long fg = trans_color (_txt.get_foreground ((int) j));
|
||||
set_color (fg, bg);
|
||||
#endif
|
||||
int col = end ? (int) (_textcolumns + 5) : 6;
|
||||
printat (col, (int) l + 1, "%c",
|
||||
int col = end ? (int) (_textcolumns + X_OFFSET -1) : X_OFFSET;
|
||||
printat (col, (int) l + Y_OFFSET, "%c",
|
||||
(unsigned int) j < strlen (c) ? c[(int) j] : ' ');
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
if ((st & underlined) && strlen (c) > (word) j)
|
||||
@ -648,8 +675,8 @@ void TViswin::draw_crossbars ()
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
|
||||
if (_cross.v > CHARY && _cross.v < (rows () - 3) * CHARY &&
|
||||
_cross.h > CHARX * 5 && _cross.h < columns () * CHARX)
|
||||
if (_cross.v > CHARY && _cross.v < (rows () - BUTTONROW_SIZE) * CHARY &&
|
||||
_cross.h > CHARX * (X_OFFSET - 1) && _cross.h < columns () * CHARX)
|
||||
{
|
||||
set_pen (COLOR_BLACK);
|
||||
set_mode (M_XOR);
|
||||
@ -658,12 +685,12 @@ void TViswin::draw_crossbars ()
|
||||
|
||||
autoscroll (FALSE);
|
||||
b1.h = _cross.h;
|
||||
b1.v = CHARY;
|
||||
b1.v = CHARY * Y_OFFSET;
|
||||
e1.h = _cross.h;
|
||||
e1.v = ((rows () - 3) * CHARY);
|
||||
b2.h = CHARX * 5;
|
||||
e1.v = ((rows() - BUTTONROW_SIZE + (_rulers ? 0 : 1)) * CHARY);
|
||||
b2.h = CHARX * (X_OFFSET -1);
|
||||
b2.v = _cross.v;
|
||||
e2.h = CHARX * columns ();
|
||||
e2.h = CHARX * columns();
|
||||
e2.v = _cross.v;
|
||||
win_move_to (win (), b1);
|
||||
win_draw_line (win (), e1);
|
||||
@ -710,19 +737,25 @@ void TViswin::paint_point (bool erase)
|
||||
|
||||
if (_isbar)
|
||||
{
|
||||
invert_bar (6, (int) (_point.y - origin ().y + 1l),
|
||||
(int) columns (), (int) (_point.y - origin ().y + 2l));
|
||||
invert_bar ((int) (_point.x - origin ().x + 6l), 1,
|
||||
(int) (_point.x - origin ().x + 7l), (int) (rows () - 3l));
|
||||
invert_bar (X_OFFSET, (int)(_point.y - origin().y + (long)Y_OFFSET),
|
||||
(int)columns(), (int) (_point.y - origin().y + (long)Y_OFFSET + 1l));
|
||||
invert_bar ((int)(_point.x - origin().x + (long)X_OFFSET), Y_OFFSET,
|
||||
(int)(_point.x - origin().x + (long)X_OFFSET + 1l),
|
||||
(int)(rows() - (long)BUTTONROW_SIZE));
|
||||
}
|
||||
else
|
||||
{
|
||||
invert_bar ((int) (_point.x - origin ().x + 6l), (int) (_point.y - origin ().y + 1l),
|
||||
(int) (_point.x - origin ().x + 7l), (int) (_point.y - origin ().y + 2l));
|
||||
invert_bar (0, (int) (_point.y - origin ().y + 1l), 5,
|
||||
(int) (_point.y - origin ().y + 2l));
|
||||
invert_bar ((int) (_point.x - origin ().x + 6l), 0,
|
||||
(int) (_point.x - origin ().x + 7l), 1);
|
||||
invert_bar ((int) (_point.x - origin ().x + (long)X_OFFSET),
|
||||
(int) (_point.y - origin ().y + (long)Y_OFFSET),
|
||||
(int) (_point.x - origin ().x + (long)X_OFFSET + 1l),
|
||||
(int) (_point.y - origin ().y + (long)Y_OFFSET + 1l));
|
||||
if (_rulers)
|
||||
{
|
||||
invert_bar (0, (int) (_point.y - origin ().y + (long)Y_OFFSET), (X_OFFSET -1),
|
||||
(int) (_point.y - origin ().y + (long)Y_OFFSET + 1l));
|
||||
invert_bar ((int) (_point.x - origin ().x + (long)X_OFFSET), 0,
|
||||
(int) (_point.x - origin ().x + (long)X_OFFSET + 1l), 1);
|
||||
}
|
||||
}
|
||||
autoscroll (TRUE);
|
||||
wasbar = _isbar;
|
||||
@ -730,7 +763,9 @@ void TViswin::paint_point (bool erase)
|
||||
|
||||
// draw screen header
|
||||
void TViswin::paint_header ()
|
||||
{
|
||||
{
|
||||
if (!_rulers)
|
||||
return;
|
||||
set_mode (M_COPY);
|
||||
set_opaque_text (TRUE);
|
||||
set_color (FOREGROUND, BACKGROUND);
|
||||
@ -744,7 +779,7 @@ void TViswin::paint_header ()
|
||||
}
|
||||
autoscroll (FALSE);
|
||||
set_color (COLOR_WHITE, BACKGROUND);
|
||||
printat (0, 0, "P.%3ld ", ((origin ().y) / _formlen) + 1l);
|
||||
printat (0, 0, "P.%3ld ", ((origin().y) / _formlen) + 1l);
|
||||
autoscroll (TRUE);
|
||||
}
|
||||
|
||||
@ -757,12 +792,12 @@ void TViswin::paint_selection ()
|
||||
for (long l = p1.y; l <= p2.y; l++)
|
||||
{
|
||||
int top, left, right;
|
||||
top = (int) (l - origin ().y + 1);
|
||||
top = (int) (l - origin().y + 1);
|
||||
if (top > 0 && top <= _textrows)
|
||||
{
|
||||
left = p1.y == l ? (int) (p1.x - origin ().x + 6l) : 6;
|
||||
right = p2.y == l ? (int) (p2.x - origin ().x + 6l) :
|
||||
(int) (_textcolumns + 6l);
|
||||
left = p1.y == l ? (int)(p1.x-origin().x + (long)X_OFFSET) : X_OFFSET;
|
||||
right = p2.y == l ? (int)(p2.x-origin().x + (long)X_OFFSET) :
|
||||
(int)(_textcolumns + (long)X_OFFSET);
|
||||
autoscroll (FALSE);
|
||||
invert_bar (left, top, right, top + 1);
|
||||
autoscroll (TRUE);
|
||||
@ -771,7 +806,7 @@ void TViswin::paint_selection ()
|
||||
}
|
||||
|
||||
void TViswin::paint_waitbar (bool xor)
|
||||
{
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
static int pic;
|
||||
#endif
|
||||
@ -779,20 +814,20 @@ void TViswin::paint_waitbar (bool xor)
|
||||
if (xor)
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
cpb_win_picture_draw_at (win (), _picture[pic], 4, 4 + (int) (rows () - 3l) * CHARY);
|
||||
cpb_win_picture_draw_at(win(),_picture[pic],4,4+(int)(rows()-(long)BUTTONROW_SIZE)*CHARY);
|
||||
if (pic == 3)
|
||||
pic = 0;
|
||||
else
|
||||
pic++;
|
||||
#else
|
||||
invert_bar (3, rows () - 2, 4, rows () - 1);
|
||||
invert_bar (3, rows() - 2, 4, rows() - 1);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
cpb_win_picture_draw_at (win (), _picture[pic], 4,
|
||||
4 + (int) (rows () - 3l) * CHARY);
|
||||
4 + (int) (rows () - (long)BUTTONROW_SIZE) * CHARY);
|
||||
if (pic == 3)
|
||||
pic = 0;
|
||||
else
|
||||
@ -812,26 +847,38 @@ void TViswin::update ()
|
||||
erase_point ();
|
||||
autoscroll (FALSE);
|
||||
set_mode (M_COPY);
|
||||
set_brush (MASK_BACK_COLOR);
|
||||
bar (5, rows () - 3, columns () + 1, rows () + 1);
|
||||
|
||||
if (_toplevel)
|
||||
{
|
||||
set_brush (BACKGROUND);
|
||||
bar ((X_OFFSET-1), rows()-BUTTONROW_SIZE, columns()+1, rows() + 1);
|
||||
}
|
||||
if (_need_update)
|
||||
{
|
||||
if (_isselection)
|
||||
erase_selection ();
|
||||
clear (COLOR_WHITE);
|
||||
set_mode (M_COPY);
|
||||
set_brush (MASK_BACK_COLOR);
|
||||
set_mode (M_COPY);
|
||||
set_brush (BACKGROUND);
|
||||
autoscroll (FALSE);
|
||||
bar (0, 0, columns () + 1, 1);
|
||||
bar (0, 0, 5, rows () + 1);
|
||||
bar (5, rows () - 3, columns () + 1, rows () + 1);
|
||||
if (_isopen)
|
||||
if (_rulers)
|
||||
{
|
||||
bar (0, 0, columns() + 1, 1);
|
||||
bar (0, 0, 5, rows() + 1);
|
||||
// RCT r1, r2;
|
||||
// r1.top = 0; r1.left = 0; r1.bottom = CHARY; r1.right = (columns() + 1)*CHARX;
|
||||
// r2.top = 0; r2.left = 0; r2.bottom = (rows()+1)*CHARY; r2.right = 5*CHARX;
|
||||
// xvt_draw_rect(win(), r1, COLOR_WHITE, COLOR_GRAY, 2);
|
||||
// xvt_draw_rect(win(), r2, COLOR_WHITE, COLOR_GRAY, 2);
|
||||
}
|
||||
if (_toplevel)
|
||||
bar ((X_OFFSET -1), rows()-BUTTONROW_SIZE, columns() + 1, rows() + 1);
|
||||
if (_toplevel && _isopen)
|
||||
paint_waitbar (FALSE);
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
else if (parent() == TASK_WIN)
|
||||
else if (_toplevel)
|
||||
cpb_win_picture_draw_at (win(), _modpic, 4,
|
||||
4 + (int) (rows () - 3l) * CHARY);
|
||||
4 + (int) (rows () - (long)BUTTONROW_SIZE) * CHARY);
|
||||
#endif
|
||||
autoscroll (TRUE);
|
||||
paint_header ();
|
||||
@ -932,7 +979,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
}
|
||||
else if (ep->v.timer.id == _wtimer)
|
||||
{
|
||||
paint_waitbar ();
|
||||
if (_toplevel) paint_waitbar ();
|
||||
kill_timer (_wtimer);
|
||||
if (_isopen)
|
||||
_wtimer = set_timer (win, 150l);
|
||||
@ -960,8 +1007,8 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
|
||||
erase_point ();
|
||||
_sel_start = ep->v.mouse.where;
|
||||
_sel_start.x += (origin ().x - 6);
|
||||
_sel_start.y += (origin ().y - 1);
|
||||
_sel_start.x += (origin ().x - X_OFFSET);
|
||||
_sel_start.y += (origin ().y - Y_OFFSET);
|
||||
_sel_end = _sel_start;
|
||||
_selecting = TRUE;
|
||||
}
|
||||
@ -982,8 +1029,8 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
{
|
||||
p = ep->v.mouse.where;
|
||||
|
||||
if (_isopen && (p.x >= 4 && p.x) <= 6 &&
|
||||
(p.y >= (int) rows () - 3 && p.y <= (int) rows () - 1))
|
||||
if (_isopen && (p.x >= 4 && p.x) <= X_OFFSET &&
|
||||
(p.y >= (int)rows () - BUTTONROW_SIZE && p.y <= (int)rows() - Y_OFFSET))
|
||||
{
|
||||
abort_print ();
|
||||
ignore = TRUE;
|
||||
@ -995,8 +1042,8 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
break;
|
||||
}
|
||||
// confirm selection & store
|
||||
p.x += (origin ().x - 6);
|
||||
p.y += (origin ().y - 1);
|
||||
p.x += (origin ().x - X_OFFSET);
|
||||
p.y += (origin ().y - Y_OFFSET);
|
||||
|
||||
if (_sel_start == p)
|
||||
{
|
||||
@ -1099,7 +1146,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
if (_iscross)
|
||||
display_crossbar ();
|
||||
}
|
||||
else if (p.x <= 5l)
|
||||
else if (p.x <= (long)(X_OFFSET - 1))
|
||||
{
|
||||
if (_isselection)
|
||||
erase_selection ();
|
||||
@ -1111,7 +1158,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
if (_iscross)
|
||||
display_crossbar ();
|
||||
}
|
||||
else if (p.x >= _textcolumns + 6)
|
||||
else if (p.x >= _textcolumns + X_OFFSET)
|
||||
{
|
||||
if (_isselection)
|
||||
erase_selection ();
|
||||
@ -1127,8 +1174,8 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
{
|
||||
if (in_text (p))
|
||||
{
|
||||
p.x += (origin ().x - 6);
|
||||
p.y += (origin ().y - 1);
|
||||
p.x += (origin ().x - X_OFFSET);
|
||||
p.y += (origin ().y - Y_OFFSET);
|
||||
_point = p;
|
||||
if (_point.y >= _txt.lines ())
|
||||
_point.y = _txt.lines () - 1l;
|
||||
@ -1186,7 +1233,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
{
|
||||
kdiff = (int) (_point.y - origin ().y);
|
||||
new_origin = origin ().y > _textrows ?
|
||||
origin ().y - _textrows + 1l : 0;
|
||||
origin().y - _textrows + 1l : 0;
|
||||
_point.y = new_origin + kdiff;
|
||||
check_link ();
|
||||
update_thumb (origin ().x, new_origin);
|
||||
@ -1208,10 +1255,10 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
{
|
||||
kdiff = (int) (_point.x - origin ().x);
|
||||
new_origin = origin ().x > _textcolumns ?
|
||||
origin ().x - _textcolumns + 1 : 0;
|
||||
origin().x - _textcolumns + 1 : 0;
|
||||
_point.x = new_origin + kdiff;
|
||||
check_link ();
|
||||
update_thumb(new_origin, _point.y);
|
||||
update_thumb(new_origin, origin().y);
|
||||
_need_update = TRUE;
|
||||
update (); // AAAARGH!
|
||||
|
||||
@ -1235,7 +1282,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
if (need_paint_sel ())
|
||||
erase_selection ();
|
||||
check_link ();
|
||||
update_thumb (origin ().x, origin ().y - 1l);
|
||||
update_thumb (origin().x, origin().y - 1l);
|
||||
_need_scroll = down;
|
||||
}
|
||||
else
|
||||
@ -1252,7 +1299,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
if (need_paint_sel (FALSE))
|
||||
erase_selection ();
|
||||
check_link ();
|
||||
update_thumb (origin ().x - 1l, origin ().y);
|
||||
update_thumb (origin().x - 1l, origin().y);
|
||||
_point.x--;
|
||||
_need_scroll = right;
|
||||
}
|
||||
@ -1266,7 +1313,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
case SC_PAGE_DOWN:
|
||||
if (ep->type == E_VSCROLL)
|
||||
{
|
||||
if ((origin ().y + _textrows) < _txt.lines ())
|
||||
if ((origin().y + _textrows) < _txt.lines())
|
||||
{
|
||||
kdiff = (int) (_point.y - origin ().y);
|
||||
new_origin = (_txt.lines () - origin ().y) >
|
||||
@ -1289,14 +1336,14 @@ void TViswin::handler (WINDOW win, EVENT * ep)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((origin ().x + _textcolumns) < 256)
|
||||
if ((origin().x + _textcolumns) < 256)
|
||||
{
|
||||
kdiff = (int) (_point.x - origin ().x);
|
||||
new_origin = (256 - origin ().x) > _textcolumns ?
|
||||
origin ().x + _textcolumns - 1 : 256 - _textcolumns;
|
||||
_point.x = new_origin + kdiff;
|
||||
check_link ();
|
||||
update_thumb (new_origin, origin ().y);
|
||||
update_thumb (new_origin, origin().y);
|
||||
_need_update = TRUE;
|
||||
update (); // AAAARGH!
|
||||
|
||||
@ -1469,7 +1516,9 @@ bool TViswin::on_key (KEY key)
|
||||
{
|
||||
erase_selection ();
|
||||
_isselection = FALSE;
|
||||
}
|
||||
}
|
||||
if (_toplevel)
|
||||
exec_link();
|
||||
break;
|
||||
case K_TAB:
|
||||
if (_curbut == (_buttons - 1))
|
||||
@ -1645,7 +1694,7 @@ bool TViswin::on_key (KEY key)
|
||||
case K_DOWN:
|
||||
case K_SHIFT_DOWN:
|
||||
_need_update = FALSE;
|
||||
if (_point.y < (_txt.lines () - 1))
|
||||
if (_point.y < (_txt.lines() - 1))
|
||||
{
|
||||
if (key == K_SHIFT_DOWN)
|
||||
{
|
||||
@ -1657,12 +1706,12 @@ bool TViswin::on_key (KEY key)
|
||||
_selecting = TRUE;
|
||||
}
|
||||
}
|
||||
if (_point.y == origin ().y + _textrows - 1)
|
||||
if (_point.y == origin().y + _textrows - 1)
|
||||
{
|
||||
if (need_paint_sel ())
|
||||
erase_selection ();
|
||||
if (need_paint_sel())
|
||||
erase_selection();
|
||||
// check_link();
|
||||
update_thumb (origin ().x, (++_point.y) - _textrows + 1);
|
||||
update_thumb (origin().x, (++_point.y) - _textrows + 1);
|
||||
_need_scroll = up;
|
||||
}
|
||||
else
|
||||
@ -1791,7 +1840,7 @@ void TViswin::add_line (const char *l)
|
||||
_txt.append (l);
|
||||
EVENT ev;
|
||||
ev.type = E_USER;
|
||||
ev.v.user.id = (_txt.lines () - origin ().y) <= _textrows ?
|
||||
ev.v.user.id = (_txt.lines() - origin().y) <= _textrows ?
|
||||
E_ADDLINE_ONSCREEN : E_ADDLINE;
|
||||
dispatch_event (win (), &ev);
|
||||
do_events ();
|
||||
@ -1810,20 +1859,23 @@ TViswin ::TViswin (const char *fname,
|
||||
const char *title,
|
||||
bool editbutton,
|
||||
bool printbutton,
|
||||
bool linkbutton,
|
||||
int height,
|
||||
WINDOW parent):
|
||||
bool linkbutton,
|
||||
int x, int y,
|
||||
int height, int width,
|
||||
bool rulers,
|
||||
WINDOW parent,
|
||||
TBrowsefile_field* 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),
|
||||
_link_displayed (FALSE), _point_displayed (FALSE), _selecting (FALSE),
|
||||
_scrolling (FALSE), _selflag (FALSE), _need_update (TRUE), _need_scroll (none),
|
||||
_multiple (FALSE),
|
||||
_frozen (FALSE)
|
||||
_multiple (FALSE), _rulers(rulers),
|
||||
_frozen (FALSE), _brwfld(brwfld)
|
||||
{
|
||||
if (title == NULL)
|
||||
title = (fname ? fname : "Anteprima di stampa");
|
||||
|
||||
|
||||
_isopen = fname == NULL || *fname <= ' ';
|
||||
if (_isopen)
|
||||
_filename = _txt.name ();
|
||||
@ -1834,18 +1886,20 @@ TViswin ::TViswin (const char *fname,
|
||||
if (parent == NULL_WIN)
|
||||
parent = TASK_WIN;
|
||||
|
||||
bool toplevel = parent == TASK_WIN;
|
||||
|
||||
_toplevel = parent == TASK_WIN;
|
||||
|
||||
const int larg = 76;
|
||||
const int alt = 20;
|
||||
RCT r;
|
||||
get_client_rect (parent, &r);
|
||||
int maxlarg = r.right / CHARX - 6; // Calculates max window width
|
||||
|
||||
int maxalt = height == 0 ? (r.bottom / CHARY - 6) : height;
|
||||
if (larg > maxlarg)
|
||||
RCT r;
|
||||
|
||||
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 && larg > maxlarg)
|
||||
maxlarg = larg;
|
||||
if (alt > maxalt)
|
||||
if (_toplevel && alt > maxalt)
|
||||
maxalt = alt;
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
@ -1855,20 +1909,22 @@ TViswin ::TViswin (const char *fname,
|
||||
#endif
|
||||
|
||||
long flags = WSF_HSCROLL | WSF_VSCROLL;
|
||||
if (toplevel)
|
||||
if (_toplevel)
|
||||
{
|
||||
flags |= (WSF_CLOSE | WSF_SIZE);
|
||||
}
|
||||
|
||||
WIN_TYPE rt = toplevel ? W_DOC : W_PLAIN;
|
||||
|
||||
|
||||
create (-1, parent == TASK_WIN ? -1 : 0, maxlarg, maxalt, title, flags, rt, parent);
|
||||
|
||||
WIN_TYPE rt = _toplevel ? W_DOC : W_PLAIN;
|
||||
create (x, y, maxlarg, maxalt, title, flags, rt, parent);
|
||||
set_opaque_text (TRUE);
|
||||
set_font (FF_FIXED);
|
||||
|
||||
if (toplevel)
|
||||
if (_txt.lines() > 0l)
|
||||
set_scroll_max (MAXLEN - 1, _txt.lines () <= _textrows ?
|
||||
_txt.lines () : _txt.lines () - _textrows);
|
||||
|
||||
|
||||
if (_toplevel)
|
||||
{
|
||||
add_button (DLG_QUIT, DLG_QUIT_TITLE);
|
||||
_buttons = 1;
|
||||
@ -1908,11 +1964,12 @@ TViswin ::TViswin (const char *fname,
|
||||
_textcolumns = TEXTCOLUMNS;
|
||||
autoscroll (TRUE);
|
||||
|
||||
_links = &(main_app().printer ().links ());
|
||||
_multiple = main_app().printer ().ismultiplelink ();
|
||||
_bg = main_app().printer ().getbgdesc ();
|
||||
_links = _toplevel ? &(main_app().printer().links()) : &(_brwfld->_links);
|
||||
_multiple = _toplevel ? (main_app().printer ().ismultiplelink()) :
|
||||
(_brwfld->is_multiple_link());
|
||||
_bg = _toplevel ? main_app().printer().getbgdesc() : _brwfld->get_bg_desc();
|
||||
_isbackground = _bg->items () > 0;
|
||||
_formlen = main_app().printer ().formlen ();
|
||||
_formlen = _toplevel ? main_app().printer().formlen() : maxalt;
|
||||
|
||||
for (i = 0; i < _links->items (); i++)
|
||||
{
|
||||
@ -1920,7 +1977,7 @@ TViswin ::TViswin (const char *fname,
|
||||
char f = *(t.get (1));
|
||||
char b = *(t.get (2));
|
||||
t.restart ();
|
||||
_txt.set_hotspots (f, b);
|
||||
_txt.set_hotspots(f, b);
|
||||
}
|
||||
_hotspots = &(_txt.hotspots ());
|
||||
}
|
||||
@ -1939,7 +1996,7 @@ TViswin ::~TViswin ()
|
||||
|
||||
// Certified 100%
|
||||
TBrowsefile_field::TBrowsefile_field(TMask* m)
|
||||
: TMask_field(m), _viswin(NULL)
|
||||
: TMask_field(m), _viswin(NULL), _m_link(FALSE), _background(36), _lh(NULL)
|
||||
{}
|
||||
|
||||
// Certified 100%
|
||||
@ -1957,28 +2014,109 @@ TBrowsefile_field::~TBrowsefile_field()
|
||||
|
||||
void TBrowsefile_field::parse_head(TScanner& scanner)
|
||||
{
|
||||
_width = scanner.integer();
|
||||
_size = scanner.integer();
|
||||
}
|
||||
|
||||
// Certified 100%
|
||||
bool TBrowsefile_field::parse_item(TScanner& scanner)
|
||||
{
|
||||
if (scanner.key() == "FI")
|
||||
{
|
||||
_prompt = scanner.string();
|
||||
return TRUE;
|
||||
}
|
||||
return TMask_field::parse_item(scanner);
|
||||
}
|
||||
|
||||
// Certified 100%
|
||||
void TBrowsefile_field::create(WINDOW parent)
|
||||
{
|
||||
const TMask& m = mask();
|
||||
_viswin = new TViswin(_prompt, _prompt, FALSE, FALSE, FALSE, _size, parent);
|
||||
_viswin = new TViswin(_prompt, _prompt, FALSE, FALSE, FALSE, _x, _y,
|
||||
_size, _width, _flags.rightjust ? TRUE : FALSE, parent, this);
|
||||
_win = _viswin->win();
|
||||
enable_window(_win, enabled());
|
||||
show_window(_win, showed());
|
||||
}
|
||||
|
||||
|
||||
void TBrowsefile_field::set_text(const char* file)
|
||||
{
|
||||
FILE* instr = fopen(file,"r");
|
||||
if (instr == NULL)
|
||||
error_box("File non trovato: %s", file);
|
||||
while (!feof(instr))
|
||||
{
|
||||
if (fgets(__tmp_string, sizeof (__tmp_string), instr) == NULL)
|
||||
break;
|
||||
if (__tmp_string[strlen(__tmp_string)-1] == '\n')
|
||||
__tmp_string[strlen(__tmp_string)-1] = '\0';
|
||||
add_line(__tmp_string);
|
||||
}
|
||||
fclose(instr);
|
||||
}
|
||||
|
||||
int TBrowsefile_field::find_link(const char* descr)
|
||||
{
|
||||
for (int i = 0; i < _links.items(); i++)
|
||||
{
|
||||
TToken_string& tt = (TToken_string&)_links[i];
|
||||
const TFixed_string d(tt.get(0));
|
||||
if (d == descr)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int TBrowsefile_field::enable_link(const char *descr, char fg, char bg)
|
||||
{
|
||||
int lnk = find_link(descr);
|
||||
if (lnk < 0)
|
||||
{
|
||||
TToken_string *tt = new TToken_string(30);
|
||||
char b[2] = { '\0', '\0' };
|
||||
tt->add(descr);
|
||||
b[0] = fg;
|
||||
tt->add(b);
|
||||
b[0] = bg;
|
||||
tt->add(b);
|
||||
lnk = _links.add(tt);
|
||||
}
|
||||
|
||||
return lnk;
|
||||
}
|
||||
|
||||
|
||||
void TBrowsefile_field::disable_link(char fg, char bg)
|
||||
{
|
||||
for (int i = 0; i < _links.items (); i++)
|
||||
{
|
||||
TToken_string & t = (TToken_string&)_links[i];
|
||||
const char f = *(t.get(1));
|
||||
const char b = *(t.get());
|
||||
if (f == fg && b == bg)
|
||||
{
|
||||
_links.remove(i, TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TBrowsefile_field::set_background(const char* bg)
|
||||
{
|
||||
main_app().printer().parse_background(bg,_background);
|
||||
}
|
||||
|
||||
void TBrowsefile_field::add_line(const char* l)
|
||||
{
|
||||
_viswin->add_line(l);
|
||||
}
|
||||
|
||||
void TBrowsefile_field::close()
|
||||
{
|
||||
_viswin->close_print();
|
||||
}
|
||||
|
||||
void TBrowsefile_field::goto_pos(long r, long c)
|
||||
{
|
||||
}
|
||||
|
||||
void TBrowsefile_field::goto_top()
|
||||
{
|
||||
dispatch_e_char(_viswin->win(), K_END);
|
||||
}
|
||||
|
||||
void TBrowsefile_field::goto_end()
|
||||
{
|
||||
dispatch_e_char(_viswin->win(), K_HOME);
|
||||
}
|
||||
|
@ -18,8 +18,12 @@
|
||||
#include <text.h>
|
||||
#endif
|
||||
|
||||
class TBrowsefile_field;
|
||||
|
||||
class TViswin : public TScroll_window
|
||||
{
|
||||
{
|
||||
friend class TBrowsefile_field;
|
||||
|
||||
enum { MAXBUT = 4, MAXLEN = 256, BUFFERSIZE = 256, MAXPIC=4};
|
||||
enum scroll { none, up, down, left, right };
|
||||
|
||||
@ -77,6 +81,11 @@ class TViswin : public TScroll_window
|
||||
TArray* _bg;
|
||||
bool _isbackground;
|
||||
bool _frozen;
|
||||
bool _toplevel;
|
||||
bool _rulers;
|
||||
|
||||
// viene istanziato soltanto se e' usata come controllo BROWSEFILE
|
||||
TBrowsefile_field* _brwfld;
|
||||
|
||||
protected:
|
||||
|
||||
@ -132,13 +141,18 @@ public:
|
||||
|
||||
void add_line(const char* l);
|
||||
|
||||
TViswin (const char* fname = NULL,
|
||||
const char* title = NULL,
|
||||
bool editbutton = TRUE,
|
||||
bool printbutton = TRUE,
|
||||
bool linkbutton = TRUE,
|
||||
int height = 0,
|
||||
WINDOW parent = NULL_WIN);
|
||||
TViswin (const char* fname = NULL,
|
||||
const char* title = NULL,
|
||||
bool editbutton = TRUE,
|
||||
bool printbutton = TRUE,
|
||||
bool linkbutton = TRUE,
|
||||
int x = -1,
|
||||
int y = -1,
|
||||
int height = 0,
|
||||
int width = 0,
|
||||
bool rulers = TRUE,
|
||||
WINDOW parent = NULL_WIN,
|
||||
TBrowsefile_field* = NULL);
|
||||
|
||||
virtual ~TViswin ();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user