Aggiornato ba0 in base alla moderna gestione dei bottoni delle maschere~aere

git-svn-id: svn://10.65.10.50/trunk@63 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-08-26 13:04:28 +00:00
parent a5ef1e17c8
commit 86bd8244c4
6 changed files with 253 additions and 245 deletions

View File

@ -1,220 +1,226 @@
#include <applicat.h> #include <applicat.h>
#include <execp.h> #include <execp.h>
#include <mask.h> #include <mask.h>
#include <scanner.h> #include <scanner.h>
#include <strings.h> #include <strings.h>
#include <utility.h> #include <utility.h>
#include <urldefid.h> #include <urldefid.h>
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
extern "C" { extern "C" {
#include <cpb.h> #include <cpb.h>
} }
#endif #endif
#include "ba0.h" #include "ba0.h"
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Picture Mask // Picture Mask
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
class TPicture_mask : public TMask class TPicture_mask : public TMask
{ {
PICTURE _picture; PICTURE _picture;
virtual void handler(WINDOW win, EVENT* ep); virtual void handler(WINDOW win, EVENT* ep);
public: public:
TPicture_mask(const char* name, int dx, int dy, short picture_id); TPicture_mask(const char* name, int dx, int dy, short picture_id);
~TPicture_mask(); ~TPicture_mask();
}; };
TPicture_mask::TPicture_mask(const char* name, int dx, int dy, TPicture_mask::TPicture_mask(const char* name, int dx, int dy,
short picture_id) short picture_id)
: TMask(name, 1, dx, dy), _picture(0L) : TMask(name, 1, dx, dy), _picture(0L)
{ {
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
_picture = cpb_picture_load(picture_id); _picture = cpb_picture_load(picture_id);
#endif #endif
} }
TPicture_mask::~TPicture_mask() TPicture_mask::~TPicture_mask()
{ {
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
if (_picture) if (_picture)
picture_free(_picture); picture_free(_picture);
#endif #endif
} }
void TPicture_mask::handler(WINDOW win, EVENT* ep) void TPicture_mask::handler(WINDOW win, EVENT* ep)
{ {
TMask::handler(win, ep); TMask::handler(win, ep);
if (ep->type == E_UPDATE) if (ep->type == E_UPDATE)
{ {
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
if (_picture) if (_picture)
cpb_win_picture_draw_at(win, _picture, 1, 1); cpb_win_picture_draw_at(win, _picture, 1, 1);
else else
#endif #endif
{ {
const int max = 16; const int max = 16;
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
TTemp_window w(win); TTemp_window w(win);
w.rect(i*2, i, max-i*2, max-i); w.rect(i*2, i, max-i*2, max-i);
} }
} }
} }
} }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Menu application // Menu application
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
class TMenu_application : public TApplication class TMenu_application : public TApplication
{ {
const char* _name; const char* _name;
enum { MAXLEVEL = 1024 }; enum { MAXLEVEL = 1024 };
int _first[MAXLEVEL]; int _first[MAXLEVEL];
TArray _menu; // TAG|DESCRIPTION|ACTION TArray _menu; // TAG|DESCRIPTION|ACTION
int _level, _max; int _level, _max;
protected: protected:
void load_menu(); void load_menu();
int do_level(); int do_level();
bool create(); bool create();
public: public:
TMenu_application(const char* name) : _name(name) {} TMenu_application(const char* name) : _name(name) {}
}; };
void TMenu_application::load_menu()
{ static short last_button = 0;
TScanner s(_name);
void TMenu_application::load_menu()
_max = -1; {
while (s.line().not_empty()) TScanner s(_name);
{
TToken_string* ts = new TToken_string(s.token()); _max = -1;
int l = ts->get_int(); while (s.line().not_empty())
{
if (l < _max) TToken_string* ts = new TToken_string(s.token());
{ int l = ts->get_int();
error_box("Item of level %d while %d was expected)", l, _max);
l = _max; if (l < _max)
} {
if (l > _max) error_box("Item of level %d while %d was expected)", l, _max);
{ l = _max;
if (l >= MAXLEVEL) }
{ if (l > _max)
error_box("Too many menu levels: %d", l); {
l = _max; if (l >= MAXLEVEL)
} {
_first[_max = l] = _menu.items(); error_box("Too many menu levels: %d", l);
} l = _max;
}
_menu.add(ts); _first[_max = l] = _menu.items();
} }
_first[++_max] = _menu.items();
} _menu.add(ts);
}
_first[++_max] = _menu.items();
HIDDEN bool menu_item_handler(TMask_field&f, KEY k) }
{
if (k == K_SPACE)
f.mask().stop_run(f.dlg()); HIDDEN bool menu_item_handler(TMask_field&f, KEY k)
return TRUE; {
} if (k == K_SPACE)
{
last_button = f.dlg();
int TMenu_application::do_level() f.mask().stop_run(K_AUTO_ENTER);
{ }
const int first = _first[_level]; return TRUE;
const int last = _first[_level+1]; }
const char* head = ((TToken_string&)_menu[first]).get(1);
const int width = 72; int TMenu_application::do_level()
const int heigth = 18; {
const int bwidth = 20; const int first = _first[_level];
const int x = width-bwidth-12; const int last = _first[_level+1];
const char* head = ((TToken_string&)_menu[first]).get(1);
TPicture_mask menu(head, width, heigth, BA0_PICTURE);
const int width = 72;
int y = 1; const int heigth = 18;
const int bwidth = 20;
#if XVT_OS == XVT_OS_WIN const int x = width-bwidth-12;
TString t(format("#%d", BMP_STOPREC));
#else TPicture_mask menu(head, width, heigth, BA0_PICTURE);
TString t;
#endif int y = 1;
TString item(32); #if XVT_OS == XVT_OS_WIN
for (int i = first+1; i < last; i++, y++) TString t(format("#%d", BMP_STOPREC));
{ #else
TToken_string& row = (TToken_string&)_menu[i]; TString t;
item = row.get(1); #endif
menu.add_button(100+y, 0, t, x, y, 1, 1);
menu.set_handler(100+y, menu_item_handler); TString item(32);
menu.add_static(-1, 0, item, x+4, y); for (int i = first+1; i < last; i++, y++)
} {
TToken_string& row = (TToken_string&)_menu[i];
t = first ? "Menu precedente" : "Fine"; item = row.get(1);
const short id = first ? DLG_CANCEL : DLG_QUIT; menu.add_button(100+y, 0, t, x, y, 1, 1);
menu.add_button(id, 0, t, x, heigth-2, bwidth, 2); menu.set_handler(100+y, menu_item_handler);
menu.add_static(-1, 0, item, x+4, y);
menu.run(); }
int k = menu.last_key();
int m =(k == K_QUIT || k == K_ESC) ? -1 : first+k-100; t = first ? "Menu precedente" : "Fine";
return m; const short id = first ? DLG_CANCEL : DLG_QUIT;
} menu.add_button(id, 0, t, x, heigth-2, bwidth, 2);
menu.run();
bool TMenu_application::create() int k = menu.last_key();
{ int m =(k == K_QUIT || k == K_ESC) ? -1 : first+last_button-100;
load_menu(); return m;
int refarray[256]; }
int i = 0;
_level = 0; bool TMenu_application::create()
while (i >= 0) {
{ load_menu();
int m = do_level(); int refarray[256];
if (m >= 0) int i = 0;
{
const char* option = ((TToken_string&)_menu[m]).get(2); _level = 0;
if (option && *option) while (i >= 0)
{ {
int l = atoi(option); int m = do_level();
if (l > 0) if (m >= 0)
{ {
const char* flags = ((TToken_string&)_menu[m]).get(3); const char* option = ((TToken_string&)_menu[m]).get(2);
if (option && *option)
if (flags && strchr(flags, 'F') != NULL) set_firm(); {
refarray[i++] = _level; int l = atoi(option);
if (l < _max) _level = l; if (l > 0)
} {
else const char* flags = ((TToken_string&)_menu[m]).get(3);
{
TExternal_app a(option); if (flags && strchr(flags, 'F') != NULL) set_firm();
a.run(); refarray[i++] = _level;
} if (l < _max) _level = l;
} }
} else
else _level = (--i >= 0) ? refarray[i] : 0; {
} TExternal_app a(option);
a.run();
stop_run(); }
return TRUE; }
} }
else _level = (--i >= 0) ? refarray[i] : 0;
int main(int argc, char** argv) }
{
const char* menu = (argc < 2) ? "prassi.mnu" : argv[1]; stop_run();
TMenu_application ma(menu); return TRUE;
ma.run(argc, argv, "PRASSI"); }
return TRUE;
} int main(int argc, char** argv)
{
const char* menu = (argc < 2) ? "prassi.mnu" : argv[1];
TMenu_application ma(menu);
ma.run(argc, argv, "PRASSI");
return TRUE;
}

