]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
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__ | |
b698c8e9 | 13 | #pragma implementation "statbmp.h" |
e9576ca5 SC |
14 | #endif |
15 | ||
d8c736e5 GD |
16 | #include "wx/defs.h" |
17 | ||
e9576ca5 | 18 | #include "wx/statbmp.h" |
03e11df5 | 19 | #include "wx/dcclient.h" |
e9576ca5 | 20 | |
2f1ae414 | 21 | #if !USE_SHARED_LIBRARY |
90b959ae | 22 | IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl) |
2f1ae414 | 23 | #endif |
e9576ca5 SC |
24 | |
25 | /* | |
26 | * wxStaticBitmap | |
27 | */ | |
28 | ||
584bede0 | 29 | BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase) |
519cb848 SC |
30 | EVT_PAINT(wxStaticBitmap::OnPaint) |
31 | END_EVENT_TABLE() | |
32 | ||
e9576ca5 SC |
33 | bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, |
34 | const wxBitmap& bitmap, | |
35 | const wxPoint& pos, | |
2f1ae414 | 36 | const wxSize& s, |
e9576ca5 SC |
37 | long style, |
38 | const wxString& name) | |
39 | { | |
e9576ca5 | 40 | SetName(name); |
2f1ae414 | 41 | wxSize size = s ; |
7c551d95 SC |
42 | |
43 | m_backgroundColour = parent->GetBackgroundColour() ; | |
44 | m_foregroundColour = parent->GetForegroundColour() ; | |
45 | ||
584bede0 | 46 | m_bitmap = bitmap; |
e9576ca5 SC |
47 | if ( id == -1 ) |
48 | m_windowId = (int)NewControlId(); | |
49 | else | |
50 | m_windowId = id; | |
51 | ||
52 | m_windowStyle = style; | |
53 | ||
37e2cb08 | 54 | bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name ); |
584bede0 | 55 | SetBestSize( size ) ; |
7c551d95 | 56 | |
519cb848 | 57 | return ret; |
e9576ca5 SC |
58 | } |
59 | ||
60 | void wxStaticBitmap::SetSize(int x, int y, int width, int height, int sizeFlags) | |
61 | { | |
519cb848 | 62 | wxControl::SetSize( x , y , width , height , sizeFlags ) ; |
e9576ca5 SC |
63 | } |
64 | ||
65 | void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap) | |
66 | { | |
584bede0 | 67 | m_bitmap = bitmap; |
2883443e | 68 | Refresh() ; |
584bede0 | 69 | SetBestSize(wxSize(bitmap.GetWidth(), bitmap.GetHeight())); |
519cb848 | 70 | } |
3dec57ad | 71 | |
519cb848 SC |
72 | void wxStaticBitmap::OnPaint( wxPaintEvent &event ) |
73 | { | |
74 | wxPaintDC dc(this); | |
75 | PrepareDC(dc); | |
3dec57ad | 76 | |
584bede0 | 77 | dc.DrawBitmap( m_bitmap , 0 , 0 , TRUE ) ; |
7c551d95 SC |
78 | } |
79 | ||
80 | wxSize wxStaticBitmap::DoGetBestSize() const | |
81 | { | |
584bede0 GD |
82 | if ( m_bitmap.Ok() ) |
83 | return wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight()); | |
3dec57ad SC |
84 | else |
85 | return wxSize(16, 16); // completely arbitrary | |
e9576ca5 SC |
86 | } |
87 |