]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxblistctrl.cpp
f74755c82a40a0fe90282f2fd3fe515baef81e20
[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  */
9 /*
10    Copyright (C) 2004 Kern Sibbald and John Walker
11
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License
14    as published by the Free Software Foundation; either version 2
15    of the License, or (at your option) any later version.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20    GNU General Public License for more details.
21
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #include "wxblistctrl.h"
28
29 #include "csprint.h"
30 #include "wxbmainframe.h"
31
32 BEGIN_EVENT_TABLE(wxbListCtrl, wxListCtrl)
33    EVT_LEFT_DCLICK(wxbListCtrl::OnDoubleClicked)
34    EVT_RIGHT_DOWN(wxbListCtrl::OnRightClicked)
35 END_EVENT_TABLE()
36
37 DEFINE_LOCAL_EVENT_TYPE(wxbLIST_MARKED_EVENT)
38
39 wxbListCtrl::wxbListCtrl(
40       wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size): 
41             wxListCtrl(parent, id, pos, size, wxLC_REPORT | wxSUNKEN_BORDER) {
42 }
43
44 wxbListCtrl::~wxbListCtrl() {}
45
46 /* 
47  * Send mark event if the user double-clicked on the icon.
48  */
49 void wxbListCtrl::OnDoubleClicked(wxMouseEvent& event) {
50    if (event.GetX() < GetColumnWidth(0)) {
51       wxbListMarkedEvent evt(GetId());
52
53       GetParent()->GetEventHandler()->ProcessEvent(evt);
54       
55       //No Skip : we don't want to go in this directory (if it is a directory)
56    }
57    else {
58       event.Skip();
59    }
60 }
61
62 /* 
63  * Send mark event if the user right clicked on an item.
64  */
65 void wxbListCtrl::OnRightClicked(wxMouseEvent& event) {
66    wxbListMarkedEvent evt(GetId());
67
68    GetParent()->GetEventHandler()->ProcessEvent(evt);
69 }
70
71 /* Customized tree event, used for marking events */
72
73 wxbListMarkedEvent::wxbListMarkedEvent(int id): wxEvent(id, wxbLIST_MARKED_EVENT) {}
74
75 wxbListMarkedEvent::~wxbListMarkedEvent() {}
76
77 wxbListMarkedEvent::wxbListMarkedEvent(const wxbListMarkedEvent& te): wxEvent(te) {}
78
79 wxEvent *wxbListMarkedEvent::Clone() const {
80    return new wxbListMarkedEvent(*(this));
81 }