Aggiunta ricerca a viswin con F7 (cerca) e F8 (cerca il prossimo)

git-svn-id: svn://10.65.10.50/trunk@807 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-12-30 10:11:18 +00:00
parent 1877ed7dee
commit 4fbe28d0b7
5 changed files with 715 additions and 697 deletions

View File

@ -1,23 +1,23 @@
/* Maschera ricerca per viswin */ /* Maschera ricerca per viswin */
#include "bagn005.h" #include "bagn005.h"
PAGE "Cerca testo" -1 -1 55 11 PAGE "Cerca testo" -1 -1 60 5
STRING F_STRING 45 70 STRING F_STRING 70 45
BEGIN BEGIN
PROMPT 1 1 "Ricerca: " PROMPT 1 1 "Ricerca "
END END
LIST F_DIRECT LIST F_DIRECT 8
BEGIN BEGIN
PROMPT 1 2 "Direzione " PROMPT 1 2 "Direzione "
ITEM "D|Avanti" ITEM "D|Avanti"
ITEM "U|Indietro" ITEM "U|Indietro"
END END
BOOLEAN F_CASE BOOLEAN F_CASE
BEGIN BEGIN
PROMPT 30 2 "Maiuscolo/Minuscolo" PROMPT 36 2 "Maiuscolo/Minuscolo"
END END
BUTTON DLG_OK 10 2 BUTTON DLG_OK 10 2

View File

