]>
Commit | Line | Data |
---|---|---|
2646f485 | 1 | ///////////////////////////////////////////////////////////////////////////// |
18f3decb | 2 | // Name: src/mac/classic/statbmp.cpp |
2646f485 SC |
3 | // Purpose: wxStaticBitmap |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
18f3decb | 9 | // Licence: wxWindows licence |
2646f485 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
18f3decb WS |
12 | #include "wx/wxprec.h" |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
2646f485 SC |
17 | |
18 | #include "wx/statbmp.h" | |
19 | #include "wx/dcclient.h" | |
20 | ||
2646f485 | 21 | IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl) |
2646f485 SC |
22 | |
23 | /* | |
24 | * wxStaticBitmap | |
25 | */ | |
26 | ||
27 | BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase) | |
28 | EVT_PAINT(wxStaticBitmap::OnPaint) | |
29 | END_EVENT_TABLE() | |
30 | ||
31 | bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, | |
32 | const wxBitmap& bitmap, | |
33 | const wxPoint& pos, | |
34 | const wxSize& s, | |
35 | long style, | |
36 | const wxString& name) | |
37 | { | |
38 | SetName(name); | |
39 | wxSize size = s ; | |
40 | if ( bitmap.Ok() ) | |
41 | { | |
42 | if ( size.x == -1 ) | |
43 | size.x = bitmap.GetWidth() ; | |
44 | if ( size.y == -1 ) | |
45 | size.y = bitmap.GetHeight() ; | |
46 | } | |
47 | ||
48 | m_backgroundColour = parent->GetBackgroundColour() ; | |
49 | m_foregroundColour = parent->GetForegroundColour() ; | |
50 | ||
51 | m_bitmap = bitmap; | |
52 | if ( id == -1 ) | |
53 | m_windowId = (int)NewControlId(); | |
54 | else | |
55 | m_windowId = id; | |
56 | ||
57 | m_windowStyle = style; | |
58 | ||
59 | bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name ); | |
60 | SetBestSize( size ) ; | |
18f3decb | 61 | |
2646f485 SC |
62 | return ret; |
63 | } | |
64 | ||
65 | void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap) | |
66 | { | |
67 | m_bitmap = bitmap; | |
9f884528 | 68 | InvalidateBestSize(); |
2646f485 SC |
69 | SetSize(wxSize(bitmap.GetWidth(), bitmap.GetHeight())); |
70 | Refresh() ; | |
71 | } | |
72 | ||
18f3decb | 73 | void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) ) |
2646f485 SC |
74 | { |
75 | wxPaintDC dc(this); | |
76 | PrepareDC(dc); | |
77 | ||
18f3decb | 78 | dc.DrawBitmap( m_bitmap , 0 , 0 , true ) ; |
2646f485 SC |
79 | } |
80 | ||
81 | wxSize wxStaticBitmap::DoGetBestSize() const | |
82 | { | |
83 | return wxWindow::DoGetBestSize() ; | |
84 | } |