source: eviacam/trunk/fuentes/src/clickwindowbitmapvertical.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.7 KB
Line 
1/////////////////////////////////////////////////////////////////////////////
2// Name:        cclickwindowbitmap.cpp
3// Purpose:     
4// Author:      César Mauri Loba
5// Modified by:
6// Created:     22/02/2011
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
25// For compilers that support precompilation, includes "wx/wx.h".
26#include "wx/wxprec.h"
27
28#ifdef __BORLANDC__
29#pragma hdrstop
30#endif
31
32#ifndef WX_PRECOMP
33#include "wx/wx.h"
34#endif
35
36////@begin includes
37////@end includes
38
39#include "clickwindowbitmapvertical.h"
40
41////@begin XPM images
42#include "icons/eviacam_gray_bg.xpm"
43#include "icons/buttonNoClick.xpm"
44#include "icons/buttonLeft.xpm"
45#include "icons/buttonLeftDisabled.xpm"
46#include "icons/buttonMiddle.xpm"
47#include "icons/buttonMiddleDisabled.xpm"
48#include "icons/buttonRight.xpm"
49#include "icons/buttonRightDisabled.xpm"
50#include "icons/buttonDrag.xpm"
51#include "icons/buttonDragDisabled.xpm"
52#include "icons/buttonDblLeft.xpm"
53#include "icons/buttonDblLeftDisabled.xpm"
54#include "icons/buttonHideMainWindow.xpm"
55////@end XPM images
56
57#include "icons/buttonDblLeftLocked.xpm"
58#include "icons/buttonDblLeftSelectedLocked.xpm"
59#include "icons/buttonDblLeftSelected.xpm"
60#include "icons/buttonDragLocked.xpm"
61#include "icons/buttonDragSelectedLocked.xpm"
62#include "icons/buttonDragSelected.xpm"
63#include "icons/buttonLeftLocked.xpm"
64#include "icons/buttonLeftSelectedLocked.xpm"
65#include "icons/buttonLeftSelected.xpm"
66#include "icons/buttonNoClickSelected.xpm"
67#include "icons/buttonMiddleLocked.xpm"
68#include "icons/buttonMiddleSelectedLocked.xpm"
69#include "icons/buttonMiddleSelected.xpm"
70#include "icons/buttonRightLocked.xpm"
71#include "icons/buttonRightSelectedLocked.xpm"
72#include "icons/buttonRightSelected.xpm"
73#include "icons/buttonShowMainWindow.xpm"
74
75/*!
76 * CClickWindowBitmapVertical type definition
77 */
78
79IMPLEMENT_DYNAMIC_CLASS( CClickWindowBitmapVertical, CClickWindow )
80
81
82/*!
83 * CClickWindowBitmapVertical event table definition
84 */
85
86BEGIN_EVENT_TABLE( CClickWindowBitmapVertical, CClickWindow )
87
88////@begin CClickWindowBitmapVertical event table entries
89////@end CClickWindowBitmapVertical event table entries
90
91END_EVENT_TABLE()
92
93
94/*!
95 * CClickWindowBitmapVertical constructors
96 */
97
98CClickWindowBitmapVertical::CClickWindowBitmapVertical()
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
127CClickWindowBitmapVertical::CClickWindowBitmapVertical( 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/*!
159 * ClickWindowBitmapVertical creator
160 */
161
162bool CClickWindowBitmapVertical::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
163{
164////@begin CClickWindowBitmapVertical creation
165    SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
166    CClickWindow::Create( parent, id, caption, pos, size, style );
167
168    CreateControls();
169    if (GetSizer())
170    {
171        GetSizer()->SetSizeHints(this);
172    }
173    Centre();
174////@end CClickWindowBitmapVertical creation
175    return true;
176}
177
178
179/*!
180 * CClickWindowBitmapVertical destructor
181 */
182
183CClickWindowBitmapVertical::~CClickWindowBitmapVertical()
184{
185////@begin CClickWindowBitmapVertical destruction
186////@end CClickWindowBitmapVertical destruction
187}
188
189
190/*!
191 * Member initialisation
192 */
193
194void CClickWindowBitmapVertical::Init()
195{
196////@begin CClickWindowBitmapVertical member initialisation
197    m_btnNoClick = NULL;
198    m_btnLeft = NULL;
199    m_btnMiddle = NULL;
200    m_btnRight = NULL;
201    m_btnDrag = NULL;
202    m_btnDblLeft = NULL;
203    m_btnShowFrame = NULL;
204////@end CClickWindowBitmapVertical member initialisation
205}
206
207
208/*!
209 * Control creation for ClickWindowBitmapVertical
210 */
211
212void CClickWindowBitmapVertical::CreateControls()
213{   
214////@begin CClickWindowBitmapVertical content construction
215    CClickWindowBitmapVertical* itemCClickWindow1 = this;
216
217    this->SetBackgroundColour(wxColour(102, 102, 102));
218    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
219    itemCClickWindow1->SetSizer(itemBoxSizer2);
220
221    wxStaticBitmap* itemStaticBitmap3 = new wxStaticBitmap( itemCClickWindow1, wxID_STATIC, itemCClickWindow1->GetBitmapResource(wxT("icons/eviacam_gray_bg.xpm")), wxDefaultPosition, wxSize(48, 48), 0 );
222    itemBoxSizer2->Add(itemStaticBitmap3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
223
224    itemBoxSizer2->Add(4, 0, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
225
226    m_btnNoClick = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_NOCLICK, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonNoClick.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxNO_BORDER );
227    if (CClickWindowBitmapVertical::ShowToolTips())
228        m_btnNoClick->SetToolTip(_("No click"));
229    itemBoxSizer2->Add(m_btnNoClick, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
230
231    itemBoxSizer2->Add(4, 0, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
232
233    m_btnLeft = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_LEFT, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonLeft.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
234    wxBitmap m_btnLeftBitmapDisabled(itemCClickWindow1->GetBitmapResource(wxT("icons/buttonLeftDisabled.xpm")));
235    m_btnLeft->SetBitmapDisabled(m_btnLeftBitmapDisabled);
236    if (CClickWindowBitmapVertical::ShowToolTips())
237        m_btnLeft->SetToolTip(_("Left"));
238    itemBoxSizer2->Add(m_btnLeft, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
239
240    m_btnMiddle = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_MIDDLE, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonMiddle.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
241    wxBitmap m_btnMiddleBitmapDisabled(itemCClickWindow1->GetBitmapResource(wxT("icons/buttonMiddleDisabled.xpm")));
242    m_btnMiddle->SetBitmapDisabled(m_btnMiddleBitmapDisabled);
243    if (CClickWindowBitmapVertical::ShowToolTips())
244        m_btnMiddle->SetToolTip(_("Middle"));
245    itemBoxSizer2->Add(m_btnMiddle, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
246
247    m_btnRight = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_RIGHT, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonRight.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
248    wxBitmap m_btnRightBitmapDisabled(itemCClickWindow1->GetBitmapResource(wxT("icons/buttonRightDisabled.xpm")));
249    m_btnRight->SetBitmapDisabled(m_btnRightBitmapDisabled);
250    if (CClickWindowBitmapVertical::ShowToolTips())
251        m_btnRight->SetToolTip(_("Right"));
252    itemBoxSizer2->Add(m_btnRight, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
253
254    m_btnDrag = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_DRAG, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonDrag.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
255    wxBitmap m_btnDragBitmapDisabled(itemCClickWindow1->GetBitmapResource(wxT("icons/buttonDragDisabled.xpm")));
256    m_btnDrag->SetBitmapDisabled(m_btnDragBitmapDisabled);
257    if (CClickWindowBitmapVertical::ShowToolTips())
258        m_btnDrag->SetToolTip(_("Drag"));
259    itemBoxSizer2->Add(m_btnDrag, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
260
261    m_btnDblLeft = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON_DBLCLICK, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonDblLeft.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
262    wxBitmap m_btnDblLeftBitmapDisabled(itemCClickWindow1->GetBitmapResource(wxT("icons/buttonDblLeftDisabled.xpm")));
263    m_btnDblLeft->SetBitmapDisabled(m_btnDblLeftBitmapDisabled);
264    if (CClickWindowBitmapVertical::ShowToolTips())
265        m_btnDblLeft->SetToolTip(_("Double Click"));
266    itemBoxSizer2->Add(m_btnDblLeft, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
267
268    itemBoxSizer2->Add(4, 0, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
269
270    m_btnShowFrame = new wxBitmapButton( itemCClickWindow1, ID_BITMAPBUTTON, itemCClickWindow1->GetBitmapResource(wxT("icons/buttonHideMainWindow.xpm")), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
271    if (CClickWindowBitmapVertical::ShowToolTips())
272        m_btnShowFrame->SetToolTip(_("Hide main window"));
273    itemBoxSizer2->Add(m_btnShowFrame, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
274
275////@end CClickWindowBitmapVertical content construction
276       
277        ConnectEvents ();
278
279}
280
281
282/*!
283 * Should we show tooltips?
284 */
285
286bool CClickWindowBitmapVertical::ShowToolTips()
287{
288    return true;
289}
290
291/*!
292 * Get bitmap resources
293 */
294
295wxBitmap CClickWindowBitmapVertical::GetBitmapResource( const wxString& name )
296{
297    // Bitmap retrieval
298////@begin CClickWindowBitmapVertical 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 CClickWindowBitmapVertical bitmap retrieval
367}
368
369/*!
370 * Get icon resources
371 */
372
373wxIcon CClickWindowBitmapVertical::GetIconResource( const wxString& name )
374{
375    // Icon retrieval
376////@begin CClickWindowBitmapVertical icon retrieval
377    wxUnusedVar(name);
378    return wxNullIcon;
379////@end CClickWindowBitmapVertical icon retrieval
380}
381
382wxControl* CClickWindowBitmapVertical::GetNoClickButton()
383{
384        return m_btnNoClick;
385}
386
387wxControl* CClickWindowBitmapVertical::GetLeftButton()
388{
389        return m_btnLeft;
390}
391
392wxControl* CClickWindowBitmapVertical::GetMiddleButton()
393{
394        return m_btnMiddle;
395}
396
397wxControl* CClickWindowBitmapVertical::GetRightButton()
398{
399        return m_btnRight;
400}
401
402wxControl* CClickWindowBitmapVertical::GetDragButton()
403{
404        return m_btnDrag;
405}
406
407wxControl* CClickWindowBitmapVertical::GetDblClickButton()
408{
409        return m_btnDblLeft;
410}
411
412wxControl* CClickWindowBitmapVertical::GetShowFrame()
413{
414        return m_btnShowFrame;
415}
416
417void CClickWindowBitmapVertical::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 CClickWindowBitmapVertical::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
Note: See TracBrowser for help on using the repository browser.