Patch level : 10.0

Files correlati     : tutti
Ricompilazione Demo : [ ]
Commento            :
Migliorata gestione colori dei controlli


git-svn-id: svn://10.65.10.50/trunk@17590 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-11-11 16:16:48 +00:00
parent f6c12db548
commit 93c9ce1cad
15 changed files with 251 additions and 152 deletions

View File

@ -479,12 +479,8 @@ int DB_lockfile(int handle)
HIDDEN void do_key(const char *fname, RecDes *r, TAG4INFO *tag_info, int n_keys)
{
int i,j;
char tiname[_MAX_FNAME]; /* Tag name, max 8 characters long! */
char* dot;
strcpy(tiname,fname);
dot = strchr(tiname, '.');
if (dot) *dot = '\0';
char tiname[_MAX_FNAME]; /* Tag name */
_splitpath(fname, NULL, NULL, tiname, NULL);
xvt_str_make_upper(tiname);
for (i=0; ((i < MaxKeys) && (i < n_keys)); i++)
{

View File

@ -1,5 +1,4 @@
#include <colmask.h>
#include <colors.h>
#include <config.h>
#include <diction.h>

View File

@ -1,10 +1,6 @@
#ifndef __COLORS_H
#define __COLORS_H
#ifndef __STDTYPES_H
#include <stdtypes.h>
#endif
#ifndef XVT_INCL_XVT
#include <xvt.h>
#endif

View File

@ -83,6 +83,12 @@ XVT_IMAGE TImage::load(short id)
return set(xvt_res_get_image(id));
}
// Certified 100%
XVT_IMAGE TImage::load_icon(short id)
{
return set(xvt_res_get_icon(id));
}
// Certified 100%
TImage::TImage(const char* n) : _image(NULL)
{
@ -91,9 +97,15 @@ TImage::TImage(const char* n) : _image(NULL)
}
// Certified 100%
TImage::TImage(short id) : _image(NULL)
TImage::TImage(short id, bool is_icon) : _image(NULL)
{
if (id > 0) load(id);
if (id > 0)
{
if (is_icon)
load_icon(id);
else
load(id);
}
}
// Certified 90%
@ -259,12 +271,26 @@ void TImage::convert_transparent_color(COLOR transparent)
if (xvt_image_get_format(_image) == XVT_IMAGE_CL8)
{
/*
for (int index = xvt_image_get_ncolors(_image)-1; index >=0; index--)
if (same_color(trans, xvt_image_get_clut(_image, index)))
{
xvt_image_set_clut(_image, index, transparent);
// break; don't break: replace all colors equal to upper left in the palette
}
*/
int i = -1;
while (true)
{
const int index = xvt_image_find_clut_index(_image, trans);
if (index > i)
{
xvt_image_set_clut(_image, index, transparent);
i = index;
}
else
break;
}
}
else
{

View File

@ -59,6 +59,8 @@ public:
XVT_IMAGE load(const char* n);
// @cmember Legge l'immagine dal file di risorse
XVT_IMAGE load(short id);
// @cmember Legge l'immagine dal file di risorse
XVT_IMAGE load_icon(short id);
// @cmember Controlla che l'immagine sia un oggetto valido (diverso da NULL)
virtual bool ok() const
@ -96,7 +98,7 @@ public:
// @cmember Costruttore. Viene passato il nome del file
TImage(const char* n);
// @cmember Costruttore. Viene passato l'identificatore dell'immagine sul file di risorsa
TImage(short id);
TImage(short id, bool is_icon = false);
// @cmember Costruttore. Viene passata l'immagine e le sue diemsioni
TImage(const TImage& i, short width = -1, short height = -1);
// @cmember Costruttore. Viene passata l'immagine e le sue diemsioni

View File

@ -276,9 +276,6 @@ TMask::TMask(const char* maskname, int num, int max)
TMask::~TMask()
{
_field.destroy();
//xvt_vobj_destroy(_toolwin);
//xvt_vobj_destroy(_notebook);
}
word TMask::class_id() const
@ -1225,8 +1222,13 @@ WINDOW TMask::create_book(bool single)
else
{
CHECK(_notebook == NULL_WIN, "One single notebook, please!");
XVT_COLOR_COMPONENT xcc[4]; memset(xcc, 0, sizeof(xcc));
xcc[0].type = XVT_COLOR_BACKGROUND; xcc[0].color = MASK_BACK_COLOR;
xcc[1].type = XVT_COLOR_FOREGROUND; xcc[1].color = NORMAL_COLOR;
WIN_DEF wd; memset(&wd, 0, sizeof(wd));
wd.wtype = WC_NOTEBK;
wd.ctlcolors = xcc;
wd.v.ctl.flags = CTL_FLAG_TAB_DEFAULT | CTL_FLAG_TAB_TOP;
xvt_vobj_get_client_rect(parent, &wd.rct);
_notebook = xvt_ctl_create_def(&wd, parent, long(this));
@ -1293,7 +1295,7 @@ WINDOW TMask::create_bar(int height)
const long flags = TOOL_TEXT ? CTL_FLAG_PASSWORD : 0;
w = xvt_toolbar_create(-1, 0, 0, -1, TOOL_SIZE, flags, win()); // Top bar
XVT_COLOR_COMPONENT cc[4]; memset(cc, 0, sizeof(cc));
cc[0].type = XVT_COLOR_TROUGH; cc[0].color = MASK_BACK_COLOR;
cc[0].type = XVT_COLOR_BLEND; cc[0].color = MASK_BACK_COLOR;
cc[1].type = XVT_COLOR_FOREGROUND; cc[1].color = NORMAL_COLOR;
xvt_ctl_set_colors(w, cc, XVT_COLOR_ACTION_SET);
}

View File

@ -2664,47 +2664,50 @@ KEY TBrowse::run()
}
end_wait();
TBrowse_sheet s(_cursor, _items, caption, _head, buttons, field(), siblings);
k = s.run();
selected = s.selected();
}
switch (k)
{
case K_CTRL+'G':
*_cursor = selected;
k = do_link(FALSE) ? K_ENTER : K_ESC;
break;
case K_INS:
k = do_link(TRUE) ? K_ENTER : K_ESC;
break;
case K_ENTER:
*_cursor = selected;
do_output();
break;
default:
{
case K_ESC:
case K_QUIT:
break;
case K_CTRL+'G':
*_cursor = selected;
k = do_link(FALSE) ? K_ENTER : K_ESC;
break;
case K_INS:
k = do_link(TRUE) ? K_ENTER : K_ESC;
break;
case K_ENTER:
*_cursor = selected;
do_output();
break;
default:
{
for (const char* i = vals.get(0); i && *i; i = vals.get())
{
for (const char* i = vals.get(0); i && *i; i = vals.get())
{
const short id = field().atodlg(i);
TEditable_field& f = field(id);
f.set(vals.get());
f.set_dirty(vals.get_int());
}
const short id = field().atodlg(i);
TEditable_field& f = field(id);
f.set(vals.get());
f.set_dirty(vals.get_int());
}
if (k >= K_CTRL)
{
TMask& m = field().mask();
const int tag = k - K_CTRL - K_F1;
const short id = siblings.get_int(tag * 2);
TEdit_field& ef = m.efield(id);
ef.set_focus();
k = K_F9;
if (m.is_running())
m.send_key(k, id);
}
break;
}
if (k >= K_CTRL) // Scatta la ricerca su di una chiave alternativa
{
TMask& m = field().mask();
const int tag = k - K_CTRL - K_F1;
const short id = siblings.get_int(tag * 2);
TEdit_field& ef = m.efield(id);
ef.set_focus();
k = K_F9;
if (m.is_running())
m.send_key(k, id);
}
break;
}
return k;
@ -2798,16 +2801,14 @@ void TFile_select::parse_output(TScanner& scanner)
KEY TFile_select::run()
{
DIRECTORY savedir;
TFilename path;
path.add(field().get());
path.ext(_filter.ext());
FILE_SPEC fs;
xvt_fsys_get_dir(&savedir);
xvt_fsys_get_dir(&fs.dir);
strcpy(fs.type, _filter.ext());
strcpy(fs.name, field().get());
strcpy(fs.creator, "AGA");
xvt_fsys_convert_str_to_fspec(path, &fs);
DIRECTORY savedir; xvt_fsys_get_dir(&savedir);
bool good = xvt_dm_post_file_open(&fs, field().prompt()) == FL_OK;
xvt_fsys_set_dir(&savedir);
@ -2816,13 +2817,12 @@ KEY TFile_select::run()
good = _filter.blank() || xvt_str_match(fs.name, _filter, false);
if (good)
{
TFilename path;
xvt_fsys_convert_dir_to_str(&fs.dir, path.get_buffer(), path.size());
path.add(fs.name);
field().set(path);
}
else
field().error_box(TR("Il nome non corrisponde a %s"), _filter.get_buffer());
field().error_box(FR("Il nome non corrisponde a %s"), _filter.get_buffer());
}
return good ? K_ENTER : K_ESC;
}

