Bumped copyright dates for 2013
[barry.git] / desktop / src / Mode_MainMenu.cc
blob283dd17ddf24e6bff42e0cbbcc414b2e4d339759
1 ///
2 /// \file Mode_MainMenu.cc
3 /// Mode derived class for the main menu buttons
4 ///
6 /*
7 Copyright (C) 2009-2013, 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 //////////////////////////////////////////////////////////////////////////////
28 // MainMenuMode
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
45 try {
46 if( pin.Valid() ) {
47 int index = Barry::Probe::FindActive(wxGetApp().GetResults(), pin);
48 if( index != -1 ) {
49 wxBusyCursor wait;
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
56 // devices support it
57 barryverbose(_C("Ignorable screenshot exception: ") << be.what());
61 void MainMenuMode::OnPaint(wxDC &dc)
63 static bool init = false;
65 // paint the buttons
66 if( !init ) {
67 m_basebuttons->InitAll(dc);
68 init = true;
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);