ba0.cpp Tolta gestione selezione colori perche' ora e' in libreria

ba3100.cpp    Pulizie di primavera
ba3400.cpp    Pulizie di primavera
ba883.cpp     Simulazione TTab_application
batbreg.uml   Invertito ordine di output della ricerca sul codice


git-svn-id: svn://10.65.10.50/trunk@3891 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-11-12 14:58:53 +00:00
parent bf819df0be
commit 49a5aec854
5 changed files with 152 additions and 124 deletions

@ -13,12 +13,6 @@
#include <utility.h>
#include <urldefid.h>
#if XVT_OS == XVT_OS_WIN
#define STRICT
#include <windows.h>
#include <commdlg.h>
#endif
#include <nditte.h>
#include "ba0.h"
@ -262,15 +256,6 @@ COLOR TColor_mask::cid2color(short cid) const
return color[i];
}
#if XVT_OS == XVT_OS_WIN
inline COLORREF COLOR2RGB(COLOR c)
{
return RGB(XVT_COLOR_GET_RED(c), XVT_COLOR_GET_GREEN(c), XVT_COLOR_GET_BLUE(c));
}
#endif
bool TColor_mask::color_handler(TMask_field& f, KEY k)
{
bool ok = TRUE;
@ -280,57 +265,8 @@ bool TColor_mask::color_handler(TMask_field& f, KEY k)
TColor_mask& m = (TColor_mask&)f.mask();
const char* name = m.cid2name(f.dlg());
COLOR col = m.get_color_entry(name);
#if XVT_OS == XVT_OS_WIN
CHOOSECOLOR cc;
memset(&cc, 0, sizeof(cc));
HWND hwnd = (HWND)xvt_vobj_get_attr(m.win(), ATTR_NATIVE_WINDOW);
HDC hdc = GetDC(hwnd);
PALETTEENTRY* pe = NULL;
int max_entries = 0;
if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)
{
max_entries = GetDeviceCaps(hdc, SIZEPALETTE);
pe = new PALETTEENTRY[max_entries];
GetSystemPaletteEntries(hdc, 0, max_entries, pe);
}
ReleaseDC(hwnd, hdc);
unsigned long custom_colors[16];
for (int c = 0; c < 16; c++)
{
if (pe)
{
const PALETTEENTRY& e = pe[c < 8 ? c : max_entries - 16 + c];
custom_colors[c] = RGB(e.peRed, e.peGreen, e.peBlue);
}
else
{
const byte val = (c & 0x8) ? 255 : 127;
const byte red = (c & 0x1) ? val : 0;
const byte green = (c & 0x2) ? val : 0;
const byte blue = (c & 0x4) ? val : 0;
custom_colors[c] = RGB(red, green, blue);
}
}
if (pe)
{
delete pe;
pe = NULL;
}
cc.lStructSize = sizeof(cc);
cc.hwndOwner = hwnd;
cc.rgbResult = COLOR2RGB(col);
cc.lpCustColors = custom_colors;
cc.Flags = CC_RGBINIT;
ok = ChooseColor(&cc) != 0;
col = RGB2COLOR(GetRValue(cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult));
#endif
col = choose_color(col, m.win());
ok = col != COLOR_INVALID;
if (ok)
{
m.set_color_entry(name, col);

@ -10,7 +10,7 @@
#include "batbver.h"
#define REG_JOURNAL 5
#define Versamenti_table "%VER"
#define TAB_VERSAMENTI "%VER"
class TGeneric_table_app : public Tab_application
{
@ -24,6 +24,7 @@ class TGeneric_table_app : public Tab_application
void load_rec_in_disabled_fields(TMask& m);
void copy_rec_in_insert_fields(TMask& m);
// ------------------------------------------------------------
protected: // TRelation_application
virtual bool user_destroy() ;
virtual bool user_create() ;
@ -34,21 +35,26 @@ protected: // TRelation_application
virtual int rewrite(const TMask& m);
public:
bool exist_journal() {return _exist_journal;}
bool exist_journal() { return _exist_journal; }
char frequenza_versamenti(long firm, int year) const;
TGeneric_table_app() : _exist_journal(FALSE), _stampa_intest(FALSE) {}
TGeneric_table_app();
virtual ~TGeneric_table_app() {}
};
HIDDEN inline TGeneric_table_app& app() { return (TGeneric_table_app&) main_app();}
HIDDEN inline TGeneric_table_app& app() { return (TGeneric_table_app&)main_app(); }
TGeneric_table_app::TGeneric_table_app()
: _exist_journal(FALSE), _stampa_intest(FALSE), _ver(NULL)
{
}
// - tabella versamenti-specific -------------------------------
void TGeneric_table_app::load_rec_in_disabled_fields(TMask& m)
// carica il record del periodo precedente a quello immesso
// nei campi disabilitati relativi.
{
{
CHECK(_ver, "Null table");
TString key(m.get(F_ANNOES));
key << m.get(F_MESEES);
@ -97,7 +103,7 @@ void TGeneric_table_app::copy_rec_in_insert_fields(TMask& m)
void TGeneric_table_app::init_insert_mode(TMask& m)
{
TString n(get_tabname());
const TString& n = get_tabname();
if (n == "REG")
{
const long ditta = get_firm();
@ -110,8 +116,7 @@ void TGeneric_table_app::init_insert_mode(TMask& m)
_oldditta = ditta;
_oldanno = anno;
TTable reg(get_tabname());
reg.zero();
TTable reg("REG");
reg.put("CODTAB", m.get(F_ANNO));
TRectype to(reg.curr());
@ -122,7 +127,7 @@ void TGeneric_table_app::init_insert_mode(TMask& m)
}
}
else
if (n == Versamenti_table)
if (n == TAB_VERSAMENTI)
{
// Se il record e' nuovo prima carica il record precedente
load_rec_in_disabled_fields(m);
@ -135,7 +140,7 @@ void TGeneric_table_app::init_insert_mode(TMask& m)
void TGeneric_table_app::init_modify_mode(TMask& m)
{
Tab_application::init_modify_mode(m);
TString n(get_tabname());
const TString& n = get_tabname();
if (n == "REG")
{
TString16 config;
@ -147,7 +152,7 @@ void TGeneric_table_app::init_modify_mode(TMask& m)
m.enable(F_CONFIG, what >= 0);
}
else
if (n == Versamenti_table)
if (n == TAB_VERSAMENTI)
load_rec_in_disabled_fields(m);
}
@ -404,51 +409,54 @@ HIDDEN bool mese_handler(TMask_field& f, KEY k)
bool TGeneric_table_app::user_create()
{
Tab_application::user_create();
const TString& name = get_tabname();
TMask& mask = *get_mask();
if (name == "REG")
bool ok = Tab_application::user_create();
if (ok)
{
mask.set_handler(F_TIPO, tiporeg_handler);
mask.set_handler(F_PRINTER, printer_handler);
const TString& name = get_tabname();
TMask& mask = *get_mask();
TConfig st(CONFIG_STUDIO, "cg");
_stampa_intest = st.get_bool("StiReg");
}
if (name == "%DEL")
{
mask.set_handler(F_MESEDEL, mese_handler);
mask.set_handler(F_IMPORTO, impdel_handler);
mask.set_handler(F_INTERESSI, intdel_handler);
mask.set_handler(F_BANCA1, coddel_handler);
mask.set_handler(F_CONCESSIONE, coddel_handler);
}
if (name == "CAM")
set_search_field(FLD_TABCAM_D0);
if (name == Versamenti_table)
{
_ver = new TTable(Versamenti_table);
_ver->put("CODTAB","199301");
if (_ver->read() != NOERR) // Se %VER non esiste la crea
if (name == "REG")
{
mask.set_handler(F_TIPO, tiporeg_handler);
mask.set_handler(F_PRINTER, printer_handler);
TConfig st(CONFIG_STUDIO, "cg");
_stampa_intest = st.get_bool("StiReg");
}
if (name == "%DEL")
{
mask.set_handler(F_MESEDEL, mese_handler);
mask.set_handler(F_IMPORTO, impdel_handler);
mask.set_handler(F_INTERESSI, intdel_handler);
mask.set_handler(F_BANCA1, coddel_handler);
mask.set_handler(F_CONCESSIONE, coddel_handler);
}
if (name == "CAM")
set_search_field(FLD_TABCAM_D0);
if (name == TAB_VERSAMENTI)
{
_ver = new TTable(TAB_VERSAMENTI);
_ver->put("CODTAB","199301");
_ver->put("R0","1.5"); _ver->put("R1","1.5");
_ver->put("R2","1.5"); _ver->put("R3","1.5"); _ver->put("R4","1.5");
_ver->put("R5","50500"); _ver->put("R7","200000");
_ver->put("R11","88"); _ver->put("R12","88");
if (_ver->write() != NOERR)
error_box("Errore %d in scrittura sulla tabella %VER",_ver->status());
if (_ver->read() != NOERR) // Se %VER non esiste la crea
{
_ver->put("CODTAB","199301");
_ver->put("R0","1.5"); _ver->put("R1","1.5");
_ver->put("R2","1.5"); _ver->put("R3","1.5"); _ver->put("R4","1.5");
_ver->put("R5","50500"); _ver->put("R7","200000");
_ver->put("R11","88"); _ver->put("R12","88");
if (_ver->write() != NOERR)
error_box("Errore %d in scrittura sulla tabella %VER",_ver->status());
}
}
}
return TRUE;
return ok;
}
bool TGeneric_table_app::user_destroy()
{
TString n(get_tabname());
if (n == Versamenti_table)
const TString& n = get_tabname();
if (n == TAB_VERSAMENTI)
delete _ver;
return Tab_application::user_destroy();
}
@ -471,7 +479,8 @@ int TGeneric_table_app::rewrite(const TMask& m)
int ba3100(int argc, char* argv[])
{
TGeneric_table_app a ;
a.run(argc, argv, "Tabella");
TGeneric_table_app* a = new TGeneric_table_app;
a->run(argc, argv, "Tabella");
delete a; // Bella battuta!
return 0;
}

@ -31,12 +31,12 @@ TTestrel_application::TTestrel_application(const char* name, const char* num)
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);
_msk = new TMask(_maskname);
return TRUE;
}
@ -44,6 +44,7 @@ bool TTestrel_application::user_destroy()
{
delete _msk;
delete _rel;
return TRUE;
}

@ -1,11 +1,85 @@
#include <time.h>
#include <applicat.h>
#include <mask.h>
#include <progind.h>
#include <relapp.h>
#include <urldefid.h>
#include <relapp.h>
///////////////////////////////////////////////////////////
class TTab_application : public TRelation_application
{
TMask* _msk;
TRelation* _rel;
protected:
virtual TMask* get_mask(int mode);
virtual TRelation* get_relation() const;
virtual bool changing_mask(int mode);
virtual bool user_create();
virtual bool user_destroy();
public:
TTab_application();
virtual ~TTab_application();
};
// @cmember Costruttore
TTab_application::TTab_application()
: _msk(NULL), _rel(NULL)
{ }
// @cmember Distruttore
TTab_application::~TTab_application()
{ }
// @cmember Indica se la futura <mf TTab_application::get_mask> ritornera' una maschera diversa
// dalla corrente.
bool TTab_application::changing_mask(int mode)
{ return FALSE; }
// @cmember Richiede la maschera da usare
TMask* TTab_application::get_mask(int mode)
{
CHECK(_msk, "Null mask");
return _msk;
}
// @cmember Ritorna la relazione da modificare
TRelation* TTab_application::get_relation() const
{
CHECK(_rel, "Null relation");
return _rel;
}
bool TTab_application::user_create()
{
if (argc() < 3)
return FALSE;
TString16 tabname = argv(2);
tabname.upper();
_rel = new TRelation(tabname);
TString16 t(tabname);
if (t[0] == '%') t.ltrim(1);
TString16 m; m << "BATB" << t;
_msk = new TMask(m) ;
TString80 tit = _msk->get_caption();
set_title(tit);
return TRUE;
}
bool TTab_application::user_destroy()
{
if (_msk) delete _msk;
if (_rel) delete _rel;
return TRUE;
}
///////////////////////////////////////////////////////////
// Test Relapp
@ -41,12 +115,12 @@ TTestrel_application::TTestrel_application(const char* name, const char* num)
bool TTestrel_application::user_create()
{
_msk = new TMask(_maskname);
int id = atoi(_num);
const int id = atoi(_num);
if (id > 0) _rel = new TRelation(id);
else _rel = new TRelation(_num);
_msk = new TMask(_maskname);
return TRUE;
}
@ -235,8 +309,16 @@ int main(int argc, char** argv)
}
else
{
TTestrel_application a(argv[1], argv[2]);
a.run(argc, argv, "Test Relation Application");
if (isdigit(argv[2][0]))
{
TTestrel_application a(argv[1], argv[2]);
a.run(argc, argv, "Test Relation Application");
}
else
{
TTab_application a;
a.run(argc, argv, "Test Table Application");
}
}
return 0;

@ -45,8 +45,8 @@ BEGIN
DISPLAY "Codice" CODTAB[5,7]
DISPLAY "Descrizione @50" S0
DISPLAY "Tipo" I0
OUTPUT F_CODICE CODTAB[5,7]
OUTPUT F_ANNO CODTAB[1,4]
OUTPUT F_CODICE CODTAB[5,7]
OUTPUT F_DESCR S0
CHECKTYPE REQUIRED
MESSAGE COPY,20@