Patch level : 2.1 nopatch

Files correlati     : xvaga.dll
Ricompilazione Demo : [ ]
Commento            :

Risolti conflitti vari e migliorata gestione dei font e dei Display Context


git-svn-id: svn://10.65.10.50/trunk@11863 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2004-03-15 15:44:18 +00:00
parent baf2659f8f
commit 3b42ecfc52

View File

@ -31,8 +31,8 @@ extern "C" {
#define CAST_WIN(win,w) XVT_ASSERT(win != NULL_WIN); wxWindow& w = *(wxWindow*)win #define CAST_WIN(win,w) XVT_ASSERT(win != NULL_WIN); wxWindow& w = *(wxWindow*)win
#define CAST_TWIN(win,w) XVT_ASSERT(win != NULL_WIN); TwxWindow& w = *(TwxWindow*)win; XVT_ASSERT(_task_win != &w); #define CAST_TWIN(win,w) XVT_ASSERT(win != NULL_WIN); TwxWindow& w = *(TwxWindow*)win; XVT_ASSERT(_task_win != &w);
#define CAST_TDC(win,dc) XVT_ASSERT(win != NULL_WIN); TDC& dc = _dc_map.GetTDC((TwxWindow*)win); #define CAST_TDC(win,dc) XVT_ASSERT(win != NULL_WIN); TDC& dc = GetTDCMapper().GetTDC(win);
#define CAST_DC(win,dc) XVT_ASSERT(win != NULL_WIN); wxDC& dc = _dc_map.GetDC((TwxWindow*)win); #define CAST_DC(win,dc) XVT_ASSERT(win != NULL_WIN); wxDC& dc = GetTDCMapper().GetDC(win);
// Funzione interna di utilita' // Funzione interna di utilita'
MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m); MENU_ITEM* xvt_menu_duplicate_tree(const MENU_ITEM* m);
@ -490,24 +490,33 @@ bool TDC::GetClippingBox(RCT* pRct) const
return _clip.right > _clip.left; return _clip.right > _clip.left;
} }
WX_DECLARE_HASH_MAP(wxWindow*, TDC*, wxPointerHash, wxPointerEqual, wxTDCHashMap); WX_DECLARE_HASH_MAP(WINDOW, TDC*, wxIntegerHash, wxIntegerEqual, wxTDCHashMap);
class TDCMapper : public wxTDCHashMap class TDCMapper : public wxTDCHashMap
{ {
wxWindow* _pLastOwner; WINDOW _pLastOwner;
TDC* _pLastTDC; TDC* _pLastTDC;
public: public:
TDC& GetTDC(wxWindow* owner); TDC& GetTDC(WINDOW owner);
wxDC& GetDC(wxWindow* owner, bool bPaint = false) { return GetTDC(owner).GetDC(bPaint); } wxDC& GetDC(WINDOW owner, bool bPaint = false) { return GetTDC(owner).GetDC(bPaint); }
void DestroyDC(wxWindow* owner); void DestroyDC(WINDOW owner);
void DestroyTDC(wxWindow* owner); void DestroyTDC(WINDOW owner);
bool HasValidDC(WINDOW owner) const; bool HasValidDC(WINDOW owner) const;
TDCMapper() : _pLastOwner(NULL), _pLastTDC(NULL) { } TDCMapper() : _pLastOwner(NULL_WIN), _pLastTDC(NULL) { }
} _dc_map; virtual ~TDCMapper() { DestroyTDC(NULL_WIN); }
};
void TDCMapper::DestroyDC(wxWindow* owner) TDCMapper& GetTDCMapper()
{
static TDCMapper* _dc_map = NULL;
if (_dc_map == NULL)
_dc_map = new TDCMapper;
return *_dc_map;
}
void TDCMapper::DestroyDC(WINDOW owner)
{ {
if (owner) if (owner)
{ {
@ -516,21 +525,29 @@ void TDCMapper::DestroyDC(wxWindow* owner)
pTDC->KillDC(); pTDC->KillDC();
} }
else else
clear(); {
TDCMapper::iterator it;
for (it = begin(); it != end(); ++it)
{
TDC* pTDC = it->second;
if (pTDC)
pTDC->KillDC();
}
}
} }
void TDCMapper::DestroyTDC(wxWindow* owner) void TDCMapper::DestroyTDC(WINDOW owner)
{ {
if (owner) if (owner != NULL_WIN)
{ {
TDC* pTDC = (*this)[owner]; TDC* pTDC = (*this)[owner];
if (pTDC) if (pTDC)
delete pTDC; delete pTDC;
erase(owner);
} }
else else
{ {
TDCMapper::iterator it; TDCMapper::iterator it;
for (it = begin(); it != end(); ++it) for (it = begin(); it != end(); ++it)
{ {
TDC* pTDC = it->second; TDC* pTDC = it->second;
@ -539,10 +556,10 @@ void TDCMapper::DestroyTDC(wxWindow* owner)
} }
clear(); clear();
} }
_pLastOwner = NULL; _pLastOwner = NULL_WIN;
} }
TDC& TDCMapper::GetTDC(wxWindow* owner) TDC& TDCMapper::GetTDC(WINDOW owner)
{ {
if (owner == _pLastOwner) if (owner == _pLastOwner)
return *_pLastTDC; return *_pLastTDC;
@ -550,10 +567,10 @@ TDC& TDCMapper::GetTDC(wxWindow* owner)
TDC* pTDC = (*this)[owner]; TDC* pTDC = (*this)[owner];
if (pTDC == NULL) if (pTDC == NULL)
{ {
if (owner == (wxWindow*)_print_win) if (owner == _print_win)
pTDC = new TPrintDC(owner); pTDC = new TPrintDC((wxWindow*)owner);
else else
pTDC = new TDC(owner); pTDC = new TDC((wxWindow*)owner);
(*this)[owner] = pTDC; (*this)[owner] = pTDC;
} }
_pLastOwner = owner; _pLastOwner = owner;
@ -569,8 +586,7 @@ bool TDCMapper::HasValidDC(WINDOW owner) const
if (owner == (WINDOW)_pLastOwner) if (owner == (WINDOW)_pLastOwner)
return true; return true;
CAST_WIN(owner, w); TDC* pTDC = (*((TDCMapper *) this))[owner];
TDC* pTDC = (*((TDCMapper *) this))[&w];
return pTDC != NULL; return pTDC != NULL;
} }
@ -900,11 +916,11 @@ void TwxWindow::OnPaint(wxPaintEvent& event)
rct.right = rctDamaged.GetRight()+1; rct.right = rctDamaged.GetRight()+1;
rct.bottom = rctDamaged.GetBottom()+1; rct.bottom = rctDamaged.GetBottom()+1;
TDC& tdc = _dc_map.GetTDC(this); TDC& tdc = GetTDCMapper().GetTDC((WINDOW)this);
tdc.GetDC(true); // Forza la creazione di un wxPaintDC tdc.GetDC(true); // Forza la creazione di un wxPaintDC
DoXvtEvent(e); DoXvtEvent(e);
tdc.KillDC(); // Distrugge il wxPaintDC tdc.KillDC(); // Distrugge il wxPaintDC
_dc_map.DestroyDC(NULL); // Distrugge davvero tutti i wxClientDC residui (risolve molte "porcate" del video) GetTDCMapper().DestroyDC(NULL_WIN); // Distrugge davvero tutti i wxClientDC residui (risolve molte "porcate" del video)
} }
static SCROLL_CONTROL ConvertScrollToXVT(wxEventType et) static SCROLL_CONTROL ConvertScrollToXVT(wxEventType et)
@ -1073,7 +1089,7 @@ void TTaskWin::OnPaint()
rct.right = rctDamaged.GetRight()+1; rct.right = rctDamaged.GetRight()+1;
rct.bottom = rctDamaged.GetBottom()+1; rct.bottom = rctDamaged.GetBottom()+1;
TDC& dc = _dc_map.GetTDC(this); TDC& dc = GetTDCMapper().GetTDC((WINDOW)this);
dc.GetDC(true); // Forza la creazione di un wxPaintDC dc.GetDC(true); // Forza la creazione di un wxPaintDC
_task_win_handler((WINDOW)this, &e); _task_win_handler((WINDOW)this, &e);
dc.KillDC(); dc.KillDC();
@ -2180,21 +2196,6 @@ void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len)
{ {
if (s && *s && len != 0) if (s && *s && len != 0)
{ {
/*
CAST_DC(win, dc);
wxRect rct; dc.GetClippingBox(rct);
const int maxx = rct.GetRight();
if (maxx <= 0 || x < maxx)
{
wxString str(s);
if (len >= 0)
str.Truncate(len);
int height, desc, lead;
dc.GetTextExtent(str, NULL, &height, &desc, &lead);
y -= height-desc; // Triste necessita'!
dc.DrawText(str, x, y);
}
*/
CAST_TDC(win, tdc); CAST_TDC(win, tdc);
RCT rct; RCT rct;
const bool noclip = !tdc.GetClippingBox(&rct); const bool noclip = !tdc.GetClippingBox(&rct);
@ -4128,7 +4129,7 @@ void xvt_vobj_destroy(WINDOW win)
if (_nice_windows.Get(win) != NULL) if (_nice_windows.Get(win) != NULL)
{ {
CAST_TWIN(win, w); CAST_TWIN(win, w);
_dc_map.DestroyTDC(&w); GetTDCMapper().DestroyTDC(win);
w.Close(true); w.Close(true);
} }
#ifdef DBG #ifdef DBG