Cambiati leggermente i menu di default

Migliorata gestione variabili insestenti nel TConfig
Segato via _isatab dai TLocalisamfile
Cambiata la finestra di F_11 nelle maschere
Corretto errore nella TPrintrow::encoded_row() (resa pure const)
Aggiunto bottone di global un/check negli sheet


git-svn-id: svn://10.65.10.50/trunk@832 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-01-05 17:50:40 +00:00
parent a3286685d7
commit 904dffc045
14 changed files with 107 additions and 93 deletions

View File

@ -129,16 +129,23 @@ TString& TConfig::get(const char* var, const char* section, int index, const cha
if (_data.is_key(vvar))
s = (TString&)_data[vvar];
else
set(var, s = def, section, TRUE, index);
else
{
s = def;
if (s.not_empty())
set(var, s, section, TRUE, index);
}
return s;
}
long TConfig::get_long(const char* var, const char* section, int index, long def)
{
const char* n = get(var,section,index);
return *n ? atol(n) : def;
if (*n)
def = atol(n);
else
set(var, format("%ld", def), section, TRUE, index);
return def;
}
bool TConfig::get_bool(const char* var, const char* section, int index, bool def)
@ -150,17 +157,30 @@ bool TConfig::get_bool(const char* var, const char* section, int index, bool def
return s != "" && (s == "X" || s == "ON" || s == "YES" || s == "OK" || s == "TRUE");
}
HIDDEN void RGB_COLOR(COLOR c, int& r, int& g, int& b)
{
r = int(c >> 16) & 0xFF;
g = int(c >> 8) & 0xFF;
b = int(c) & 0xFF;
}
COLOR TConfig::get_color(const char* var, const char* section, int index, COLOR def)
{
const char* c = get(var, section, index);
if (*c)
{
TToken_string s(c, ',');
const int r = atoi(s.get());
const int g = atoi(s.get());
const int b = atoi(s.get());
const int r = s.get_int();
const int g = s.get_int();
const int b = s.get_int();
def = MAKE_COLOR(r, g, b);
}
else
{
int r, g, b; RGB_COLOR(def, r, g, b);
set(var, format("%d,%d,%d", r, g, b), section, TRUE, index);
}
return def;
}

View File

@ -84,8 +84,8 @@ PICTURE xvt_picture_load(short id, bool convert)
{
HWND hwnd = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW);
HDC hdc = GetDC(hwnd);
const int col = GetDeviceCaps(hdc, COLORRES);
_can_convert = col == 18;
const int bits = GetDeviceCaps(hdc, BITSPIXEL);
_can_convert = bits == 8;
ReleaseDC(hwnd, hdc);
}

View File

@ -33,14 +33,15 @@ MENU VISWIN_BAR
MENU MENU_VISWIN
ITEM M_EDIT_CLIPBOARD "Interrompi\tESC"
ITEM M_EDIT_CUT "Collega...\tAlt+C" DISABLED
ITEM M_EDIT_PASTE "Esporta...\tAlt+E"
ITEM M_EDIT_SEL_ALL "Stampa... \tAlt+S" DISABLED
ITEM M_EDIT_CUT "~Collega...\tCtrl+C" DISABLED
ITEM M_EDIT_PASTE "~Esporta...\tCtrl+E"
ITEM M_EDIT_SEL_ALL "~Stampa... \tCtrl+S" DISABLED
SEPARATOR
ITEM M_FONT "Mostra righelli" CHECKABLE
ITEM M_STYLE "Mostra bottoni" CHECKABLE
SEPARATOR
ITEM M_EDIT_QUIT "Chiudi\tESC+ESC"
ITEM M_FONT "Mostra ~righelli" CHECKABLE
ITEM M_STYLE "Mostra ~bottoni" CHECKABLE
ITEM M_EDIT_UNDO "Ri~disegna"
SEPARATOR
ITEM M_EDIT_QUIT "Chiudi\tESC+ESC"
MENU M_EDIT
ITEM M_EDIT_COPY "~Copia" DISABLED
@ -48,8 +49,6 @@ MENU M_EDIT
SEPARATOR
ITEM M_EDIT_SEARCH "Cerca...\tF8"
ITEM M_EDIT_DELETE "Cerca il prossimo\tF9" DISABLED
SEPARATOR
ITEM M_EDIT_UNDO "~Ridisegna"
ACCEL MENU_FILE "f" ALT

View File

