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()) if (user().empty())
check_parameters(argc, argv); check_parameters(argc, argv);
__argc = argc; _argc_ = argc;
__argv = (const char**)argv; _argv_ = (const char**)argv;
if (argc > 1 && argv[1][0] == '-') 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 // About box: risposta alla opzione Informazioni del menu File
void TApplication::about() const void TApplication::about() const
{ {
const TFilename n(__argv[0]); const TFilename n(argv(0));
const word ser_no = dongle().number(); const word ser_no = dongle().number();
int year, release, tag, patch; int year, release, tag, patch;

View File

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

View File

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

View File

@ -22,33 +22,26 @@
#define S4OFF_REPORT #define S4OFF_REPORT
#ifdef CB6 #ifdef CB6
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
#define S4DLL #define S4DLL
#define S4WIN16 #define S4WIN16
#else
#if XVT_OS == XVT_OS_WIN32
#define S4DLL
#define S4WIN32
#else
#define S4UNIX
#endif
#endif #endif
// #ifdef XVT /* This not recommended in Unix!*/
// #undef S4UNIX #if XVT_OS == XVT_OS_WIN32
// #define S4DLL #define S4DLL
// #endif #define S4WIN32
#endif
#ifdef FOXPRO #ifdef FOXPRO
#undef S4UNIX #define S4DLL
#define S4DLL #define S4WIN16
#define S4WIN16
#endif #endif
#pragma pack(1) //#pragma pack(1)
#include <d4all.h> #include <d4all.h>
// #include <x4filter.h> //#pragma pack()
// #include <i4chang.h>
#pragma pack()
#include <codeb.h> #include <codeb.h>
#include <rectypes.h> #include <rectypes.h>
#include <progind.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); TWindow* w = (TWindow*)xi_get_app_data(itf);
CHECK(w, "Can't send XVT event to a null window"); CHECK(w, "Can't send XVT event to a null window");
w->handler(w->win(), &xiev->v.xvte); w->handler(w->win(), &xiev->v.xvte);
if (xiev->v.xvte.type == E_MOUSE_UP) if (xiev->v.xvte.type == E_MOUSE_UP)
_button_blocked = FALSE; _button_blocked = FALSE;
} }
@ -1517,13 +1516,25 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
void TPushbutton_control::update() void TPushbutton_control::update()
{ {
const long attrib = xi_get_attrib(_obj); const long attrib = xi_get_attrib(_obj);
const WINDOW win = parent();
if (attrib & XI_ATR_VISIBLE) 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) if (_native_hicon)
{ {
const RCT& rct = (RCT &) _obj->v.btn->rct;
os_draw_native_icon(win, rct, _native_hicon); os_draw_native_icon(win, rct, _native_hicon);
return; return;
} }
@ -1532,24 +1543,16 @@ void TPushbutton_control::update()
if (bmp > 0) if (bmp > 0)
{ {
const TImage& i = _picture->image(bmp); const TImage& i = _picture->image(bmp);
const RCT& rct = (RCT &) _obj->v.btn->rct; int x = (rct.right + rct.left - i.width()) / 2;
int x = rct.left + (rct.right - rct.left - i.width()) / 2; int y = (rct.bottom + rct.top - i.height()) / 2;
int y = rct.top + (rct.bottom - rct.top - i.height()) / 2;
if (_obj->v.btn->down) if (_obj->v.btn->down)
{ {
x += 2; x += 2;
y += 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); i.draw(win, x, y);
#ifdef XI_R4
xi_set_clip( win, NULL );
#endif
if (!(attrib & XI_ATR_ENABLED)) if (!(attrib & XI_ATR_ENABLED))
{ {
CPEN pen; CPEN pen;
@ -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) void TDropDownList::ddl_str_eh(XI_OBJ* itf, XI_EVENT* xiev)
{ {
TDropDownList* ddl = (TDropDownList*)xi_get_app_data(itf); TDropDownList* ddl = (TDropDownList*)xi_get_app_data(itf);
const char* row = NULL; if (!ddl->is_open())
long rec = 0l; return;
if (!ddl->is_open()) return; const char* row = NULL;
// long rec = 0l;
switch(xiev->type) switch(xiev->type)
{ {
case XIE_CELL_REQUEST: case XIE_CELL_REQUEST:
rec = xiev->v.cell_request.rec; row = ddl->item(xiev->v.cell_request.rec);
row = ddl->item((int)rec);
strncpy(xiev->v.cell_request.s, (char *)row, xiev->v.cell_request.len); 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'; xiev->v.cell_request.s[xiev->v.cell_request.len - 1] = '\0';
break; break;
@ -1912,7 +1918,7 @@ void TDropDownList::ddl_str_eh(XI_OBJ* itf, XI_EVENT* xiev)
if (xiev->v.xi_obj->type == XIT_ROW) if (xiev->v.xi_obj->type == XIT_ROW)
{ {
const long rec = ddl->row2rec(xiev->v.xi_obj->v.row); const long rec = ddl->row2rec(xiev->v.xi_obj->v.row);
ddl->select((int)rec); ddl->select(int(rec));
} }
break; break;
case XIE_XVT_EVENT: 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) xiev->v.xvte.type == E_MOUSE_UP)
{ {
ddl->close(); ddl->close();
#ifndef XI_R4 #ifndef XIR4
if (xiev->v.xvte.type == E_FOCUS) if (xiev->v.xvte.type == E_FOCUS)
_button_blocked = TRUE; _button_blocked = TRUE;
#endif #endif
@ -1948,12 +1954,17 @@ void TDropDownList::close()
{ {
if (_open) if (_open)
{ {
_open = _displayed = FALSE; _open = FALSE;
xvt_vobj_destroy(xi_get_window(_xi_lst->itf)); xvt_vobj_set_visible(xi_get_window(_xi_lst->itf), FALSE);
xvt_dwin_update (xi_get_window(_obj->itf)); xvt_dwin_update (xi_get_window(_obj->itf));
} }
} }
void TDropDownList::destroy()
{
_xi_lst = NULL;
}
bool TDropDownList::select(int i, bool force) bool TDropDownList::select(int i, bool force)
{ {
if (force || i != _selected) if (force || i != _selected)
@ -1962,8 +1973,7 @@ bool TDropDownList::select(int i, bool force)
if (_obj->type == XIT_FIELD) if (_obj->type == XIT_FIELD)
{ {
if (is_open()) if (_open) xi_set_text(_obj, ""); // Altrimenti a volte ridisegna male!
xi_set_text(_obj, ""); // Altrimenti a volte ridisegna male!
xi_set_text(_obj, (char*)_values.get(i)); xi_set_text(_obj, (char*)_values.get(i));
TListbox_control* listbox = (TListbox_control *)xi_get_app_data(_obj); TListbox_control* listbox = (TListbox_control *)xi_get_app_data(_obj);
listbox->notify_key(K_SPACE); listbox->notify_key(K_SPACE);
@ -1971,7 +1981,7 @@ bool TDropDownList::select(int i, bool force)
else else
xi_set_text(_obj, (char*)_codes.get(i)); 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); xi_scroll_rec(_xi_lst, i, FOCUS_COLOR, XI_ATR_ENABLED | XI_ATR_SELECTED, 0);
return TRUE; return TRUE;
@ -2031,19 +2041,6 @@ bool TDropDownList::select_by_ofs(int i)
return FALSE; 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) void TDropDownList::set_values(const char* c, const char* v)
{ {
_codes = c; _codes = c;
@ -2062,9 +2059,9 @@ int TDropDownList::calc_min_width()
return len * XI_FU_MULTIPLE; 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, "", XI_OBJ_DEF* itfdef = xi_create_itf_def(ITF_CID, (XI_EVENT_HANDLER)ddl_str_eh, NULL, "",
(long)this); (long)this);
@ -2147,14 +2144,26 @@ void TDropDownList::open()
CHECK(itfobj != NULL, "Oggetto del cazzo!"); CHECK(itfobj != NULL, "Oggetto del cazzo!");
_xi_lst = xi_get_obj(itfobj, _obj->cid+1000); _xi_lst = xi_get_obj(itfobj, _obj->cid+1000);
CHECK(_xi_lst != NULL, "Lista del cazzo!"); 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; _open = TRUE;
xi_cell_request(_xi_lst); xi_cell_request(_xi_lst);
WINDOW win = xi_get_window(_xi_lst->itf);
xvt_scr_set_focus_vobj(win); xvt_scr_set_focus_vobj(win);
xvt_vobj_raise(win); xvt_vobj_raise(win);
_displayed = TRUE;
select(_selected, TRUE); select(_selected, TRUE);
@ -2180,7 +2189,7 @@ bool TListbox_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev)
_ddl->select_by_initial(char(k)); _ddl->select_by_initial(char(k));
else if (k == K_F9) else if (k == K_F9)
_ddl->open(); _ddl->open();
else if (k == K_RIGHT) // poor man's substitute for down arrow else if (k == K_RIGHT) // poor man's substitute for down arrow
_ddl->select_by_ofs(1); _ddl->select_by_ofs(1);
else if (k == K_LEFT) // poor man's substitute for up arrow else if (k == K_LEFT) // poor man's substitute for up arrow
_ddl->select_by_ofs(-1); _ddl->select_by_ofs(-1);
@ -2199,6 +2208,28 @@ bool TListbox_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev)
return ok; 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) void TListbox_control::set_values(const char* cod, const char* val)
{ {
_ddl->set_values(cod, 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); _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, TListbox_control::TListbox_control(WINDOW win, short cid,
short left, short top, short width, short left, short top, short width,
const char* flags, const char* text, 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); void change_attrib(unsigned long attr, bool on, XI_OBJ* obj = NULL);
bool notify_key(KEY k);
// @access Public Member // @access Public Member
public: public:
@ -74,9 +73,9 @@ public:
virtual ~TControl(); virtual ~TControl();
static KEY xiev_to_key(const XI_EVENT* xiev); static KEY xiev_to_key(const XI_EVENT* xiev);
virtual bool event_handler(XI_OBJ* itf, XI_EVENT* ep); virtual bool event_handler(XI_OBJ* itf, XI_EVENT* ep);
bool notify_key(KEY k);
bool is_edit_key(KEY k) const; bool is_edit_key(KEY k) const;
// @cmember Ritorna l'identificatore assegnato al controllo // @cmember Ritorna l'identificatore assegnato al controllo
@ -281,10 +280,14 @@ public:
const char* flags, const char* text); const char* flags, const char* text);
virtual ~TCheckbox_control() {} virtual ~TCheckbox_control() {}
}; };
///////////////////////////////////////////////////////////
// TDropDownList
///////////////////////////////////////////////////////////
class TDropDownList : public TObject class TDropDownList : public TObject
{ {
XI_OBJ* _obj; XI_OBJ* _obj; // Owner cell or field
XI_OBJ* _xi_lst; XI_OBJ* _xi_lst;
TToken_string _codes; TToken_string _codes;
@ -292,22 +295,22 @@ class TDropDownList : public TObject
int _selected; int _selected;
bool _open; bool _open;
bool _displayed;
bool _in_cell;
protected: protected:
static void ddl_str_eh (XI_OBJ* itf, XI_EVENT* xiev); static void ddl_str_eh (XI_OBJ* itf, XI_EVENT* xiev);
void update_selection(XI_EVENT* xiev) const; void update_selection(XI_EVENT* xiev) const;
int calc_min_width(); int calc_min_width();
void create();
void destroy();
public: public:
const int selected() const { return _selected; } const int selected() const { return _selected; }
void open(); void open();
void close(); void close();
bool is_open() const { return _open; } 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(); } int items() const { return _values.items(); }
long row2rec(int) const; long row2rec(int) const;
int rec2row(long rec) const; int rec2row(long rec) const;
@ -318,12 +321,12 @@ public:
bool select_by_ofs(int n); bool select_by_ofs(int n);
TDropDownList(XI_OBJ* o, const char* codes, const char* values); TDropDownList(XI_OBJ* o, const char* codes, const char* values);
virtual ~TDropDownList() {} virtual ~TDropDownList();
}; };
class TListbox_control : public TField_control class TListbox_control : public TField_control
{ {
friend class TDropDownList;
TDropDownList* _ddl; TDropDownList* _ddl;
private: private:
@ -334,11 +337,11 @@ protected: // TTField_control
public: public:
void set_values(const char* c, const char* v); void set_values(const char* c, const char* v);
int items() const { return _ddl->items(); } int items() const;
bool select(int i) { return _ddl->select(i); } bool select(int i);
bool select_by_initial(char c) { return _ddl->select_by_initial(c); } bool select_by_initial(char c);
bool select_by_ofs(int i) { return _ddl->select_by_ofs(i); } bool select_by_ofs(int i);
int selected() const { return _ddl->selected(); } int selected() const;
TListbox_control(WINDOW win, short cid, TListbox_control(WINDOW win, short cid,
short left, short top, short width, short left, short top, short width,