Patch level : aga 2.0 387
Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione P@rtners 2.0 patch 387 Da terminare. git-svn-id: svn://10.65.10.50/trunk@10769 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
0ae61deb48
commit
a5fed37e67
2593
ba/ba0.cpp
2593
ba/ba0.cpp
File diff suppressed because it is too large
Load Diff
1601
ba/ba0100.cpp
Executable file
1601
ba/ba0100.cpp
Executable file
File diff suppressed because it is too large
Load Diff
2
ba/ba0100.h
Executable file
2
ba/ba0100.h
Executable file
@ -0,0 +1,2 @@
|
||||
int ba0100(int argc, char** argv);
|
||||
|
657
ba/ba0101.cpp
Executable file
657
ba/ba0101.cpp
Executable file
@ -0,0 +1,657 @@
|
||||
#include <applicat.h>
|
||||
#include <currency.h>
|
||||
#include <dongle.h>
|
||||
#include <execp.h>
|
||||
#include <mask.h>
|
||||
#include <prefix.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include "ba0100a.h"
|
||||
#include "ba0101.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Menu management
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
static int get_next_string(const char* s, int from, TString& str, char& brace)
|
||||
{
|
||||
if (from < 0)
|
||||
return -1;
|
||||
|
||||
char closing = '\0';
|
||||
int start = 0;
|
||||
|
||||
for (int i = from; s[i]; i++)
|
||||
{
|
||||
if (s[i] == closing)
|
||||
{
|
||||
char* fine = (char*)(s + i);
|
||||
const char old = *fine;
|
||||
*fine = '\0';
|
||||
str = s + start;
|
||||
*fine = old;
|
||||
return i+1;
|
||||
}
|
||||
|
||||
if (!closing)
|
||||
{
|
||||
switch(s[i])
|
||||
{
|
||||
case '\'':
|
||||
case '"' : closing = s[i]; break;
|
||||
case '<' : closing = '>' ; break;
|
||||
case '[' : closing = ']' ; break;
|
||||
default : break;
|
||||
}
|
||||
if (closing)
|
||||
{
|
||||
start = i+1;
|
||||
brace = s[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int get_next_int(const char* s, int from, int& val)
|
||||
{
|
||||
if (from < 0)
|
||||
return -1;
|
||||
|
||||
const char* start = NULL;
|
||||
for (int i = from; s[i]; i++)
|
||||
{
|
||||
if (start == NULL)
|
||||
{
|
||||
if (isdigit(s[i]))
|
||||
start = s+i;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s[i] == ',')
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start != NULL)
|
||||
val = atoi(start);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TTimed_image
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TTimed_image : public TImage
|
||||
{
|
||||
clock_t _last_time;
|
||||
|
||||
public:
|
||||
clock_t touch() { return _last_time = clock(); }
|
||||
clock_t last_time() const { return _last_time; }
|
||||
|
||||
TTimed_image(const char* name) : TImage(name) { touch(); }
|
||||
virtual ~TTimed_image() { }
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Menu Item
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TMenuitem::TMenuitem(TSubmenu* sm)
|
||||
: _submenu(sm),
|
||||
_exist(-1), _firm(FALSE), _password(FALSE), _reloadmenu(FALSE),
|
||||
_color(NORMAL_COLOR), _icon(0)
|
||||
{ }
|
||||
|
||||
TMenu& TMenuitem::menu() const
|
||||
{ return _submenu->menu(); }
|
||||
|
||||
void TMenuitem::create(const char* t)
|
||||
{
|
||||
TString16 flags;
|
||||
char brace;
|
||||
int start = 0;
|
||||
|
||||
start = get_next_string(t, start, _caption, brace);
|
||||
start = get_next_string(t, start, _action, _type);
|
||||
start = get_next_string(t, start, flags, brace);
|
||||
start = get_next_int(t, start, _icon);
|
||||
_caption = dictionary_translate(_caption);
|
||||
|
||||
for (int i = flags.len()-1; i >= 0; i--)
|
||||
{
|
||||
switch(toupper(flags[i]))
|
||||
{
|
||||
case 'D': _exist = FALSE; break;
|
||||
case 'F': _firm = TRUE; break;
|
||||
case 'P': _password = TRUE; break;
|
||||
case 'R': _reloadmenu = TRUE; break;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_type == '<')
|
||||
{
|
||||
if (_action.find('.') < 0)
|
||||
_action << ".men";
|
||||
if (fexist(_action))
|
||||
menu().read(_action, _action);
|
||||
else
|
||||
_action.cut(0);
|
||||
_type = '[';
|
||||
}
|
||||
|
||||
if (_action.empty())
|
||||
{
|
||||
_exist = FALSE;
|
||||
_enabled = FALSE;
|
||||
}
|
||||
|
||||
// Controlla lo stato di aggiornamento
|
||||
if (_enabled && is_program())
|
||||
_enabled = !menu().is_dangerous(_action);
|
||||
}
|
||||
|
||||
int TMenuitem::icon() const
|
||||
{
|
||||
return _icon;
|
||||
}
|
||||
|
||||
bool TMenuitem::enabled() const
|
||||
{
|
||||
bool yes = FALSE;
|
||||
if (_exist)
|
||||
{
|
||||
if (is_submenu())
|
||||
{
|
||||
TSubmenu* mnu = menu().find(_action);
|
||||
yes = mnu && mnu->enabled();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_exist < 0)
|
||||
{
|
||||
if (menu().is_dangerous(_action))
|
||||
{
|
||||
yes = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int endname = _action.find(' ');
|
||||
TFilename name(endname > 0 ? _action.left(endname) : _action);
|
||||
const char* ext[] = { "exe", "pif", "com", "bat", NULL };
|
||||
for (int e = 0; ext[e]; e++)
|
||||
{
|
||||
name.ext(ext[e]);
|
||||
if (name.exist())
|
||||
break;
|
||||
}
|
||||
yes = ext[e] != NULL;
|
||||
}
|
||||
((TMenuitem*)this)->_exist = yes;
|
||||
}
|
||||
if (_exist)
|
||||
{
|
||||
TExternal_app app(_action);
|
||||
yes = app.can_run();
|
||||
}
|
||||
if (!yes)
|
||||
((TMenuitem*)this)->_enabled = FALSE;
|
||||
}
|
||||
}
|
||||
return yes;
|
||||
}
|
||||
|
||||
bool TMenuitem::perform_submenu() const
|
||||
{
|
||||
TSubmenu* mnu = menu().find(_action);
|
||||
bool ok = mnu != NULL && mnu->enabled();
|
||||
if (ok)
|
||||
ok = menu().jumpto(mnu);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TMenuitem::perform_program() const
|
||||
{
|
||||
bool ok = TRUE;
|
||||
|
||||
if (_password)
|
||||
{
|
||||
TMask mask("ba0100a");
|
||||
mask.disable(F_USER);
|
||||
mask.set(F_USER, "SERVIZIO");
|
||||
ok = FALSE;
|
||||
if (mask.run() == K_ENTER)
|
||||
{
|
||||
const TDate oggi(TODAY);
|
||||
TString16 pwd; pwd << dongle().administrator() << (oggi.month() + oggi.day());
|
||||
ok = pwd == mask.get(F_PASSWORD);
|
||||
}
|
||||
if (!ok) error_box("Password di servizio errata!\nAccesso negato.");
|
||||
}
|
||||
|
||||
if (_firm && main_app().get_firm() == 0)
|
||||
#ifdef _DEMO_
|
||||
ok = main_app().set_firm(1);
|
||||
#else
|
||||
ok = main_app().set_firm();
|
||||
#endif
|
||||
|
||||
if (ok)
|
||||
{
|
||||
TCurrency::force_cache_update(); // Chiude cache valute
|
||||
prefix().set(NULL); // Chiude prefix
|
||||
TExternal_app a(_action);
|
||||
a.run(FALSE,3);
|
||||
|
||||
const bool maintenance_app = _action.compare("ba1 -0", 6, TRUE) == 0;
|
||||
if (maintenance_app)
|
||||
{
|
||||
char line1[16],line2[16];
|
||||
|
||||
while (fexist("conv.his"))
|
||||
{
|
||||
FILE* fp = fopen("conv.his","r");
|
||||
fgets(line1,15,fp);
|
||||
fclose(fp);
|
||||
// Ora aspetta...
|
||||
time_t old_time ;
|
||||
time( &old_time) ;
|
||||
while ( time( (time_t *) 0 ) <= old_time ) do_events();
|
||||
TExternal_app auto_conv("ba1 -0 -C");
|
||||
auto_conv.run();
|
||||
fp = fopen("conv.his","r");
|
||||
if (fp != NULL)
|
||||
{
|
||||
fgets(line2,15,fp);
|
||||
fclose(fp);
|
||||
}
|
||||
else strcpy(line2,"");
|
||||
if (strcmp(line1,line2) == 0)
|
||||
if (!yesno_box("La conversione non sembra procedere. Continuare?"))
|
||||
break;
|
||||
}
|
||||
}
|
||||
prefix().set("DEF"); // Aggiorna prefix
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TMenuitem::perform() const
|
||||
{
|
||||
bool ok = enabled();
|
||||
if (ok)
|
||||
{
|
||||
if (is_submenu())
|
||||
ok = perform_submenu();
|
||||
else
|
||||
ok = perform_program();
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Submenu
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TSubmenu::TSubmenu(TMenu* menu, const char* name)
|
||||
: _menu(menu), _name(name), _enabled(TRUE), _firm(FALSE), _items(12)
|
||||
{
|
||||
}
|
||||
|
||||
void TSubmenu::read(TScanner& scanner)
|
||||
{
|
||||
while (scanner.ok())
|
||||
{
|
||||
TString& line = scanner.line();
|
||||
if (line.empty())
|
||||
break;
|
||||
if (line[0] == '[')
|
||||
{
|
||||
scanner.push();
|
||||
break;
|
||||
}
|
||||
|
||||
char brace;
|
||||
if (line.compare("Caption", 7, TRUE) == 0)
|
||||
{
|
||||
get_next_string(line, 8, _caption, brace);
|
||||
_caption = dictionary_translate(_caption);
|
||||
} else
|
||||
if (line.compare("Module", 6, TRUE) == 0)
|
||||
{
|
||||
const int equal = line.find('=');
|
||||
if (equal > 0)
|
||||
{
|
||||
bool disable = TRUE;
|
||||
TToken_string mod(line.mid(equal+1, -1), ',');
|
||||
FOR_EACH_TOKEN(mod, cod)
|
||||
{
|
||||
const int code = atoi(cod);
|
||||
if (code == 0 || main_app().has_module(code))
|
||||
{
|
||||
disable = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (disable)
|
||||
_enabled = FALSE;
|
||||
}
|
||||
} else
|
||||
if (line.compare("Picture", 7, TRUE) == 0)
|
||||
get_next_string(line, 8, _picture, brace); else
|
||||
if (line.compare("Flags", 5, TRUE) == 0)
|
||||
{
|
||||
TString16 flags;
|
||||
get_next_string(line, 6, flags, brace);
|
||||
if (flags.find('D') >= 0)
|
||||
_enabled = FALSE;
|
||||
if (flags.find('F') >= 0)
|
||||
_firm = TRUE;
|
||||
} else
|
||||
if (line.compare("Item", 4, TRUE) == 0)
|
||||
{
|
||||
TMenuitem* item = new TMenuitem(this);
|
||||
_items.add(item);
|
||||
item->create(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int TSubmenu::find_string(const TString& str) const
|
||||
{
|
||||
bool found = FALSE;
|
||||
|
||||
TString caption;
|
||||
caption = _caption; caption.upper();
|
||||
if (caption.find(str) >= 0 || caption.match(str))
|
||||
found = TRUE;
|
||||
|
||||
for (int i = 0; i < items(); i++)
|
||||
{
|
||||
const TMenuitem& mi = item(i);
|
||||
caption = item(i).caption();
|
||||
caption.upper();
|
||||
const bool match = caption.find(str) >= 0 || caption.match(str);
|
||||
found = match && mi.is_program() && mi.enabled();
|
||||
if (found)
|
||||
return i;
|
||||
}
|
||||
|
||||
return found ? 0 : -1;
|
||||
}
|
||||
|
||||
TImage& TSubmenu::image() const
|
||||
{
|
||||
return menu().image(picture());
|
||||
}
|
||||
|
||||
bool TSubmenu::perform(int i)
|
||||
{
|
||||
bool ok = i >= 0 && i < items();
|
||||
if (ok)
|
||||
ok = item(i).perform();
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TMenu::read(const char* name, TString& root)
|
||||
{
|
||||
TString str(255);
|
||||
bool first = TRUE;
|
||||
|
||||
TScanner scanner(name);
|
||||
while (scanner.ok())
|
||||
{
|
||||
const TString& line = first ? scanner.line() : scanner.pop();
|
||||
if (line.empty())
|
||||
break;
|
||||
|
||||
char brace = '[';
|
||||
get_next_string(line, 0, str, brace);
|
||||
|
||||
if (first)
|
||||
{
|
||||
root = str;
|
||||
first = FALSE;
|
||||
}
|
||||
|
||||
if (objptr(str) == NULL)
|
||||
{
|
||||
TSubmenu* mnu = new TSubmenu(this, str);
|
||||
mnu->read(scanner);
|
||||
add(str, mnu);
|
||||
}
|
||||
else
|
||||
break; // Menu gia' caricato!
|
||||
}
|
||||
|
||||
return first == FALSE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Menu
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
bool TMenu::read(const char* name)
|
||||
{
|
||||
TString root;
|
||||
bool ok = read(name, root);
|
||||
if (ok && _current == NULL)
|
||||
{
|
||||
_default_menu = root;
|
||||
_current = find(root);
|
||||
_item = 0;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TMenu::jumpto(TSubmenu* next)
|
||||
{
|
||||
if (next && next->disabled())
|
||||
next = NULL;
|
||||
|
||||
if (next)
|
||||
{
|
||||
if (next->query_firm())
|
||||
{
|
||||
#ifdef _DEMO_
|
||||
if (!main_app().set_firm(1))
|
||||
next = NULL;
|
||||
#else
|
||||
if (!main_app().set_firm())
|
||||
next = NULL;
|
||||
#endif
|
||||
}
|
||||
if (next)
|
||||
{
|
||||
if (_stack.count() >= 32)
|
||||
_stack.destroy_base();
|
||||
_stack.push(_current->name());
|
||||
_current = next;
|
||||
_item = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return next != NULL;
|
||||
}
|
||||
|
||||
bool TMenu::jumpto_root()
|
||||
{
|
||||
TSubmenu* sm = find(_default_menu);
|
||||
return jumpto(sm);
|
||||
}
|
||||
|
||||
TSubmenu& TMenu::pop()
|
||||
{
|
||||
TSubmenu* sm = _current;
|
||||
if (!at_top())
|
||||
{
|
||||
TString& name = (TString&)_stack.pop();
|
||||
sm = (TSubmenu*)objptr(name);
|
||||
}
|
||||
if (sm)
|
||||
{
|
||||
_current = sm;
|
||||
_item = 0;
|
||||
}
|
||||
return *sm;
|
||||
}
|
||||
|
||||
TSubmenu* TMenu::find_string(const TString& str)
|
||||
{
|
||||
TString upstr(str);
|
||||
upstr.upper();
|
||||
|
||||
if (_last_search != upstr)
|
||||
{
|
||||
_last_search = upstr;
|
||||
_ignore_list.destroy();
|
||||
}
|
||||
|
||||
restart();
|
||||
for (TSubmenu* sm = (TSubmenu*)get(); sm; sm = (TSubmenu*)get())
|
||||
{
|
||||
if (sm->enabled() && !_ignore_list.is_key(sm->name()))
|
||||
{
|
||||
const int item = sm->find_string(upstr);
|
||||
if (item >= 0)
|
||||
{
|
||||
jumpto(sm);
|
||||
_item = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sm != NULL)
|
||||
_ignore_list.add(sm->name());
|
||||
else
|
||||
_ignore_list.destroy();
|
||||
|
||||
return sm;
|
||||
}
|
||||
|
||||
TSubmenu* TMenu::find_parent(const TSubmenu& sub)
|
||||
{
|
||||
restart();
|
||||
for (TSubmenu* sm = (TSubmenu*)get(); sm; sm = (TSubmenu*)get())
|
||||
{
|
||||
for (int i = sm->items()-1; i >= 0; i--)
|
||||
{
|
||||
const TMenuitem& mi = sm->item(i);
|
||||
if (mi.is_submenu() && mi.action().find(sub.name()) >= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sm;
|
||||
}
|
||||
|
||||
bool TMenu::perform()
|
||||
{
|
||||
bool ok = _current != NULL;
|
||||
if (ok)
|
||||
ok = _current->perform(_item);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TMenu::can_be_transparent(const TImage& i) const
|
||||
{
|
||||
const int w = i.width()-1;
|
||||
const int h = i.height()-1;
|
||||
const COLOR col = i.get_pixel(0,0);
|
||||
if (i.get_pixel(w,0) != col)
|
||||
return FALSE;
|
||||
if (i.get_pixel(w,h) != col)
|
||||
return FALSE;
|
||||
if (i.get_pixel(0,h) != col)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TImage& TMenu::image(const char* name)
|
||||
{
|
||||
TTimed_image* image = (TTimed_image*)_images.objptr(name);
|
||||
if (image == NULL)
|
||||
{
|
||||
if (fexist(name))
|
||||
{
|
||||
if (_images.items() == 0)
|
||||
_default_bmp = name; // Store default bitmap name
|
||||
|
||||
image = new TTimed_image(name);
|
||||
if (can_be_transparent(*image))
|
||||
image->convert_transparent_color(MASK_BACK_COLOR);
|
||||
_images.add(name, image);
|
||||
}
|
||||
else
|
||||
{
|
||||
image = (TTimed_image*)_images.objptr(_default_bmp);
|
||||
if (image == NULL)
|
||||
fatal_box("%s %s", TR("Impossibile trovare l'immagine"), (const char*)_default_bmp);
|
||||
}
|
||||
|
||||
if (_images.items() > 3)
|
||||
{
|
||||
TString worst_bmp;
|
||||
clock_t worst_time = image->touch(); // Impedisco di cancellare la prossima
|
||||
_images.restart();
|
||||
for (THash_object* o = _images.get_hashobj(); o; o = _images.get_hashobj())
|
||||
{
|
||||
if (o->key() != _default_bmp)
|
||||
{
|
||||
TTimed_image& i = (TTimed_image&)o->obj();
|
||||
if (i.last_time() < worst_time)
|
||||
{
|
||||
worst_time = i.last_time();
|
||||
worst_bmp = o->key();
|
||||
}
|
||||
}
|
||||
}
|
||||
_images.remove(worst_bmp);
|
||||
}
|
||||
}
|
||||
image->touch();
|
||||
return *image;
|
||||
}
|
||||
|
||||
void TMenu::reload_images()
|
||||
{
|
||||
_images.destroy();
|
||||
}
|
||||
|
||||
bool TMenu::has_module(const char* mod)
|
||||
{
|
||||
TString16 key;
|
||||
|
||||
if (_modules.items() == 0)
|
||||
{
|
||||
TScanner scanner(AUT_FILE);
|
||||
TString16 val;
|
||||
for (int aut = 0; scanner.line() != ""; aut++)
|
||||
{
|
||||
key.strncpy(scanner.token(), 2);
|
||||
key.lower();
|
||||
val.format("%d", aut);
|
||||
_modules.add(key, val);
|
||||
}
|
||||
}
|
||||
|
||||
key.strncpy(mod, 2);
|
||||
key.lower();
|
||||
|
||||
int module = 0;
|
||||
TString* cod = (TString*)_modules.objptr(key);
|
||||
if (cod) module = atoi(*cod);
|
||||
return main_app().has_module(module);
|
||||
}
|
||||
|
||||
bool TMenu::is_dangerous(const char* mod)
|
||||
{
|
||||
TString code(mod);
|
||||
code.cut(2);
|
||||
return _dangerous.get_pos(code) >= 0;
|
||||
}
|
||||
|
166
ba/ba0101.h
Executable file
166
ba/ba0101.h
Executable file
@ -0,0 +1,166 @@
|
||||
#ifndef __BA0101_H
|
||||
#define __BA0101_H
|
||||
|
||||
#ifndef __ASSOC_H
|
||||
#include <assoc.h>
|
||||
#endif
|
||||
|
||||
#ifndef __COLORS_H
|
||||
#include <colors.h>
|
||||
#endif
|
||||
|
||||
#ifndef __IMAGE_H
|
||||
#include <image.h>
|
||||
#endif
|
||||
|
||||
#ifndef __SCANNER_H
|
||||
#include <scanner.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STACK_H
|
||||
#include <stack.h>
|
||||
#endif
|
||||
|
||||
|
||||
class TSubmenu;
|
||||
class TMenu;
|
||||
|
||||
class TMenuitem : public TObject
|
||||
{
|
||||
TSubmenu* _submenu;
|
||||
TString _caption, _action;
|
||||
int _icon;
|
||||
char _type;
|
||||
COLOR _color;
|
||||
int _exist : 2;
|
||||
bool _enabled : 2;
|
||||
bool _firm : 2;
|
||||
bool _password : 2;
|
||||
bool _reloadmenu : 2;
|
||||
|
||||
protected:
|
||||
bool perform_submenu() const;
|
||||
bool perform_program() const;
|
||||
|
||||
public:
|
||||
virtual bool ok() { return _caption.not_empty(); }
|
||||
|
||||
const TString& caption() const { return _caption; }
|
||||
int icon() const;
|
||||
const TString& action() const { return _action; }
|
||||
bool enabled() const;
|
||||
bool disabled() const { return !enabled(); }
|
||||
|
||||
COLOR color() const { return enabled() ? _color : DISABLED_COLOR; }
|
||||
|
||||
bool is_submenu() const { return _type == '[' && _action.not_empty(); }
|
||||
bool is_program() const { return _type != '[' && _action.not_empty(); }
|
||||
bool perform() const;
|
||||
|
||||
TSubmenu& submenu() const { return *_submenu; }
|
||||
TMenu& menu() const;
|
||||
|
||||
void create(const char* t);
|
||||
|
||||
TMenuitem(TSubmenu* sm);
|
||||
virtual ~TMenuitem() { }
|
||||
};
|
||||
|
||||
class TSubmenu : public TObject
|
||||
{
|
||||
TMenu* _menu;
|
||||
TString _name;
|
||||
TString _caption;
|
||||
TFilename _picture;
|
||||
TArray _items;
|
||||
bool _enabled : 2;
|
||||
bool _firm : 2;
|
||||
|
||||
public:
|
||||
void read(TScanner& scanner);
|
||||
|
||||
TMenu& menu() const { return *_menu; }
|
||||
int find_string(const TString& str) const;
|
||||
|
||||
TMenuitem& item(int i) { return (TMenuitem&)_items[i]; }
|
||||
const TMenuitem& item(int i) const { return (const TMenuitem&)_items[i]; }
|
||||
const TMenuitem& operator[](int i) const { return item(i); }
|
||||
|
||||
const TString& name() const { return _name; }
|
||||
const TString& caption() const { return _caption; }
|
||||
const TString& picture() const { return _picture; }
|
||||
int items() const { return _items.items(); }
|
||||
|
||||
TImage& image() const;
|
||||
|
||||
bool query_firm() const { return _firm; }
|
||||
bool enabled() const { return _enabled; }
|
||||
bool disabled() const { return !enabled(); }
|
||||
|
||||
bool perform(int i);
|
||||
|
||||
TSubmenu(TMenu* menu, const char* name);
|
||||
virtual ~TSubmenu() { }
|
||||
};
|
||||
|
||||
class TMenu : public TAssoc_array
|
||||
{
|
||||
TSubmenu* _current;
|
||||
int _item;
|
||||
TStack _stack;
|
||||
|
||||
TFilename _default_bmp;
|
||||
TString _default_menu;
|
||||
|
||||
TAssoc_array _images;
|
||||
TAssoc_array _modules;
|
||||
|
||||
TToken_string _dangerous;
|
||||
|
||||
TString _last_search;
|
||||
TAssoc_array _ignore_list;
|
||||
|
||||
protected:
|
||||
bool can_be_transparent(const TImage& i) const;
|
||||
|
||||
public: // TObject
|
||||
virtual bool ok() const { return _current != NULL; }
|
||||
|
||||
public:
|
||||
bool read(const char* name); // First call
|
||||
bool read(const char* name, TString& root);
|
||||
|
||||
TSubmenu& current() const { return *_current; }
|
||||
TSubmenu* find(const char* name) const { return (TSubmenu*)objptr(name); }
|
||||
bool jumpto(TSubmenu *next);
|
||||
bool jumpto_root();
|
||||
|
||||
TSubmenu& pop();
|
||||
bool at_top() const { return _stack.count() == 0; }
|
||||
|
||||
void select(int i) { _item = i; }
|
||||
int selected() const { return _item; }
|
||||
TMenuitem& curr_item() { return _current->item(_item); }
|
||||
TSubmenu* find_parent(const TSubmenu& sub);
|
||||
|
||||
bool perform();
|
||||
TSubmenu* find_string(const TString& str);
|
||||
TString& last_search_string() { return _last_search; }
|
||||
TAssoc_array& search_ignore_list() { return _ignore_list; }
|
||||
|
||||
TImage& image(const char* name);
|
||||
void reload_images();
|
||||
|
||||
bool has_module(const char* mod);
|
||||
bool is_dangerous(const char* mod);
|
||||
|
||||
void set_dangerous_modules(const TToken_string& mod)
|
||||
{ _dangerous = mod; }
|
||||
|
||||
TMenu() : _current(NULL), _item(0) { }
|
||||
TMenu(const char* name) { read(name); }
|
||||
virtual ~TMenu() { }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
763
ba/ba0102.cpp
Executable file
763
ba/ba0102.cpp
Executable file
@ -0,0 +1,763 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <mask.h>
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include "ba0102.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TMenu_tree
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
const TSubmenu& TMenu_tree::curr_submenu() const
|
||||
{
|
||||
CHECKS(_submenu, "NULL submenu ", (const char*)_curr_id);
|
||||
return *_submenu;
|
||||
}
|
||||
|
||||
const TMenuitem& TMenu_tree::curr_item() const
|
||||
{
|
||||
const TSubmenu& sm = curr_submenu();
|
||||
if (_menuitem < 0 || _menuitem >= sm.items())
|
||||
{
|
||||
NFCHECK("Invalid submenu item %d in %s", _menuitem, (const char*)sm.name());
|
||||
return sm.item(0);
|
||||
}
|
||||
return sm.item(_menuitem);
|
||||
}
|
||||
|
||||
struct TFind_node_data
|
||||
{
|
||||
TString _id;
|
||||
size_t _count;
|
||||
};
|
||||
|
||||
struct TFind_string_data
|
||||
{
|
||||
TString _str;
|
||||
TAssoc_array* _ignore_list;
|
||||
};
|
||||
|
||||
HIDDEN bool find_string_callback(TTree& tree, void* jolly, word flags)
|
||||
{
|
||||
if (flags == SCAN_PRE_ORDER)
|
||||
{
|
||||
TMenu_tree& mt = (TMenu_tree&)tree;
|
||||
TFind_string_data& data = *(TFind_string_data*)jolly;
|
||||
|
||||
const TSubmenu& sm = mt.curr_submenu();
|
||||
if (data._ignore_list->is_key(sm.name()))
|
||||
return FALSE;
|
||||
|
||||
TString desc; mt.get_description(desc);
|
||||
desc.upper();
|
||||
if (desc.find(data._str) >= 0 || desc.match(data._str))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HIDDEN bool find_node_callback(TTree& tree, void* jolly, word flags)
|
||||
{
|
||||
if (flags == SCAN_PRE_ORDER)
|
||||
{
|
||||
TFind_node_data& data = *(TFind_node_data*)jolly;
|
||||
data._count++;
|
||||
TString id; tree.curr_id(id);
|
||||
if (id == data._id)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HIDDEN bool find_leaf_callback(TTree& tree, void* jolly, word flags)
|
||||
{
|
||||
if (flags == SCAN_PRE_ORDER)
|
||||
{
|
||||
const TString& leaf = *(TString*)jolly;
|
||||
TString id; tree.curr_id(id);
|
||||
const int slash = id.rfind('/');
|
||||
if (slash > 0)
|
||||
id = id.mid(slash+1);
|
||||
if (id == leaf)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TMenu_tree::find_string(const TString& str)
|
||||
{
|
||||
TFind_string_data data;
|
||||
data._str = str; data._str.upper();
|
||||
data._ignore_list = &_menu->search_ignore_list();
|
||||
|
||||
if (data._str != _menu->last_search_string())
|
||||
{
|
||||
_menu->last_search_string() = data._str;
|
||||
_menu->search_ignore_list().destroy();
|
||||
}
|
||||
|
||||
goto_root();
|
||||
bool ok = scan_depth_first(find_string_callback, &data, SCAN_PRE_ORDER);
|
||||
if (ok)
|
||||
_menu->search_ignore_list().add(curr_submenu().name());
|
||||
else
|
||||
_menu->search_ignore_list().destroy();
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TMenu_tree::find_leaf(const TString& str)
|
||||
{
|
||||
goto_root();
|
||||
bool ok = scan_depth_first(find_leaf_callback, (void *)&str, SCAN_PRE_ORDER);
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TMenu_tree::node2id(const TObject* node, TString& id) const
|
||||
{
|
||||
TString* str = (TString*)node;
|
||||
id = *str;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_root()
|
||||
{
|
||||
TSubmenu* sm = _menu->find(_root_id);
|
||||
if (sm)
|
||||
{
|
||||
_curr_id = _root_id;
|
||||
_curr_id << ".0";
|
||||
_submenu = sm;
|
||||
_menuitem = 0;
|
||||
}
|
||||
return sm != NULL;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_firstson()
|
||||
{
|
||||
const TMenuitem& mi = curr_item();
|
||||
if (mi.is_submenu())
|
||||
{
|
||||
const TSubmenu* sm = _menu->find(mi.action());
|
||||
if (sm && sm->items() > 0)
|
||||
{
|
||||
_curr_id << '/' << mi.action() << ".0";
|
||||
_submenu = sm;
|
||||
_menuitem = 0;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_rbrother()
|
||||
{
|
||||
if (_menuitem < _submenu->items()-1)
|
||||
{
|
||||
const int dot = _curr_id.rfind('.');
|
||||
_curr_id.cut(dot+1);
|
||||
_curr_id << (++_menuitem);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_node(const TString &id)
|
||||
{
|
||||
const int dot = id.rfind('.');
|
||||
CHECKS(dot > 0, "Invalid tree node ", (const char*)id);
|
||||
_menuitem = atoi(id.mid(dot+1));
|
||||
_curr_id = id.left(dot);
|
||||
const int slash = _curr_id.rfind('/');
|
||||
|
||||
_curr_id = _curr_id.mid(slash+1);
|
||||
_submenu = _menu->find(_curr_id);
|
||||
_curr_id = id;
|
||||
|
||||
return _submenu != NULL;
|
||||
}
|
||||
|
||||
bool TMenu_tree::has_son() const
|
||||
{
|
||||
const TMenuitem& mi = curr_item();
|
||||
return mi.is_submenu();
|
||||
}
|
||||
|
||||
bool TMenu_tree::has_rbrother() const
|
||||
{
|
||||
return _menuitem < _submenu->items()-1;
|
||||
}
|
||||
|
||||
bool TMenu_tree::has_root() const
|
||||
{
|
||||
return _root_id.not_empty();
|
||||
}
|
||||
|
||||
bool TMenu_tree::has_father() const
|
||||
{
|
||||
return _curr_id.find('/') > 0;
|
||||
}
|
||||
|
||||
bool TMenu_tree::has_lbrother() const
|
||||
{
|
||||
return _menuitem > 0;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_father()
|
||||
{
|
||||
const int slash = _curr_id.rfind('/');
|
||||
if (slash > 0)
|
||||
{
|
||||
const TString id = _curr_id.left(slash);
|
||||
return goto_node(id);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TMenu_tree::goto_lbrother()
|
||||
{
|
||||
if (_menuitem > 0)
|
||||
{
|
||||
const int dot = _curr_id.rfind('.');
|
||||
_curr_id.cut(dot+1);
|
||||
_curr_id << (--_menuitem);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
TObject* TMenu_tree::curr_node() const
|
||||
{
|
||||
return &((TMenu_tree*)this)->_curr_id;
|
||||
}
|
||||
|
||||
bool TMenu_tree::get_description(TString& desc) const
|
||||
{
|
||||
const TMenuitem& mi = curr_item();
|
||||
desc = mi.caption();
|
||||
return desc.not_empty();
|
||||
}
|
||||
|
||||
TImage* TMenu_tree::image(bool selected) const
|
||||
{
|
||||
const TMenuitem& mi = curr_item();
|
||||
if (mi.disabled())
|
||||
return get_res_image(BMP_STOP);
|
||||
return TTree::image(selected);
|
||||
}
|
||||
|
||||
long TMenu_tree::find_node(const TString& id)
|
||||
{
|
||||
TFind_node_data data;
|
||||
data._id = id;
|
||||
data._count = 0;
|
||||
goto_root();
|
||||
scan_depth_first(find_node_callback, &data,
|
||||
SCAN_PRE_ORDER | SCAN_IGNORING_UNEXPANDED);
|
||||
return data._count;
|
||||
}
|
||||
|
||||
TMenu_tree::TMenu_tree(TMenu& menu)
|
||||
: _menu(&menu), _curr_id(128, '/')
|
||||
{
|
||||
_root_id = _menu->current().name();
|
||||
goto_root();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Utility
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
void synchronize_tree_field(TTree_field& tf)
|
||||
{
|
||||
TMenu_tree& mt = *(TMenu_tree*)tf.tree();
|
||||
|
||||
tf.select_current();
|
||||
TString id; mt.curr_id(id); // Memorizza nodo corrente
|
||||
|
||||
mt.shrink_all();
|
||||
mt.goto_node(id);
|
||||
do
|
||||
{
|
||||
mt.expand();
|
||||
}
|
||||
while (mt.goto_father());
|
||||
|
||||
mt.goto_node(id);
|
||||
tf.set_tree(&mt); // Azzera origine
|
||||
|
||||
TField_window& win = tf.win();
|
||||
win.force_update();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TMenulist_field
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TMenulist_images : public TCache
|
||||
{
|
||||
WINDOW _win;
|
||||
|
||||
protected:
|
||||
TObject* key2obj(const char* key);
|
||||
bool can_be_transparent(const TImage& i) const;
|
||||
|
||||
public:
|
||||
void set_owner(WINDOW win) { _win = win; }
|
||||
TImage* image(const TString& filename);
|
||||
TMenulist_images() : TCache(17), _win(NULL_WIN) { }
|
||||
};
|
||||
|
||||
bool TMenulist_images::can_be_transparent(const TImage& i) const
|
||||
{
|
||||
const int w = i.width()-1;
|
||||
const int h = i.height()-1;
|
||||
const COLOR col = i.get_pixel(0,0);
|
||||
if (i.get_pixel(w,0) != col)
|
||||
return FALSE;
|
||||
if (i.get_pixel(w,h) != col)
|
||||
return FALSE;
|
||||
if (i.get_pixel(0,h) != col)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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
|
||||
#define TEST(s, h, i) { const int k = h+i; if (k*k <= s) h = k; }
|
||||
const int s = x*x + y*y;
|
||||
int h = 0;
|
||||
TEST(s, h, 512); TEST(s, h, 256); TEST(s, h, 128);
|
||||
TEST(s, h, 64); TEST(s, h, 32); TEST(s, h, 16);
|
||||
TEST(s, h, 8); TEST(s, h, 4); TEST(s, h, 2); TEST(s, h, 1);
|
||||
return h;
|
||||
}
|
||||
|
||||
TObject* TMenulist_images::key2obj(const char* key)
|
||||
{
|
||||
TImage* img = NULL;
|
||||
|
||||
if (fexist(key))
|
||||
{
|
||||
TWait_cursor hourglass;
|
||||
TImage image(key);
|
||||
if (can_be_transparent(image))
|
||||
image.convert_transparent_color(NORMAL_BACK_COLOR);
|
||||
|
||||
const int w = image.width();
|
||||
const int h = image.height();
|
||||
const int radius = min(w, h)/2;
|
||||
|
||||
const clock_t start_timer = clock();
|
||||
for (int y = h-1; y >= 0; y--)
|
||||
{
|
||||
for (int x = w-1; x >= 0; x--)
|
||||
{
|
||||
int perc = 0;
|
||||
const int r = fast_hypot(x-w/2, y-h/2);
|
||||
if (r < radius)
|
||||
{
|
||||
perc = 75 - (75 * r / radius);
|
||||
}
|
||||
COLOR col = image.get_pixel(x, y);
|
||||
COLOR bri = blend_colors(col, NORMAL_BACK_COLOR, perc);
|
||||
image.set_pixel(x, y, bri);
|
||||
}
|
||||
}
|
||||
const clock_t stop_timer = clock()-start_timer;
|
||||
|
||||
RCT rct; xvt_vobj_get_client_rect(_win, &rct);
|
||||
const double ratiox = double(rct.right) / image.width();
|
||||
const double ratioy = double(rct.bottom) / image.height();
|
||||
const double ratio = max(ratiox, ratioy);
|
||||
const int maxx = int(ratio * image.width())-2;
|
||||
const int maxy = int(ratio * image.height())-2;
|
||||
img = new TImage(image, maxx, maxy);
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
TImage* TMenulist_images::image(const TString& filename)
|
||||
{
|
||||
TObject* obj = objptr(filename);
|
||||
return (TImage*)obj;
|
||||
}
|
||||
|
||||
class TMenulist_window : public TField_window
|
||||
{
|
||||
enum { MENU_COLS = 3, MENU_ROWS = 5 };
|
||||
|
||||
private:
|
||||
TMenu_tree* _tree;
|
||||
TString _curr_node;
|
||||
bool _can_go_back;
|
||||
|
||||
TMenulist_images _images;
|
||||
TString _image_name;
|
||||
|
||||
int _selected;
|
||||
TPointer_array _sorted;
|
||||
|
||||
protected:
|
||||
virtual void update();
|
||||
virtual void handler(WINDOW win, EVENT* ep);
|
||||
virtual bool on_key(KEY k);
|
||||
|
||||
void synchronize_buddy_tree() const;
|
||||
void draw_item(int i);
|
||||
void click_on(int index);
|
||||
void select(int s, int direction);
|
||||
|
||||
public:
|
||||
void set_menu(TMenu_tree& mt);
|
||||
|
||||
TMenulist_window(int x, int y, int dx, int dy, WINDOW parent, TMenulist_field* owner);
|
||||
virtual ~TMenulist_window();
|
||||
};
|
||||
|
||||
void TMenulist_window::draw_item(int i)
|
||||
{
|
||||
if (i < 0 && i >= _sorted.items())
|
||||
return; // Scarta elementi non validi
|
||||
|
||||
RCT rct; xvt_vobj_get_client_rect(win(), &rct);
|
||||
const int width = rct.right - rct.left;
|
||||
const int height = rct.bottom - rct.top;
|
||||
|
||||
xvt_set_font(win(), NULL, 0, 0); // Set default font
|
||||
set_opaque_text(TRUE);
|
||||
|
||||
const TMenuitem& item = (const TMenuitem&)_sorted[i];
|
||||
if (i == _selected && item.enabled())
|
||||
set_color(item.color(), FOCUS_BACK_COLOR);
|
||||
else
|
||||
{
|
||||
COLOR bc = item.enabled() ? NORMAL_BACK_COLOR : DISABLED_BACK_COLOR;
|
||||
set_color(item.color(), bc);
|
||||
}
|
||||
|
||||
const int row = i / MENU_COLS;
|
||||
const int col = i % MENU_COLS;
|
||||
const int left = col * width / MENU_COLS;
|
||||
const int right = (col+1) * width / MENU_COLS;
|
||||
const int top = row * height / MENU_ROWS;
|
||||
const int bottom = (row+1) * height / MENU_ROWS;
|
||||
|
||||
const int maxchars = (right-left)/CHARX - 1;
|
||||
const int cx = (left+right)/2;
|
||||
const int cy = (top+bottom)/2;
|
||||
|
||||
const int ico = item.enabled() ? item.icon() : 0;
|
||||
const int ix = cx-16;
|
||||
const int iy = top+2;
|
||||
if (item.is_submenu())
|
||||
{
|
||||
xvt_dwin_draw_icon(win(), ix, iy, 10202);
|
||||
if ( ico > 0)
|
||||
xvt_dwin_draw_icon(win(), ix, iy+4, ico);
|
||||
}
|
||||
else
|
||||
{
|
||||
xvt_dwin_draw_icon(win(), ix, iy, ico > 0 ? ico : ICON_RSRC);
|
||||
}
|
||||
|
||||
TString str = item.caption();
|
||||
if (i == 0 && _can_go_back)
|
||||
str.insert("(..)\n");
|
||||
|
||||
TParagraph_string para(str, maxchars);
|
||||
int y = iy + 32 + CHARY-2;
|
||||
FOR_EACH_TOKEN(para, line)
|
||||
{
|
||||
const int ll = xvt_dwin_get_text_width(win(), line, -1);
|
||||
const int x = cx - ll/2;
|
||||
xvt_dwin_draw_text(win(), x, y, line, -1);
|
||||
y += CHARY-2;
|
||||
}
|
||||
if (item.disabled())
|
||||
xvt_dwin_draw_icon(win(), ix+4, iy+4, 10203); // Stop icon
|
||||
/* if (item.disabled())
|
||||
{
|
||||
set_pen(COLOR_RED, 3);
|
||||
PNT p;
|
||||
p.h = ix, p.v = iy; xvt_dwin_draw_set_pos(win(), p);
|
||||
p.h = ix+32, p.v = iy+32; xvt_dwin_draw_line(win(), p);
|
||||
p.h = ix+32, p.v = iy; xvt_dwin_draw_set_pos(win(), p);
|
||||
p.h = ix, p.v = iy+32; xvt_dwin_draw_line(win(), p);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void TMenulist_window::update()
|
||||
{
|
||||
TImage* img = _images.image(_image_name); // Delay time before clearing
|
||||
|
||||
TField_window::update();
|
||||
if (_tree == NULL)
|
||||
return; // Nothing to draw
|
||||
|
||||
if (img != NULL)
|
||||
{
|
||||
RCT rct; xvt_vobj_get_client_rect(win(), &rct);
|
||||
const int x = (rct.right - img->width())/2;
|
||||
const int y = (rct.bottom - img->height())/2;
|
||||
img->draw(win(), x, y);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _sorted.items(); i++)
|
||||
draw_item(i);
|
||||
}
|
||||
|
||||
void TMenulist_window::click_on(int index)
|
||||
{
|
||||
if (index >= 0 && index < _sorted.items())
|
||||
{
|
||||
const TMenuitem& mi = (const TMenuitem&)_sorted[index];
|
||||
if (mi.enabled())
|
||||
{
|
||||
if (mi.is_submenu())
|
||||
{
|
||||
if (index == 0 && _can_go_back) // Sù di un livello
|
||||
{
|
||||
_tree->goto_node(_curr_node);
|
||||
_tree->goto_father();
|
||||
set_menu(*_tree);
|
||||
}
|
||||
else // Giù di un livello
|
||||
{
|
||||
if (mi.perform()) // Eventuale richiesta ditta
|
||||
{
|
||||
_tree->goto_node(_curr_node);
|
||||
const TSubmenu& mnu = _tree->curr_submenu();
|
||||
for (int i = 0; i < mnu.items(); i++)
|
||||
{
|
||||
const TMenuitem& ti = mnu[i];
|
||||
if (ti.action() == mi.action())
|
||||
{
|
||||
_tree->goto_firstson();
|
||||
set_menu(*_tree);
|
||||
synchronize_buddy_tree();
|
||||
break;
|
||||
}
|
||||
_tree->goto_rbrother();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mi.perform();
|
||||
}
|
||||
set_focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TMenulist_window::handler(WINDOW win, EVENT* ep)
|
||||
{
|
||||
switch (ep->type)
|
||||
{
|
||||
case E_MOUSE_DOWN:
|
||||
{
|
||||
int index = 0;
|
||||
if (ep->v.mouse.button > 0) // Tasto destro = Torna sù
|
||||
{
|
||||
if (!_can_go_back)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
RCT rct; xvt_vobj_get_client_rect(win, &rct);
|
||||
const int row = ep->v.mouse.where.v * MENU_ROWS / rct.bottom;
|
||||
const int col = ep->v.mouse.where.h * MENU_COLS / rct.right;
|
||||
index = row * MENU_COLS + col;
|
||||
}
|
||||
click_on(index);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
TField_window::handler(win, ep);
|
||||
}
|
||||
|
||||
void TMenulist_window::select(int s, int direction)
|
||||
{
|
||||
const int old_selection = _selected;
|
||||
|
||||
if (s < 0)
|
||||
s = 0;
|
||||
if (s >= _sorted.items())
|
||||
s = _sorted.last();
|
||||
|
||||
_selected = s;
|
||||
const TMenuitem& mi = (const TMenuitem&)_sorted[_selected];
|
||||
if (!mi.enabled())
|
||||
{
|
||||
for (_selected += direction; ; _selected += direction)
|
||||
{
|
||||
if (_selected < 0)
|
||||
_selected = _sorted.last();
|
||||
if (_selected >= _sorted.items())
|
||||
_selected = 0;
|
||||
if (_selected == s) // Ho rifatto l'intero giro!
|
||||
break;
|
||||
|
||||
const TMenuitem& item = (const TMenuitem&)_sorted[_selected];
|
||||
if (item.enabled())
|
||||
break; // Ho trovato un elemento abilitato!
|
||||
}
|
||||
}
|
||||
|
||||
draw_item(old_selection);
|
||||
draw_item(_selected);
|
||||
}
|
||||
|
||||
bool TMenulist_window::on_key(KEY k)
|
||||
{
|
||||
switch (k)
|
||||
{
|
||||
case K_ESC:
|
||||
case K_BACKSPACE:
|
||||
if (_tree != NULL && _can_go_back) // Sù di un livello
|
||||
click_on(0);
|
||||
break;
|
||||
case K_ENTER:
|
||||
case K_SPACE:
|
||||
click_on(_selected);
|
||||
break;
|
||||
case K_HOME:
|
||||
select(0, +1);
|
||||
break;
|
||||
case K_UP:
|
||||
case K_PREV:
|
||||
select(_selected - MENU_COLS, -1);
|
||||
break;
|
||||
case K_DOWN:
|
||||
case K_NEXT:
|
||||
select(_selected + MENU_COLS, +1);
|
||||
break;
|
||||
case K_LEFT:
|
||||
select(_selected-1, -1);
|
||||
break;
|
||||
case K_RIGHT:
|
||||
select(_selected+1, +1);
|
||||
break;
|
||||
case K_END:
|
||||
select(_sorted.last(), -1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TMenulist_window::synchronize_buddy_tree() const
|
||||
{
|
||||
TMask& m = owner().mask();
|
||||
for (int i = 0; i < m.fields(); i++)
|
||||
{
|
||||
TMask_field& mf = m.fld(i);
|
||||
if (mf.is_kind_of(CLASS_TREE_FIELD))
|
||||
{
|
||||
TTree_field& tf = (TTree_field&)mf;
|
||||
synchronize_tree_field(tf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TMenulist_window::set_menu(TMenu_tree& tree)
|
||||
{
|
||||
_tree = &tree;
|
||||
|
||||
tree.curr_id(_curr_node);
|
||||
const int dot = _curr_node.rfind('.')+1;
|
||||
|
||||
int sel = -1;
|
||||
if (dot > 0)
|
||||
{
|
||||
sel = atoi(_curr_node.mid(dot));
|
||||
_curr_node.overwrite("0", dot);
|
||||
}
|
||||
|
||||
_sorted.destroy();
|
||||
_can_go_back = tree.goto_father();
|
||||
if (_can_go_back)
|
||||
{
|
||||
_sorted.add(tree.curr_item());
|
||||
tree.goto_node(_curr_node);
|
||||
}
|
||||
|
||||
int folders = _sorted.items();
|
||||
|
||||
// Lista riordinata dei menu items
|
||||
const TSubmenu& mnu = tree.curr_submenu();
|
||||
for (int i = 0; i < mnu.items(); i++)
|
||||
{
|
||||
const TMenuitem& item = mnu[i];
|
||||
if (item.is_submenu())
|
||||
_sorted.insert(item, folders++);
|
||||
else
|
||||
_sorted.add(item);
|
||||
}
|
||||
|
||||
TString80 sel_act;
|
||||
if (sel >= 0 && sel < mnu.items())
|
||||
sel_act= mnu[sel].action();
|
||||
|
||||
for (_selected = _sorted.last(); _selected > 0; _selected--)
|
||||
{
|
||||
const TMenuitem& sm = (const TMenuitem&)_sorted[_selected];
|
||||
if (sm.enabled() && sm.action() == sel_act)
|
||||
break;
|
||||
}
|
||||
|
||||
_image_name = mnu.picture();
|
||||
|
||||
force_update();
|
||||
}
|
||||
|
||||
TMenulist_window::TMenulist_window(int x, int y, int dx, int dy, WINDOW parent, TMenulist_field* owner)
|
||||
: TField_window(x, y, dx, dy, parent, owner), _tree(NULL)
|
||||
{
|
||||
set_scroll_max(0, 0); // Get rid of that useless scrollbars
|
||||
_images.set_owner(win());
|
||||
}
|
||||
|
||||
TMenulist_window::~TMenulist_window()
|
||||
{
|
||||
}
|
||||
|
||||
TField_window* TMenulist_field::create_window(int x, int y, int dx, int dy, WINDOW parent)
|
||||
{
|
||||
return new TMenulist_window(x, y, dx, dy, parent, this);
|
||||
}
|
||||
|
||||
void TMenulist_field::create(short dlg, int x, int y, int dx, int dy)
|
||||
{
|
||||
_dlg = dlg;
|
||||
_win = create_window(x, y, dx, dy, mask().win());
|
||||
}
|
||||
|
||||
void TMenulist_field::set_menu(TMenu_tree& mt)
|
||||
{
|
||||
TMenulist_window& w = (TMenulist_window&)win();
|
||||
w.set_menu(mt);
|
||||
}
|
74
ba/ba0102.h
Executable file
74
ba/ba0102.h
Executable file
@ -0,0 +1,74 @@
|
||||
#ifndef __BA0102_H
|
||||
#define __BA0102_H
|
||||
|
||||
#ifndef __MASKFLD_H
|
||||
#include <maskfld.h>
|
||||
#endif
|
||||
|
||||
#ifndef __TREE_H
|
||||
#include <tree.h>
|
||||
#endif
|
||||
|
||||
#ifndef __BA0101_H
|
||||
#include "ba0101.h"
|
||||
#endif
|
||||
|
||||
class TMenu_tree : public TBidirectional_tree
|
||||
{
|
||||
TMenu* _menu;
|
||||
const TSubmenu* _submenu;
|
||||
int _menuitem;
|
||||
|
||||
TString _root_id, _curr_id;
|
||||
|
||||
protected: // TTree
|
||||
virtual void node2id(const TObject* node, TString& id) const;
|
||||
|
||||
public: // TTree
|
||||
virtual bool goto_root();
|
||||
virtual bool goto_firstson();
|
||||
virtual bool goto_rbrother();
|
||||
virtual bool goto_node(const TString &id);
|
||||
virtual bool has_son() const;
|
||||
virtual bool has_rbrother() const;
|
||||
virtual TObject* curr_node() const;
|
||||
|
||||
virtual bool has_root() const;
|
||||
virtual bool has_father() const;
|
||||
virtual bool has_lbrother() const;
|
||||
virtual bool goto_father();
|
||||
virtual bool goto_lbrother();
|
||||
|
||||
virtual void curr_id(TString& id) const { id = _curr_id; }
|
||||
virtual bool get_description(TString& desc) const;
|
||||
virtual TImage* image(bool selected) const;
|
||||
|
||||
public:
|
||||
const TSubmenu& curr_submenu() const;
|
||||
const TMenuitem& curr_item() const;
|
||||
|
||||
bool find_leaf(const TString& str);
|
||||
bool find_string(const TString& str);
|
||||
long find_node(const TString& id);
|
||||
|
||||
TMenu_tree(TMenu& menu);
|
||||
virtual ~TMenu_tree() { }
|
||||
};
|
||||
|
||||
class TMenulist_field : public TWindowed_field
|
||||
{
|
||||
protected: // TWindowed_field
|
||||
virtual TField_window* create_window(int x, int y, int dx, int dy, WINDOW parent);
|
||||
|
||||
public:
|
||||
void set_menu(TMenu_tree& mt);
|
||||
void create(short dlg, int x, int y, int dx, int dy);
|
||||
|
||||
TMenulist_field(TMask* m) : TWindowed_field(m) { }
|
||||
virtual ~TMenulist_field() { }
|
||||
};
|
||||
|
||||
// Utilities
|
||||
void synchronize_tree_field(TTree_field& tf);
|
||||
|
||||
#endif
|
@ -1,124 +1,124 @@
|
||||
PAGE "Colori" -1 -1 50 19
|
||||
PAGE "Colori" -1 -1 54 19
|
||||
|
||||
GROUPBOX DLG_NULL 48 3
|
||||
GROUPBOX DLG_NULL 16 5
|
||||
BEGIN
|
||||
PROMPT 1 0 "@bMaschera"
|
||||
END
|
||||
|
||||
BUTTON 101 10
|
||||
BUTTON 101 12
|
||||
BEGIN
|
||||
PROMPT 2 1 "Normale"
|
||||
END
|
||||
|
||||
BUTTON 102 10
|
||||
BUTTON 102 12
|
||||
BEGIN
|
||||
PROMPT 19 1 "Chiaro"
|
||||
PROMPT 2 2 "Chiaro"
|
||||
END
|
||||
|
||||
BUTTON 103 10
|
||||
BUTTON 103 12
|
||||
BEGIN
|
||||
PROMPT 36 1 "Scuro"
|
||||
PROMPT 2 3 "Scuro"
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 14 4
|
||||
GROUPBOX DLG_NULL 16 5
|
||||
BEGIN
|
||||
PROMPT 1 3 "@bNormale"
|
||||
PROMPT 19 0 "@bBottoni"
|
||||
END
|
||||
|
||||
BUTTON 104 10
|
||||
BUTTON 111 12
|
||||
BEGIN
|
||||
PROMPT 2 4 "Testo"
|
||||
PROMPT 20 1 "Sfondo"
|
||||
END
|
||||
|
||||
BUTTON 105 10
|
||||
BUTTON 112 12
|
||||
BEGIN
|
||||
PROMPT 2 5 "Sfondo"
|
||||
PROMPT 20 2 "Chiaro"
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 14 4
|
||||
BUTTON 113 12
|
||||
BEGIN
|
||||
PROMPT 18 3 "@bAttivo"
|
||||
PROMPT 20 3 "Scuro"
|
||||
END
|
||||
|
||||
BUTTON 106 10
|
||||
GROUPBOX DLG_NULL 16 5
|
||||
BEGIN
|
||||
PROMPT 19 4 "Testo"
|
||||
PROMPT 37 0 "@bNormale"
|
||||
END
|
||||
|
||||
BUTTON 107 10
|
||||
BUTTON 104 12
|
||||
BEGIN
|
||||
PROMPT 19 5 "Sfondo"
|
||||
PROMPT 38 1 "Testo"
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 14 4
|
||||
BUTTON 105 12
|
||||
BEGIN
|
||||
PROMPT 35 3 "@bDisabilitato"
|
||||
PROMPT 38 2 "Sfondo"
|
||||
END
|
||||
|
||||
BUTTON 108 10
|
||||
BUTTON 106 12
|
||||
BEGIN
|
||||
PROMPT 36 4 "Testo"
|
||||
PROMPT 38 3 "Obbligatorio"
|
||||
END
|
||||
|
||||
BUTTON 109 10
|
||||
|
||||
GROUPBOX DLG_NULL 16 4
|
||||
BEGIN
|
||||
PROMPT 36 5 "Sfondo"
|
||||
PROMPT 37 5 "@bAttivo"
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 14 5
|
||||
BUTTON 107 12
|
||||
BEGIN
|
||||
PROMPT 35 7 "@bBottone"
|
||||
PROMPT 38 6 "Testo"
|
||||
END
|
||||
|
||||
BUTTON 110 10
|
||||
BUTTON 108 12
|
||||
BEGIN
|
||||
PROMPT 36 8 "Sfondo"
|
||||
PROMPT 38 7 "Sfondo"
|
||||
END
|
||||
|
||||
BUTTON 111 10
|
||||
GROUPBOX DLG_NULL 16 4
|
||||
BEGIN
|
||||
PROMPT 36 9 "Chiaro"
|
||||
PROMPT 37 9 "@bDisabilitato"
|
||||
END
|
||||
|
||||
BUTTON 112 10
|
||||
BUTTON 109 12
|
||||
BEGIN
|
||||
PROMPT 36 10 "Scuro"
|
||||
PROMPT 38 10 "Testo"
|
||||
END
|
||||
|
||||
BOOLEAN 113
|
||||
BUTTON 110 12
|
||||
BEGIN
|
||||
PROMPT 2 18 "Campi 3D"
|
||||
PROMPT 38 11 "Sfondo"
|
||||
END
|
||||
|
||||
BOOLEAN 115
|
||||
BOOLEAN 213
|
||||
BEGIN
|
||||
PROMPT 2 17 "Icone alternative"
|
||||
PROMPT 38 13 "Campi 3D"
|
||||
END
|
||||
|
||||
BUTTON 114 10 2
|
||||
BOOLEAN 215
|
||||
BEGIN
|
||||
PROMPT 20 -1 "Font"
|
||||
PROMPT 38 14 "Icone piccole"
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 14 8
|
||||
BUTTON 214 12 2
|
||||
BEGIN
|
||||
PROMPT 35 12 ""
|
||||
PROMPT -33 16 "Font"
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 10 2
|
||||
BUTTON DLG_CANCEL 12 2
|
||||
BEGIN
|
||||
PROMPT 36 13 "Annulla"
|
||||
PROMPT -13 -1 "Annulla"
|
||||
END
|
||||
|
||||
BUTTON DLG_USER 10 2
|
||||
BUTTON DLG_USER 12 2
|
||||
BEGIN
|
||||
PROMPT 36 15 "A~zzera"
|
||||
PROMPT -23 -1 "A~zzera"
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 10 2
|
||||
BUTTON DLG_OK 12 2
|
||||
BEGIN
|
||||
PROMPT 36 17 "Conferma"
|
||||
PICTURE BMP_OK
|
||||
PROMPT -33 -1 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
PAGE "Preferiti" -1 -1 70 16
|
||||
|
||||
BOOLEAN F_PREF_TREE
|
||||
LIST F_PREF_TREE 1 10
|
||||
BEGIN
|
||||
PROMPT 1 0 "Menu ad albero"
|
||||
PROMPT 1 0 "Tipo di Menu"
|
||||
ITEM " |Normale"
|
||||
ITEM "1|Albero"
|
||||
ITEM "2|Explorer"
|
||||
END
|
||||
|
||||
SPREADSHEET F_PREF_SHEET 63 -3
|
||||
|
@ -2239,7 +2239,8 @@ int ba1600(int argc, char* argv[])
|
||||
TCreazione_dischi app;
|
||||
app.run(argc, argv, TR("Creazione dischetti"));
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
error_box(FR("L'utente %s non e' abilitato all'esecuzione di questo programma"), (const char*)user());
|
||||
return 0;
|
||||
}
|
||||
|
@ -624,7 +624,7 @@ KEY TInstaller_mask::askdisk(TString & path, TFilename & cmdline, int d, int dis
|
||||
TMask retry_mask(TR("Inserimento dischi"),1,80,10);
|
||||
|
||||
retry_mask.add_static((F_PATH==101 ? 102:101),0,
|
||||
format(FR("Inserire il disco %d di %d del modulo'%s' nell' unità indicata"), d, dischi, modulo)
|
||||
format(FR("Inserire il disco %d di %d del modulo'%s' nell'unità"), d, dischi, modulo)
|
||||
,2,2);
|
||||
retry_mask.add_static(F_PATH+3,0,TR("oppure indicare un percorso diverso"),2,3);
|
||||
|
||||
|
@ -109,14 +109,18 @@ bool TArchive_mask::on_field_event(TOperable_field& o, TField_event e, long joll
|
||||
bool TArchive_app::create()
|
||||
{
|
||||
bool ok = TRUE;
|
||||
|
||||
|
||||
TIsamfile utenti(LF_USER);
|
||||
utenti.open(_excllock);
|
||||
for (int err = utenti.first(); err == NOERR; err = utenti.next())
|
||||
{
|
||||
const TString16 u = utenti.get("USERNAME");
|
||||
if (u != user() && utenti.get_bool("CONNECTED"))
|
||||
#ifdef DBG
|
||||
ok = yesno_box("L'archiviazione non puo' essere effettuata\nse ci sono altri utenti collegati (%s)", (const char*)u);
|
||||
#else
|
||||
ok = error_box(FR("L'archiviazione non puo' essere effettuata\nse ci sono altri utenti collegati (%s)"), (const char*)u);
|
||||
#endif
|
||||
}
|
||||
utenti.close();
|
||||
|
||||
|
@ -3214,7 +3214,8 @@ KEY TEditMask_window::main_loop()
|
||||
//Richiama <TApplication::create>
|
||||
bool TMaskEditor_application::create()
|
||||
{
|
||||
return TApplication::create();
|
||||
dispatch_e_menu(MENU_ITEM(11));
|
||||
return true;
|
||||
}
|
||||
|
||||
//Richiama <TApplication::destroy>
|
||||
@ -3485,7 +3486,6 @@ bool TMaskEditor_application::menu(MENU_TAG m)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//int main(int argc, char* argv[])
|
||||
int ba2600(int argc, char* argv[])
|
||||
{
|
||||
TMaskEditor_application a;
|
||||
|
@ -3,12 +3,11 @@ Caption = "Menu Principale"
|
||||
Picture = <ba00.bmp>
|
||||
Module = 0
|
||||
Flags = ""
|
||||
Item_01 = "Anagrafiche di base", [MENU_001]
|
||||
Item_02 = "Amministrazione", <cgarea.men>
|
||||
Item_03 = "Acquisti e vendite", <vearea.men>
|
||||
Item_04 = "Magazzino e Produzione", <mgarea.men>
|
||||
Item_11 = "Comunicazione", [MENU_019]
|
||||
Item_11 = "Manutenzione", [MENU_015]
|
||||
Item_01 = "Anagrafiche di base", [MENU_001], "", 10214
|
||||
Item_02 = "Amministrazione", <cgarea.men>, "", 10212
|
||||
Item_03 = "Acquisti e vendite", <vearea.men>, "", 10211
|
||||
Item_04 = "Magazzino e Produzione", <mgarea.men>, "", 10215
|
||||
Item_05 = "Manutenzione", [MENU_015], "", 10210
|
||||
|
||||
[MENU_001]
|
||||
Caption = "Gestione Anagrafiche"
|
||||
@ -95,18 +94,9 @@ Item_03 = "Utenti", "ba1 -3", ""
|
||||
Item_04 = "Attivazione moduli", "ba1 -4", ""
|
||||
Item_05 = "Installazione moduli", "ba1 -6", ""
|
||||
Item_06 = "Creazione dischi di installazione", "ba1 -5", ""
|
||||
Item_07 = "Backup", "ba2 -1", ""
|
||||
Item_07 = "Backup", "ba2 -1", "", 10213
|
||||
Item_08 = "Conversione all'Euro", [MENU_883]
|
||||
|
||||
[MENU_019]
|
||||
Caption = "Comunicazione"
|
||||
Picture = <ba05.bmp>
|
||||
Module = 0
|
||||
Item_01 = "EasyDoc", "c:\EasyDoc\EasyDoc.exe", ""
|
||||
Item_02 = "Gestione Fax", "bafax -s", ""
|
||||
Item_03 = "Archivio fax spediti e ricevuti", disabled
|
||||
Item_04 = "Archivio contatti telefonici", disabled
|
||||
|
||||
[MENU_883]
|
||||
Caption = "Conversione all'Euro"
|
||||
Picture = <ba00.bmp>
|
||||
|
@ -1,2 +0,0 @@
|
||||
@echo off
|
||||
zip386.exe %1 -@ < %2
|
@ -113,6 +113,7 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
for (short id = 111; id <= 114; id++)
|
||||
{
|
||||
is.delete_column(id);
|
||||
|
||||
ism.hide(id); // Descrizioni commessa e fase
|
||||
}
|
||||
}
|
||||
@ -1831,4 +1832,4 @@ int cg2100 (int argc, char** argv)
|
||||
a->run(argc, argv, "Prima nota");
|
||||
delete a;
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -89,17 +89,12 @@ Flags = ""
|
||||
Item_01 = "Prima nota", "cg2 -0", "F"
|
||||
Item_02 = "Gestione movimenti provvisori", "cg2 -1", "F"
|
||||
Item_03 = "Visualizzazione mastrini", "cg3 -5", "F"
|
||||
Item_04 = "IVA", [CGMENU_010]
|
||||
Item_05 = "Lista movimenti", "cg3 -0 M", "F"
|
||||
Item_06 = "Lista fatture per clienti/fornitori", "cg3 -0 C", "F"
|
||||
Item_07 = "Stampa Mastrini", "cg3 -1", "F"
|
||||
Item_08 = "Stampa Riepiloghi", "cg3 -4", "F"
|
||||
Item_09 = "Visualizzazione saldi", "cg5 -2", "F"
|
||||
Item_10 = "Ricalcolo saldi", "cg4 -0", "F"
|
||||
Item_11 = "Bilancio", "cg1 -4", "F"
|
||||
Item_12 = "Bilancio IV direttiva CEE", "cg1 -5", "F"
|
||||
Item_13 = "Giornale", "cg3 -3", "F"
|
||||
Item_14 = "Saldaconto", <scmenu.men>
|
||||
Item_04 = "Visualizzazione saldi", "cg5 -2", "F"
|
||||
Item_05 = "Ricalcolo saldi", "cg4 -0", "F"
|
||||
Item_06 = "IVA", [CGMENU_010]
|
||||
Item_07 = "Stampe di contabilita`", [CGMENU_023]
|
||||
Item_08 = "Stampe CDC/Commesse ", <cmmenu.men>
|
||||
Item_09 = "Saldaconto", <scmenu.men>
|
||||
|
||||
[CGMENU_010]
|
||||
Caption = "IVA"
|
||||
@ -231,6 +226,19 @@ Item_02 = "Gestione versamenti", "ba3 -0 %del", ""
|
||||
Item_03 = "Stampa versamenti", "cg1 -3", "F"
|
||||
Item_04 = "Gestione profili deleghe e distinte", "ba2 -0", ""
|
||||
|
||||
[CGMENU_023]
|
||||
Caption = "Stampe di contabilita`"
|
||||
Picture = <cg01.bmp>
|
||||
Module = 7
|
||||
Flags = ""
|
||||
Item_01 = "Lista movimenti", "cg3 -0 M", "F"
|
||||
Item_02 = "Lista fatture per clienti/fornitori", "cg3 -0 C", "F"
|
||||
Item_03 = "Stampa Mastrini", "cg3 -1", "F"
|
||||
Item_04 = "Stampa Riepiloghi", "cg3 -4", "F"
|
||||
Item_05 = "Bilancio", "cg1 -4", "F"
|
||||
Item_06 = "Bilancio IV direttiva CEE", "cg1 -5", "F"
|
||||
Item_07 = "Giornale", "cg3 -3", "F"
|
||||
|
||||
[CGMENU_025]
|
||||
Caption = "Collegamento bilanci"
|
||||
Picture = <cg01.bmp>
|
||||
|
@ -58,18 +58,6 @@ bool handle_ok(int handle)
|
||||
|
||||
static char* find_slash_backslash(const char* s)
|
||||
{
|
||||
/*
|
||||
const int l = strlen(str);
|
||||
const char* xstr = str + l;
|
||||
while (xstr-- && l--)
|
||||
if (*xstr == '\\' || *xstr == '/' || l <= 0)
|
||||
break;
|
||||
if (l <= 0)
|
||||
return NULL;
|
||||
else
|
||||
return xstr;
|
||||
*/
|
||||
|
||||
const char* slash = NULL;
|
||||
for ( ; *s; s++)
|
||||
{
|
||||
|
@ -51,6 +51,7 @@ COLOR blend_colors(COLOR col1, COLOR col2, int perc)
|
||||
}
|
||||
|
||||
|
||||
|
||||
class TColor_row_mask : public TMask
|
||||
{
|
||||
public:
|
||||
@ -329,4 +330,3 @@ TSelect_color_mask::~TSelect_color_mask()
|
||||
{
|
||||
delete _sheet_mask;
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ TImage::TImage(const TImage& im, short w, short h) : _image(NULL)
|
||||
|
||||
if (ok())
|
||||
{
|
||||
#ifndef XVAGA
|
||||
if (fmt == XVT_IMAGE_CL8)
|
||||
{
|
||||
const short colors = xvt_image_get_ncolors(im._image);
|
||||
@ -88,6 +89,7 @@ TImage::TImage(const TImage& im, short w, short h) : _image(NULL)
|
||||
for (short c = 0; c < colors; c++)
|
||||
xvt_image_set_clut(_image, c, xvt_image_get_clut((XVT_IMAGE)im._image, c));
|
||||
}
|
||||
#endif
|
||||
xvt_image_transfer(_image, (XVT_IMAGE)im._image, &_src, (RCT*)&im._src);
|
||||
}
|
||||
}
|
||||
|
@ -957,8 +957,9 @@ int TBaseisamfile::_read(TRectype& rec, word op, word lockop)
|
||||
|
||||
_lasterr = cisread(fhnd, getkey(), rec, op + lockop, _recno);
|
||||
|
||||
_recno = DB_recno(fhnd); // qui
|
||||
if(rec.has_memo())
|
||||
// _recno = DB_recno(fhnd); // Gia' fatto nella cisread
|
||||
|
||||
if(rec.has_memo())
|
||||
rec.init_memo(_recno, _isam_handle);
|
||||
|
||||
if (_lasterr == NOERR)
|
||||
@ -1275,10 +1276,8 @@ int TBaseisamfile::_open(
|
||||
else
|
||||
fatal_box(msg);
|
||||
}
|
||||
if (prefix().get_recdes(_logicnum).NKeys <= 0) // qui
|
||||
fatal_box("Il file %d (%s) e' senza indici",
|
||||
num(),
|
||||
(const char*)filename);
|
||||
if (prefix().get_recdes(_logicnum).NKeys <= 0)
|
||||
fatal_box("Il file %d (%s) e' senza indici", num(), (const char*)filename);
|
||||
_recno = RECORD_NON_FISICO;
|
||||
setkey(_curr_key);
|
||||
_lasterr = NOERR;
|
||||
@ -2462,13 +2461,16 @@ int TSystemisamfile::load(
|
||||
char* s2 = (char*) s.get();
|
||||
if (fd)
|
||||
{
|
||||
s2++;
|
||||
s2[strlen(s2) - 1] = '\0';
|
||||
s1.rtrim(1);
|
||||
s1.ltrim(1);
|
||||
}
|
||||
if (curr().type((const TString&) fld[j]) == _memofld)
|
||||
s1 = esc(s2);
|
||||
else
|
||||
s1 = s2;
|
||||
{
|
||||
TString s2 = s1;
|
||||
|
||||
s1 = esc(s2);
|
||||
}
|
||||
|
||||
put((const TString&) fld[j], s1);
|
||||
}
|
||||
}
|
||||
@ -3362,9 +3364,6 @@ int TRectype::readat(TBaseisamfile& f, TRecnotype nrec, word lockop)
|
||||
// Certified 100%
|
||||
int TRectype::next(TBaseisamfile& f,word lockop)
|
||||
{
|
||||
/* const int err = f._read(*this, _isnext, lockop);
|
||||
*this = f.curr();
|
||||
return err; */
|
||||
return read(f, _isnext, lockop);
|
||||
}
|
||||
|
||||
|
@ -1562,6 +1562,7 @@ public:
|
||||
|
||||
class TWindowed_field : public TOperable_field
|
||||
{
|
||||
protected:
|
||||
short _dlg;
|
||||
TField_window* _win;
|
||||
|
||||
@ -1610,6 +1611,8 @@ public:
|
||||
bool goto_selected();
|
||||
|
||||
void set_header(const char* head);
|
||||
void set_row_height(int rh);
|
||||
|
||||
|
||||
TTree_field(TMask* m) : TWindowed_field(m) { }
|
||||
virtual ~TTree_field() { }
|
||||
@ -1637,4 +1640,3 @@ public:
|
||||
|
||||
#endif // __MASKFLD_H
|
||||
|
||||
|
||||
|
@ -1007,9 +1007,9 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
static char tmp[16];
|
||||
static clock_t digit_timer = 0;
|
||||
|
||||
|
||||
BOOLEAN& refused = xiev->refused;
|
||||
|
||||
|
||||
switch (xiev->type)
|
||||
{
|
||||
case XIE_GET_FIRST:
|
||||
@ -1110,6 +1110,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
if (xiev->v.cell_request.back_color == 0 && f->required())
|
||||
xiev->v.cell_request.back_color = REQUIRED_BACK_COLOR;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1585,7 +1585,7 @@ bool TPrinter::set()
|
||||
// determine index of currently selected printer
|
||||
// ACTHUNG! Deep hacking of XVT internals! NON PORTABLE!
|
||||
|
||||
_prname = (const char *)(get_printrcd() + 4);
|
||||
_prname = (const char *)(get_printrcd()) + 4;
|
||||
if (_prname.blank())
|
||||
_prname = oldprn;
|
||||
|
||||
|
@ -804,13 +804,15 @@ class TTree_window : public TField_window
|
||||
TAuto_token_string _header;
|
||||
int _headlines;
|
||||
|
||||
static int _row_height;
|
||||
/*static*/ int _row_height;
|
||||
static bool _tree_locked;
|
||||
|
||||
protected: // TWindow
|
||||
virtual void update();
|
||||
virtual bool on_key(KEY key);
|
||||
virtual void handler(WINDOW win, EVENT* ep);
|
||||
|
||||
int row_height() const { return _row_height; }
|
||||
PNT log2dev(long x, long y) const;
|
||||
TPoint dev2log(const PNT& p) const;
|
||||
|
||||
@ -830,12 +832,13 @@ public:
|
||||
bool goto_selected();
|
||||
void set_header(const char* head);
|
||||
|
||||
|
||||
TTree_window(int x, int y, int dx, int dy,
|
||||
WINDOW parent, TTree_field* owner);
|
||||
virtual ~TTree_window() { }
|
||||
};
|
||||
|
||||
int TTree_window::_row_height = CHARY+2;
|
||||
/* int TTree_window::_row_height = CHARY+2; */
|
||||
bool TTree_window::_tree_locked = FALSE;
|
||||
|
||||
const int TABX = 3;
|
||||
@ -929,19 +932,22 @@ bool TTree_window::callback_draw_node(TTree& node, void* jolly, word when)
|
||||
const WINDOW win = ui->_win->win();
|
||||
ui->_win->set_pen(DISABLED_COLOR);
|
||||
|
||||
const int rh = ui->_win->row_height();
|
||||
|
||||
PNT q;
|
||||
q.h = p.h; q.v = p.v + _row_height/2;
|
||||
q.h = p.h; q.v = p.v + rh/2;
|
||||
xvt_dwin_draw_set_pos(win, q);
|
||||
q.h -= TABX*CHARX - 3*CHARX/2;
|
||||
xvt_dwin_draw_line(win, q);
|
||||
q.v = (by+1+ui->_headlines)*_row_height;
|
||||
q.v = (by+1)*rh;
|
||||
|
||||
xvt_dwin_draw_line(win, q);
|
||||
|
||||
TImage* bmp = node.image(is_selected);
|
||||
if (bmp)
|
||||
{
|
||||
const int x = p.h;
|
||||
const int y = p.v + (_row_height - bmp->height()) / 2;
|
||||
const int y = p.v + (rh - bmp->height()) / 2;
|
||||
if (is_enabled)
|
||||
bmp->draw(win, x, y);
|
||||
else
|
||||
@ -1145,6 +1151,12 @@ bool TTree_window::goto_selected()
|
||||
return ok;
|
||||
}
|
||||
|
||||
void TTree_window::set_row_height(int rh)
|
||||
{
|
||||
if (rh <= 0)
|
||||
rh = CHARY+2;
|
||||
_row_height = rh;
|
||||
}
|
||||
|
||||
int TTree_window::info2index(const TNode_info& info) const
|
||||
{
|
||||
@ -1347,7 +1359,7 @@ TTree_window::TTree_window(int x, int y, int dx, int dy,
|
||||
: TField_window(x, y, dx, dy, parent, owner), _tree(NULL),
|
||||
_hide_leaves(FALSE), _headlines(0)
|
||||
{
|
||||
_row_height = CHARY+2;
|
||||
set_row_height(-1); // Compute default row height
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1397,7 +1409,14 @@ void TTree_field::set_header(const char* head)
|
||||
tree_win().set_header(head);
|
||||
}
|
||||
|
||||
void TTree_field::set_row_height(int rh)
|
||||
{
|
||||
tree_win().set_row_height(rh);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TField_window* TTree_field::create_window(int x, int y, int dx, int dy, WINDOW parent)
|
||||
{
|
||||
return new TTree_window(x, y, dx, dy, parent, this);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include <wx/wx.h>
|
||||
#include <wx/wxprec.h>
|
||||
#include <wx/datetime.h>
|
||||
#include <wx/snglinst.h>
|
||||
#include <wx/socket.h>
|
||||
|
@ -1,6 +1,13 @@
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "BaseServ.h"
|
||||
|
||||
#include <wx/db.h>
|
||||
#include <wx/dbtable.h>
|
||||
//#include <wx/db.h>
|
||||
#include <wx/mstream.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
@ -1,3 +1,3 @@
|
||||
mondrian ICON "soap.ico"
|
||||
#include "wx/msw/wx.rc"
|
||||
#include "../../wx240/include/wx/msw/wx.rc"
|
||||
|
||||
|
@ -1897,6 +1897,7 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc)
|
||||
else
|
||||
_righe_iva->add(r, conto, ALL_DECIMALS, perc);
|
||||
|
||||
|
||||
}
|
||||
r.put(RDOC_CODIVA, codiva2); //Restore
|
||||
}
|
||||
|
@ -2360,6 +2360,7 @@ bool TDocumento_mask::controeuro_handler( TMask_field& f, KEY key )
|
||||
|
||||
bool TDocumento_mask::codval_handler( TMask_field& f, KEY key )
|
||||
|
||||
|
||||
{
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
@ -2388,4 +2389,3 @@ bool TDocumento_mask::codval_handler( TMask_field& f, KEY key )
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -2175,7 +2175,10 @@ SLIST xvt_fsys_list_files(char *type, char *pat, BOOLEAN dirs)
|
||||
wxString f = ::wxFindFirstFile(pat, flags);
|
||||
while (!f.IsEmpty())
|
||||
{
|
||||
xvt_slist_add_at_elt(list, NULL, f, 0L);
|
||||
if (f.StartsWith(".\\"))
|
||||
f = f.Mid(2);
|
||||
xvt_slist_add_at_elt(list, NULL, f, 0L);
|
||||
|
||||
f = ::wxFindNextFile();
|
||||
}
|
||||
|
||||
@ -3150,6 +3153,9 @@ long xvt_vobj_get_attr(WINDOW win, long data)
|
||||
case ATTR_TASK_WINDOW:
|
||||
ret = long(_task_win);
|
||||
break;
|
||||
case ATTR_WIN_INSTANCE:
|
||||
ret = 0;
|
||||
break;
|
||||
case ATTR_WIN_PM_DRAWABLE_TWIN:
|
||||
ret = TRUE;
|
||||
break;
|
||||
@ -3502,4 +3508,4 @@ WINDOW statbar_create(int cid, int left, int top, int right, int bottom,
|
||||
w.SetStatusWidths(2, widths);
|
||||
|
||||
return (WINDOW)&w;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user