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

@ -13,7 +13,7 @@ WINDOW xvt_create_checkbox(
long app_data, long app_data,
int id); int id);
WINDOW xvt_create_radiobutton( WINDOW xvt_create_radiobutton(
short left, short top, short right, short bottom, short left, short top, short right, short bottom,
const char* caption, const char* caption,
WINDOW parent, WINDOW parent,
@ -21,7 +21,7 @@ WINDOW xvt_create_radiobutton(
long app_data, long app_data,
int id); int id);
WINDOW xvt_create_pushbutton( WINDOW xvt_create_pushbutton(
short left, short top, short right, short bottom, short left, short top, short right, short bottom,
const char* caption, const char* caption,
WINDOW parent, WINDOW parent,
@ -29,7 +29,7 @@ WINDOW xvt_create_pushbutton(
long app_data, long app_data,
int id); int id);
WINDOW xvt_create_text( WINDOW xvt_create_text(
short left, short top, short right, short bottom, short left, short top, short right, short bottom,
const char* caption, const char* caption,
WINDOW parent, WINDOW parent,
@ -37,7 +37,7 @@ WINDOW xvt_create_text(
long app_data, long app_data,
int id); int id);
WINDOW xvt_create_groupbox( WINDOW xvt_create_groupbox(
short left, short top, short right, short bottom, short left, short top, short right, short bottom,
const char* caption, const char* caption,
WINDOW parent, WINDOW parent,
@ -45,18 +45,18 @@ WINDOW xvt_create_groupbox(
long app_data, long app_data,
int id); int id);
void free_controls_bmp(); void free_controls_bmp();
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Custom control // Custom control
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
class TControl class TControl
{ {
WINDOW _win; WINDOW _win;
short _id; short _id;
TString _caption; TString80 _caption;
bool _disabled : 1; bool _disabled : 1;
bool _checked : 1; bool _checked : 1;

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 <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -46,17 +46,28 @@ char TMask_field::TField_Flags::update(const char* s)
for (; *s; s++) for (; *s; s++)
switch(toupper(*s)) switch(toupper(*s))
{ {
case 'A': automagic = persistent = TRUE; break; case 'A':
case 'D': enable_default = enabled = FALSE; break; automagic = persistent = TRUE; break;
case 'F': firm = persistent = TRUE; break; case 'D':
case 'G': ghost = TRUE; break; enable_default = enabled = FALSE; break;
case 'H': show_default = showed = FALSE; break; case 'F':
case 'M': roman = TRUE; break; firm = persistent = TRUE; break;
case 'P': persistent = TRUE; break; case 'G':
case 'R': rightjust = TRUE; break; ghost = TRUE; break;
case 'U': uppercase = TRUE; break; case 'H':
case 'V': exchange = TRUE; break; show_default = showed = FALSE; break;
case 'Z': zerofilled = TRUE; 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 #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 #endif
@ -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++) for (int i = 0 ; i < _sheet.items(); i++)
{ {
TToken_string& ts =_sheet.row(i); TToken_string& ts =_sheet.row(i);
@ -2536,7 +2547,7 @@ int TList_field::str2curr(const char* data)
if (_flags.uppercase) if (_flags.uppercase)
str.upper(); 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 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) void TList_field::set_window_data(const char* data)
{ {
CHECKD(win(), "Control window not initialized ", dlg()); CHECKD(win(), "Control window not initialized ", dlg());
int i = str2curr(data); const int i = str2curr(data);
current(i); current(i);
} }
@ -2574,7 +2585,7 @@ void TList_field::current(int n)
int TList_field::current() const int TList_field::current() const
{ {
int sel = win_list_get_sel_index(win()); const int sel = win_list_get_sel_index(win());
#ifdef DBG #ifdef DBG
if (sel < 0 && items() > 0) if (sel < 0 && items() > 0)
error_box("Lista senza selezione nel campo %d", dlg()); error_box("Lista senza selezione nel campo %d", dlg());
@ -2584,7 +2595,9 @@ int TList_field::current() const
const char* TList_field::get_window_data() 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) void TList_field::set_field_data(const char* data)
@ -2733,7 +2746,8 @@ void TRadio_field::destroy()
int TRadio_field::current() const 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 #ifndef __MASKFLD_H
#define __MASKFLD_H #define __MASKFLD_H
@ -209,8 +209,8 @@ class TEdit_field : public TMask_field
protected: protected:
// @DPROT // @DPROT
TString _str; TString80 _str;
TString _picture; TString16 _picture;
TString _warning; TString _warning;
CheckType _check; // Accettabilita' di valori nulli CheckType _check; // Accettabilita' di valori nulli
bool _forced; bool _forced;
@ -410,7 +410,7 @@ protected:
// @FPROT // @FPROT
TToken_string _values; TToken_string _values;
TToken_string _codes; TToken_string _codes;
TString _str; TString80 _str;
virtual word class_id() const; virtual word class_id() const;
@ -418,7 +418,6 @@ protected:
virtual const char* get_window_data() const; virtual const char* get_window_data() const;
virtual void set_field_data(const char* data = NULL); virtual void set_field_data(const char* data = NULL);
virtual const char* get_field_data() const; virtual const char* get_field_data() const;
// virtual const char* picture_data(const char* data, bool video);
virtual void create(WINDOW parent); virtual void create(WINDOW parent);

View File

@ -13,10 +13,10 @@
typedef bool (*VAL_FUNC)(TEdit_field&, KEY k); typedef bool (*VAL_FUNC)(TEdit_field&, KEY k);
HIDDEN const TArray* _parms; HIDDEN const TArray* _parms;
HIDDEN int get_val_param_num() { return _parms->items();} 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 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) HIDDEN bool _expr_val(TEdit_field& f, KEY)
{ {
@ -266,7 +266,6 @@ 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; if (f.mask().query_mode()) return TRUE;
TString16 pi(f.get()); TString16 pi(f.get());
@ -276,7 +275,6 @@ 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; 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_dat = m.field(atoi(get_val_param(2)));
TMask_field& fld_com = m.field(atoi(get_val_param(3))); 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 data(fld_dat.get());
TString16 com(fld_com.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; if ((p = wm.find(cf[14])) != -1) cf[14] = '0' + p;
int gn = atoi(cf.mid(9,2)); 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"); if (passed) fld_sex.set(sesso == 'M' ? "F" : "M");
else return TRUE; else return TRUE;
} }
if (gn > 40) gn -= 40; if (gn > 40) gn -= 40; // Aggiusta giorno di nascita delle donne
// Controllo data di nascita // Controllo data di nascita
wm = "ABCDEHLMPRST"; wm = "ABCDEHLMPRST";
@ -384,14 +383,12 @@ HIDDEN bool _xtz_cf_val(TEdit_field& f, KEY key)
HIDDEN bool _notempty_val(TEdit_field& f, KEY) HIDDEN bool _notempty_val(TEdit_field& f, KEY)
{ {
return f.mask().query_mode() || f.get().not_empty(); return f.mask().query_mode() || f.get().not_empty();
} }
HIDDEN bool _date_cmp(TEdit_field& f, KEY) HIDDEN bool _date_cmp(TEdit_field& f, KEY)
{ {
TFixed_string s(f.get()); TFixed_string s(f.get());
if (s.empty()) return TRUE; if (s.empty()) return TRUE;

View File

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