@ -1205,16 +1205,16 @@ long TForm::records() const
bool TForm::print(long from, long to)
{
_form = this; // setta il form corrente
_lastpage = FALSE;
_form = this; // Setta il form corrente
TPrinter& printer = main_app().printer();
TPrinter& printer = main_app().printer(); // Setta handlers
printer.setheaderhandler(header_handler);
printer.setfooterhandler(footer_handler);
printer.formlen(height());
const bool was_open = printer.isopen();
_lastpage = FALSE; // non e' l'ultima pagina
if (!was_open && !printer.open())
return FALSE;
@ -1248,7 +1248,10 @@ bool TForm::print(long from, long to)
if (!was_open)
printer.close();
_form = NULL; // resetta form
_form = NULL; // resetta handlers
printer.setheaderhandler(NULL);
printer.setfooterhandler(NULL);
return ok;
}

View File

@ -638,17 +638,15 @@ TLocalisamfile::TLocalisamfile(int logicnum, bool linkrecinst)
: TBaseisamfile(logicnum, linkrecinst)
{
open();
if (_was_open) // Dangerous change by Guy
{
if (_was_open)
_oldkey = getkey();
setkey(1);
}
setkey(1);
}
TLocalisamfile::~TLocalisamfile()
{
if (_was_open) // Dangerous change by Guy
if (_was_open)
setkey(_oldkey);
close();
}

View File

@ -386,10 +386,9 @@ public:
// @FPUB
virtual int operator +=(const TRecnotype npos); // Avanza npos record
virtual int operator -=(const TRecnotype npos); // Sposta indietro di npos
virtual int operator ++(); // record successivo
virtual int operator --(); // record precedente
bool tab() const { return _isatab;} // Ritorna vero se tabella
void settab(bool fl = FALSE) { _isatab = fl;} // Setta il flag _isatab
virtual int operator ++(); // record successivo
virtual int operator --(); // record precedente
virtual bool tab() const { return FALSE;} // Ritorna vero se tabella
int open(unsigned int mode = _manulock);
int close() ;

View File

@ -1,4 +1,3 @@
#include <time.h>
#include <stdio.h>
#include <applicat.h>
@ -13,8 +12,6 @@
HIDDEN const char* const MASK_EXT = "msk";
clock_t clock1, clock2;
///////////////////////////////////////////////////////////
// TMask methods
///////////////////////////////////////////////////////////
@ -192,8 +189,6 @@ TMask::TMask(const char* title, int pages, int cols, int rows, int xpos,
void TMask::read_mask(const char* name, int num, int max)
{
clock1 = clock();
if (max <= 0) max = MAX_PAGES;
_source_file = name;
@ -232,8 +227,6 @@ void TMask::read_mask(const char* name, int num, int max)
fatal_box("Impossibile leggere la maschera %s", name);
add_buttons();
clock1 = clock()-clock1;
}
@ -422,8 +415,6 @@ bool TMask::page_enabled(byte page) const
void TMask::start_run()
{
clock2 = clock();
load_checks();
const int max = fields();
@ -453,8 +444,6 @@ void TMask::start_run()
f.set_dirty(FALSE);
}
}
clock2 = clock() - clock2;
}
bool TMask::check_fields()
@ -757,14 +746,6 @@ bool TMask::on_key(KEY key)
case K_NEXT:
next_page(+1);
break;
case K_F11:
message_box("Siete fortunati utenti del campo %d della maschera '%s'\n"
"caricata nell'incredibile tempo di %ld millisecondi\n"
"ed inizializzata mostruosamente in %ld millisecondi\n"
"Grazie per la comprensione",
fld(_focus).dlg(), (const char*)source_file(), clock1, clock2);
set_focus();
break;
default:
if (key > K_CTRL)
{
@ -1232,7 +1213,7 @@ void TMask::set_handler(MASK_HANDLER handler)
_handler = handler;
}
// aggiunta campi a runclock
// aggiunta campi a runtime
void TMask::add_static (short id, int page, const char* prompt, int x,
int y, const char* flags)

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.66 1995-01-02 09:32:42 guy Exp $
// $Id: maskfld.cpp,v 1.67 1995-01-05 17:50:24 guy Exp $
#include <xvt.h>
#include <applicat.h>
@ -799,14 +799,29 @@ bool TMask_field::on_key(KEY key)
HWND hwnd = (HWND)get_value(TASK_WIN, ATTR_NATIVE_WINDOW);
WinHelp(hwnd, "prassi.hlp", HELP_MULTIKEY, (DWORD)&mk);
} else
break;
}
#endif
if (_help.not_empty())
message_box(_help);
else
beep();
case K_SHIFT+K_F1:
if (_help.not_empty())
message_box(_help);
else
beep();
set_focus();
break;
case K_F11:
{
const char* c = "";
if (field())
c = field()->name();
message_box("Siete fortunati utenti del campo %d della maschera '%s'\n"
"corrispondente al campo su file '%s'\n"
"Grazie per la comprensione",
dlg(), (const char*)mask().source_file(), c);
set_focus();
}
break;
case K_F2:
if (is_edit()) set("");
else reset();
@ -1580,7 +1595,6 @@ bool TBrowse::check(CheckTime t)
else
if (t != FINAL_CHECK) do_clear();
}
// _checked = passed;
return passed;
}

