source: eviacam/trunk/fuentes/src/clickwindow.cpp @ 567

Last change on this file since 567 was 567, checked in by mabarracus, 4 years ago

updated sources to version 2.0.3

File size: 8.4 KB
Line 
1/////////////////////////////////////////////////////////////////////////////
2// Name:        clickwindow.cpp
3// Purpose: 
4// Author:      Cesar Mauri Loba (cesar at crea-si dot com)
5// Modified by:
6// Created:     
7// Copyright:   (C) 2008-09 Cesar Mauri Loba - CREA Software Systems
8//
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 3 of the License, or
12//  (at your option) any later version.
13//
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.  See the
17//  GNU General Public License for more details.
18//
19//  You should have received a copy of the GNU General Public License
20//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21/////////////////////////////////////////////////////////////////////////////
22
23// For compilers that support precompilation, includes "wx/wx.h".
24#include "wx/wxprec.h"
25
26#ifdef __BORLANDC__
27#pragma hdrstop
28#endif
29
30#ifndef WX_PRECOMP
31#include "wx/wx.h"
32#endif
33
34#include "wxappbar.h"
35#include "clickwindow.h"
36#include "clickwindowcontroller.h"
37
38/*!
39 * CClickWindow type definition
40 */
41
42//IMPLEMENT_DYNAMIC_CLASS( CClickWindow, WXAppBar )
43
44
45/*!
46 * CClickWindow event table definition
47 */
48
49BEGIN_EVENT_TABLE( CClickWindow, WXAppBar )
50
51        EVT_CLOSE( CClickWindow::OnCloseWindow )
52
53END_EVENT_TABLE()
54
55/*!
56 * CClickWindow constructors
57 */
58
59CClickWindow::CClickWindow()
60{
61    Init();
62}
63
64CClickWindow::CClickWindow( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
65{
66        Init();
67        Create(parent, id, caption, pos, size, style);
68}
69
70
71/*!
72 * CClickWindow creator
73 */
74
75bool CClickWindow::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
76{
77        SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
78        bool retval= WXAppBar::Create( parent, id, caption, pos, size, style );
79        //SetSticky(true);
80        SetEntryInTaskBar (false);
81        SetEntryInPager (false);
82        SetAcceptFocus (false);
83        return retval;
84}
85
86
87/*!
88 * CClickWindow destructor
89 */
90
91CClickWindow::~CClickWindow()
92{
93}
94
95
96/*!
97 * Member initialisation
98 */
99
100void CClickWindow::Init()
101{
102        m_pController= NULL;
103}
104
105
106/*!
107 * Control creation for CClickWindow
108 */
109
110void CClickWindow::ConnectEvents()
111{ 
112    GetNoClickButton()->Connect(GetNoClickButton()->GetId(), wxEVT_LEFT_DOWN, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
113    GetNoClickButton()->Connect(GetNoClickButton()->GetId(), wxEVT_LEFT_UP, wxMouseEventHandler(CClickWindow::OnLeftUp), NULL, this);
114    GetNoClickButton()->Connect(GetNoClickButton()->GetId(), wxEVT_LEFT_DCLICK, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
115    GetNoClickButton()->Connect(GetNoClickButton()->GetId(), wxEVT_ENTER_WINDOW, wxMouseEventHandler(CClickWindow::OnEnterWindow), NULL, this);
116    GetNoClickButton()->Connect(GetNoClickButton()->GetId(), wxEVT_SET_FOCUS, wxFocusEventHandler(CClickWindow::OnEventSkipperFocus), NULL, this);
117    GetLeftButton()->Connect(GetLeftButton()->GetId(), wxEVT_LEFT_DOWN, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
118    GetLeftButton()->Connect(GetLeftButton()->GetId(), wxEVT_LEFT_UP, wxMouseEventHandler(CClickWindow::OnLeftUp), NULL, this);
119    GetLeftButton()->Connect(GetLeftButton()->GetId(), wxEVT_LEFT_DCLICK, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
120    GetLeftButton()->Connect(GetLeftButton()->GetId(), wxEVT_ENTER_WINDOW, wxMouseEventHandler(CClickWindow::OnEnterWindow), NULL, this);
121    GetLeftButton()->Connect(GetLeftButton()->GetId(), wxEVT_SET_FOCUS, wxFocusEventHandler(CClickWindow::OnEventSkipperFocus), NULL, this);
122   GetMiddleButton()->Connect(GetMiddleButton()->GetId(), wxEVT_LEFT_DOWN, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
123    GetMiddleButton()->Connect(GetMiddleButton()->GetId(), wxEVT_LEFT_UP, wxMouseEventHandler(CClickWindow::OnLeftUp), NULL, this);
124    GetMiddleButton()->Connect(GetMiddleButton()->GetId(), wxEVT_LEFT_DCLICK, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
125    GetMiddleButton()->Connect(GetMiddleButton()->GetId(), wxEVT_ENTER_WINDOW, wxMouseEventHandler(CClickWindow::OnEnterWindow), NULL, this);
126    GetMiddleButton()->Connect(GetMiddleButton()->GetId(), wxEVT_SET_FOCUS, wxFocusEventHandler(CClickWindow::OnEventSkipperFocus), NULL, this);
127    GetRightButton()->Connect(GetRightButton()->GetId(), wxEVT_LEFT_DOWN, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
128    GetRightButton()->Connect(GetRightButton()->GetId(), wxEVT_LEFT_UP, wxMouseEventHandler(CClickWindow::OnLeftUp), NULL, this);
129    GetRightButton()->Connect(GetRightButton()->GetId(), wxEVT_LEFT_DCLICK, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
130    GetRightButton()->Connect(GetRightButton()->GetId(), wxEVT_ENTER_WINDOW, wxMouseEventHandler(CClickWindow::OnEnterWindow), NULL, this);
131    GetRightButton()->Connect(GetRightButton()->GetId(), wxEVT_SET_FOCUS, wxFocusEventHandler(CClickWindow::OnEventSkipperFocus), NULL, this);
132    GetDragButton()->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
133    GetDragButton()->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(CClickWindow::OnLeftUp), NULL, this);
134    GetDragButton()->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
135    GetDragButton()->Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(CClickWindow::OnEnterWindow), NULL, this);
136    GetDragButton()->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(CClickWindow::OnEventSkipperFocus), NULL, this);
137    GetDblClickButton()->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
138    GetDblClickButton()->Connect( wxEVT_LEFT_UP, wxMouseEventHandler(CClickWindow::OnLeftUp), NULL, this);
139    GetDblClickButton()->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
140    GetDblClickButton()->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler(CClickWindow::OnEnterWindow), NULL, this);
141    GetDblClickButton()->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler(CClickWindow::OnEventSkipperFocus), NULL, this);
142    GetShowFrame()->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
143    GetShowFrame()->Connect( wxEVT_LEFT_UP, wxMouseEventHandler(CClickWindow::OnLeftUp), NULL, this);
144    GetShowFrame()->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler(CClickWindow::OnEventSkipperMouse), NULL, this);
145    GetShowFrame()->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler(CClickWindow::OnEnterWindow), NULL, this);
146    GetShowFrame()->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler(CClickWindow::OnEventSkipperFocus), NULL, this);
147}
148
149CClickWindowController::EButton CClickWindow::ButtonId2EButton (int id)
150{
151        if (id== GetNoClickButton()->GetId()) return CClickWindowController::NO_CLICK;
152    if (id== GetLeftButton()->GetId()) return CClickWindowController::LEFT;
153    if (id== GetMiddleButton()->GetId()) return CClickWindowController::MIDDLE;
154    if (id== GetRightButton()->GetId()) return CClickWindowController::RIGHT;
155    if (id== GetDragButton()->GetId()) return CClickWindowController::DRAG;
156    if (id== GetDblClickButton()->GetId()) return CClickWindowController::DBLCLICK;
157       
158    assert (false);
159        return CClickWindowController::NO_CLICK;        // Avoid warning
160}
161
162void CClickWindow::OnCloseWindow( wxCloseEvent& event )
163{
164        bool cVeto= event.CanVeto();
165       
166        if (cVeto) event.Skip (false);
167        else Destroy();
168}
169
170void CClickWindow::OnLeftUp( wxMouseEvent& event )
171{
172        if (event.GetId()== GetShowFrame()->GetId())
173                m_pController->NotifyShowMainWindowClick ();
174        else
175                m_pController->NotifyButtonClick (ButtonId2EButton (event.GetId()));
176       
177        event.Skip(false);
178}
179
180/*!
181 * wxEVT_ENTER_WINDOW event handler for ID_BUTTON_NOCLICK
182 */
183
184void CClickWindow::OnEnterWindow( wxMouseEvent& event )
185{
186        if (event.GetId()!= GetShowFrame()->GetId())
187                m_pController->NotifyButtonEnter (ButtonId2EButton (event.GetId()));
188        event.Skip(false);
189}
190
191void CClickWindow::OnMainWindowShow ( wxShowEvent& event )
192{
193        event.Skip(false);
194}
195
196void CClickWindow::OnEventSkipperMouse( wxMouseEvent& event )
197{
198        event.Skip(false);
199}
200       
201void CClickWindow::OnEventSkipperFocus( wxFocusEvent& event )
202{
203        event.Skip(false);
204}
Note: See TracBrowser for help on using the repository browser.