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