Corretti problemi di triplo click e aggiunda validazione dei nomi dei file

git-svn-id: svn://10.65.10.50/trunk@722 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-12-02 13:30:45 +00:00
parent 4265b6a9ac
commit 0a2e2fd909
20 changed files with 1182 additions and 1115 deletions

View File

@ -2,125 +2,129 @@
PAGE "IMPOSTAZIONE STAMPANTE" -1 -1 76 13
RADIOBUTTON MSK_1_TYPE 70
RADIOBUTTON MSK_1_TYPE 1 70
BEGIN
PROMPT 1 1 "Stampa su..."
HELP "Selezionare il tipo dove direzionare la stampa"
ITEM "0|Stampante"
MESSAGE HIDE,MSK_1_FILENAME|RESET,MSK_1_FILENAME|SHOW,MSK_1_PRINTERS
MESSAGE ENABLE,MSK_1_PRINTERS
MESSAGE ENABLE,MSK_1_CODES
MESSAGE ENABLE,MSK_1_SIZE
MESSAGE ENABLE,MSK_1_LINES
MESSAGE ENABLE,DLG_SETPRINT
ITEM "2|Visualizzazione"
MESSAGE HIDE,MSK_1_FILENAME|RESET,MSK_1_FILENAME
MESSAGE SHOW,MSK_1_PRINTERS|DISABLE,MSK_1_PRINTERS
MESSAGE DISABLE,MSK_1_CODES
MESSAGE DISABLE,MSK_1_SIZE
MESSAGE DISABLE,MSK_1_LINES
MESSAGE DISABLE,DLG_SETPRINT
ITEM "1|File su disco"
MESSAGE SHOW,MSK_1_FILENAME|HIDE,MSK_1_PRINTERS
MESSAGE ENABLE,MSK_1_CODES
MESSAGE DISABLE,MSK_1_SIZE
MESSAGE DISABLE,MSK_1_LINES
MESSAGE DISABLE,DLG_SETPRINT
FLAGS "Z"
PROMPT 1 1 "Stampa su..."
HELP "Selezionare il tipo dove direzionare la stampa"
ITEM "0|Stampante"
MESSAGE HIDE,MSK_1_FILENAME
MESSAGE SHOW,MSK_1_PRINTERS|ENABLE,MSK_1_PRINTERS
MESSAGE ENABLE,MSK_1_CODES
MESSAGE ENABLE,MSK_1_SIZE
MESSAGE ENABLE,MSK_1_LINES
MESSAGE ENABLE,DLG_SETPRINT
ITEM "2|Visualizzazione"
MESSAGE HIDE,MSK_1_FILENAME
MESSAGE SHOW,MSK_1_PRINTERS|DISABLE,MSK_1_PRINTERS
MESSAGE DISABLE,MSK_1_CODES
MESSAGE DISABLE,MSK_1_SIZE
MESSAGE DISABLE,MSK_1_LINES
MESSAGE DISABLE,DLG_SETPRINT
ITEM "1|File su disco"
MESSAGE SHOW,MSK_1_FILENAME
MESSAGE HIDE,MSK_1_PRINTERS
MESSAGE ENABLE,MSK_1_CODES
MESSAGE DISABLE,MSK_1_SIZE
MESSAGE DISABLE,MSK_1_LINES
MESSAGE DISABLE,DLG_SETPRINT
FLAGS "Z"
END
LIST MSK_1_PRINTERS 50
BEGIN
/* viene riempito a run-time con nomi letti da config */
PROMPT 4 5 "Stampante "
HELP "Selezionare il tipo di stampante desiderata"
/* viene riempito a run-time con nomi letti da config */
PROMPT 4 5 "Stampante "
HELP "Selezionare il tipo di stampante desiderata"
END
STRING MSK_1_FILENAME 52
BEGIN
PROMPT 4 5 "Nome file "
HELP "Nome del file su cui direzionare la stampa"
PROMPT 4 5 "Nome file "
CHECKTYPE REQUIRED
VALIDATE FILENAME_FUNC
FLAGS "A"
HELP "Nome del file in cui memorizzare la stampa"
WARNING "E' necessario specificare un nome di file"
END
LIST MSK_1_CODES 40
BEGIN
PROMPT 4 6 "Tipo stampa "
/* pure */
HELP "Modalita' nelle quale si desidera la stampa"
PROMPT 4 6 "Tipo stampa "
HELP "Modalita' nelle quale si desidera la stampa"
END
LIST MSK_1_SIZE 3
BEGIN
PROMPT 31 6 "Carattere "
ITEM "7|7"
ITEM "8|8"
ITEM "10|10"
ITEM "12|12"
ITEM "15|15"
ITEM "17|17"
HELP "Dimensioni del carattere di stampa"
PROMPT 31 6 "Carattere "
ITEM "7|7"
ITEM "8|8"
ITEM "10|10"
ITEM "12|12"
ITEM "15|15"
ITEM "17|17"
HELP "Dimensioni del carattere di stampa"
END
LIST MSK_1_LINES 3
BEGIN
PROMPT 52 6 "Linee/Inch "
ITEM "4|4"
ITEM "5|5"
ITEM "6|6"
ITEM "7|7"
ITEM "8|8"
ITEM "9|9"
ITEM "10|10"
HELP "Numero di linee per pollice"
PROMPT 52 6 "Linee/Inch "
ITEM "4|4"
ITEM "5|5"
ITEM "6|6"
ITEM "7|7"
ITEM "8|8"
ITEM "9|9"
ITEM "10|10"
HELP "Numero di linee per pollice"
END
LIST MSK_1_FONT 10
BEGIN
PROMPT 4 6 "Font "
HELP "Font di stampa su video o stampante"
ITEM "1|Courier"
FLAGS "D"
PROMPT 4 6 "Font "
HELP "Font di stampa su video o stampante"
ITEM "1|Courier"
FLAGS "D"
END
NUMBER MSK_1_NPAGES 3 0
BEGIN
PROMPT 54 8 "N.o copie "
HELP "Numero di copie da fare"
PROMPT 54 8 "N.o copie "
HELP "Numero di copie da fare"
END
BOOLEAN MSK_1_ISGRAPHICS
BEGIN
PROMPT 4 8 "Stampa elementi grafici"
HELP "Indicare se stampare elementi grafici (linee, box, logo) quando la stampante lo consente"
PROMPT 4 8 "Stampa elementi grafici"
HELP "Indicare se stampare elementi grafici (linee, box, logo) quando la stampante lo consente"
END
GROUPBOX DLG_NULL 74 4
BEGIN
PROMPT 1 9 ""
PROMPT 1 9 ""
END
BUTTON DLG_SETPRINT 9 2
BEGIN
PROMPT -14 -2 "~Imposta"
HELP "Chiama l'Impostazione Stampante di Windows"
MESSAGE EXIT,DLG_SETPRINT
PROMPT -14 -2 "~Imposta"
HELP "Chiama l'Impostazione Stampante di Windows"
MESSAGE EXIT,DLG_SETPRINT
END
BUTTON DLG_SAVEREC 9 2
BEGIN
PROMPT -24 -2 "~Registra"
MESSAGE EXIT,K_INS
PROMPT -24 -2 "~Registra"
MESSAGE EXIT,K_INS
END
BUTTON DLG_OK 9 2
BEGIN
PROMPT -34 -2 ""
PROMPT -34 -2 ""
END
BUTTON DLG_CANCEL 9 2
BEGIN
PROMPT -44 -2 ""
PROMPT -44 -2 ""
END
ENDPAGE

