#
CONSSRCS = main.cpp console_thread.cpp authenticate.c console_conf.c wxbrestorepanel.cpp \
- wxbmainframe.cpp wxbtableparser.cpp wxbtreectrl.cpp
+ wxbmainframe.cpp wxbtableparser.cpp wxbtreectrl.cpp wxblistctrl.cpp
CONSOBJS = main.o console_thread.o authenticate.o console_conf.o wxbrestorepanel.o \
- wxbmainframe.o wxbtableparser.o wxbtreectrl.o
+ wxbmainframe.o wxbtableparser.o wxbtreectrl.o wxblistctrl.o
@if test "@DISTNAME@" = "cygwin" then \
RES = wx-console_private.res; \
--- /dev/null
+/*
+ *
+ * Custom tree control, which send "tree marked" events when the user right-
+ * click on a item, or double-click on a mark.
+ *
+ * Nicolas Boichat, April 2004
+ *
+ */
+/*
+ Copyright (C) 2004 Kern Sibbald and John Walker
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "wxblistctrl.h"
+
+#include "csprint.h"
+#include "wxbmainframe.h"
+
+BEGIN_EVENT_TABLE(wxbListCtrl, wxListCtrl)
+ EVT_LEFT_DCLICK(wxbListCtrl::OnDoubleClicked)
+ EVT_RIGHT_DOWN(wxbListCtrl::OnRightClicked)
+END_EVENT_TABLE()
+
+DEFINE_LOCAL_EVENT_TYPE(wxbLIST_MARKED_EVENT)
+
+wxbListCtrl::wxbListCtrl(
+ wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size):
+ wxListCtrl(parent, id, pos, size,wxLC_REPORT) {
+}
+
+wxbListCtrl::~wxbListCtrl() {}
+
+/*
+ * Send mark event if the user double-clicked on the icon.
+ */
+void wxbListCtrl::OnDoubleClicked(wxMouseEvent& event) {
+ if (event.GetX() < GetColumnWidth(0)) {
+ wxbListMarkedEvent evt(GetId());
+
+ GetParent()->GetEventHandler()->ProcessEvent(evt);
+
+ //No Skip : we don't want to go in this directory (if it is a directory)
+ }
+ else {
+ event.Skip();
+ }
+}
+
+/*
+ * Send mark event if the user right clicked on an item.
+ */
+void wxbListCtrl::OnRightClicked(wxMouseEvent& event) {
+ if (event.GetX() < GetColumnWidth(0)) {
+ wxbListMarkedEvent evt(GetId());
+
+ GetParent()->GetEventHandler()->ProcessEvent(evt);
+ }
+ event.Skip();
+}
+
+/* Customized tree event, used for marking events */
+
+wxbListMarkedEvent::wxbListMarkedEvent(int id): wxEvent(id, wxbLIST_MARKED_EVENT) {}
+
+wxbListMarkedEvent::~wxbListMarkedEvent() {}
+
+wxbListMarkedEvent::wxbListMarkedEvent(const wxbListMarkedEvent& te): wxEvent(te) {}
+
+wxEvent *wxbListMarkedEvent::Clone() const {
+ return new wxbListMarkedEvent(*(this));
+}
--- /dev/null
+/*
+ *
+ * Custom list control, which send "list marked" events when the user right-
+ * click on a item, or double-click on a mark.
+ *
+ * Nicolas Boichat, April 2004
+ *
+ */
+/*
+ Copyright (C) 2004 Kern Sibbald and John Walker
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef WXBLISTCTRL_H
+#define WXBLISTCTRL_H
+
+#include "wx/wxprec.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include <wx/listctrl.h>
+
+BEGIN_DECLARE_EVENT_TYPES()
+ DECLARE_LOCAL_EVENT_TYPE(wxbLIST_MARKED_EVENT, 1)
+END_DECLARE_EVENT_TYPES()
+
+/* Customized list event, used for marking events */
+class wxbListMarkedEvent: public wxEvent {
+ public:
+ wxbListMarkedEvent(int id);
+ ~wxbListMarkedEvent();
+ wxbListMarkedEvent(const wxbListMarkedEvent& te);
+ virtual wxEvent *Clone() const;
+
+};
+
+typedef void (wxEvtHandler::*wxListMarkedEventFunction)(wxbListMarkedEvent&);
+
+#define EVT_LIST_MARKED_EVENT(id, fn) \
+ DECLARE_EVENT_TABLE_ENTRY( \
+ wxbLIST_MARKED_EVENT, id, wxID_ANY, \
+ (wxObjectEventFunction)(wxEventFunction)(wxListMarkedEventFunction)&fn, \
+ (wxObject *) NULL \
+ ),
+
+/* Customized list, which transmit double clicks on images */
+class wxbListCtrl: public wxListCtrl {
+ public:
+ wxbListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
+ ~wxbListCtrl();
+
+ private:
+ void OnDoubleClicked(wxMouseEvent& event);
+ void OnRightClicked(wxMouseEvent& event);
+
+ DECLARE_EVENT_TABLE();
+};
+
+#endif // WXBTREECTRL_H
+
EVT_LIST_ITEM_ACTIVATED(ListCtrl, wxbRestorePanel::OnListActivated)
EVT_TREE_MARKED_EVENT(wxID_ANY, wxbRestorePanel::OnTreeMarked)
- EVT_LIST_ITEM_RIGHT_CLICK(ListCtrl, wxbRestorePanel::OnListRightClicked)
+ EVT_LIST_MARKED_EVENT(wxID_ANY, wxbRestorePanel::OnListMarked)
EVT_CHOICE(ClientChoice, wxbRestorePanel::OnClientChoiceChanged)
END_EVENT_TABLE()
tree->SetImageList(imagelist);
- list = new wxListCtrl(this, ListCtrl, wxDefaultPosition, wxDefaultSize, wxLC_REPORT);
+ list = new wxbListCtrl(this, ListCtrl, wxDefaultPosition, wxDefaultSize);
secondSizer->Add(list, 1, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 10);
list->SetImageList(imagelist, wxIMAGE_LIST_SMALL);
}
else if (status == entered) {
if (jobChoice->GetStringSelection().Length() < 1) {
- wxbMainFrame::GetInstance()->SetStatusText("Please select a client.\n");
+ wxbMainFrame::GetInstance()->SetStatusText("Please select a client.");
return;
}
WaitForEnd("restore\n");
wxTreeItemId root = tree->AddRoot(clientChoice->GetStringSelection(), -1, -1, new wxbTreeItemData("/", clientChoice->GetStringSelection(), 0));
tree->Refresh();
WaitForList(root, true);
- wxbMainFrame::GetInstance()->SetStatusText("Right click on a file or on a directory to add it to the restore list.\n");
+ wxbMainFrame::GetInstance()->SetStatusText("Right click on a file or on a directory, or double-click on its mark to add it to the restore list.");
tree->Expand(root);
}
else if (status == choosing) {
setStatus(restoring);
- wxbMainFrame::GetInstance()->SetStatusText("Restoring, please wait...\n");
+ wxbMainFrame::GetInstance()->SetStatusText("Restoring, please wait...");
totfilemessages = 0;
WaitForEnd("estimate\n");
if (totfilemessages == 0) {
wxbMainFrame::GetInstance()->Print("Restore failed : no file selected.\n", CS_DEBUG);
- wxbMainFrame::GetInstance()->SetStatusText("Restore failed : no file selected.\n");
+ wxbMainFrame::GetInstance()->SetStatusText("Restore failed : no file selected.");
setStatus(finished);
return;
}
WaitForEnd("messages\n");
- wxbMainFrame::GetInstance()->SetStatusText(wxString("Restoring, please wait (") << filemessages << " of " << totfilemessages << " files done)...\n");
+ wxbMainFrame::GetInstance()->SetStatusText(wxString("Restoring, please wait (") << filemessages << " of " << totfilemessages << " files done)...");
time_t start = wxDateTime::Now().GetTicks();
while (((wxDateTime::Now().GetTicks())-start) < 3) {
if ((*tableParser)[0][7] == "T") {
wxbMainFrame::GetInstance()->Print("Restore done successfully.\n", CS_DEBUG);
- wxbMainFrame::GetInstance()->SetStatusText("Restore done successfully.\n");
+ wxbMainFrame::GetInstance()->SetStatusText("Restore done successfully.");
}
else {
wxbMainFrame::GetInstance()->Print("Restore failed, please look at messages.\n", CS_DEBUG);
- wxbMainFrame::GetInstance()->SetStatusText("Restore failed, please look at messages in console.\n");
+ wxbMainFrame::GetInstance()->SetStatusText("Restore failed, please look at messages in console.");
}
setStatus(finished);
}
working = false;
}
-void wxbRestorePanel::OnListRightClicked(wxListEvent& event) {
+void wxbRestorePanel::OnListMarked(wxbListMarkedEvent& event) {
if (working) {
event.Skip();
return;
}
working = true;
+ //long item = event.GetId();
long item = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
CmdMark(wxTreeItemId(), item);
event.Skip();
#include "wxbpanel.h"
#include "wxbtreectrl.h"
+#include "wxblistctrl.h"
/*
* wxbPanel for restoring files
void OnTreeExpanding(wxTreeEvent& event);
void OnTreeChanged(wxTreeEvent& event);
void OnTreeMarked(wxbTreeMarkedEvent& event);
- void OnListRightClicked(wxListEvent& event);
+ void OnListMarked(wxbListMarkedEvent& event);
void OnListActivated(wxListEvent& event);
void OnClientChoiceChanged(wxCommandEvent& event);
wxChoice* clientChoice;
wxChoice* jobChoice;
wxbTreeCtrl* tree;
- wxListCtrl* list;
+ wxbListCtrl* list;
wxGauge* gauge;
DECLARE_EVENT_TABLE();