Patch level : 10.0

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
execp:  usate macro USR_* per accedere ai cami di LF_USER
progind: eliminato bottone di annullamento e sostituito con X di chiusura finestra
retprint:tolte righe commentate inutili
window: sostituito TRUE con true


git-svn-id: svn://10.65.10.50/trunk@17342 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-10-02 15:57:06 +00:00
parent 1e9d8243a7
commit 68569f358f
5 changed files with 72 additions and 54 deletions

View File

@ -4,6 +4,7 @@
#include <execp.h>
#include <prefix.h>
#include <recarray.h>
#include <user.h>
static bool is_outlook_menu_chain()
{
@ -70,7 +71,7 @@ long TExternal_app::run(
if (dir.not_empty() && dir.find("custom") < 0)
{
DIRECTORY d;
if (xvt_fsys_convert_str_to_dir((char*)(const char*)dir, &d))
if (xvt_fsys_convert_str_to_dir(dir, &d))
xvt_fsys_set_dir(&d);
}
}
@ -133,18 +134,18 @@ bool TExternal_app::can_run() const
return TRUE;
const TLocalisamfile test(LF_USER);
if (test.curr().exist("PERMISSION"))
if (test.curr().exist(USR_PERMISSION))
{
TRecord_cache utonti(LF_USER); // Non uso cache() per problemi durante conversioni
TToken_string perm(4096, '\n'), row(80,SAFE_PIPE_CHR);
for (TString16 u = user(); u.not_empty(); u = utonti.get(u, "GROUPNAME"))
for (TString16 u = user(); u.not_empty(); u = utonti.get(u, USR_GROUPNAME))
{
if (utonti.already_loaded(u))
{
NFCHECK("L'utente %s ha dei permessi ricorsivi", (const char*)u);
break;
}
perm = utonti.get(u, "PERMISSION");
perm = utonti.get(u, USR_PERMISSION);
if (!perm.blank())
{
FOR_EACH_TOKEN(perm, tok)

View File

@ -5,6 +5,7 @@
#include <diction.h>
#include <progind.h>
#include <controls.h>
#include <reprint.h>
#include <urldefid.h>
int TIndwin::_indwin_count = 0;
@ -23,7 +24,7 @@ word TIndwin::measure_text(TToken_string& s, word& maxlen) const
// Certified 70%
TIndwin::TIndwin(long tot, const char* txt, bool cancel, bool bar, int div)
: _text(NULL), _cancel(NULL), _gauge(NULL_WIN), _bar(0),
: _gauge(NULL_WIN), _can_cancel(cancel), _bar_top(0),
_flags(0x0), _max(tot), _status(0L)
{
TToken_string testo(txt, '\n');
@ -31,34 +32,27 @@ TIndwin::TIndwin(long tot, const char* txt, bool cancel, bool bar, int div)
const word lines = measure_text(testo, maxlen);
const int hor = min(maxlen+3, 78);
const int ver = lines+1 + (bar ? 2 : 0) + (cancel ? 2: 0);
const int ver = lines+3 + (bar ? 2 : 0);
const int y = _indwin_count == 0 ? 3 : 12;
set_win(create_interface(TASK_WIN, -1, y, hor, ver, TR("Elaborazione in corso"), this/*, FALSE*/));
long flags = WSF_INVISIBLE;
if (_can_cancel)
flags |= WSF_CLOSE;
create(-1, y, hor, ver, TR("Elaborazione in corso"), flags, WD_MODAL);
_bar_top = (lines+1)*ROWY;
_text = new TMultiline_control(win(), DLG_NULL, 1, 0, hor-2, lines+1, 512, "CD", "");
_text->set_read_only();
set_text(testo);
if (bar)
{
WIN_DEF wd; memset(&wd, 0, sizeof(wd));
wd.wtype = WC_HGAUGE;
RCT& r = wd.rct;
_text->get_rect(r);
_bar = r.bottom + CHARY;
get_bar_rct(r);
get_bar_rct(wd.rct);
_gauge = xvt_ctl_create_def(&wd, win(), tot);
}
if (cancel)
_cancel = new TPushbutton_control(win(), DLG_CANCEL, -11, -1, 12, 2, "", "", BMP_CANCEL);
open_modal();
do_events();
_indwin_count++;
setmax(tot);
@ -75,15 +69,13 @@ void TIndwin::set_text(
// passato, quindi occorre dimensionare correttamente il primo passato
// (es. inserire degli spazi) quando se ne prevede uno piu' lungo.
{
//#ifdef XI_R4
_text->set_caption(t);
/*
#else
TString testo(t);
testo.replace('\n', '\r');
_text->set_caption(testo);
#endif
*/
_text.destroy();
TToken_string txt(t, '\n');
FOR_EACH_TOKEN(txt, tok)
_text.add(tok);
RCT r; get_txt_rct(r);
xvt_dwin_invalidate_rect(win(), &r);
}
void TIndwin::setmax(long m)
@ -98,9 +90,6 @@ TIndwin::~TIndwin()
{
if (is_open())
close_modal();
if (_cancel) delete _cancel;
if (_text) delete _text;
_indwin_count--;
}
@ -117,19 +106,26 @@ KEY TIndwin::check_stop()
if ((_flags & IND_FINISHED) || (_flags & IND_CANCELLED))
{
k = (_flags & IND_FINISHED) ? K_ENTER : K_ESC;
stop_run(k);
if (is_running())
stop_run(k);
}
return k;
}
RCT* TIndwin::get_bar_rct(RCT& r) const
void TIndwin::get_bar_rct(RCT& r) const
{
xvt_vobj_get_client_rect(win(), &r);
r.left += CHARX;
r.right -= CHARX;
r.top = _bar;
r.top = _bar_top;
r.bottom = r.top + ROWY;
return &r;
}
void TIndwin::get_txt_rct(RCT& r) const
{
get_bar_rct(r);
r.bottom = r.top - ROWY/2;
r.top = ROWY/2;
}
void TIndwin::sec2str(unsigned long ss, TString& str) const
@ -185,8 +181,26 @@ void TIndwin::update_bar()
void TIndwin::update()
{
clear(MASK_BACK_COLOR);
if (_gauge != NULL_WIN)
update_bar();
if (!_text.empty())
{
RCT r; get_txt_rct(r);
WINDOW w = win();
CBRUSH brush; brush.pat = PAT_SOLID; brush.color = MASK_BACK_COLOR;
xvt_dwin_set_cbrush(w, &brush);
xvt_dwin_set_std_cpen(w, TL_PEN_HOLLOW);
xvt_dwin_draw_rect(w, &r);
xvt_dwin_set_clip(w, NULL);
set_color(NORMAL_COLOR, MASK_BACK_COLOR);
set_opaque_text(TRUE);
set_font();
advanced_draw_paragraph(*this, _text, r, 'L', 'C', CHARY);
}
}
bool TIndwin::setstatus(long l)
@ -207,18 +221,24 @@ bool TIndwin::setstatus(long l)
bool TIndwin::on_key(KEY k)
{
if (k == K_ESC && _cancel)
if (k == K_ESC && _can_cancel)
{
_flags |= IND_CANCELLED;
check_stop();
}
return TRUE;
return true; // Ignora tutti gli altri tasti, senza chiamare TWindow::on_key(k)
}
void TIndwin::on_button(short id)
bool TIndwin::stop_run(KEY k)
{
if (id == DLG_CANCEL)
on_key(K_ESC);
if (k == K_ESC)
{
if (_can_cancel)
_flags |= IND_CANCELLED;
else
return false;
}
return TWindow::stop_run(k);
}

View File

@ -28,13 +28,12 @@ class TIndwin : public TWindow
// @ccost:(INTERNAL) IND_FINISHED | 0x02 | Controlla se l'operazione e' terminata
IND_FINISHED= 0x02 };
// @cmember:(INTERNAL) Testo da inserire nella finestra
TField_control* _text;
// @cmember:(INTERNAL) Bottone "Annulla"
TControl* _cancel;
TString_array _text;
short _bar_top;
bool _can_cancel;
// @cmember:(INTERNAL) Movimento della barra e percentuale
WINDOW _gauge;
int _bar;
// @cmember:(INTERNAL) ora inizio elaborazione
unsigned long _start_time;
@ -53,16 +52,16 @@ protected:
word measure_text(TToken_string& t, word& len) const;
// @cmember Calcola il rettangolo della barra di attesa
RCT* get_bar_rct(RCT& r) const;
void get_bar_rct(RCT& r) const;
// @cmember Calcola il rettangolo del testo
void get_txt_rct(RCT& r) const;
// @cmember converte secondi in una stringa nel formato hh:mm:ss
void sec2str(unsigned long ss, TString& str) const;
// @cmember Gestisce gli eventi tasto della finestra
virtual bool on_key(KEY k);
// @cmember Gestisce gli eventi bottone della finestra
virtual void on_button(short id);
virtual bool stop_run(KEY k);
// @cmember Aggiorna la barra di attesa (chiama update_bar)
virtual void update();

View File

@ -114,8 +114,6 @@ void advanced_draw_text_line(TWindow& win, const char* text, const RCT& r, char
xvt_dwin_draw_text(w, x, y, text, -1);
if (restore_clip)
xvt_dwin_set_clip(w, &orig);
// else
// xvt_dwin_set_clip(w, NULL);
}
}

View File

@ -492,7 +492,7 @@ bool TWindow::stop_run(KEY key)
{
_running = FALSE;
_lastkey = key;
return TRUE;
return true;
}
bool TWindow::can_be_closed() const