Patch level : 10.0

Files correlati     : tutti
Ricompilazione Demo : [ ]
Commento            :
Cambiata gestione chiavi alternative di ordinamento nelle maschere di ricerca
Corretta gestione bottoni di filtro sulle ricerche stesse


git-svn-id: svn://10.65.10.50/trunk@16788 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-06-19 15:36:49 +00:00
parent de77f64a9c
commit 1fb9f09beb
10 changed files with 208 additions and 40 deletions

View File

@ -16,31 +16,31 @@ END
BUTTON DLG_FIRSTREC 3
BEGIN
PROMPT -34 -1 "Prima pagina"
PROMPT -34 -1 "Prima"
PICTURE 121
END
BUTTON DLG_PREVREC 3
BEGIN
PROMPT -34 -2 "Pagina Precedente"
PROMPT -34 -2 "Precedente"
PICTURE 122
END
BUTTON DLG_FINDREC 10 2
BEGIN
PROMPT -34 -1 "Ricerca Pagina"
PROMPT -34 -1 "Pagina"
PICTURE 166
END
BUTTON DLG_NEXTREC 3
BEGIN
PROMPT -34 -2 "Prossima pagina"
PROMPT -34 -2 "Prossima"
PICTURE 124
END
BUTTON DLG_LASTREC 3
BEGIN
PROMPT -34 -1 "Ultima Pagina"
PROMPT -34 -1 "Ultima"
PICTURE 125
END

View File

