Patch level : 4.0

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
codeb.c       risolti piccoli conflitti
colors.cpp    aggiunta conversione da colori a grigi
controls.cpp migliorata visibilita' bottoni disabilitati
image.cpp   aggiunto metodo fade_to_gray dei Visage
retprint.cpp  corretta esportazione testo


git-svn-id: svn://10.65.10.50/trunk@14955 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2007-02-23 08:17:38 +00:00
parent 4bd66668c9
commit 5d121d7663
8 changed files with 86 additions and 32 deletions

View File

@ -459,7 +459,7 @@ int DB_add(int handle)
if (rt == 0 && is_locked == 0)
{
while ((rt = d4flush(data)) == r4locked)
u4delaySec();
u4delaySec();
}
}
DB_unlock(handle);
@ -1168,7 +1168,7 @@ int DB_memowrite( const int handle, const char * fieldname, const char * data )
if (ret == 0 && !DB_file_locked(handle))
{
d4flush(dbdata[handle]);
d4unlock(dbdata[handle]);
d4unlock(dbdata[handle]);
}
return ret;
}

View File

@ -46,8 +46,16 @@ COLOR blend_colors(COLOR col1, COLOR col2, double perc)
const byte g = byte(g1 * perc + g2*(1.0-perc));
const byte b = byte(b1 * perc + b2*(1.0-perc));
// return RGB2COLOR(r, g, b);
return MAKE_COLOR(r, g, b); // Faster
return MAKE_COLOR(r, g, b);
}
COLOR grayed_color(COLOR col)
{
const unsigned int r = XVT_COLOR_GET_RED(col);
const unsigned int g = XVT_COLOR_GET_GREEN(col);
const unsigned int b = XVT_COLOR_GET_BLUE(col);
const unsigned int k = (unsigned int)(0.299 * r + 0.587 * g + 0.114 * b);
return MAKE_COLOR(k, k, k);
}
unsigned int color_distance(COLOR col1, COLOR col2)

View File

@ -12,6 +12,7 @@
COLOR RGB2COLOR(unsigned char red, unsigned char green, unsigned char blue);
COLOR choose_color(COLOR col = COLOR_BLACK, WINDOW win = NULL_WIN);
COLOR blend_colors(COLOR col1, COLOR col2, double perc = 0.5);
COLOR grayed_color(COLOR col);
unsigned int color_distance(COLOR col1, COLOR col2);
extern COLOR MASK_BACK_COLOR;

View File