View File

@ -16,8 +16,6 @@ extern "C"
#include <relation.h>
#include <urldefid.h>
#include <limits.h>
class TCell_property : public TObject
{
COLOR _back, _fore;
@ -1117,7 +1115,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
{
const real r(src); // Memorizzo valore numerico
const int pos = driver->dlg() - FIRST_FIELD;
const TString16 codval = rowrec.get(pos); // Codice valuta
const TString4 codval = rowrec.get(pos); // Codice valuta
const TCurrency c(r, codval, ZERO, _exchange_undefined, e->uppercase());
src = c.string(TRUE);
break;
@ -1131,7 +1129,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
}
else
{
if (e->class_id() == CLASS_BOOLEAN_FIELD) //qui
if (e->class_id() == CLASS_BOOLEAN_FIELD)
xiev->v.cell_request.icon_rid = ICO_CHECK_OFF;
}
@ -1146,14 +1144,15 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
xiev->v.cell_request.color, rec, col);
if (xiev->v.cell_request.back_color == 0 && f->required())
xiev->v.cell_request.back_color = REQUIRED_BACK_COLOR;
}
if (e->has_query_button())
{
xiev->v.cell_request.button = TRUE;
xiev->v.cell_request.button_on_focus = TRUE;
}
if (e->has_query_button()) // Metto il bottone sulle celle attive
{
xiev->v.cell_request.button = TRUE;
xiev->v.cell_request.button_on_focus = TRUE;
if (e->has_check())
xiev->v.cell_request.button_icon_rid = ICO_SEARCH;
}
}
}
else
xiev->v.cell_request.back_color = DISABLED_BACK_COLOR;

