]>
Commit | Line | Data |
---|---|---|
489468fe | 1 | ///////////////////////////////////////////////////////////////////////////// |
524c47aa | 2 | // Name: src/osx/carbon/statbmp.cpp |
489468fe SC |
3 | // Purpose: wxStaticBitmap |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
489468fe SC |
7 | // Copyright: (c) Stefan Csomor |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #if wxUSE_STATBMP | |
14 | ||
15 | #include "wx/statbmp.h" | |
16 | ||
17 | #ifndef WX_PRECOMP | |
18 | #include "wx/dcclient.h" | |
19 | #endif | |
20 | ||
489468fe SC |
21 | /* |
22 | * wxStaticBitmap | |
23 | */ | |
24 | ||
25 | BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase) | |
26 | EVT_PAINT(wxStaticBitmap::OnPaint) | |
27 | END_EVENT_TABLE() | |
28 | ||
29 | bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, | |
30 | const wxBitmap& bitmap, | |
31 | const wxPoint& pos, | |
32 | const wxSize& size, | |
33 | long style, | |
34 | const wxString& name) | |
35 | { | |
36 | SetName(name); | |
37 | ||
38 | m_backgroundColour = parent->GetBackgroundColour() ; | |
39 | m_foregroundColour = parent->GetForegroundColour() ; | |
40 | ||
41 | m_bitmap = bitmap; | |
42 | if ( id == wxID_ANY ) | |
43 | m_windowId = (int)NewControlId(); | |
44 | else | |
45 | m_windowId = id; | |
46 | ||
47 | m_windowStyle = style; | |
48 | ||
49 | bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name ); | |
50 | SetInitialSize( size ) ; | |
51 | ||
52 | return ret; | |
53 | } | |
54 | ||
55 | void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap) | |
56 | { | |
57 | m_bitmap = bitmap; | |
58 | InvalidateBestSize(); | |
59 | SetSize(GetBestSize()); | |
60 | Refresh() ; | |
61 | } | |
62 | ||
63 | void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) ) | |
64 | { | |
65 | wxPaintDC dc(this); | |
66 | PrepareDC(dc); | |
67 | ||
a1b806b9 | 68 | if (m_bitmap.IsOk()) |
489468fe SC |
69 | { |
70 | dc.DrawBitmap( m_bitmap , 0 , 0 , TRUE ) ; | |
71 | } | |
72 | } | |
73 | ||
74 | wxSize wxStaticBitmap::DoGetBestSize() const | |
75 | { | |
a1b806b9 | 76 | if ( m_bitmap.IsOk() ) |
489468fe SC |
77 | return DoGetSizeFromClientSize( wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight()) ); |
78 | ||
79 | // this is completely arbitrary | |
80 | return DoGetSizeFromClientSize( wxSize(16, 16) ); | |
81 | } | |
82 | ||
83 | #endif |