]> git.sur5r.net Git - bacula/bacula/commitdiff
Added wxblistctrl, which allows the user to double-click on the mark in the list.
authorNicolas Boichat <nicolas@boichat.ch>
Fri, 16 Apr 2004 00:09:10 +0000 (00:09 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Fri, 16 Apr 2004 00:09:10 +0000 (00:09 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1211 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/Makefile.in
bacula/src/wx-console/wxblistctrl.cpp [new file with mode: 0644]
bacula/src/wx-console/wxblistctrl.h [new file with mode: 0644]
bacula/src/wx-console/wxbrestorepanel.cpp
bacula/src/wx-console/wxbrestorepanel.h

index 919f70431078172a2c7af3d4e47f01f169195079..08c058cf797a0a716cdad174adc94d1e860b46c5 100644 (file)
@@ -21,9 +21,9 @@ dummy:
 
 #
 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; \
diff --git a/bacula/src/wx-console/wxblistctrl.cpp b/bacula/src/wx-console/wxblistctrl.cpp
new file mode 100644 (file)
index 0000000..0034f06
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ *
+ *   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));
+}
diff --git a/bacula/src/wx-console/wxblistctrl.h b/bacula/src/wx-console/wxblistctrl.h
new file mode 100644 (file)
index 0000000..c069a4e
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ *
+ *   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
+
index 77b18f632df879cb7959a5e2b866e15a36ec42a8..a2268ea3662c58552a6829648143a6b4505547d2 100644 (file)
@@ -145,7 +145,7 @@ BEGIN_EVENT_TABLE(wxbRestorePanel, wxPanel)
    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()
@@ -185,7 +185,7 @@ wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) {
 
    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);
@@ -403,7 +403,7 @@ void wxbRestorePanel::CmdStart() {
    }
    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");
@@ -415,13 +415,13 @@ void wxbRestorePanel::CmdStart() {
       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");
@@ -429,7 +429,7 @@ void wxbRestorePanel::CmdStart() {
 
       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;
       }
@@ -455,7 +455,7 @@ void wxbRestorePanel::CmdStart() {
 
          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) {
@@ -469,11 +469,11 @@ void wxbRestorePanel::CmdStart() {
 
       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);
    }
@@ -964,12 +964,13 @@ void wxbRestorePanel::OnTreeMarked(wxbTreeMarkedEvent& event) {
    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();
index 3e1fdcd2e549baee2f7d6444013841b3932106f5..cc185ac4c67bdbc41ef8ef08ab2ecdb5881a44d8 100644 (file)
@@ -35,6 +35,7 @@
 #include "wxbpanel.h"
 
 #include "wxbtreectrl.h"
+#include "wxblistctrl.h"
 
 /*
  * wxbPanel for restoring files
@@ -127,7 +128,7 @@ class wxbRestorePanel : public wxbPanel
       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);
 
@@ -138,7 +139,7 @@ class wxbRestorePanel : public wxbPanel
       wxChoice* clientChoice;
       wxChoice* jobChoice;
       wxbTreeCtrl* tree;
-      wxListCtrl* list;
+      wxbListCtrl* list;
       wxGauge* gauge;
 
       DECLARE_EVENT_TABLE();