Browsefile, listbox
git-svn-id: svn://10.65.10.50/trunk@2818 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c9e5acad42
commit
2474fc25ad
@ -23,6 +23,8 @@ class TBrowsefile_field : public TOperable_field
|
||||
TArray _links;
|
||||
TArray _background;
|
||||
bool _m_link;
|
||||
short _dlg;
|
||||
WINDOW _parent;
|
||||
|
||||
protected:
|
||||
virtual word class_id() const;
|
||||
@ -61,7 +63,11 @@ public:
|
||||
// print background
|
||||
void set_background(const char* bg);
|
||||
TArray* get_bg_desc() { return &_background; }
|
||||
|
||||
|
||||
virtual short dlg() const { return _dlg; }
|
||||
// @cmember Ritorna la finestra padre
|
||||
virtual WINDOW parent() const { return _parent; }
|
||||
|
||||
TBrowsefile_field(TMask* m);
|
||||
virtual ~TBrowsefile_field();
|
||||
};
|
||||
|
@ -650,9 +650,7 @@ TMask_field* TMask::parse_field(TScanner& scanner)
|
||||
if (k == "RA") return new TRadio_field(this);
|
||||
if (k == "ME") return new TMemo_field(this);
|
||||
if (k == "ZO") return new TZoom_field(this);
|
||||
/* Guy
|
||||
if (k == "BR") return new TBrowsefile_field(this);
|
||||
*/
|
||||
if (k == "SP")
|
||||
{
|
||||
_sheets++;
|
||||
|
@ -145,13 +145,13 @@ public:
|
||||
short atodlg(const char* s) const;
|
||||
|
||||
// @cmember Ritorna la finestra padre
|
||||
WINDOW parent() const;
|
||||
virtual WINDOW parent() const;
|
||||
|
||||
RCT& get_rect(RCT& r) const;
|
||||
void set_rect(const RCT& r);
|
||||
|
||||
// @cmember Ritorna l'identificatore del controllo
|
||||
short dlg() const;
|
||||
virtual short dlg() const;
|
||||
|
||||
// @cmember Controlla se si tratta di un controllo corretto
|
||||
virtual bool ok() const;
|
||||
|
@ -1,3 +1,281 @@
|
||||
<<<<<<< progind.cpp
|
||||
#include <defmask.h>
|
||||
#include <progind.h>
|
||||
#include <controls.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
const char* const TITLE_TEXT = "Attesa";
|
||||
|
||||
word TIndwin::measure_text(TToken_string& s, word& maxlen) const
|
||||
{
|
||||
word lines = 0;
|
||||
for(const char* t = s.get(0); t; t = s.get())
|
||||
{
|
||||
const word l = strlen(t);
|
||||
if (l > maxlen) maxlen = l;
|
||||
lines++;
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
// Certified 70%
|
||||
TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
|
||||
: _text(NULL), _cancel(NULL), _bar(0),
|
||||
_status(0L), _max(max), _flags(0x0)
|
||||
{
|
||||
if (_max <= 0) _max = 1;
|
||||
|
||||
TToken_string testo(txt, '\n');
|
||||
word maxlen = div;
|
||||
const word lines = measure_text(testo, maxlen);
|
||||
|
||||
int ver = lines+2;
|
||||
|
||||
int hor = maxlen+2; if (hor > 78) hor = 78;
|
||||
|
||||
if (bar)
|
||||
{
|
||||
_bar = ver * CHARY;
|
||||
ver += 2;
|
||||
}
|
||||
ver += cancel ? 2 : 0;
|
||||
|
||||
set_win(create_interface(TASK_WIN, -1, -1, hor, ver, TITLE_TEXT, this, FALSE));
|
||||
|
||||
_text = new TMultiline_control(win(), DLG_NULL, 1, 1, hor-2, lines, 512, "CD", "");
|
||||
|
||||
testo.replace('\n', '\r');
|
||||
_text->set_caption(testo);
|
||||
|
||||
if (cancel)
|
||||
{
|
||||
_cancel = new TPushbutton_control(win(), DLG_CANCEL, -11, -1, 10, 2, "", "Annulla", BMP_CANCEL);
|
||||
}
|
||||
open_modal();
|
||||
do_events();
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @mfunc Setta il testo della finestra
|
||||
void TIndwin::set_text(
|
||||
const char* t) // @parm Testo della finestra
|
||||
|
||||
// @comm Si puo' chiamare questa funzione per cambiare il testo, ma
|
||||
// le dimensioni della finestra sono calcolate sul primo testo
|
||||
// passato, quindi occorre dimensionare correttamente il primo passato
|
||||
// (es. inserire degli spazi) se se ne prevede uno piu' lungo.
|
||||
{
|
||||
_text->set_caption(t);
|
||||
}
|
||||
|
||||
TIndwin::~TIndwin()
|
||||
{
|
||||
close_modal();
|
||||
|
||||
if (_text) delete _text;
|
||||
if (_cancel) delete _cancel;
|
||||
}
|
||||
|
||||
bool TIndwin::can_be_closed() const
|
||||
{
|
||||
const bool ok = (_flags & IND_FINISHED) || (_flags & IND_CANCELLED);
|
||||
if (!ok) error_box("Attendere la fine dell'operazione prima di chiudere l'applicazione");
|
||||
return ok;
|
||||
}
|
||||
|
||||
KEY TIndwin::check_stop()
|
||||
{
|
||||
KEY k = 0;
|
||||
if ((_flags & IND_FINISHED) || (_flags & IND_CANCELLED))
|
||||
{
|
||||
k = (_flags & IND_FINISHED) ? K_ENTER : K_ESC;
|
||||
stop_run(k);
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
void TIndwin::update_bar()
|
||||
{
|
||||
if (_status >= _max)
|
||||
{
|
||||
_status = _max;
|
||||
_flags |= IND_FINISHED;
|
||||
}
|
||||
|
||||
const double prc = (double)_status/_max;
|
||||
|
||||
RCT r; xvt_vobj_get_client_rect(win(), &r);
|
||||
r.left = CHARX; r.right -= CHARX;
|
||||
r.top = (int)_bar;
|
||||
r.bottom = r.top + 2*CHARY;
|
||||
|
||||
const int width = r.right - r.left;
|
||||
RCT b = r;
|
||||
set_pen(COLOR_BLACK);
|
||||
|
||||
/*
|
||||
set_brush(COLOR_BLUE);
|
||||
b.right = b.left + int(width*prc);
|
||||
xvt_dwin_draw_rect(win(), &b);
|
||||
|
||||
set_brush(COLOR_WHITE);
|
||||
b.left = b.right; b.right = r.right;
|
||||
xvt_dwin_draw_rect(win(), &b);
|
||||
|
||||
set_mode(M_XOR);
|
||||
xvt_dwin_set_fore_color(win(), COLOR_BLUE);
|
||||
char n[8]; sprintf(n, "%d%%", int(100*prc));
|
||||
xvt_dwin_draw_text(win(), r.left+width/2-CHARX, (r.bottom+r.top+CHARY)/2-3, n, -1);
|
||||
set_mode(M_COPY);
|
||||
*/
|
||||
|
||||
WINDOW w = win();
|
||||
b.right = b.left + int(width*prc);
|
||||
xi_draw_3d_rect(w, &b, FALSE, 2, 0, 0, 0);
|
||||
|
||||
set_brush(COLOR_WHITE);
|
||||
b.left = b.right; b.right = r.right;
|
||||
xvt_dwin_draw_rect(w, &b);
|
||||
|
||||
char n[8]; sprintf(n, "%d%%", int(100*prc));
|
||||
xvt_dwin_draw_text(w, r.left+width/2-CHARX, (r.bottom+r.top+CHARY)/2-3, n, -1);
|
||||
|
||||
check_stop();
|
||||
}
|
||||
|
||||
void TIndwin::update()
|
||||
{
|
||||
if (_bar) update_bar();
|
||||
}
|
||||
|
||||
bool TIndwin::on_key(KEY k)
|
||||
{
|
||||
if (k == K_ESC && _cancel)
|
||||
{
|
||||
_flags |= IND_CANCELLED;
|
||||
check_stop();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TIndwin::on_button(short id)
|
||||
{
|
||||
if (id == DLG_CANCEL)
|
||||
on_key(K_ESC);
|
||||
}
|
||||
|
||||
|
||||
// TProgind --------------------------------------------------------------
|
||||
|
||||
TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)
|
||||
: TIndwin(max, txt, cancel, bar, div)
|
||||
{}
|
||||
|
||||
// TTimerind ------------------------------------------------------------
|
||||
|
||||
long TTimerind::_timer_id = 0L;
|
||||
|
||||
void TTimerind::handler(WINDOW w, EVENT* e)
|
||||
{
|
||||
switch(e->type)
|
||||
{
|
||||
case E_CREATE:
|
||||
case E_UPDATE:
|
||||
if (_status == 0L)
|
||||
_timer_id = xvt_timer_create(w, _interval);
|
||||
break;
|
||||
case E_TIMER:
|
||||
if (e->v.timer.id == _timer_id)
|
||||
{
|
||||
_status += _interval;
|
||||
force_update();
|
||||
xvt_timer_create(w, _interval);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
TIndwin::handler(w,e);
|
||||
}
|
||||
|
||||
TTimerind::TTimerind(long msec, const char* txt,
|
||||
bool cancel, bool bar, int div, int i) :
|
||||
TIndwin(msec, txt, cancel, bar, div)
|
||||
{
|
||||
_interval = i;
|
||||
_timer_id = 0L;
|
||||
}
|
||||
|
||||
TTimerind::~TTimerind()
|
||||
{ xvt_timer_destroy(_timer_id); }
|
||||
|
||||
// C-style binding
|
||||
// uses static pointer for single instance of TIndwin
|
||||
|
||||
static TIndwin* __indwin__p = NULL;
|
||||
|
||||
void progind_create(long m, char* t, bool b, bool c, int n)
|
||||
{
|
||||
CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator");
|
||||
__indwin__p = new TProgind(m,t,b,c,n);
|
||||
}
|
||||
|
||||
void progind_set_status(long l)
|
||||
{
|
||||
((TProgind*)__indwin__p)->setstatus(l);
|
||||
}
|
||||
|
||||
void progind_cancel()
|
||||
{
|
||||
__indwin__p->cancel();
|
||||
}
|
||||
|
||||
bool progind_iscancelled()
|
||||
{
|
||||
return __indwin__p->iscancelled();
|
||||
}
|
||||
|
||||
bool progind_isfinished()
|
||||
{
|
||||
return __indwin__p->isfinished();
|
||||
}
|
||||
|
||||
void progind_destroy()
|
||||
{
|
||||
delete __indwin__p;
|
||||
__indwin__p = NULL;
|
||||
}
|
||||
|
||||
void timerind_create(long l, char* title, bool bar, bool cancel,
|
||||
int divisions, int interval)
|
||||
{
|
||||
CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator");
|
||||
__indwin__p = new TTimerind(l,title,bar,cancel,divisions,interval);
|
||||
}
|
||||
|
||||
void timerind_cancel()
|
||||
{
|
||||
__indwin__p->cancel();
|
||||
}
|
||||
|
||||
bool timerind_iscancelled()
|
||||
{
|
||||
return __indwin__p->iscancelled();
|
||||
}
|
||||
|
||||
bool timerind_isfinished()
|
||||
{
|
||||
return __indwin__p->isfinished();
|
||||
}
|
||||
|
||||
void timerind_destroy()
|
||||
{
|
||||
delete __indwin__p;
|
||||
__indwin__p = NULL;
|
||||
}
|
||||
|
||||
=======
|
||||
#include <defmask.h>
|
||||
#include <progind.h>
|
||||
#include <controls.h>
|
||||
@ -257,3 +535,4 @@ void timerind_destroy()
|
||||
__indwin__p = NULL;
|
||||
}
|
||||
|
||||
>>>>>>> 1.11
|
||||
|
@ -2646,6 +2646,8 @@ void TBrowsefile_field::create(WINDOW parent)
|
||||
_ctl_data._x, _ctl_data._y, _ctl_data._size, _ctl_data._width,
|
||||
_flags.rightjust ? TRUE : FALSE, parent, this);
|
||||
WINDOW win = _viswin->win();
|
||||
_dlg = _ctl_data._dlg;
|
||||
_parent = parent;
|
||||
xvt_vobj_set_enabled(win, enabled());
|
||||
xvt_vobj_set_visible(win, shown());
|
||||
}
|
||||
|
@ -326,8 +326,8 @@ public:
|
||||
void find_next();
|
||||
|
||||
// @cmember void | TViswin | const char* fname=NULL, const char* title=NULL,
|
||||
// bool editbutton=TRUE, int width=0, bool rulers=TRUE,
|
||||
// WINDOW parent=NULL_WIN, TBrowsefile_field*=NULL | Costruttore
|
||||
// bool editbutton=TRUE, int width=0, bool rulers=TRUE,
|
||||
// WINDOW parent=NULL_WIN, TBrowsefile_field*=NULL | Costruttore
|
||||
TViswin(const char* fname=NULL, const char* title=NULL, bool editbutton=TRUE,
|
||||
bool printbutton=TRUE, bool linkbutton=TRUE, int x=-1, int y=-1, int height=0,
|
||||
int width=0, bool rulers=TRUE, WINDOW parent=NULL_WIN, TBrowsefile_field* =NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user