..gata nella gestione delle pagine disabilitate

git-svn-id: svn://10.65.10.50/trunk@636 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-11-16 15:51:06 +00:00
parent e738fe49c0
commit 76f16c5b5f
11 changed files with 3186 additions and 3108 deletions

View File

@ -389,7 +389,10 @@ const char* TApplication::get_module_name() const
if (ok) ok = has_module(aut);
if (!ok)
fatal_box("Il modulo '%s' non e' autorizzato", module);
{
error_box("Il modulo '%s' non e' autorizzato", module);
module = "";
}
return module;
}
@ -480,8 +483,11 @@ void TApplication::run(int argc, char* argv[], const char* title)
}
set_perms();
const TFixed_string mod(get_module_name());
if (mod.empty()) return;
TString80 caption;
caption << "PRASSI S.p.A. - " << get_module_name();
caption << "PRASSI S.p.A. - " << mod;
static XVT_CONFIG cfg;
cfg.base_appl_name = (char*)base.name();

View File

@ -39,6 +39,8 @@ int fatal_box(const char* fmt, ...)
if (xvt_running())
main_app().stop_run();
else
exit(1);
#else
beep();
if (xvt_running()) xvt_fatal("%s", msg);

View File

@ -706,6 +706,8 @@ protected:
public:
TPage_button(WINDOW parent, byte flag);
byte get_flag() const { return _flag; }
void set_flag(byte f);
};
TPage_button::TPage_button(WINDOW parent, byte flag) : _flag(flag)
@ -729,9 +731,16 @@ void TPage_button::mouse_up()
void TPage_button::update() const
{
TControl::update();
if (_flag)
cpb_win_picture_draw_at(_hdc, cpb[BMP_BOOK1 + _flag -1], 0, 0);
}
void TPage_button::set_flag(byte f)
{
_flag = f;
update();
}
///////////////////////////////////////////////////////////
// TTag_button
///////////////////////////////////////////////////////////
@ -752,6 +761,8 @@ protected:
public:
TTag_button(WINDOW parent, byte p, byte tot);
byte get_pages() const { return _pages; }
void set_pages(byte p);
};
TTag_button::TTag_button(WINDOW parent, byte p, byte tot)
@ -809,7 +820,8 @@ void TTag_button::update() const
void TTag_button::mouse_down(PNT where)
{
_curr = where.h / width;
if (_curr >= _pages) _curr = _pages-1;
if (_curr >= _pages) _curr = _pages-1; else
if (_curr < 0) _curr = 0;
}
void TTag_button::mouse_up()
@ -818,6 +830,12 @@ void TTag_button::mouse_up()
dispatch_e_char(_parent, K_CTRL + K_F1 + _curr);
}
void TTag_button::set_pages(byte p)
{
_pages = p;
update();
}
///////////////////////////////////////////////////////////
// Checkbox
///////////////////////////////////////////////////////////
@ -1024,3 +1042,23 @@ TControl* TControl::WINDOW2TControl(WINDOW win)
CHECK(model && *model, "Can't get the model from a window");
return *model;
}
void xvt_change_page_tags(WINDOW pag, bool on, WINDOW tag, byte p)
{
if (pag != NULL_WIN)
{
TPage_button* pb = (TPage_button*)TControl::WINDOW2TControl(pag);
byte f = pb->get_flag();
if (on) f |= 0x1;
else f &= 0x2;
pb->set_flag(f);
}
if (tag != NULL_WIN)
{
TTag_button* pt = (TTag_button*)TControl::WINDOW2TControl(tag);
pt->set_pages(p);
}
}

View File

