#include "marked.xpm"
#include "partmarked.xpm"
+#include <wx/listimpl.cpp>
+
/* A macro named Yield is defined under MinGW */
#undef Yield
+WX_DEFINE_LIST(wxbEventList);
+
/*
* Class which is stored in the tree and in the list to keep informations
* about the element.
* wxbRestorePanel constructor
*/
wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) {
+ //pendingEvents = new wxbEventList(); //EVTQUEUE
+ //processing = false; //EVTQUEUE
+ SetWorking(false);
+
imagelist = new wxImageList(16, 16, TRUE, 3);
imagelist->Add(wxIcon(unmarked_xpm));
imagelist->Add(wxIcon(marked_xpm));
list->SetColumnWidth(i, 70);
}
- working = false;
SetCursor(*wxSTANDARD_CURSOR);
markWhenListingDone = false;
}
wxStopWatch sw;
- while ((working) && (cancelled != 2)) {
+ while ((IsWorking()) && (cancelled != 2)) {
wxTheApp->Yield(true);
::wxUsleep(100);
if (sw.Time() > 30000) { /* 30 seconds timeout */
if (!item.IsOk()) {
return;
}
- UpdateTreeItem(item, (tree->GetSelection() == item), false);
+ UpdateTreeItem(item, true, false);
if (list->GetItemCount() >= 1) {
int firstwidth = list->GetSize().GetWidth();
this->Layout();
tree->Enable(true);
list->Enable(true);
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
break;
case configuring:
start->Enable(false);
configPanel->Enable(false);
tree->Enable(false);
list->Enable(false);
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
break;
}
status = newstatus;
UI related
----------------------------------------------------------------------------*/
+void wxbRestorePanel::SetWorking(bool working) {
+ this->working = working;
+ if (working) {
+ SetCursor(*wxHOURGLASS_CURSOR);
+// SetEvtHandlerEnabled(false); //EVTQUEUE
+ }
+// else if (!processing) { /* Empty event queue if we aren't already doing this */ //EVTQUEUE
+ else {
+// processing = true; //EVTQUEUE
+ SetCursor(*wxSTANDARD_CURSOR);
+// SetEvtHandlerEnabled(true); //EVTQUEUE
+/* wxNode *node = pendingEvents->First(); //EVTQUEUE
+ while ( node ) {
+ wxEvent *event = (wxEvent *)node->Data();
+ delete node;
+
+ wxEvtHandler::ProcessEvent(*event);
+ delete event;
+
+ node = pendingEvents->First();
+ }
+ processing = false;*/
+ }
+}
+
+bool wxbRestorePanel::IsWorking() {
+ return this->working;
+}
+
void wxbRestorePanel::EnableConfig(bool enable) {
restorePanel->Enable(enable);
}
Event handling
----------------------------------------------------------------------------*/
-void wxbRestorePanel::OnCancel(wxCommandEvent& WXUNUSED(event)) {
+
+//EVTQUEUE
+/*
+bool wxbRestorePanel::ProcessEvent(wxEvent& event) {
+ if (IsWorking() || processing) {
+ wxEvent *eventCopy = event.Clone();
+
+ pendingEvents->Append(eventCopy);
+ return TRUE;
+ }
+ else {
+ return wxEvtHandler::ProcessEvent(event);
+ }
+}
+*/
+
+void wxbRestorePanel::OnCancel(wxCommandEvent& event) {
cancel->Enable(false);
SetCursor(*wxHOURGLASS_CURSOR);
CmdCancel();
SetCursor(*wxSTANDARD_CURSOR);
}
-void wxbRestorePanel::OnStart(wxCommandEvent& WXUNUSED(event)) {
- if (working) {
+void wxbRestorePanel::OnStart(wxCommandEvent& event) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
return;
}
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
CmdStart();
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
}
void wxbRestorePanel::OnTreeChanging(wxTreeEvent& event) {
- if (working) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
event.Veto();
}
}
void wxbRestorePanel::OnTreeExpanding(wxTreeEvent& event) {
- if (working) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
event.Veto();
return;
}
}
void wxbRestorePanel::OnTreeChanged(wxTreeEvent& event) {
- if (working) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
return;
}
if (currentTreeItem == event.GetItem()) {
treeadd->Enable(false);
treeremove->Enable(false);
treerefresh->Enable(false);
- SetCursor(*wxHOURGLASS_CURSOR);
markWhenListingDone = false;
- working = true;
+ SetWorking(true);
currentTreeItem = event.GetItem();
CmdList(event.GetItem());
if (markWhenListingDone) {
CmdMark(event.GetItem(), NULL, 0);
tree->Refresh();
}
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
if (event.GetItem().IsOk()) {
int status = ((wxbTreeItemData*)tree->GetItemData(event.GetItem()))->GetMarked();
treeadd->Enable(status != 1);
void wxbRestorePanel::OnTreeMarked(wxbTreeMarkedEvent& event) {
csprint("Tree marked", CS_DEBUG);
- if (working) {
+ if (IsWorking()) {
if (tree->GetSelection() == event.GetItem()) {
markWhenListingDone = !markWhenListingDone;
}
+ AddPendingEvent(event);
return;
}
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
CmdMark(event.GetItem(), NULL, 0);
//event.Skip();
tree->Refresh();
- working = false;
+ SetWorking(false);
if (event.GetItem().IsOk()) {
int status = ((wxbTreeItemData*)tree->GetItemData(event.GetItem()))->GetMarked();
treeadd->Enable(status != 1);
treeremove->Enable(status != 0);
}
- SetCursor(*wxSTANDARD_CURSOR);
}
void wxbRestorePanel::OnTreeAdd(wxCommandEvent& event) {
- if (working) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
return;
}
if (currentTreeItem.IsOk()) {
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
CmdMark(currentTreeItem, NULL, 0, 1);
tree->Refresh();
- working = false;
treeadd->Enable(0);
treeremove->Enable(1);
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
}
}
void wxbRestorePanel::OnTreeRemove(wxCommandEvent& event) {
- if (working) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
return;
}
if (currentTreeItem.IsOk()) {
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
CmdMark(currentTreeItem, NULL, 0, 0);
tree->Refresh();
- working = false;
treeadd->Enable(1);
treeremove->Enable(0);
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
}
}
void wxbRestorePanel::OnTreeRefresh(wxCommandEvent& event) {
- if (working) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
return;
}
+ SetWorking(true);
RefreshTree();
+ SetWorking(false);
}
void wxbRestorePanel::OnListMarked(wxbListMarkedEvent& event) {
- if (working) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
//event.Skip();
return;
}
return;
}
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
long* items = new long[list->GetSelectedItemCount()];
event.Skip();
tree->Refresh();
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
}
void wxbRestorePanel::OnListActivated(wxListEvent& event) {
- if (working) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
//event.Skip();
return;
}
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
long item = event.GetIndex();
// long item = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
if (item > -1) {
wxString name2 = tree->GetItemText(currentChild);
if (name2 == name) {
//tree->UnselectAll();
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
tree->Expand(currentTreeItem);
tree->SelectItem(currentChild);
//tree->Refresh();
}
}
}
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
}
void wxbRestorePanel::OnListChanged(wxListEvent& event) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
+ return;
+ }
+
listadd->Enable(false);
listremove->Enable(false);
listremove->Enable(marked);
}
-void wxbRestorePanel::OnListAdd(wxCommandEvent& WXUNUSED(event)) {
- if (working) {
+void wxbRestorePanel::OnListAdd(wxCommandEvent& event) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
return;
}
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
long* items = new long[list->GetSelectedItemCount()];
delete[] items;
tree->Refresh();
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
listadd->Enable(false);
listremove->Enable(true);
}
-void wxbRestorePanel::OnListRemove(wxCommandEvent& WXUNUSED(event)) {
- if (working) {
+void wxbRestorePanel::OnListRemove(wxCommandEvent& event) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
return;
}
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
long* items = new long[list->GetSelectedItemCount()];
delete[] items;
tree->Refresh();
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
listadd->Enable(true);
listremove->Enable(false);
}
-void wxbRestorePanel::OnListRefresh(wxCommandEvent& WXUNUSED(event)) {
- if (working) {
+void wxbRestorePanel::OnListRefresh(wxCommandEvent& event) {
+ if (IsWorking()) {
+ AddPendingEvent(event);
return;
}
+ SetWorking(true);
RefreshList();
+ SetWorking(false);
}
void wxbRestorePanel::OnConfigUpdated(wxCommandEvent& event) {
if (status == entered) {
if (event.GetId() == ConfigJobName) {
- if (working) {
+ if (IsWorking()) {
return;
}
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
UpdateFirstConfig();
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
}
else if (event.GetId() == ConfigClient) {
- if (working) {
+ if (IsWorking()) {
return;
}
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
configPanel->Enable(false);
CmdListJobs();
configPanel->Enable(true);
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
}
cfgUpdated = cfgUpdated | (1 << event.GetId());
}
void wxbRestorePanel::OnConfigOk(wxCommandEvent& WXUNUSED(event)) {
if (status != configuring) return;
- if (working) {
+ if (IsWorking()) {
return;
}
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
CmdStart();
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
}
void wxbRestorePanel::OnConfigApply(wxCommandEvent& WXUNUSED(event)) {
if (status != configuring) return;
- if (working) {
+ if (IsWorking()) {
return;
}
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
CmdConfigApply();
if (cfgUpdated == 0) {
restorePanel->EnableApply(false);
}
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
}
void wxbRestorePanel::OnConfigCancel(wxCommandEvent& WXUNUSED(event)) {
if (status != configuring) return;
- if (working) {
+ if (IsWorking()) {
return;
}
- SetCursor(*wxHOURGLASS_CURSOR);
- working = true;
+ SetWorking(true);
CmdConfigCancel();
- working = false;
- SetCursor(*wxSTANDARD_CURSOR);
+ SetWorking(false);
}
#include "wxbtreectrl.h"
#include "wxblistctrl.h"
+WX_DECLARE_LIST(wxEvent, wxbEventList);
+
/*
* wxbPanel for restoring files
*/
/* UI related */
bool working; // A command is running, discard GUI events
+ void SetWorking(bool working);
+ bool IsWorking();
bool markWhenListingDone;
wxTreeItemId currentTreeItem; // Currently selected tree item
void EnableConfig(bool enable);
/* Event handling */
- void OnStart(wxCommandEvent& WXUNUSED(event));
- void OnCancel(wxCommandEvent& WXUNUSED(event));
+// wxbEventList* pendingEvents; /* Stores event sent while working */ //EVTQUEUE
+// bool processing; /* True if pendingEvents is being processed */ //EVTQUEUE
+
+// virtual void AddPendingEvent(wxEvent& event);
+// virtual bool ProcessEvent(wxEvent& event); //EVTQUEUE
+
+ void OnStart(wxCommandEvent& event);
+ void OnCancel(wxCommandEvent& event);
void OnTreeChanging(wxTreeEvent& event);
void OnTreeExpanding(wxTreeEvent& event);
void OnTreeChanged(wxTreeEvent& event);
void OnTreeMarked(wxbTreeMarkedEvent& event);
- void OnTreeAdd(wxCommandEvent& WXUNUSED(event));
- void OnTreeRemove(wxCommandEvent& WXUNUSED(event));
- void OnTreeRefresh(wxCommandEvent& WXUNUSED(event));
+ void OnTreeAdd(wxCommandEvent& event);
+ void OnTreeRemove(wxCommandEvent& event);
+ void OnTreeRefresh(wxCommandEvent& event);
void OnListMarked(wxbListMarkedEvent& event);
void OnListActivated(wxListEvent& event);
void OnListChanged(wxListEvent& event);
- void OnListAdd(wxCommandEvent& WXUNUSED(event));
- void OnListRemove(wxCommandEvent& WXUNUSED(event));
- void OnListRefresh(wxCommandEvent& WXUNUSED(event));
+ void OnListAdd(wxCommandEvent& event);
+ void OnListRemove(wxCommandEvent& event);
+ void OnListRefresh(wxCommandEvent& event);
void OnConfigUpdated(wxCommandEvent& event);
void OnConfigOk(wxCommandEvent& WXUNUSED(event));