2 /// \file Mode_MainMenu.cc
3 /// Mode derived class for the main menu buttons
7 Copyright (C) 2009-2012, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include "Mode_MainMenu.h"
23 #include "BaseButtons.h"
24 #include "barrydesktop.h"
25 #include <barry/barry.h>
27 //////////////////////////////////////////////////////////////////////////////
30 MainMenuMode::MainMenuMode(wxWindow
*parent
)
31 : m_basebuttons( new BaseButtons(parent
) )
35 MainMenuMode::~MainMenuMode()
39 void MainMenuMode::UpdateScreenshot(const Barry::Pin
&pin
)
41 // clear existing screenshot
42 m_screenshot
= wxBitmap();
44 // fetch the new device's screenshot
47 int index
= Barry::Probe::FindActive(wxGetApp().GetResults(), pin
);
50 m_screenshot
= wxGetApp().GetScreenshot(wxGetApp().GetResults()[index
]);
54 catch( Barry::Error
&be
) {
55 // don't worry if we can't get a screenshot... not all
57 barryverbose("Ignorable screenshot exception: " << be
.what());
61 void MainMenuMode::OnPaint(wxDC
&dc
)
63 static bool init
= false;
67 m_basebuttons
->InitAll(dc
);
70 m_basebuttons
->DrawAll(dc
);
72 // paint the screenshot if available
73 if( m_screenshot
.IsOk() ) {
74 dc
.DrawBitmap(m_screenshot
, 410, 290);
78 void MainMenuMode::OnMouseMotion(wxDC
&dc
, int x
, int y
)
80 m_basebuttons
->HandleMotion(dc
, x
, y
);
83 void MainMenuMode::OnLeftDown(wxDC
&dc
, int x
, int y
)
85 m_basebuttons
->HandleDown(dc
, x
, y
);
88 void MainMenuMode::OnLeftUp(wxDC
&dc
, int x
, int y
)
90 m_basebuttons
->HandleUp(dc
, x
, y
);