@ -1,115 +1,115 @@
#ifndef __FORM_H #ifndef __FORM_H
#define __FORM_H #define __FORM_H
#ifndef __PRINTER_H #ifndef __PRINTER_H
#include <printer.h> #include <printer.h>
#endif #endif
#ifndef __SCANNER_H #ifndef __SCANNER_H
#include <scanner.h> #include <scanner.h>
#endif #endif
#ifndef __MASK_H #ifndef __MASK_H
class TMask; class TMask;
#endif #endif
#ifndef __RELATION_H #ifndef __RELATION_H
class TRelation; class TRelation;
class TCursor; class TCursor;
#endif #endif
enum pagetype { odd_page, even_page, first_page, last_page }; enum pagetype { odd_page, even_page, first_page, last_page };
class TForm; class TForm;
class TForm_item; class TForm_item;
class TPrint_section : public TArray class TPrint_section : public TArray
{ {
static TMask* _msk; static TMask* _msk;
word _height; // Altezza della sezione word _height; // Altezza della sezione
TForm* _form; // Form cui appartiene alla sezione TForm* _form; // Form cui appartiene alla sezione
TArray _item; // Lista dei campi da stampare TArray _item; // Lista dei campi da stampare
const TPrint_section& copy(const TPrint_section& ps); const TPrint_section& copy(const TPrint_section& ps);
protected: protected:
virtual void print_on(ostream& out) const; virtual void print_on(ostream& out) const;
TForm_item* parse_item(const TString& key); TForm_item* parse_item(const TString& key);
TForm_item* parse_item(TScanner& scanner); TForm_item* parse_item(TScanner& scanner);
public: public:
TPrintrow& row(int num); TPrintrow& row(int num);
TForm* form() const { return _form; } TForm* form() const { return _form; }
TForm_item& field(int n) const { return (TForm_item&)_item[n]; } TForm_item& field(int n) const { return (TForm_item&)_item[n]; }
word fields() const { return _item.items(); } word fields() const { return _item.items(); }
word height() const { return _height; } word height() const { return _height; }
virtual bool ok() const { return height() > 0 || fields() > 0; } virtual bool ok() const { return height() > 0 || fields() > 0; }
void reset(); void reset();
bool update(); bool update();
bool parse(TScanner& scanner); bool parse(TScanner& scanner);
bool edit(const char* title); bool edit(const char* title);
const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); } const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); }
TPrint_section(TForm* parent); TPrint_section(TForm* parent);
TPrint_section(const TPrint_section& ps) { copy(ps); } TPrint_section(const TPrint_section& ps) { copy(ps); }
virtual ~TPrint_section(); virtual ~TPrint_section();
}; };
class TForm : public TObject class TForm : public TObject
{ {
friend class TForm_editor; friend class TForm_editor;
TFilename _name; // Profile name TFilename _name; // Profile name
TRelation* _relation; // Can be NULL TRelation* _relation; // Can be NULL
TCursor* _cursor; // Can be NULL TCursor* _cursor; // Can be NULL
TArray _head; // Headers TArray _head; // Headers
TArray _body; // Bodies TArray _body; // Bodies
TArray _foot; // Footers TArray _foot; // Footers
bool _lastpage; // I am about to print the last page bool _lastpage; // I am about to print the last page
TPrint_section* exist(char s, pagetype t, bool create = FALSE); // Can be NULL TPrint_section* exist(char s, pagetype t, bool create = FALSE); // Can be NULL
static void header_handler(TPrinter& p); static void header_handler(TPrinter& p);
static void footer_handler(TPrinter& p); static void footer_handler(TPrinter& p);
protected: protected:
// H = Header, B = Body, F = Footer, R = Relation // H = Header, B = Body, F = Footer, R = Relation
TPrint_section& section(char s = 'B', word page = 1); TPrint_section& section(char s = 'B', word page = 1);
word height(); // Height of first page word height(); // Height of first page
void print_section(ostream& out, char s) const; void print_section(ostream& out, char s) const;
virtual void print_on(ostream& out) const; virtual void print_on(ostream& out) const;
bool edit_relation(); bool edit_relation();
bool parse_use(TScanner&); bool parse_use(TScanner&);
bool parse_join(TScanner&); bool parse_join(TScanner&);
word page(const TPrinter& p) const; word page(const TPrinter& p) const;
virtual long records() const; virtual long records() const;
virtual word set_header(word p, bool u); virtual word set_header(word p, bool u);
virtual word set_body(word p, bool u); virtual word set_body(word p, bool u);
virtual word set_footer(word p, bool u); virtual word set_footer(word p, bool u);
public: public:
bool print(long from = 0L, long to = -1L); bool print(long from = 0L, long to = -1L);
const TFilename& name() const { return _name; } const TFilename& name() const { return _name; }
TRelation* relation() const { return _relation; } TRelation* relation() const { return _relation; }
TCursor* cursor() const { return _cursor; } TCursor* cursor() const { return _cursor; }
TForm(const char* form); TForm(const char* form);
virtual ~TForm(); virtual ~TForm();
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1479,6 +1479,12 @@ bool TViswin::on_key (KEY key)
switch (key) switch (key)
{ {
case K_F7:
find();
break;
case K_F8:
find_next();
break;
case CTRL_E: case CTRL_E:
if (_isedit) if (_isedit)
{ {
@ -1882,7 +1888,7 @@ void TViswin::goto_top()
goto_pos(0l,0l);; goto_pos(0l,0l);;
} }
void TViswin::goto_pos(long r, long c) void TViswin::goto_pos(long r, long c, bool moveorigin)
{ {
if (r >= _txt.lines() || c >= 256) if (r >= _txt.lines() || c >= 256)
return; return;
@ -1891,7 +1897,9 @@ void TViswin::goto_pos(long r, long c)
if (_isselection) erase_selection(); if (_isselection) erase_selection();
_point.x = c; _point.x = c;
_point.y = r; _point.y = r;
update_thumb (c,r); if (!moveorigin)
c = (c > (origin().x + _textcolumns)) ? c - origin().x : 0l;
update_thumb(c,r);
check_link(&_point); check_link(&_point);
if (_isselection) display_selection(); if (_isselection) display_selection();
display_point(); display_point();
@ -1943,7 +1951,7 @@ void TViswin::find()
} }
else else
{ {
goto_pos(l,(long)x); goto_pos(l, (long)x, FALSE);
_last_found.x = (long)x; _last_found.x = (long)x;
_last_found.y = l; _last_found.y = l;
} }
@ -1958,11 +1966,11 @@ void TViswin::find_next()
beep(); beep();
else else
{ {
long l = search(_txt_to_find, x, _point.y, _down_dir); long l = search(_txt_to_find, x, _point.y+(_down_dir ? 1l : -1l), _down_dir);
if (l == -1) if (l == -1)
beep(); beep();
else else
goto_pos(l,x); goto_pos(l,x,FALSE);
} }
} }
@ -2136,13 +2144,18 @@ void TBrowsefile_field::parse_head(TScanner& scanner)
// Certified 100% // Certified 100%
void TBrowsefile_field::create(WINDOW parent) void TBrowsefile_field::create(WINDOW parent)
{ {
CURSOR oldcur = get_cursor(TASK_WIN);
set_cursor(TASK_WIN,CURSOR_WAIT);
const TMask& m = mask(); const TMask& m = mask();
_viswin = new TViswin(_prompt, _prompt, FALSE, FALSE, FALSE, _x, _y, _viswin = new TViswin(_prompt, _prompt, FALSE, FALSE, FALSE, _x, _y,
_size, _width, _flags.rightjust ? TRUE : FALSE, parent, this); _size, _width, _flags.rightjust ? TRUE : FALSE, parent, this);
_win = _viswin->win(); _win = _viswin->win();
enable_window(_win, enabled()); enable_window(_win, enabled());
show_window(_win, shown()); show_window(_win, shown());
set_cursor(TASK_WIN, oldcur);
} }
@ -2153,6 +2166,9 @@ long TBrowsefile_field::set_text(const char* file, const char* line)
FILE* instr = fopen(file,"r"); FILE* instr = fopen(file,"r");
if (instr == NULL) if (instr == NULL)
fatal_box("File non trovato: %s", file); fatal_box("File non trovato: %s", file);
CURSOR oldcur = get_cursor(TASK_WIN);
set_cursor(TASK_WIN,CURSOR_WAIT);
TString256 tmpp; TString256 tmpp;
long ret = -1l; long ret = -1l;
@ -2175,7 +2191,9 @@ long TBrowsefile_field::set_text(const char* file, const char* line)
} }
fclose(instr); fclose(instr);
_viswin->close_print(); _viswin->close_print();
set_cursor(TASK_WIN, oldcur);
return ret; return ret;
} }
@ -2243,7 +2261,7 @@ void TBrowsefile_field::close()
void TBrowsefile_field::goto_pos(long r, long c) void TBrowsefile_field::goto_pos(long r, long c)
{ {
_viswin->goto_pos(r,c); _viswin->goto_pos(r,c,TRUE);
} }
void TBrowsefile_field::goto_top() void TBrowsefile_field::goto_top()

View File

@ -147,7 +147,7 @@ public:
void goto_end(); void goto_end();
void goto_top(); void goto_top();
void goto_pos(long,long); void goto_pos(long r, long c, bool moveorigin = TRUE);
void refresh(); void refresh();
void add_line(const char* l); void add_line(const char* l);