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