]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: statbmp.cpp | |
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 |
65571936 | 9 | // Licence: wxWindows licence |
e9576ca5 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
3d1a4878 | 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
b698c8e9 | 13 | #pragma implementation "statbmp.h" |
e9576ca5 SC |
14 | #endif |
15 | ||
3d1a4878 | 16 | #include "wx/wxprec.h" |
d8c736e5 | 17 | |
179e085f RN |
18 | #if wxUSE_STATBMP |
19 | ||
e9576ca5 | 20 | #include "wx/statbmp.h" |
03e11df5 | 21 | #include "wx/dcclient.h" |
e9576ca5 | 22 | |
2f1ae414 | 23 | #if !USE_SHARED_LIBRARY |
90b959ae | 24 | IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl) |
2f1ae414 | 25 | #endif |
e9576ca5 SC |
26 | |
27 | /* | |
28 | * wxStaticBitmap | |
29 | */ | |
30 | ||
584bede0 | 31 | BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase) |
519cb848 SC |
32 | EVT_PAINT(wxStaticBitmap::OnPaint) |
33 | END_EVENT_TABLE() | |
34 | ||
e9576ca5 SC |
35 | bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, |
36 | const wxBitmap& bitmap, | |
37 | const wxPoint& pos, | |
982a831b | 38 | const wxSize& size, |
e9576ca5 SC |
39 | long style, |
40 | const wxString& name) | |
41 | { | |
e9576ca5 | 42 | SetName(name); |
7c551d95 SC |
43 | |
44 | m_backgroundColour = parent->GetBackgroundColour() ; | |
45 | m_foregroundColour = parent->GetForegroundColour() ; | |
46 | ||
584bede0 | 47 | m_bitmap = bitmap; |
e9576ca5 | 48 | if ( id == -1 ) |
e40298d5 | 49 | m_windowId = (int)NewControlId(); |
e9576ca5 | 50 | else |
e40298d5 | 51 | m_windowId = id; |
e9576ca5 SC |
52 | |
53 | m_windowStyle = style; | |
54 | ||
37e2cb08 | 55 | bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name ); |
e40298d5 | 56 | SetBestSize( size ) ; |
7c551d95 | 57 | |
519cb848 | 58 | return ret; |
e9576ca5 SC |
59 | } |
60 | ||
e9576ca5 SC |
61 | void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap) |
62 | { | |
584bede0 | 63 | m_bitmap = bitmap; |
9f884528 | 64 | InvalidateBestSize(); |
982a831b | 65 | SetSize(GetBestSize()); |
2883443e | 66 | Refresh() ; |
519cb848 | 67 | } |
3dec57ad | 68 | |
eb22f2a6 | 69 | void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) ) |
519cb848 SC |
70 | { |
71 | wxPaintDC dc(this); | |
72 | PrepareDC(dc); | |
3dec57ad | 73 | |
584bede0 | 74 | dc.DrawBitmap( m_bitmap , 0 , 0 , TRUE ) ; |
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 | |
83 | return DoGetSizeFromClientSize( wxSize(16, 16) ); | |
e9576ca5 SC |
84 | } |
85 | ||
179e085f RN |
86 | #endif |
87 |