Migliorata gestione delle ricerche incrementali

git-svn-id: svn://10.65.10.50/trunk@547 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-11-07 13:51:11 +00:00
parent ab9480626f
commit ccc71bd6db
14 changed files with 121 additions and 82 deletions

View File

@ -114,7 +114,7 @@ void TBanner::handler(WINDOW win, EVENT* ep)
char* t = (char*)(const char*)main_app().title();
int w = win_get_text_width(win, t, -1);
int a; win_get_font_metrics(win, NULL, &a, NULL);
int x = (r.right-r.left-w)>>1, y = 32 + CHARX + a;
int x = (r.right-w)>>1, y = (r.bottom+a)>>1 ;
win_draw_text(win, x+1, y+1, t, -1);
set_color(COLOR_BLACK, COLOR_LTGRAY);
win_draw_text(win, x, y, t, -1);

View File

@ -965,8 +965,8 @@ WINDOW xvt_create_pushbutton(
default:
if (bottom-top > (CHARY<<1))
{
top += CHARY>>1;
bottom -= CHARY>>1;
top += BASEY>>1;
bottom -= BASEY>>1;
}
pb = new TPush_button(left, top, right, bottom,
caption, parent,

View File

@ -37,7 +37,7 @@ int TExternal_app::run(bool async)
#if XVT_OS == XVT_OS_WIN
set_cursor(TASK_WIN, CURSOR_WAIT);
const int req = 25;
const int req = 30;
int perc = GetFreeSystemResources(GFSR_SYSTEMRESOURCES);
if (perc < req)
{

View File

@ -1269,14 +1269,10 @@ void TMask::set_caption(const char* c)
}
void TMask::set_exchange(const real& e)
void TMask::set_exchange(bool show_value, const real& n)
{
const real nuo = (e.sign() <= 0) ? real(1.0) : e;
const bool run = is_running();
const real nuo = (n.sign() <= 0) ? _exchange : n;
if (run && _exchange == nuo)
return;
const CURSOR oldcur = get_cursor(TASK_WIN); // Store current cursor
set_cursor(TASK_WIN, CURSOR_WAIT);
@ -1284,18 +1280,8 @@ void TMask::set_exchange(const real& e)
{
TMask_field& f = fld(i);
const word id = f.class_id();
if (id == CLASS_SHEET_FIELD)
{
TSheet_field& s = (TSheet_field&)f;
TMask& m = s.sheet_mask();
m.set_exchange(nuo);
if (run) s.force_update();
} else
if (id == CLASS_REAL_FIELD && f._flags.exchange)
{
TReal_field& r = (TReal_field&)f;
r.exchange(_exchange, nuo);
}
if (id == CLASS_SHEET_FIELD || id == CLASS_REAL_FIELD && f.exchangeable())
f.exchange(show_value, nuo);
}
_exchange = nuo; // Update current exchange

View File

@ -114,7 +114,7 @@ public:
void set_mode(int m) { _mode = m; }
int mode() const { return _mode; }
void set_exchange(const real& e);
void set_exchange(bool show_value, const real& nuo);
const real& exchange() const { return _exchange; }
bool check_fields();

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.41 1994-11-04 11:07:16 alex Exp $
// $Id: maskfld.cpp,v 1.42 1994-11-07 13:50:56 guy Exp $
#include <xvt.h>
#include <applicat.h>
@ -549,7 +549,7 @@ bool TMask_field::do_message(int num)
if (message == NULL || message->empty()) return FALSE;
TToken_string msg(16, ',');
TString value(16);
TString80 value;
for (const char* m = message->get(0); m && *m; m = message->get())
{
@ -1151,6 +1151,19 @@ void TBrowse::parse_insert(TScanner& scanner)
TMask_field& TBrowse::field(short n) const
{ return _fld->mask().field(n); }
// Ritorna il numero di inputs senza contare quelli che funzionano solo da filtro
int TBrowse::inputs()
{
int inp = 0;
for (const char* fld = _inp_id.get(0); fld; fld = _inp_id.get())
{
if (*fld != '"' && strchr(fld, '@') == NULL)
inp++;
}
return inp;
}
// Ritorna il numero di campi non vuoti e non filtrati
int TBrowse::do_input(bool filter)
{
@ -2455,20 +2468,21 @@ void TReal_field::set_window_data(const char* data)
TMask_field::set_window_data(data);
}
else
{
{
real n(data);
if (!n.is_zero())
{
if (_flags.exchange)
if (exchangeable() && decimals())
{
const real& e = mask().exchange();
if (e != 1.0) n /= e;
n /= e;
}
if (_picture.empty())
data = n.stringa(_size, _decimals);
else
data = n.string(_picture);
} else data = "";
}
else data = "";
TEdit_field::set_window_data(data);
}
}
@ -2494,16 +2508,13 @@ const char* TReal_field::get_window_data() const
else
{
fpark = real::ita2eng(fpark);
if (_flags.exchange)
if (exchangeable() && decimals())
{
real n(fpark);
const real& e = mask().exchange();
if (e != 1.0)
{
real n(fpark);
n *= e;
if (n.is_zero()) fpark.cut(0);
else fpark = n.string();
}
n *= e;
if (n.is_zero()) fpark.cut(0);
else fpark = n.string();
}
}
@ -2521,28 +2532,31 @@ void TReal_field::set_decimals(int d)
}
void TReal_field::exchange(const real& vec, const real& nuo)
void TReal_field::exchange(bool show_value, const real& nuo)
{
const int dec = (nuo != 1.0) ? 2 : 0;
const int dec = show_value ? 2 : 0; // Quanti decimali voglio
const bool value = decimals() != 0; // Sono attualmente in valuta ?
if (decimals() != dec)
set_decimals(dec);
else
if (dec == 2)
return;
if (show_value == value && show_value) return; // Se cambio da valuta a valuta esco subito!
if (mask().is_running())
{
const char* n = real::ita2eng(TEdit_field::get_window_data());
const char* n = get_window_data();
if (*n)
{
const real& vec = mask().exchange();
real r(n);
r *= vec;
r /= nuo;
if (!show_value)
r *= nuo;
r /= vec;
r.round(dec);
set_decimals(dec);
TEdit_field::set_window_data(r.string(_picture));
}
}
if (decimals() != dec)
set_decimals(dec);
}
///////////////////////////////////////////////////////////

View File

@ -1,4 +1,4 @@
/* $Id: maskfld.h,v 1.6 1994-11-03 12:46:42 guy Exp $ */
/* $Id: maskfld.h,v 1.7 1994-11-07 13:51:00 guy Exp $ */
#ifndef __MASKFLD_H
#define __MASKFLD_H
@ -105,9 +105,10 @@ protected:
virtual void set_window_data(const char* data);
virtual void set_field_data(const char* data);
virtual const char* get_field_data() const;
virtual void exchange(bool show_value, const real& n) {}
bool do_message(int n);
public:
// @FPUB
short atodlg(const char* s) const;
@ -130,6 +131,7 @@ public:
bool roman() const { return _flags.roman; }
bool automagic() const { return _flags.automagic; }
bool ghost() const { return _flags.ghost; }
bool exchangeable() const { return _flags.exchange; }
virtual bool has_check() const { return FALSE;}
virtual bool has_query() const { return FALSE;}
@ -239,7 +241,6 @@ protected:
virtual void set_field_data(const char* data);
virtual const char* get_field_data() const;
public:
// @FPUB
virtual bool on_hit();
@ -293,7 +294,7 @@ protected:
TToken_string& create_siblings(TToken_string& siblings);
public:
int inputs() { return _inp_id.items(); }
int inputs();
int do_input(bool filter = FALSE); // Serve ai TCursor_sheet
TBrowse(TEdit_field* f, TRelation* r, int key = 1, const char* filter = "");
@ -372,6 +373,7 @@ protected:
virtual const char* get_window_data() const;
virtual void set_window_data(const char* data);
virtual void exchange(bool show_value, const real& n);
virtual void create(WINDOW parent);
virtual void parse_head(TScanner& scanner);
@ -381,8 +383,7 @@ public:
// @FPUB
void set_decimals(int d); // Set precision & picture
int decimals() const { return _decimals; } // Get precision
void exchange(const real& o, const real& n); // Change value / o * n
TReal_field(TMask* mask);
};

View File

@ -177,8 +177,8 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
}
RCT rct = resize_rect(x, y, dx, dy, WO_TE, parent);
rct.bottom -= 8;
rct.right -= 28;
rct.bottom -= 12;
rct.right -= 28;
if ((f_width+max_width)*CHARX > rct.right)
fixed_columns = 1;
@ -1179,3 +1179,45 @@ bool TSheet_field::on_key(KEY k)
return TMask_field::on_key(k);
}
void TSheet_field::exchange(bool show_value, const real& nuo)
{
TMask& m = sheet_mask();
const real& vec = mask().exchange();
if (vec != nuo)
{
TBit_array valuta(32);
int i = 0;
for (int f = FIRST_FIELD; ;f++, i++)
{
const int pos = m.id2pos(f);
if (pos < 0) break;
if (m.fld(pos).class_id() == CLASS_REAL_FIELD)
{
if (m.fld(pos).exchangeable())
valuta.set(i);
}
}
for (int riga = 0; riga < items(); riga++)
{
TToken_string& r = row(riga);
for (const char* s = r.get(i = 0); s; s = r.get(++i))
if (*s > ' ' && valuta[i])
{
real v(s);
v *= nuo;
v /= vec;
v.round();
r.add(v.string(), i);
}
}
}
m.set_exchange(show_value, nuo);
if (mask().is_running())
force_update();
}

