Modificati WINWM in XVT_OS_WIN altrimenti compilava male!!!!

git-svn-id: svn://10.65.10.50/trunk@103 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-08-30 14:40:29 +00:00
parent 3d6dff6698
commit 8779aa4841
6 changed files with 201 additions and 180 deletions

View File

@ -191,7 +191,7 @@ void TControl::create(
};
_id = id;
_caption = title;
_caption = title; _caption.strip("~");
_disabled = (flags & CTL_FLAG_DISABLED) != 0;
_checked = (flags & CTL_FLAG_CHECKED) != 0;
_multiple = (flags & CTL_FLAG_MULTIPLE) != 0;
@ -505,6 +505,7 @@ class TPush_button : public TButton
{
PICTURE _picup, _picdn;
byte _dx, _dy;
int _accel;
protected:
void draw_pressed(bool pressed) const;
@ -518,10 +519,10 @@ public:
};
TPush_button::TPush_button(short left, short top, short right, short bottom,
const char* caption, WINDOW parent,
const char* capt, WINDOW parent,
long flags, long app_data, short id)
: TButton(left-(id == DLG_F9), top, right, bottom,
caption, parent, flags, app_data, id),
capt, parent, flags, app_data, id),
_picup(0L), _picdn(0L)
{
const int height = bottom-top;
@ -529,69 +530,69 @@ TPush_button::TPush_button(short left, short top, short right, short bottom,
switch(id)
{
case DLG_OK:
if (height > ROWY && strcmp("Conferma", caption) == 0)
caption = format("#%d", BMP_OK);
if (height > ROWY && strcmp("Conferma", caption()) == 0)
capt = format("#%d", BMP_OK);
break;
case DLG_CANCEL:
if (height > ROWY && strcmp("Annulla", caption) == 0)
caption = format("#%d", BMP_CANCEL);
if (height > ROWY && strcmp("Annulla", caption()) == 0)
capt = format("#%d", BMP_CANCEL);
break;
case DLG_QUIT:
caption = format("#%d#%d", BMP_QUIT, BMP_QUITDN);
capt = format("#%d#%d", BMP_QUIT, BMP_QUITDN);
break;
case DLG_SELECT:
caption = format("#%d", BMP_SELECT);
capt = format("#%d", BMP_SELECT);
break;
case DLG_DELREC:
caption = format("#%d#%d", BMP_DELREC, BMP_DELRECDN);
capt = format("#%d#%d", BMP_DELREC, BMP_DELRECDN);
break;
case DLG_NEWREC:
if (height > ROWY && strcmp("~Nuovo", caption) == 0) // Puo' essere Gestione
caption = format("#%d#%d", BMP_NEWREC, BMP_NEWRECDN);
if (height > ROWY && strcmp("Nuovo", caption()) == 0) // Puo' essere Gestione
capt = format("#%d#%d", BMP_NEWREC, BMP_NEWRECDN);
break;
case DLG_FIRSTREC:
caption = format("#%d", BMP_FIRSTREC);
capt = format("#%d", BMP_FIRSTREC);
break;
case DLG_PREVREC:
caption = format("#%d", BMP_PREVREC);
capt = format("#%d", BMP_PREVREC);
break;
case DLG_STOPREC:
caption = format("#%d", BMP_STOPREC);
capt = format("#%d", BMP_STOPREC);
break;
case DLG_NEXTREC:
caption = format("#%d", BMP_NEXTREC);
capt = format("#%d", BMP_NEXTREC);
break;
case DLG_LASTREC:
caption = format("#%d", BMP_LASTREC);
capt = format("#%d", BMP_LASTREC);
break;
case DLG_SAVEREC:
caption = format("#%d#%d", BMP_SAVEREC, BMP_SAVERECDN);
capt = format("#%d#%d", BMP_SAVEREC, BMP_SAVERECDN);
break;
case DLG_FINDREC:
caption = format("#%d", BMP_FINDREC);
capt = format("#%d", BMP_FINDREC);
break;
case DLG_F9:
caption = format("#%d", BMP_SEARCH);
capt = format("#%d", BMP_SEARCH);
break;
case DLG_LINK:
caption = format("#%d", BMP_LINK);
capt = format("#%d", BMP_LINK);
break;
case DLG_EDIT:
caption = format("#%d", BMP_EDIT);
capt = format("#%d", BMP_EDIT);
break;
case DLG_PRINT:
caption = format("#%d", BMP_PRINT);
capt = format("#%d", BMP_PRINT);
break;
default:
break;
}
if (*caption == '#')
if (*capt == '#')
{
int pid = atoi(caption+1);
int pid = atoi(capt+1);
_picup = cpb.getbmp(pid);
const char* d = strrchr(caption, '#');
if (d > caption)
const char* d = strrchr(capt, '#');
if (d > capt)
{
pid = atoi(d+1);
_picdn = cpb.getbmp(pid);
@ -601,10 +602,16 @@ TPush_button::TPush_button(short left, short top, short right, short bottom,
cpb_get_picture_size(_picup, &r);
_dx = byte((right-left-r.right+1) >> 1);
_dy = byte((height-r.bottom) >> 1);
_accel = -1;
}
else
{
_dx = (right-left-strlen(caption)*CHARX) >> 1;
TFixed_string c(capt);
_accel = c.find('~');
if (_accel > 0)
_accel *= CHARX;
_dx = (right-left-strlen(caption())*CHARX) >> 1;
_dy = ((height-CHARY) >> 1) + CHARY-3;
}
}
@ -629,10 +636,14 @@ void TPush_button::draw_pressed(bool pressed) const
win_set_fore_color(_hdc, COLOR_WHITE);
win_draw_text(_hdc, _dx+p+1, _dy+p+1, (char*)t, -1);
if (_accel >= 0)
win_draw_text(_hdc, _dx+_accel+p+1, _dy+p+1, "_", 1);
const COLOR c = disabled() ? DISABLED_COLOR : NORMAL_COLOR;
win_set_fore_color(_hdc, c);
win_draw_text(_hdc, _dx+p, _dy+p, (char*)t, -1);
if (_accel >= 0)
win_draw_text(_hdc, _dx+_accel+p, _dy+p, "_", 1);
}
}

View File

@ -1,98 +1,98 @@
#ifndef __CONTROLS_H
#define __CONTROLS_H
#ifndef __STRINGS_H
#include <strings.h>
#endif
WINDOW xvt_create_checkbox(
short left, short top, short right, short bottom,
const char* caption,
WINDOW parent,
long flags,
long app_data,
int id);
WINDOW xvt_create_radiobutton(
short left, short top, short right, short bottom,
const char* caption,
WINDOW parent,
long flags,
long app_data,
int id);
WINDOW xvt_create_pushbutton(
short left, short top, short right, short bottom,
const char* caption,
WINDOW parent,
long flags,
long app_data,
int id);
WINDOW xvt_create_text(
short left, short top, short right, short bottom,
const char* caption,
WINDOW parent,
long flags,
long app_data,
int id);
WINDOW xvt_create_groupbox(
short left, short top, short right, short bottom,
const char* caption,
WINDOW parent,
long flags,
long app_data,
int id);
void free_controls_bmp();
///////////////////////////////////////////////////////////
// Custom control
///////////////////////////////////////////////////////////
class TControl
{
WINDOW _win;
short _id;
TString _caption;
bool _disabled : 1;
bool _checked : 1;
bool _focused : 1;
bool _multiple : 1;
protected:
static long handler(WINDOW win, EVENT* ep);
void create(short left, short top, short right, short bottom,
const char* caption,
WINDOW parent, long flags, long app_data, short id);
virtual void update() const pure;
virtual void mouse_down(PNT) {};
virtual void mouse_up() {};
virtual WIN_TYPE type() const { return W_NO_BORDER; }
public:
static TControl* WINDOW2TControl(WINDOW win);
virtual ~TControl();
WINDOW win() const { return _win; }
short id() const { return _id; }
const char* caption() const { return _caption; }
bool checked() const { return _checked; }
virtual void check(bool on);
bool disabled() const { return _disabled; }
void enable(bool on);
bool focused() const { return _focused; }
void focus(bool on) { _focused = on; }
bool multiple() const { return _multiple; }
};
#endif
#ifndef __CONTROLS_H
#define __CONTROLS_H
#ifndef __STRINGS_H
#include <strings.h>
#endif
WINDOW xvt_create_checkbox(
short left, short top, short right, short bottom,
const char* caption,
WINDOW parent,
long flags,
long app_data,
int id);
WINDOW xvt_create_radiobutton(
short left, short top, short right, short bottom,
const char* caption,
WINDOW parent,
long flags,
long app_data,
int id);
WINDOW xvt_create_pushbutton(
short left, short top, short right, short bottom,
const char* caption,
WINDOW parent,
long flags,
long app_data,
int id);
WINDOW xvt_create_text(
short left, short top, short right, short bottom,
const char* caption,
WINDOW parent,
long flags,
long app_data,
int id);
WINDOW xvt_create_groupbox(
short left, short top, short right, short bottom,
const char* caption,
WINDOW parent,
long flags,
long app_data,
int id);
void free_controls_bmp();
///////////////////////////////////////////////////////////
// Custom control
///////////////////////////////////////////////////////////
class TControl
{
WINDOW _win;
short _id;
TString80 _caption;
bool _disabled : 1;
bool _checked : 1;
bool _focused : 1;
bool _multiple : 1;
protected:
static long handler(WINDOW win, EVENT* ep);
void create(short left, short top, short right, short bottom,
const char* caption,
WINDOW parent, long flags, long app_data, short id);
virtual void update() const pure;
virtual void mouse_down(PNT) {};
virtual void mouse_up() {};
virtual WIN_TYPE type() const { return W_NO_BORDER; }
public:
static TControl* WINDOW2TControl(WINDOW win);
virtual ~TControl();
WINDOW win() const { return _win; }
short id() const { return _id; }
const char* caption() const { return _caption; }
bool checked() const { return _checked; }
virtual void check(bool on);
bool disabled() const { return _disabled; }
void enable(bool on);
bool focused() const { return _focused; }
void focus(bool on) { _focused = on; }
bool multiple() const { return _multiple; }
};
#endif

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.8 1994-08-29 11:03:17 alex Exp $
// $Id: maskfld.cpp,v 1.9 1994-08-30 14:40:25 guy Exp $
#include <xvt.h>
#include <applicat.h>
@ -46,21 +46,32 @@ char TMask_field::TField_Flags::update(const char* s)
for (; *s; s++)
switch(toupper(*s))
{
case 'A': automagic = persistent = TRUE; break;
case 'D': enable_default = enabled = FALSE; break;
case 'F': firm = persistent = TRUE; break;
case 'G': ghost = TRUE; break;
case 'H': show_default = showed = FALSE; break;
case 'M': roman = TRUE; break;
case 'P': persistent = TRUE; break;
case 'R': rightjust = TRUE; break;
case 'U': uppercase = TRUE; break;
case 'V': exchange = TRUE; break;
case 'Z': zerofilled = TRUE; break;
case 'A':
automagic = persistent = TRUE; break;
case 'D':
enable_default = enabled = FALSE; break;
case 'F':
firm = persistent = TRUE; break;
case 'G':
ghost = TRUE; break;
case 'H':
show_default = showed = FALSE; break;
case 'M':
roman = TRUE; break;
case 'P':
persistent = TRUE; break;
case 'R':
rightjust = TRUE; break;
case 'U':
uppercase = TRUE; break;
case 'V':
exchange = TRUE; break;
case 'Z':
zerofilled = TRUE; break;
#ifdef DBG
default : ::warning_box("FLAG sconosciuto in %s: %c", kk, *s); break;
default : ::warning_box("FLAG sconosciuto in %s: %c", kk, *s); break;
#endif
}
}
return *s;
}
@ -835,7 +846,7 @@ int TList_sheet::do_input()
}
}
TString fd(16), it(16);
TString80 fd, it;
for (int i = 0 ; i < _sheet.items(); i++)
{
TToken_string& ts =_sheet.row(i);
@ -2536,7 +2547,7 @@ int TList_field::str2curr(const char* data)
if (_flags.uppercase)
str.upper();
int i = _codes.get_pos(str);
int i = str.not_empty() ? _codes.get_pos(str) : 0;
if (i < 0) // Se non trova il codice ritenta dopo trim
{
@ -2562,7 +2573,7 @@ int TList_field::str2curr(const char* data)
void TList_field::set_window_data(const char* data)
{
CHECKD(win(), "Control window not initialized ", dlg());
int i = str2curr(data);
const int i = str2curr(data);
current(i);
}
@ -2574,7 +2585,7 @@ void TList_field::current(int n)
int TList_field::current() const
{
int sel = win_list_get_sel_index(win());
const int sel = win_list_get_sel_index(win());
#ifdef DBG
if (sel < 0 && items() > 0)
error_box("Lista senza selezione nel campo %d", dlg());
@ -2583,8 +2594,10 @@ int TList_field::current() const
}
const char* TList_field::get_window_data() const
{
return ((TList_field*)this)->_codes.get(current());
{
const int c = current();
const char* v = ((TList_field*)this)->_codes.get(c);
return v;
}
void TList_field::set_field_data(const char* data)
@ -2733,7 +2746,8 @@ void TRadio_field::destroy()
int TRadio_field::current() const
{
return xvt_get_checked_radio(_radio_ctl_win, _nitems);
const int c = xvt_get_checked_radio(_radio_ctl_win, _nitems);
return c;
}

View File

@ -1,4 +1,4 @@
/* $Id: maskfld.h,v 1.2 1994-08-23 13:52:23 guy Exp $ */
/* $Id: maskfld.h,v 1.3 1994-08-30 14:40:27 guy Exp $ */
#ifndef __MASKFLD_H
#define __MASKFLD_H
@ -209,8 +209,8 @@ class TEdit_field : public TMask_field
protected:
// @DPROT
TString _str;
TString _picture;
TString80 _str;
TString16 _picture;
TString _warning;
CheckType _check; // Accettabilita' di valori nulli
bool _forced;
@ -410,7 +410,7 @@ protected:
// @FPROT
TToken_string _values;
TToken_string _codes;
TString _str;
TString80 _str;
virtual word class_id() const;
@ -418,7 +418,6 @@ protected:
virtual const char* get_window_data() const;
virtual void set_field_data(const char* data = NULL);
virtual const char* get_field_data() const;
// virtual const char* picture_data(const char* data, bool video);
virtual void create(WINDOW parent);

View File

@ -13,10 +13,10 @@
typedef bool (*VAL_FUNC)(TEdit_field&, KEY k);
HIDDEN const TArray* _parms;
HIDDEN int get_val_param_num() { return _parms->items();}
HIDDEN const char* get_val_param(int i)
{ return i < _parms->items() ? (const char*)((const TString&) (*_parms)[i]):"" ;}
HIDDEN int get_val_param_num() { return _parms->items(); }
HIDDEN const char* get_val_param(int i)
{ return i < _parms->items() ? (const char*)((const TString&) (*_parms)[i]):"" ; }
HIDDEN bool _expr_val(TEdit_field& f, KEY)
{
@ -64,7 +64,7 @@ HIDDEN bool _emptycopy_val(TEdit_field& f, KEY)
}
bool pi_check(const char * st, const char * paiva)
bool pi_check(const char * st, const char * paiva)
{
int tot = 0, y;
TFixed_string stato (st);
@ -265,8 +265,7 @@ HIDDEN bool _xt_pi_val(TEdit_field& f, KEY key)
}
HIDDEN bool _xtz_pi_val(TEdit_field& f, KEY key)
HIDDEN bool _xtz_pi_val(TEdit_field& f, KEY key)
{
if (f.mask().query_mode()) return TRUE;
TString16 pi(f.get());
@ -275,8 +274,7 @@ HIDDEN bool _xtz_pi_val(TEdit_field& f, KEY key)
}
HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
{
if (f.mask().query_mode()) return TRUE;
@ -301,7 +299,7 @@ HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
TMask_field& fld_dat = m.field(atoi(get_val_param(2)));
TMask_field& fld_com = m.field(atoi(get_val_param(3)));
char sesso = fld_sex.get()[0];
const char sesso = fld_sex.get()[0];
TString16 data(fld_dat.get());
TString16 com(fld_com.get());
@ -316,14 +314,15 @@ HIDDEN bool _xt_cf_val(TEdit_field& f, KEY key)
if ((p = wm.find(cf[14])) != -1) cf[14] = '0' + p;
int gn = atoi(cf.mid(9,2));
if ((sesso == 'F' && gn <= 40) || (sesso == 'M' && gn >= 40))
if ((sesso == 'F' && gn < 40) || (sesso == 'M' && gn > 40))
{
passed = fld_sex.yesno_box("Sesso non congruente al codice fiscale: correzione automatica?");
passed = fld_sex.yesno_box("Sesso non congruente al codice fiscale:\n"
"correzione automatica?");
if (passed) fld_sex.set(sesso == 'M' ? "F" : "M");
else return TRUE;
}
if (gn > 40) gn -= 40;
if (gn > 40) gn -= 40; // Aggiusta giorno di nascita delle donne
// Controllo data di nascita
wm = "ABCDEHLMPRST";
@ -384,14 +383,12 @@ HIDDEN bool _xtz_cf_val(TEdit_field& f, KEY key)
HIDDEN bool _notempty_val(TEdit_field& f, KEY)
{
return f.mask().query_mode() || f.get().not_empty();
}
HIDDEN bool _date_cmp(TEdit_field& f, KEY)
{
TFixed_string s(f.get());
if (s.empty()) return TRUE;

View File

@ -163,7 +163,7 @@ break;
switch(wparam)
{
case VK_PRIOR:
wparam = K_PREV; break;
key = K_PREV; break;
case VK_NEXT:
key = K_NEXT; break;
case VK_UP:
@ -611,7 +611,7 @@ WINDOW xvt_create_control(WIN_TYPE wt,
const char* xvt_get_title(WINDOW win)
{
#if XVTWS == WINWS
#if XVT_OS == XVT_OS_WIN
TControl* c = TControl::WINDOW2TControl(win);
return c->caption();
#else
@ -623,7 +623,7 @@ const char* xvt_get_title(WINDOW win)
void xvt_set_front_control(WINDOW win)
{
#if XVTWS == WINWS
#if XVT_OS == XVT_OS_WIN
TControl* c = TControl::WINDOW2TControl(win);
c->focus(TRUE);
#endif
@ -633,7 +633,7 @@ void xvt_set_front_control(WINDOW win)
void xvt_enable_control(WINDOW win, bool on)
{
#if XVTWS == WINWS
#if XVT_OS == XVT_OS_WIN
TControl* c = TControl::WINDOW2TControl(win);
c->enable(on);
#else
@ -644,33 +644,33 @@ void xvt_enable_control(WINDOW win, bool on)
void xvt_check_box(WINDOW win, bool on)
{
#if XVTWS == WMWS
win_check_box(win, on);
#else
#if XVT_OS == XVT_OS_WIN
TControl* c = (TControl*)TControl::WINDOW2TControl(win);
c->check(on);
#else
win_check_box(win, on);
#endif
}
bool xvt_get_checked_state(WINDOW win)
{
#if XVTWS == WMWS
return get_checked_state(win);
#else
#if XVT_OS == XVT_OS_WIN
TControl* c = TControl::WINDOW2TControl(win);
return c->checked();
#else
return get_checked_state(win);
#endif
}
void xvt_check_radio_button(WINDOW win, const WINDOW* ctls, int count)
{
#if XVTWS == WMWS
win_check_radio_button(win, (WINDOW*)ctls, count);
#else
#if XVT_OS == XVT_OS_WIN
for (int i = 0; i < count; i++)
xvt_check_box(ctls[i], ctls[i] == win);
#else
win_check_radio_button(win, (WINDOW*)ctls, count);
#endif
}