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