]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/bmpmotif.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart, originally in bitmap.cpp
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "bmpmotif.h"
17 #define XtParent XTPARENT
21 #include "wx/motif/bmpmotif.h"
24 #pragma message disable nosimpint
28 #pragma message enable nosimpint
31 #include "wx/motif/private.h"
38 Pixmap
XCreateInsensitivePixmap( Display
*display
, Pixmap pixmap
);
40 wxBitmapCache::~wxBitmapCache()
44 Screen
* screen
= DefaultScreenOfDisplay( (Display
*)m_display
);
47 XmDestroyPixmap( screen
, (Pixmap
)m_labelPixmap
);
50 XmDestroyPixmap( screen
, (Pixmap
)m_armPixmap
);
53 XmDestroyPixmap( screen
, (Pixmap
)m_insensPixmap
);
59 XmUninstallImage( (XImage
*)m_image
);
60 XtFree( (char*)(XImage
*)m_image
);
64 void wxBitmapCache::SetBitmap( const wxBitmap
& bitmap
)
66 if( m_bitmap
!= bitmap
)
73 XmUninstallImage( (XImage
*)m_image
);
74 XtFree( (char*)(XImage
*)m_image
);
75 m_image
= (WXImage
*)NULL
;
80 void wxBitmapCache::InvalidateCache()
82 m_recalcPixmaps
.label
= true;
83 m_recalcPixmaps
.arm
= true;
84 m_recalcPixmaps
.insens
= true;
87 void wxBitmapCache::SetColoursChanged()
92 void wxBitmapCache::CreateImageIfNeeded( WXWidget w
)
98 (WXDisplay
*)XtDisplay( (Widget
)w
) :
99 (WXDisplay
*)wxGetDisplay();
101 XImage
*ximage
= XGetImage( (Display
*)m_display
,
102 (Drawable
)m_bitmap
.GetPixmap(),
104 m_bitmap
.GetWidth(), m_bitmap
.GetHeight(),
105 AllPlanes
, ZPixmap
);
107 m_image
= (WXImage
*)ximage
;
112 sprintf( tmp
, "Im%x", (unsigned int)ximage
);
113 XmInstallImage( ximage
, tmp
);
117 WXPixmap
wxBitmapCache::GetLabelPixmap( WXWidget w
)
119 if( m_labelPixmap
&& !m_recalcPixmaps
.label
)
120 return m_labelPixmap
;
122 CreateImageIfNeeded( w
);
124 Screen
* screen
= DefaultScreenOfDisplay( (Display
*)m_display
);
127 XmDestroyPixmap( screen
, (Pixmap
)m_labelPixmap
);
130 return (WXPixmap
)NULL
;
133 sprintf( tmp
, "Im%x", (unsigned int)m_image
);
136 Widget widget
= (Widget
)w
;
138 while( XmIsGadget( widget
) )
139 widget
= XtParent( widget
);
140 XtVaGetValues( widget
,
145 m_labelPixmap
= (WXPixmap
)XmGetPixmap( screen
, tmp
, fg
, bg
);
147 m_recalcPixmaps
.label
= !m_labelPixmap
;
148 return m_labelPixmap
;
151 WXPixmap
wxBitmapCache::GetArmPixmap( WXWidget w
)
153 if( m_armPixmap
&& !m_recalcPixmaps
.arm
)
156 CreateImageIfNeeded( w
);
158 Screen
* screen
= DefaultScreenOfDisplay( (Display
*)m_display
);
161 XmDestroyPixmap( screen
, (Pixmap
)m_armPixmap
);
164 return (WXPixmap
)NULL
;
167 sprintf( tmp
, "Im%x", (unsigned int)m_image
);
170 Widget widget
= (Widget
) w
;
172 XtVaGetValues( widget
, XmNarmColor
, &bg
, NULL
);
173 while( XmIsGadget( widget
) )
174 widget
= XtParent( widget
);
175 XtVaGetValues( widget
, XmNforeground
, &fg
, NULL
);
177 m_armPixmap
= (WXPixmap
)XmGetPixmap( screen
, tmp
, fg
, bg
);
179 m_recalcPixmaps
.arm
= !m_armPixmap
;
183 WXPixmap
wxBitmapCache::GetInsensPixmap( WXWidget w
)
185 if( m_insensPixmap
&& !m_recalcPixmaps
.insens
)
186 return m_insensPixmap
;
188 CreateImageIfNeeded( w
);
190 Screen
* screen
= DefaultScreenOfDisplay( (Display
*)m_display
);
193 XmDestroyPixmap( screen
, (Pixmap
)m_insensPixmap
);
196 return (WXPixmap
)NULL
;
199 (WXPixmap
)XCreateInsensitivePixmap( (Display
*)m_display
,
200 (Pixmap
)m_bitmap
.GetPixmap() );
202 m_recalcPixmaps
.insens
= !m_insensPixmap
;
203 return m_insensPixmap
;