]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/statbmp.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:           wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  11 #pragma implementation "statbmp.h" 
  18 #include "wx/statbmp.h" 
  23 //----------------------------------------------------------------------------- 
  25 //----------------------------------------------------------------------------- 
  27 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
,wxControl
) 
  29 wxStaticBitmap::wxStaticBitmap(void) 
  33 wxStaticBitmap::wxStaticBitmap( wxWindow 
*parent
, wxWindowID id
, const wxBitmap 
&bitmap
, 
  34       const wxPoint 
&pos
, const wxSize 
&size
, 
  35       long style
, const wxString 
&name 
) 
  37     Create( parent
, id
, bitmap
, pos
, size
, style
, name 
); 
  40 void wxStaticBitmap::CreatePixmapWidget() 
  42     wxCHECK_RET( m_bitmap
.Ok(), wxT("should only be called if we have a bitmap") ); 
  44     GdkBitmap 
*mask 
= (GdkBitmap 
*) NULL
; 
  45     if ( m_bitmap
.GetMask() ) 
  46         mask 
= m_bitmap
.GetMask()->GetBitmap(); 
  47     m_widget 
= gtk_pixmap_new( m_bitmap
.GetPixmap(), mask 
); 
  49     // insert GTK representation 
  50     (*m_parent
->m_insertCallback
)(m_parent
, this); 
  52     gtk_widget_show( m_widget 
); 
  54     m_focusWidget 
= m_widget
; 
  59 bool wxStaticBitmap::Create( wxWindow 
*parent
, wxWindowID id
, const wxBitmap 
&bitmap
, 
  60                              const wxPoint 
&pos
, const wxSize 
&size
, 
  61                              long style
, const wxString 
&name 
) 
  65     if (!PreCreation( parent
, pos
, size 
) || 
  66         !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name 
)) 
  68         wxFAIL_MSG( wxT("wxXX creation failed") ); 
  76         GdkBitmap 
*mask 
= (GdkBitmap 
*) NULL
; 
  77         if ( m_bitmap
.GetMask() ) 
  78             mask 
= m_bitmap
.GetMask()->GetBitmap(); 
  79         m_widget 
= gtk_pixmap_new( m_bitmap
.GetPixmap(), mask 
); 
  85         m_widget 
= gtk_label_new( "Bitmap" ); 
  87         m_focusWidget 
= m_widget
; 
  92     m_parent
->DoAddChild( this ); 
  99 void wxStaticBitmap::SetBitmap( const wxBitmap 
&bitmap 
) 
 101     bool hasWidget 
= m_bitmap
.Ok(); 
 108             gtk_widget_destroy( m_widget 
); 
 110             /* recreate m_widget because we've created a label 
 111                and not a bitmap above */ 
 112             CreatePixmapWidget(); 
 116             GdkBitmap 
*mask 
= (GdkBitmap 
*) NULL
; 
 117             if (m_bitmap
.GetMask()) mask 
= m_bitmap
.GetMask()->GetBitmap(); 
 118             gtk_pixmap_set( GTK_PIXMAP(m_widget
), m_bitmap
.GetPixmap(), mask 
); 
 121         SetBestSize(wxSize(bitmap
.GetWidth(), bitmap
.GetHeight())); 
 125 #endif // wxUSE_STATBMP