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