@ -85,22 +85,25 @@ KEY TControl::xiev_to_key(const XI_EVENT* xiev)
// TPicture_array
///////////////////////////////////////////////////////////
class TPicture_array : public TArray
class TPicture_array
{
TArray _enabled, _disabled;
public:
bool add(short id);
const TImage& image(short id) const { return (const TImage&)operator[](id); }
bool exist(short id) const { return objptr(id) != NULL; }
const TImage& image(short id) const { return (const TImage&)_enabled[id]; }
const TImage& disabled_image(short id) const { return (const TImage&)_disabled[id]; }
bool exist(short id) const { return _enabled.objptr(id) != NULL; }
void reload();
TPicture_array() : TArray(128) {}
TPicture_array() {}
virtual ~TPicture_array() {}
};
bool TPicture_array::add(short id)
{
TImage* i = (TImage*)objptr(id);
TImage* i = (TImage*)_enabled.objptr(id);
if (i == NULL)
{
if (SMALL_ICONS)
@ -117,7 +120,11 @@ bool TPicture_array::add(short id)
if (i->ok())
{
i->convert_transparent_color(BTN_BACK_COLOR);
TArray::add(i, id);
_enabled.add(i, id);
TImage* d = new TImage(*i);
d->fade_to_gray(COLOR_GRAY);
_disabled.add(d, id);
}
else
{
@ -130,9 +137,10 @@ bool TPicture_array::add(short id)
void TPicture_array::reload()
{
for (short id = last(); id > 0; id--) if (exist(id))
_disabled.destroy();
for (int id = _enabled.last(); id > 0; id = _enabled.pred(id))
{
destroy(id);
_enabled.destroy(id);
add(id);
}
}
@ -1675,7 +1683,7 @@ void TPushbutton_control::update()
const short bmp = (_bmp_dn > 0 && _obj->v.btn->down) ? _bmp_dn : _bmp_up;
if (bmp > 0)
{
const TImage& i = _picture->image(bmp);
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;
@ -1687,8 +1695,7 @@ void TPushbutton_control::update()
}
i.draw(win, x, y);
if (!(attrib & XI_ATR_ENABLED))
/* if (!(attrib & XI_ATR_ENABLED))
{
CPEN pen;
pen.width = 1;
@ -1710,7 +1717,7 @@ void TPushbutton_control::update()
p.v += i.height();
xvt_dwin_draw_line(win, p);
}
}
} */
}
else
{
@ -2501,4 +2508,4 @@ TListbox_control::TListbox_control(WINDOW win, short cid,
TListbox_control::~TListbox_control()
{
delete _ddl; _ddl = NULL;
}
}

View File

@ -10,7 +10,7 @@
#endif
enum TDongleHardware { _dongle_unknown, _dongle_hardlock, _dongle_eutron, _dongle_network };
enum TDongleType { _no_dongle, _user_dongle, _developer_dongle, _aga_dongle, _prassi_dongle };
enum TDongleType { _no_dongle, _user_dongle, _developer_dongle, _aga_dongle };
enum { MAX_DONGLE_ASSIST = 8 };
class TDongle : public TObject

View File

@ -78,18 +78,7 @@ TImage::TImage(const TImage& im, short w, short h) : _image(NULL)
set(xvt_image_create(fmt, w, h, 0L));
if (ok())
{
#ifndef XVAGA
if (fmt == XVT_IMAGE_CL8)
{
const short colors = xvt_image_get_ncolors(im._image);
xvt_image_set_ncolors(_image, colors);
for (short c = 0; c < colors; c++)
xvt_image_set_clut(_image, c, xvt_image_get_clut((XVT_IMAGE)im._image, c));
}
#endif
xvt_image_transfer(_image, (XVT_IMAGE)im._image, &_src, (RCT*)&im._src);
}
}
// Certified 90%
@ -288,3 +277,49 @@ void TImage::convert_transparent_color(COLOR transparent)
}
}
void TImage::fade_to_gray(int gray)
// @comm Legge nell'immagine i pixel diversi da quello in alto a sinistra e li setta
// in grigio
{
if (_image == NULL)
return; // Null image
const COLOR trans = get_pixel(0,0) & 0x00FFFFFF;
if (xvt_image_get_format(_image) == XVT_IMAGE_CL8)
{
for (int index = xvt_image_get_ncolors(_image)-1; index >=0; index--)
{
COLOR pixie = xvt_image_get_clut(_image, index) & 0x00FFFFFF;
if (pixie != trans)
{
pixie = grayed_color(pixie);
if (gray >= 0)
{
const int k = (XVT_COLOR_GET_RED(pixie) + gray) / 2;
pixie = MAKE_COLOR(k,k,k);
}
xvt_image_set_clut(_image, index, pixie);
}
}
}
else
{
short dx, dy; xvt_image_get_dimensions(_image, &dx, &dy);
for (short y = 0; y < dy; y++) for (short x = 0; x < dx; x++)
{
COLOR pixie = get_pixel(x, y) & 0x00FFFFFF;
if (pixie != trans)
{
pixie = grayed_color(pixie);
if (gray >= 0)
{
const int k = (XVT_COLOR_GET_RED(pixie) + gray) / 2;
pixie = MAKE_COLOR(k,k,k);
}
set_pixel(x, y, pixie);
}
}
}
}

View File

@ -80,6 +80,10 @@ public:
// @cmember Setta i colori dell'immagine in modo da renderla trasparente
// usando l'angolo in alto a sinistra dell'imagine stessa
void convert_transparent_color(COLOR transparent);
// Trasforma l'immagine in toni di grigio.
// Se gray>=0 sfuma ulteriormente verso il tono specificato
void fade_to_gray(int gray = -1);
// @cmember Setta l'<p n>.esime entry della paletta al colore <p c>
void set_clut(byte n, COLOR c);

View File

@ -1452,9 +1452,8 @@ bool TBook::print_page(TWindow& win, size_t page)
bool TBook::export_text(const TFilename& fname)
{
const TFixed_string ext(fname.ext());
if (ext.compare("pdf", true) == 0)
export_pdf(fname);
if (fname.ends_with(".pdf", true))
return export_pdf(fname);
TString str(1024);
char* buffer = str.get_buffer();