Aggiunti i Flags # trimma a destra e @ trimma a sinistra ai campi

git-svn-id: svn://10.65.10.50/trunk@2603 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1996-02-16 10:54:55 +00:00
parent 54e3d10ba0
commit 7bd4ee2f23
2 changed files with 51 additions and 20 deletions

View File

@ -1,3 +1,5 @@
#define STRICT
#define XVT_INCL_NATIVE
#include <xvt.h>
#include <applicat.h>
@ -17,12 +19,34 @@
#include <xvtility.h>
#include <text.h>
#if XVT_OS == XVT_OS_WIN
#include <windows.h>
#endif
HIDDEN TString256 fpark;
// @doc INTERNAL
// @mfunc Elimina gli spazi iniziali e/o finali da un stringa
HIDDEN void smart_trim(
TString & s, // @parm Stringa
byte mode // @parm operazione da effettuare ( 0 = nessuna operazione
// 1 = trimma a sinistra
// 2 = trimma a destra
// 3 = trimma da entrambi i lati
)
{
switch (mode)
{
case 1 :
s.ltrim(); break;
case 2 :
s.rtrim(); break;
case 3 :
s.trim(); break;
default:
break;
}
}
///////////////////////////////////////////////////////////
// Field Flags
///////////////////////////////////////////////////////////
@ -39,7 +63,7 @@ TMask_field::TField_Flags::TField_Flags()
roman = exchange = FALSE;
firm = ghost = FALSE;
password = FALSE;
trim = TRUE;
trim = 3;
pipeallowed = FALSE;
}
@ -49,9 +73,13 @@ char TMask_field::TField_Flags::update(const char* f)
for (const char* s = f; *s; s++)
switch(toupper(*s))
{
case '#':
trim = 2; break;
case '@':
trim = 1; break;
case ' ':
case '_':
trim = FALSE; break;
trim = 0; break;
case '*':
password = TRUE; break;
case 'A':
@ -353,7 +381,7 @@ int TMask_field::create_prompt(
{
const long flags = default_flags() & (~CTL_FLAG_DISABLED); // Static controls shouldn't be grayed
#if XVT_OS == XVT_OS_WIN
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT
const int k = _prompt.find('~');
if (k >= 0) _prompt[k] = '&';
#endif
@ -523,7 +551,7 @@ const char* TMask_field::picture_data(
if (video)
{
fpark = data;
fpark.trim();
smart_trim(fpark, (byte) _flags.trim);
if (_flags.uppercase)
fpark.upper();
return fpark;
@ -600,8 +628,8 @@ TString& TMask_field::get() const
gpark = get_window_data();
else
gpark = get_field_data();
if (_flags.trim) gpark.trim();
smart_trim(gpark,(byte) _flags.trim);
return gpark;
}
@ -932,7 +960,7 @@ bool TMask_field::on_key(KEY key)
send_key(key, 0);
break;
case K_F1:
#if XVT_OS == XVT_OS_WIN
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT
if (fexist("prassi.hlp"))
{
struct MULTIGUY
@ -2127,7 +2155,8 @@ void TEdit_field::create(WINDOW parent)
_x += len;
#if XVTWS == WMWS
#if XVT_OS == XVT_OS_SCOUNIX
const int delta = 2;
#else
const int delta = 1;
@ -2135,7 +2164,7 @@ void TEdit_field::create(WINDOW parent)
wincreate(WC_EDIT, _width+delta, 1, _str, parent, bandiere);
#if XVT_OS == XVT_OS_WIN
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT
HWND hwnd = (HWND)xvt_vobj_get_attr(win(), ATTR_NATIVE_WINDOW);
SendMessage(hwnd, EM_LIMITTEXT, _size, 0L); // Limita il testo
#endif
@ -2191,8 +2220,8 @@ const char* TEdit_field::get_field_data() const
const char* TEdit_field::format(const char* d) const
{
fpark = d;
if (_flags.trim) fpark.trim();
fpark = d;
smart_trim(fpark, (byte) _flags.trim);
if (fpark.not_empty())
{
@ -2235,7 +2264,8 @@ const char* TEdit_field::format(const char* d) const
const char* TEdit_field::picture_data(const char* data, bool video) const
{
fpark = video ? data : format(data);
if (_flags.trim) fpark.trim();
smart_trim(fpark, (byte) _flags.trim);
return fpark;
}
@ -3403,7 +3433,7 @@ bool TList_field::on_key(KEY key)
CHECK(index >= 0, "List with no selection!");
int newindex = -1;
#if XVTWS == WMWS
#if XVT_OS == XVT_OS_SCOUNIX
if (key >= 'A' && key <= 'z')
{
for (int i = index+1; i != index; i++)
@ -3452,7 +3482,7 @@ bool TList_field::on_key(KEY key)
*/
}
#if XVTWS == VMWS
#if XVT_OS == XVT_OS_SCOUNIX
if (key == K_TAB && class_id() == CLASS_LIST_FIELD)
dispacth_e_char(win(), K_F9);
#endif
@ -3916,7 +3946,7 @@ void TZoom_field::create(WINDOW parent)
{
TEdit_field::create( parent );
#if XVTWS == WMWS
#if XVT_OS == XVT_OS_SCOUNIX
int delta = 2;
#else
int delta = 1;

View File

@ -121,11 +121,12 @@ protected:
bool roman : 1; // Is a Roman number ?
bool shown : 1; // Is visible
bool show_default : 1;
bool trim : 1; // Trim the string
byte trim : 2; // Trim the string
bool uppercase : 1;
bool exchange : 1; // Value exchange
bool zerofilled : 1;
bool pipeallowed : 1;
TField_Flags();
char update(const char*);
@ -395,7 +396,7 @@ public:
// @struct TField_Flags | Flag indicante il settaggio del campo
// @comm ATTENZIONE: Questa struttura e' definita ed utilizzata unicamente nella classe
// <c TMask_field>
// <c TMask_field>
// @field bool | automagic: 1 | Indica se il campo e' automagic
// @field bool | dirty: 2 | Indica se il campo e' stato modificato
// @field bool | enabled: 1 | Indica se il campo e' editabile