~ubuntu-branches/ubuntu/precise/guayadeque/precise

« back to all changes in this revision

Viewing changes to src/.svn/text-base/ShowImage.cpp.svn-base

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2011-05-14 15:08:03 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110514150803-8b5evqetnaj35j34
Tags: 0.3.1~dfsg0-1
* New upstream release.
* Strip wxsqlite3 stuff out of upstream's tarballs.
* Update get-orig-source target in debian/rules.
* Update gbp config file.
* Bump Standards.
* Build-depend on libwxsqlite3-2.8-dev
* Enable parallel builds.
* Link binaries against the system-wide copy of wxsqlite3.
* Point sources to the correct wxcurl's headers location.
* Update copyright file as per DEP-5
* Improve debian/watch to handle the ~dfsg\d* suffix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -------------------------------------------------------------------------------- //
2
 
//      Copyright (C) 2008-2010 J.Rios
3
 
//      anonbeat@gmail.com
4
 
//
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)
8
 
//    any later version.
9
 
//
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.
14
 
//
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
19
 
//
20
 
// -------------------------------------------------------------------------------- //
21
 
#include "ShowImage.h"
22
 
 
23
 
#include "Utils.h"
24
 
 
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 )
28
 
{
29
 
    m_CapturedMouse = false;
30
 
 
31
 
        this->SetSizeHints( wxDefaultSize, wxDefaultSize );
32
 
 
33
 
        wxBoxSizer* MainSizer;
34
 
        MainSizer = new wxBoxSizer( wxVERTICAL );
35
 
 
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 );
39
 
 
40
 
        this->SetSizer( MainSizer );
41
 
        this->Layout();
42
 
 
43
 
    if( image )
44
 
    {
45
 
        m_Bitmap->SetBitmap( wxBitmap( image->Copy() ) );
46
 
        delete image;
47
 
    }
48
 
 
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 );
54
 
 
55
 
}
56
 
 
57
 
// -------------------------------------------------------------------------------- //
58
 
guShowImage::~guShowImage()
59
 
{
60
 
    if( m_CapturedMouse )
61
 
        ReleaseMouse();
62
 
}
63
 
 
64
 
// -------------------------------------------------------------------------------- //
65
 
void guShowImage::OnClick( wxMouseEvent &event )
66
 
{
67
 
    Close();
68
 
}
69
 
 
70
 
// -------------------------------------------------------------------------------- //
71
 
void guShowImage::OnCaptureLost( wxMouseCaptureLostEvent &event )
72
 
{
73
 
    Close();
74
 
}
75
 
 
76
 
// -------------------------------------------------------------------------------- //
77
 
void guShowImage::FrameActivate( wxActivateEvent &event )
78
 
{
79
 
    if( !event.GetActive() )
80
 
      Close();
81
 
}
82
 
 
83
 
// -------------------------------------------------------------------------------- //
84
 
void guShowImage::OnMouse( wxMouseEvent &event )
85
 
{
86
 
    int MouseX, MouseY;
87
 
    wxGetMousePosition( &MouseX, &MouseY );
88
 
 
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 ) )
92
 
    {
93
 
        Close();
94
 
    }
95
 
    else
96
 
    {
97
 
        if( !m_CapturedMouse )
98
 
        {
99
 
            m_CapturedMouse = true;
100
 
            CaptureMouse();
101
 
        }
102
 
    }
103
 
    event.Skip();
104
 
}
105
 
 
106
 
// -------------------------------------------------------------------------------- //