@ -11,7 +11,8 @@ WINDOW xvt_create_checkbox(
WINDOW parent,
long flags,
long app_data,
int id);
int id
);
WINDOW xvt_create_radiobutton(
short left, short top, short right, short bottom,
@ -19,7 +20,8 @@ WINDOW xvt_create_checkbox(
WINDOW parent,
long flags,
long app_data,
int id);
int id
);
WINDOW xvt_create_pushbutton(
short left, short top, short right, short bottom,
@ -27,7 +29,8 @@ WINDOW xvt_create_checkbox(
WINDOW parent,
long flags,
long app_data,
int id);
int id
);
WINDOW xvt_create_text(
short left, short top, short right, short bottom,
@ -35,7 +38,8 @@ WINDOW xvt_create_checkbox(
WINDOW parent,
long flags,
long app_data,
int id);
int id
);
WINDOW xvt_create_groupbox(
short left, short top, short right, short bottom,
@ -43,7 +47,8 @@ WINDOW xvt_create_checkbox(
WINDOW parent,
long flags,
long app_data,
int id);
int id
);
void free_controls_bmp();
@ -51,7 +56,6 @@ WINDOW xvt_create_checkbox(
// Custom control
///////////////////////////////////////////////////////////
class TControl
{
WINDOW _win;

View File

@ -162,15 +162,19 @@ void TMask::handler(WINDOW win, EVENT* ep)
void TMask::init_mask(int mode)
{
_sheets = _pages = 0; // Azzera numero pagine e sheets
_enabled = 0xffff; // Abilita tutte le pagine
_enabled.set(MAX_PAGES);
_enabled.set(); // Abilita tutte le pagine
_focus = _first_focus = 0; // Nessuno ha il focus
_page = -1; // Nessuna pagina corrente
_handler = NULL; // Nessun handler utente
_mode = mode; // Inizializza modo
_exchange = 1.0; // Il cambio per la valuta e' la lira
for (int i = 0; i <= MAX_PAGES; i++)
_pagewin[i] = NULL_WIN; // Azzera le finestre delle varie pagine
memset(_pagewin, 0, sizeof(_pagewin));
memset(_pagepag, 0, sizeof(_pagepag));
memset(_pagetag, 0, sizeof(_pagetag));
}
@ -237,12 +241,12 @@ void TMask::add_buttons()
{
if (_pages > 1)
{
const byte flag = (p < _pages-1 ? 0x1 : 0x0) | (p > 0 ? 0x2 : 0x0);
xvt_create_control(WC_PUSHBUTTON, 0,0,1,1, "",
_pagewin[p], flag, 0, DLG_PAGE);
const long flags = (p < _pages-1 ? 0x1 : 0x0) | (p > 0 ? 0x2 : 0x0);
_pagepag[p] = xvt_create_control(WC_PUSHBUTTON, 0, 0, 1, 1, "",
_pagewin[p], flags, 0, DLG_PAGE);
}
if (toolwin())
xvt_create_control(WC_PUSHBUTTON, 0,0,0,1, "",
_pagetag[p] = xvt_create_control(WC_PUSHBUTTON, 0, 0, 0, 1, "",
_pagewin[p], p, _pages, DLG_PAGETAGS);
}
#else
@ -384,23 +388,31 @@ void TMask::load_checks() const
}
}
void TMask::enable_page(int page, bool on)
// Dis/abilita una pagina e tutte le successive
void TMask::enable_page(byte page, bool on)
{
int first = (page >= 0) ? page : 1;
int last = (page >= 0) ? page+1 : _pages;
CHECK(page > 0, "Can't enable/disable first page");
for (int p = first; p < last; p++)
if (_enabled[page] != on)
{
const word n = 1 << p;
if (on) _enabled |= n;
else _enabled &= ~n;
for (byte i = page; i < _pages; i++)
_enabled.set(i, on);
#if XVT_OS == XVT_OS_WIN
const byte p = on ? _pages : page;
for (i = 0; i < page-1; i++)
xvt_change_page_tags(NULL_WIN, FALSE, _pagetag[i], p);
xvt_change_page_tags(_pagepag[page-1], on, _pagetag[page-1], p);
#endif
}
}
bool TMask::page_enabled(int page) const
// Controlla lo stato di abilitazione di una pagina
// Certified 100%
bool TMask::page_enabled(byte page) const
{
const unsigned long n = 1 << page;
return (_enabled & n) > 0;
return _enabled[page];
}
@ -426,7 +438,7 @@ void TMask::start_run()
for (i = 0; i < max; i++)
{
TMask_field& f = fld(i);
if (mode() == MODE_QUERY && f.is_edit() && f.in_key(1) &&
if (query_mode() && f.is_edit() && f.in_key(1) &&
!f.automagic() && !f.get().empty())
{
f.set_dirty(TRUE);
@ -497,7 +509,7 @@ void TMask::get_mask_fields()
int TMask::id2pos(short id) const
{
const int MAX_FIELDS = 128;
const int MAX_FIELDS = 256;
static byte positions[MAX_FIELDS]; // 100 <= id < MAX_FIELDS
const int max = fields();
@ -1124,27 +1136,35 @@ void TMask::autosave(TRelation* r) const
}
}
void TMask::send_key(KEY key, short to) const
void TMask::send_key(KEY key, short to, TMask_field* from)
{
if (to == 0)
{
WINDOW w = win();
if (w == NULL_WIN) w = _pagewin[0];
WINDOW w = from ? from->parent() : _pagewin[0];
dispatch_e_char(w, key);
return;
}
if (to > 0)
{
if (to == DLG_PAGE)
{
CHECK(from, "You should specify a sender!");
const int p = find_parent_page(*from)+1;
CHECKD(p > 0 && p < _pages, "You should specify a good page, not ", p);
key -= K_CTRL+K_SHIFT;
enable_page(p, key == 's' || key == 'e');
}
else
{
const int pos = id2pos(to);
if (pos >= 0)
fld(pos).on_key(key);
if (pos >= 0) fld(pos).on_key(key);
#ifdef DBG
else
if (mode() != MODE_SEARCH)
yesnofatal_box("Can't send key %u to field %d", key, to);
#endif
}
}
else
{
const int max = fields();

View File

@ -30,11 +30,13 @@ class TMask : public TWindow
// @DPRIV
enum { MAX_PAGES = 12 }; // Massimo numero di pagine nella maschera
WINDOW _pagewin[MAX_PAGES+1]; // Windows of the pages
WINDOW _pagepag[MAX_PAGES]; // Windows of pgup/pgdn
WINDOW _pagetag[MAX_PAGES]; // Windows of pagetags
int _pages; // Number of pages of the mask
int _page; // Current page
word _enabled; // Are pages enabled (bit field)
TBit_array _enabled; // Are pages enabled
int _mode; // Mode of the mask
TArray _field; // Fields in the mask
@ -150,9 +152,9 @@ public:
void disable(short fld_id) { enable(fld_id, FALSE); }
void enable_default(short fld_id = -1);
void enable_page(int p, bool on = TRUE);
void disable_page(int p) { enable_page(p, FALSE); }
bool page_enabled(int p) const;
void enable_page(byte p, bool on = TRUE);
void disable_page(byte p) { enable_page(p, FALSE); }
bool page_enabled(byte p) const;
byte num_keys() const;
void enable_key(byte key, bool on = TRUE);
@ -170,7 +172,7 @@ public:
void autoload(const TRelation* = NULL);
void autosave(TRelation* = NULL) const;
void send_key(KEY key, short id) const;
void send_key(KEY key, short id, TMask_field* from = NULL);
void set_handler(short fld_id, CONTROL_HANDLER handler);
void set_handler(MASK_HANDLER handler);
void set_workfile(const char* workfile) { _workfile = workfile; _lastpos = 0L;}

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.48 1994-11-15 17:14:22 guy Exp $
// $Id: maskfld.cpp,v 1.49 1994-11-16 15:50:57 guy Exp $
#include <xvt.h>
#include <applicat.h>
@ -541,8 +541,13 @@ HIDDEN const char* copy_value(TToken_string& msg, const TString& val)
return val.sub(from, to);
}
void TMask_field::send_key(KEY k, short to)
{
mask().send_key(k, to, this);
}
// Certified 50%
// Certified 90%
bool TMask_field::do_message(int num)
{
const int MAX_CMD = 14;
@ -644,7 +649,7 @@ bool TMask_field::do_message(int num)
if (key > 0)
{
if (broadcast) fld = -fld;
mask().send_key(key, fld);
send_key(key, fld);
}
}
else
@ -742,7 +747,7 @@ bool TMask_field::on_key(KEY key)
break;
case K_PREV:
case K_NEXT:
dispatch_e_char(parent(), key);
send_key(key, 0);
break;
case K_F1:
if (_help.not_empty())
@ -1486,7 +1491,7 @@ default:
const short id = siblings.get_int((k - K_CTRL) << 1);
TEdit_field& ef = (TEdit_field&)_fld->mask().field(id);
ef.set_focus();
ef.mask().send_key(k = K_F9, 0);
ef.send_key(k = K_F9, 0);
}
break;
}
@ -2000,7 +2005,8 @@ bool TEdit_field::on_key(KEY key)
{
for (int fld = m.get_key_field(i, TRUE); fld != -1; fld = m.get_key_field(i, FALSE))
m.field(fld).set_dirty(FALSE);
dispatch_e_char(get_parent(win()), K_AUTO_ENTER);
// dispatch_e_char(get_parent(win()), K_AUTO_ENTER);
mask().stop_run(K_AUTO_ENTER);
break;
}
}
@ -2055,7 +2061,7 @@ bool TEdit_field::on_key(KEY key)
{
set_dirty();
if (mask().is_running())
mask().send_key(K_TAB, 0);
send_key(K_TAB, 0);
else
on_hit();
return TRUE;

View File

@ -1,4 +1,4 @@
/* $Id: maskfld.h,v 1.10 1994-11-15 17:14:28 guy Exp $ */
/* $Id: maskfld.h,v 1.11 1994-11-16 15:51:01 guy Exp $ */
#ifndef __MASKFLD_H
#define __MASKFLD_H
@ -187,6 +187,7 @@ public:
const TFieldref* field() const { return _field; }
void set_focus() const;
void send_key(KEY k, short to);
// set focus, message-box, set focus
bool message_box(const char* fmt, ...) const;

View File

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

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.28 1994-11-15 11:23:19 guy Exp $
// $Id: relapp.cpp,v 1.29 1994-11-16 15:51:05 guy Exp $
#include <mailbox.h>
#include <sheet.h>
#include <urldefid.h>
@ -712,7 +712,6 @@ bool TRelation_application::main_loop()
// Dis/abilita cambio ditta
enable_menu_item(M_FILE_NEW, (_mask->mode() == MODE_QUERY));
k = _mask->run();
// Seleziona il cursore a clessidra se necessario

View File

@ -24,7 +24,8 @@ WINDOW xvt_create_window(WIN_TYPE wt,
const char* caption, WINDOW parent,
long flags,
EVENT_HANDLER eh,
long app_data);
long app_data
);
WINDOW xvt_create_control(WIN_TYPE wt,
short x, short y, short dx, short dy,
@ -32,7 +33,8 @@ WINDOW xvt_create_window(WIN_TYPE wt,
WINDOW parent,
long flags,
long app_data,
int id);
int id
);
WINDOW xvt_create_statbar();
void xvt_statbar_set(const char* text, bool def = FALSE);
@ -53,6 +55,7 @@ WINDOW xvt_create_window(WIN_TYPE wt,
bool xvt_get_checked_state(WINDOW win);
void xvt_check_radio_button(WINDOW win, const WINDOW* ctls, int count);
int xvt_get_checked_radio(const WINDOW* ctls, int count);
void xvt_change_page_tags(WINDOW pag, bool on, WINDOW tag, byte p);
bool xvt_test_menu_tag(MENU_TAG tag);
@ -60,9 +63,6 @@ WINDOW xvt_create_window(WIN_TYPE wt,
PAT_STYLE trans_brush(char p);
PEN_STYLE trans_pen (char p);
/* @END */
extern short CHARX, CHARY, BASEY, ROWY;
/* @END */