Patch level : 10.0

Files correlati     : xvaga.dll
Ricompilazione Demo : [ ]
Commento            :
Aggiunto supporto per icone trasparenti negli alberi (non solo bitmap)


git-svn-id: svn://10.65.10.50/trunk@17591 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-11-11 16:17:40 +00:00
parent 93c9ce1cad
commit 0a41f5a38b
6 changed files with 245 additions and 156 deletions

View File

@ -15,6 +15,7 @@
#include <wx/sysopt.h>
#include <wx/thread.h>
#include <wx/tokenzr.h>
#include <wx/aui/aui.h>
#include "xvt.h"
#include "statbar.h"
@ -1110,6 +1111,8 @@ public:
#else
const wxBitmap& Bitmap(wxDC& dc);
#endif
COLOR GetPixel(int x, int y) const;
void SetPixel(int x, int y, COLOR color);
TXVT_IMAGE() : m_bitmap(NULL), m_nDepth(0), m_bDirty(false) { }
~TXVT_IMAGE();
@ -1120,6 +1123,21 @@ IMPLEMENT_DYNAMIC_CLASS(TXVT_IMAGE, wxImage);
#define CAST_TIMAGE(xvtimg, img) TXVT_IMAGE* img = wxDynamicCast(xvtimg, TXVT_IMAGE);
#define CAST_IMAGE(xvtimg, img) const wxImage* img = wxDynamicCast(xvtimg, wxImage);
COLOR TXVT_IMAGE::GetPixel(int x, int y) const
{
// Chissa' perche' non esiste la GetRGB
const long pos = XYToIndex(x, y) * 3;
unsigned char* data = GetData() + pos;
return XVT_MAKE_COLOR(data[0], data[1], data[2]);
}
void TXVT_IMAGE::SetPixel(int x, int y, COLOR color)
{
SetRGB(x, y, XVT_COLOR_GET_RED(color), XVT_COLOR_GET_GREEN(color), XVT_COLOR_GET_BLUE(color));
m_bDirty = true;
}
#ifdef WIN32
HBITMAP TXVT_IMAGE::Bitmap(wxDC& dc)
@ -1228,7 +1246,7 @@ int TFontId::Weight() const
return (m_wMask & XVT_FS_BOLD) ? wxBOLD : wxNORMAL;
}
wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
const wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
{
int nSize = PointSize();
if (win == PRINTER_WIN)
@ -1301,7 +1319,13 @@ wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
nSize = (int)(nSize * dPrintScale + 0.5);
}
return XVT_FONT_CACHE.FindOrCreate(nSize, Family(), Style(), Weight(), Underline(), FaceName());
const wxFont& ff1 = XVT_FONT_CACHE.FindOrCreate(nSize, Family(), Style(), Weight(), Underline(), FaceName());
if (ff1.GetPointSize() > 0)
return ff1;
XVT_FONT_CACHE.Destroy();
const wxFont& ff2 = XVT_FONT_CACHE.FindOrCreate(nSize, Family(), Style(), Weight(), Underline(), FaceName());
return ff2;
}
void TFontId::Copy(const wxFont& rFont)
@ -1324,17 +1348,15 @@ void TFontId::Copy(const wxFont& rFont)
void xvt_dwin_clear(WINDOW win, COLOR col)
{
CAST_DC(win, dc);
CAST_COLOR(col, brush_color);
wxBrush* brush = wxTheBrushList->FindOrCreateBrush(brush_color, wxSOLID);
dc.SetBackground(*brush);
dc.Clear();
CAST_WIN(win, w);
CAST_COLOR(col, colour);
w.SetOwnBackgroundColour(colour);
w.ClearBackground();
}
void xvt_dwin_draw_arc(WINDOW win, const RCT* r, int sx, int sy, int ex, int ey)
{
if (r != NULL)
if (win != NULL_WIN && r != NULL)
{
CAST_DC(win, dc);
dc.DrawArc(sx, sy, ex, ey, (r->right+r->left)/2, (r->top+r->bottom)/2);
@ -1483,7 +1505,7 @@ void xvt_dwin_draw_polygon(WINDOW win, const PNT *lpnts, int npnts)
void xvt_dwin_draw_polyline(WINDOW win, const PNT *lpnts, int npnts)
{
if (lpnts != NULL && npnts > 1)
if (win != NULL_WIN && lpnts != NULL && npnts > 1) // Occorrono almeno 2 punti
{
xvt_dwin_draw_set_pos(win, lpnts[0]);
for (int i = 1; i < npnts; i++)
@ -1609,17 +1631,8 @@ XVT_FNTID xvt_dwin_get_font(WINDOW win)
void xvt_dwin_get_font_metrics(WINDOW win, int *leadingp, int *ascentp, int *descentp)
{
CAST_DC(win, dc);
const wxString str = "Mq";
int height, desc, lead;
dc.GetTextExtent(str, NULL, &height, &desc, &lead);
if (leadingp)
*leadingp = lead;
if (ascentp)
*ascentp = height-lead-desc;
if (descentp)
*descentp = desc;
CAST_TDC(win, dc);
xvt_font_get_metrics(&dc._font, leadingp, ascentp, descentp);
}
long xvt_dwin_get_font_size_mapped(WINDOW win)
@ -1644,7 +1657,7 @@ int xvt_dwin_get_text_width(WINDOW win, const char *s, int len)
}
if (len > 0)
str.Truncate(len);
int height;
int height = 0;
dc.GetTextExtent(str, &width, &height);
}
@ -1891,10 +1904,14 @@ void xvt_font_destroy(XVT_FNTID font_id)
BOOLEAN xvt_font_get_family(XVT_FNTID font_id, char* buf, long max_buf)
{
CAST_FONT(font_id, font);
wxStrncpy(buf, font.FaceName(), max_buf);
buf[max_buf-1] = '\0';
return TRUE;
BOOLEAN ok = font_id != NULL && buf != NULL && max_buf > 0;
if (ok)
{
CAST_FONT(font_id, font);
wxStrncpy(buf, font.FaceName(), max_buf);
buf[max_buf-1] = '\0';
}
return ok;
}
BOOLEAN xvt_font_get_family_mapped(XVT_FNTID font_id, char* buf, long max_buf)
@ -1904,12 +1921,21 @@ void xvt_font_get_metrics(XVT_FNTID font_id, int *leadingp, int *ascentp, int *d
{
CAST_FONT(font_id, font);
WINDOW win = font.Win();
if (win == NULL_WIN)
win = TASK_WIN;
CAST_DC(win, dc);
if (win != PRINTER_WIN)
win = TASK_WIN; // Non mi fido troppo della finestra su cui il font e' mappato
CAST_DC(win, dc);
const wxString str = "Mq";
int height, desc, lead;
dc.GetTextExtent(str, NULL, &height, &desc, &lead, &font.Font(&dc, win));
int height = 0, desc = 0, lead = 0;
const wxFont& ff = font.Font(&dc, win);
dc.GetTextExtent(str, NULL, &height, &desc, &lead, (wxFont*)&ff);
if (height <= 0 || height > 64000) // Gestisce eventuali anomalie alla meno peggio
{
wxASSERT(false);
height = ff.GetPointSize();
desc = height / 5;
lead = 0;
}
if (leadingp)
*leadingp = lead;
if (ascentp)
@ -1920,8 +1946,8 @@ void xvt_font_get_metrics(XVT_FNTID font_id, int *leadingp, int *ascentp, int *d
BOOLEAN xvt_font_get_native_desc(XVT_FNTID font_id, char *buf, long max_buf)
{
long len = xvt_font_serialize(font_id, buf, max_buf);
return len > 0;
const long len = xvt_font_serialize(font_id, buf, max_buf);
return len > 0 && len < max_buf;
}
long xvt_font_get_size(XVT_FNTID font_id)
@ -1984,15 +2010,17 @@ long xvt_font_serialize(XVT_FNTID font_id, char *buf, long max_buf)
const char* name = font.FaceName();
const int size = font.PointSize();
const int italic = (font.Mask() & XVT_FS_ITALIC) != 0;
const int weight = 400; // Normal size
const int weight = (font.Mask() & XVT_FS_BOLD) ? 700 : 400;
wxString str;
str = wxString::Format("01\\%s\\0\\%d\\WIN01/%d/%d/0/0/%d/0/0/0/0/0/0/0/0/%s",
name, size, size, weight, italic, name);
wxStrncpy(buf, str, max_buf);
buf[max_buf-1] = '\0';
return strlen(buf);
if (buf != NULL && max_buf > 0)
{
wxStrncpy(buf, str, max_buf);
buf[max_buf-1] = '\0';
}
return str.Len();
}
void xvt_font_unmap(XVT_FNTID font_id)
@ -2061,7 +2089,7 @@ BOOLEAN xvt_fsys_parse_pathname(const char* mbs, char* volname, char* dirname, c
BOOLEAN xvt_fsys_convert_dir_to_str(DIRECTORY* dirp, char* path, int sz_path)
{
BOOLEAN ok = path != NULL && dirp != NULL;
BOOLEAN ok = dirp != NULL && path != NULL && sz_path > 0;
if (ok)
{
wxStrncpy(path, dirp->path, sz_path-1);
@ -2085,7 +2113,7 @@ BOOLEAN xvt_fsys_convert_str_to_dir(const char *path, DIRECTORY *dirp)
BOOLEAN xvt_fsys_convert_fspec_to_str(const FILE_SPEC *fs, char *path, int sz_path)
{
BOOLEAN ok = FALSE;
if (fs != NULL)
if (fs != NULL && path != NULL && sz_path > 0)
{
char mbs[_MAX_PATH];
xvt_fsys_build_pathname(mbs, "", fs->dir.path, fs->name, fs->type, NULL);
@ -2121,8 +2149,7 @@ void xvt_fsys_get_default_dir(DIRECTORY *dirp)
BOOLEAN xvt_fsys_get_dir(DIRECTORY *dirp)
{
wxString str = ::wxGetCwd();
return xvt_fsys_convert_str_to_dir(str, dirp);
return xvt_fsys_convert_str_to_dir(::wxGetCwd(), dirp);
}
static wxString get_disk_root(const char* path)
@ -2169,7 +2196,7 @@ BOOLEAN xvt_fsys_is_removable_drive(const char* path)
{
#ifdef WIN32
const wxString strRoot = get_disk_root(path);
yes = GetDriveType(strRoot) == DRIVE_REMOVABLE;
yes = ::GetDriveType(strRoot) == DRIVE_REMOVABLE;
#else
char dev[_MAX_PATH];
OsLinux_GetFileSys(path, dev, NULL, NULL);
@ -2190,7 +2217,7 @@ BOOLEAN xvt_fsys_is_network_drive(const char* path)
{
#ifdef WIN32
const wxString strRoot = get_disk_root(path);
yes = GetDriveType(strRoot) == DRIVE_REMOTE;
yes = ::GetDriveType(strRoot) == DRIVE_REMOTE;
#else
yes = OsLinux_IsNetworkDrive(path);
#endif
@ -2208,7 +2235,7 @@ BOOLEAN xvt_fsys_is_fixed_drive(const char* path)
{
#ifdef WIN32
const wxString strRoot = get_disk_root(path);
yes = GetDriveType(strRoot) == DRIVE_FIXED;
yes = ::GetDriveType(strRoot) == DRIVE_FIXED;
#else
yes = !(xvt_fsys_is_network_drive(path) || xvt_fsys_is_removable_drive(path));
#endif
@ -2396,6 +2423,27 @@ void xvt_image_destroy(XVT_IMAGE img)
delete image;
}
int xvt_image_find_clut_index(XVT_IMAGE img, COLOR rgb)
{
CAST_IMAGE(img, image);
int i = -1;
if (image && image->Ok() && image->HasPalette())
{
const wxPalette& pal = image->GetPalette();
for (i = 255; i >= 0; i--)
{
unsigned char ri, gi, bi;
if (pal.GetRGB(i, &ri, &gi, &bi))
{
const COLOR rgbi = XVT_MAKE_COLOR(ri, gi, bi);
if ((rgbi & 0x00FFFFFF) == (rgb & 0x00FFFFFF))
break;
}
}
}
return i;
}
COLOR xvt_image_get_clut(XVT_IMAGE img, short index)
{
CAST_IMAGE(img, image);
@ -2403,8 +2451,8 @@ COLOR xvt_image_get_clut(XVT_IMAGE img, short index)
{
const wxPalette& pal = image->GetPalette();
unsigned char r, g, b;
pal.GetRGB(index, &r, &g, &b);
return XVT_MAKE_COLOR(r, g, b);
if (pal.GetRGB(index, &r, &g, &b))
return XVT_MAKE_COLOR(r, g, b);
}
return COLOR_INVALID;
}
@ -2448,14 +2496,9 @@ short xvt_image_get_ncolors(XVT_IMAGE image)
COLOR xvt_image_get_pixel(XVT_IMAGE image, short x, short y)
{
CAST_IMAGE(image, i);
CAST_TIMAGE(image, i);
if (i != NULL && i->Ok())
{
int r = i->GetRed(x, y);
int g = i->GetGreen(x, y);
int b = i->GetBlue(x, y);
return XVT_MAKE_COLOR(r, g, b);
}
return i->GetPixel(x, y);
return COLOR_INVALID;
}
@ -2496,23 +2539,27 @@ void xvt_image_set_clut(XVT_IMAGE image, short index, COLOR color)
CAST_TIMAGE(image, i);
if (i != NULL && i->Ok() && i->HasPalette())
{
CAST_COLOR(color, c);
wxImage& bmp = i->Image(); // Set dirty!
unsigned char ri, gi, bi;
bmp.GetOrFindMaskColour(&ri,&gi, &bi);
const int idx = xvt_image_find_clut_index(image, XVT_MAKE_COLOR(ri, gi, bi));
if (idx == index)
bmp.SetMaskColour(c.Red(), c.Green(), c.Blue());
const wxPalette& pal = bmp.GetPalette();
CAST_COLOR (color, c);
unsigned char ri, gi, bi;
pal.GetRGB(index, &ri, &gi, &bi);
const COLOR old_color = XVT_MAKE_COLOR(ri, gi, bi);
const int w = bmp.GetWidth();
const int h = bmp.GetHeight();
for (int y = 0; y < h; y++) for (int x = 0; x < w; x++)
{
unsigned char r = bmp.GetRed(x, y);
if (r != ri) continue;
unsigned char g = bmp.GetGreen(x, y);
if (g != gi) continue;
unsigned char b = bmp.GetBlue(x, y);
if (b != bi) continue;
bmp.SetRGB(x, y, c.Red(), c.Green(), c.Blue());
const COLOR rgb = i->GetPixel(x, y);
if (rgb == old_color)
i->SetPixel(x, y, color);
}
}
}
@ -2526,10 +2573,7 @@ void xvt_image_set_pixel(XVT_IMAGE image, short x, short y, COLOR color)
{
CAST_TIMAGE(image, i);
if (i != NULL && i->Ok())
{
CAST_COLOR(color, c);
i->Image().SetRGB(x, y, c.Red(), c.Green(), c.Blue());
}
i->SetPixel(x, y, color);
}
void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RCT *srcrctp)
@ -2904,6 +2948,14 @@ XVT_FNTID xvt_res_get_font(int rid)
return f;
}
XVT_IMAGE xvt_res_get_icon(int rid)
{
const wxString strFileName = _GetResourceName("Icon", rid);
const bool ok = !strFileName.IsEmpty();
XVT_ASSERT(ok);
return ok ? xvt_image_read(strFileName) : NULL;
}
XVT_IMAGE xvt_res_get_image(int rid)
{
const wxString strFileName = _GetResourceName("Image", rid);
@ -3967,8 +4019,6 @@ void xvt_vobj_destroy(WINDOW win)
w->Destroy(); // same as delete w
_nice_windows.Delete(win); // Elimina "di nuovo" dalla lista delle finestre attive
GetTDCMapper().DestroyTDC(win); // Elimina dalla lista dei display context
}
}
@ -4246,10 +4296,26 @@ void xvt_vobj_raise(WINDOW win)
w.Raise();
}
static void SetArtistColor(WINDOW win, int id, long rgb)
{
CAST_WIN(win, w);
const wxAuiManager* pMgr = wxAuiManager::GetManager(&w);
wxAuiDockArt* pArt = (pMgr != NULL) ? pMgr->GetArtProvider() : NULL;
if (pArt != NULL)
{
CAST_COLOR(rgb, col);
pArt->SetColour(id, col);
if (id == wxAUI_DOCKART_BACKGROUND_COLOUR)
{
}
}
}
void xvt_vobj_set_attr(WINDOW win, long data, long value)
{
switch (data)
{
case ATTR_BACK_COLOR: SetArtistColor(win, wxAUI_DOCKART_BACKGROUND_COLOUR, value); break;
case ATTR_ERRMSG_HANDLER: _error_handler = (XVT_ERRMSG_HANDLER)value; break;
case ATTR_EVENT_HOOK: SORRY_BOX(); break; // TBI?: Native events hook!
case ATTR_WIN_PM_DRAWABLE_TWIN: break; // Ignored: Always TRUE

View File

@ -199,6 +199,7 @@ XVTDLL BOOLEAN xvt_help_process_event(XVT_HELP_INFO hi, WINDOW win, EVENT
XVTDLL XVT_IMAGE xvt_image_capture(WINDOW win, const RCT* rct);
XVTDLL XVT_IMAGE xvt_image_create(XVT_IMAGE_FORMAT format, short width, short height, long reserved);
XVTDLL void xvt_image_destroy(XVT_IMAGE image);
XVTDLL int xvt_image_find_clut_index(XVT_IMAGE image, COLOR color);
XVTDLL COLOR xvt_image_get_clut(XVT_IMAGE image, short index);
XVTDLL void xvt_image_get_dimensions(XVT_IMAGE image, short *width, short *height);
XVTDLL XVT_IMAGE_FORMAT xvt_image_get_format(XVT_IMAGE image);
@ -293,6 +294,7 @@ XVTDLL void xvt_rect_inflate(RCT *rctp, short ix, short iy);
XVTDLL void xvt_res_free_menu_tree(MENU_ITEM* tree);
XVTDLL XVT_FNTID xvt_res_get_font(int rid);
XVTDLL XVT_IMAGE xvt_res_get_icon(int rid);
XVTDLL XVT_IMAGE xvt_res_get_image(int rid);
XVTDLL MENU_ITEM* xvt_res_get_menu(int rid);
XVTDLL char* xvt_res_get_str(int rid, char *s, int sz_s);

View File

@ -4,7 +4,6 @@
#include "statbar.h"
#include <wx/filename.h>
#include <wx/notebook.h>
#include <wx/treectrl.h>
#include <wx/vlbox.h>
#include <wx/aui/aui.h>
@ -73,6 +72,15 @@ const wxBitmap& _GetToolResource(int nIcon, int nDesiredSize)
return *bmp;
}
static wxAuiDockArt* FindArtist(wxWindow* pWindow)
{
wxAuiDockArt* pArtist = NULL;
const wxAuiManager* pManager = wxAuiManager::GetManager(pWindow);
if (pManager != NULL)
pArtist = pManager->GetArtProvider();
return pArtist;
}
///////////////////////////////////////////////////////////
// Controls functions
///////////////////////////////////////////////////////////
@ -95,8 +103,10 @@ class TwxNoteBook : public wxAuiNotebook
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(TwxNoteBook)
protected:
virtual bool SetBackgroundColour(const wxColour& col);
void OnPageChanged(wxAuiNotebookEvent& e);
long Flags2Style(long flags) const;
@ -220,7 +230,7 @@ WINDOW xvt_ctl_create_def(WIN_DEF* win_def_p, WINDOW parent_win, long app_data)
break;
case WC_CHECKBOX: /* check box */
{
long style = wxCHK_2STATE | wxTRANSPARENT_WINDOW;
long style = wxCHK_2STATE;
if (win_def_p->wtype == CTL_FLAG_RIGHT_JUST)
style |= wxALIGN_RIGHT;
wxCheckBox* cb = new wxCheckBox(pParent, id, win_def_p->text,
@ -292,31 +302,31 @@ void xvt_ctl_check_radio_button(WINDOW win, WINDOW* wins, int NbrWindows)
void xvt_ctl_set_checked(WINDOW win, BOOLEAN bCheck)
{
wxCheckBox* cb = (wxCheckBox*)win;
wxASSERT(cb != NULL);
cb->SetValue(bCheck != 0);
wxCheckBox* cb = wxDynamicCast((wxObject*)win, wxCheckBox);
if (cb != NULL)
cb->SetValue(bCheck != 0);
}
void xvt_ctl_set_colors(WINDOW win, const XVT_COLOR_COMPONENT* colors, XVT_COLOR_ACTION action)
{
// Non posso usare wxControl in quanto certi controlli derivano da wxWindow
wxWindow* w = wxDynamicCast((wxObject*)win, wxWindow);
if (w != NULL && colors != NULL)
{
for (int i = 0; colors[i].type; i++)
if (action == XVT_COLOR_ACTION_SET)
{
CAST_COLOR(colors[i].color, rgb);
if (action == XVT_COLOR_ACTION_SET)
for (int i = 0; colors[i].type; i++)
{
CAST_COLOR(colors[i].color, rgb);
switch(colors[i].type)
{
case XVT_COLOR_BACKGROUND:
if (w->IsKindOf(CLASSINFO(wxButton)))
w->SetOwnBackgroundColour(rgb);
w->SetOwnBackgroundColour(rgb);
break;
case XVT_COLOR_FOREGROUND:
w->SetForegroundColour(rgb);
w->SetOwnForegroundColour(rgb);
break;
case XVT_COLOR_TROUGH:
case XVT_COLOR_BLEND:
if (!w->IsKindOf(CLASSINFO(wxButton)))
w->SetOwnBackgroundColour(rgb);
break;
@ -324,10 +334,10 @@ void xvt_ctl_set_colors(WINDOW win, const XVT_COLOR_COMPONENT* colors, XVT_COLOR
break;
}
}
else
{
// ???
}
}
else
{
// ???
}
}
}
@ -519,6 +529,19 @@ XVTDLL BOOLEAN xvt_pane_set_size_range(WINDOW win, int min_size, int best_size,
///////////////////////////////////////////////////////////
// Notebook interface
///////////////////////////////////////////////////////////
class TwxAuiDefaultTabArt : public wxAuiDefaultTabArt
{
public:
void SetBackgroundColour(const wxColor& colour) { m_base_colour = colour; }
virtual wxAuiTabArt* Clone();
};
wxAuiTabArt* TwxAuiDefaultTabArt::Clone()
{
TwxAuiDefaultTabArt* art = new TwxAuiDefaultTabArt();
art->m_base_colour = m_base_colour;
return art;
}
IMPLEMENT_DYNAMIC_CLASS(TwxNoteBook, wxAuiNotebook)
@ -531,6 +554,18 @@ BEGIN_EVENT_TABLE(TwxNoteBook, wxAuiNotebook)
EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY, OnPageChanged)
END_EVENT_TABLE();
bool TwxNoteBook::SetBackgroundColour(const wxColour& col)
{
const bool ok = wxAuiNotebook::SetBackgroundColour(col);
if (ok) // Se cambio lo sfondo del tab control devo notificarlo all'art provider
{
TwxAuiDefaultTabArt* pArtist = (TwxAuiDefaultTabArt*)GetArtProvider();
if (pArtist != NULL)
pArtist->SetBackgroundColour(col);
}
return ok;
}
void TwxNoteBook::OnPageChanged(wxAuiNotebookEvent& evt)
{
if (!m_bSuspended)
@ -625,6 +660,7 @@ TwxNoteBook::TwxNoteBook(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long flags)
: wxAuiNotebook(parent, id, pos, size, Flags2Style(flags)), m_bSuspended(false)
{
SetArtProvider(new TwxAuiDefaultTabArt);
_nice_windows.Put((WINDOW)this, this); // Serve per poter fare la xvt_vobj_destroy
}
@ -897,7 +933,18 @@ int TwxTreeCtrl::img2int(XVT_IMAGE xvt_img)
AssignImageList(il = nil);
}
}
i = il->Add(wxBitmap(img));
if (!img.HasMask())
{
wxImage& trans = (wxImage&)img;
const int r = img.GetRed(0,0);
const int g = img.GetGreen(0,0);
const int b = img.GetBlue(0,0);
trans.SetMask();
trans.SetMaskColour(r, g, b);
}
const wxBitmap bmp(img);
i = il->Add(bmp);
m_img[xvt_img] = i+1; // Memorizzo indice+1
}
if (i < 0)
@ -1202,17 +1249,6 @@ BEGIN_EVENT_TABLE(TwxOutlookBar, wxVListBox)
EVT_MOUSE_CAPTURE_LOST(TwxOutlookBar::OnMouseCaptureLost)
END_EVENT_TABLE()
/*
static wxAuiDockArt* GetArtist(const wxWindow* pWindow)
{
wxAuiDockArt* pArtist = NULL;
const wxAuiManager* pManager = wxAuiManager::GetManager(pWindow->GetParent());
if (pManager != NULL)
pArtist = pManager->GetArtProvider();
return pArtist;
}
*/
static const wxColour ModulateColour(const wxColour& col, int percent)
{
int k = 0;
@ -1290,7 +1326,9 @@ void TwxOutlookBar::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
dc.SetFont(GetFont()); // Imposta il font predefinito per questo controllo
wxColour color = wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT);
wxColour color = GetForegroundColour();
if (InheritsBackgroundColour())
color = wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT);
dc.SetTextForeground(color);
const wxSize szText = dc.GetTextExtent(oi.m_strText);
@ -1389,28 +1427,6 @@ int TwxOutlookBar::Add(short nIconId, const wxString strText, int nFlags)
return i;
}
static bool AreSystemColors(const XVT_COLOR_COMPONENT* colors)
{
bool yes = true;
if (colors != NULL && colors->type != 0)
{
XVT_COLOR_COMPONENT* cc = (XVT_COLOR_COMPONENT*)xvt_vobj_get_attr(NULL_WIN, ATTR_APP_CTL_COLORS);
for (int i = 0; colors[i].type && yes; i++)
{
for (int j = 0; cc[j].type; j++)
{
if (colors[i].type == cc[j].type)
{
yes = colors[i].color == cc[j].color;
break;
}
}
}
xvt_mem_free((DATA_PTR)cc);
}
return yes;
}
TwxOutlookBar::TwxOutlookBar(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style)
: wxVListBox(parent, id, pos, size, style), m_bCaptured(false), m_nHovering(wxNOT_FOUND)
@ -1424,58 +1440,44 @@ TwxOutlookBar::~TwxOutlookBar()
ReleaseMouse();
}
int xvt_list_add_item(WINDOW win, short icon, const char* text, int flags)
{
int n = -1;
if (win != NULL_WIN)
{
TwxOutlookBar* olb = (TwxOutlookBar*)win;
n = olb->Add(icon, text, flags);
}
TwxOutlookBar* olb = wxDynamicCast((wxObject*)win, TwxOutlookBar);
const int n = olb != NULL ? olb->Add(icon, text, flags) : -1;
return n;
}
BOOLEAN xvt_list_clear(WINDOW win)
{
BOOLEAN ok = win != NULL_WIN;
if (ok)
{
TwxOutlookBar* olb = (TwxOutlookBar*)win;
TwxOutlookBar* olb = wxDynamicCast((wxObject*)win, TwxOutlookBar);
if (olb)
olb->Clear();
}
return ok;
return olb != NULL;
}
BOOLEAN xvt_list_get_sel_index(WINDOW win)
{
int sel = -1;
BOOLEAN ok = win != NULL_WIN;
if (ok)
{
TwxOutlookBar* olb = (TwxOutlookBar*)win;
sel = olb->GetSelection();
}
TwxOutlookBar* olb = wxDynamicCast((wxObject*)win, TwxOutlookBar);
const int sel = olb != NULL ? olb->GetSelection() : -1;
return sel;
}
BOOLEAN xvt_list_set_sel(WINDOW win, int index, BOOLEAN select)
{
BOOLEAN ok = win != NULL_WIN;
if (ok)
TwxOutlookBar* olb = wxDynamicCast((wxObject*)win, TwxOutlookBar);
if (olb != NULL)
{
TwxOutlookBar* olb = (TwxOutlookBar*)win;
if (select)
olb->SetSelection(index);
}
return ok;
return olb != NULL;
}
///////////////////////////////////////////////////////////
// ToolBar
///////////////////////////////////////////////////////////
#if wxCHECK_VERSION(3,0,0)
#if wxCHECK_VERSION(8,8,3)
#include <wx/aui/auibar.h>
#define TwxToolBarBase wxAuiToolBar
#else
@ -1489,6 +1491,7 @@ class TwxToolBar : public TwxToolBarBase
protected:
DECLARE_EVENT_TABLE()
void OnTool(wxCommandEvent& evt);
virtual bool SetBackgroundColour(const wxColour& colour);
TwxToolBar() : TwxToolBarBase(NULL, wxID_ANY) { }
public:
@ -1513,8 +1516,19 @@ void TwxToolBar::OnTool(wxCommandEvent& evt)
win->DoXvtEvent(e);
}
TwxToolBar::TwxToolBar(wxWindow* parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style)
bool TwxToolBar::SetBackgroundColour(const wxColour& colour)
{
const bool ok = TwxToolBarBase::SetBackgroundColour(colour);
if (ok) // Se cambio lo sfondo della toolbar devo aggiornare anche quello del gripper
{
wxAuiDockArt* pArtist = FindArtist(this);
if (pArtist != NULL)
pArtist->SetColor(wxAUI_DOCKART_GRIPPER_COLOUR, colour);
}
return ok;
}
TwxToolBar::TwxToolBar(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: TwxToolBarBase(parent, id, pos, size, style)
{ }

View File

@ -695,18 +695,24 @@ int xvt_print_get_name(const PRINT_RCD* precp, char* name, int sz_s)
wxString n = ((const char*)precp) + 4;
if (n.Length() >= 30)
{
double dBest = 1.0;
wxString strBest = n;
SLIST plist = xvt_print_list_devices();
for (SLIST_ELT pitem = xvt_slist_get_first(plist);
pitem != NULL; pitem = xvt_slist_get_next(plist, pitem))
pitem != NULL; pitem = xvt_slist_get_next(plist, pitem))
{
const wxString pname = xvt_slist_get(plist, pitem, NULL);
if (pname.StartsWith(n))
const double dScore = xvt_str_fuzzy_compare_ignoring_case(n, pname);
if (dScore < dBest)
{
n = pname;
break;
dBest = dScore;
strBest = pname;
if (dScore == 0.0)
break;
}
}
xvt_slist_destroy(plist);
n = strBest;
}
#else
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
@ -717,7 +723,7 @@ int xvt_print_get_name(const PRINT_RCD* precp, char* name, int sz_s)
#endif
if (name != NULL && sz_s > 0)
{
strncpy(name, n, sz_s);
wxStrncpy(name, n, sz_s);
name[sz_s-1] = '\0';
}
return n.Length();

View File

@ -5,8 +5,7 @@
#include "xvtwin.h"
#include <wx/aui/aui.h>
#include <wx/dcbuffer.h>
#include <wx/notebook.h>
//#include <wx/dcbuffer.h>
#include <wx/taskbar.h>
#include <wx/treectrl.h>
#include <wx/vlbox.h>
@ -966,6 +965,8 @@ TwxWindow::~TwxWindow()
_eh = NULL;
_app_data = 0L;
GetTDCMapper().DestroyTDC((WINDOW)this); // Elimina dalla lista dei display context
if (HasCapture())
{
ReleaseMouse();

View File

@ -31,7 +31,7 @@ public:
int Family() const;
void Copy(const wxFont& rFont);
wxFont& Font(wxDC* dc, WINDOW w) const;
const wxFont& Font(wxDC* dc, WINDOW w) const;
TFontId& operator=(const TFontId& f) { Copy(f); return *this; }
bool operator==(const TFontId& f) const { return IsEqual(f); }