@ -93,21 +93,22 @@ class TPicture_array
TArray _enabled, _disabled;
public:
bool add(short id);
short add(const char * n);
bool add(int id);
int add(const char* n);
int add_icon(int id);
const TImage& image(short id) const { return (const TImage&)_enabled[id]; }
const TImage& disabled_image(short id) const { return (const TImage&)_disabled[id]; }
bool exist(short id) const { return _enabled.objptr(id) != NULL; }
const TImage& image(int id) const { return (const TImage&)_enabled[id]; }
const TImage& disabled_image(int id) const { return (const TImage&)_disabled[id]; }
bool exist(int id) const { return _enabled.objptr(id) != NULL; }
void reload();
TPicture_array() {}
virtual ~TPicture_array() {}
};
short TPicture_array::add(const char * n)
int TPicture_array::add(const char* n)
{
short id; // calcola il prossimo identificatore di immagine libero
int id; // calcola il prossimo identificatore di immagine libero
for (id = 30000; _enabled.objptr(id) != NULL; id++);
TImage* i = new TImage(n);
@ -120,7 +121,25 @@ short TPicture_array::add(const char * n)
return id;
}
bool TPicture_array::add(short id)
int TPicture_array::add_icon(int id)
{
const int rid = 50000+id;
TImage* i = (TImage*)_enabled.objptr(rid);
if (i == NULL)
{
TConfig ini("res/resource.ini", "Icons");
TString8 strid; strid << id;
TFilename n; n << "res/" << ini.get(strid);
TImage* i = new TImage(n);
_enabled.add(i, rid);
TImage* d = new TImage(*i);
d->fade_to_gray(true);
_disabled.add(d, rid);
}
return rid;
}
bool TPicture_array::add(int id)
{
TImage* i = (TImage*)_enabled.objptr(id);
if (i == NULL)
@ -1729,13 +1748,13 @@ void TPushbutton_control::set_caption(const char* c)
}
}
void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
void TPushbutton_control::set_bmp(int bmp_up, int bmp_dn)
{
if (bmp_up > 0)
{
set_icon(0);
_bmp_up = (bmp_up > 0 && _picture->add(bmp_up)) ? bmp_up : 0;
_bmp_dn = (bmp_dn > 0 && _picture->add(bmp_dn)) ? bmp_dn : _bmp_up;
set_icon(0);
}
else
_bmp_up = _bmp_dn = 0;
@ -1755,16 +1774,32 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
_obj->v.btn->drawable = _bmp_up > 0;
}
void TPushbutton_control::set_icon(int icon_up, int icon_dn)
{
if (xi_get_native_controls(_obj))
{
TButton_control::set_icon(0, 0);
if (icon_up > 0)
{
const int bmp_up = _picture->add_icon(icon_up);
const int bmp_dn = _picture->add_icon(icon_dn > 0 ? icon_dn : icon_up);
set_bmp(bmp_up, bmp_dn);
}
}
else
TButton_control::set_icon(icon_up, icon_dn);
}
void TPushbutton_control::set_bmp(const char* bmp_up, const char* bmp_dn)
{
if (bmp_up && *bmp_up)
{
set_icon(0);
_bmp_up = _picture->add(bmp_up);
if (bmp_dn && *bmp_dn)
_bmp_dn = _picture->add(bmp_dn);
else
_bmp_dn = _bmp_up;
set_icon(0);
}
else
_bmp_up = _bmp_dn = 0;
@ -1842,10 +1877,39 @@ TCheckbox_control::TCheckbox_control(WINDOW win, short cid,
// TCheckbutton_control
///////////////////////////////////////////////////////////
void TCheckbutton_control::check(bool on)
{
TButton_control::check(on);
if (xi_get_native_controls(_obj))
{
XVT_IMAGE img_up = _picture->image(on ? _pic_dn : _pic_up).xvt_image();
XVT_IMAGE img_dn = _picture->image(on ? _pic_up : _pic_dn).xvt_image();
xvt_btn_set_images((WINDOW)_obj->v.btn->btnctl, img_up, img_dn);
}
}
void TCheckbutton_control::set_icon(int icon_up, int icon_dn)
{
if (xi_get_native_controls(_obj))
{
TButton_control::set_icon(0, 0);
if (icon_up > 0)
{
_pic_up = _picture->add_icon(icon_up);
_pic_dn = _picture->add_icon(icon_dn > 0 ? icon_dn : icon_up);
XVT_IMAGE img_up = _pic_up > 0 ? _picture->image(_pic_up).xvt_image() : NULL;
XVT_IMAGE img_dn = _pic_dn > 0 ? _picture->image(_pic_dn).xvt_image() : NULL;
xvt_btn_set_images((WINDOW)_obj->v.btn->btnctl, img_up, img_dn);
}
}
else
TButton_control::set_icon(icon_up, icon_dn);
}
TCheckbutton_control::TCheckbutton_control(WINDOW win, short cid,
short left, short top, short width, int height,
const char* flags, const char* text,
short icon_up, short icon_dn)
int icon_up, int icon_dn)
{
create(win, cid, left, top, width, height, flags, text, WC_CHECKBUTTON, NULL);
set_icon(icon_up, icon_dn);

View File

@ -202,14 +202,14 @@ protected:
public:
bool checked() const;
void check(bool on = true);
virtual void check(bool on = true);
void uncheck() { check(false); }
bool toggle();
int button_type() const;
XI_OBJ* container() const;
void set_icon(unsigned int icon_up, unsigned int icon_dn = 0);
virtual void set_icon(unsigned int icon_up, unsigned int icon_dn = 0);
TButton_control() {}
virtual ~TButton_control() {}
@ -229,8 +229,9 @@ public:
// @cmember Setta il prompt del bottone
virtual void set_caption(const char* c);
void set_bmp(short up, short dn);
void set_bmp(int up, int dn);
void set_bmp(const char * up, const char * dn);
void set_icon(int icon_up, int icon_dn = 0);
void set_central_icon(unsigned int hicon);
char mnemonic() const;
@ -294,11 +295,18 @@ public:
class TCheckbutton_control : public TButton_control
{
int _pic_up, _pic_dn;
protected:
virtual void check(bool on);
public:
virtual void set_icon(int icon_up, int icon_dn);
TCheckbutton_control(WINDOW win, short cid,
short left, short top, short width, int height,
const char* flags, const char* text,
short icon_up, short icon_dn);
int icon_up, int icon_dn);
virtual ~TCheckbutton_control() {}
};
@ -372,6 +380,4 @@ public:
virtual ~TListbox_control();
};
#endif

View File