View File

@ -24,6 +24,8 @@ protected:
virtual bool parse_item(TScanner& scanner);
virtual void create(WINDOW parent);
virtual void exchange(bool show_value, const real& n);
public:
TToken_string& row(int n); // Get/Create a new row
TArray& rows_array() const; // Get all rows

View File

@ -1 +1 @@
#define VERSION 1.12
#define VERSION 1.13

View File

@ -289,7 +289,7 @@ char *real ::literals () const
// Certified 75%
char *real ::points (int dec) const
{
const char *str = stringa ();
const char *str = stringa (0, dec);
const int neg = (*str == '-') ? 1 : 0;
TFixed_string n ((char *) str, 24);
int i;
@ -302,8 +302,7 @@ char *real ::points (int dec) const
{
if (n[dot] == '\0')
n << ',';
const int d = strlen (str + dot + 1); // Decimals already
// there
const int d = strlen (str + dot + 1); // Decimals already there
if (d <= dec)
for (i = d; i < dec; i++)

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.22 1994-10-31 12:09:42 guy Exp $
// $Id: relapp.cpp,v 1.23 1994-11-07 13:51:07 guy Exp $
#include <mailbox.h>
#include <sheet.h>
#include <urldefid.h>
@ -733,7 +733,12 @@ bool TRelation_application::main_loop()
else
{
if (save_and_new())
insert_mode();
{
if (_mask->insert_mode())
insert_mode();
else
query_mode();
}
else
modify_mode();
}
@ -789,12 +794,7 @@ bool TRelation_application::main_loop()
if (recins > 0 && _autoins_caller.not_empty())
{
TMessage msg(_autoins_caller, MSG_AI, format("%ld", recins));
msg.send();
}
if (recins > 0 && _lnflag)
{
TMessage msg(_autoins_caller, MSG_LN, format("%ld", recins));
TMessage msg(_autoins_caller, _lnflag ? MSG_LN : MSG_AI, format("%ld", recins));
msg.send();
}

View File

@ -704,17 +704,10 @@ void TBrowse_sheet::repos_buttons() const
}
HIDDEN const char* ztrim(TString& s)
{
for (int i = 0; s[i] == ' ' || s[i] == '0'; i++);
if (i > 0) s.ltrim(i);
return s;
}
bool TBrowse_sheet::on_key(KEY k)
{
const WINDOW ctl = get_ctl_window(win(), 100);
const bool alnum = k < 256 && isprint(k);
const bool alnum = k >= ' ' && k < 256;
if (ctl != NULL_WIN && (alnum || k == K_BACKSPACE || k == K_DEL))
{
@ -723,12 +716,14 @@ bool TBrowse_sheet::on_key(KEY k)
const WINDOW fldwin = field().win();
TString80 old(corre ? field().get_window_data() : field().get_field_data());
TString80 val(ztrim(old));
TString80 val(old.ltrim());
if (alnum)
{
if (val.len() >= field().size())
val.cut(0);
if (field()._flags.uppercase && isalpha(k))
k = toupper(k);
val << char(k);
}
else val.rtrim(1);

View File

@ -492,9 +492,6 @@ void customize_controls(bool on)
set_value(NULL_WIN,ATTR_WIN_PM_DRAWABLE_TWIN, TRUE);
set_value(NULL_WIN,ATTR_EVENT_HOOK, (long)event_hook);
NormalFont = GetStockObject(ANSI_FIXED_FONT);
GetObject(NormalFont, sizeof(LOGFONT), &LogFont);
#ifdef __CTL3D__
// set_value(NULL_WIN,ATTR_WIN_CREATEWINDOW_HOOK, (long)createwindow_hook);
HINSTANCE _hInstance = (HINSTANCE)get_value(NULL_WIN, ATTR_WIN_INSTANCE);
@ -555,7 +552,7 @@ void xvt_init_font()
HDC hdc = GetDC(hwnd);
GetTextMetrics(hdc, &tm);
ReleaseDC(hwnd, hdc);
const int COLX = GetSystemMetrics(SM_CXSCREEN) / 80;
CHARX = tm.tmAveCharWidth+1;
if (CHARX > COLX) CHARX = COLX;
@ -612,14 +609,17 @@ WINDOW xvt_create_window(WIN_TYPE wt,
#if XVT_OS == XVT_OS_WIN
static bool to_set = TRUE;
HWND hwnd = (HWND)get_value(win, ATTR_NATIVE_WINDOW);
if (to_set)
{
HWND hwnd = (HWND)get_value(win, ATTR_NATIVE_WINDOW);
word style = GetClassWord(hwnd, GCW_STYLE);
style |= CS_BYTEALIGNCLIENT;
SetClassWord(hwnd, GCW_STYLE, style);
to_set = FALSE;
}
long style = GetWindowLong(hwnd, GWL_STYLE);
style &= ~WS_CLIPCHILDREN;
SetWindowLong(hwnd, GWL_STYLE, style);
#endif
return win;
@ -805,7 +805,7 @@ WINDOW xvt_create_statbar()
char* prop_list[prop_count+1] =
{
"Status bar",
"HEIGHT=23",
"HEIGHT=24",
"TASK_WIN",
"FIELD_OFFSET=24",
NULL