Patch level : 4.0

Files correlati     : *.*
Ricompilazione Demo : [ ]
Commento            :
ccustio.c     Cambiato oridne di inclusione per far contento Visual Studio >= 2008
colors.h       Aggiunto flag NATIVE_CONTROLS e tolto flag SMALL_ICONS
controls.*     Aggiunto supporto per bottoni nativi al posto dei simulacri XI
dongle.cpp  Aggiunta in modo DBG la simulazione chiave master per Power Station
expr.cpp     TRUE -> true    FALSE -> false
image.h       Reso accessibile handle XVT_IMAGE per bottoni nativi
isam.cpp     Corretta segnalazione campi mancanti acceduti tramite TRecfield
maskfld.*     Supporto per controlli nativi
printapp.cpp Eliminate funzioni DEPRECATED per Visual Studio >= 2005
relacpp.cpp  Corretto posizionamento bottoni per controli nativi e non
tree.cpp      Supporto per Tree controls nativi ed eliminati quelli fatti "in casa"
window.*     Reso virtuale metodoto TWindow::force_update, necessario ai TTree_field


git-svn-id: svn://10.65.10.50/trunk@15851 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2007-12-10 09:48:34 +00:00
parent cc8c97ada8
commit 146f97b7c3
16 changed files with 184 additions and 938 deletions

View File

@ -1,4 +1,3 @@
#include "ccustio.h"
#include <sys/stat.h>
#ifdef WIN32
#include <sys/types.h>
@ -12,6 +11,8 @@
#include <unistd.h>
#endif
#include "ccustio.h"
#define CalcPos(Rec, Len, Base) (((Rec) - 1) * ((RecNoType) (Len)) + ((RecNoType) (Base)))
#define LOCK_OFF 1200000000L

View File

@ -31,10 +31,10 @@ extern COLOR FOCUS_BACK_COLOR;
extern COLOR REQUIRED_BACK_COLOR;
extern bool CAMPI_SCAVATI;
extern bool NATIVE_CONTROLS;
extern bool ADVANCED_GRAPHICS;
extern bool AUTOSELECT;
extern bool AUTOZOOM;
extern bool SMALL_ICONS;
extern bool AUTOEND;
const COLOR COLOR_DKCYAN = MAKE_COLOR(0,128,128);

View File