View File

@ -430,14 +430,14 @@ TPrintrow & TPrintrow::reset ()
return *this;
}
const char *TPrintrow::row_codified ()
const char* TPrintrow::row_codified() const
{
// returns the row with @-codes for font style and color
char last_attr = -1;
int last_color = -1;
int k = 0;
_row.rtrim ();
for (int i = 0; i < _row.len (); i++)
int last = 0, k = 0;
for (int i = 0; i < _row.size(); i++)
{
if (_attr[i] != last_attr)
{
@ -470,9 +470,10 @@ const char *TPrintrow::row_codified ()
last_color = _cols[i];
}
__tmp_string[k++] = _row[i];
if (_row[i] > ' ') last = k;
}
// k = k > 255 ? 255 : k;
__tmp_string[k] = '\0';
__tmp_string[last] = '\0';
return __tmp_string;
}

View File

@ -70,7 +70,7 @@ public:
virtual TObject* dup() const;
const char* row() const { return _row; }
const char* row_codified();
const char* row_codified() const;
TPrintrow& reset();
TPrintstyle get_style(int position) const { return (TPrintstyle)_attr[position]; }

View File

@ -79,6 +79,7 @@ TSheet::TSheet(short x, short y, short dx, short dy,
_visible_rows = rows()- head_on() - 3;
add_button(DLG_SELECT, "Selezione" );
if (_checkable) add_button(DLG_USER, "Tutti");
if (buttons & 0x1) add_button(DLG_NEWREC, "Gestione");
if (buttons & 0x2) add_button(DLG_NEWREC, "Nuovo");
if (buttons & 0x4) add_button(DLG_DELREC, "Elimina");
@ -226,6 +227,8 @@ void TSheet::handler(WINDOW win, EVENT* ep)
dispatch_e_char(win, K_INS); break;
case DLG_DELREC:
dispatch_e_char(win, K_DEL); break;
case DLG_USER:
dispatch_e_char(win, one_checked() ? K_F2 : K_F3); break;
default:
{
const WINDOW b = ep->v.ctl.ci.win;
@ -709,7 +712,7 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
const int s = f->size()+1;
#endif
xvt_create_control(WC_EDIT, 1, -3, s, 1, f->get(), win(),
CTL_FLAG_DISABLED, 0L, 100);
CTL_FLAG_DISABLED, 0L, DLG_EDIT);
}
if (s && s->items() > 2)
@ -725,7 +728,7 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
}
WINDOW listbox = xvt_create_control(WC_LISTBUTTON, f->size()+3, -3, maxlen+3, 3,
"", win(), 0, 0L, 99);
"", win(), 0, 0L, DLG_FINDREC);
win_list_add(listbox, -1, (char*)lst);
slist_dispose(lst);
@ -750,8 +753,9 @@ void TBrowse_sheet::repos_buttons() const
int left = CHARX; // left coord of next control to draw
for (int id = 99; id <= 100; id++)
{
for (int i = 0; i < 1; i++)
{
const short id = i ? DLG_EDIT : DLG_FINDREC;
const WINDOW w = get_ctl_window(win(), id);
if (w != NULL_WIN)
{
@ -769,7 +773,7 @@ void TBrowse_sheet::repos_buttons() const
bool TBrowse_sheet::on_key(KEY k)
{
const WINDOW ctl = get_ctl_window(win(), 100);
const WINDOW ctl = get_ctl_window(win(), DLG_EDIT);
const bool alnum = k >= ' ' && k < K_UP;
if (ctl != NULL_WIN && (alnum || k == K_BACKSPACE || k == K_DEL))
@ -826,7 +830,7 @@ bool TBrowse_sheet::on_key(KEY k)
void TBrowse_sheet::handler(WINDOW win, EVENT* ep)
{
if (ep->type == E_CONTROL && ep->v.ctl.id == 99)
if (ep->type == E_CONTROL && ep->v.ctl.id == DLG_FINDREC)
{
const int what = win_list_get_sel_index(ep->v.ctl.ci.win);
if (what >= 0)

View File

@ -12,21 +12,16 @@ int TTable::name2log(const char* n)
TTable::TTable(const char* tabname, bool linkrecinst)
: TLocalisamfile(name2log(tabname), linkrecinst)
: TLocalisamfile(name2log(tabname), linkrecinst), _cod(curr(), "COD")
{
if ((*tabname == '%') || (*tabname == '#')) tabname++;
_tabname = tabname;
_tabname.upper();
settab(TRUE);
curr().settab(_tabname);
_cod = new TRecfield(curr(), "COD");
}
TTable::~TTable()
{
delete _cod;
}
{}
int TTable::first(word lockop)
@ -35,7 +30,7 @@ int TTable::first(word lockop)
zero();
TBaseisamfile::read(_isgteq, lockop);
if (good())
if (_tabname != (const char *) *_cod) setstatus(_isemptyfile);
if (_tabname != (const char *)_cod) setstatus(_isemptyfile);
if (bad()) zero();
return status();
}
@ -50,7 +45,7 @@ int TTable::last(word lockop)
if (!eof()) TBaseisamfile::prev(lockop);
else setstatus(NOERR);
if (good())
if (_tabname != (const char *) *_cod) setstatus(_isemptyfile);
if (_tabname != (const char *)_cod) setstatus(_isemptyfile);
if (bad()) zero();
return status();
}
@ -67,7 +62,7 @@ int TTable::next(word lockop)
}
TBaseisamfile::next(lockop);
if (_tabname != (const char *) *_cod)
if (_tabname != (const char *)_cod)
{
if (lockop == _lock) TBaseisamfile::reread(_unlock);
TBaseisamfile::readat(nrec, lockop);
@ -85,7 +80,7 @@ int TTable::prev(word lockop)
TRecnotype nrec = recno();
TBaseisamfile::prev(lockop);
if (_tabname != (const char *) *_cod)
if (_tabname != (const char *)_cod)
{
if (lockop == _lock) TBaseisamfile::reread(_unlock);
TBaseisamfile::readat(nrec, lockop);
@ -100,7 +95,7 @@ int TTable::skip(TRecnotype nrec, word lockop)
{
if (!nrec) return NOERR;
TBaseisamfile::skip(nrec, lockop);
if (_tabname != (const char *) *_cod)
if (_tabname != (const char *)_cod)
{
if (nrec > 0)
{
@ -124,7 +119,7 @@ int TTable::read(word op, word lockop, TDate&)
{
CHECKD(op >= _iscurr && op <= _isgteq, "Invalid read operation : ", op);
TBaseisamfile::read(op, lockop);
if (_tabname != (const char *) *_cod)
if (_tabname != (const char *)_cod)
{
if (lockop == _lock) TBaseisamfile::reread(_unlock);
last(lockop);
@ -139,7 +134,7 @@ int TTable::read(TRectype& rec, word op, word lockop, TDate&)
{
CHECKD(op >= _iscurr && op <= _isgteq, "Invalid read operation : ", op);
TBaseisamfile::read(rec, op, lockop);
if (_tabname != (const char *) *_cod)
if (_tabname != (const char *)_cod)
{
setstatus(_iseof);
if (lockop == _lock) TBaseisamfile::reread(_unlock);
@ -154,7 +149,7 @@ int TTable::readat(TRecnotype nrec, word lockop)
{
TBaseisamfile::readat(nrec, lockop);
CHECKS(_tabname == (const char * ) *_cod, "Invalid position : Table ", (const char *)_tabname);
CHECKS(_tabname == (const char * )_cod, "Invalid position : Table ", (const char *)_tabname);
return status();
}
@ -164,7 +159,7 @@ int TTable::readat(TRectype& rec ,TRecnotype nrec, word lockop)
{
TBaseisamfile::readat(rec, nrec, lockop);
CHECKS(_tabname == (const char *) *_cod, "Invalid position : Table ", (const char *)_tabname);
CHECKS(_tabname == (const char *)_cod, "Invalid position : Table ", (const char *)_tabname);
return status();
}

View File

@ -22,8 +22,8 @@
class TTable : public TLocalisamfile
{
// @DPRIV
TString _tabname;
TRecfield * _cod;
TString16 _tabname;
TRecfield _cod;
public:
// @FPUB
@ -36,8 +36,8 @@ public:
virtual int read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& = (TDate&)botime);
virtual int readat(TRecnotype nrec, word lockop = _nolock);
virtual int readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock);
virtual const char* name() const { return (const char*) _tabname;}
virtual bool tab() const { return TRUE; }
virtual const char* name() const { return _tabname;}
TTable(const char* tabname, bool linkrecinst = FALSE);
virtual ~TTable();

View File

@ -74,7 +74,7 @@ HIDDEN void xvt_menu_enable(MENU_ITEM* m, bool on)
{
switch(m->tag)
{
case M_FILE:
case MENU_FILE:
if (m->child)
xvt_menu_enable(m->child, on);
break;