Aggiunta richiesta maschera se non specificata sulla riga di comando
git-svn-id: svn://10.65.10.50/trunk@492 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
aff1df6bf0
commit
8a0f601db7
217
ba/ba883.cpp
217
ba/ba883.cpp
@ -1,100 +1,117 @@
|
||||
#include <msksheet.h>
|
||||
#include <relapp.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Test Relapp
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TTestrel_application : public TRelation_application
|
||||
{
|
||||
const char* _maskname;
|
||||
const char* _num;
|
||||
|
||||
TRelation* _rel;
|
||||
TMask* _msk;
|
||||
|
||||
protected:
|
||||
virtual bool user_create();
|
||||
virtual bool user_destroy();
|
||||
virtual TMask* get_mask(int) { return _msk; }
|
||||
virtual bool changing_mask(int) { return FALSE;}
|
||||
virtual TRelation* get_relation() const { return _rel; }
|
||||
virtual int read(TMask& m) { m.autoload(); return NOERR; }
|
||||
virtual int write(const TMask&) { return NOERR; }
|
||||
virtual int rewrite(const TMask&) { return NOERR; }
|
||||
|
||||
public:
|
||||
TTestrel_application(const char* name, const char* num);
|
||||
};
|
||||
|
||||
TTestrel_application::TTestrel_application(const char* name, const char* num)
|
||||
: _maskname(name), _num(num),
|
||||
_msk(NULL), _rel(NULL)
|
||||
{}
|
||||
|
||||
|
||||
bool TTestrel_application::user_create()
|
||||
{
|
||||
_msk = new TMask(_maskname);
|
||||
|
||||
int id = atoi(_num);
|
||||
if (id > 0) _rel = new TRelation(id);
|
||||
else _rel = new TRelation(_num);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TTestrel_application::user_destroy()
|
||||
{
|
||||
delete _msk;
|
||||
delete _rel;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Testmask
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TTest_application : public TApplication
|
||||
{
|
||||
const char* _maskname;
|
||||
|
||||
protected:
|
||||
bool create() { dispatch_e_menu(BAR_ITEM(1)); return TRUE; }
|
||||
bool destroy() { return TRUE; }
|
||||
bool menu(MENU_TAG);
|
||||
|
||||
public:
|
||||
TTest_application(const char* name) : _maskname(name) {}
|
||||
};
|
||||
|
||||
bool TTest_application::menu(MENU_TAG)
|
||||
{
|
||||
TMask m(_maskname);
|
||||
KEY k = m.run();
|
||||
if (k == K_QUIT) stop_run();
|
||||
|
||||
return k != K_QUIT;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2) fatal_box("You should specify a mask");
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
TTest_application a(argv[1]);
|
||||
a.run(argc, argv, "Test Mask");
|
||||
}
|
||||
else
|
||||
{
|
||||
TTestrel_application a(argv[1], argv[2]);
|
||||
a.run(argc, argv, "Test Relation Application");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <msksheet.h>
|
||||
#include <relapp.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Test Relapp
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TTestrel_application : public TRelation_application
|
||||
{
|
||||
const char* _maskname;
|
||||
const char* _num;
|
||||
|
||||
TRelation* _rel;
|
||||
TMask* _msk;
|
||||
|
||||
protected:
|
||||
virtual bool user_create();
|
||||
virtual bool user_destroy();
|
||||
virtual TMask* get_mask(int) { return _msk; }
|
||||
virtual bool changing_mask(int) { return FALSE;}
|
||||
virtual TRelation* get_relation() const { return _rel; }
|
||||
virtual int read(TMask& m) { m.autoload(); return NOERR; }
|
||||
virtual int write(const TMask&) { return NOERR; }
|
||||
virtual int rewrite(const TMask&) { return NOERR; }
|
||||
|
||||
public:
|
||||
TTestrel_application(const char* name, const char* num);
|
||||
};
|
||||
|
||||
TTestrel_application::TTestrel_application(const char* name, const char* num)
|
||||
: _maskname(name), _num(num),
|
||||
_msk(NULL), _rel(NULL)
|
||||
{}
|
||||
|
||||
|
||||
bool TTestrel_application::user_create()
|
||||
{
|
||||
_msk = new TMask(_maskname);
|
||||
|
||||
int id = atoi(_num);
|
||||
if (id > 0) _rel = new TRelation(id);
|
||||
else _rel = new TRelation(_num);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TTestrel_application::user_destroy()
|
||||
{
|
||||
delete _msk;
|
||||
delete _rel;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Testmask
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TTest_application : public TApplication
|
||||
{
|
||||
TFilename _maskname;
|
||||
|
||||
protected:
|
||||
bool create() { dispatch_e_menu(BAR_ITEM(1)); return TRUE; }
|
||||
bool destroy() { return TRUE; }
|
||||
bool menu(MENU_TAG);
|
||||
|
||||
public:
|
||||
TTest_application(const char* name) : _maskname(name) {}
|
||||
};
|
||||
|
||||
bool TTest_application::menu(MENU_TAG)
|
||||
{
|
||||
KEY k;
|
||||
if (_maskname.empty())
|
||||
{
|
||||
TMask m("Inserire il nome della maschera", 1, 42, 4);
|
||||
m.add_string(101, 0, "", 1, 1, 40);
|
||||
m.efield(101).check_type(CHECK_REQUIRED);
|
||||
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
|
||||
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
|
||||
k = m.run();
|
||||
if (k == K_ENTER)
|
||||
_maskname = m.get(101);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
TMask m(_maskname);
|
||||
k = m.run();
|
||||
if (k == K_QUIT) stop_run();
|
||||
|
||||
return k != K_QUIT;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
TFilename mask;
|
||||
if (argc > 1)
|
||||
mask = argv[1];
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
TTest_application a(mask);
|
||||
a.run(argc, argv, "Test Mask");
|
||||
}
|
||||
else
|
||||
{
|
||||
TTestrel_application a(mask, argv[2]);
|
||||
a.run(argc, argv, "Test Relation Application");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user