]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxblistctrl.cpp
Some Win32 fixes
[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, wxEvtHandler* handler, wxWindowID id, const wxPoint& pos, const wxSize& size): 
41             wxListCtrl(parent, id, pos, size, wxLC_REPORT | wxSUNKEN_BORDER) {
42    this->handler = handler;
43 }
44
45 wxbListCtrl::~wxbListCtrl() {}
46
47 /* 
48  * Send mark event if the user double-clicked on the icon.
49  */
50 void wxbListCtrl::OnDoubleClicked(wxMouseEvent& event) {
51    if (event.GetX() < GetColumnWidth(0)) {
52       wxbListMarkedEvent evt(GetId());
53
54       handler->ProcessEvent(evt);
55       
56       //No Skip : we don't want to go in this directory (if it is a directory)
57    }
58    else {
59       event.Skip();
60    }
61 }
62
63 /* 
64  * Send mark event if the user right clicked on an item.
65  */
66 void wxbListCtrl::OnRightClicked(wxMouseEvent& event) {
67    wxbListMarkedEvent evt(GetId());
68
69    handler->ProcessEvent(evt);
70 }
71
72 /* Customized tree event, used for marking events */
73
74 wxbListMarkedEvent::wxbListMarkedEvent(int id): wxEvent(id, wxbLIST_MARKED_EVENT) {}
75
76 wxbListMarkedEvent::~wxbListMarkedEvent() {}
77
78 wxbListMarkedEvent::wxbListMarkedEvent(const wxbListMarkedEvent& te): wxEvent(te) {}
79
80 wxEvent *wxbListMarkedEvent::Clone() const {
81    return new wxbListMarkedEvent(*(this));
82 }