Patch level : 2.0 nopatch

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Aggiunte utili per gestione dizionario
assoc.cpp    Aggiunta possibilita' di selezionare un elemento causale di un assoc
controls.cpp Corretta gestione scrollbar dei listbox
diction.cpp  Migliorata selezione caratteri da trimmare dalle traduzioni
isam.cpp     Corretto azzeramento dei memo (non azzerava il TString_array corrispondente)
msksheet.cpp Resa personalizzabile la larghezza della colonna col numero di riga
netsock.cpp  Migliorata gestione "a capo" in protocollo soap
progind.cpp  Corretto posizionamento progind sovrapposte
relapp.cpp   Cambiato un messaggio di richiesta annullamento


git-svn-id: svn://10.65.10.50/trunk@11651 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2003-12-03 09:41:16 +00:00
parent ceef4f23dd
commit 6bac6177c4
13 changed files with 167 additions and 65 deletions

View File

@ -1,3 +1,4 @@
#include <stdlib.h>
#include <assoc.h>
// @ccost:(INTERNAL) HASH_SIZE | 883 | Dimensione della tabella hash
@ -129,6 +130,31 @@ TObject* TAssoc_array::pred_item()
return (o == NULL || o->_obj == NULL) ? NULL : o->_obj;
}
THash_object* TAssoc_array::random_hash_object()
{
THash_object* o = NULL;
if (items() > 0)
{
int bucket = rand() % _bucket.size();
if (_bucket.objptr(bucket) == NULL)
bucket = _bucket.succ(bucket);
if (_bucket.objptr(bucket) == NULL)
bucket = _bucket.pred(bucket);
const TArray* arr = (const TArray*)_bucket.objptr(bucket);
if (arr != NULL)
{
const int item = rand() % arr->size();
o = (THash_object*)arr->objptr(item);
if (o != NULL)
{
_rowitem = bucket;
_colitem = item;
}
}
}
return o;
}
// @doc EXTERNAL
// @mfunc Aggiunge un oggetto all'array.
@ -225,13 +251,6 @@ TObject& TAssoc_array::find(
// @comm Cerca l'oggetto indicizzato con chiave <p key>. Viene controllato se
// non c'e' (normalmente si usa operator[key])
{
/* Guy ruined this
bool isnew = FALSE;
THash_object* o = _lookup(key, isnew);
if (o == NULL) error_box("INTERNAL (HASH): Unref key");
if (o->_obj == NULL) return error;
else return *(o->_obj);
*/
TObject* o = objptr(key);
CHECKS(o, "Can't find hash object with key ", key);
return *o;
@ -258,7 +277,7 @@ TObject* TAssoc_array::objptr(
// @flag TRUE | Se la chiave esiste
// @flag FALSE | Se la chiave non esiste
bool TAssoc_array::is_key(
const char* key) const // @parm Chiave da cercarne l'esistenza
const char* key) const // @parm Chiave di cui cercare l'esistenza
{
bool isnew = FALSE;
THash_object* o = ((TAssoc_array *)this)->_lookup(key,isnew);
@ -349,8 +368,7 @@ int TAssoc_array::get_keys(TString_array& kl, bool add_values)
// @mfunc Copia tutto l'array e ne duplica gli elementi
//
TAssoc_array & TAssoc_array::copy(
const TAssoc_array & a) // @parm Array associativo sorgente
TAssoc_array & TAssoc_array::copy(const TAssoc_array & a) // @parm Array associativo sorgente
{
destroy();
TAssoc_array& from = (TAssoc_array&)a;

View File

@ -88,6 +88,8 @@ public:
virtual TObject* succ_item( );
// @cmember Ritorna un puntatore all'oggetto che precede quello corrente
virtual TObject* pred_item( );
// @cmember Ritorna un puntatore ad un THash_object casuale (anche NULL)
THash_object* random_hash_object();
// @cmember Ritorna il numero di elementi presenti come long
virtual long objects() { return _cnt; }

View File

@ -41,6 +41,8 @@ bool SMALL_ICONS=FALSE;
HIDDEN bool _button_blocked = FALSE;
HIDDEN int _last_mouse_button = 0;
HIDDEN TDropDownList* _cur_ddl = NULL;
short low_get_focus_id(WINDOW win)
{
@ -568,6 +570,8 @@ HIDDEN void xi_event_handler(XI_OBJ* itf, XI_EVENT* xiev)
{
case E_MOUSE_DOWN:
_last_mouse_button = xiev->v.xvte.v.mouse.button;
if (_cur_ddl != NULL)
_cur_ddl->on_mouse_down(xiev->v.xvte.v.mouse.where);
break;
case E_CHAR:
{
@ -1967,16 +1971,7 @@ void TDropDownList::ddl_str_eh(XI_OBJ* itf, XI_EVENT* xiev)
}
break;
case XIE_XVT_EVENT:
if ((xiev->v.xvte.type == E_FOCUS && xiev->v.xvte.v.active == FALSE) ||
xiev->v.xvte.type == E_MOUSE_UP)
{
ddl->close();
#ifndef XIR4
if (xiev->v.xvte.type == E_FOCUS)
_button_blocked = TRUE;
#endif
}
else if (xiev->v.xvte.type == E_CHAR)
if (xiev->v.xvte.type == E_CHAR)
{
const KEY k = xiev->v.xvte.v.chr.ch;
if (k == K_ENTER || k == K_ESC)
@ -1988,8 +1983,6 @@ void TDropDownList::ddl_str_eh(XI_OBJ* itf, XI_EVENT* xiev)
}
}
break;
case XIE_CHAR_CELL: // TBI: questa e' copiata da edit
break;
default:
break;
}
@ -2002,6 +1995,7 @@ void TDropDownList::close()
_open = FALSE;
if (_xi_lst != NULL)
xvt_vobj_set_visible((WINDOW)xi_get_window(_xi_lst->itf), FALSE);
_cur_ddl = NULL;
}
}
@ -2124,7 +2118,7 @@ void TDropDownList::create()
(long)this);
itfdef->v.itf->automatic_back_color = TRUE;
const int hei = items() <= 1 ? 2*XI_FU_MULTIPLE + 1 : (min(6,items()) * XI_FU_MULTIPLE) + 1;
const int hei = items() <= 1 ? 2*XI_FU_MULTIPLE + 1 : (min(8,items()) * XI_FU_MULTIPLE) + 1;
XI_OBJ_DEF* lstdef = xi_add_list_def(itfdef, _obj->cid+1000, 0, 0, hei,
XI_ATR_ENABLED|XI_ATR_VISIBLE,
FOCUS_COLOR, FOCUS_BACK_COLOR,
@ -2132,7 +2126,7 @@ void TDropDownList::create()
FOCUS_COLOR, 0);
XI_LIST_DEF* ld = lstdef->v.list;
ld->active_back_color = FOCUS_BACK_COLOR;
ld->scroll_bar = items() > 6;
ld->scroll_bar = items() > 8;
ld->no_heading = TRUE;
ld->no_horz_lines = TRUE;
ld->no_vert_lines = TRUE;
@ -2209,7 +2203,6 @@ void TDropDownList::create()
CHECK(_xi_lst, "Can't create listbox");
}
void TDropDownList::open()
{
if (_open)
@ -2230,6 +2223,7 @@ void TDropDownList::open()
select(_selected, TRUE);
xi_dequeue();
_cur_ddl = this;
}
// ------------------------------------------------------------------
@ -2270,6 +2264,17 @@ bool TListbox_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev)
return ok;
}
void TDropDownList::on_mouse_down(const PNT& pt)
{
if (_open)
{
RCT rct;
xvt_vobj_get_outer_rect((WINDOW)xi_get_window(_xi_lst->itf), &rct);
if (!xvt_rect_has_point(&rct, pt))
close();
}
}
TDropDownList::TDropDownList(XI_OBJ* o, const char* codes, const char* values)
: _obj(o), _codes(codes), _values(values),
_open(FALSE), _xi_lst(NULL), _selected(0)
@ -2339,4 +2344,4 @@ TListbox_control::TListbox_control(WINDOW win, short cid,
TListbox_control::~TListbox_control()
{
delete _ddl;
}
}

