1994-09-22 07:48:15 +00:00
|
|
|
/* This is really -*-c++-*- */
|
|
|
|
#ifndef __VISWIN_H
|
|
|
|
#define __VISWIN_H
|
|
|
|
|
|
|
|
#ifndef __WINDOW_H
|
|
|
|
#include <window.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __STRINGS_H
|
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __TEXTFILE_H
|
|
|
|
#include <text.h>
|
|
|
|
#endif
|
|
|
|
|
1994-12-01 14:49:44 +00:00
|
|
|
class TBrowsefile_field;
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
class TViswin : public TScroll_window
|
1994-12-01 14:49:44 +00:00
|
|
|
{
|
1995-10-13 09:23:08 +00:00
|
|
|
friend class TBrowsefile_field; // yes, perche' puo' anche essere un controllo di una mask
|
1994-12-01 14:49:44 +00:00
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
enum { MAXBUT = 4, MAXLEN = 256, BUFFERSIZE = 256, MAXPIC=4};
|
|
|
|
enum scroll { none, up, down, left, right };
|
|
|
|
|
|
|
|
TFilename _filename; // name of visfile
|
|
|
|
bool _islink; // "link" button present
|
|
|
|
bool _isedit; // "edit" button present
|
|
|
|
bool _isprint; // "print" button present
|
|
|
|
bool _iscross; // crossbars being drawn
|
|
|
|
bool _selecting; // selection in progress
|
|
|
|
bool _isselection; // selection active
|
|
|
|
bool _isbar; // X-bar drawn instead of cursor at point
|
|
|
|
bool _scrolling; // scrolling in progress
|
|
|
|
bool _need_update; // full update required
|
|
|
|
bool _istimer; // timer successivo attivo?
|
|
|
|
bool _isopen; // new lines may arrive
|
|
|
|
bool _selflag;
|
1995-10-13 09:23:08 +00:00
|
|
|
bool _sel_displayed; // selezione evidenziata
|
|
|
|
bool _link_displayed; // link ipertestuale evidenziato
|
|
|
|
bool _cross_displayed; // visualizzato cursore a croce
|
|
|
|
bool _point_displayed; // visualizzato cursore a carattere
|
1994-09-22 07:48:15 +00:00
|
|
|
long _timer; // timer per evitare autorepeat tasti
|
|
|
|
long _wtimer; // wait timer before close()
|
|
|
|
scroll _need_scroll; // scrolling required?
|
|
|
|
bool _wasneeded; // flag for smart painting
|
|
|
|
WINDOW _button[MAXBUT]; // button array
|
|
|
|
int _curbut; // button which currently has focus
|
|
|
|
int _buttons; // button count
|
1995-03-22 09:07:04 +00:00
|
|
|
|
1995-10-13 09:23:08 +00:00
|
|
|
WINDOW _link_button; // ID bottone "Collega"
|
|
|
|
WINDOW _print_button; // ID bottone "Stampa"
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
long _textrows; // righe di testo
|
|
|
|
long _textcolumns; // indovina indovinello
|
|
|
|
|
1994-12-23 11:57:45 +00:00
|
|
|
TTextfile _txt; // text being displayed
|
1994-09-22 07:48:15 +00:00
|
|
|
long _firstline; // 1rst text line being displayed
|
|
|
|
long _lastline; // last text line being displayed
|
1995-10-13 09:23:08 +00:00
|
|
|
|
|
|
|
// Ricerca testo
|
|
|
|
TString _txt_to_find; // text to find
|
|
|
|
TPoint _last_found; // position of last find
|
|
|
|
bool _down_dir; // search direction
|
|
|
|
bool _case_sensitive; // case sensitivity
|
1994-12-23 11:57:45 +00:00
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
int _formlen; // length of a page
|
|
|
|
|
|
|
|
TPoint _point; // current point position
|
|
|
|
PNT _cross; // current crossbar point
|
|
|
|
TPoint _sel_start; // start of selection (column, line of FILE)
|
|
|
|
TPoint _sel_end; // end of selection (ibidem)
|
|
|
|
|
|
|
|
TArray* _links; // admitted links
|
|
|
|
TArray* _hotspots; // hotspots
|
1995-04-13 07:45:30 +00:00
|
|
|
TArray* _bookmarks; // bookmarks
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
bool need_paint_sel(bool smart = TRUE);
|
1995-03-22 09:07:04 +00:00
|
|
|
|
|
|
|
TArray _modules; // Scrolling module icons
|
|
|
|
TArray _images; // pictures properly resized
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1995-10-13 09:23:08 +00:00
|
|
|
// link multiplo: se si' vengono passati all'handler tutti i link presenti sulla
|
|
|
|
// stessa riga anziche' solo il selezionato
|
|
|
|
bool _multiple; // si/no
|
|
|
|
TString80 _linktxt; // testo del link
|
|
|
|
int _linkID; // ID del link specificata
|
|
|
|
TToken_string _multiple_link; // tutti i link della riga
|
1994-12-01 14:49:44 +00:00
|
|
|
|
1995-10-13 09:23:08 +00:00
|
|
|
TArray* _bg; // internal structure to hold parsed background
|
|
|
|
bool _frozen; // non si tocca piu' nulla (files temp. cancellati), gestito internamente
|
|
|
|
bool _toplevel; // e' una finestra colle palle (se FALSE e' un campo di una mask)
|
|
|
|
bool _rulers; // righello mostrato
|
|
|
|
bool _showbuts; // bottoni mostrati
|
|
|
|
bool _inside_linkexec; // var di comodo per sapere se si sta attivando un link
|
|
|
|
bool _menu_present; // c'e' il menu specifico della viswin
|
|
|
|
|
|
|
|
// viene istanziato soltanto se e' usata come controllo BROWSEFILE in una mask
|
1994-12-01 14:49:44 +00:00
|
|
|
TBrowsefile_field* _brwfld;
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual bool on_key (KEY);
|
|
|
|
virtual void open();
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
int tabx(int x) const; // Convert charx to pixels
|
|
|
|
int taby(int y) const; // Convert chary to pixels
|
|
|
|
|
1995-10-13 09:23:08 +00:00
|
|
|
void shift_screen(scroll); // shift di 1 su, giu', dx, sin a seconda di scroll passato
|
|
|
|
void paint_screen(); // pittura lo schermo sulla porzione corrente di testo
|
|
|
|
void draw_crossbars(); // pittura il cursore a crossbar in xor
|
|
|
|
|
|
|
|
// pittura header (righello)
|
|
|
|
void paint_header();
|
|
|
|
// pittura il cursore (in xor) nello stile del momento, se
|
|
|
|
// necessario e erase == TRUE cancella quello di prima
|
|
|
|
void paint_point(bool erase = FALSE);
|
|
|
|
// pittura la riga r (in coordinate testo)
|
|
|
|
void paint_row(long r);
|
|
|
|
// pittura una sola colonna: se end == true e' l'ultima e implica uno scroll orizz. avvenuto
|
|
|
|
void paint_column(long r, bool end);
|
|
|
|
// pittura (in xor) la selezione corrente a meno che non sia gia' pitturata
|
|
|
|
void paint_selection();
|
|
|
|
// controlla l'immaginetta di 'busy'; xor serve solo per UNIX, dove si
|
|
|
|
// pittura una barretta che viene cancellata alla prossima paint
|
|
|
|
void paint_waitbar(bool xor = TRUE);
|
|
|
|
// pittura il background specificato a riga long e colonna int
|
|
|
|
void paint_background(long, int);
|
|
|
|
// chiama l'editor definito nei parametri con il testo corrente
|
|
|
|
bool call_editor();
|
|
|
|
// utility per sapere se il punto e' nel testo mostrato
|
|
|
|
bool in_text(const TPoint& p) const;
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
WINDOW add_button(short id, const char* caption);
|
|
|
|
void repos_buttons();
|
1995-10-13 09:23:08 +00:00
|
|
|
// assicura che la selezione rimanga nei limiti fisici del testo
|
|
|
|
void adjust_selection(TPoint& p1, TPoint& p2);
|
|
|
|
// interfaccia furba a paint_selection: display mostra se non c'e', erase cancella se c'e'
|
1994-09-22 07:48:15 +00:00
|
|
|
void display_selection();
|
|
|
|
void erase_selection();
|
1995-10-13 09:23:08 +00:00
|
|
|
// interfaccia furba a paint_point (se cross): display mostra se non c'e', erase cancella se c'e'
|
1994-09-22 07:48:15 +00:00
|
|
|
void display_crossbar();
|
|
|
|
void erase_crossbar();
|
1995-10-13 09:23:08 +00:00
|
|
|
// interfaccia furba a paint_point (se point): display mostra se non c'e', erase cancella se c'e'
|
1994-09-22 07:48:15 +00:00
|
|
|
void display_point();
|
1995-10-13 09:23:08 +00:00
|
|
|
void erase_point();
|
|
|
|
// controlla se la nuova posizione cursore (se NULL e' il curs. corrente) cade su un
|
|
|
|
// link ipertestuale e si comporta di conseguenza
|
|
|
|
bool check_link(TPoint* where = NULL);
|
|
|
|
// sistema x1 e x2 in modo che il minore sia il primo, e controlla che y sia
|
|
|
|
// nel testo (box e' su una sola riga, usata solo per i link)
|
1994-09-22 07:48:15 +00:00
|
|
|
bool adjust_box(long& x1, long& x2, long y);
|
1995-10-13 09:23:08 +00:00
|
|
|
// display mostra il link ipertestuale se non c'e', erase cancella se c'e'
|
1994-09-22 07:48:15 +00:00
|
|
|
void paint_link(long, long, long);
|
1995-10-13 09:23:08 +00:00
|
|
|
void erase_link(long, long, long);
|
|
|
|
// mostra in xor sto cazzo di link ipertesticolare (usata da paint/erase link)
|
1994-09-22 07:48:15 +00:00
|
|
|
void display_link(long, long, long, const char*);
|
1995-10-13 09:23:08 +00:00
|
|
|
// usata internamente per bloccare l'aggiunta di nuove righe
|
|
|
|
void freeze() { _frozen = TRUE; }
|
|
|
|
// chiama l'handler del link se si preme collega o si batte spazio su un link
|
|
|
|
void exec_link();
|
|
|
|
// controlla la generazione del menu indice se ci sono bookmarks
|
1995-04-13 07:45:30 +00:00
|
|
|
void build_index_menu();
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1995-10-13 09:23:08 +00:00
|
|
|
protected:
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1995-10-13 09:23:08 +00:00
|
|
|
// chiamata quando si fa uno scroll impossibile da x,y
|
|
|
|
// fa beep e torna li'
|
|
|
|
void scroll_error(long x, long y);
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1995-10-13 09:23:08 +00:00
|
|
|
// son tutte figlie di mamma application
|
|
|
|
virtual void update();
|
|
|
|
virtual void handler(WINDOW win, EVENT* ep);
|
1995-01-03 16:44:27 +00:00
|
|
|
void check_menu_item(MENU_TAG item, bool on = TRUE);
|
|
|
|
void enable_menu_item(MENU_TAG item, bool on = TRUE);
|
|
|
|
|
1994-09-22 07:48:15 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
// gestione "collegamenti": vengono passati il testo completo,
|
|
|
|
// il punto di inizio selezione e quello di fine selezione; se
|
|
|
|
// non c'e' selezione non viene chiamata affatto (il bottone non fa nulla)
|
|
|
|
// Se serve, si faccia stop_run() qui dentro
|
|
|
|
virtual void process_link(TTextfile& txt, TPoint start, TPoint end) { }
|
1995-10-13 09:23:08 +00:00
|
|
|
// termina la stampa su video e crea il menu indice se c'e'
|
1994-09-22 07:48:15 +00:00
|
|
|
void close_print();
|
1995-10-13 09:23:08 +00:00
|
|
|
bool frozen() { return _frozen; }
|
|
|
|
// terminazione by user (ESC durante stampa)
|
1994-09-22 07:48:15 +00:00
|
|
|
void abort_print();
|
1995-07-12 15:59:19 +00:00
|
|
|
|
1995-01-03 16:44:27 +00:00
|
|
|
long lines() { return _txt.lines(); }
|
1995-07-12 15:59:19 +00:00
|
|
|
TTextfile& text() { return _txt; }
|
1994-09-22 07:48:15 +00:00
|
|
|
|
1995-10-13 09:23:08 +00:00
|
|
|
// bound to keys and menu actions
|
1994-12-16 10:24:34 +00:00
|
|
|
void goto_end();
|
|
|
|
void goto_top();
|
1994-12-30 10:11:18 +00:00
|
|
|
void goto_pos(long r, long c, bool moveorigin = TRUE);
|
1994-12-16 10:24:34 +00:00
|
|
|
void refresh();
|
1995-01-03 16:44:27 +00:00
|
|
|
void show_rulers (bool on = TRUE);
|
|
|
|
void show_buttons(bool on = TRUE);
|
|
|
|
|
1995-10-13 09:23:08 +00:00
|
|
|
// usata da chi la usa (es. printer) per stampare nella finestra
|
1994-12-16 10:24:34 +00:00
|
|
|
void add_line(const char* l);
|
|
|
|
|
1995-10-13 09:23:08 +00:00
|
|
|
// non-interactive search and replace
|
1995-01-03 16:44:27 +00:00
|
|
|
long search (const char* txt, int& pos, long from = 0,
|
|
|
|
bool down = TRUE, bool casesens = FALSE);
|
1994-12-16 10:24:34 +00:00
|
|
|
int replace(long line, const char* txt, int pos = 0, int len = -1);
|
1994-12-23 11:57:45 +00:00
|
|
|
|
1995-10-13 09:23:08 +00:00
|
|
|
// interactive search (con maschera, bound to F7/F8)
|
1994-12-23 11:57:45 +00:00
|
|
|
void find();
|
|
|
|
void find_next();
|
1994-12-16 10:24:34 +00:00
|
|
|
|
1994-12-01 14:49:44 +00:00
|
|
|
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);
|
1994-09-22 07:48:15 +00:00
|
|
|
|
|
|
|
virtual ~TViswin ();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|