View File

@ -598,7 +598,7 @@ TPush_button::TPush_button(short left, short top, short right, short bottom,
_accel *= CHARX;
_dx = (width - win_get_text_width(win(), (char*)caption(), -1)) >> 1;
_dy = byte((height-CHARY)/2 + BASEY);
_dy = byte((height-CHARY)/2 + BASEY - DEPTH);
}
}

View File

@ -59,6 +59,7 @@
n.ro campi lista di campi
CHECK_FIELD esegue il check su di un altro campo
campo
FILENAME_FUNC controlla se la stringa e' un nome di file
*/
#define EXPR_FUNC 0 2
@ -79,6 +80,7 @@
#define STRCALC_FUNC 15
#define ONEREQ_FUNC 16
#define CHECK_FIELD 17 1
#define FILENAME_FUNC 18
#define VALEXPR VALIDATE EXPR_FUNC
#define NUM_EXPR VALEXPR 0

View File

@ -1,4 +1,4 @@
// $Id: mailbox.cpp,v 1.7 1994-11-10 14:16:39 alex Exp $
// $Id: mailbox.cpp,v 1.8 1994-12-02 13:30:03 guy Exp $
#include <stdlib.h>
#include <fstream.h>
@ -16,12 +16,13 @@
#define DEF_MSGS_CAPACITY 50
#define MAX_TXT_LEN 200
TMessage::TMessage(const char* to, const char* sub, const char* text,
const char* from)
TMessage::TMessage(const char* to, const char* sub,
const char* text, const char* from)
{
_to = to; _subject = sub;
_to = cmd2name(to);
_subject = sub;
_text = text;
_from = (from == NULL || *from == '\0' ? main_app().name() : from);
_from = (from == NULL || *from == '\0') ? main_app().name() : from;
_flags = 0x00; _number = -1;
}
@ -146,9 +147,7 @@ void TMailbox::send(TMessage& m)
ofstream fto(to_path, ios::app);
CHECK(fto.good(),"send: trouble opening mailbox file");
fto << m.from() << '\n'
<< m.subject() << '\n'
<< m.body() << '\n';
fto << m.from() << '\n' << m.subject() << '\n' << m.body() << '\n';
fto.close();
}

