applicat.* Sostituiti __argc e __argv con _argc_ _argv_ perche'

esistono gia' a 32 bit
array.h      Aggiunto cast per evitare warning a 32 bit
codeb.c      Tolte define inutili in CB6
controls.*   Corretta e migliorata gestione listbox a 32 bit


git-svn-id: svn://10.65.10.50/trunk@6348 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-03-13 10:18:29 +00:00
parent 109e0c26bb
commit a3d13d1b9f
6 changed files with 139 additions and 87 deletions

View File

@ -552,8 +552,8 @@ void TApplication::run(
if (user().empty())
check_parameters(argc, argv);
__argc = argc;
__argv = (const char**)argv;
_argc_ = argc;
_argv_ = (const char**)argv;
if (argc > 1 && argv[1][0] == '-')
{
@ -619,7 +619,7 @@ bool TApplication::get_version_info(int& year, int& release, int& tag, int& patc
// About box: risposta alla opzione Informazioni del menu File
void TApplication::about() const
{
const TFilename n(__argv[0]);
const TFilename n(argv(0));
const word ser_no = dongle().number();
int year, release, tag, patch;

View File

@ -30,9 +30,9 @@ class TApplication
// // @cmember:(INTERNAL) Identificatore del menu' legato all'applicazione
// int _bar;
// @cmember:(INTERNAL) Numero di argomenti passati all'applicazione
int __argc;
int _argc_;
// @cmember:(INTERNAL) Array di argomenti passati all'applicazione
const char** __argv;
const char** _argv_;
// @cmember:(INTERNAL) Ora di inizio utilizzo del programma (per versioni DEMO)
time_t _start_time;
// @cmember:(INTERNAL) Array di autorizzazione concessa della chiavi
@ -141,12 +141,12 @@ public:
{ return _name; }
// @cmember Ritorna l'array di parametri da passare all'applicazione
const char** argv() const
{ return __argv; }
{ return _argv_; }
// @cmember Ritroan il parametro <p i>-esimo da passare all'applicazione
const char* argv(int i) const { return __argv[i]; }
const char* argv(int i) const { return _argv_[i]; }
// @cmember Ritorna il numero di paramentri da passare all'applicazione
int argc() const
{ return __argc; }
{ return _argc_; }
// @cmember Setta il titolo da assegnare all'applicazione
void set_title(const char* t)

View File

@ -256,7 +256,7 @@ protected:
{ return word(n >> 3); }
// @cmember Ritorna la posizione del bit <p n> all'interno del byte
byte mask(long n) const
{ return 1 << (n & 0x7); }
{ return byte(1 << (n & 0x7)); }
// @access Public Member
public:

View File

@ -22,33 +22,26 @@
#define S4OFF_REPORT
#ifdef CB6
#if XVT_OS == XVT_OS_WIN
#define S4DLL
#define S4WIN16
#else
#endif
#if XVT_OS == XVT_OS_WIN32
#define S4DLL
#define S4WIN32
#else
#define S4UNIX
#endif
#endif
// #ifdef XVT /* This not recommended in Unix!*/
// #undef S4UNIX
// #define S4DLL
// #endif
#ifdef FOXPRO
#undef S4UNIX
#define S4DLL
#define S4WIN16
#endif
#pragma pack(1)
//#pragma pack(1)
#include <d4all.h>
// #include <x4filter.h>
// #include <i4chang.h>
#pragma pack()
//#pragma pack()
#include <codeb.h>
#include <rectypes.h>
#include <progind.h>

View File

@ -561,7 +561,6 @@ HIDDEN void xi_event_handler(XI_OBJ* itf, XI_EVENT* xiev)
TWindow* w = (TWindow*)xi_get_app_data(itf);
CHECK(w, "Can't send XVT event to a null window");
w->handler(w->win(), &xiev->v.xvte);
if (xiev->v.xvte.type == E_MOUSE_UP)
_button_blocked = FALSE;
}
@ -1517,13 +1516,25 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
void TPushbutton_control::update()
{
const long attrib = xi_get_attrib(_obj);
const WINDOW win = parent();
if (attrib & XI_ATR_VISIBLE)
{
RCT rct = (RCT&) _obj->v.btn->rct;
rct.left += 5; rct.top += 5; rct.right -= 5; rct.bottom -= 5;
#ifdef XI_R4
XinWindow xiwin = xi_get_window(_obj->itf);
xi_set_clip(xiwin, (XinRect *) &rct );
#endif
// Cancello il testo sottostante
const WINDOW win = parent();
CBRUSH brush = { PAT_SOLID, BTN_BACK_COLOR };
xvt_dwin_set_cbrush(win, &brush);
xvt_dwin_set_std_cpen(win, TL_PEN_HOLLOW);
xvt_dwin_draw_rect(win, &rct);
if (_native_hicon)
{
const RCT& rct = (RCT &) _obj->v.btn->rct;
os_draw_native_icon(win, rct, _native_hicon);
return;
}
@ -1532,23 +1543,15 @@ void TPushbutton_control::update()
if (bmp > 0)
{
const TImage& i = _picture->image(bmp);
const RCT& rct = (RCT &) _obj->v.btn->rct;
int x = rct.left + (rct.right - rct.left - i.width()) / 2;
int y = rct.top + (rct.bottom - rct.top - i.height()) / 2;
int x = (rct.right + rct.left - i.width()) / 2;
int y = (rct.bottom + rct.top - i.height()) / 2;
if (_obj->v.btn->down)
{
x += 2;
y += 2;
}
#ifdef XI_R4
XinWindow win = xi_get_window(_obj->itf);
xi_set_clip( win, (XinRect *) &rct );
#endif
i.draw(win, x, y);
#ifdef XI_R4
xi_set_clip( win, NULL );
#endif
if (!(attrib & XI_ATR_ENABLED))
{
@ -1574,6 +1577,9 @@ void TPushbutton_control::update()
}
}
}
#ifdef XI_R4
xi_set_clip(xiwin, NULL);
#endif
}
}
@ -1856,16 +1862,16 @@ void TDropDownList::update_selection(XI_EVENT* xiev) const
void TDropDownList::ddl_str_eh(XI_OBJ* itf, XI_EVENT* xiev)
{
TDropDownList* ddl = (TDropDownList*)xi_get_app_data(itf);
const char* row = NULL;
long rec = 0l;
if (!ddl->is_open())
return;
if (!ddl->is_open()) return;
const char* row = NULL;
// long rec = 0l;
switch(xiev->type)
{
case XIE_CELL_REQUEST:
rec = xiev->v.cell_request.rec;
row = ddl->item((int)rec);
row = ddl->item(xiev->v.cell_request.rec);
strncpy(xiev->v.cell_request.s, (char *)row, xiev->v.cell_request.len);
xiev->v.cell_request.s[xiev->v.cell_request.len - 1] = '\0';
break;
@ -1912,7 +1918,7 @@ void TDropDownList::ddl_str_eh(XI_OBJ* itf, XI_EVENT* xiev)
if (xiev->v.xi_obj->type == XIT_ROW)
{
const long rec = ddl->row2rec(xiev->v.xi_obj->v.row);
ddl->select((int)rec);
ddl->select(int(rec));
}
break;
case XIE_XVT_EVENT:
@ -1920,7 +1926,7 @@ void TDropDownList::ddl_str_eh(XI_OBJ* itf, XI_EVENT* xiev)
xiev->v.xvte.type == E_MOUSE_UP)
{
ddl->close();
#ifndef XI_R4
#ifndef XIR4
if (xiev->v.xvte.type == E_FOCUS)
_button_blocked = TRUE;
#endif
@ -1948,12 +1954,17 @@ void TDropDownList::close()
{
if (_open)
{
_open = _displayed = FALSE;
xvt_vobj_destroy(xi_get_window(_xi_lst->itf));
_open = FALSE;
xvt_vobj_set_visible(xi_get_window(_xi_lst->itf), FALSE);
xvt_dwin_update (xi_get_window(_obj->itf));
}
}
void TDropDownList::destroy()
{
_xi_lst = NULL;
}
bool TDropDownList::select(int i, bool force)
{
if (force || i != _selected)
@ -1962,8 +1973,7 @@ bool TDropDownList::select(int i, bool force)
if (_obj->type == XIT_FIELD)
{
if (is_open())
xi_set_text(_obj, ""); // Altrimenti a volte ridisegna male!
if (_open) xi_set_text(_obj, ""); // Altrimenti a volte ridisegna male!
xi_set_text(_obj, (char*)_values.get(i));
TListbox_control* listbox = (TListbox_control *)xi_get_app_data(_obj);
listbox->notify_key(K_SPACE);
@ -1971,7 +1981,7 @@ bool TDropDownList::select(int i, bool force)
else
xi_set_text(_obj, (char*)_codes.get(i));
if (force && is_open())
if (force && _open)
xi_scroll_rec(_xi_lst, i, FOCUS_COLOR, XI_ATR_ENABLED | XI_ATR_SELECTED, 0);
return TRUE;
@ -2031,19 +2041,6 @@ bool TDropDownList::select_by_ofs(int i)
return FALSE;
}
TDropDownList::TDropDownList(XI_OBJ* o, const char* codes, const char* values)
: _obj(o), _codes(codes), _values(values),
_open(FALSE), _xi_lst(NULL), _displayed(FALSE), _selected(0)
{
if (o->type == XIT_CELL)
{
const char* val = xi_get_text(o, NULL, -1);
_selected = _codes.get_pos(val);
if (_selected < 0)
_selected = 0;
}
}
void TDropDownList::set_values(const char* c, const char* v)
{
_codes = c;
@ -2062,9 +2059,9 @@ int TDropDownList::calc_min_width()
return len * XI_FU_MULTIPLE;
}
void TDropDownList::open()
void TDropDownList::create()
{
if (_open) return;
if (_xi_lst) return;
XI_OBJ_DEF* itfdef = xi_create_itf_def(ITF_CID, (XI_EVENT_HANDLER)ddl_str_eh, NULL, "",
(long)this);
@ -2147,14 +2144,26 @@ void TDropDownList::open()
CHECK(itfobj != NULL, "Oggetto del cazzo!");
_xi_lst = xi_get_obj(itfobj, _obj->cid+1000);
CHECK(_xi_lst != NULL, "Lista del cazzo!");
}
void TDropDownList::open()
{
if (_xi_lst)
xvt_vobj_set_visible(xi_get_window(_xi_lst->itf), TRUE);
else
create();
if (_open)
return;
_open = TRUE;
xi_cell_request(_xi_lst);
WINDOW win = xi_get_window(_xi_lst->itf);
xvt_scr_set_focus_vobj(win);
xvt_vobj_raise(win);
_displayed = TRUE;
select(_selected, TRUE);
@ -2199,6 +2208,28 @@ bool TListbox_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev)
return ok;
}
TDropDownList::TDropDownList(XI_OBJ* o, const char* codes, const char* values)
: _obj(o), _codes(codes), _values(values),
_open(FALSE), _xi_lst(NULL), _selected(0)
{
if (o->type == XIT_CELL)
{
const char* val = xi_get_text(o, NULL, -1);
_selected = _codes.get_pos(val);
if (_selected < 0)
_selected = 0;
}
}
TDropDownList::~TDropDownList()
{
destroy();
}
///////////////////////////////////////////////////////////
// TListbox_control
///////////////////////////////////////////////////////////
void TListbox_control::set_values(const char* cod, const char* val)
{
_ddl->set_values(cod, val);
@ -2208,6 +2239,31 @@ void TListbox_control::set_values(const char* cod, const char* val)
_ddl->select(selected(), TRUE);
}
int TListbox_control::items() const
{
return _ddl->items();
}
bool TListbox_control::select(int i)
{
return _ddl->select(i);
}
bool TListbox_control::select_by_initial(char c)
{
return _ddl->select_by_initial(c);
}
bool TListbox_control::select_by_ofs(int i)
{
return _ddl->select_by_ofs(i);
}
int TListbox_control::selected() const
{
return _ddl->selected();
}
TListbox_control::TListbox_control(WINDOW win, short cid,
short left, short top, short width,
const char* flags, const char* text,

View File

@ -66,7 +66,6 @@ protected:
void change_attrib(unsigned long attr, bool on, XI_OBJ* obj = NULL);
bool notify_key(KEY k);
// @access Public Member
public:
@ -74,9 +73,9 @@ public:
virtual ~TControl();
static KEY xiev_to_key(const XI_EVENT* xiev);
virtual bool event_handler(XI_OBJ* itf, XI_EVENT* ep);
bool notify_key(KEY k);
bool is_edit_key(KEY k) const;
// @cmember Ritorna l'identificatore assegnato al controllo
@ -282,9 +281,13 @@ public:
virtual ~TCheckbox_control() {}
};
///////////////////////////////////////////////////////////
// TDropDownList
///////////////////////////////////////////////////////////
class TDropDownList : public TObject
{
XI_OBJ* _obj;
XI_OBJ* _obj; // Owner cell or field
XI_OBJ* _xi_lst;
TToken_string _codes;
@ -292,22 +295,22 @@ class TDropDownList : public TObject
int _selected;
bool _open;
bool _displayed;
bool _in_cell;
protected:
static void ddl_str_eh (XI_OBJ* itf, XI_EVENT* xiev);
void update_selection(XI_EVENT* xiev) const;
int calc_min_width();
void create();
void destroy();
public:
const int selected() const { return _selected; }
void open();
void close();
bool is_open() const { return _open; }
bool displayed() const { return _displayed; }
const char* item(int i) { return _values.get(i); }
const char* item(long i) { return _values.get(int(i)); }
int items() const { return _values.items(); }
long row2rec(int) const;
int rec2row(long rec) const;
@ -318,12 +321,12 @@ public:
bool select_by_ofs(int n);
TDropDownList(XI_OBJ* o, const char* codes, const char* values);
virtual ~TDropDownList() {}
virtual ~TDropDownList();
};
class TListbox_control : public TField_control
{
friend class TDropDownList;
TDropDownList* _ddl;
private:
@ -334,11 +337,11 @@ protected: // TTField_control
public:
void set_values(const char* c, const char* v);
int items() const { return _ddl->items(); }
bool select(int i) { return _ddl->select(i); }
bool select_by_initial(char c) { return _ddl->select_by_initial(c); }
bool select_by_ofs(int i) { return _ddl->select_by_ofs(i); }
int selected() const { return _ddl->selected(); }
int items() const;
bool select(int i);
bool select_by_initial(char c);
bool select_by_ofs(int i);
int selected() const;
TListbox_control(WINDOW win, short cid,
short left, short top, short width,