3 * Custom tree control, which send "tree marked" events when the user right-
4 * click on a item, or double-click on a mark.
6 * Nicolas Boichat, April 2004
11 Bacula® - The Network Backup Solution
13 Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
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
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.
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
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.
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.
47 #include "wxbtreectrl.h"
50 #include "wxbmainframe.h"
52 BEGIN_EVENT_TABLE(wxbTreeCtrl, wxTreeCtrl)
53 EVT_LEFT_DCLICK(wxbTreeCtrl::OnDoubleClicked)
54 EVT_RIGHT_DOWN(wxbTreeCtrl::OnRightClicked)
57 DEFINE_LOCAL_EVENT_TYPE(wxbTREE_MARKED_EVENT)
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;
65 wxbTreeCtrl::~wxbTreeCtrl() {}
68 * Send mark event if the user double-clicked on the icon.
70 void wxbTreeCtrl::OnDoubleClicked(wxMouseEvent& event) {
72 wxTreeItemId treeid = HitTest(event.GetPosition(), flags);
73 if ((flags & wxTREE_HITTEST_ONITEMICON) && (treeid.IsOk())) {
74 wxbTreeMarkedEvent evt(GetId(), treeid);
76 handler->ProcessEvent(evt);
78 //No Skip : we don't want this item to be collapsed or expanded
86 * Send mark event if the user right clicked on an item.
88 void wxbTreeCtrl::OnRightClicked(wxMouseEvent& event) {
90 wxTreeItemId treeid = HitTest(event.GetPosition(), flags);
92 wxbTreeMarkedEvent evt(GetId(), treeid);
94 handler->ProcessEvent(evt);
99 /* Customized tree event, used for marking events */
101 wxbTreeMarkedEvent::wxbTreeMarkedEvent(int id, wxTreeItemId& item): wxEvent(id, wxbTREE_MARKED_EVENT) {
105 wxbTreeMarkedEvent::~wxbTreeMarkedEvent() {}
107 wxbTreeMarkedEvent::wxbTreeMarkedEvent(const wxbTreeMarkedEvent& te): wxEvent(te) {
108 this->item = te.item;
111 wxEvent *wxbTreeMarkedEvent::Clone() const {
112 return new wxbTreeMarkedEvent(*(this));
115 wxTreeItemId wxbTreeMarkedEvent::GetItem() {