View File

@ -318,6 +318,8 @@ public:
bool select(int i, bool force = FALSE);
bool select_by_initial(char c);
bool select_by_ofs(int n);
void on_mouse_down(const PNT& pt);
TDropDownList(XI_OBJ* o, const char* codes, const char* values);
virtual ~TDropDownList();

View File

@ -1,12 +1,11 @@
/*
<xml>
<dictionary>
<entry module="ba">
<ita>Attezione: premere OK per cancellare</ita>
<eng>Attension: pres ochei to dilit</eng>
</entry>
</dictionary>
</xml>
<dictionary>
<entry>
<ita>Attezione: premere OK per cancellare</ita>
<eng>Atension: pres ochei to dilit</eng>
<src>ba1.exe</src>
</entry>
</dictionary>
*/
#include <xvt.h>
@ -14,7 +13,50 @@
#include <diction.h>
#include <netsock.h>
#include <scanner.h>
#include <utility.h>
///////////////////////////////////////////////////////////
// Utility di conversione
///////////////////////////////////////////////////////////
TString& txt2xml(const TString& str)
{
TString& tmp = get_tmp_string();
for (int i = 0; str[i]; i++)
{
if (str[i] < ' ' || str[i] > 'z' || strchr("&<>/", str[i]) != NULL)
{
TString8 code;
code.format("&#%X;", (int)(unsigned char)(str[i]));
tmp << code;
}
else
tmp << str[i];
}
return tmp;
}
TString& xml2txt(const TString& str)
{
TString& tmp = get_tmp_string();
for (int i = 0; str[i]; i++)
{
if (str[i] == '&' && str[i+1] == '#')
{
i += 2;
const int semicolon = str.find(';', i);
if (semicolon > 0)
{
int n;
sscanf(str.sub(i, semicolon), "%X", &n);
tmp << char(n & 0xFF);
i = semicolon;
}
}
else
tmp << str[i];
}
return tmp;
}
///////////////////////////////////////////////////////////
// TTraduttore
@ -43,7 +85,7 @@ TObject* TTraduttore::key2obj(const char* key)
_str.cut(0);
_str << "<m:Translate>\n"
<< prefix << unesc(key) << posfix << '\n'
<< prefix << txt2xml(key) << posfix << '\n'
<< "</m:Translate>\n";
if (_client.HttpSoap(_connection, _str))
@ -58,7 +100,7 @@ TObject* TTraduttore::key2obj(const char* key)
{
const int stop = buf.find('<', start);
if (stop > 0)
_str = esc(buf.sub(start, stop));
_str = xml2txt(buf.sub(start, stop));
}
// _client.ReleaseBuffer(); // Non perdiamo tempo in 'ste cose
}
@ -158,12 +200,18 @@ const char* dictionary_translate_prompt(const char* prompt, int maxlen)
{
TString& str = get_tmp_string();
str = prompt;
TString8 prefix;
int prefixlen = 0;
if (str[0] == '@')
{
prefix = str.left(2); // Usually bold = @b
str.ltrim(2);
}
prefixlen = 2; else
if (str[0] == '$')
prefixlen = 6;
TString8 prefix;
if (prefixlen > 0)
{
prefix = str.left(prefixlen);
str = str.mid(prefixlen);
}
const char matilde = strip_accelerator(str); // Ricorda tasto rapido

View File

@ -1,6 +1,10 @@
#ifndef __DICTION_H
#define __DICTION_H
#ifndef __STRINGS_H
#include <strings.h>
#endif
#define TO_BE_TRANSLATED "\03\02\01\00"
#define ALREADY_TRANSLATED "\01\02\03\00"
@ -8,6 +12,9 @@
typedef unsigned long WINDOW;
#endif
TString& txt2xml(const TString& str);
TString& xml2txt(const TString& str);
const char* dictionary_translate(const char* sentence);
const char* dictionary_translate_macro(const char* sentence);
const char* dictionary_translate_prompt(const char* prompt, int maxlen = 0);

View File

@ -3311,10 +3311,17 @@ void TRectype::zero(const char* fieldname)
const byte len = recd->Fd[nf].Len;
const byte dec = recd->Fd[nf].Dec;
const TFieldtypes type = (TFieldtypes) recd->Fd[nf].TypeF;
if (type == _datefld)
__putfieldbuff(len, dec, _datefld, "", p);
else
switch (type)
{
case _datefld:
__putfieldbuff(len, dec, _datefld, "", p);
break;
case _memofld:
__putfieldbuff(len, dec, _memofld, "", p);
_memo_data->add("", nf);
_memo_data->set_dirty(nf);
break;
default:
memset(p, ' ', len);
if ((type == _intfld) || (type == _longfld) || (type == _wordfld))
*(p + len - 1) = '0';
@ -3329,6 +3336,7 @@ void TRectype::zero(const char* fieldname)
else
*(p + len - 1) = '0';
}
break;
}
}
}