@ -167,6 +167,7 @@ bool TPostman::can_dispatch_transaction(const TRectype& rec)
for (int r = 0; cfg.exist("Recipient", r); r++)
{
str = cfg.get("Recipient", NULL, r);
expand_sys_vars(str);
TRecipient* rcp = new TRecipient(str);
_recipient.add(rcp);
}
@ -175,6 +176,8 @@ bool TPostman::can_dispatch_transaction(const TRectype& rec)
for (int f = 0; cfg.exist("Filter", f); f++)
{
str = cfg.get("Filter", NULL, f);
expand_sys_vars(str);
const int num = str.get_int(1);
if (num != rec.num()) continue;
@ -274,10 +277,10 @@ bool TPostman::dispatch_transaction(const TRectype& rec,
if (a.can_receive(rec))
{
const TString& addr = a.address();
if (addr.find('@') >= 0) // Indirizzo posta
dest.add(addr);
if (addr.starts_with("http")) // Indirizzo http
soap_dest.add(addr);
soap_dest.add(addr); else
if (addr.find('@') > 0) // Indirizzo posta
dest.add(addr);
else
{
if (fexist(addr))
@ -326,7 +329,7 @@ bool TPostman::dispatch_transaction(const TRectype& rec,
if (file_dest.items() > 0)
{
TString16 basename;
const struct tm * tl = xvt_time_now();
const struct tm* tl = xvt_time_now();
basename.format("%02d%02d%02d_%02d%02d%02d_0",
tl->tm_year%100, tl->tm_mon+1, tl->tm_mday,
tl->tm_hour, tl->tm_min, tl->tm_sec);

View File

@ -1389,13 +1389,11 @@ void TRelation_application::main_loop()
const bool trovato = _mask->query_mode() && test_key(1, FALSE) && find(1);
if (trovato)
{
if (is_transaction())
_curr_transaction=TRANSACTION_MODIFY;
else
warning_box(TR("Elemento gia' presente"));
modify_mode();
}
else
insert_mode();

View File

@ -990,18 +990,20 @@ void TQuery_field::create(WINDOW parent)
///////////////////////////////////////////////////////////
#define DLG_QUERY 25883
TSheet::TSheet(short x, short y, short dx, short dy,
const char* title, const char* head,
byte buttons, short sht_y, WINDOW parent)
: TMask(title, 1, dx, dy, x, y, parent),
_sheet(NULL), _select_row(-1), _parked(-1)
{
#ifdef OLD_FASHIONED_BROWSE
if (sht_y > 0) // Crea notebook se TBrowse_sheet
{
create_book(false); // Crea notebook e poi ...
create_page(title, 0); // ... la sua prima pagina
}
#endif
create_bar(1); // Crea toolbar in alto
TQuery_field* qf = new TQuery_field(this);
@ -1759,11 +1761,55 @@ void TBrowse_sheet::handler(
TCursor_sheet::handler(win, ep);
}
#ifndef OLD_FASHIONED_BROWSE
bool lst_handler(TMask_field& lst, KEY k)
{
if (k == K_SPACE)
{
TMask& m = lst.mask();
if (m.is_running())
{
const int sel = atoi(lst.get());
m.on_key(K_CTRL + K_F1 + sel);
}
}
return true;
}
#endif
void TBrowse_sheet::create_key_selector(TToken_string& ca)
{
#ifdef OLD_FASHIONED_BROWSE
set_tab_buttons(ca); // Non funziona piu' bene: cambiamo strada
#else
const int items = ca.items();
if (items > 1)
{
TToken_string co;
for (int i = 0; i < items; i++)
co.add(i);
TList_field& lst = add_list(69, 0, PR("Ordinamento per "), 1, 0, 16, "", co, ca);
lst.set_handler(lst_handler);
}
#endif
}
void TBrowse_sheet::update_key_selector(int sel)
{
#ifdef OLD_FASHIONED_BROWSE
show_page(sel);
#else
if (id2pos(69) >= 0) // Has been created?
set(69, sel, 0); // Don't fire any events!
#endif
}
TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
const char* title, const char* head, byte buttons,
TEdit_field& f, TToken_string& sibling)
: TCursor_sheet(cursor, fields, title, head, buttons,
f.browse() ? f.browse()->input_fields() : 1),
f.browse() ? f.browse()->input_fields()+1 : 1),
_field(f), _sel(0), _original_filter(cursor->filter())
{
const bool normal = f.browse() != NULL && sibling.full();
@ -1787,8 +1833,8 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
if (ca.blank())
ca = TR("Codice");
}
set_tab_buttons(ca);
create_key_selector(ca);
TToken_string tids = head;
TToken_string tfns = fields;
TToken_string ids, fns;
@ -1799,8 +1845,13 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
}
TEditable_field* e = NULL;
short y = 0;
bool first = true;
#ifdef OLD_FASHIONED_BROWSE
int y = 0;
#else
int y = 1;
#endif
bool first = true;
for (const char* i = ids.get(0); i; i = ids.get())
{
@ -1899,7 +1950,7 @@ bool TBrowse_sheet::on_key(KEY k)
const int what = k - K_CTRL - K_F1;
if (what >= 0 && what != _sel)
TWindow::stop_run(k);
return TRUE;
return true;
}
return TSheet::on_key(k);
}
@ -1907,7 +1958,7 @@ bool TBrowse_sheet::on_key(KEY k)
KEY TBrowse_sheet::run()
{
_cur_browse = this;
show_page(_sel);
update_key_selector(_sel);
const KEY key = TCursor_sheet::run();
_cur_browse = NULL;
return key;

View File

@ -245,6 +245,8 @@ protected:
// @cmember Ritorna il campo a cui si riferisce lo sheet
TEdit_field& field() { return _field; }
void create_key_selector(TToken_string& ca);
void update_key_selector(int sel);
void add_custom_filter(const char* regexp);
static bool browse_field_handler(TMask_field& f, KEY k);

View File

@ -1,6 +1,7 @@
#include <xvt.h>
#include <statbar.h>
#include <date.h>
#include <diction.h>
#include <utility.h>
@ -600,3 +601,44 @@ bool is_power_station()
}
return false;
}
bool expand_sys_vars(TString& str)
{
bool found = false;
for (int i = str.find("$("); i >= 0; i = str.find("$("))
{
TString value;
int j = str.find(')', i);
if (j < 0) j = i+2;
const TString& name = str.sub(i+2, j);
if (name.compare("HostName", -1, true) == 0)
{
value = get_hostname();
} else
if (name.compare("UserName", -1, true) == 0)
{
value = user();
} else
if (name.compare("Session", -1, true) == 0)
{
value << xvt_sys_get_session_id();
} else
if (name.compare("DateAnsi", -1, true) == 0)
{
const TDate oggi(TODAY);
value << oggi.date2ansi();
} else
if (name.compare("TimeAnsi", -1, true) == 0)
{
value.format("%06ld", daytime());
}
const TString& before = str.left(i);
const TString& after = str.mid(j + 1);
str.cut(0) << before << value << after;
found = true;
}
return found;
}

View File

@ -49,10 +49,10 @@ const char* unesc(const char* str); // Trasforma i caratteri '\n' nella sequenza
istream& eatwhite (istream& i);
const TString & get_hostname();
const TString& get_hostname();
bool is_power_station();
long daytime();
bool expand_sys_vars(TString& str);
#define ODD(x) (x & 1)
#define EVEN(x) !(x & 1)

View File

@ -387,7 +387,9 @@ void set_xvt_hooks()
xvt_vobj_set_attr(NULL_WIN,ATTR_ERRMSG_HANDLER, (long)error_hook);
xvt_vobj_set_attr(NULL_WIN,ATTR_WIN_PM_DRAWABLE_TWIN, TRUE);
long twin_style = WSF_ICONIZABLE | WSF_CLOSE | WSF_SIZE;
long twin_style = xvt_vobj_get_attr(NULL_WIN,ATTR_WIN_PM_TWIN_STARTUP_STYLE);
twin_style |= WSF_ICONIZABLE | WSF_CLOSE; // WSF_SIZE pare azzardato
TConfig cfg(CONFIG_GUI, "Colors");
const int res = cfg.get_int("Resolution");
const int scx = xvt_vobj_get_attr(NULL_WIN, ATTR_SCREEN_WIDTH);