]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/statbmp.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/motif/statbmp.cpp 
   3 // Purpose:     wxStaticBitmap 
   4 // Author:      Julian Smart 
   8 // Copyright:   (c) Julian Smart 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // For compilers that support precompilation, includes "wx.h". 
  13 #include "wx/wxprec.h" 
  15 #include "wx/statbmp.h" 
  18 #pragma message disable nosimpint 
  22 #include <Xm/LabelG.h> 
  24 #pragma message enable nosimpint 
  27 #include "wx/motif/private.h" 
  29 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
, wxControl
) 
  35 bool wxStaticBitmap::Create(wxWindow 
*parent
, wxWindowID id
, 
  36            const wxBitmap
& bitmap
, 
  42     if( !CreateControl( parent
, id
, pos
, size
, style
, wxDefaultValidator
, 
  46     m_messageBitmap 
= bitmap
; 
  47     m_messageBitmapOriginal 
= bitmap
; 
  49     Widget parentWidget 
= (Widget
) parent
->GetClientWidget(); 
  51     m_mainWidget 
= (WXWidget
) XtVaCreateManagedWidget ("staticBitmap", 
  53                     xmLabelGadgetClass
, parentWidget
, 
  55                     xmLabelWidgetClass
, parentWidget
, 
  57                     XmNalignment
, XmALIGNMENT_BEGINNING
, 
  60     ChangeBackgroundColour (); 
  66     wxSize 
actualSize(size
); 
  67     // work around the cases where the bitmap is a wxNull(Icon/Bitmap) 
  68     if (actualSize
.x 
== -1) 
  69         actualSize
.x 
= bitmap
.Ok() ? bitmap
.GetWidth() : 1; 
  70     if (actualSize
.y 
== -1) 
  71         actualSize
.y 
= bitmap
.Ok() ? bitmap
.GetHeight() : 1; 
  72     AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
, 
  73                   pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
); 
  78 wxStaticBitmap::~wxStaticBitmap() 
  80     SetBitmap(wxNullBitmap
); 
  83 void wxStaticBitmap::DoSetBitmap() 
  85     Widget widget 
= (Widget
) m_mainWidget
; 
  88     if (m_messageBitmapOriginal
.Ok()) 
  90         w2 
= m_messageBitmapOriginal
.GetWidth(); 
  91         h2 
= m_messageBitmapOriginal
.GetHeight(); 
  95         // Must re-make the bitmap to have its transparent areas drawn 
  96         // in the current widget background colour. 
  97         if (m_messageBitmapOriginal
.GetMask()) 
 100             XtVaGetValues( widget
, XmNbackground
, &backgroundPixel
, 
 104             col
.SetPixel(backgroundPixel
); 
 106             wxBitmap newBitmap 
= wxCreateMaskedBitmap(m_messageBitmapOriginal
, col
); 
 107             m_messageBitmap 
= newBitmap
; 
 109             pixmap 
= (Pixmap
) m_messageBitmap
.GetDrawable(); 
 113             m_bitmapCache
.SetBitmap( m_messageBitmap 
); 
 114             pixmap 
= (Pixmap
)m_bitmapCache
.GetLabelPixmap(widget
); 
 117         XtVaSetValues (widget
, 
 118             XmNlabelPixmap
, pixmap
, 
 119             XmNlabelType
, XmPIXMAP
, 
 126         // Null bitmap: must not use current pixmap 
 127         // since it is no longer valid. 
 128         XtVaSetValues (widget
, 
 129             XmNlabelType
, XmSTRING
, 
 130             XmNlabelPixmap
, XmUNSPECIFIED_PIXMAP
, 
 135 void wxStaticBitmap::SetBitmap(const wxBitmap
& bitmap
) 
 137     m_messageBitmap 
= bitmap
; 
 138     m_messageBitmapOriginal 
= bitmap
; 
 143 void wxStaticBitmap::ChangeBackgroundColour() 
 145     wxWindow::ChangeBackgroundColour(); 
 147     // must recalculate the background colour 
 148     m_bitmapCache
.SetColoursChanged(); 
 152 void wxStaticBitmap::ChangeForegroundColour() 
 154     m_bitmapCache
.SetColoursChanged(); 
 155     wxWindow::ChangeForegroundColour();