]> git.saurik.com Git - wxWidgets.git/blob - tests/testableframe.cpp
Fix horizontal mouse wheel scrolling in wxGTK.
[wxWidgets.git] / tests / testableframe.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: testableframe.cpp
3 // Purpose: An improved wxFrame for unit-testing
4 // Author: Steven Lamerton
5 // Copyright: (c) 2010 Steven Lamerton
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
8
9 // For compilers that support precompilation, includes "wx/wx.h".
10 #include "testprec.h"
11
12 #ifdef __BORLANDC__
13 #pragma hdrstop
14 #endif
15
16 #include "wx/app.h"
17 #include "testableframe.h"
18
19 wxTestableFrame::wxTestableFrame() : wxFrame(NULL, wxID_ANY, "Test Frame")
20 {
21 }
22
23 void wxTestableFrame::OnEvent(wxEvent& evt)
24 {
25 m_count[evt.GetEventType()]++;
26
27 if(! evt.IsCommandEvent() )
28 evt.Skip();
29 }
30
31 int wxTestableFrame::GetEventCount(wxEventType type)
32 {
33 return m_count[type];
34 }
35
36 void wxTestableFrame::ClearEventCount(wxEventType type)
37 {
38 m_count[type] = 0;
39 }
40
41 EventCounter::EventCounter(wxWindow* win, wxEventType type) : m_type(type),
42 m_win(win)
43
44 {
45 m_frame = wxStaticCast(wxTheApp->GetTopWindow(), wxTestableFrame);
46
47 m_win->Connect(m_type, wxEventHandler(wxTestableFrame::OnEvent),
48 NULL, m_frame);
49 }
50
51 EventCounter::~EventCounter()
52 {
53 m_win->Disconnect(m_type, wxEventHandler(wxTestableFrame::OnEvent),
54 NULL, m_frame);
55
56 //This stops spurious counts from previous tests
57 Clear();
58
59 m_frame = NULL;
60 m_win = NULL;
61 }