]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbtreectrl.cpp
Fix some trivial errors and implemented the restore of IRIX xattrs.
[bacula/bacula] / bacula / src / wx-console / wxbtreectrl.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 three of the GNU Affero General Public
19    License as published by the Free Software Foundation and included
20    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 Affero 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 Kern Sibbald.
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 "wxbtreectrl.h"
48
49 #include "csprint.h"
50 #include "wxbmainframe.h"
51
52 BEGIN_EVENT_TABLE(wxbTreeCtrl, wxTreeCtrl)
53    EVT_LEFT_DCLICK(wxbTreeCtrl::OnDoubleClicked)
54    EVT_RIGHT_DOWN(wxbTreeCtrl::OnRightClicked)
55 END_EVENT_TABLE()
56
57 DEFINE_LOCAL_EVENT_TYPE(wxbTREE_MARKED_EVENT)
58
59 wxbTreeCtrl::wxbTreeCtrl(
60       wxWindow* parent, wxEvtHandler* handler, wxWindowID id, const wxPoint& pos, const wxSize& size): 
61             wxTreeCtrl(parent, id, pos, size, wxSUNKEN_BORDER | wxTR_HAS_BUTTONS) {
62    this->handler = handler;
63 }
64
65 wxbTreeCtrl::~wxbTreeCtrl() {}
66
67 /* 
68  * Send mark event if the user double-clicked on the icon.
69  */
70 void wxbTreeCtrl::OnDoubleClicked(wxMouseEvent& event) {
71    int flags;
72    wxTreeItemId treeid = HitTest(event.GetPosition(), flags);
73    if ((flags & wxTREE_HITTEST_ONITEMICON) && (treeid.IsOk())) {
74       wxbTreeMarkedEvent evt(GetId(), treeid);
75
76       handler->ProcessEvent(evt);
77       
78       //No Skip : we don't want this item to be collapsed or expanded
79    }
80    else {
81       event.Skip();
82    }
83 }
84
85 /* 
86  * Send mark event if the user right clicked on an item.
87  */
88 void wxbTreeCtrl::OnRightClicked(wxMouseEvent& event) {
89    int flags;
90    wxTreeItemId treeid = HitTest(event.GetPosition(), flags);
91    if (treeid.IsOk()) {
92       wxbTreeMarkedEvent evt(GetId(), treeid);
93
94       handler->ProcessEvent(evt);
95    }
96    event.Skip();
97 }
98
99 /* Customized tree event, used for marking events */
100
101 wxbTreeMarkedEvent::wxbTreeMarkedEvent(int id, wxTreeItemId& item): wxEvent(id, wxbTREE_MARKED_EVENT) {
102    this->item = item;
103 }
104
105 wxbTreeMarkedEvent::~wxbTreeMarkedEvent() {}
106
107 wxbTreeMarkedEvent::wxbTreeMarkedEvent(const wxbTreeMarkedEvent& te): wxEvent(te) {
108    this->item = te.item;
109 }
110
111 wxEvent *wxbTreeMarkedEvent::Clone() const {
112    return new wxbTreeMarkedEvent(*(this));
113 }
114
115 wxTreeItemId wxbTreeMarkedEvent::GetItem() {
116    return item;
117 }