]> git.sur5r.net Git - bacula/bacula/commitdiff
- Mark files and dirs without reasking the list to the director.
authorNicolas Boichat <nicolas@boichat.ch>
Thu, 15 Apr 2004 23:22:27 +0000 (23:22 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Thu, 15 Apr 2004 23:22:27 +0000 (23:22 +0000)
- Allow double-click to mark dirs.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1209 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/CHANGELOG
bacula/src/wx-console/TODO
bacula/src/wx-console/wxbrestorepanel.cpp
bacula/src/wx-console/wxbrestorepanel.h
bacula/src/wx-console/wxbtreectrl.cpp [new file with mode: 0644]
bacula/src/wx-console/wxbtreectrl.h [new file with mode: 0644]

index 041464d4aaf14e1e9dc9a54b02a0c8eafe7b32fb..837f7b3b81c4904869758c0f238221a0eefcbcb7 100644 (file)
@@ -1,3 +1,11 @@
+16-04-2004 :
+ - wxbRestorePanel : Allow the user to change the status by double-clicking on the check mark
+
+15-04-2004 :
+ - project renamed in wx-console
+ - console_thread : Uses wx-console.conf instead of console.conf
+ - wxbRestorePanel : Change the marked state without redoing a dir
+
 12-04-2004 :
  - The source code is now better documented
  - wxbRestorePanel : Check if a client was selected before
index a1c5b3157be06064ed99abd4075f469c5adfa290..a689181706e23835dc75f3351e0851f918a4b8eb 100644 (file)
@@ -2,7 +2,10 @@ wxbRestorePanel : Add buttons to mark/unmark directories/files.
 
 wxbRestorePanel : Allow the user to choose where he wants to restore his files
 
-wxbPanel/wxbMainFrame : Add a locking function (for example, deny the user to type something in the console when a restore is in progress)
+wxbRestorePanel : Add a button to force the refreshing of the whole tree
+
+wxbPanel/wxbMainFrame : Add a locking function (for example, deny the user 
+               to type something in the console when a restore is in progress)
 
 wxbRestorePanel : Check more carefully which job we just have run.
 
@@ -14,8 +17,4 @@ general : create a class like wxbtableparser, which fetches commands results
 
 win32 : do a static build
 
-(old build params : )
--lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid 
--lkernel32 -lcomdlg32 -lgdi32 -lrpcrt4 -luser32 -lz
-
--fno-pcc-struct-return -Os -fno-rtti -fno-exceptions
+win32 : correct Makefile.in to use ressource file
index 1ab4efb3950af8b9eea7c3428ab9d0b9e4769b5c..77b18f632df879cb7959a5e2b866e15a36ec42a8 100644 (file)
  */
 class wxbTreeItemData : public wxTreeItemData {
    public:
-      wxbTreeItemData(wxString path, wxString name, int marked);
-      wxbTreeItemData(wxString path, wxString name, wxString marked);
+      wxbTreeItemData(wxString path, wxString name, int marked, long listid = -1);
+      wxbTreeItemData(wxString path, wxString name, wxString marked, long listid = -1);
       ~wxbTreeItemData();
       wxString GetPath();
       wxString GetName();
-      //wxbTreeItemData* GetChild(wxString dirname);
+            
       int GetMarked();
       void SetMarked(int marked);
       void SetMarked(wxString marked);
+      
+      long GetListId();
 
       static int GetMarkedStatus(wxString file);
    private:
       wxString* path; /* Full path */
       wxString* name; /* File name */
       int marked; /* 0 - Not Marked, 1 - Marked, 2 - Some file under is marked */
+      long listid; /* list ID : >-1 if this data is in the list (and/or on the tree) */
 };
 
-wxbTreeItemData::wxbTreeItemData(wxString path, wxString name, int marked): wxTreeItemData() {
+wxbTreeItemData::wxbTreeItemData(wxString path, wxString name, int marked, long listid): wxTreeItemData() {
    this->path = new wxString(path);
    this->name = new wxString(name);
    this->marked = marked;
+   this->listid = listid;
 }
 
-wxbTreeItemData::wxbTreeItemData(wxString path, wxString name, wxString marked): wxTreeItemData() {
+wxbTreeItemData::wxbTreeItemData(wxString path, wxString name, wxString marked, long listid): wxTreeItemData() {
    this->path = new wxString(path);
    this->name = new wxString(name);
    SetMarked(marked);
+   this->listid = listid;
 }
 
 wxbTreeItemData::~wxbTreeItemData() {
@@ -89,6 +94,10 @@ void wxbTreeItemData::SetMarked(int marked) {
    this->marked = marked;
 }
 
+long wxbTreeItemData::GetListId() {
+   return listid;
+}
+
 wxString wxbTreeItemData::GetPath() {
    return *path;
 }
@@ -133,9 +142,11 @@ BEGIN_EVENT_TABLE(wxbRestorePanel, wxPanel)
    EVT_TREE_SEL_CHANGING(TreeCtrl, wxbRestorePanel::OnTreeChanging)
    EVT_TREE_SEL_CHANGED(TreeCtrl, wxbRestorePanel::OnTreeChanged)
    EVT_TREE_ITEM_EXPANDING(TreeCtrl, wxbRestorePanel::OnTreeExpanding)
-   EVT_TREE_ITEM_RIGHT_CLICK(TreeCtrl, wxbRestorePanel::OnTreeRightClicked)
-   EVT_LIST_ITEM_RIGHT_CLICK(ListCtrl, wxbRestorePanel::OnListRightClicked)
    EVT_LIST_ITEM_ACTIVATED(ListCtrl, wxbRestorePanel::OnListActivated)
+
+   EVT_TREE_MARKED_EVENT(wxID_ANY, wxbRestorePanel::OnTreeMarked)
+   EVT_LIST_ITEM_RIGHT_CLICK(ListCtrl, wxbRestorePanel::OnListRightClicked)   
+  
    EVT_CHOICE(ClientChoice, wxbRestorePanel::OnClientChoiceChanged)
 END_EVENT_TABLE()
 
@@ -169,7 +180,7 @@ wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) {
 
    wxFlexGridSizer *secondSizer = new wxFlexGridSizer(1, 2, 10, 10);
 
-   tree = new wxTreeCtrl(this, TreeCtrl, wxDefaultPosition, wxSize(250, 10));
+   tree = new wxbTreeCtrl(this, TreeCtrl, wxDefaultPosition, wxSize(200,50));
    secondSizer->Add(tree, 1, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 10);
 
    tree->SetImageList(imagelist);
@@ -263,39 +274,42 @@ void wxbRestorePanel::Print(wxString str, int stat) {
       if (file == NULL)
             return;
 
+      wxTreeItemId treeid;
+
       if (file[8].GetChar(file[8].Length()-1) == '/') {
          wxString itemStr;
 
          long cookie;
-         wxTreeItemId currentChild = tree->GetFirstChild(currentTreeItem, cookie);
+         treeid = tree->GetFirstChild(currentTreeItem, cookie);
 
          bool updated = false;
 
-         while (currentChild.IsOk()) {
-            itemStr = tree->GetItemText(currentChild);
+         while (treeid.IsOk()) {
+            itemStr = tree->GetItemText(treeid);
             if (file[8] == itemStr) {
                int stat = wxbTreeItemData::GetMarkedStatus(file[6]);
-               if (static_cast<wxbTreeItemData*>(tree->GetItemData(currentChild))->GetMarked() != stat) {
-                  tree->SetItemImage(currentChild, stat, wxTreeItemIcon_Normal);
-                  tree->SetItemImage(currentChild, stat, wxTreeItemIcon_Selected);
-                  static_cast<wxbTreeItemData*>(tree->GetItemData(currentChild))->SetMarked(file[6]);
+               if (static_cast<wxbTreeItemData*>(tree->GetItemData(treeid))->GetMarked() != stat) {
+                  tree->SetItemImage(treeid, stat, wxTreeItemIcon_Normal);
+                  tree->SetItemImage(treeid, stat, wxTreeItemIcon_Selected);
+                  static_cast<wxbTreeItemData*>(tree->GetItemData(treeid))->SetMarked(file[6]);
                }
                updated = true;
                break;
             }
-            currentChild = tree->GetNextChild(currentTreeItem, cookie);
+            treeid = tree->GetNextChild(currentTreeItem, cookie);
          }
 
          if (!updated) {
             int img = wxbTreeItemData::GetMarkedStatus(file[6]);
-            tree->AppendItem(currentTreeItem, file[8], img, img, new wxbTreeItemData(file[7], file[8], file[6]));
+            treeid = tree->AppendItem(currentTreeItem, file[8], img, img, new wxbTreeItemData(file[7], file[8], file[6]));
          }
       }
 
       if (updatelist) {
          long ind = list->InsertItem(list->GetItemCount(), wxbTreeItemData::GetMarkedStatus(file[6]));
-         long data = (long)(new wxbTreeItemData(file[7], file[8], file[6]));
-         list->SetItemData(ind, data);
+         wxbTreeItemData* data = new wxbTreeItemData(file[7], file[8], file[6], ind);
+         data->SetId(treeid);
+         list->SetItemData(ind, (long)data);
          list->SetItem(ind, 1, file[8]); // filename
          list->SetItem(ind, 2, file[4]); //Size
          list->SetItem(ind, 3, file[5]); //date
@@ -561,71 +575,26 @@ void wxbRestorePanel::CmdMark(wxTreeItemId treeitem, long listitem) {
       WaitForEnd(wxString("cd ") << dir << "\n");
       WaitForEnd(wxString((itemdata->GetMarked() == 1) ? "unmark " : "mark ") << file << "\n");
 
-      if ((dir == "/") && (file == "*")) {
+      /*if ((dir == "/") && (file == "*")) {
             itemdata->SetMarked((itemdata->GetMarked() == 1) ? 0 : 1);
-      }
+      }*/
 
-      if (listitem != -1) {
-         treeitem = tree->GetSelection();
+      if (listitem == -1) { /* tree item state changed */
+         SetTreeItemState(treeitem, (itemdata->GetMarked() == 1) ? 0 : 1);
+         /*treeitem = tree->GetSelection();
          UpdateTree(treeitem, true);
-         treeitem = tree->GetItemParent(treeitem);
+         treeitem = tree->GetItemParent(treeitem);*/
       }
       else {
-         UpdateTree(treeitem, (tree->GetSelection() == treeitem));
-         treeitem = tree->GetItemParent(treeitem);
+         SetListItemState(listitem, (itemdata->GetMarked() == 1) ? 0 : 1);
+         /*UpdateTree(treeitem, (tree->GetSelection() == treeitem));
+         treeitem = tree->GetItemParent(treeitem);*/
       }
 
-      while (treeitem.IsOk()) {
+      /*while (treeitem.IsOk()) {
          WaitForList(treeitem, false);
          treeitem = tree->GetItemParent(treeitem);
-      }
-      
-      /* Update root marked status */
-      treeitem = tree->GetRootItem();
-      long cookie;
-      wxTreeItemId currentChild = tree->GetFirstChild(treeitem, cookie);
-
-      bool onechildmarked = false;
-      bool onechildunmarked = false;
-
-      while (currentChild.IsOk()) {
-         itemdata = (wxbTreeItemData*)tree->GetItemData(currentChild);
-         switch (itemdata->GetMarked()) {
-         case 0:
-            onechildunmarked = true;
-            break;
-         case 1:
-            onechildmarked = true;
-            break;
-         case 2:
-            onechildmarked = true;
-            onechildunmarked = true;
-            break;
-         }
-         
-         if (onechildmarked && onechildunmarked) {
-            break;
-         }
-         
-         currentChild = tree->GetNextChild(treeitem, cookie);
-      }
-      
-      itemdata = (wxbTreeItemData*)tree->GetItemData(treeitem);
-      if (onechildmarked && onechildunmarked) {
-         itemdata->SetMarked(2);
-         tree->SetItemImage(treeitem, 2, wxTreeItemIcon_Normal);
-         tree->SetItemImage(treeitem, 2, wxTreeItemIcon_Selected);
-      }
-      else if (onechildmarked) {
-         itemdata->SetMarked(1);
-         tree->SetItemImage(treeitem, 1, wxTreeItemIcon_Normal);
-         tree->SetItemImage(treeitem, 1, wxTreeItemIcon_Selected);
-      }
-      else {
-         itemdata->SetMarked(0);
-         tree->SetItemImage(treeitem, 0, wxTreeItemIcon_Normal);
-         tree->SetItemImage(treeitem, 0, wxTreeItemIcon_Selected);
-      }
+      }*/
    }
 }
 
@@ -715,20 +684,164 @@ wxString* wxbRestorePanel::ParseList(wxString line) {
    return ret;
 }
 
-/* Update a tree item, and all its childs. */
-void wxbRestorePanel::UpdateTree(wxTreeItemId item, bool updatelist) {
-   WaitForList(item, updatelist);
+/* Sets a list item state, and update its parents and children if it is a directory */
+void wxbRestorePanel::SetListItemState(long listitem, int newstate) {
+   wxbTreeItemData* itemdata = (wxbTreeItemData*)list->GetItemData(listitem);
+   
+   wxTreeItemId treeitem;
+   
+   itemdata->SetMarked(newstate);
+   list->SetItemImage(listitem, newstate, 0); /* TODO: Find what these ints are for */
+   list->SetItemImage(listitem, newstate, 1);
+      
+   if ((treeitem = itemdata->GetId()).IsOk()) {
+      SetTreeItemState(treeitem, newstate);
+   }
+   else {
+      UpdateTreeItemState(tree->GetSelection());
+   }
+}
 
-   /* Updated all child which are not collapsed */
+/* Sets a tree item state, and update its children, parents and list (if necessary) */
+void wxbRestorePanel::SetTreeItemState(wxTreeItemId item, int newstate) {
    long cookie;
    wxTreeItemId currentChild = tree->GetFirstChild(item, cookie);
 
+   bool onechildmarked = false;
+   bool onechildunmarked = false;
+
+   wxbTreeItemData* itemdata;
+
+   while (currentChild.IsOk()) {
+      itemdata = (wxbTreeItemData*)tree->GetItemData(currentChild);
+      int state = itemdata->GetMarked();
+      
+      if (state != newstate) {
+         itemdata->SetMarked(newstate);
+         tree->SetItemImage(currentChild, newstate, wxTreeItemIcon_Normal);
+         tree->SetItemImage(currentChild, newstate, wxTreeItemIcon_Selected);
+      }
+      
+      currentChild = tree->GetNextChild(item, cookie);
+   }
+     
+   itemdata = (wxbTreeItemData*)tree->GetItemData(item);  
+   itemdata->SetMarked(newstate);
+   tree->SetItemImage(item, newstate, wxTreeItemIcon_Normal);
+   tree->SetItemImage(item, newstate, wxTreeItemIcon_Selected);
+   tree->Refresh();
+   
+   if (tree->GetSelection() == item) {
+      for (long i = 0; i < list->GetItemCount(); i++) {
+         list->SetItemImage(i, newstate, 0); /* TODO: Find what these ints are for */
+         list->SetItemImage(i, newstate, 1);
+      }
+   }
+   
+   UpdateTreeItemState(tree->GetParent(item));
+}
+
+/* Update a tree item state, and its parents' state */
+void wxbRestorePanel::UpdateTreeItemState(wxTreeItemId item) {  
+   if (!item.IsOk()) {
+      return;
+   }
+   
+   int state = 0;
+       
+   long cookie;
+   wxTreeItemId currentChild = tree->GetFirstChild(item, cookie);
+
+   bool onechildmarked = false;
+   bool onechildunmarked = false;
+
+   while (currentChild.IsOk()) {
+      state = ((wxbTreeItemData*)tree->GetItemData(currentChild))->GetMarked();
+      switch (state) {
+      case 0:
+         onechildunmarked = true;
+         break;
+      case 1:
+         onechildmarked = true;
+         break;
+      case 2:
+         onechildmarked = true;
+         onechildunmarked = true;
+         break;
+      }
+      
+      if (onechildmarked && onechildunmarked) {
+         break;
+      }
+      
+      currentChild = tree->GetNextChild(item, cookie);
+   }
+   
+   if (tree->GetSelection() == item) {
+      for (long i = 0; i < list->GetItemCount(); i++) {
+         state = ((wxbTreeItemData*)list->GetItemData(i))->GetMarked();
+         
+         switch (state) {
+         case 0:
+            onechildunmarked = true;
+            break;
+         case 1:
+            onechildmarked = true;
+            break;
+         case 2:
+            onechildmarked = true;
+            onechildunmarked = true;
+            break;
+         }
+         
+         if (onechildmarked && onechildunmarked) {
+            break;
+         }
+      }
+   }
+   
+   state = 0;
+   
+   if (onechildmarked && onechildunmarked) {
+      state = 2;
+   }
+   else if (onechildmarked) {
+      state = 1;
+   }
+   else if (onechildunmarked) {
+      state = 0;
+   }
+   else { // no child, don't change anything
+      UpdateTreeItemState(tree->GetParent(item));
+      return;
+   }
+   
+   wxbTreeItemData* itemdata = (wxbTreeItemData*)tree->GetItemData(item);
+      
+   itemdata->SetMarked(state);
+   tree->SetItemImage(item, state, wxTreeItemIcon_Normal);
+   tree->SetItemImage(item, state, wxTreeItemIcon_Selected);
+   
+   UpdateTreeItemState(tree->GetParent(item));
+}
+
+/* 
+ * Refresh a tree item, and all its childs, 
+ * by asking the director for new lists 
+ */
+void wxbRestorePanel::RefreshTree(wxTreeItemId item) {
+/*   WaitForList(item, updatelist);
+
+   /* Update all child which are not collapsed */
+/*   long cookie;
+   wxTreeItemId currentChild = tree->GetFirstChild(item, cookie);
+
    while (currentChild.IsOk()) {
       if (tree->IsExpanded(currentChild))
          UpdateTree(currentChild, false);
 
       currentChild = tree->GetNextChild(item, cookie);
-   }
+   }*/
 }
 
 /*----------------------------------------------------------------------------
@@ -838,14 +951,15 @@ void wxbRestorePanel::OnTreeChanged(wxTreeEvent& event) {
    working = false;
 }
 
-void wxbRestorePanel::OnTreeRightClicked(wxTreeEvent& event) {
+void wxbRestorePanel::OnTreeMarked(wxbTreeMarkedEvent& event) {
+   //wxbMainFrame::GetInstance()->Print(wxString("MARKED\n"), CS_DEBUG);
    if (working) {
-      event.Skip();
+      //event.Skip();
       return;
    }
    working = true;
    CmdMark(event.GetItem(), -1);
-   event.Skip();
+   //event.Skip();
    tree->Refresh();
    working = false;
 }
@@ -898,3 +1012,4 @@ void wxbRestorePanel::OnListActivated(wxListEvent& event) {
    }
    working = false;
 }
+
index da335f59d21bfbca628992be2403d68866ba1eb3..3e1fdcd2e549baee2f7d6444013841b3932106f5 100644 (file)
@@ -34,6 +34,8 @@
 
 #include "wxbpanel.h"
 
+#include "wxbtreectrl.h"
+
 /*
  * wxbPanel for restoring files
  */
@@ -87,8 +89,17 @@ class wxbRestorePanel : public wxbPanel
       /* Parse dir command results. */
       wxString* ParseList(wxString line);
 
-      /* Update a tree item, and all its childs. */
-      void UpdateTree(wxTreeItemId item, bool updatelist);
+      /* Sets a list item state, and update its parents and children if it is a directory */
+      void SetListItemState(long listitem, int newstate);
+
+      /* Sets a tree item state, and update its children, parents and list (if necessary) */
+      void SetTreeItemState(wxTreeItemId item, int newstate);
+      
+      /* Update a tree item parents' state */
+      void UpdateTreeItemState(wxTreeItemId item);
+
+      /* Refresh a tree item, and all its children. */
+      void RefreshTree(wxTreeItemId item);
 
 /* Status related */
       enum status_enum
@@ -115,7 +126,7 @@ class wxbRestorePanel : public wxbPanel
       void OnTreeChanging(wxTreeEvent& event);
       void OnTreeExpanding(wxTreeEvent& event);
       void OnTreeChanged(wxTreeEvent& event);
-      void OnTreeRightClicked(wxTreeEvent& event);
+      void OnTreeMarked(wxbTreeMarkedEvent& event);
       void OnListRightClicked(wxListEvent& event);
       void OnListActivated(wxListEvent& event);
       void OnClientChoiceChanged(wxCommandEvent& event);
@@ -126,7 +137,7 @@ class wxbRestorePanel : public wxbPanel
       wxButton* start;
       wxChoice* clientChoice;
       wxChoice* jobChoice;
-      wxTreeCtrl* tree;
+      wxbTreeCtrl* tree;
       wxListCtrl* list;
       wxGauge* gauge;
 
diff --git a/bacula/src/wx-console/wxbtreectrl.cpp b/bacula/src/wx-console/wxbtreectrl.cpp
new file mode 100644 (file)
index 0000000..b22242e
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ *
+ *   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 "wxbtreectrl.h"
+
+#include "csprint.h"
+#include "wxbmainframe.h"
+
+BEGIN_EVENT_TABLE(wxbTreeCtrl, wxTreeCtrl)
+   EVT_LEFT_DCLICK(wxbTreeCtrl::OnDoubleClicked)
+   EVT_RIGHT_DOWN(wxbTreeCtrl::OnRightClicked)
+END_EVENT_TABLE()
+
+DEFINE_LOCAL_EVENT_TYPE(wxbTREE_MARKED_EVENT)
+
+wxbTreeCtrl::wxbTreeCtrl(
+      wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size): 
+            wxTreeCtrl(parent, id, pos, size) {
+   marked = false;
+}
+
+wxbTreeCtrl::~wxbTreeCtrl() {}
+
+/* 
+ * Send mark event if the user double-clicked on the icon.
+ */
+void wxbTreeCtrl::OnDoubleClicked(wxMouseEvent& event) {
+   int flags;
+   wxTreeItemId treeid = HitTest(event.GetPosition(), flags);
+   if ((flags & wxTREE_HITTEST_ONITEMICON) && (treeid.IsOk())) {
+      wxbTreeMarkedEvent evt(GetId(), treeid);
+
+      GetParent()->GetEventHandler()->ProcessEvent(evt);
+      
+      //No Skip : we don't want this item to be collapsed or expanded
+   }
+   else {
+      event.Skip();
+   }
+}
+
+/* 
+ * Send mark event if the user right clicked on an item.
+ */
+void wxbTreeCtrl::OnRightClicked(wxMouseEvent& event) {
+   int flags;
+   wxTreeItemId treeid = HitTest(event.GetPosition(), flags);
+   if (treeid.IsOk()) {
+      wxbTreeMarkedEvent evt(GetId(), treeid);
+
+      bool res = GetParent()->GetEventHandler()->ProcessEvent(evt);
+   }
+   event.Skip();
+}
+
+/* Customized tree event, used for marking events */
+
+wxbTreeMarkedEvent::wxbTreeMarkedEvent(int id, wxTreeItemId& item): wxEvent(id, wxbTREE_MARKED_EVENT) {
+   this->item = item;
+}
+
+wxbTreeMarkedEvent::~wxbTreeMarkedEvent() {}
+
+wxbTreeMarkedEvent::wxbTreeMarkedEvent(const wxbTreeMarkedEvent& te): wxEvent(te) {
+   this->item = te.item;
+}
+
+wxEvent *wxbTreeMarkedEvent::Clone() const {
+   return new wxbTreeMarkedEvent(*(this));
+}
+
+wxTreeItemId wxbTreeMarkedEvent::GetItem() {
+   return item;
+}
diff --git a/bacula/src/wx-console/wxbtreectrl.h b/bacula/src/wx-console/wxbtreectrl.h
new file mode 100644 (file)
index 0000000..024e473
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ *
+ *   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.
+ */
+
+#ifndef WXBTREECTRL_H
+#define WXBTREECTRL_H
+
+#include "wx/wxprec.h"
+
+#ifndef WX_PRECOMP
+   #include "wx/wx.h"
+#endif
+
+#include <wx/treectrl.h>
+
+BEGIN_DECLARE_EVENT_TYPES()
+   DECLARE_LOCAL_EVENT_TYPE(wxbTREE_MARKED_EVENT,       1)
+END_DECLARE_EVENT_TYPES()
+
+/* Customized tree event, used for marking events */
+class wxbTreeMarkedEvent: public wxEvent {
+   public:
+      wxbTreeMarkedEvent(int id, wxTreeItemId& item);
+      ~wxbTreeMarkedEvent();
+      wxbTreeMarkedEvent(const wxbTreeMarkedEvent& te);
+      virtual wxEvent *Clone() const;
+      
+      wxTreeItemId GetItem();
+   private:
+      wxTreeItemId item;
+};
+
+typedef void (wxEvtHandler::*wxTreeMarkedEventFunction)(wxbTreeMarkedEvent&);
+
+#define EVT_TREE_MARKED_EVENT(id, fn) \
+    DECLARE_EVENT_TABLE_ENTRY( \
+        wxbTREE_MARKED_EVENT, id, wxID_ANY, \
+        (wxObjectEventFunction)(wxEventFunction)(wxTreeMarkedEventFunction)&fn, \
+        (wxObject *) NULL \
+    ),
+
+/* Customized tree, which transmit double clicks on images */
+class wxbTreeCtrl: public wxTreeCtrl {
+   public:
+      wxbTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
+      ~wxbTreeCtrl();
+      
+   private:
+      bool marked;
+   
+      void OnDoubleClicked(wxMouseEvent& event);
+      void OnRightClicked(wxMouseEvent& event);
+      
+      DECLARE_EVENT_TABLE();
+};
+
+#endif // WXBTREECTRL_H
+