64 bit compilation fix (pointer can't be cast to int); code simplification (don't duplicate code in GetArm/LabelPixmap)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-09-17 21:54:54 +00:00
parent e6b2a3b383
commit 2263a14efc
2 changed files with 26 additions and 31 deletions

View File

@@ -44,6 +44,8 @@ private:
void InvalidateCache();
void CreateImageIfNeeded( WXWidget w );
WXPixmap GetPixmapFromCache(WXWidget w);
struct
{
bool label : 1;

View File

@@ -42,6 +42,11 @@
Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
static inline wxCharBuffer GetCacheImageName(WXImage image)
{
return wxString::Format(_T("wxBitmap_%p"), image).ToAscii();
}
wxBitmapCache::~wxBitmapCache()
{
if( m_display )
@@ -113,12 +118,26 @@ void wxBitmapCache::CreateImageIfNeeded( WXWidget w )
if( m_image )
{
char tmp[128];
sprintf( tmp, "Im%x", (unsigned int)ximage );
XmInstallImage( ximage, tmp );
XmInstallImage( ximage, GetCacheImageName(m_image).data() );
}
}
WXPixmap wxBitmapCache::GetPixmapFromCache(WXWidget w)
{
Widget widget = (Widget)w;
while( XmIsGadget( widget ) )
widget = XtParent( widget );
Pixel fg, bg;
XtVaGetValues( widget,
XmNbackground, &bg,
XmNforeground, &fg,
NULL );
Screen* screen = DefaultScreenOfDisplay( (Display*)m_display );
return (WXPixmap)XmGetPixmap(screen, GetCacheImageName(m_image).data(), fg, bg);
}
WXPixmap wxBitmapCache::GetLabelPixmap( WXWidget w )
{
if( m_labelPixmap && !m_recalcPixmaps.label )
@@ -134,21 +153,7 @@ WXPixmap wxBitmapCache::GetLabelPixmap( WXWidget w )
if( !m_image )
return (WXPixmap)NULL;
char tmp[128];
sprintf( tmp, "Im%x", (unsigned int)m_image );
Pixel fg, bg;
Widget widget = (Widget)w;
while( XmIsGadget( widget ) )
widget = XtParent( widget );
XtVaGetValues( widget,
XmNbackground, &bg,
XmNforeground, &fg,
NULL );
m_labelPixmap = (WXPixmap)XmGetPixmap( screen, tmp, fg, bg );
m_labelPixmap = GetPixmapFromCache(w);
m_recalcPixmaps.label = !m_labelPixmap;
return m_labelPixmap;
}
@@ -168,19 +173,7 @@ WXPixmap wxBitmapCache::GetArmPixmap( WXWidget w )
if( !m_image )
return (WXPixmap)NULL;
char tmp[128];
sprintf( tmp, "Im%x", (unsigned int)m_image );
Pixel fg, bg;
Widget widget = (Widget) w;
XtVaGetValues( widget, XmNarmColor, &bg, NULL );
while( XmIsGadget( widget ) )
widget = XtParent( widget );
XtVaGetValues( widget, XmNforeground, &fg, NULL );
m_armPixmap = (WXPixmap)XmGetPixmap( screen, tmp, fg, bg );
m_armPixmap = GetPixmapFromCache(w);
m_recalcPixmaps.arm = !m_armPixmap;
return m_armPixmap;
}