@ -34,18 +34,17 @@ COLOR FOCUS_COLOR = NORMAL_COLOR;
COLOR FOCUS_BACK_COLOR = COLOR_YELLOW;
COLOR REQUIRED_BACK_COLOR = MAKE_COLOR(255,255,156);
bool CAMPI_SCAVATI = true;
bool AUTOSELECT = false;
bool CAMPI_SCAVATI = true;
bool AUTOSELECT = false;
bool ADVANCED_GRAPHICS = true;
bool AUTOZOOM = false;
bool SMALL_ICONS=false;
bool AUTOEND = false;
bool AUTOZOOM = false;
bool AUTOEND = false;
bool NATIVE_CONTROLS = false;
HIDDEN bool _button_blocked = false;
HIDDEN int _last_mouse_button = 0;
HIDDEN TDropDownList* _cur_ddl = NULL;
short low_get_focus_id(WINDOW win)
{
XI_OBJ * itf = xi_get_itf((XinWindow)win);
@ -122,17 +121,7 @@ bool TPicture_array::add(short id)
TImage* i = (TImage*)_enabled.objptr(id);
if (i == NULL)
{
if (SMALL_ICONS)
{
ignore_xvt_errors(true);
i = new TImage(10000+id);
ignore_xvt_errors(false);
if (!i->ok())
i->load(id);
}
else
i = new TImage(id);
i = new TImage(id);
if (i->ok())
{
i->convert_transparent_color(BTN_BACK_COLOR);
@ -195,7 +184,7 @@ XVT_FNTID xvt_default_font(bool bold, bool big)
DEF_FONT = xvt_dwin_get_font(TASK_WIN);
TConfig font(CONFIG_GUI, "Font");
TString font_ser_desc(font.get("FontDesc"));
TString font_ser_desc = font.get("FontDesc");
if (font_ser_desc.empty())
{
const char* name = "Courier New";
@ -328,16 +317,21 @@ void customize_colors()
CAMPI_SCAVATI = colors.get_bool("Campi3D", NULL, -1, CAMPI_SCAVATI);
AUTOSELECT = colors.get_bool("AutoSelect", NULL, -1, AUTOSELECT);
AUTOZOOM = colors.get_bool("AutoZoom", NULL, -1, AUTOZOOM);
SMALL_ICONS = colors.get_bool("SmallIcons", NULL, -1, SMALL_ICONS);
ADVANCED_GRAPHICS = colors.get_bool("AdvancedGraphics", NULL, -1, ADVANCED_GRAPHICS);
if (ADVANCED_GRAPHICS)
{
const long dt = xvt_vobj_get_attr(NULL_WIN, ATTR_DISPLAY_TYPE);
ADVANCED_GRAPHICS = dt == XVT_DISPLAY_DIRECT_COLOR;
ADVANCED_GRAPHICS = dt == XVT_DISPLAY_DIRECT_COLOR; // Always true from 1995
if (ADVANCED_GRAPHICS)
{
NATIVE_CONTROLS = colors.get_bool("NativeControls", NULL, -1, NATIVE_CONTROLS);
xi_set_pref(XI_PREF_NATIVE_CTRLS, NATIVE_CONTROLS);
}
}
const int SPEECH_MODE = colors.get_int("SpeechMode", NULL, -1, 0);
xvt_vobj_set_attr(NULL_WIN, ATTR_SPEECH_MODE, SPEECH_MODE);
xi_set_pref(XI_PREF_COLOR_LIGHT, MASK_LIGHT_COLOR);
xi_set_pref(XI_PREF_COLOR_CTRL, MASK_BACK_COLOR);
xi_set_pref(XI_PREF_COLOR_DARK, MASK_DARK_COLOR);
@ -362,8 +356,8 @@ void init_controls()
{
xi_set_font_id(xvt_load_default_font());
xi_set_pref(XI_PREF_NATIVE_CTRLS, false);
xi_set_pref(XI_PREF_3D_LOOK, true);
xi_set_pref(XI_PREF_NATIVE_CTRLS, NATIVE_CONTROLS);
xi_set_pref(XI_PREF_3D_LOOK, CAMPI_SCAVATI);
xi_set_pref(XI_PREF_CARET_WIDTH, 2);
#ifdef XI_R4
xi_set_pref(XI_PREF_COMBO_ICON, ICO_COMBO);
@ -475,26 +469,23 @@ HIDDEN void init_fu_multiple(XI_OBJ* itf)
HIDDEN XI_BITMAP* get_background_bitmap()
{
static bool checked = false;
static XI_BITMAP* bmp = NULL;
if (ADVANCED_GRAPHICS)
static XI_BITMAP* bmp = (XI_BITMAP*)-1;
if (bmp == (XI_BITMAP*)-1)
{
if (bmp == NULL && !checked)
bmp = NULL;
if (ADVANCED_GRAPHICS && !NATIVE_CONTROLS)
{
TConfig ini(CONFIG_GUI, "Colors");
TFilename back = ini.get("Tile");
if (back.custom_path())
bmp = xi_bitmap_create(back.get_buffer(), XI_BITMAP_TILE);
checked = true;
}
return bmp;
}
return NULL;
return bmp;
}
WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
const char* caption, TWindow* msk, bool tag)
const char* caption, TWindow* msk, bool orecchie)
{
if (parent == NULL_WIN)
parent = TASK_WIN;
@ -534,8 +525,18 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
const WIN_TYPE wt = (dx == 0) ? W_PLAIN : W_DOC;
long wsf = WSF_INVISIBLE | WSF_NO_MENUBAR;
WINDOW win = xvt_win_create(wt, &r, (char*)caption, 0L, parent, wsf,
EM_ALL, (EVENT_HANDLER)xi_event, (long)msk);
WINDOW win = NULL_WIN;
if (NATIVE_CONTROLS && orecchie && parent != NULL_WIN)
{
const short tab_no = xvt_notebk_get_num_tabs(parent);
xvt_notebk_add_tab(parent, tab_no, caption, NULL);
xvt_notebk_add_page(parent, tab_no, 0, caption, (long)msk);
win = xvt_notebk_create_face(parent, tab_no, 0, EM_ALL, xi_event, (long)msk);
}
else
win = xvt_win_create(wt, &r, caption, 0L, parent, wsf,
EM_ALL, (EVENT_HANDLER)xi_event, (long)msk);
CHECK(win, "Can't create an XVT window for an interface");
xvtil_set_font(win, NULL, 0, 0);
@ -551,7 +552,7 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
def->v.itf->menu_win = (XinWindow)TASK_WIN; // Window that owns the menu
XI_BITMAP* bmpback = get_background_bitmap();
if (bmpback != NULL && !tag)
if (bmpback != NULL /* && !tabs */)
{
def->v.itf->back_color = 0;
def->v.itf->bitmap = bmpback;
@ -575,8 +576,8 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
xvt_vobj_move(win, &r);
}
// Aggiunge rettangolo di cornice per pagine con tag buttons
if (tag)
// Aggiunge rettangolo di cornice per pagine con orecchie
if (!NATIVE_CONTROLS && orecchie)
{
XI_RCT rct; xi_get_xi_rct(itf, &rct);
rct.top += Y_FU_MULTIPLE; // Lascia lo spazio per i Bottoni di cambio pagina
@ -599,7 +600,7 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
xi_dequeue();
xi_tree_free(def);
}
return win;
}
@ -1000,6 +1001,9 @@ RCT& TControl::get_rect(RCT& r) const
void TControl::set_rect(const RCT& r)
{
xi_set_rect(_obj, (XinRect*)&r, false);
if (xi_get_native_controls(_obj)) // Dovevano pensarci quelli di XI, ma sono morti!
xvt_vobj_move((WINDOW)_obj->v.btn->btnctl, &r);
}
unsigned long TControl::flags2attr(const char* flags) const
@ -1399,6 +1403,7 @@ void TField_control::create(WINDOW win, short cid,
{
f->button = true;
f->pixel_button_distance = 1;
f->button_width = 16;
}
}
else // E' un multiline, quindi setto il rettangolo
@ -1422,7 +1427,7 @@ void TField_control::create(WINDOW win, short cid,
if (button)
{
// Aggiusta il rettangolo del bottone in modo da allinearlo al testo
RCT& br = (RCT&)_obj->v.field->btn_rct;
XinRect& br = (XinRect&)_obj->v.field->btn_rct;
const int offset = stx->rct.right - br.left - 1;
br.left += offset;
br.right += offset;
@ -1519,7 +1524,7 @@ TMultiline_control::TMultiline_control(WINDOW win, short cid,
void TButton_control::create(WINDOW win, short cid,
short left, short top, short width, short height,
const char* flags, const char* text,
WIN_TYPE wc, XI_OBJ* container)
WIN_TYPE wc, XI_OBJ* container, bool drawable)
{
bool bold, big;
COLOR color;
@ -1552,6 +1557,8 @@ void TButton_control::create(WINDOW win, short cid,
def->v.btn->type = XIBT_BUTTON;
if (bold)
def->v.btn->font = (XinFont *)BIG_FONT;
if (drawable)
def->v.btn->text = ""; // Nasceranno icone successivamente
break;
case WC_CHECKBOX : def->v.btn->type = XIBT_CHECKBOX; break;
case WC_RADIOBUTTON: def->v.btn->type = XIBT_RADIOBTN; break;
@ -1595,9 +1602,10 @@ void TButton_control::create(WINDOW win, short cid,
case WC_RADIOBUTTON:
{
XI_RCT& r = _obj->v.btn->rct;
r.top++; r.bottom-=2;
r.top++; r.bottom -= 2;
r.right += XI_FU_MULTIPLE / 2;
}
break;
default:
break;
}
@ -1692,8 +1700,9 @@ TPushbutton_control::TPushbutton_control(WINDOW win, short cid,
short bmp_up, short bmp_dn)
: _bmp_up(bmp_up), _bmp_dn(bmp_dn)
{
create(win, cid, left, top, width, height, flags, text, WC_PUSHBUTTON, NULL);
{
const bool drawable = bmp_up > 0;
create(win, cid, left, top, width, height, flags, text, WC_PUSHBUTTON, NULL, drawable);
set_bmp(bmp_up, bmp_dn);
}
@ -1733,10 +1742,23 @@ void TPushbutton_control::set_bmp(short bmp_up, short bmp_dn)
}
else
_bmp_up = _bmp_dn = 0;
_obj->v.btn->drawable = _bmp_up > 0;
if (xi_get_native_controls(_obj))
{
_obj->v.btn->drawable = FALSE; // Non disegnarci a mano e lascia fare ad XVT!
XVT_IMAGE img_up = NULL, img_dn = NULL;
if (bmp_up > 0)
img_up = _picture->image(bmp_up).xvt_image();
if (bmp_dn > 0)
img_dn = _picture->image(bmp_dn).xvt_image();
xvt_btn_set_images((WINDOW)_obj->v.btn->btnctl, img_up, img_dn);
}
else
_obj->v.btn->drawable = _bmp_up > 0;
}
void TPushbutton_control::set_bmp(const char * bmp_up, const char * bmp_dn)
void TPushbutton_control::set_bmp(const char* bmp_up, const char* bmp_dn)
{
if (bmp_up && *bmp_up)
{
@ -1749,88 +1771,45 @@ void TPushbutton_control::set_bmp(const char * bmp_up, const char * bmp_dn)
}
else
_bmp_up = _bmp_dn = 0;
_obj->v.btn->drawable = _bmp_up > 0;
// Chiamo qui la gestione di basso livello per gestire i native controls
set_bmp(_bmp_up, _bmp_dn);
}
void TPushbutton_control::update()
{
const long attrib = xi_get_attrib(_obj);
// Dovrebbe passare di qui solo per i controlli NON nativi, ma non si sa mai
if (!xi_get_native_controls(_obj))
{
const long attrib = xi_get_attrib(_obj);
if (attrib & XI_ATR_VISIBLE)
{
WINDOW win = parent();
XI_RCT rct = _obj->v.btn->rct;
rct.left += 5; rct.top += 5; rct.right -= 5; rct.bottom -= 5;
xi_set_clip((XinWindow)win, &rct);
if (attrib & XI_ATR_VISIBLE)
{
XI_RCT rct = _obj->v.btn->rct;
rct.left += 5; rct.top += 5; rct.right -= 5; rct.bottom -= 5;
WINDOW win = parent();
xi_set_clip((XinWindow)win, &rct);
// Cancello il testo sottostante
CBRUSH brush = { PAT_SOLID, BTN_BACK_COLOR };
xvt_dwin_set_cbrush(win, &brush);
xvt_dwin_set_std_cpen(win, TL_PEN_HOLLOW);
xi_draw_rect((XinWindow)win, &rct);
const short bmp = (_bmp_dn > 0 && _obj->v.btn->down) ? _bmp_dn : _bmp_up;
if (bmp > 0)
{
const TImage& i = attrib & XI_ATR_ENABLED ? _picture->image(bmp) : _picture->disabled_image(bmp);
if (!SMALL_ICONS || i.width() > i.height()*2)
{
int x = (rct.right + rct.left - i.width()) / 2;
int y = (rct.bottom + rct.top - i.height()) / 2;
if (_obj->v.btn->down)
{
x += 2;
y += 2;
}
i.draw(win, x, y);
/* if (!(attrib & XI_ATR_ENABLED))
{
CPEN pen;
pen.width = 1;
pen.pat = PAT_SOLID;
pen.style = P_SOLID;
pen.color = BTN_BACK_COLOR;
xvt_dwin_set_cpen(win, &pen);
for (int py = y + i.height(); py >= y; py -= 2)
{
PNT p; p.v = py; p.h = x;
xvt_dwin_draw_set_pos(win, p);
p.h += i.width();
xvt_dwin_draw_line(win, p);
}
for (int px = x + i.width(); px >= x; px -= 2)
{
PNT p; p.v = y; p.h = px;
xvt_dwin_draw_set_pos(win, p);
p.v += i.height();
xvt_dwin_draw_line(win, p);
}
} */
}
else
{
const char* cap = caption();
int width = i.width();
if (*cap)
width += xvt_dwin_get_text_width(win, cap, -1) + 1;
int x = (rct.right + rct.left - width) / 2 + _obj->v.btn->down;
int y = (rct.bottom + rct.top - i.height()) / 2 + _obj->v.btn->down;
i.draw(win, x, y);
if (*cap)
{
const int height = xvt_dwin_get_font_size_mapped(win);
x += i.width()+1;
y = (rct.top + rct.bottom + height) / 2 + _obj->v.btn->down;
xvt_dwin_set_fore_color(win, (attrib & XI_ATR_ENABLED) ? NORMAL_COLOR : DISABLED_COLOR);
xvt_dwin_draw_text(win, x, y, cap, -1);
}
}
// Cancello il testo sottostante
CBRUSH brush = { PAT_SOLID, BTN_BACK_COLOR };
xvt_dwin_set_cbrush(win, &brush);
xvt_dwin_set_std_cpen(win, TL_PEN_HOLLOW);
xi_draw_rect((XinWindow)win, &rct);
const short bmp = (_bmp_dn > 0 && _obj->v.btn->down) ? _bmp_dn : _bmp_up;
if (bmp > 0)
{
const TImage& i = attrib & XI_ATR_ENABLED ? _picture->image(bmp) : _picture->disabled_image(bmp);
int x = (rct.right + rct.left - i.width()) / 2;
int y = (rct.bottom + rct.top - i.height()) / 2;
if (_obj->v.btn->down)
{
x += 2;
y += 2;
}
i.draw(win, x, y);
}
xi_set_clip((XinWindow)win, NULL);
}
xi_set_clip((XinWindow)win, NULL);
}
}
@ -1860,7 +1839,7 @@ bool TPushbutton_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev)
TCheckbox_control::TCheckbox_control(WINDOW win, short cid,
short left, short top, short width,
const char* flags, const char* text)
{ create(win, cid, left, top, width, 1, flags, text, WC_CHECKBOX, NULL); }
{ create(win, cid, left, top, width, 1, flags, text, WC_CHECKBOX); }
///////////////////////////////////////////////////////////
// TCheckbutton_control
@ -1964,7 +1943,7 @@ void TRadiobutton_control::check_button(byte c)
int children;
XI_OBJ** child = xi_get_member_list(_obj, &children);
CHECKD(c < children, "This radio is rather old, it doesn't have button ", c);
if (!xi_is_checked(child[c]))
if (!xi_is_checked(child[c]) || NATIVE_CONTROLS)
xi_check(child[c], true);
}
@ -2042,6 +2021,7 @@ TTagbutton_control::TTagbutton_control(WINDOW win, short cid,
btn_def->v.btn->fore_color = color;
btn_def->v.btn->checked = tag == b-1;
btn_def->app_data = (long)this;
btn_def->v.btn->draw_as = XIBT_EMULATED; // Disegna le orecchie a mano!
}
_obj = xi_create(itf, cnt_def);

View File

@ -196,14 +196,14 @@ protected:
void create(WINDOW win, short cid,
short left, short top, short width, short height,
const char* flags, const char* text,
WIN_TYPE wc, XI_OBJ* container);
WIN_TYPE wc, XI_OBJ* container = NULL, bool drawable = false);
virtual bool event_handler(XI_OBJ* itf, XI_EVENT* ep);
public:
bool checked() const;
void check(bool on = TRUE);
void uncheck() { check(FALSE); }
void check(bool on = true);
void uncheck() { check(false); }
bool toggle();
int button_type() const;

View File

@ -284,6 +284,10 @@ bool TDongle::hardlock_login(bool test_all_keys)
if (_type == _user_dongle)
_type = _developer_dongle;
_serno = 0;
#ifdef DBG
if (test_all_keys && is_power_station())
_type = _aga_dongle;
#endif
}
}
}

View File

@ -244,7 +244,7 @@ TExpression::TExpression(const char* expression, TTypeexp type, bool ignore_err)
{
_ignore_error=ignore_err;
_error=0;
_dirty = TRUE;
_dirty = true;
_type = type;
compile(_original, type);
}
@ -1270,7 +1270,7 @@ bool TExpression::compile(const TString& expression, TTypeexp type)
_val = ZERO;
_code.clear();
if (expression.blank())
return TRUE;
return true;
TCodesym currsym = __gettoken();
bool ok = currsym != _invalid;

View File

@ -100,7 +100,7 @@ bool TGolem_mask::file_handler(TMask_field& f, KEY k)
xvt_fsys_convert_str_to_dir(".", &fs.dir);
strcpy(fs.type, "");
strcpy(fs.name, "*.*");
strcpy(fs.creator, "GOLEM");
strcpy(fs.creator, "CAMPO");
DIRECTORY dir; xvt_fsys_get_dir(&dir);
FL_STATUS ok = xvt_dm_post_file_open(&fs, "Selezionare il file ...");

View File

@ -90,6 +90,9 @@ public:
// @cmember Setta l'<p n>.esime entry della paletta al colore <p c>
void set_clut(byte n, COLOR c);
XVT_IMAGE xvt_image() const { return _image; }
operator XVT_IMAGE () const { return xvt_image(); }
static bool build_filename(TFilename & file);
// @cmember Costruttore. Viene passato il nome del file

View File

@ -4090,7 +4090,7 @@ void TRecfield::set(int from, int to)
if (nf == FIELDERR)
{
NFCHECK("File n. %d unknown field %s", _rec->num(), _name);
NFCHECK("File n. %d unknown field %s", _rec->num(), (const char*)_name);
_p = _rec->string();
_len = 0;
_dec = 0;

View File

@ -251,7 +251,9 @@ void TMask_field::construct(
int len, // @parm Lunghezza del buffer campo
WINDOW parent, // @parm Finestra padre alla quale assegnare il campo
const char* flags, // @parm Flags del campo (default "")
int width) // @parm Lunghezza a video del campo
int width, // @parm Lunghezza a video del campo
short bmp_up, // @parm Immagine standard del bottone
short bmp_dn) // @parm Immagine spremuta del bottone
// @parm TScanner& | scanner | File dal quale leggere leggere le informazioni
// @syntax void construct(TScanner& scanner, WINDOW parent);
@ -274,6 +276,8 @@ void TMask_field::construct(
case CLASS_BUTTON_FIELD:
_ctl_data._height = len;
_ctl_data._width = width <= 0 ? 12 : width;
_ctl_data._bmp_up = bmp_up;
_ctl_data._bmp_dn = bmp_dn;
break;
case CLASS_MEMO_FIELD:
case CLASS_TREE_FIELD:
@ -294,7 +298,6 @@ void TMask_field::construct(
create(parent);
}
void TMask_field::construct(TScanner& scanner, WINDOW parent)
{
_ctl_data.reset();
@ -1522,8 +1525,8 @@ void TEditable_field::reset_key(byte key)
bool TEditable_field::validate(
KEY k) // @parm Tasto da passare alla funzione di validazione
{
bool ok = TRUE;
if (_validate)
bool ok = true;
if (_validate != NULL)
ok = ::validate(_validate->_func, *this, k, _validate->_parms);
return ok;
}

View File

@ -130,7 +130,9 @@ protected:
} _flags;
// @cmember Costruisce il campo con i suoi parametri
void construct(short id, const char* prompt, int x, int y, int len, WINDOW parent, const char* flags = "", int width = 0);
void construct(short id, const char* prompt, int x, int y, int len,
WINDOW parent, const char* flags = "", int width = 0,
short bmp_up = 0, short bmp_dn = 0);
void destroy();
// @cmember Legge la testata del controllo dal file .msk <p scanner>

View File

@ -233,8 +233,6 @@ void TPrint_application::add_file (
// ---------------------------------------------------------------
// ------------ user function ------------------------------------
static char tb[120];
// @doc EXTERNAL
// @mfunc Permette di trovare un link ipertestuale
@ -384,38 +382,30 @@ void TPrint_application::set_background (
const char* FLD (int lognum, const char *f, int from, int to)
{
sprintf (tb, "%c|%d|%s|%d|%d", 'n', lognum, f, from, to);
char *p = new char[strlen (tb) + 1];
strcpy (p, tb);
return p;
TString80 tb; tb.format("%c|%d|%s|%d|%d", 'n', lognum, f, from, to);
return _strdup(tb);
}
const char* FLD (int lognum, const char *f, const char *picture)
{
sprintf (tb, "%c|%d|%s|%s", 'p', lognum, f, picture);
char *p = new char[strlen (tb) + 1];
strcpy (p, tb);
return p;
TString80 tb; tb.format("%c|%d|%s|%s", 'p', lognum, f, picture);
return _strdup(tb);
}
const char* FLD (const char *tabname, const char *f, int from, int to)
{
CHECKS (strlen (tabname) < 5, "Invalid table name", tabname);
int lognum = TTable ::name2log (tabname);
sprintf (tb, "%c|%d|%s|%d|%d", 'n', lognum, f, from, to);
char *p = new char[strlen (tb) + 1];
strcpy (p, tb);
return p;
const int lognum = TTable::name2log (tabname);
TString80 tb; tb.format("%c|%d|%s|%d|%d", 'n', lognum, f, from, to);
return _strdup(tb);
}
const char* FLD (const char *tabname, const char *f, const char *picture)
{
CHECKS (strlen (tabname) < 5, "Invalid table name", tabname);
int lognum = TTable ::name2log (tabname);
sprintf (tb, "%c|%d|%s|%s", 'p', lognum, f, picture);
char *p = new char[strlen (tb) + 1];
strcpy (p, tb);
return p;
CHECKS (strlen(tabname) <= 4, "Invalid table name", tabname);
const int lognum = TTable::name2log(tabname);
TString80 tb; tb.format("%c|%d|%s|%s", 'p', lognum, f, picture);
return _strdup(tb);
}
TString& fill_str (TString & t, char f)
@ -692,8 +682,8 @@ void TPrint_application::set_row (
TString bigbuf(256);
char* strbuf = bigbuf.get_buffer();
TString fftt(256);
char *fmt = fftt.get_buffer();
// let the poor programmer use format() at will
const TString fftt(frmt);
char fill = _fillchar;
@ -701,8 +691,6 @@ void TPrint_application::set_row (
int size = 0, dec = 0, strind = 0;
char ch, align = 'l';
// let the poor programmer use format() at will
strcpy (fmt, frmt);
_print_defined = TRUE;
_currow = r;
@ -713,6 +701,7 @@ void TPrint_application::set_row (
va_start(params, frmt);
// parse format string
const char* fmt = fftt;
while ((ch = *fmt++) != '\0')
{
if (ch == '@')
@ -968,7 +957,7 @@ void TPrint_application::set_row (
else
{
#ifdef __LONGDOUBLE__
sprintf (q.get_buffer(), formato, (long double)rrr);
q.format(formato, (long double)rrr);
#else
q = rrr.format(formato);
#endif
@ -1228,7 +1217,8 @@ bool TPrint_application::print_one (
if (t->row() == i)
{
char pic[36], fn[17];
TString80 pic; // was char pic[36]
TString16 fn; // was char fn[17]
int ch, ln, from, to;
if (t->tag() == 3)
@ -1248,18 +1238,21 @@ bool TPrint_application::print_one (
TPrintstyle st = normalstyle;
switch (ft->_fld[0])
{
case 'u':
st = underlinedstyle;
break;
case 'b':
st = boldstyle;
break;
case 'i':
st = italicstyle;
break;
case 'r':
st = normalstyle;
break;
case 'u':
st = underlinedstyle;
break;
case 'b':
st = boldstyle;
break;
case 'i':
st = italicstyle;
break;
case 'r':
st = normalstyle;
break;
default:
st = normalstyle;
break;
}
((TPrintrow *)(&rw[ft->row()]))->set_style (st);
}
@ -1286,17 +1279,17 @@ bool TPrint_application::print_one (
TToken_string ttt (ft->_fld, '|');
ch = (ttt.get ())[0];
ln = atoi ((const char *) ttt.get ());
strcpy (fn, (const char *) ttt.get ());
strcpy (pic, (const char *) ttt.get ());
fn = ttt.get();
pic = ttt.get();
}
else
{
TToken_string ttt (ft->_fld, '|');
ch = (ttt.get ())[0];
ln = atoi ((const char *) ttt.get ());
strcpy (fn, (const char *) ttt.get ());
from = atoi ((const char *) ttt.get ());
to = atoi ((const char *) ttt.get ());
ln = ttt.get_int();
fn = ttt.get();
from = ttt.get_int();
to = ttt.get_int();
}
// get field val
TLocalisamfile &f = _cur->file(ln);
@ -1331,12 +1324,12 @@ bool TPrint_application::print_one (
}
else if (ft->_flags & BOOLEAN_FLAG)
{
toprint = f.get(fn) == "X" ? "Si" : "No";
toprint = f.get(fn) == "X" ? TR("Si") : TR("No");
}
else if (ft->_flags & NUMBER_FLAG)
{
TString80 pict;
real r(f.get (fn));
real r(f.get(fn));
bool isreal = f.curr ().type (fn) == _realfld;
@ -1481,7 +1474,7 @@ bool TPrint_application::print_one (
else
{
#ifdef __LONGDOUBLE__
sprintf(ps.get_buffer(), fff, (long double)rrr);
ps.format(fff, (long double)rrr);
#else
ps = rrr.format(fff);
#endif

View File

@ -1,4 +1,4 @@
#include <defmask.h>
#include <colors.h>
#include <mailbox.h>
#include <msksheet.h>
#include <postman.h>
@ -139,10 +139,18 @@ void TRelation_application::set_find_button()
int bx = bwidth / 3;
int by = bheight / 2;
RCT r = rct_base; r.left += bx-2; r.right -= bx-2;
RCT r = rct_base;
r.left += bx; r.right -= bx;
if (!NATIVE_CONTROLS)
{
r.left -= 2; r.right += 2;
}
f_find.set_rect(r); // Ridimensiona il bottone centrale di ricerca
bx += 5; by += 3; // Aggiusta dimensioni bottoni sussidiari
if (!NATIVE_CONTROLS)
{
bx += 5; by += 3; // Aggiusta dimensioni bottoni sussidiari
}
pos = _mask->id2pos(DLG_FIRSTREC);
if (pos >= 0)

View File

@ -1,7 +1,7 @@
#include <colors.h>
#include <image.h>
#include <tree.h>
#include <urldefid.h>
#include <image.h>
///////////////////////////////////////////////////////////
// Callbacks
@ -717,749 +717,3 @@ bool TString_tree::get_description(TString& str) const
return obj != NULL;
}
///////////////////////////////////////////////////////////
// TNode_info
///////////////////////////////////////////////////////////
class TNode_info : public TSortable
{
public:
bool _valid : 1;
bool _enabled : 1;
bool _expandable : 1;
bool _expanded : 1;
TString _id;
long _plusx;
long _startx;
long _endx;
const TNode_info& operator =(const TNode_info& ni)
{
_valid = ni._valid;
_enabled = ni._enabled;
_expanded = ni._expanded;
_expandable = ni._expandable;
_id = ni._id;
_plusx = ni._plusx;
_startx = ni._startx;
_endx = ni._endx;
return ni;
}
virtual int compare(const TSortable& s) const
{
const TNode_info& ni = (const TNode_info&)s;
return _id.compare(ni._id);
}
virtual bool ok() const { return _valid; }
void reset() { _valid = false; }
TNode_info() : _valid(false) { }
virtual ~TNode_info() { }
};
class TNode_info_array : public TObject
{
TArray _data;
public:
int last() const;
int find(const TNode_info& ni) const;
TNode_info& operator[](int index);
const TNode_info& operator[](int index) const
{ return (const TNode_info&)_data[index]; }
void reset();
};
TNode_info& TNode_info_array::operator[](int index)
{
CHECKD(index >= 0, "Bad index ", index);
TNode_info* ni = (TNode_info*)_data.objptr(index);
if (ni == NULL)
{
ni = new TNode_info;
_data.add(ni, index);
}
return *ni;
}
void TNode_info_array::reset()
{
for (int i = _data.last(); i >= 0; i = _data.pred(i))
((TNode_info*)_data.objptr(i))->reset();
}
int TNode_info_array::last() const
{
int i;
for (i = _data.last(); i >= 0; i = _data.pred(i))
if (_data[i].ok())
break;
return i;
}
int TNode_info_array::find(const TNode_info& ni) const
{
int i;
for (i = last(); i >= 0; i = _data.pred(i))
{
if (((TNode_info*)_data.objptr(i))->compare(ni) == 0)
break;
}
return i;
}
///////////////////////////////////////////////////////////
// TTree_window
///////////////////////////////////////////////////////////
#include <maskfld.h>
class TTree_window : public TField_window
{
TTree* _tree;
bool _hide_leaves;
long _first_line; // Prima riga disegnata
TNode_info_array _node_info;
TNode_info _curr_info; // Nodo attualmente selezionato
TAuto_token_string _header;
int _headlines;
/*static*/ int _row_height;
static bool _tree_locked;
protected: // TWindow
virtual void update();
virtual bool on_key(KEY key);
virtual void handler(WINDOW win, EVENT* ep);
int row_height() const { return _row_height; }
PNT log2dev(long x, long y) const;
TPoint dev2log(const PNT& p) const;
protected: // Internal use
static bool callback_draw_node(TTree& node, void* jolly, word);
void update_header();
void draw_plus_minus();
void draw_text(int x, int y, const TString& str);
int info2index(const TNode_info& ni) const;
bool index2info(long index, TNode_info& ni);
public:
TTree* tree() const { return _tree; }
void set_tree(TTree* tree) { _tree = tree; _first_line = -1; }
void hide_leaves(bool yes) { _hide_leaves = yes; }
bool select_current();
bool goto_selected();
void set_header(const char* head);
void set_row_height(int rh);
TTree_window(int x, int y, int dx, int dy,
WINDOW parent, TTree_field* owner);
virtual ~TTree_window() { }
};
bool TTree_window::_tree_locked = false;
const int TABX = 3;
struct TUpdate_info
{
TTree_window* _win;
TToken_string _str;
long _x, _y;
long _firsty, _lasty;
long _jolly;
int _headlines;
TNode_info_array* _node_info;
TNode_info* _curr_info;
};
PNT TTree_window::log2dev(long x, long y) const
{
if (_headlines > 0)
y += _headlines;
if (autoscrolling())
{
if (_pixmap)
{
x -= origin().x * CHARX;
y -= origin().y * _row_height;
}
else
{
x -= origin().x;
y -= origin().y;
}
}
PNT pnt; pnt.h = (int)x; pnt.v = (int)y;
if (!_pixmap)
{
pnt.h *= CHARX;
pnt.v *= _row_height;
}
return pnt;
}
TPoint TTree_window::dev2log(const PNT& dp) const
{
PNT p = dp;
if (_headlines > 0)
p.v -= _headlines * _row_height;
TPoint pnt(_pixmap ? p.h : p.h/CHARX, _pixmap ? p.v : p.v/_row_height);
return pnt;
}
void TTree_window::draw_text(int x, int y, const TString& str)
{
int start = 0, pos = 0;
while (pos >= 0)
{
pos = str.find(" ", start);
const TString& mid = str.sub(start, pos);
if (!mid.blank())
stringat(x + start, y, mid);
start = pos+2;
}
}
bool TTree_window::callback_draw_node(TTree& node, void* jolly, word when)
{
TUpdate_info* ui = (TUpdate_info*)jolly;
if (when == SCAN_PRE_ORDER)
{
if (ui->_y >= ui->_firsty && ui->_y <= ui->_lasty)
{
node.curr_id(ui->_str);
const bool is_selected = ui->_str == ui->_curr_info->_id;
const bool is_enabled = node.enabled();
const bool is_marked = node.marked();
int text_len = 0;
if (node.get_description(ui->_str))
{
text_len = ui->_str.len();
if (is_selected)
ui->_win->set_color(FOCUS_COLOR, FOCUS_BACK_COLOR);
else
ui->_win->set_color(is_enabled ? NORMAL_COLOR : DISABLED_COLOR,
is_marked ? REQUIRED_BACK_COLOR : NORMAL_BACK_COLOR);
ui->_win->draw_text(int(ui->_x+2), int(ui->_y), ui->_str);
}
const int ry = int(ui->_y - ui->_firsty);
int by;
for (by = ry-1; by >= 0; by--)
{
long rx = (*ui->_node_info)[by]._startx;
if (rx < ui->_x)
break;
}
const PNT p = ui->_win->log2dev(ui->_x, ui->_y);
const WINDOW win = ui->_win->win();
ui->_win->set_pen(DISABLED_COLOR);
const int rh = ui->_win->row_height();
PNT q;
q.h = p.h; q.v = p.v + rh/2;
xvt_dwin_draw_set_pos(win, q);
q.h -= TABX*CHARX - 3*CHARX/2;
xvt_dwin_draw_line(win, q);
q.v = (by+1+ui->_headlines)*rh;
xvt_dwin_draw_line(win, q);
TImage* bmp = node.image(is_selected);
if (bmp)
{
const int x = p.h;
const int y = p.v + (rh - bmp->height()) / 2;
if (is_enabled)
bmp->draw(win, x, y);
else
{
TImage dis(*bmp);
for (int j = dis.height()-1; j >= 0; j--)
for (int i = dis.width() - (j&1 ? 2 : 1); i >= 0; i-=2)
dis.set_pixel(i, j, NORMAL_BACK_COLOR);
dis.draw(win, x, y);
}
}
TNode_info& ni = (*ui->_node_info)[ry];
node.curr_id(ni._id);
ni._valid = true;
ni._startx = ui->_x;
ni._endx = ui->_x + text_len + 2;
ni._enabled = is_enabled;
ni._expandable = is_enabled && node.has_son();
if (ni._expandable)
{
ni._plusx = ui->_x - TABX + 1;
ni._expanded = node.expanded();
}
else
{
ni._plusx = 0;
ni._expanded = false;
}
}
ui->_y++;
ui->_x += TABX;
if (ui->_x > ui->_jolly)
ui->_jolly = ui->_x;
} else
if (when == SCAN_IN_ORDER)
{
ui->_x -= TABX;
if (ui->_y > ui->_lasty)
return true;
}
return false;
}
void TTree_window::draw_plus_minus()
{
const long firsty = origin().y;
const int last_drawn = _node_info.last();
for (int i = last_drawn; i >= 0; i--)
{
TNode_info& ni = _node_info[i];
if (ni._plusx > 0)
{
if (ni._expanded)
{
bool spudorato = i == last_drawn; // Falso espandibile
if (!spudorato)
{
const TNode_info& nni = _node_info[i+1];
spudorato = nni._startx <= ni._startx;
}
if (spudorato)
{
ni._expandable = false;
ni._expanded = false;
ni._plusx = 0;
continue;
}
}
WINDOW w = win();
PNT r = log2dev(ni._plusx, firsty + i);
r.v += _row_height/2;
r.h += CHARX/2;
RCT rct;
rct.left = r.h - 4;
rct.top = r.v - 4;
rct.right = r.h + 5;
rct.bottom = r.v + 5;
set_pen(NORMAL_COLOR);
set_brush(NORMAL_BACK_COLOR);
xvt_dwin_draw_rect(w, &rct);
PNT f, t;
f.h = rct.left+2; f.v = r.v;
t.h = rct.right+-2; t.v = r.v;
xvt_dwin_draw_set_pos(w, f);
xvt_dwin_draw_line(w, t);
if (!ni._expanded)
{
f.h = r.h; f.v = rct.top+2;
t.h = r.h; t.v = rct.bottom-2;
xvt_dwin_draw_set_pos(w, f);
xvt_dwin_draw_line(w, t);
}
}
}
}
void TTree_window::set_header(const char* head)
{
_header = head;
_headlines = _header.items();
}
void TTree_window::update_header()
{
if (_headlines > 0)
{
autoscroll(false);
set_brush(MASK_BACK_COLOR);
bar(0,-_headlines,columns(),0);
autoscroll(true);
set_opaque_text(false);
for (int i = 0; i < _headlines; i++)
{
const TFixed_string str(_header.get(i));
draw_text(2, int(origin().y+i-_headlines), str);
}
}
}
void TTree_window::update()
{
TField_window::update();
if (_tree == NULL)
return;
update_header();
TUpdate_info ui;
ui._win = this;
ui._x = 0;
ui._y = 0;
ui._firsty = origin().y;
ui._lasty = ui._firsty + rows();
ui._jolly = 0;
ui._headlines = _headlines;
ui._node_info = &_node_info;
ui._curr_info = &_curr_info;
bool ok = false;
if (_first_line > 0)
{
const long index = origin().y - _first_line;
TNode_info ni;
if (index2info(index, ni))
{
ok = _tree->goto_node(ni._id);
ui._x = ni._startx;
ui._y = ui._firsty;
}
}
if (!ok)
{
ok = _tree->goto_root();
if (!ok)
return;
}
_node_info.reset();
set_opaque_text(true);
word flags = SCAN_PRE_ORDER | SCAN_IN_ORDER | SCAN_IGNORING_UNEXPANDED;
if (_hide_leaves) flags |= SCAN_IGNORING_LEAVES;
_tree->scan_depth_first(callback_draw_node, &ui, flags);
while (ui._y < ui._lasty)
{
if (_tree->goto_father())
{
ui._x -= TABX;
if (_tree->goto_rbrother())
_tree->scan_depth_first(callback_draw_node, &ui, flags);
}
else
break;
}
draw_plus_minus();
set_scroll_max(ui._jolly+columns(), ui._y);
_first_line = ui._firsty;
}
// Fa diventare il nodo corrente selezionato
bool TTree_window::select_current()
{
if (_tree)
_tree->curr_id(_curr_info._id);
return _tree != NULL;
}
// Salta al nodo correntemente selezionato
bool TTree_window::goto_selected()
{
bool ok = false;
if (_tree)
ok = _tree->goto_node(_curr_info._id);
return ok;
}
void TTree_window::set_row_height(int rh)
{
if (rh <= 0)
rh = CHARY+2;
_row_height = rh;
}
int TTree_window::info2index(const TNode_info& info) const
{
return _node_info.find(info);
}
bool TTree_window::index2info(long index, TNode_info& ni)
{
bool ok = false;
const int last = _node_info.last();
if (index == -1)
{
if (index2info(0, ni) && _tree->goto_node(ni._id))
{
ok = _tree->goto_lbrother();
if (!ok)
{
ok = _tree->goto_father();
ni._startx -= TABX;
}
if (ok)
_tree->curr_id(ni._id);
}
} else
if (index == last+1 && last >= 0)
{
if (index2info(last, ni) && _tree->goto_node(ni._id))
{
ok = _tree->expanded() && _tree->goto_firstson();
if (ok && _hide_leaves && !_tree->has_son())
{
_tree->goto_node(ni._id); // Ritorno al padre perche' ignoro le foglie
ok = false;
}
if (!ok)
{
ok = _tree->goto_rbrother();
ni._startx += TABX;
}
if (ok)
{
_tree->curr_id(ni._id);
}
}
} else
if (index >= 0 && index <= last)
{
TNode_info& info = _node_info[int(index)];
ok = info.ok();
if (ok)
ni = info;
}
return ok;
}
bool TTree_window::on_key(KEY key)
{
if (_tree == NULL || _tree_locked)
return false;
if (key == K_RIGHT)
{
if (_tree->goto_node(_curr_info._id) &&
!_tree->expanded() && _tree->has_son())
key = K_ENTER;
else
key = K_DOWN;
}
if (key == K_LEFT)
{
if (_tree->goto_node(_curr_info._id) &&
_tree->expanded())
key = K_ENTER;
else
key = K_UP;
}
if (key == K_UP || key == K_DOWN)
{
_tree_locked = true;
int index = info2index(_curr_info);
if (key == K_UP)
index--;
else
index++;
bool ok = false;
bool scroll = false;
TNode_info ni;
if (index2info(index, ni))
{
ok = _tree->goto_node(ni._id);
scroll = ok && (index < 0 || index > _node_info.last());
}
else
{
const int index = key == K_UP ? 0 : _node_info.last();
ok = index2info(index, ni) && _tree->goto_node(ni._id);
}
if (ok && _curr_info != ni)
{
_tree->curr_id(_curr_info._id);
owner().on_key(K_SPACE);
if (!scroll)
{
force_update();
do_events();
}
}
_tree_locked = false;
if (!scroll)
return true;
}
if (key == K_ENTER)
{
_tree_locked = true;
if (_tree->goto_node(_curr_info._id))
{
if (_tree->has_son())
{
bool ok;
if (_tree->expanded())
ok = _tree->shrink();
else
ok = _tree->expand();
if (ok)
{
force_update();
do_events();
// Make sure of being well positioned after the redraw!!!
_tree->goto_node(_curr_info._id);
}
}
owner().on_key(K_CTRL + K_SPACE);
}
_tree_locked = false;
}
return TField_window::on_key(key);
}
void TTree_window::handler(WINDOW win, EVENT* ep)
{
switch(ep->type)
{
case E_MOUSE_DBL:
case E_MOUSE_DOWN:
if (_tree && !_tree_locked)
{
_tree_locked = true;
const TPoint lp = dev2log(ep->v.mouse.where);
const int c = (int)lp.x;
const int r = (int)lp.y;
TNode_info ni;
bool ok = index2info(r, ni);
if (ok && (c == ni._plusx || (c >= ni._startx && c < ni._endx)) &&
_tree->goto_node(ni._id))
{
if (c == ni._plusx || (ni._expandable && ep->type == E_MOUSE_DBL && c <= ni._plusx+3))
{
if (_tree->expanded())
ok = _tree->shrink();
else
ok = _tree->expand();
if (ok)
{
owner().on_key(K_SHIFT + K_SPACE); // Expansion
owner().on_key(K_SPACE); // Selection
}
}
else
{
KEY key = K_SPACE;
if (ep->type == E_MOUSE_DBL)
key += K_CTRL; // Double click selection
owner().on_key(key);
}
if (ok)
{
_curr_info = ni;
force_update();
}
}
_tree_locked = false;
}
break;
default:
TField_window::handler(win, ep);
break;
}
}
TTree_window::TTree_window(int x, int y, int dx, int dy,
WINDOW parent, TTree_field* owner)
: TField_window(x, y, dx, dy, parent, owner), _tree(NULL),
_hide_leaves(false), _headlines(0)
{
set_row_height(-1); // Compute default row height
}
///////////////////////////////////////////////////////////
// TTree_field
///////////////////////////////////////////////////////////
word TTree_field::class_id() const
{
return CLASS_TREE_FIELD;
}
bool TTree_field::is_kind_of(word cid) const
{
return cid == CLASS_TREE_FIELD || TWindowed_field::is_kind_of(cid);
}
#define tree_win() ((TTree_window&)win())
TTree* TTree_field::tree() const
{
return tree_win().tree();
}
void TTree_field::set_tree(TTree* tree)
{
tree_win().set_tree(tree);
tree_win().select_current();
}
void TTree_field::hide_leaves(bool yes)
{
tree_win().hide_leaves(yes);
}
bool TTree_field::select_current()
{
return tree_win().select_current();
}
bool TTree_field::goto_selected()
{
return tree_win().goto_selected();
}
void TTree_field::set_header(const char* head)
{
tree_win().set_header(head);
}
void TTree_field::set_row_height(int rh)
{
tree_win().set_row_height(rh);
}
TField_window* TTree_field::create_window(int x, int y, int dx, int dy, WINDOW parent)
{
return new TTree_window(x, y, dx, dy, parent, this);
}

View File

@ -378,7 +378,6 @@ WINDOW cur_win()
}
///////////////////////////////////////////////////////////
// TWindow
///////////////////////////////////////////////////////////
@ -1182,6 +1181,5 @@ bool TScroll_window::on_key(KEY key)
default:
break;
}
return TWindow::on_key(key);
}

View File

@ -204,7 +204,7 @@ public:
// @cmember Interrompe l'esecuzione della finestra
virtual bool stop_run(KEY key);
// @cmember Forza ridisegno della finestra
void force_update();
virtual void force_update();
// @cmember Cambia il colore dello sfondo
void set_background_color(COLOR col);
// @cmember Mostra la finestra