viswin.cpp Velocizzati calcoli necessari per ridisegno

viswin.h     Resi virtuali alcuni metodi di disegno
window.cpp   Corretto uso del membro _pixmap per disegnare a pixel
             invece che a caratteri
xvtility.cpp Aggiunta riga vuota


git-svn-id: svn://10.65.10.50/trunk@6046 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-01-28 09:28:26 +00:00
parent 1df45b8904
commit 3fc8354997
4 changed files with 80 additions and 53 deletions

View File

@ -1081,29 +1081,24 @@ void TViswin::paint_point (
// @flag TRUE | Cancella il cursore precedente // @flag TRUE | Cancella il cursore precedente
// @flag FALSE | Mantiene il cursore precedente // @flag FALSE | Mantiene il cursore precedente
{ {
autoscroll (FALSE);
static bool wasbar; static bool wasbar;
autoscroll (FALSE);
const int x = int(_point.x - origin().x + X_OFFSET);
const int y = int(_point.y - origin().y + Y_OFFSET);
if (_isbar) if (_isbar)
{ {
invert_bar (X_OFFSET, (int)(_point.y - origin().y + (long)Y_OFFSET), invert_bar (X_OFFSET, y, (int)columns(), y+1);
(int)columns(), (int) (_point.y - origin().y + (long)Y_OFFSET + 1l)); invert_bar (x, Y_OFFSET, x+1, (int)(rows() - BUTTONROW_SIZE));
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 else
{ {
invert_bar ((int) (_point.x - origin ().x + (long)X_OFFSET), invert_bar (x, y, x+1, y+1);
(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) if (_rulers)
{ {
invert_bar (0, (int) (_point.y - origin ().y + (long)Y_OFFSET), (X_OFFSET -1), invert_bar (0, y, X_OFFSET-1, y+1);
(int) (_point.y - origin ().y + (long)Y_OFFSET + 1l)); invert_bar (x, 0, x+1, 1);
invert_bar ((int) (_point.x - origin ().x + (long)X_OFFSET), 0,
(int) (_point.x - origin ().x + (long)X_OFFSET + 1l), 1);
} }
} }
autoscroll (TRUE); autoscroll (TRUE);
@ -1130,7 +1125,7 @@ void TViswin::paint_header ()
} }
autoscroll (FALSE); autoscroll (FALSE);
set_color (COLOR_WHITE, BACKGROUND); 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); autoscroll (TRUE);
} }
@ -1212,12 +1207,12 @@ void TViswin::update ()
else else
if (_showbuts) ((TImage&)_modules[4]).draw(win()); if (_showbuts) ((TImage&)_modules[4]).draw(win());
autoscroll (TRUE); autoscroll (TRUE);
paint_header (); paint_screen();
paint_screen (); paint_header();
if (_isselection) if (_isselection)
display_selection (); display_selection();
} }
display_point (); display_point();
check_link(&_point); check_link(&_point);
autoscroll (TRUE); autoscroll (TRUE);
_need_update = TRUE; _need_update = TRUE;
@ -1284,10 +1279,11 @@ void TViswin::on_button(short dlg)
void TViswin::handler (WINDOW win, EVENT * ep) void TViswin::handler (WINDOW win, EVENT * ep)
{ {
static bool ignore = FALSE;
int kdiff_x, kdiff_y; int kdiff_x, kdiff_y;
PNT newcross; PNT newcross;
TPoint p; TPoint p;
static bool ignore = FALSE;
bool tlnk = FALSE; bool tlnk = FALSE;
int kdiff; int kdiff;
long new_origin; long new_origin;
@ -1396,7 +1392,6 @@ void TViswin::handler (WINDOW win, EVENT * ep)
xvt_win_trap_pointer (win); xvt_win_trap_pointer (win);
if (ep->v.mouse.button == 0) // left button: text selection if (ep->v.mouse.button == 0) // left button: text selection
{ {
if (need_paint_sel (FALSE)) if (need_paint_sel (FALSE))
{ {
@ -1433,7 +1428,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
{ {
p = ep->v.mouse.where; p = ep->v.mouse.where;
if (_isopen && (p.x >= 4 && p.x) <= X_OFFSET && if (_isopen && _toplevel && (p.x >= 4 && p.x) <= X_OFFSET &&
(p.y >= (int)rows () - BUTTONROW_SIZE && p.y <= (int)rows() - Y_OFFSET)) (p.y >= (int)rows () - BUTTONROW_SIZE && p.y <= (int)rows() - Y_OFFSET))
{ {
abort_print (); abort_print ();
@ -1491,7 +1486,7 @@ void TViswin::handler (WINDOW win, EVENT * ep)
if (_sel_end.x > 255) if (_sel_end.x > 255)
_sel_end.x = 255; _sel_end.x = 255;
_point = _sel_end; _point = _sel_end;
_isselection = TRUE; _isselection = _selecting;
check_link (&_point); check_link (&_point);
display_point (); display_point ();
} }
@ -2259,6 +2254,15 @@ void TViswin::add_line (const char *l)
} }
} }
void TViswin::destroy_lines()
{
if (_isopen && !_frozen)
{
_txt.destroy();
force_update();
}
}
void TViswin::close_print () void TViswin::close_print ()
{ {
_isopen = FALSE; _isopen = FALSE;
@ -2469,7 +2473,7 @@ TViswin::TViswin(const char *fname,
_down_dir(TRUE), _showbuts(FALSE), _case_sensitive(FALSE), _down_dir(TRUE), _showbuts(FALSE), _case_sensitive(FALSE),
_menu_present(FALSE), _regexp(FALSE) _menu_present(FALSE), _regexp(FALSE)
{ {
begin_wait(); TWait_cursor hourglass;
if (title == NULL) if (title == NULL)
title = (fname ? fname : "Anteprima di stampa"); title = (fname ? fname : "Anteprima di stampa");
@ -2592,8 +2596,6 @@ TViswin::TViswin(const char *fname,
} }
_hotspots = &(_txt.hotspots()); _hotspots = &(_txt.hotspots());
end_wait();
} }
TViswin ::~TViswin () TViswin ::~TViswin ()
@ -2629,16 +2631,23 @@ void TBrowsefile_field::parse_head(TScanner& scanner)
_ctl_data._size = scanner.integer(); _ctl_data._size = scanner.integer();
} }
void TBrowsefile_field::set_vis_win(TViswin* viswin)
{
if (_viswin != NULL)
delete _viswin;
_viswin = viswin;
}
// Certified 100% // Certified 100%
void TBrowsefile_field::create(WINDOW parent) void TBrowsefile_field::create(WINDOW parent)
{ {
const TMask& m = mask(); if (_viswin == NULL)
_viswin = new TViswin(_ctl_data._prompt, _ctl_data._prompt, FALSE, FALSE, FALSE, _viswin = new TViswin(_ctl_data._prompt, _ctl_data._prompt, FALSE, FALSE, FALSE,
_ctl_data._x, _ctl_data._y, _ctl_data._size, _ctl_data._width, _ctl_data._x, _ctl_data._y, _ctl_data._size, _ctl_data._width,
_flags.rightjust ? TRUE : FALSE, parent, this); _flags.rightjust ? TRUE : FALSE, parent, this);
WINDOW win = _viswin->win();
_dlg = _ctl_data._dlg; _dlg = _ctl_data._dlg;
_parent = parent; _parent = parent;
WINDOW win = _viswin->win();
xvt_vobj_set_enabled(win, enabled()); xvt_vobj_set_enabled(win, enabled());
xvt_vobj_set_visible(win, shown()); xvt_vobj_set_visible(win, shown());
} }
@ -2652,7 +2661,7 @@ long TBrowsefile_field::set_text(const char* file, const char* line)
if (instr == NULL) if (instr == NULL)
fatal_box("File non trovato: %s", file); fatal_box("File non trovato: %s", file);
begin_wait(); TWait_cursor hourglass;
TString256 tmpp; TString256 tmpp;
long ret = -1l; long ret = -1l;
@ -2678,7 +2687,6 @@ long TBrowsefile_field::set_text(const char* file, const char* line)
_viswin->close_print(); _viswin->close_print();
end_wait();
return ret; return ret;
} }

View File

@ -201,9 +201,9 @@ protected:
// @cmember Disegna il cursore in xor nello stile del momento // @cmember Disegna il cursore in xor nello stile del momento
void paint_point(bool erase = FALSE); void paint_point(bool erase = FALSE);
// @cmember Disegna la riga <p r>-esima (in coordinate testo) // @cmember Disegna la riga <p r>-esima (in coordinate testo)
void paint_row(long r); virtual void paint_row(long r);
// @cmember Disegna una colonna // @cmember Disegna una colonna
void paint_column(long r, bool end); virtual void paint_column(long c, bool end);
// @cmember Disegna in xor la selezione corrente a meno che non sia gia' disegnata // @cmember Disegna in xor la selezione corrente a meno che non sia gia' disegnata
void paint_selection(); void paint_selection();
// @cmember Controlla l'immagine di 'busy'; xor serve solo per UNIX, dove si // @cmember Controlla l'immagine di 'busy'; xor serve solo per UNIX, dove si
@ -237,6 +237,8 @@ protected:
void display_point(); void display_point();
// @cmember Interfaccia per paint_point (se point): cancella se c'e' // @cmember Interfaccia per paint_point (se point): cancella se c'e'
void erase_point(); void erase_point();
// @cmember Ritorna la posizione attuale del cursore
const TPoint& get_point() const { return _point; }
// @cmember Controlla se la posizione cursore <p where> cade su un // @cmember Controlla se la posizione cursore <p where> cade su un
// link ipertestuale e si comporta di conseguenza // link ipertestuale e si comporta di conseguenza
@ -275,6 +277,8 @@ protected:
// @cmember Abilita/Disabilita una voce di menu' // @cmember Abilita/Disabilita una voce di menu'
void enable_menu_item(MENU_TAG item, bool on = TRUE); void enable_menu_item(MENU_TAG item, bool on = TRUE);
TBrowsefile_field* browsefile_field() const { return _brwfld; }
// @access Public Member // @access Public Member
public: public:
// @cmember Permette di gestire i collegamenti ipertestuali. Occorre passare il testo completo // @cmember Permette di gestire i collegamenti ipertestuali. Occorre passare il testo completo
@ -314,8 +318,10 @@ public:
// @cmember Indica se mostrare o no i bottoni della finestra di anteprima // @cmember Indica se mostrare o no i bottoni della finestra di anteprima
void show_buttons(bool on = TRUE); void show_buttons(bool on = TRUE);
// @cmember Stampa nella finestra la riga <p l>-esima // @cmember Aggiunge la riga di testo <p l> in fondo al file
void add_line(const char* l); void add_line(const char* l);
// @cmember Elimina tutte le righe di testo
void destroy_lines();
// @cmember Funzione di ricerca non interattiva // @cmember Funzione di ricerca non interattiva
long search (const char* txt, int& pos, long from = 0, bool down = TRUE, bool casesens = FALSE, bool regx = FALSE); long search (const char* txt, int& pos, long from = 0, bool down = TRUE, bool casesens = FALSE, bool regx = FALSE);

View File

@ -647,9 +647,11 @@ void TWindow::close()
void TWindow::close_modal() void TWindow::close_modal()
{ {
CHECK(is_modal(), "Can't modal-close a non-modal window");
WinManager.unreg(this); WinManager.unreg(this);
close(); close();
_open = FALSE; _open = FALSE;
set_modal(FALSE);
} }
bool TWindow::stop_run(KEY key) bool TWindow::stop_run(KEY key)
@ -942,7 +944,7 @@ void TWindow::frame(
r.bottom = t.v; r.right = t.h; r.bottom = t.v; r.right = t.h;
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (flag & 2) if (!_pixmap && (flag & 2))
{ {
r.left += CHARX>>1; r.top += CHARY>>1; r.left += CHARX>>1; r.top += CHARY>>1;
r.right-= CHARX>>1; r.bottom -= CHARY>>1; r.right-= CHARX>>1; r.bottom -= CHARY>>1;
@ -1052,10 +1054,13 @@ void TWindow::line(short x0, short y0, short x1, short y1)
PNT t = log2dev(x1,y1); PNT t = log2dev(x1,y1);
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
if (!_pixmap)
{
if (f.h == 0) f.h = -CHARX; else f.h += CHARX>>1; if (f.h == 0) f.h = -CHARX; else f.h += CHARX>>1;
if (f.v == 0) f.v = -CHARY; else f.v += CHARY>>1; if (f.v == 0) f.v = -CHARY; else f.v += CHARY>>1;
if (t.h == 0) t.h = -CHARX; else t.h += CHARX>>1; if (t.h == 0) t.h = -CHARX; else t.h += CHARX>>1;
if (t.v == 0) t.v = -CHARY; else t.v += CHARY>>1; if (t.v == 0) t.v = -CHARY; else t.v += CHARY>>1;
}
#endif #endif
xvt_dwin_draw_set_pos(win(), f); xvt_dwin_draw_set_pos(win(), f);
@ -1182,14 +1187,21 @@ WINDOW TScroll_window::create(short x, short y, short dx, short dy,
PNT TScroll_window::log2dev(long x, long y) const PNT TScroll_window::log2dev(long x, long y) const
{ {
if (_autoscroll) if (_autoscroll)
{
if (_pixmap)
{
x -= _origin.x * CHARX;
y -= (_origin.y >> _shift) * CHARY;
}
else
{ {
x -= _origin.x; x -= _origin.x;
y -= _origin.y >> _shift; y -= _origin.y >> _shift;
} }
}
return TWindow::log2dev(x,y); return TWindow::log2dev(x,y);
} }
void TScroll_window::set_scroll_max(long maxx, long maxy) void TScroll_window::set_scroll_max(long maxx, long maxy)
{ {
if (_has_hscroll && maxx >= 0) if (_has_hscroll && maxx >= 0)

View File

@ -79,6 +79,7 @@ static BOOLEAN event_hook(HWND hwnd,
if ((lparam & (1<<29)) == 0) // Il tasto alt non e' premuto if ((lparam & (1<<29)) == 0) // Il tasto alt non e' premuto
{ {
KEY k = K_F1; KEY k = K_F1;
int sc = GetAsyncKeyState(VK_CONTROL); // Stato del tasto control int sc = GetAsyncKeyState(VK_CONTROL); // Stato del tasto control
if (sc & 0x8000) k += K_CTRL; if (sc & 0x8000) k += K_CTRL;