View File

@ -1,4 +1,4 @@
#include <ba2300.h> #include "ba2300.h"
PAGE "SELECT PRINTER" -1 -1 40 15 PAGE "SELECT PRINTER" -1 -1 40 15

View File

@ -1,4 +1,4 @@
#include <ba2300.h> #include "ba2300.h"
PAGE "ADD/MODIFY PRINTER" -1 -1 64 17 PAGE "ADD/MODIFY PRINTER" -1 -1 64 17

View File

@ -1,4 +1,4 @@
#include <ba2300.h> #include "ba2300.h"
PAGE "VIEW PRINTER" -1 -1 64 17 PAGE "VIEW PRINTER" -1 -1 64 17

View File

@ -1,4 +1,4 @@
#include <ba2300.h> #include "ba2300.h"
PAGE "ADD NEW CODE" -1 -1 76 7 PAGE "ADD NEW CODE" -1 -1 76 7

View File

@ -1,5 +1,4 @@
#include <ba3100.h> #include <ba3100.h>
#include <batb%ban.h>
TOOLBAR "" 0 20 0 2 TOOLBAR "" 0 20 0 2
@ -11,19 +10,20 @@ PAGE "Tabella banche" -1 -1 78 18
NUMBER H_CODICEABI 5 NUMBER H_CODICEABI 5
BEGIN BEGIN
PROMPT 0 0 ""
FLAGS "HRZ" FLAGS "HRZ"
GROUP GR_SEARCH
USE %BAN SELECT CODTAB[6,10]="" USE %BAN SELECT CODTAB[6,10]=""
INPUT CODTAB[1,5] F_CODICEABI INPUT CODTAB[1,5] F_CODICEABI
DISPLAY "Codice ABI" CODTAB[1,5] DISPLAY "Codice ABI" CODTAB[1,5]
DISPLAY "Codice CAB" CODTAB[6,10] DISPLAY "Codice CAB" CODTAB[6,10]
DISPLAY "Istituto@50" S0 DISPLAY "Istituto@50" S0
OUTPUT F_ISTIT S0 OUTPUT F_ISTIT S0
GROUP GR_SEARCH
END END
NUMBER F_CODICEABI 5 NUMBER F_CODICEABI 5 5
BEGIN BEGIN
PROMPT 4 1 "Codice ABI " PROMPT 6 1 "Codice ABI "
FIELD %BAN->CODTAB[1,5] FIELD %BAN->CODTAB[1,5]
FLAGS "RZ" FLAGS "RZ"
KEY 1 KEY 1
@ -39,34 +39,33 @@ BEGIN
MESSAGE COPY,H_CODICEABI MESSAGE COPY,H_CODICEABI
END END
NUMBER F_CODICECAB 5 NUMBER F_CODICECAB 5 5
BEGIN BEGIN
PROMPT 29 1 "Codice CAB " PROMPT 28 1 "Codice CAB "
FIELD %BAN->CODTAB[6,10] FIELD %BAN->CODTAB[6,10]
FLAGS "RZ" FLAGS "RZ"
KEY 1 KEY 1
COPY ALL F_CODICEABI COPY ALL F_CODICEABI
MESSAGE SHOW,F_ISTIT|EMPTY HIDE,F_ISTIT
VALIDATE AUTOEXIT_FUNC 2 F_CODICEABI F_CODICECAB VALIDATE AUTOEXIT_FUNC 2 F_CODICEABI F_CODICECAB
MESSAGE SHOW,F_ISTIT
MESSAGE EMPTY HIDE,F_ISTIT
END END
NUMBER F_CODICEDIP 4 NUMBER F_CODICEDIP 4 4
BEGIN BEGIN
PROMPT 52 1 "Codice Dipendenza " PROMPT 50 1 "Codice Dipendenza "
FIELD %BAN->I0 FIELD %BAN->I0
FLAGS "RZ" FLAGS "RZ"
END END
STRING F_ISTIT 50 STRING F_ISTIT 50
BEGIN BEGIN
PROMPT 4 3 "Istituto " PROMPT 6 3 "Istituto "
FLAGS "D" FLAGS "D"
END END
STRING F_DENOM 50 STRING F_DENOM 50
BEGIN BEGIN
PROMPT 4 5 "Denominazione " PROMPT 6 5 "Denominazione "
FIELD %BAN->S0 FIELD %BAN->S0
KEY 2 KEY 2
USE %BAN KEY 2 USE %BAN KEY 2
@ -79,26 +78,30 @@ BEGIN
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
END END
GROUPBOX DLG_NULL 72 7
BEGIN
PROMPT 4 8 "Sede"
END
STRING F_INDIRIZZO 35 STRING F_INDIRIZZO 35
BEGIN BEGIN
PROMPT 4 7 "Indirizzo " PROMPT 6 9 "Indirizzo "
FIELD %BAN->S2 FIELD %BAN->S2
END END
STRING F_CIV 10 STRING F_CIV 10
BEGIN BEGIN
PROMPT 57 7 "N." PROMPT 60 9 "N. "
FIELD %BAN->S7 FIELD %BAN->S7
END END
STRING F_COMUNE 4 STRING F_COMUNE 4
BEGIN BEGIN
PROMPT 4 9 "Comune " PROMPT 6 11 "Comune "
FIELD %BAN->S5 FIELD %BAN->S5
USE LF_COMUNI USE LF_COMUNI
INPUT STATO "" INPUT STATO ""
INPUT COM F_COMUNE INPUT COM F_COMUNE
#include <comdcod.h>
OUTPUT F_COMUNE COM OUTPUT F_COMUNE COM
OUTPUT F_DENCOM DENCOM OUTPUT F_DENCOM DENCOM
OUTPUT F_PROV PROVCOM OUTPUT F_PROV PROVCOM
@ -110,26 +113,25 @@ END
STRING F_DENCOM 50 STRING F_DENCOM 50
BEGIN BEGIN
PROMPT 4 11 "Denominazione " PROMPT 6 12 "Denominazione "
USE LF_COMUNI KEY 2 USE LF_COMUNI KEY 2
INPUT DENCOM F_DENCOM INPUT DENCOM F_DENCOM
#include <comdden.h>
COPY OUTPUT F_COMUNE COPY OUTPUT F_COMUNE
CHECKTYPE NORMAL CHECKTYPE NORMAL
END END
STRING F_PROV 2 STRING F_PROV 2
BEGIN BEGIN
PROMPT 4 13 "Provincia " PROMPT 6 13 "Provincia "
FLAGS "D" FLAGS "D"
END END
STRING F_CAP 5 STRING F_CAP 5
BEGIN BEGIN
PROMPT 56 13 "C.A.P. " PROMPT 60 13 "C.A.P. "
FIELD %BAN->S3 FIELD %BAN->S3
END END
ENDPAGE ENDPAGE
ENDMASK ENDMASK