Gestione maschere limitate per pagine e campi browsefile

git-svn-id: svn://10.65.10.50/trunk@683 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-11-22 15:03:51 +00:00
parent 8bcb52a949
commit 6f39cd2f4e
9 changed files with 81 additions and 25 deletions

View File

@ -1,8 +1,8 @@
#ifndef __BROWFILE_H #ifndef __BROWFILE_H
#define __BROWFILE_H #define __BROWFILE_H
#ifndef __SCANNER_H #ifndef __MASK_H
#include <scanner.h> #include <mask.h>
#endif #endif
class TViswin; class TViswin;

View File

@ -26,8 +26,8 @@ bool TExternal_app::can_run() const
{ {
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
const TFixed_string p(_path); const TFixed_string p(_path);
const bool clifo = p.find("cg0") == 0 && p.find("-1") > 0; const bool clifo = p.find("cg0") == 0 && p.right(2) == "-1";
const int richieste = clifo ? 45 : 15; const int richieste = clifo ? 50 : 15;
const int libere = GetFreeSystemResources(GFSR_SYSTEMRESOURCES); const int libere = GetFreeSystemResources(GFSR_SYSTEMRESOURCES);
return libere >= richieste; return libere >= richieste;
#else #else

View File

@ -855,7 +855,7 @@ int TSystemisamfile::build(TRecnotype eox)
{ {
TFilename lf; TFilename lf;
lf.format("std/lf%04d.txt", num()); lf.format("%sstd/lf%04d.txt", __ptprf, num());
if (fexist(lf)) if (fexist(lf))
load(lf); load(lf);
} }

View File

@ -160,7 +160,7 @@ void TMask::handler(WINDOW win, EVENT* ep)
TWindow::handler(win, ep); TWindow::handler(win, ep);
} }
void TMask::init_mask(int mode) void TMask::init_mask()
{ {
_sheets = _pages = 0; // Azzera numero pagine e sheets _sheets = _pages = 0; // Azzera numero pagine e sheets
@ -170,7 +170,7 @@ void TMask::init_mask(int mode)
_focus = _first_focus = 0; // Nessuno ha il focus _focus = _first_focus = 0; // Nessuno ha il focus
_page = -1; // Nessuna pagina corrente _page = -1; // Nessuna pagina corrente
_handler = NULL; // Nessun handler utente _handler = NULL; // Nessun handler utente
_mode = mode; // Inizializza modo _mode = NO_MODE; // Inizializza modo
_exchange = 1.0; // Il cambio per la valuta e' la lira _exchange = 1.0; // Il cambio per la valuta e' la lira
memset(_pagewin, 0, sizeof(_pagewin)); memset(_pagewin, 0, sizeof(_pagewin));
@ -180,20 +180,22 @@ void TMask::init_mask(int mode)
TMask::TMask(const char* title, int pages, int cols, int rows, int xpos, TMask::TMask(const char* title, int pages, int cols, int rows, int xpos,
int ypos, int mode) int ypos)
{ {
init_mask(mode); init_mask();
for (_pages = 0; _pages < pages; _pages++) for (_pages = 0; _pages < pages; _pages++)
_pagewin[_pages] = create(xpos, ypos, cols, rows, title, WSF_CLOSE, WD_MODAL); _pagewin[_pages] = create(xpos, ypos, cols, rows, title, WSF_CLOSE, WD_MODAL);
set_win(NULL_WIN); set_win(NULL_WIN);
add_buttons(); add_buttons();
} }
void TMask::read_mask(const char* name, int mode, int num) void TMask::read_mask(const char* name, int num, int max)
{ {
clock1 = clock(); clock1 = clock();
if (max <= 0) max = MAX_PAGES;
_source_file = name; _source_file = name;
_source_file.ext(MASK_EXT); _source_file.ext(MASK_EXT);
TScanner scanner(_source_file); TScanner scanner(_source_file);
@ -205,7 +207,7 @@ void TMask::read_mask(const char* name, int mode, int num)
if (scanner.line() == "ENDMASK") break; if (scanner.line() == "ENDMASK") break;
} }
init_mask(mode); init_mask();
const CURSOR old = get_cursor(TASK_WIN); const CURSOR old = get_cursor(TASK_WIN);
set_cursor(TASK_WIN, CURSOR_WAIT); set_cursor(TASK_WIN, CURSOR_WAIT);
@ -216,6 +218,8 @@ void TMask::read_mask(const char* name, int mode, int num)
{ {
CHECKD(_pages < MAX_PAGES, "Maschera con troppe pagine: ", _pages); CHECKD(_pages < MAX_PAGES, "Maschera con troppe pagine: ", _pages);
_pagewin[_pages++] = read_page(scanner, FALSE); _pagewin[_pages++] = read_page(scanner, FALSE);
if (_pages >= max)
break;
} else } else
if (scanner.key() == "TO") if (scanner.key() == "TO")
{ {
@ -270,10 +274,10 @@ void TMask::add_buttons()
} }
TMask::TMask(const char* maskname, int mode, int num) TMask::TMask(const char* maskname, int num, int max)
{ {
if (maskname && *maskname) if (maskname && *maskname)
read_mask(maskname, mode, num); read_mask(maskname, num, max);
} }

View File

@ -66,9 +66,9 @@ protected:
virtual void start_run(); // called when the mask starts to run virtual void start_run(); // called when the mask starts to run
virtual TMask_field* parse_field(TScanner& scanner); virtual TMask_field* parse_field(TScanner& scanner);
void init_mask(int mode); void init_mask();
WINDOW read_page(TScanner& scanner, bool toolbar = FALSE); WINDOW read_page(TScanner& scanner, bool toolbar = FALSE);
void read_mask(const char* name, int mode, int num); void read_mask(const char* name, int num, int max);
void add_buttons(); void add_buttons();
int find_parent_page(const TMask_field&) const; int find_parent_page(const TMask_field&) const;
@ -85,11 +85,11 @@ protected:
public: public:
// @FPUB // @FPUB
// crea leggendo descrizione da file .msk // crea leggendo descrizione da file .msk
TMask(const char* name, int mode = NO_MODE, int num = 0); TMask(const char* name, int num = 0, int max = MAX_PAGES);
// crea mask vuota con parametri dati // crea mask vuota con parametri dati
TMask(const char* title, int pages, int cols, int rows, int xpos = -1, TMask(const char* title, int pages, int cols, int rows, int xpos = -1,
int ypos = -1, int mode = NO_MODE); int ypos = -1);
virtual ~TMask(); virtual ~TMask();

View File

@ -1 +1 @@
#define VERSION 1.15 #define VERSION 1.16

View File

@ -438,7 +438,7 @@ _dirty (FALSE), _istemp (FALSE), _item (0), _line (256), _cur_line (-1),
_hotspots (4), _accept (TRUE) _hotspots (4), _accept (TRUE)
{ {
// open file & build index // open file & build index
if (file == NULL) if (file == NULL || *file <= ' ')
{ {
_filename.temp (); _filename.temp ();
_istemp = TRUE; _istemp = TRUE;
@ -450,7 +450,7 @@ _hotspots (4), _accept (TRUE)
if (_index == NULL || _instr == NULL) if (_index == NULL || _instr == NULL)
{ {
error_box ("Impossibile aprire files temporanei"); yesnofatal_box ("Impossibile aprire files temporanei");
freeze (); freeze ();
} }
if (file != NULL) if (file != NULL)

View File

@ -7,6 +7,7 @@
#define ALIAS AL #define ALIAS AL
#define BEGIN BE #define BEGIN BE
#define BOOLEAN BO #define BOOLEAN BO
#define BROWSEFILE BR
#define BUTTON BU #define BUTTON BU
#define CHECKTYPE CH #define CHECKTYPE CH
#define COPY CO #define COPY CO

View File

@ -1,13 +1,14 @@
#include <xvtility.h> #include <browfile.h>
#include <colors.h> #include <colors.h>
#include <config.h> #include <config.h>
#include <defmask.h> #include <defmask.h>
#include <execp.h> #include <execp.h>
#include <mailbox.h> #include <mailbox.h>
#include <utility.h>
#include <printapp.h> #include <printapp.h>
#include <urldefid.h> #include <urldefid.h>
#include <utility.h>
#include <viswin.h> #include <viswin.h>
#include <xvtility.h>
#ifndef __PRINTER_H #ifndef __PRINTER_H
typedef void (*LINKHANDLER) (int, const char *); typedef void (*LINKHANDLER) (int, const char *);
@ -1823,7 +1824,7 @@ TViswin ::TViswin (const char *fname,
if (title == NULL) if (title == NULL)
title = (fname ? fname : "Anteprima di stampa"); title = (fname ? fname : "Anteprima di stampa");
_isopen = fname == NULL; _isopen = fname == NULL || *fname <= ' ';
if (_isopen) if (_isopen)
_filename = _txt.name (); _filename = _txt.name ();
@ -1931,3 +1932,53 @@ TViswin ::~TViswin ()
picture_free (_picture[i]); picture_free (_picture[i]);
#endif #endif
} }
///////////////////////////////////////////////////////////
// Campo di visualizzazione sulle maschere
///////////////////////////////////////////////////////////
// Certified 100%
TBrowsefile_field::TBrowsefile_field(TMask* m)
: TMask_field(m), _viswin(NULL)
{}
// Certified 100%
word TBrowsefile_field::class_id() const
{
return CLASS_BROWSEFILE_FIELD;
}
// Certified 100%
TBrowsefile_field::~TBrowsefile_field()
{
CHECK(_viswin, "Can't delete NULL sheet");
delete _viswin;
}
void TBrowsefile_field::parse_head(TScanner& scanner)
{
_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);
_win = _viswin->win();
enable_window(_win, enabled());
show_window(_win, showed());
}