View File

@ -1102,46 +1102,48 @@ void TSheet::repos_buttons() const
return; // Sono ancora in fase di creazione: aspetta!
WINDOW btnwin = toolwin(); // was win()
RCT br, wr;
int buttons = 0;
FOR_EACH_MASK_FIELD((*this), f, c)
{
if (c->parent() == btnwin && c->is_kind_of(CLASS_BUTTON_FIELD))
{
if (buttons == 0)
c->get_rect(br);
buttons++;
}
}
if (buttons > 0)
if (btnwin != NULL_WIN)
{
xvt_vobj_get_client_rect(btnwin, &wr);
const short width = br.right - br.left;
const short height = br.bottom - br.top;
int space = (wr.right - buttons * width) / (buttons+1);
if (space < 0) space = 0;
int x = space;
const int y = (wr.bottom - height) / 2;
int buttons = 0;
RCT br;
FOR_EACH_MASK_FIELD((*this), f, c)
{
{
if (c->parent() == btnwin && c->is_kind_of(CLASS_BUTTON_FIELD))
{
buttons--;
const PNT p = { y, x };
xvt_rect_set_pos(&br, p);
c->set_rect(br);
x += space+width;
}
}
{
if (buttons == 0)
c->get_rect(br);
buttons++;
}
}
if (buttons > 0)
{
RCT wr; xvt_vobj_get_client_rect(btnwin, &wr);
const short width = br.right - br.left;
const short height = br.bottom - br.top;
int space = (wr.right - buttons * width) / (buttons+1);
if (space < 0) space = 0;
int x = space;
const int y = (wr.bottom - height) / 2;
FOR_EACH_MASK_FIELD((*this), f, c)
{
if (c->parent() == btnwin && c->is_kind_of(CLASS_BUTTON_FIELD))
{
buttons--;
const PNT p = { y, x };
xvt_rect_set_pos(&br, p);
c->set_rect(br);
x += space+width;
}
}
}
}
// Aggiusta anche lo spreadsheet se necessario
TMask_field& s = field(DLG_QUERY);
xvt_vobj_get_client_rect(s.parent(), &wr);
s.get_rect(br);
RCT wr; xvt_vobj_get_client_rect(s.parent(), &wr);
RCT br; s.get_rect(br);
if (br.bottom > wr.bottom || (wr.bottom-br.bottom) > 48)
{
br.bottom = wr.bottom - br.left; // Lascio uno spazio in fondo pari al bordo sinistro
@ -1708,23 +1710,18 @@ void TBrowse_sheet::handler(
{
case 1:
{
MENU_ITEM* menu = xvt_res_get_menu(BROWSE_BAR);
if (menu)
{
dictionary_translate_menu(menu);
const PNT& p = ep->v.mouse.where;
RCT cr; xvt_vobj_get_client_rect(win, &cr);
XVT_POPUP_ALIGNMENT pa = XVT_POPUP_CENTER;
if (p.h < cr.right / 3)
pa = XVT_POPUP_LEFT_ALIGN;
else
if (p.h > 2 * cr.right / 3)
pa = XVT_POPUP_RIGHT_ALIGN;
xvt_menu_popup(menu->child, win, p, pa, NULL);
xvt_res_free_menu_tree(menu);
}
return;
RCT r; sheet().get_rect(r);
if (xvt_rect_has_point(&r, ep->v.mouse.where))
{
MENU_ITEM* menu = xvt_res_get_menu(BROWSE_BAR);
if (menu)
{
dictionary_translate_menu(menu);
xvt_menu_popup(menu->child, win, ep->v.mouse.where, XVT_POPUP_LEFT_ALIGN, NULL);
xvt_res_free_menu_tree(menu);
return; // no default handling!
}
}
}
break;
default:
@ -1758,6 +1755,7 @@ void TBrowse_sheet::handler(
break;
}
break;
#if OLD_FASHIONED_BROWSE
case E_CONTROL:
if (ep->v.ctl.ci.type == WC_NOTEBK)
{
@ -1766,6 +1764,7 @@ void TBrowse_sheet::handler(
return;
}
break;
#endif
default:
break;
}
@ -1865,7 +1864,7 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
bool first = true;
for (const char* i = ids.get(0); i; i = ids.get())
FOR_EACH_TOKEN(ids, i)
{
if (*i != '\0' && *i != '"' && strchr(i, '@') == NULL)
{
@ -1914,14 +1913,14 @@ TBrowse_sheet::TBrowse_sheet(TCursor* cursor, const char* fields,
const int sz = csize > 50 ? 50 : csize; // Dimensione del campo di ricerca
e = &add_string(c.dlg(), 0, p, 1, y++, csize, flags, sz);
// Aggiunge campo con le icone di filtraggio
add_checkbutton(c.dlg()+500, 0, "", sz+strlen(p)+ 2, y-1, 2, 1, "", 10112, 10113).set_handler(filter_handler);
add_checkbutton(c.dlg()+500, 0, "", sz+p.len()+ 2, y-1, 2, 1, "", 10112, 10113).set_handler(filter_handler);
}
break;
case CLASS_ZOOM_FIELD:
{
e = &add_string(c.dlg(), 0, p, 1, y++, 32000, flags, 50);
// Aggiunge campo con le icone di filtraggio
add_checkbutton(c.dlg()+500, 0, "", 52 + strlen(p), y-1, 2, 1, "", 10112, 10113).set_handler(filter_handler);
add_checkbutton(c.dlg()+500, 0, "", 52 + p.len(), y-1, 2, 1, "", 10112, 10113).set_handler(filter_handler);
}
break;
case CLASS_REAL_FIELD:

View File

@ -66,7 +66,7 @@ TString& TString::set(
{
const int sz = strlen(s);
if (sz > size()) resize(sz, false);
strcpy(_str, s);
strncpy(s, size());
}
else
{
@ -123,7 +123,13 @@ TString::TString() : _str(NULL), _size(0)
TString::~TString()
{
if (_str)
{
delete _str;
#ifdef DBG
_str = NULL;
_size = -883;
#endif
}
}
char TString::shift(int n)
@ -1086,14 +1092,25 @@ TString& TFixed_string::format(
// Certified 90%
const char* TFilename::ext() const
{
/* Riduciamo il parsing "manuale" dei nomi dei file
const char* d = strrchr(name(), '.');
if (d && is_not_slash(*(++d))) return d;
if (d && is_not_slash(*(++d)))
return d;
return "";
*/
if (rfind('.') > 0)
{
char e[_MAX_EXT];
xvt_fsys_parse_pathname(_str, NULL, NULL, NULL, e, NULL);
return get_tmp_string() = e;
}
return "";
}
// Certified 90%
void TFilename::ext(const char* e)
{
/* Riduciamo il parsing "manuale" dei nomi dei file
int start = find(' ')-1;
if (start < 0)
start = len()-1;
@ -1116,12 +1133,16 @@ void TFilename::ext(const char* e)
*this << ".";
*this << e;
}
*/
char v[_MAX_DRIVE], d[_MAX_DIR], n[_MAX_FNAME];
xvt_fsys_parse_pathname(_str, v, d, n, NULL, NULL);
xvt_fsys_build_pathname(_str, v, d, n, e, NULL);
}
// Certified 95%
const char* TFilename::name() const
{
/* Riduciamo il parsing "manuale" dei nomi dei file
int start = find(' ')-1;
if (start < 0)
start = len()-1;
@ -1134,11 +1155,36 @@ const char* TFilename::name() const
spark = &_str[i+1];
spark.cut(start-i);
return spark;
*/
if (full())
{
char n[_MAX_FNAME], e[_MAX_EXT];
xvt_fsys_parse_pathname(_str, NULL, NULL, n, e, NULL);
TString& spark = get_tmp_string();
spark = n;
if (*e)
spark << '.' << e;
return spark;
}
return "";
}
// Certified 95%
const TString& TFilename::name_only() const
{
if (full())
{
char n[_MAX_FNAME];
xvt_fsys_parse_pathname(_str, NULL, NULL, n, NULL, NULL);
return get_tmp_string() = n;
}
return EMPTY_STRING;
}
// Certified 95%
const char* TFilename::path() const
{
{
/* Riduciamo il parsing "manuale" dei nomi dei file
int start = find(' ')-1;
if (start < 0)
start = len()-1;
@ -1150,9 +1196,20 @@ const char* TFilename::path() const
spark = _str;
spark.cut(i+1);
return spark;
*/
if (full())
{
char v[_MAX_DRIVE], d[_MAX_DIR];
xvt_fsys_parse_pathname(_str, v, d, NULL, NULL, NULL);
TString& spark = get_tmp_string();
spark << v << d;
if (spark.not_empty())
spark << SLASH;
return spark;
}
return EMPTY_STRING;
}
TFilename& TFilename::add(const char* n)
{
if (not_empty() && is_not_slash(_str[len()-1]) && is_not_slash(*n))
@ -1161,7 +1218,6 @@ TFilename& TFilename::add(const char* n)
return *this;
}
// @doc EXTERNAL
// @mfunc Controlla il formato del nome del file
@ -1383,7 +1439,7 @@ bool TFilename::exist() const
bool TFilename::fremove() const
{
return ::remove_file(_str);
return xvt_fsys_remove_file(_str) != FALSE;
}
bool TFilename::search_in_path(TFilename& path) const
@ -1403,8 +1459,8 @@ bool TFilename::custom_path(const char* path_list)
{
if (blank()) // Inutile continuare!
return false;
if (!is_absolute_path())
// Espando solo i nomi di file senza path (relativo o assoluto)
if (!starts_with(".") && !is_absolute_path())
{
TToken_string pl = path_list;
if (pl.empty())
@ -2039,7 +2095,7 @@ TToken_string& get_tmp_string(int len)
else
{
if (str->size() < len)
str->spaces(len);
str->resize(len, false);
str->cut(0);
}

View File

@ -461,18 +461,18 @@ class TFilename : public TString
// @author:(INTERNAL) Guido
{
// @comm Nel caso di utilizzo di Windows 95 occorre cambiare le classe base in <c TString256>
// @access Public Member
public:
// @cmember Costruttore
TFilename(const char* n = "") : TString(256)
TFilename(const char* n = "") : TString(260)
{ set(n); }
// @cmember Costruttore
TFilename(const TString& n) : TString(256)
TFilename(const TString& n) : TString(260)
{ set(n); }
// @cmember Costruttore
TFilename(const TFilename& n) : TString(256)
TFilename(const TFilename& n) : TString(260)
{ set(n); }
// @cmember Assegnazione tra TFilename e stringa
@ -510,9 +510,11 @@ public:
bool search_in_path(TFilename& path) const;
// @cmember Richiede all'utente il nome di un file
bool input();
// @cmember Ritorna il nome del file
// @cmember Ritorna il nome del file con estensione
const char* name() const;
// @cmember Ritorna il nome del direttorio
// @cmember Ritorna il nome del file senza estensione
const TString& name_only() const;
// @cmember Ritorna il nome della cartella del file
const char* path() const;
// @cmember Genera il nome di un file temporaneo
const TFilename& temp(const char* prefix = NULL, const char* extension = NULL);

View File

@ -297,6 +297,30 @@ TImage* TTree::get_res_image(short bmp_id) const
return bmp;
}
TImage* TTree::get_res_icon(short icon_id) const
{
const int id = 100000 + icon_id;
TImage* bmp = (TImage*)_image.objptr(id);
if (bmp == NULL)
{
TImage ico(icon_id, true);
if (ico.ok())
{
const TImage* def = get_res_image(BMP_FILE);
int w = 16, h = 16;
if (def != NULL)
{
w = def->width();
h = def->height();
}
ico.convert_transparent_color(NORMAL_BACK_COLOR);
bmp = new TImage(ico, w, h);
((TTree*)this)->_image.add(bmp, id);
}
}
return bmp;
}
TImage* TTree::image(bool selected) const
{
short bmp_id = BMP_FILE;
@ -305,7 +329,6 @@ TImage* TTree::image(bool selected) const
return get_res_image(bmp_id);
}
///////////////////////////////////////////////////////////
// TBidirectional_tree
///////////////////////////////////////////////////////////

View File

@ -23,8 +23,9 @@ class TTree : public TObject
protected:
TAssoc_array _expanded;
TArray _image;
TImage* get_res_image(short id) const; // helper for image(bool)
// helpers for image(bool)
TImage* get_res_image(short id) const;
TImage* get_res_icon(short id) const;
protected:
virtual void node2id(const TObject* node, TString& id) const pure;

View File

@ -1326,10 +1326,8 @@ TOutlook_window::TOutlook_window(int x, int y, int dx, int dy, WINDOW parent, TO
XVT_COLOR_COMPONENT xcc[4]; memset(xcc, 0, sizeof(xcc));
xcc[0].type = XVT_COLOR_BACKGROUND;
xcc[0].color = BTN_BACK_COLOR;
xcc[1].type = XVT_COLOR_BLEND;
xcc[1].color = BTN_LIGHT_COLOR;
xcc[2].type = XVT_COLOR_BORDER;
xcc[2].color = BTN_DARK_COLOR;
xcc[1].type = XVT_COLOR_FOREGROUND;
xcc[1].color = NORMAL_COLOR;
WIN_DEF wd; memset(&wd, 0, sizeof(wd));
wd.wtype = WC_OUTLOOKBAR;

View File

@ -96,13 +96,13 @@
#define BMP_DIR 167
#define BMP_DIRDN 168
#define BMP_FILE 169
#define BMP_STOP 170
#define BMP_FILECHK 171
#define BMP_DIRSEL 172
#define BMP_DIRDNSEL 173
#define BMP_PDF 174
#define BMP_ARCHIVE 175
#define BMP_PROGRAM 176
#define BMP_FONT 179
#define BMP_CLOSETURN 206
#define BMP_CLOSESCONTR 207