]> git.saurik.com Git - wxWidgets.git/blob - src/mac/statbmp.cpp
mac changes : wxDC - removed doubly defined vars (inherited from base) and fixed...
[wxWidgets.git] / src / mac / statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: statbmp.cpp
3 // Purpose: wxStaticBitmap
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "statbmp.h"
14 #endif
15
16 #include "wx/statbmp.h"
17 #include "wx/dcclient.h"
18
19 #if !USE_SHARED_LIBRARY
20 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
21 #endif
22
23 /*
24 * wxStaticBitmap
25 */
26
27 BEGIN_EVENT_TABLE(wxStaticBitmap, wxControl)
28 EVT_PAINT(wxStaticBitmap::OnPaint)
29 END_EVENT_TABLE()
30
31 bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
32 const wxBitmap& bitmap,
33 const wxPoint& pos,
34 const wxSize& s,
35 long style,
36 const wxString& name)
37 {
38 SetName(name);
39 wxSize size = s ;
40
41 m_backgroundColour = parent->GetBackgroundColour() ;
42 m_foregroundColour = parent->GetForegroundColour() ;
43
44 m_messageBitmap = bitmap;
45
46 if ( id == -1 )
47 m_windowId = (int)NewControlId();
48 else
49 m_windowId = id;
50
51 m_windowStyle = style;
52
53 bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
54 SetSizeOrDefault( size ) ;
55
56 return ret;
57 }
58
59 void wxStaticBitmap::SetSize(int x, int y, int width, int height, int sizeFlags)
60 {
61 wxControl::SetSize( x , y , width , height , sizeFlags ) ;
62 }
63
64 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
65 {
66 m_messageBitmap = bitmap;
67 SetSizeOrDefault();
68 }
69 void wxStaticBitmap::OnPaint( wxPaintEvent &event )
70 {
71 wxPaintDC dc(this);
72 PrepareDC(dc);
73 dc.SetPalette( *m_messageBitmap.GetPalette() ) ;
74 dc.DrawBitmap( m_messageBitmap , 0 , 0 ) ;
75 }
76
77 wxSize wxStaticBitmap::DoGetBestSize() const
78 {
79 if ( m_messageBitmap.Ok() )
80 return wxSize(m_messageBitmap.GetWidth(), m_messageBitmap.GetHeight());
81 else
82 return wxSize(16, 16); // completely arbitrary
83 }
84