View File

@ -955,10 +955,11 @@ void TMask::reset(short fld_id)
for (int f = 0; f < fields(); f++)
{
TMask_field& c = fld(f);
c._flags.dirty = FALSE;
c.reset();
c.set_dirty(FALSE);
}
} else field(fld_id).reset();
}
else field(fld_id).reset();
}

View File

@ -16,9 +16,8 @@
// @T
typedef bool (*MASK_HANDLER)(TMask& mask, KEY key);
enum TMaskmode { NO_MODE, MODE_INS , MODE_MOD , MODE_DEL ,
MODE_VIS , MODE_QUERY, MODE_QUERYINS,
MODE_SEARCH };
enum TMaskmode { NO_MODE, MODE_INS , MODE_MOD ,
MODE_VIS , MODE_QUERY, MODE_QUERYINS };
// @END
// @C

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.56 1994-12-02 13:07:39 alex Exp $
// $Id: maskfld.cpp,v 1.57 1994-12-02 13:30:09 guy Exp $
#include <xvt.h>
#include <applicat.h>
@ -1348,7 +1348,7 @@ bool TBrowse::do_insert()
#endif
TMailbox mail;
TMessage msg(cmd2name(app), MSG_AI, "");
TMessage msg(app, MSG_AI, "");
mail.send(msg);
TExternal_app a(app);
@ -1497,10 +1497,13 @@ switch (k)
default:
if (k >= K_CTRL)
{
const TMask& m = _fld->mask();
const short id = siblings.get_int((k - K_CTRL) << 1);
TEdit_field& ef = (TEdit_field&)_fld->mask().field(id);
TEdit_field& ef = m.efield(id);
ef.set_focus();
ef.send_key(k = K_F9, 0);
k = K_F9;
if (m.is_running())
ef.send_key(k, 0);
}
break;
}
@ -1552,10 +1555,7 @@ bool TBrowse::check(CheckTime t)
bool TBrowse::empty_check()
{
const TMaskmode mode = (TMaskmode)field().mask().mode();
const bool no_check = mode == MODE_SEARCH || field().mask().query_mode();
if ( no_check || _fld->check_type() == CHECK_NONE ||
if ( field().mask().query_mode() || _fld->check_type() == CHECK_NONE ||
_fld->check_type() == CHECK_NORMAL)
return TRUE;
else
@ -1870,7 +1870,7 @@ void TEdit_field::create(WINDOW parent)
flags |= CTL_FLAG_INVISIBLE;
}
_buttonwin = xvt_create_control(WC_PUSHBUTTON, _x+_width+delta, _y,
2, 1, "*", parent, flags, PTR_LONG(this), DLG_F9);
2, 1, "*", parent, flags, PTR_LONG(this), DLG_F9);
}
}
@ -2060,12 +2060,15 @@ bool TEdit_field::on_key(KEY key)
case K_F9:
if (check_enabled())
{
enable_check(FALSE);
if (dirty()) set(get());
KEY k = K_ESC;
if (_browse) k = _browse->run();
else if (_sheet) k = _sheet->run();
else beep();
if (mask().is_running() && k != K_F9) set_focus();
else
if (_sheet) k = _sheet->run();
else beep();
if (k != K_F9) set_focus();
enable_check(TRUE);
if (k == K_ENTER)
{
set_dirty();

View File

@ -480,21 +480,7 @@ break;
case XIE_BUTTON:
if (xiev->v.xi_obj->type == XIT_CELL)
{
if (_edit_field)
{
const char* val = xi_get_text(xiev->v.xi_obj, NULL, -1);
_edit_field->set(val); // Update current cell
_check_enabled = FALSE; // Disable checks
if (!_row_dirty) notify(_cur_row, K_SPACE);
if (_edit_field->on_key(K_F9)) // Show search sheet
{
mask2str(_cur_row); // Update row
_row_dirty = TRUE;
}
set_front_window(win()); // It seems necessary to make xi_set_focus work properly
xi_set_focus(xiev->v.xi_obj); // Restore focus to cell
_check_enabled = TRUE; // Enable checks
}
dispatch_e_char(win(), K_F9);
} else
if (xiev->v.xi_obj->type == XIT_LIST)
insert(-1);
@ -655,32 +641,40 @@ break;
case K_F8:
case K_F9:
case K_F11:
{
_check_enabled = FALSE; // Disable checks
if (!_row_dirty) notify(_cur_row, K_SPACE);
if (_edit_field->on_key(k))
if (_check_enabled)
{
mask2str(_cur_row);
_row_dirty = TRUE;
_check_enabled = FALSE; // Disable checks
if (!_row_dirty) notify(_cur_row, K_SPACE);
if (_edit_field->on_key(k))
{
mask2str(_cur_row);
_row_dirty = TRUE;
}
else
if (k == K_F9)
{
_edit_field = &_mask.fld(_mask.focus_field());
const short foca = _edit_field->dlg();
const int col = (foca - FIRST_FIELD) % 100 +1;
if (col > 0 && col != _cur_col)
{
_cur_col = col;
dispatch_e_char(win(), K_F9);
}
}
set_focus_cell(_cur_row, _cur_col);
_check_enabled = TRUE; // Enable checks
}
set_focus_cell(_cur_row, _cur_col);
_check_enabled = TRUE; // Enable checks
}
break;
case K_PREV:
case K_NEXT:
{
const bool ok = (bool)xi_move_focus(_itf);
if (ok) dispatch_e_char(parent(), k);
}
if (xi_move_focus(_itf))
dispatch_e_char(parent(), k);
break;
case K_ESC:
{
xi_set_focus(_itf);
dispatch_e_char(parent(), K_ESC);
}
break;
case K_CTRL+K_PREV:
xi_scroll(_list, XI_SCROLL_PGUP);
break;
@ -1087,6 +1081,7 @@ TSheet_field::~TSheet_field()
void TSheet_field::reset()
{
_sheet->destroy();
_sheet->mask().reset();
}
// Certified 100%

View File

@ -1,6 +1,4 @@
#include <stdlib.h>
#include <xvt.h>
#include <urldefid.h>
#if XVT_OS==XVT_OS_SCOUNIX
#include <unistd.h>
@ -10,18 +8,20 @@
#include <stdio.h>
#endif
#include <strstream.h>
#include <xvt.h>
#define STYLE_NUM 4
#include <applicat.h>
#include <execp.h>
#include <extcdecl.h>
#include <mask.h>
#include <urldefid.h>
#include <utility.h>
#include <viswin.h>
#include <extcdecl.h>
#include <applicat.h>
#include <printer.h>
#include <execp.h>
#include <bagn001a.h>
#include <strstream.h>
struct PrDesc
{
@ -1158,12 +1158,24 @@ void TPrinter::set()
TToken_string pn1 (50), pn2 (100);
int i;
if (_printerfile.empty())
{
_printerfile.tempdir();
#if XVT_OS == XVT_OS_SCOUNIX
_printerfile << '/';
#else
_printerfile << '\\';
#endif
}
TFilename defile("printer.def");
#if XVT_OS == XVT_OS_SCOUNIX
defile << format (".%d", getuid ());
#endif
mask.set_workfile(defile);
mask.set(MSK_1_FILENAME, _printerfile);
mask.set(MSK_1_NPAGES, _ncopies);
#if XVT_OS != XVT_OS_WIN
@ -1199,9 +1211,6 @@ void TPrinter::set()
mask.set(MSK_1_PRINTERS, format("%d", _curprn));
mask.set(MSK_1_CODES, format("%d", _curcode));
mask.set(MSK_1_FILENAME, _printerfile);
mask.set(MSK_1_NPAGES, _ncopies);
KEY k;
if ((k = mask.run()) == K_ESC)
@ -1236,7 +1245,6 @@ void TPrinter::set()
}
break;
case 1: // file
_printertype = fileprinter;
_printerfile = mask.get (MSK_1_FILENAME);
_curcode = atoi (mask.get (MSK_1_CODES));
@ -1267,8 +1275,6 @@ void TPrinter::set()
mask.set(MSK_1_SIZE, _ch_size);
mask.set(MSK_1_LINES, _lines_per_inch);
mask.set(MSK_1_NPAGES, _ncopies);
if (_printertype == fileprinter)
mask.set (MSK_1_TYPE, "1");
else if (_printertype == screenvis)
@ -1502,9 +1508,6 @@ genera_dischetti ()
{
int r;
warning_box ("Questa procedura richiede %2d dischetti",
_volume);
for (int i = 0; i < _tmp_files.items (); i++)
{
// Avvisa l'utente di inserire un dischetto

View File

@ -112,15 +112,13 @@ real & real::operator += (const real & b)
real & real::operator += (double a)
{
__tmp_real = *this;
adddfd (ptr (), __tmp_real.ptr (), a);
adddfd (ptr (), ptr (), a);
return *this;
}
real & real::operator -= (const real & b)
{
__tmp_real = *this;
dsub (ptr (), __tmp_real.ptr (), b.ptr ());
dsub (ptr (), ptr (), b.ptr ());
return *this;
}
@ -235,7 +233,7 @@ char *real ::literals () const
TFixed_string risultato (__string, 80);
risultato.cut (0);
TString16 centinaia;
TString80 centinaia;
for (int migliaia = 0;; migliaia++)
{
@ -436,7 +434,7 @@ real & real ::ceil (int prec)
dint (&integer, ptr ()); // Extract the integer part
if (disgt (ptr (), &integer)) // If positive ...
addid (ptr (), &integer, 1); // add 1
addid (ptr (), &integer, 1); // ... add 1
else
dcpy(ptr(), &integer); // If negative

View File

@ -14,10 +14,6 @@
#include <stdtypes.h>
#endif
#ifndef __OBJECT_H
#include <object.h>
#endif
#ifndef __ARRAY_H
#include <array.h>
#endif

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.35 1994-11-30 09:04:01 guy Exp $
// $Id: relapp.cpp,v 1.36 1994-12-02 13:30:27 guy Exp $
#include <mailbox.h>
#include <sheet.h>
#include <urldefid.h>
@ -648,6 +648,7 @@ bool TRelation_application::save(bool check_dirty)
switch(err)
{
case NOERR:
_recins = get_relation()->lfile().recno();
break;
case _isreinsert:
warning_box("Esiste gia' un documento con la stessa chiave");
@ -718,7 +719,7 @@ bool TRelation_application::remove()
bool TRelation_application::main_loop()
{
long recins = -1;
_recins = -1;
query_mode();
_mask->open_modal();
@ -753,13 +754,8 @@ bool TRelation_application::main_loop()
k = K_QUIT;
break;
case K_QUIT:
if (save(TRUE))
{
if (_mask->edit_mode() &&
(_autoins_caller.not_empty() || _lnflag))
recins = file().recno();
}
else k = K_ENTER;
if (!save(TRUE))
k = K_ENTER;
break;
case K_ENTER:
if (find(0)) modify_mode();
@ -768,9 +764,8 @@ bool TRelation_application::main_loop()
case K_SAVE:
if (save(FALSE))
{
if (_autoins_caller.not_empty() || _lnflag)
if (_autoins_caller.not_empty())
{
recins = file().recno();
k = K_QUIT;
}
else
@ -835,9 +830,9 @@ bool TRelation_application::main_loop()
_mask->set_mode(NO_MODE);
if (recins > 0 && _autoins_caller.not_empty())
if (autoins_caller().not_empty() && _recins >= 0)
{
TMessage msg(_autoins_caller, _lnflag ? MSG_LN : MSG_AI, format("%ld", recins));
TMessage msg(autoins_caller(), _lnflag ? MSG_LN : MSG_AI, format("%ld", _recins));
msg.send();
}
@ -901,16 +896,15 @@ bool TRelation_application::filter()
_lnflag = TRUE;
const char* v = body.get();
const int max = _mask->fields();
for (int i = 0; i < max && v != NULL; i++)
TString80 s;
for (int i = 0; v != NULL && i < _mask->fields(); i++)
{
TMask_field& f = _mask->fld(i);
if (f.active() && f.dlg() > 0 && f.in_key(key))
{
const TString s(v);
_fixed.add(format("%d=%s", f.dlg(), (const char*) s));
s = v;
_fixed.add(format("%d=%s", f.dlg(), (const char*)s));
v = body.get();
}
}

View File

@ -22,7 +22,9 @@ class TRelation_application : public TApplication
TRecnotype _first, _last;
int _search_id;
TString _autoins_caller;
TString16 _autoins_caller;
long _recins;
bool _lnflag;
TToken_string _fixed;

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.24 1994-11-18 17:01:26 guy Exp $
// $Id: relation.cpp,v 1.25 1994-12-02 13:30:30 guy Exp $
// relation.cpp
// fv 12/8/93
// relation class for isam files
@ -98,13 +98,13 @@ TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key,
s = r.left(eq); // Parte a sinistra dell' =
#ifdef DBG
TString80 n(s);
const int p = n.find('[');
if (p > 0) n.cut(p);
const char* n = s;
const int p = s.find('[');
if (p > 0) n = s.left(p);
if (rel->file(_num).curr().exist(n) == FALSE)
{
error_box("'%s' non e' un campo del file %d",
(const char*)n, rel->file(_num).num());
yesnofatal_box("Errore di JOIN: '%s' non e' un campo del file %d",
n, rel->file(_num).num());
continue;
}
#endif
@ -115,8 +115,9 @@ TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key,
eq++;
}
const TString80 xx(s);
_fields.add(new TFieldref(xx,0));
// const TString80 xx(s);
// _fields.add(new TFieldref(xx,0));
_fields.add(new TFieldref(s,0));
_exprs.add(new TExpression(r.mid(eq+1), _strexpr));
}
@ -1103,10 +1104,10 @@ int name2log(const char* name)
if (name && *name)
{
if (isdigit(*name))
if (isdigit(*name) || *name == '-')
{
log = atoi(name);
if (strchr(name, '@')) log = -log;
if (strchr(name, '@')) log = -log;
}
else
{

View File

@ -2,7 +2,6 @@
#include <applicat.h>
#include <colors.h>
#include <relation.h>
#include <printer.h>
#include <sheet.h>
#include <urldefid.h>
#include <utility.h>
@ -35,7 +34,12 @@ TSheet::TSheet(short x, short y, short dx, short dy,
_checkable = _size[0] = 1;
else
_size[_columns] = l > 0 ? l : item.len();
} else _size[_columns] = item.len();
}
else
{
_size[_columns] = item.len();
_type[_columns] = '\0';
}
item.trim();
new_head.add(item);
@ -309,15 +313,27 @@ bool TSheet::on_key(KEY key)
if (_checkable && _check_enabled && items() > 0)
{
bool ok = TRUE;
bool force = FALSE;
switch(key)
{
case K_SPACE: _checked.not(selected()); break;
case K_F2 : uncheck(-1); break;
case K_F3 : check(-1); break;
default : ok = FALSE; break;
}
if (ok) force_update();
case K_SPACE:
_checked.not(selected());
set_opaque_text(TRUE);
update_row(selected());
set_opaque_text(FALSE);
break;
case K_F2:
uncheck(-1);
force = TRUE;
break;
case K_F3:
check(-1);
force = TRUE;
break;
default:
break;
}
if (force) force_update();
}
return TScroll_window::on_key(key);
}

View File

@ -585,6 +585,48 @@ const char* TFilename::path() const
return spark;
}
bool TFilename::ok() const
{
const int l = len();
int len = 0; // lunghezza ultima sottostringa
bool ext = FALSE; // trovata estensione
for (int c = 0; c < l; c++)
{
switch(_str[c])
{
#if XVT_OS != XVT_OS_SCOUNIX
case ':':
if (c != 1 || !isalpha(_str[0])) return FALSE; // Nome disco errato
len = 0;
break;
case '\\':
#endif
case '/':
if (ext) return FALSE; // Slash dopo estensione
if (len > 8) return FALSE; // Nome troppo lungo
if (!isalnum(_str[++c])) return FALSE;
len = 1;
break;
case '.':
if (len == 0 || ext) return FALSE; // Nome nullo o Doppia estensione
ext = TRUE;
len = 0;
c++;
default:
if (isalnum(_str[c])) len++;
else return FALSE;
break;
}
}
if (ext && len > 3)
return FALSE;
return len > 0 && len < 9;
}
// Certified 70%
const TFilename& TFilename::tempdir()
{

View File

@ -80,12 +80,13 @@ public:
const TString& sub(int from, int to = -1) const; // Ritorna la stringa da FROM a TO (escluso)
const TString& right(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da destra
///////////////////////////////////////////////////////////
// @DES Modifying methods
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// @DES Modifying methods
///////////////////////////////////////////////////////////
// @FPUB
TString& fill(char c, int n = -1); // Riempie con n caratteri c
// @FPUB
TString& fill(char c, int n = -1); // Riempie con n caratteri c
TString& spaces(int n = -1) { return fill(' ', n); }
TString& overwrite(const char* s, int pos = 0); // Sovrascrive la stringa s dalla posizione pos
TString& insert(const char* s, int pos = 0); // Inserisce la stringa s dalla posizione pos
@ -108,12 +109,13 @@ public:
TString& upper(); // Mette la stringa in maiuscolo
TString& lower(); // Mette la stringa in minuscolo
///////////////////////////////////////////////////////////
// @DES Standard operators
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// @DES Standard operators
///////////////////////////////////////////////////////////
// @FPUB
const TString& operator =(const TString& s) { return set(s._str); }
// @FPUB
const TString& operator =(const TString& s) { return set(s._str); }
const TString& operator =(const char* s) { return set(s); }
TString& operator <<(const char*);
@ -205,9 +207,11 @@ public:
TFilename(const char* n = "") : TString80(n) {}
TFilename(const TString& n) : TString80(n) {}
// assegnazione tra TFile e stringa
const TString& operator =(const char* s) { return set(s); }
const TString& operator =(const TString& s) { return set((const char*)s); }
// assegnazione tra TFile e stringa
virtual bool ok() const; // Controlla il formato del nome del file
const char* ext() const; // Ritorna l'estensione
void ext(const char*); // Imposta come estensione la stringa puntata da char*

View File

@ -436,7 +436,7 @@ HIDDEN bool _fixlen_val(TEdit_field& f, KEY)
}
HIDDEN bool _mtcheck_val(TEdit_field& f, KEY)
HIDDEN bool _mtcheck_val(TEdit_field& f, KEY)
{
const int month = atoi(f.get());
if (month < 1 || month > 13) return FALSE;
@ -549,12 +549,11 @@ HIDDEN bool _onereq_val(TEdit_field& f, KEY k)
const TMask& m = f.mask();
if (m.mode() == MODE_QUERY) return TRUE;
const int nparms = get_val_param_num();
TString s;
for (int i = 0; i < nparms ; i++)
{
s = m.get(atoi(get_val_param(i)));
if (s.not_empty()) return TRUE;
const char* s = m.get(atoi(get_val_param(i)));
if (*s) return TRUE;
}
return FALSE;
}
@ -572,7 +571,13 @@ HIDDEN bool _chkfld_val(TEdit_field& f, KEY k)
return TRUE;
}
#define MAX_FUNC 18
HIDDEN bool _filename_val(TEdit_field& f, KEY)
{
const TFilename fn(f.get());
return fn.ok();
}
#define MAX_FUNC 19
HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] =
{
@ -593,7 +598,8 @@ HIDDEN VAL_FUNC _global_val_func[MAX_FUNC] =
_numcalc_val,
_strcalc_val,
_onereq_val,
_chkfld_val
_chkfld_val,
_filename_val
};
bool validate(int fn, TEdit_field& f, KEY k, const TArray& parms)

View File

@ -8,8 +8,6 @@
#include <urldefid.h>
#include <utility.h>
#include <viswin.h>
#include <xvtility.h>
#include <colors.h>
#ifndef __PRINTER_H
typedef void (*LINKHANDLER) (int, const char *);
@ -1784,24 +1782,26 @@ default:
bool TViswin::call_editor ()
{
TConfig cnf (CONFIG_GENERAL, "Link");
TString editor (cnf.get ("txt"));
const TFilename editor (cnf.get ("txt"));
bool ok = FALSE;
if (!editor.empty ())
{
TString newfilename;
static FILE_SPEC fs;
get_default_dir(&fs.dir);
TFilename newfilename; newfilename.tempdir();
FILE_SPEC fs;
str_to_dir((char*)(const char*)newfilename, &fs.dir);
strcpy (fs.type, "txt");
strcpy (fs.name, "");
save_dir ();
if (save_file_dlg (&fs, "Salva il file con il nome:") == FL_OK)
{
restore_dir ();
char path[256];
dir_to_str (&fs.dir, path, sizeof (path));
newfilename << path << '/' << fs.name;
newfilename = path;
newfilename << '/' << fs.name;
TPoint p1, p2;
if (_isselection)
@ -1819,8 +1819,7 @@ bool TViswin::call_editor ()
ok = TRUE;
}
}
else
restore_dir ();
restore_dir ();
}
else
warning_box ("Nessun editor specificato nei parametri studio");

View File

@ -342,7 +342,7 @@ void beep()
class TEvent_manager
{
enum { MAX = 16 };
enum { MAX = 2 };
WINDOW _w[MAX];
EVENT _e[MAX];
int _begin, _end;
@ -360,8 +360,11 @@ void TEvent_manager::push(WINDOW w, const EVENT& e)
CHECK(w, "You shouldn't send events to NULL_WIN!");
_w[_end] = w;
_e[_end] = e;
_end = (++_end) % MAX;
CHECKD(_end != _begin, "Too many events queued: max. ", MAX);
const int next = (_end+1) % MAX;
if (next == _begin)
error_box("Hey %s, clicca piu' piano!", (const char*)main_app().user());
else
_end = next;
}
void TEvent_manager::pop()