View File

@ -126,8 +126,8 @@ class TSpreadsheet : public TControl
// @access:(INTERNAL) Private Member
// @cmember:(INTERNAL) costanti
enum {NUMBER_WIDTH=3};
enum {MAX_COL=64};
static int NUMBER_WIDTH;
// @cmember:(INTERNAL) Array di TToken_strings contenenti le righe
TString_array _str;
@ -294,7 +294,8 @@ public:
void load_columns_order();
// @cmember Setta la disposizione delle colonne
void set_columns_order(TToken_string* order);
static int set_line_number_width(int digits);
// @cmember Setta la larghezza della colonna
void set_column_width(const int col, const int width) const;
// @cmember Setta il titolo della colonna
@ -368,7 +369,7 @@ public:
virtual ~TSpreadsheet();
};
int TSpreadsheet::NUMBER_WIDTH = 3;
KEY TSpreadsheet::barcode_newline() const
{
@ -2086,6 +2087,13 @@ void TSpreadsheet::swap_rows( const int fromindex, const int toindex)
_property.swap(fromindex, toindex);
}
int TSpreadsheet::set_line_number_width(int digits)
{
const int old = NUMBER_WIDTH;
NUMBER_WIDTH = digits;
return old;
}
void TSpreadsheet::set_column_width(const int col, const int width) const
{
XI_OBJ* column = find_column(col);
@ -2780,6 +2788,11 @@ void TSheet_field::sort(ROWS_COMPARE_FUNCTION compare)
}
}
int TSheet_field::set_line_number_width(int width )
{
return TSpreadsheet::set_line_number_width(width);
}
void TSheet_field::set_column_width( const int col, const int width ) const
{
TSpreadsheet* s = (TSpreadsheet*)_ctl;

View File

@ -231,6 +231,8 @@ public:
// @cmember Controlla se l'utente ha salvato la disposizione delle colonne
bool user_saved_columns_order() const;
// @cmember Setta la larghezza della colonna col numero di riga
static int set_line_number_width(int width = 3);
// @cmember Setta la larghezza della colonna
void set_column_width( const int col, const int width ) const;
// @cmember Setta il titolo della colonna

View File

@ -857,15 +857,16 @@ bool TSocketClient::HttpPostFile(CONNID id, const char* remote, const char* loca
TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
if (conn == NULL)
return ok;
const char* const eol = "\r\n";
TString buf(4096);
buf << "POST " << remote << " HTTP/1.0\r\n"
<< "User-Agent: Campo/1.7\r\n"
<< "Content-Type: text/plain\r\n"
<< "Content-Length: " << fsize(local) << "\r\n";
buf << "POST " << remote << " HTTP/1.0" << eol
<< "User-Agent: Campo/1.7" << eol
<< "Content-Type: text/plain" << eol
<< "Content-Length: " << fsize(local) << eol;
if (authorization && *authorization)
buf << "Authorization: " << authorization << "\r\n";
buf << "\r\n";
buf << "Authorization: " << authorization << eol;
buf << eol;
ok = conn->WriteLine(buf);
if (ok)
@ -898,7 +899,7 @@ bool TSocketClient::HttpPostFile(CONNID id, const char* remote, const char* loca
cur_socket->getline(buf.get_buffer(), buf.size(), '\n');
if (buf.blank())
break;
if (buf.compare("Content-length:", 15, TRUE) == 0)
if (buf.starts_with("Content-length:", true) == 0)
{
const int colon = buf.find(':');
size = atol(buf.mid(colon+1));

View File

@ -36,7 +36,7 @@ TIndwin::TIndwin(long max, const char* txt, bool cancel, bool bar, int div)
const int hor = min(maxlen+3, 78);
const int ver = lines+1 + (bar ? 2 : 0) + (cancel ? 2: 0);
const int y = _indwin_count == 0 ? 4 : 12;
const int y = _indwin_count == 0 ? 3 : 12;
set_win(create_interface(TASK_WIN, -1, y, hor, ver, TR("Elaborazione in corso"), this, FALSE));

View File

@ -75,14 +75,11 @@ protected:
// @access Public Member
public:
// @cmember Controlla se e' stato premuto il tasto "Annulla"
bool iscancelled() const
{ do_events(); return (_flags & IND_CANCELLED) != 0; }
bool iscancelled() const { return (_flags & IND_CANCELLED) != 0; }
// @cmember Controlla se e' finito l'operazione
bool isfinished() const
{ do_events(); return (_flags & IND_FINISHED) != 0; }
bool isfinished() const { return (_flags & IND_FINISHED) != 0; }
// @cmember Ritorna lo stato dell'operazione (quantita' dell'applicazione gia' fatta)
long status() const
{ do_events(); return _status; }
long status() const { return _status; }
// @cmember Ferma l'operazione (chiude la finestra)
void cancel()
{ _flags |= IND_CANCELLED; do_events(); check_stop(); }

View File

@ -960,8 +960,7 @@ bool TRelation_application::save(bool check_dirty)
if (mode == MODE_QUERY)
{
const char* ms = (mode == MODE_MOD) ? TR("Annullare le modifiche?") : TR("Annullare i dati inseriti?");
const bool cont = !dirty || yesno_box(ms);
const bool cont = !dirty || yesno_box(TR("Annullare i dati inseriti?"));
return cont;
}