source: eviacam/trunk/fuentes/src/clickwindowbitmap.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

  • Property svn:executable set to *
File size: 16.6 KB
Line 
1/////////////////////////////////////////////////////////////////////////////
2// Name:        cclickwindowbitmap.cpp
3// Purpose:     
4// Author:      César Mauri Loba
5// Modified by:
6// Created:     16/11/2009 15:10:47
7// RCS-ID:     
8// Copyright:   (C) 2008 Cesar Mauri Loba - CREA Software Systems
9//
10//  This program is free software: you can redistribute it and/or modify
11//  it under the terms of the GNU General Public License as published by
12//  the Free Software Foundation, either version 3 of the License, or
13//  (at your option) any later version.
14//
15//  This program is distributed in the hope that it will be useful,
16//  but WITHOUT ANY WARRANTY; without even the implied warranty of
17//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18//  GNU General Public License for more details.
19//
20//  You should have received a copy of the GNU General Public License
21//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22/////////////////////////////////////////////////////////////////////////////
23
24// For compilers that support precompilation, includes "wx/wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
28#pragma hdrstop
29#endif
30
31#ifndef WX_PRECOMP
32#include "wx/wx.h"
33#endif
34
35////@begin includes
36////@end includes
37
38#include "clickwindowbitmap.h"
39
40////@begin XPM images
41#include "icons/eviacam_gray_bg.xpm"
42#include "icons/buttonNoClick.xpm"
43#include "icons/buttonLeft.xpm"
44#include "icons/buttonLeftDisabled.xpm"
45#include "icons/buttonMiddle.xpm"
46#include "icons/buttonMiddleDisabled.xpm"
47#include "icons/buttonRight.xpm"
48#include "icons/buttonRightDisabled.xpm"
49#include "icons/buttonDrag.xpm"
50#include "icons/buttonDragDisabled.xpm"
51#include "icons/buttonDblLeft.xpm"
52#include "icons/buttonDblLeftDisabled.xpm"
53#include "icons/buttonHideMainWindow.xpm"
54////@end XPM images
55
56#include "icons/buttonDblLeftLocked.xpm"
57#include "icons/buttonDblLeftSelectedLocked.xpm"
58#include "icons/buttonDblLeftSelected.xpm"
59#include "icons/buttonDragLocked.xpm"
60#include "icons/buttonDragSelectedLocked.xpm"
61#include "icons/buttonDragSelected.xpm"
62#include "icons/buttonLeftLocked.xpm"
63#include "icons/buttonLeftSelectedLocked.xpm"
64#include "icons/buttonLeftSelected.xpm"
65#include "icons/buttonNoClickSelected.xpm"
66#include "icons/buttonMiddleLocked.xpm"
67#include "icons/buttonMiddleSelectedLocked.xpm"
68#include "icons/buttonMiddleSelected.xpm"
69#include "icons/buttonRightLocked.xpm"
70#include "icons/buttonRightSelectedLocked.xpm"
71#include "icons/buttonRightSelected.xpm"
72#include "icons/buttonShowMainWindow.xpm"
73
74
75/*!
76 * CClickWindowBitmap type definition
77 */
78
79IMPLEMENT_DYNAMIC_CLASS( CClickWindowBitmap, CClickWindow )
80
81
82/*!
83 * CClickWindowBitmap event table definition
84 */
85
86BEGIN_EVENT_TABLE( CClickWindowBitmap, CClickWindow )
87
88////@begin CClickWindowBitmap event table entries
89////@end CClickWindowBitmap event table entries
90
91END_EVENT_TABLE()
92
93
94/*!
95 * CClickWindowBitmap constructors
96 */
97
98CClickWindowBitmap::CClickWindowBitmap()
99: m_bmpButtonDblLeftLocked(buttonDblLeftLocked)
100, m_bmpButtonDblLeftSelectedLocked(buttonDblLeftSelectedLocked)
101, m_bmpButtonDblLeftSelected(buttonDblLeftSelected)
102, m_bmpButtonDblLeft(buttonDblLeft)
103, m_bmpButtonDragLocked(buttonDragLocked)
104, m_bmpButtonDragSelectedLocked(buttonDragSelectedLocked)
105, m_bmpButtonDragSelected(buttonDragSelected)
106, m_bmpButtonDrag(buttonDrag)
107, m_bmpButtonHideMainWindow(buttonHideMainWindow)
108, m_bmpButtonLeftLocked(buttonLeftLocked)
109, m_bmpButtonLeftSelectedLocked(buttonLeftSelectedLocked)
110, m_bmpButtonLeftSelected(buttonLeftSelected)
111, m_bmpButtonLeft(buttonLeft)
112, m_bmpButtonNoClickSelected(buttonNoClickSelected)
113, m_bmpButtonNoClick(buttonNoClick)
114, m_bmpButtonMiddleLocked(buttonMiddleLocked)
115, m_bmpButtonMiddleSelectedLocked(buttonMiddleSelectedLocked)
116, m_bmpButtonMiddleSelected(buttonMiddleSelected)
117, m_bmpButtonMiddle(buttonMiddle)
118, m_bmpButtonRightLocked(buttonRightLocked)
119, m_bmpButtonRightSelectedLocked(buttonRightSelectedLocked)
120, m_bmpButtonRightSelected(buttonRightSelected)
121, m_bmpButtonRight(buttonRight)
122, m_bmpButtonShowMainWindow(buttonShowMainWindow)
123{
124    Init();
125}
126
127CClickWindowBitmap::CClickWindowBitmap( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
128: m_bmpButtonDblLeftLocked(buttonDblLeftLocked)
129, m_bmpButtonDblLeftSelectedLocked(buttonDblLeftSelectedLocked)
130, m_bmpButtonDblLeftSelected(buttonDblLeftSelected)
131, m_bmpButtonDblLeft(buttonDblLeft)
132, m_bmpButtonDragLocked(buttonDragLocked)
133, m_bmpButtonDragSelectedLocked(buttonDragSelectedLocked)
134, m_bmpButtonDragSelected(buttonDragSelected)
135, m_bmpButtonDrag(buttonDrag)
136, m_bmpButtonHideMainWindow(buttonHideMainWindow)
137, m_bmpButtonLeftLocked(buttonLeftLocked)
138, m_bmpButtonLeftSelectedLocked(buttonLeftSelectedLocked)
139, m_bmpButtonLeftSelected(buttonLeftSelected)
140, m_bmpButtonLeft(buttonLeft)
141, m_bmpButtonNoClickSelected(buttonNoClickSelected)
142, m_bmpButtonNoClick(buttonNoClick)
143, m_bmpButtonMiddleLocked(buttonMiddleLocked)
144, m_bmpButtonMiddleSelectedLocked(buttonMiddleSelectedLocked)
145, m_bmpButtonMiddleSelected(buttonMiddleSelected)
146, m_bmpButtonMiddle(buttonMiddle)
147, m_bmpButtonRightLocked(buttonRightLocked)
148, m_bmpButtonRightSelectedLocked(buttonRightSelectedLocked)
149, m_bmpButtonRightSelected(buttonRightSelected)
150, m_bmpButtonRight(buttonRight)
151, m_bmpButtonShowMainWindow(buttonShowMainWindow)
152{
153    Init();
154    Create(parent, id, caption, pos, size, style);
155}
156
157/*!
158 * CClickWindowBitmap creator
159 */
160
161bool CClickWindowBitmap::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
162{
163////@begin CClickWindowBitmap creation
164    SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
165    CClickWindow::Create( parent, id, caption, pos, size, style );
166
167    CreateControls();
168    if (GetSizer())
169    {
170        GetSizer()->SetSizeHints(this);
171    }
172    Centre();
173////@end CClickWindowBitmap creation
174    return true;
175}
176
177
178/*!
179 * CClickWindowBitmap destructor
180 */
181
182CClickWindowBitmap::~CClickWindowBitmap()
183{
184////@begin CClickWindowBitmap destruction
185////@end CClickWindowBitmap destruction
186}
187
188
189/*!
190 * Member initialisation
191 */
192
193void CClickWindowBitmap::Init()
194{
195////@begin CClickWindowBitmap member initialisation
196    m_btnNoClick = NULL;
197    m_btnLeft = NULL;
198    m_btnMiddle = NULL;
199    m_btnRight = NULL;
200    m_btnDrag = NULL;
201    m_btnDblLeft = NULL;
202    m_btnShowFrame = NULL;
203////@end CClickWindowBitmap member initialisation
204}
205
206
207/*!
208 * Control creation for CClickWindowBitmap
209 */
210
211void CClickWindowBitmap::CreateControls()
212{   
213////@begin CClickWindowBitmap content construction
214    CClickWindowBitmap* itemCClickWindow1 = this;
215
216    this->SetBackgroundColour(wxColour(102, 102, 102));
217    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
218    itemCClickWindow1->SetSizer(itemBoxSizer2);
219
220    wxStaticBitmap* itemStaticBitmap3 = new wxStaticBitmap( itemCClickWindow1, wxID_STATIC, itemCClickWindow1->GetBitmapResource(wxT("icons/eviacam_gray_bg.xpm")), wxDefaultPosition, wxSize(48, 48), 0 );
221    itemBoxSizer2->Add(itemStaticBitmap3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
222
223    itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
224
225    m_btnNoClick = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_NOCLICK, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonNoClick.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxNO_BORDER );
226    if (CClickWindowBitmap::ShowToolTips())
227        m_btnNoClick->SetToolTip(_("No click"));
228    itemBoxSizer2->Add(m_btnNoClick, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
229
230    itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
231
232    m_btnLeft = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_LEFT, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonLeft.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
233    wxBitmap m_btnLeftBitmapDisabled(itemCClickWindow1->GetBitmapResource(wxT("icons/buttonLeftDisabled.xpm")));
234    m_btnLeft->SetBitmapDisabled(m_btnLeftBitmapDisabled);
235    if (CClickWindowBitmap::ShowToolTips())
236        m_btnLeft->SetToolTip(_("Left"));
237    itemBoxSizer2->Add(m_btnLeft, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
238
239    m_btnMiddle = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_MIDDLE, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonMiddle.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
240    wxBitmap m_btnMiddleBitmapDisabled(itemCClickWindow1->GetBitmapResource(wxT("icons/buttonMiddleDisabled.xpm")));
241    m_btnMiddle->SetBitmapDisabled(m_btnMiddleBitmapDisabled);
242    if (CClickWindowBitmap::ShowToolTips())
243        m_btnMiddle->SetToolTip(_("Middle"));
244    itemBoxSizer2->Add(m_btnMiddle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
245
246    m_btnRight = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_RIGHT, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonRight.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
247    wxBitmap m_btnRightBitmapDisabled(itemCClickWindow1->GetBitmapResource(wxT("icons/buttonRightDisabled.xpm")));
248    m_btnRight->SetBitmapDisabled(m_btnRightBitmapDisabled);
249    if (CClickWindowBitmap::ShowToolTips())
250        m_btnRight->SetToolTip(_("Right"));
251    itemBoxSizer2->Add(m_btnRight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
252
253    m_btnDrag = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_DRAG, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonDrag.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
254    wxBitmap m_btnDragBitmapDisabled(itemCClickWindow1->GetBitmapResource(wxT("icons/buttonDragDisabled.xpm")));
255    m_btnDrag->SetBitmapDisabled(m_btnDragBitmapDisabled);
256    if (CClickWindowBitmap::ShowToolTips())
257        m_btnDrag->SetToolTip(_("Drag"));
258    itemBoxSizer2->Add(m_btnDrag, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
259
260    m_btnDblLeft = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_DBLCLICK, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonDblLeft.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
261    wxBitmap m_btnDblLeftBitmapDisabled(itemCClickWindow1->GetBitmapResource(wxT("icons/buttonDblLeftDisabled.xpm")));
262    m_btnDblLeft->SetBitmapDisabled(m_btnDblLeftBitmapDisabled);
263    if (CClickWindowBitmap::ShowToolTips())
264        m_btnDblLeft->SetToolTip(_("Double Click"));
265    itemBoxSizer2->Add(m_btnDblLeft, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
266
267    itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
268
269    m_btnShowFrame = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonHideMainWindow.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
270    if (CClickWindowBitmap::ShowToolTips())
271        m_btnShowFrame->SetToolTip(_("Hide main window"));
272    itemBoxSizer2->Add(m_btnShowFrame, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
273
274    // Connect events and objects
275    m_btnNoClick->Connect(ID_BITMAPBUTTON_NOCLICK, wxEVT_ENTER_WINDOW, wxMouseEventHandler(CClickWindowBitmap::OnEnterWindow), NULL, this);
276////@end CClickWindowBitmap content construction
277
278        ConnectEvents ();
279}
280
281
282/*!
283 * Should we show tooltips?
284 */
285
286bool CClickWindowBitmap::ShowToolTips()
287{
288    return true;
289}
290
291/*!
292 * Get bitmap resources
293 */
294
295wxBitmap CClickWindowBitmap::GetBitmapResource( const wxString& name )
296{
297    // Bitmap retrieval
298////@begin CClickWindowBitmap bitmap retrieval
299    wxUnusedVar(name);
300    if (name == _T("icons/eviacam_gray_bg.xpm"))
301    {
302        wxBitmap bitmap(eviacam);
303        return bitmap;
304    }
305    else if (name == _T("icons/buttonNoClick.xpm"))
306    {
307        wxBitmap bitmap(buttonNoClick);
308        return bitmap;
309    }
310    else if (name == _T("icons/buttonLeft.xpm"))
311    {
312        wxBitmap bitmap(buttonLeft);
313        return bitmap;
314    }
315    else if (name == _T("icons/buttonLeftDisabled.xpm"))
316    {
317        wxBitmap bitmap(buttonLeftDisabled);
318        return bitmap;
319    }
320    else if (name == _T("icons/buttonMiddle.xpm"))
321    {
322        wxBitmap bitmap(buttonMiddle);
323        return bitmap;
324    }
325    else if (name == _T("icons/buttonMiddleDisabled.xpm"))
326    {
327        wxBitmap bitmap(buttonMiddleDisabled);
328        return bitmap;
329    }
330    else if (name == _T("icons/buttonRight.xpm"))
331    {
332        wxBitmap bitmap(buttonRight);
333        return bitmap;
334    }
335    else if (name == _T("icons/buttonRightDisabled.xpm"))
336    {
337        wxBitmap bitmap(buttonRightDisabled);
338        return bitmap;
339    }
340    else if (name == _T("icons/buttonDrag.xpm"))
341    {
342        wxBitmap bitmap(buttonDrag);
343        return bitmap;
344    }
345    else if (name == _T("icons/buttonDragDisabled.xpm"))
346    {
347        wxBitmap bitmap(buttonDragDisabled);
348        return bitmap;
349    }
350    else if (name == _T("icons/buttonDblLeft.xpm"))
351    {
352        wxBitmap bitmap(buttonDblLeft);
353        return bitmap;
354    }
355    else if (name == _T("icons/buttonDblLeftDisabled.xpm"))
356    {
357        wxBitmap bitmap(buttonDblLeftDisabled);
358        return bitmap;
359    }
360    else if (name == _T("icons/buttonHideMainWindow.xpm"))
361    {
362        wxBitmap bitmap(buttonHideMainWindow);
363        return bitmap;
364    }
365    return wxNullBitmap;
366////@end CClickWindowBitmap bitmap retrieval
367}
368
369/*!
370 * Get icon resources
371 */
372
373wxIcon CClickWindowBitmap::GetIconResource( const wxString& name )
374{
375    // Icon retrieval
376////@begin CClickWindowBitmap icon retrieval
377    wxUnusedVar(name);
378    return wxNullIcon;
379////@end CClickWindowBitmap icon retrieval
380}
381
382wxControl* CClickWindowBitmap::GetNoClickButton()
383{
384        return m_btnNoClick;
385}
386
387wxControl* CClickWindowBitmap::GetLeftButton()
388{
389        return m_btnLeft;
390}
391
392wxControl* CClickWindowBitmap::GetMiddleButton()
393{
394        return m_btnMiddle;
395}
396
397wxControl* CClickWindowBitmap::GetRightButton()
398{
399        return m_btnRight;
400}
401
402wxControl* CClickWindowBitmap::GetDragButton()
403{
404        return m_btnDrag;
405}
406
407wxControl* CClickWindowBitmap::GetDblClickButton()
408{
409        return m_btnDblLeft;
410}
411
412wxControl* CClickWindowBitmap::GetShowFrame()
413{
414        return m_btnShowFrame;
415}
416
417void CClickWindowBitmap::UpdateButtons (bool noClickStatus, CClickWindowController::EButton selected, CClickWindowController::EButton locked)
418{
419        // No click button
420       
421        if (noClickStatus)
422        {
423                m_btnNoClick->SetBitmapLabel (m_bmpButtonNoClick);
424                m_btnLeft->Enable();
425                m_btnMiddle->Enable();
426                m_btnRight->Enable();
427                m_btnDrag->Enable();
428                m_btnDblLeft->Enable();
429        }
430        else
431        {
432                m_btnNoClick->SetBitmapLabel (m_bmpButtonNoClickSelected);
433                m_btnLeft->Disable();
434                m_btnMiddle->Disable();
435                m_btnRight->Disable();
436                m_btnDrag->Disable();
437                m_btnDblLeft->Disable();
438        }
439               
440
441        if (selected== CClickWindowController::LEFT)
442                if (locked== CClickWindowController::LEFT)
443                        m_btnLeft->SetBitmapLabel (m_bmpButtonLeftSelectedLocked);
444                else
445                        m_btnLeft->SetBitmapLabel (m_bmpButtonLeftSelected);
446        else
447                if (locked== CClickWindowController::LEFT)
448                        m_btnLeft->SetBitmapLabel (m_bmpButtonLeftLocked);
449                else
450                        m_btnLeft->SetBitmapLabel (m_bmpButtonLeft);
451               
452        if (selected== CClickWindowController::MIDDLE)
453                if (locked== CClickWindowController::MIDDLE)
454                        m_btnMiddle->SetBitmapLabel (m_bmpButtonMiddleSelectedLocked);
455                else
456                        m_btnMiddle->SetBitmapLabel (m_bmpButtonMiddleSelected);
457        else
458                if (locked== CClickWindowController::MIDDLE)
459                        m_btnMiddle->SetBitmapLabel (m_bmpButtonMiddleLocked);
460                else
461                        m_btnMiddle->SetBitmapLabel (m_bmpButtonMiddle);
462
463        if (selected== CClickWindowController::RIGHT)
464                if (locked== CClickWindowController::RIGHT)
465                        m_btnRight->SetBitmapLabel (m_bmpButtonRightSelectedLocked);
466                else
467                        m_btnRight->SetBitmapLabel (m_bmpButtonRightSelected);
468        else
469                if (locked== CClickWindowController::RIGHT)
470                        m_btnRight->SetBitmapLabel (m_bmpButtonRightLocked);
471                else
472                        m_btnRight->SetBitmapLabel (m_bmpButtonRight);
473
474        if (selected== CClickWindowController::DRAG)
475                if (locked== CClickWindowController::DRAG)
476                        m_btnDrag->SetBitmapLabel (m_bmpButtonDragSelectedLocked);
477                else
478                        m_btnDrag->SetBitmapLabel (m_bmpButtonDragSelected);
479        else
480                if (locked== CClickWindowController::DRAG)
481                        m_btnDrag->SetBitmapLabel (m_bmpButtonDragLocked);
482                else
483                        m_btnDrag->SetBitmapLabel (m_bmpButtonDrag);
484
485        if (selected== CClickWindowController::DBLCLICK)
486                if (locked== CClickWindowController::DBLCLICK)
487                        m_btnDblLeft->SetBitmapLabel (m_bmpButtonDblLeftSelectedLocked);
488                else
489                        m_btnDblLeft->SetBitmapLabel (m_bmpButtonDblLeftSelected);
490        else
491                if (locked== CClickWindowController::DBLCLICK)
492                        m_btnDblLeft->SetBitmapLabel (m_bmpButtonDblLeftLocked);
493                else
494                        m_btnDblLeft->SetBitmapLabel (m_bmpButtonDblLeft);
495}
496
497void CClickWindowBitmap::OnMainWindowShow ( wxShowEvent& event )
498{
499        if (event.GetShow())   
500        {
501                m_btnShowFrame->SetBitmapLabel(m_bmpButtonHideMainWindow);
502                m_btnShowFrame->SetToolTip(_("Hide main window"));
503        }
504        else
505        {
506                m_btnShowFrame->SetBitmapLabel(m_bmpButtonShowMainWindow);
507                m_btnShowFrame->SetToolTip(_("Show main window"));
508        }
509        // Set to true to propagate events to the text mode clickwindow
510        event.Skip (true);
511}
512
513
514/*!
515 * wxEVT_ENTER_WINDOW event handler for ID_BITMAPBUTTON_NOCLICK
516 */
517
518void CClickWindowBitmap::OnEnterWindow( wxMouseEvent& event )
519{
520        event.Skip(true);
521}
522
Note: See TracBrowser for help on using the repository browser.