Patch level : 2.0 nopatch

Files correlati     : ba0.exe
Ricompilazione Demo : [ ]
Commento            :

Aggiunto menu preferiti.
Corretta gestione "Aggiungi a preferiti" nel caso di Expolrer mode


git-svn-id: svn://10.65.10.50/trunk@11495 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2003-10-14 13:44:01 +00:00
parent 73159b6e3b
commit 8c42e5fa15
7 changed files with 152 additions and 45 deletions

View File

@ -87,6 +87,7 @@ protected:
void load_preferences();
void save_preferences();
void update_preferred_tree();
void update_preferred();
void add_to_preferred();
void manage_preferred();
@ -345,7 +346,7 @@ bool TColor_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
TColor_mask::TColor_mask()
: TAutomask("ba0200a")
{
TConfig color(CONFIG_USER, "Colors");
TConfig color(CONFIG_GUI, "Colors");
_color = color.list_variables();
set(213, CAMPI_SCAVATI ? "X" : "");
set(215, ADVANCED_GRAPHICS ? "X" : "");
@ -433,7 +434,7 @@ void TColor_mask::update()
void TColor_mask::save_colors()
{
TConfig colors(CONFIG_USER, "Colors");
TConfig colors(CONFIG_GUI, "Colors");
FOR_EACH_ASSOC_STRING(_color, obj, key, str)
colors.set(key, str);
colors.set("Campi3D", get_bool(213) ? "X" : "");
@ -927,13 +928,14 @@ bool TMenu_application::create()
if (!test_programs())
return FALSE;
if (!_menu.ok())
{
TWait_cursor hourglass;
TFilename menu = _name;
menu.ext("men");
_menu.read(menu);
update_preferred_tree();
TSkeleton_application::create();
}
@ -1068,7 +1070,7 @@ bool TMenu_application::choose_editors()
{
disable_menu_item(OPTIONS_MENU);
TConfig link(CONFIG_USER, "Link");
TConfig link(CONFIG_GUI, "Link");
TMask* msk = new TMask("ba0300a");
TMask& m = *msk;
@ -1322,31 +1324,62 @@ void TMenu_application::update_preferred()
xvt_menu_set_tree(TASK_WIN, mm);
xvt_menu_update(TASK_WIN);
xvt_res_free_menu_tree(mm);
update_preferred_tree();
}
void TMenu_application::update_preferred_tree()
{
TSubmenu* pref = _menu.find("MENU_PREFERITI");
if (pref != NULL && _preferred.items() > 0)
{
TToken_string node(16, '.');
pref->destroy_items();
FOR_EACH_ARRAY_ROW(_preferred, i, row)
{
int slash = row->rfind('/');
if (slash < 0)
slash = row->rfind(row->separator());
node = row->mid(slash+1);
if (node.items() == 2)
{
const char* sub = node.get(0);
TSubmenu* sm = _menu.find(sub);
if (sm != NULL)
{
const int num = node.get_int(1);
pref->add(new TMenuitem(sm->item(num)));
}
}
}
}
}
void TMenu_application::load_preferences()
{
TConfig cfg(CONFIG_USER, "ba0");
TConfig cfg(CONFIG_GUI, "ba0");
_tree_view = cfg.get_int("TreeView");
_preferred.destroy();
TToken_string row;
for (int i = 0; ; i++)
int i;
for (i = 0; ; i++)
{
row = cfg.get("Preferred", NULL, i);
if (row.empty_items())
break;
_preferred.add(row);
}
if (i > 0)
update_preferred();
}
void TMenu_application::save_preferences()
{
TConfig cfg(CONFIG_USER, "ba0");
TConfig cfg(CONFIG_GUI, "ba0");
for (int i = 0; i < _preferred.items(); i++)
cfg.set("Preferred", _preferred.row(i), NULL, TRUE, i);
cfg.set("Preferred", "", NULL, TRUE, i);
@ -1363,31 +1396,43 @@ void TMenu_application::add_to_preferred()
if (_preferred.items() < maxpref)
{
TToken_string tok;
if (_tree_view != 0)
{
TTree_field& tf = _mask->tfield(DLG_TREE);
tf.goto_selected();
tf.tree()->get_description(tok);
TString id; tf.tree()->curr_id(id);
tok.add(id);
}
else
{
const TMask_field& butt = _mask->focus_field();
const int index = butt.dlg() - 101;
if (index >= 0 && index < 16)
{
_menu.select(index);
tok = _menu.curr_item().caption();
tok.add(_menu.current().name());
tok << '.' << index;
switch (_tree_view)
{
case 1:
{
TTree_field& tf = _mask->tfield(DLG_TREE);
tf.goto_selected();
tf.tree()->get_description(tok);
TString id; tf.tree()->curr_id(id);
tok.add(id);
}
break;
case 2:
{
TMenulist_field& mf = (TMenulist_field&)_mask->field(DLG_LIST);
mf.curr_item(tok);
}
break;
default:
{
const TMask_field& butt = _mask->focus_field();
const int index = butt.dlg() - 101;
if (index >= 0 && index < 16)
{
_menu.select(index);
tok = _menu.curr_item().caption();
tok.add(_menu.current().name());
tok << '.' << index;
}
}
break;
}
if (!tok.empty())
if (tok.not_empty() && _preferred.find(tok) < 0)
{
_preferred.add(tok);
update_preferred();
save_preferences();
update_preferred();
}
}
else
@ -1480,8 +1525,8 @@ void TMenu_application::manage_preferred()
const int old_tv = _tree_view;
_tree_view = m->get_int(F_PREF_TREE);
update_preferred();
save_preferences();
update_preferred();
if (_tree_view != old_tv && _mask != NULL)
{

View File

@ -102,11 +102,19 @@ public:
///////////////////////////////////////////////////////////
TMenuitem::TMenuitem(TSubmenu* sm)
: _submenu(sm),
_exist(-1), _firm(FALSE), _password(FALSE), _reloadmenu(FALSE),
: _submenu(sm), _exist(-1), _firm(FALSE),
_password(FALSE), _reloadmenu(FALSE),
_color(NORMAL_COLOR), _icon(0)
{ }
TMenuitem::TMenuitem(const TMenuitem& mi)
: _submenu(mi._submenu), _exist(mi._exist), _firm(mi._firm),
_password(mi._password), _reloadmenu(mi._reloadmenu),
_color(mi._color), _icon(mi._icon), _enabled(mi._enabled),
_caption(mi._caption), _action(mi._action), _type(mi._type)
{ }
TMenu& TMenuitem::menu() const
{ return _submenu->menu(); }
@ -363,7 +371,7 @@ void TSubmenu::read(TScanner& scanner)
if (line.compare("Item", 4, TRUE) == 0)
{
TMenuitem* item = new TMenuitem(this);
_items.add(item);
add(item);
item->create(line);
}
}
@ -392,6 +400,18 @@ int TSubmenu::find_string(const TString& str) const
return found ? 0 : -1;
}
int TSubmenu::find(const TMenuitem& it) const
{
int i;
for (i = items()-1; i >= 0; i--)
{
const TMenuitem& mi = item(i);
if (mi.action() == it.action())
break;
}
return i;
}
TImage& TSubmenu::image() const
{
return menu().image(picture());

View File

@ -63,6 +63,7 @@ public:
void create(const char* t);
TMenuitem(TSubmenu* sm);
TMenuitem(const TMenuitem& mi);
virtual ~TMenuitem() { }
};
@ -85,6 +86,10 @@ public:
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); }
int find(const TMenuitem& mi) const;
void destroy_items() { _items.destroy(); }
void add(TMenuitem* mi) { _items.add(mi); }
const TString& name() const { return _name; }
const TString& caption() const { return _caption; }

View File

@ -362,27 +362,28 @@ TObject* TMenulist_images::key2obj(const char* key)
const int w = image.width();
const int h = image.height();
const int radius = 3*min(w, h)/4;
const int radius = min(w, h) / 4;
const clock_t start_timer = clock();
for (int y = h-1; y >= 0; y--)
{
for (int x = w-1; x >= 0; x--)
{
const int r = fast_hypot(x-w/2, y-h/2);
if (r < radius)
if (r > radius)
{
// const double perc = 0.7 - (0.7 * r / radius);
const double perc = 0.5 - (0.5 * 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 double perc = 1.0 - (double(r - radius) / (radius*1.5));
if (perc >= 0.0)
{
COLOR col = image.get_pixel(x, y);
COLOR bri = blend_colors(col, NORMAL_BACK_COLOR, perc);
image.set_pixel(x, y, bri);
}
else
image.set_pixel(x, y, NORMAL_BACK_COLOR);
}
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;
RCT rct; xvt_vobj_get_client_rect(_win, &rct);
const double ratiox = double(rct.right) / image.width();
@ -429,6 +430,7 @@ protected:
void select(int s, int direction);
public:
void curr_item(TToken_string& id) const;
void set_menu(TMenu_tree& mt);
TMenulist_window(int x, int y, int dx, int dy, WINDOW parent, TMenulist_field* owner);
@ -528,6 +530,12 @@ void TMenulist_window::click_on(int index)
const TMenuitem& mi = (const TMenuitem&)_sorted[index];
if (mi.enabled())
{
if (xvt_vobj_get_attr(NULL_WIN, ATTR_SPEECH_MODE) & (1<<7))
{
const TString& str = mi.caption();
if (str.find("..") < 0)
xvt_dm_post_speech(str, 7, TRUE);
}
if (mi.is_submenu())
{
if (index == 0 && _can_go_back) // Sù di un livello
@ -563,6 +571,8 @@ void TMenulist_window::click_on(int index)
}
set_focus();
}
else
xvt_sys_beep(1);
}
}
@ -683,6 +693,19 @@ void TMenulist_window::synchronize_buddy_tree() const
}
}
void TMenulist_window::curr_item(TToken_string& id) const
{
if (_selected >= 0 && _selected < _sorted.items())
{
const TMenuitem& item = (const TMenuitem&)_sorted[_selected];
const TSubmenu& sm = item.submenu();
const int index = sm.find(item);
id = item.caption();
id.add(sm.name());
id << '.' << index;
}
}
void TMenulist_window::set_menu(TMenu_tree& tree)
{
_tree = &tree;
@ -761,3 +784,9 @@ void TMenulist_field::set_menu(TMenu_tree& mt)
TMenulist_window& w = (TMenulist_window&)win();
w.set_menu(mt);
}
void TMenulist_field::curr_item(TToken_string& id) const
{
TMenulist_window& w = (TMenulist_window&)win();
w.curr_item(id);
}

View File

@ -63,6 +63,7 @@ protected: // TWindowed_field
public:
void set_menu(TMenu_tree& mt);
void create(short dlg, int x, int y, int dx, int dy);
void curr_item(TToken_string& id) const;
TMenulist_field(TMask* m) : TWindowed_field(m) { }
virtual ~TMenulist_field() { }

View File

@ -37,8 +37,7 @@ HIDDEN void encode_string(char* dninst_key, char* data)
HIDDEN bool build_dninst(const TFilename& name)
{
TFilename src = name; src.ext("txt");
ifstream inf(src, ios::in | ios::nocreate);
ifstream inf("dninst.txt", ios::in | ios::nocreate);
if (inf.good())
{
char dninst_key[8] = "";

View File

@ -8,6 +8,7 @@ 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
Item_06 = "Preferiti", [MENU_PREFERITI], "", 10216
[MENU_001]
Caption = "Gestione Anagrafiche"
@ -95,3 +96,10 @@ 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", "", 10213
[MENU_PREFERITI]
Caption = "Preferiti"
Picture = <ba00>
Module = 0
Flags = ""