Aggiustato text per replace etc; aggiunto bottone DLG_RECALC con icona
git-svn-id: svn://10.65.10.50/trunk@836 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
42279d33b5
commit
f24bcf1bab
@ -657,6 +657,9 @@ TPush_button::TPush_button(short left, short top, short right, short bottom,
|
|||||||
case DLG_SETPRINT:
|
case DLG_SETPRINT:
|
||||||
capt = format("#%d", BMP_SETPRINT);
|
capt = format("#%d", BMP_SETPRINT);
|
||||||
break;
|
break;
|
||||||
|
case DLG_RECALC:
|
||||||
|
capt = format("#%d", BMP_RECALC);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ ACCEL MENU_FILE "f" ALT
|
|||||||
BMP_LINK bitmap DISCARDABLE f:\p.due\bmp\link.bmp
|
BMP_LINK bitmap DISCARDABLE f:\p.due\bmp\link.bmp
|
||||||
BMP_PRINT bitmap DISCARDABLE f:\p.due\bmp\print.bmp
|
BMP_PRINT bitmap DISCARDABLE f:\p.due\bmp\print.bmp
|
||||||
BMP_SETPRINT bitmap DISCARDABLE f:\p.due\bmp\setprint.bmp
|
BMP_SETPRINT bitmap DISCARDABLE f:\p.due\bmp\setprint.bmp
|
||||||
|
BMP_RECALC bitmap DISCARDABLE f:\p.due\bmp\recalc.bmp
|
||||||
|
|
||||||
$$$
|
$$$
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#define DLG_LINK 23 /* TAG del bottone Collega (applicazione) */
|
#define DLG_LINK 23 /* TAG del bottone Collega (applicazione) */
|
||||||
#define DLG_PRINT 24 /* TAG del bottone Stampa */
|
#define DLG_PRINT 24 /* TAG del bottone Stampa */
|
||||||
#define DLG_SETPRINT 25 /* TAG del bottone Imposta Stampa */
|
#define DLG_SETPRINT 25 /* TAG del bottone Imposta Stampa */
|
||||||
|
#define DLG_RECALC 26 /* TAG del bottone Ricalcola */
|
||||||
#define DLG_USER 100 /* TAG del primo controllo definito dall'utente */
|
#define DLG_USER 100 /* TAG del primo controllo definito dall'utente */
|
||||||
|
|
||||||
/* @M
|
/* @M
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <fstream.h>
|
#include <fstream.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <applicat.h>
|
||||||
|
|
||||||
static char mytmpstr[257];
|
static char mytmpstr[257];
|
||||||
|
|
||||||
@ -54,8 +55,77 @@ style TTextfile::_trans_style (char ch)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTextfile::_read_page (long n)
|
|
||||||
|
void TTextfile::_save_changes()
|
||||||
{
|
{
|
||||||
|
main_app().begin_wait();
|
||||||
|
// fa i dovuti replace anche sul disco (solo replace di linee esistenti)
|
||||||
|
long line = 0l;
|
||||||
|
|
||||||
|
fclose(_index);
|
||||||
|
remove(_indname);
|
||||||
|
|
||||||
|
TString oldfile(_filename);
|
||||||
|
_filename.temp("txtf");
|
||||||
|
|
||||||
|
FILE* newf = fopen(_filename, "a+");
|
||||||
|
|
||||||
|
if ((_index = fopen(_indname, "w+b")) == NULL || newf == NULL)
|
||||||
|
{
|
||||||
|
yesnofatal_box ("Impossibile aprire files temporanei");
|
||||||
|
freeze();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fseek(_instr, 0l, SEEK_SET);
|
||||||
|
|
||||||
|
while (!feof(_instr))
|
||||||
|
{
|
||||||
|
const long l = ftell(newf);
|
||||||
|
fwrite (&l, sizeof(long), 1, _index);
|
||||||
|
|
||||||
|
if (ferror(_index) || ferror(newf))
|
||||||
|
{
|
||||||
|
error_box ("Errore di scrittura file temporaneo: scrittura interrotta");
|
||||||
|
freeze ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fgets(mytmpstr, sizeof(mytmpstr), _instr) == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (line >= _page_start && line <= _page_end)
|
||||||
|
{
|
||||||
|
TString& lin = (TString&)(_page[(int)(line - _page_start)]);
|
||||||
|
if (_dirty_lines[line - _page_start])
|
||||||
|
{
|
||||||
|
strcpy(mytmpstr, lin);
|
||||||
|
strcat(mytmpstr, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(newf, "%s", mytmpstr);
|
||||||
|
line++;
|
||||||
|
}
|
||||||
|
|
||||||
|
fflush(_index);
|
||||||
|
fclose(_instr);
|
||||||
|
fclose(newf);
|
||||||
|
remove(oldfile);
|
||||||
|
rename(_filename, oldfile);
|
||||||
|
_filename = oldfile;
|
||||||
|
_instr = fopen(_filename, "a+");
|
||||||
|
|
||||||
|
main_app().end_wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TTextfile::_read_page (long n)
|
||||||
|
{
|
||||||
|
if (_dirty_lines.ones() > 0l)
|
||||||
|
{
|
||||||
|
_save_changes();
|
||||||
|
_dirty_lines.reset();
|
||||||
|
}
|
||||||
|
|
||||||
switch (_direction)
|
switch (_direction)
|
||||||
{
|
{
|
||||||
case down:
|
case down:
|
||||||
@ -266,6 +336,7 @@ int TTextfile::replace(long l, const char* txt, int pos, int len)
|
|||||||
if (cnt == pos)
|
if (cnt == pos)
|
||||||
{
|
{
|
||||||
line.overwrite(txt, cnt+skip);
|
line.overwrite(txt, cnt+skip);
|
||||||
|
_dirty_lines.set(l-_page_start);
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
else cnt++;
|
else cnt++;
|
||||||
@ -502,18 +573,18 @@ TTextfile ::TTextfile (const char *file, int pagesize, direction preferred):
|
|||||||
_page_size (pagesize), _page (pagesize), _filename (file), _lines (0l),
|
_page_size (pagesize), _page (pagesize), _filename (file), _lines (0l),
|
||||||
_index (NULL), _page_start (0l), _page_end (-1l), _direction (preferred),
|
_index (NULL), _page_start (0l), _page_end (-1l), _direction (preferred),
|
||||||
_dirty (FALSE), _istemp (FALSE), _item (0), _line (256), _cur_line (-1),
|
_dirty (FALSE), _istemp (FALSE), _item (0), _line (256), _cur_line (-1),
|
||||||
_hotspots (4), _accept (TRUE)
|
_hotspots (4), _accept (TRUE), _dirty_lines(pagesize)
|
||||||
{
|
{
|
||||||
// open file & build index
|
// open file & build index
|
||||||
if (file == NULL || *file <= ' ')
|
if (file == NULL || *file <= ' ')
|
||||||
{
|
{
|
||||||
_filename.temp ();
|
_filename.temp("txtf");
|
||||||
_istemp = TRUE;
|
_istemp = TRUE;
|
||||||
}
|
}
|
||||||
_isopen = TRUE;
|
_isopen = TRUE;
|
||||||
|
|
||||||
_instr = fopen (_filename, "a+");
|
_instr = fopen (_filename, "a+");
|
||||||
_indname.temp ();
|
_indname.temp("txti");
|
||||||
_index = fopen (_indname, "w+b");
|
_index = fopen (_indname, "w+b");
|
||||||
|
|
||||||
if (_index == NULL || _instr == NULL)
|
if (_index == NULL || _instr == NULL)
|
||||||
@ -528,8 +599,8 @@ _hotspots (4), _accept (TRUE)
|
|||||||
fwrite (&l, sizeof (long), 1, _index);
|
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");
|
error_box("Errore di scrittura file temporaneo: scrittura interrotta");
|
||||||
freeze ();
|
freeze();
|
||||||
}
|
}
|
||||||
if (fgets (mytmpstr, sizeof (mytmpstr), _instr) == NULL)
|
if (fgets (mytmpstr, sizeof (mytmpstr), _instr) == NULL)
|
||||||
break;
|
break;
|
||||||
|
@ -28,6 +28,7 @@ class TTextfile: public TObject
|
|||||||
enum {DEFAULT_PAGESIZE = 128};
|
enum {DEFAULT_PAGESIZE = 128};
|
||||||
|
|
||||||
TArray _page;
|
TArray _page;
|
||||||
|
TBit_array _dirty_lines;
|
||||||
long _page_start;
|
long _page_start;
|
||||||
long _page_end;
|
long _page_end;
|
||||||
long _page_size;
|
long _page_size;
|
||||||
@ -49,8 +50,10 @@ class TTextfile: public TObject
|
|||||||
bool _accept;
|
bool _accept;
|
||||||
|
|
||||||
void _read_page(long line);
|
void _read_page(long line);
|
||||||
bool _in_page(long l)
|
bool _in_page(long l)
|
||||||
{ return l >= _page_start && l < _page_end; }
|
{ return l >= _page_start && l < _page_end; }
|
||||||
|
void _save_changes();
|
||||||
|
|
||||||
// void _parse_style(long j);
|
// void _parse_style(long j);
|
||||||
style _trans_style(char c);
|
style _trans_style(char c);
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#define BMP_EDIT 116
|
#define BMP_EDIT 116
|
||||||
#define BMP_LINK 117
|
#define BMP_LINK 117
|
||||||
#define BMP_PRINT 118
|
#define BMP_PRINT 118
|
||||||
|
#define BMP_RECALC 119
|
||||||
#define BMP_FIRSTREC 121
|
#define BMP_FIRSTREC 121
|
||||||
#define BMP_PREVREC 122
|
#define BMP_PREVREC 122
|
||||||
#define BMP_STOPREC 123
|
#define BMP_STOPREC 123
|
||||||
@ -61,7 +62,6 @@
|
|||||||
#define BMP_NEWRECDN 155
|
#define BMP_NEWRECDN 155
|
||||||
#define BMP_QUITDN 164
|
#define BMP_QUITDN 164
|
||||||
#define BMP_SETPRINT 165
|
#define BMP_SETPRINT 165
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -1939,7 +1939,7 @@ void TViswin::add_line (const char *l)
|
|||||||
void TViswin::close_print ()
|
void TViswin::close_print ()
|
||||||
{
|
{
|
||||||
_isopen = FALSE;
|
_isopen = FALSE;
|
||||||
kill_timer (_wtimer);
|
if (_showbuts) kill_timer (_wtimer);
|
||||||
_need_update = TRUE;
|
_need_update = TRUE;
|
||||||
if (_toplevel)
|
if (_toplevel)
|
||||||
{
|
{
|
||||||
@ -2090,6 +2090,8 @@ TViswin::TViswin(const char *fname,
|
|||||||
_frozen (FALSE), _brwfld(brwfld), _link_button(-1),
|
_frozen (FALSE), _brwfld(brwfld), _link_button(-1),
|
||||||
_down_dir(TRUE), _showbuts(FALSE), _case_sensitive(FALSE)
|
_down_dir(TRUE), _showbuts(FALSE), _case_sensitive(FALSE)
|
||||||
{
|
{
|
||||||
|
main_app().begin_wait();
|
||||||
|
|
||||||
if (title == NULL)
|
if (title == NULL)
|
||||||
title = (fname ? fname : "Anteprima di stampa");
|
title = (fname ? fname : "Anteprima di stampa");
|
||||||
|
|
||||||
@ -2215,6 +2217,8 @@ TViswin::TViswin(const char *fname,
|
|||||||
_txt.set_hotspots(f, b);
|
_txt.set_hotspots(f, b);
|
||||||
}
|
}
|
||||||
_hotspots = &(_txt.hotspots());
|
_hotspots = &(_txt.hotspots());
|
||||||
|
|
||||||
|
main_app().end_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
TViswin ::~TViswin ()
|
TViswin ::~TViswin ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user