Patch level : 2.0 nopatch

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Correzioni al menu principale ed alla gestione dei codici uffici in agagrafica


git-svn-id: svn://10.65.10.50/trunk@10901 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2003-03-11 11:09:18 +00:00
parent 8faed1fa70
commit 601b3f546b
5 changed files with 96 additions and 103 deletions

View File

@ -113,7 +113,7 @@ inline TMenu_application& app()
class TPicture_mask : public TMask class TPicture_mask : public TMask
{ {
TImage* _image; TSubmenu* _submenu;
protected: // TMask protected: // TMask
virtual void update(); virtual void update();
@ -122,28 +122,12 @@ protected: // TMask
public: public:
virtual bool stop_run(KEY key); virtual bool stop_run(KEY key);
void set_current(const TSubmenu& sm);
void set_image(TImage* image); TPicture_mask(const char* name, int dx, int dy, const TSubmenu& sm, int x = -1, int y = -1);
TPicture_mask(const char* name, int dx, int dy, TImage* image, int x = -1, int y = -1);
virtual ~TPicture_mask(); virtual ~TPicture_mask();
}; };
void TPicture_mask::set_image(TImage* image)
{
if (image && image->ok())
{
if (image != _image)
{
_image = image;
_image->set_palette(win());
force_update();
}
}
else
_image = NULL;
}
bool TPicture_mask::stop_run(KEY key) bool TPicture_mask::stop_run(KEY key)
{ {
if (key == K_FORCE_CLOSE) if (key == K_FORCE_CLOSE)
@ -153,7 +137,8 @@ bool TPicture_mask::stop_run(KEY key)
void TPicture_mask::update() void TPicture_mask::update()
{ {
if (_image && _image->ok()) TImage& image = _submenu->image();
if (image.ok())
{ {
int x = 1, y = 1, maxx = 640, maxy = 480; // Default values int x = 1, y = 1, maxx = 640, maxy = 480; // Default values
@ -166,12 +151,12 @@ void TPicture_mask::update()
maxx = client.right - rctree.right - 12; maxx = client.right - rctree.right - 12;
maxy = client.bottom - 4 * ROWY; maxy = client.bottom - 4 * ROWY;
const double ratiox = double(maxx) / _image->width(); const double ratiox = double(maxx) / image.width();
const double ratioy = double(maxy) / _image->height(); const double ratioy = double(maxy) / image.height();
const double ratio = min(ratiox, ratioy); const double ratio = min(ratiox, ratioy);
maxx = int(ratio * _image->width()); maxx = int(ratio * image.width());
maxy = int(ratio * _image->height()); maxy = int(ratio * image.height());
x = client.right - maxx - 4; x = client.right - maxx - 4;
y = (client.bottom - maxy) / 2; y = (client.bottom - maxy) / 2;
@ -183,12 +168,12 @@ void TPicture_mask::update()
maxx = rctbut.left - CHARX; maxx = rctbut.left - CHARX;
maxy = client.bottom - 4 * ROWY; maxy = client.bottom - 4 * ROWY;
const double ratiox = double(maxx) / _image->width(); const double ratiox = double(maxx) / image.width();
const double ratioy = double(maxy) / _image->height(); const double ratioy = double(maxy) / image.height();
const double ratio = min(ratiox, ratioy); const double ratio = min(ratiox, ratioy);
maxx = int(ratio * _image->width()); maxx = int(ratio * image.width());
maxy = int(ratio * _image->height()); maxy = int(ratio * image.height());
x = 1; x = 1;
y = 1; y = 1;
} }
@ -196,7 +181,7 @@ void TPicture_mask::update()
RCT dst; RCT dst;
::xvt_rect_set(&dst, x, y, x+maxx, y+maxy); ::xvt_rect_set(&dst, x, y, x+maxx, y+maxy);
if (::xvt_dwin_is_update_needed(win(), &dst)) if (::xvt_dwin_is_update_needed(win(), &dst))
_image->draw(win(), dst); image.draw(win(), dst);
} }
} }
@ -232,11 +217,16 @@ void TPicture_mask::on_firm_change()
force_update(); force_update();
} }
TPicture_mask::TPicture_mask(const char* name, int dx, int dy, void TPicture_mask::set_current(const TSubmenu& sm)
TImage* image, int x, int y)
: TMask(name, 1, dx, dy, x, y)
{ {
set_image(image); _submenu = (TSubmenu*)&sm;
}
TPicture_mask::TPicture_mask(const char* name, int dx, int dy,
const TSubmenu& submenu, int x, int y)
: TMask(name, 1, dx, dy, x, y), _submenu(NULL)
{
set_current(submenu);
} }
TPicture_mask::~TPicture_mask() TPicture_mask::~TPicture_mask()
@ -490,7 +480,7 @@ const char* TColor_mask::cid2name(short cid) const
COLOR TColor_mask::cid2color(short cid) const COLOR TColor_mask::cid2color(short cid) const
{ {
COLOR color[] = { COLOR_LTGRAY, COLOR_WHITE, COLOR_GRAY, COLOR color[] = { COLOR_LTGRAY, COLOR_WHITE, COLOR_GRAY,
COLOR_BLACK, COLOR_WHITE, blend_colors(COLOR_WHITE, COLOR_YELLOW, 85), COLOR_BLACK, COLOR_WHITE, blend_colors(COLOR_WHITE, COLOR_YELLOW, 0.85),
COLOR_BLACK, COLOR_YELLOW, COLOR_BLACK, COLOR_YELLOW,
COLOR_DKGRAY, COLOR_LTGRAY, COLOR_DKGRAY, COLOR_LTGRAY,
COLOR_LTGRAY, COLOR_WHITE, COLOR_GRAY }; COLOR_LTGRAY, COLOR_WHITE, COLOR_GRAY };
@ -551,9 +541,7 @@ int TMenu_application::do_level()
const TSubmenu& curr = _menu.current(); const TSubmenu& curr = _menu.current();
const int bwidth = 20; const int bwidth = 20;
TImage& image = _menu.image(curr.picture()); TPicture_mask mask(curr.caption(), -4, -4, curr);
TPicture_mask mask(curr.caption(), -4, -4, &image);
CHECK(_mask == NULL, "Two masks are better than one?"); CHECK(_mask == NULL, "Two masks are better than one?");
_mask = &mask; _mask = &mask;
@ -661,6 +649,10 @@ void TMenu_application::reload_images()
bool TMenu_application::check_user() bool TMenu_application::check_user()
{ {
// Disabilita le voci di personalizzazione
for (int mi = 2; mi <= 6; mi++)
disable_menu_item(MENU_ITEM(mi));
TString utente(user()); TString utente(user());
#ifdef _DEMO_ #ifdef _DEMO_
@ -778,8 +770,9 @@ bool TMenu_application::check_user()
prawin.set("User", utente); prawin.set("User", utente);
} }
enable_menu_item(OPTIONS_MENU); // Abilita le voci di personalizzazione
enable_menu_item(PREFERRED_MENU); for (int mi = 2; mi <= 6; mi++)
enable_menu_item(MENU_ITEM(mi));
customize_colors(); // Aggiorna set di colori customize_colors(); // Aggiorna set di colori
reload_images(); // Ritrasparentizza immagini reload_images(); // Ritrasparentizza immagini
@ -1167,9 +1160,8 @@ bool TMenu_application::tree_handler(TMask_field& f, KEY k)
if (mi.is_submenu() && mt.expanded()) if (mi.is_submenu() && mt.expanded())
{ {
TMenu& menu = mt.curr_submenu().menu(); TMenu& menu = mt.curr_submenu().menu();
TImage& image = menu.image(menu.current().picture()); TPicture_mask& pm = (TPicture_mask&)f.mask();
TPicture_mask& pm = (TPicture_mask&)f.mask(); pm.set_current(menu.current());
pm.set_image(&image);
} }
} }
return TRUE; return TRUE;
@ -1456,9 +1448,7 @@ int TMenu_application::do_tree()
{ {
_menu.jumpto_root(); _menu.jumpto_root();
const TSubmenu& curr = _menu.current(); const TSubmenu& curr = _menu.current();
TPicture_mask mask(curr.caption(), 0, 0, curr, 0, 0);
TImage& image = _menu.image(curr.picture());
TPicture_mask mask(curr.caption(), 0, 0, &image, 0, 0);
CHECK(_mask == NULL, "Two masks are better than one?"); CHECK(_mask == NULL, "Two masks are better than one?");
_mask = &mask; _mask = &mask;
@ -1575,13 +1565,10 @@ int ba0100(int argc, char** argv)
if (user().blank()) if (user().blank())
{ {
TConfig prawin(CONFIG_INSTALL, "Main"); TConfig prawin(CONFIG_INSTALL, "Main");
user() = prawin.get("User"); TString16 u = prawin.get("User");
if (user().blank() || user() == dongle().administrator()) if (u.blank())
{ u = dongle().administrator();
char name[32]; user() = u;
if (aga_get_user_name(name, 32))
user() = name;
}
} }
TFilename menu = (argc < 2) ? MEN_FILE : argv[1]; TFilename menu = (argc < 2) ? MEN_FILE : argv[1];

View File

@ -402,7 +402,9 @@ bool TMenu::read(const char* name, TString& root)
TString str(255); TString str(255);
bool first = TRUE; bool first = TRUE;
TScanner scanner(name); TFilename menuname = name;
menuname.custom_path();
TScanner scanner(menuname);
while (scanner.ok()) while (scanner.ok())
{ {
const TString& line = first ? scanner.line() : scanner.pop(); const TString& line = first ? scanner.line() : scanner.pop();
@ -576,12 +578,14 @@ TImage& TMenu::image(const char* name)
TTimed_image* image = (TTimed_image*)_images.objptr(name); TTimed_image* image = (TTimed_image*)_images.objptr(name);
if (image == NULL) if (image == NULL)
{ {
if (fexist(name)) TFilename realname = name;
realname.custom_path();
if (realname.exist())
{ {
if (_images.items() == 0) if (_images.items() == 0)
_default_bmp = name; // Store default bitmap name _default_bmp = name; // Store default bitmap name
image = new TTimed_image(name); image = new TTimed_image(realname);
if (can_be_transparent(*image)) if (can_be_transparent(*image))
image->convert_transparent_color(MASK_BACK_COLOR); image->convert_transparent_color(MASK_BACK_COLOR);
_images.add(name, image); _images.add(name, image);
@ -590,7 +594,7 @@ TImage& TMenu::image(const char* name)
{ {
image = (TTimed_image*)_images.objptr(_default_bmp); image = (TTimed_image*)_images.objptr(_default_bmp);
if (image == NULL) if (image == NULL)
fatal_box("%s %s", TR("Impossibile trovare l'immagine"), (const char*)_default_bmp); fatal_box(FR("Impossibile trovare l'immagine %s"), (const char*)_default_bmp);
} }
if (_images.items() > 3) if (_images.items() > 3)

View File

@ -325,19 +325,6 @@ bool TMenulist_images::can_be_transparent(const TImage& i) const
inline int fast_hypot(int x, int y) inline int fast_hypot(int x, int y)
{ {
// return (int)sqrt(double(x*x + y*y)); // Pitagora
/*
const int s = x*x + y*y;
int h = 0;
for (int i = 512; i > 0; i /= 2)
{
const int k = h+i;
if (k*k <= s)
h = k;
}
return h;
*/
// loop unrolled // loop unrolled
#define TEST(s, h, i) { const int k = h+i; if (k*k <= s) h = k; } #define TEST(s, h, i) { const int k = h+i; if (k*k <= s) h = k; }
const int s = x*x + y*y; const int s = x*x + y*y;
@ -352,10 +339,12 @@ TObject* TMenulist_images::key2obj(const char* key)
{ {
TImage* img = NULL; TImage* img = NULL;
if (fexist(key)) TFilename name = key;
name.custom_path();
if (name.exist())
{ {
TWait_cursor hourglass; TWait_cursor hourglass;
TImage image(key); TImage image(name);
if (can_be_transparent(image)) if (can_be_transparent(image))
image.convert_transparent_color(NORMAL_BACK_COLOR); image.convert_transparent_color(NORMAL_BACK_COLOR);
@ -368,15 +357,16 @@ TObject* TMenulist_images::key2obj(const char* key)
{ {
for (int x = w-1; x >= 0; x--) for (int x = w-1; x >= 0; x--)
{ {
int perc = 0;
const int r = fast_hypot(x-w/2, y-h/2); const int r = fast_hypot(x-w/2, y-h/2);
if (r < radius) if (r < radius)
{ {
perc = 75 - (75 * r / radius); const double perc = 0.8 - (0.8 * r / radius);
} COLOR col = image.get_pixel(x, y);
COLOR col = image.get_pixel(x, y); COLOR bri = blend_colors(col, NORMAL_BACK_COLOR, perc);
COLOR bri = blend_colors(col, NORMAL_BACK_COLOR, perc); image.set_pixel(x, y, bri);
image.set_pixel(x, y, bri); }
else
image.set_pixel(x, y, NORMAL_BACK_COLOR);
} }
} }
const clock_t stop_timer = clock()-start_timer; const clock_t stop_timer = clock()-start_timer;

View File

@ -271,7 +271,7 @@ bool gest_uff_imp(TMask_field& f, KEY key)
if (!f.to_check(key, TRUE)) if (!f.to_check(key, TRUE))
return TRUE; return TRUE;
TString cod_com; TString8 cod_com;
if ( giuridica ) if ( giuridica )
{ {
@ -292,26 +292,34 @@ bool gest_uff_imp(TMask_field& f, KEY key)
if (cod_com.empty()) if (cod_com.empty())
return TRUE; return TRUE;
TString16 cod("|"); cod<< cod_com; TString8 cod("|"); cod<< cod_com;
const TRectype & comune = cache().get(LF_COMUNI, cod); const TRectype & comune = cache().get(LF_COMUNI, cod);
msk.set(F_IMP_DENCOM, comune.get("DENCOM")); msk.set(F_IMP_DENCOM, comune.get("DENCOM"));
msk.set(F_IMP_PROVCOM, comune.get("PROVCOM")); msk.set(F_IMP_PROVCOM, comune.get("PROVCOM"));
msk.set(F_UFFUUE, comune.get("CODUUE1"),TRUE); msk.set(F_UFFUUE, comune.get("CODUUE1"));
msk.check_field(F_UFFUUE); msk.check_field(F_UFFUUE);
TString80 s(comune.get(N_IMPDIR1)) ; TString80 s(comune.get(N_IMPDIR1)) ;
if (s.empty()) s = comune.get(N_IMPDIR2) ; if (s.empty()) s = comune.get(N_IMPDIR2) ;
if (s.empty()) s = comune.get(N_IMPDIR3) ; if (s.empty()) s = comune.get(N_IMPDIR3) ;
if (msk.get(F_UFFIIDD).empty() || msk.is_running()) if (msk.get(F_UFFIIDD).empty() || msk.is_running())
msk.set(F_UFFIIDD, s, TRUE); {
msk.set(F_UFFIIDD, s);
msk.check_field(F_UFFIIDD);
}
s = comune.get(N_IVA1); s = comune.get(N_IVA1);
if (s.empty()) s = comune.get(N_IVA2) ; if (s.empty()) s = comune.get(N_IVA2) ;
if (s.empty()) s = comune.get(N_IVA3) ; if (s.empty()) s = comune.get(N_IVA3) ;
if (msk.get(F_UFFIVA).empty() || msk.is_running()) if (msk.get(F_UFFIVA).empty() || msk.is_running())
msk.set(F_UFFIVA, s, TRUE); {
msk.set(F_UFFREG, comune.get("UFFREG"), TRUE); msk.set(F_UFFIVA, s);
msk.check_field(F_UFFIVA);
}
msk.set(F_UFFREG, comune.get("UFFREG"));
msk.check_field(F_UFFREG);
if (msk.get_bool(F_TITCF)) if (msk.get_bool(F_TITCF))
{ {
if (msk.get(F_UFFCONC).empty() || msk.is_running()) if (msk.get(F_UFFCONC).empty() || msk.is_running())
@ -320,9 +328,15 @@ bool gest_uff_imp(TMask_field& f, KEY key)
} }
const bool fisica = ! giuridica; const bool fisica = ! giuridica;
if (fisica && (msk.get(F_CODREG96).empty() || msk.is_running())) if (fisica && (msk.get(F_CODREG96).empty() || msk.is_running()))
msk.set(F_CODREG96, comune.get("CODREG"), TRUE); {
msk.set(F_UFFCONC_P, comune.get("UFFCONC"), TRUE); msk.set(F_CODREG96, comune.get("CODREG"));
msk.set(F_UFFSERV, comune.get("UFFCSERV"), TRUE); msk.check_field(F_CODREG96);
}
msk.set(F_UFFCONC_P, comune.get("UFFCONC"));
msk.check_field(F_UFFCONC_P);
msk.set(F_UFFSERV, comune.get("UFFCSERV"));
msk.check_field(F_UFFSERV);
msk.set(F_CODCONTR_EP, comune.get("UFFESPROV").mid(1, 2)); msk.set(F_CODCONTR_EP, comune.get("UFFESPROV").mid(1, 2));
msk.set(F_CODCONTR_EC, comune.get("UFFESCOM")); msk.set(F_CODCONTR_EC, comune.get("UFFESCOM"));
@ -399,12 +413,11 @@ bool cod_reg(TMask_field& f, KEY key)
if (cod_com.empty()) if (cod_com.empty())
cod_com = msk.get(giuridica ? FLD_AG2_COMRES : FLD_AF1_COMRES) ; cod_com = msk.get(giuridica ? FLD_AG2_COMRES : FLD_AF1_COMRES) ;
if (cod_com.not_empty()) if (cod_com.not_empty() && !msk.field(F_CODREG96).empty())
{ {
TString16 key("|"); key << cod_com; TString16 key("|"); key << cod_com;
const TRectype & comune = cache().get(LF_COMUNI, key); const TRectype & comune = cache().get(LF_COMUNI, key);
app.set_reset_codreg(msk.get(F_CODREG96) == comune.get("CODREG"));
app.set_reset_codreg((!comune.empty()) && msk.get(F_CODREG96) == comune.get("CODREG"));
} }
} }
return TRUE; return TRUE;
@ -542,7 +555,6 @@ bool TPersone_app::user_create()
_rel[MSKG] = new TRelation(LF_ANAG); _rel[MSKG] = new TRelation(LF_ANAG);
_rel[MSKG]->add(LF_ANAGGIU, "CODANAGR=CODANAGR", 1); _rel[MSKG]->add(LF_ANAGGIU, "CODANAGR=CODANAGR", 1);
if (argc() > 3) if (argc() > 3)
{ {
get_mask(MODE_QUERY); get_mask(MODE_QUERY);

View File

@ -902,19 +902,19 @@ FIELD LF_ANAG->RFDIVERSA
HELP "Dire se il domicilio fiscale e' diverso della sede legale" HELP "Dire se il domicilio fiscale e' diverso della sede legale"
END END
NUMBER F_CODREG96 2 STRING F_CODREG96 2
BEGIN BEGIN
PROMPT 2 9 "Cod.regione al 1 Gennaio " PROMPT 2 9 "Cod.regione al 1 Gennaio "
FIELD LF_ANAGFIS->CODREG96 FIELD LF_ANAGFIS->CODREG96
FLAGS "RZ" FLAGS "Z"
USE %RGI USE %RGI
INPUT CODTAB F_CODREG96 INPUT CODTAB F_CODREG96
DISPLAY "Codice" CODTAB DISPLAY "Codice" CODTAB
DISPLAY "Denominazione@50" S0 DISPLAY "Denominazione@50" S0
OUTPUT F_CODREG96 CODTAB OUTPUT F_CODREG96 CODTAB
OUTPUT F_DESREG96 S0 OUTPUT F_DESREG96 S0
CHECKTYPE NORMAL CHECKTYPE NORMAL
WARNING "Regione assente" WARNING "Regione assente"
END END
STRING F_DESREG96 50 40 STRING F_DESREG96 50 40