1
// -------------------------------------------------------------------------------- //
2
// Copyright (C) 2008-2010 J.Rios
5
// This Program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2, or (at your option)
10
// This Program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; see the file LICENSE. If not, write to
17
// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
// http://www.gnu.org/copyleft/gpl.html
20
// -------------------------------------------------------------------------------- //
21
#include "ShowImage.h"
25
// -------------------------------------------------------------------------------- //
26
guShowImage::guShowImage( wxWindow * parent, wxImage * image, const wxPoint &pos ) :
27
wxFrame( parent, wxID_ANY, wxEmptyString, pos, wxSize( image->GetWidth(), image->GetHeight() ), wxFRAME_NO_TASKBAR | wxTAB_TRAVERSAL )
29
m_CapturedMouse = false;
31
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
33
wxBoxSizer* MainSizer;
34
MainSizer = new wxBoxSizer( wxVERTICAL );
36
m_Bitmap = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition,
37
wxSize( image->GetWidth(), image->GetHeight() ), 0 );
38
MainSizer->Add( m_Bitmap, 1, wxEXPAND, 5 );
40
this->SetSizer( MainSizer );
45
m_Bitmap->SetBitmap( wxBitmap( image->Copy() ) );
49
Connect( wxEVT_ACTIVATE, wxActivateEventHandler( guShowImage::FrameActivate ) );
50
m_Bitmap->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( guShowImage::OnClick ), NULL, this );
51
m_Bitmap->Connect( wxEVT_MOTION, wxMouseEventHandler( guShowImage::OnMouse ), NULL, this );
52
Connect( wxEVT_MOTION, wxMouseEventHandler( guShowImage::OnMouse ), NULL, this );
53
Connect( wxEVT_MOUSE_CAPTURE_LOST, wxMouseCaptureLostEventHandler( guShowImage::OnCaptureLost ), NULL, this );
57
// -------------------------------------------------------------------------------- //
58
guShowImage::~guShowImage()
64
// -------------------------------------------------------------------------------- //
65
void guShowImage::OnClick( wxMouseEvent &event )
70
// -------------------------------------------------------------------------------- //
71
void guShowImage::OnCaptureLost( wxMouseCaptureLostEvent &event )
76
// -------------------------------------------------------------------------------- //
77
void guShowImage::FrameActivate( wxActivateEvent &event )
79
if( !event.GetActive() )
83
// -------------------------------------------------------------------------------- //
84
void guShowImage::OnMouse( wxMouseEvent &event )
87
wxGetMousePosition( &MouseX, &MouseY );
89
wxRect WinRect = m_Bitmap->GetScreenRect();
90
//guLogMessage( wxT( "Mouse: %i %i %i %i %i %i" ), MouseX, MouseY, WinRect.x, WinRect.y, WinRect.width, WinRect.height );
91
if( !WinRect.Contains( MouseX, MouseY ) )
97
if( !m_CapturedMouse )
99
m_CapturedMouse = true;
106
// -------------------------------------------------------------------------------- //