]> git.saurik.com Git - wxWidgets.git/blob - src/generic/panelg.cpp
Fix typo in last commit
[wxWidgets.git] / src / generic / panelg.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/panelg.cpp
3 // Purpose: Generic wxPanel implementation.
4 // Author: Vadim Zeitlin
5 // Created: 2011-03-20
6 // RCS-ID: $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #ifndef WX_PRECOMP
27 #include "wx/dc.h"
28 #include "wx/panel.h"
29 #endif // WX_PRECOMP
30
31 #ifdef wxHAS_GENERIC_PANEL
32
33 // ============================================================================
34 // implementation
35 // ============================================================================
36
37 void wxPanel::DoSetBackgroundBitmap(const wxBitmap& bmp)
38 {
39 m_bitmapBg = bmp;
40
41 if ( m_bitmapBg.IsOk() )
42 {
43 Connect(wxEVT_ERASE_BACKGROUND,
44 wxEraseEventHandler(wxPanel::OnEraseBackground));
45 }
46 else
47 {
48 Disconnect(wxEVT_ERASE_BACKGROUND,
49 wxEraseEventHandler(wxPanel::OnEraseBackground));
50 }
51 }
52
53 void wxPanel::OnEraseBackground(wxEraseEvent& event)
54 {
55 wxDC& dc = *event.GetDC();
56
57 const wxSize clientSize = GetClientSize();
58 const wxSize bitmapSize = m_bitmapBg.GetSize();
59
60 for ( int x = 0; x < clientSize.x; x += bitmapSize.x )
61 {
62 for ( int y = 0; y < clientSize.y; y += bitmapSize.y )
63 {
64 dc.DrawBitmap(m_bitmapBg, x, y);
65 }
66 }
67 }
68
69 #endif // wxHAS_GENERIC_PANEL