]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxblistctrl.cpp
kes wx-console crashes because of differences between Bacula and wxWidgets
[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-2006 Kern Sibbald
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    version 2 as amended with additional clauses defined in the
16    file LICENSE in the main source directory.
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    the file LICENSE for additional details.
22
23  */
24
25 #include "bacula.h"
26
27 #include "wxblistctrl.h"
28 #include "csprint.h"
29 #include "wxbmainframe.h"
30
31 BEGIN_EVENT_TABLE(wxbListCtrl, wxListCtrl)
32    EVT_LEFT_DCLICK(wxbListCtrl::OnDoubleClicked)
33    EVT_RIGHT_DOWN(wxbListCtrl::OnRightClicked)
34 END_EVENT_TABLE()
35
36 DEFINE_LOCAL_EVENT_TYPE(wxbLIST_MARKED_EVENT)
37
38 wxbListCtrl::wxbListCtrl(
39       wxWindow* parent, wxEvtHandler* handler, wxWindowID id, const wxPoint& pos, const wxSize& size): 
40             wxListCtrl(parent, id, pos, size, wxLC_REPORT | wxSUNKEN_BORDER) {
41    this->handler = handler;
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       handler->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    handler->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 }