1 /* Copyright (C) 2007-2011 The SpringLobby Team. All rights reserved. */
2
3 #include "wxbackgroundimage.h"
4
5 #include <wx/dc.h>
6 #include <wx/window.h>
7 #include <wx/dcbuffer.h>
8 #include <wx/image.h>
9
10 #if 1
11
ProcessEvent(wxEvent & Event)12 bool wxBackgroundBitmap::ProcessEvent(wxEvent &Event)
13 {
14 if(Event.GetEventType() == wxEVT_ERASE_BACKGROUND)
15 {
16 if(Bitmap.IsOk())
17 {
18 }
19 else
20 Event.Skip();
21 }
22 else if(Event.GetEventType() == wxEVT_PAINT)
23 {
24
25 bool TransactionIsOk = false;
26 if(Bitmap.IsOk())
27 {
28 wxWindow * TempWindow = wxDynamicCast(Event.GetEventObject(),wxWindow);
29 if(TempWindow)
30 {
31 wxAutoBufferedPaintDC DC(TempWindow);
32 int w, h;
33 TempWindow->GetClientSize(&w, &h);
34 wxSize current( w,h);
35 if ( current != m_lastSize )
36 {
37 wxImage TempImage = Bitmap.ConvertToImage();
38 TempImage.Rescale(w,h);
39 Bitmap = wxBitmap( TempImage );
40 }
41 DC.DrawBitmap(Bitmap, 0, 0, false);
42 m_lastSize = current;
43 TransactionIsOk = true;
44 }
45 }
46 if(TransactionIsOk == false)
47 Event.Skip();
48 }
49 else if(Event.GetEventType() == wxEVT_SIZE)
50 {
51 wxWindow * TempWindow = wxDynamicCast(Event.GetEventObject(),wxWindow);
52 if(TempWindow)
53 {
54 TempWindow->Refresh();
55 }
56 Event.Skip();
57 }
58 else
59 return wxEvtHandler::ProcessEvent(Event);
60 return true;
61 }
62 #else
ProcessEvent(wxEvent & Event)63 bool wxBackgroundBitmap::ProcessEvent(wxEvent &Event)
64 {
65 if (Event.GetEventType() == wxEVT_ERASE_BACKGROUND) {
66 wxEraseEvent &EraseEvent = dynamic_cast<wxEraseEvent &>(Event);
67 wxDC *DC = EraseEvent.GetDC();
68 DC->DrawBitmap(Bitmap, 0, 0, false);
69 return true;
70 } else return Inherited::ProcessEvent(Event);
71 }
72
73 #endif
74
75