]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxblistctrl.cpp
Fix bugs 819 and 837
[bacula/bacula] / bacula / src / wx-console / wxblistctrl.cpp
1 /*
2  *
3  *   Custom tree control, which send "tree marked" events when the user right-
4  *   click on a item, or double-click on a mark.
5  *
6  *    Nicolas Boichat, April 2004
7  *
8  *    Version $Id$
9  */
10 /*
11    Bacula® - The Network Backup Solution
12
13    Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
14
15    The main author of Bacula is Kern Sibbald, with contributions from
16    many others, a complete list can be found in the file AUTHORS.
17    This program is Free Software; you can redistribute it and/or
18    modify it under the terms of version two of the GNU General Public
19    License as published by the Free Software Foundation plus additions
20    that are listed in the file LICENSE.
21
22    This program is distributed in the hope that it will be useful, but
23    WITHOUT ANY WARRANTY; without even the implied warranty of
24    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25    General Public License for more details.
26
27    You should have received a copy of the GNU General Public License
28    along with this program; if not, write to the Free Software
29    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30    02110-1301, USA.
31
32    Bacula® is a registered trademark of John Walker.
33    The licensor of Bacula is the Free Software Foundation Europe
34    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
35    Switzerland, email:ftf@fsfeurope.org.
36 */
37
38 /*  Windows debug builds set _DEBUG which is used by wxWidgets to select their
39  *  debug memory allocator.  Unfortunately it conflicts with Bacula's SmartAlloc.
40  * So we turn _DEBUG off since we aren't interested in things it enables.
41  */
42
43 #undef _DEBUG
44
45 #include "bacula.h"
46
47 #include "wxblistctrl.h"
48 #include "csprint.h"
49 #include "wxbmainframe.h"
50
51 BEGIN_EVENT_TABLE(wxbListCtrl, wxListCtrl)
52    EVT_LEFT_DCLICK(wxbListCtrl::OnDoubleClicked)
53    EVT_RIGHT_DOWN(wxbListCtrl::OnRightClicked)
54 END_EVENT_TABLE()
55
56 DEFINE_LOCAL_EVENT_TYPE(wxbLIST_MARKED_EVENT)
57
58 wxbListCtrl::wxbListCtrl(
59       wxWindow* parent, wxEvtHandler* handler, wxWindowID id, const wxPoint& pos, const wxSize& size): 
60             wxListCtrl(parent, id, pos, size, wxLC_REPORT | wxSUNKEN_BORDER) {
61    this->handler = handler;
62 }
63
64 wxbListCtrl::~wxbListCtrl() {}
65
66 /* 
67  * Send mark event if the user double-clicked on the icon.
68  */
69 void wxbListCtrl::OnDoubleClicked(wxMouseEvent& event) {
70    if (event.GetX() < GetColumnWidth(0)) {
71       wxbListMarkedEvent evt(GetId());
72
73       handler->ProcessEvent(evt);
74       
75       //No Skip : we don't want to go in this directory (if it is a directory)
76    }
77    else {
78       event.Skip();
79    }
80 }
81
82 /* 
83  * Send mark event if the user right clicked on an item.
84  */
85 void wxbListCtrl::OnRightClicked(wxMouseEvent& event) {
86    wxbListMarkedEvent evt(GetId());
87
88    handler->ProcessEvent(evt);
89 }
90
91 /* Customized tree event, used for marking events */
92
93 wxbListMarkedEvent::wxbListMarkedEvent(int id): wxEvent(id, wxbLIST_MARKED_EVENT) {}
94
95 wxbListMarkedEvent::~wxbListMarkedEvent() {}
96
97 wxbListMarkedEvent::wxbListMarkedEvent(const wxbListMarkedEvent& te): wxEvent(te) {}
98
99 wxEvent *wxbListMarkedEvent::Clone() const {
100    return new wxbListMarkedEvent(*(this));
101 }