Hi,
Here is my patch to complete this feature. Nothing really interesting in
it. I finally found a way to detect the active pane (thanks to the
wx-users Google groups).
Any comments on the patch?
--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com
diff --git a/pgadmin/frm/events.cpp b/pgadmin/frm/events.cpp
index ba072de..61df839 100644
--- a/pgadmin/frm/events.cpp
+++ b/pgadmin/frm/events.cpp
@@ -58,6 +58,9 @@ BEGIN_EVENT_TABLE(frmMain, pgFrame)
EVT_LIST_ITEM_SELECTED(CTL_PROPVIEW, frmMain::OnPropSelChanged)
EVT_LIST_ITEM_ACTIVATED(CTL_PROPVIEW, frmMain::OnPropSelActivated)
EVT_LIST_ITEM_RIGHT_CLICK(CTL_PROPVIEW, frmMain::OnPropRightClick)
+ EVT_LIST_ITEM_SELECTED(CTL_STATVIEW, frmMain::OnSelectItem)
+ EVT_LIST_ITEM_SELECTED(CTL_DEPVIEW, frmMain::OnSelectItem)
+ EVT_LIST_ITEM_SELECTED(CTL_REFVIEW, frmMain::OnSelectItem)
EVT_TREE_SEL_CHANGED(CTL_BROWSER, frmMain::OnTreeSelChanged)
EVT_TREE_ITEM_EXPANDING(CTL_BROWSER, frmMain::OnExpand)
EVT_TREE_ITEM_COLLAPSING(CTL_BROWSER, frmMain::OnCollapse)
@@ -221,9 +224,44 @@ void frmMain::OnPropSelChanged(wxListEvent& event)
}
}
}
+
+ editMenu->Enable(MNU_COPY, properties->GetSelectedItemCount() > 0);
+ if(properties->GetSelectedItemCount() > 0)
+ {
+ manager.GetPane(wxT("listViews")).SetFlag(wxAuiPaneInfo::optionActive, true);
+ }
}
+void frmMain::OnSelectItem(wxListEvent &event)
+{
+ ctlListView *list;
+
+ switch(listViews->GetSelection())
+ {
+ case NBP_STATISTICS:
+ list = statistics;
+ break;
+ case NBP_DEPENDENCIES:
+ list = dependencies;
+ break;
+ case NBP_DEPENDENTS:
+ list = dependents;
+ break;
+ default:
+ // This shouldn't happen.
+ // If it does, it's no big deal, we just need to get out.
+ return;
+ break;
+ }
+
+ editMenu->Enable(MNU_COPY, list->GetSelectedItemCount() > 0);
+ if(list->GetSelectedItemCount() > 0)
+ {
+ manager.GetPane(wxT("listViews")).SetFlag(wxAuiPaneInfo::optionActive, true);
+ }
+}
+
void frmMain::OnPropSelActivated(wxListEvent& event)
{
if (propFactory->CheckEnable(currentObject))
diff --git a/pgadmin/frm/frmMain.cpp b/pgadmin/frm/frmMain.cpp
index d62912b..bf4a7e7 100644
--- a/pgadmin/frm/frmMain.cpp
+++ b/pgadmin/frm/frmMain.cpp
@@ -28,6 +28,7 @@
#include <wx/imaglist.h>
#include <wx/busyinfo.h>
#include <wx/sysopt.h>
+#include <wx/clipbrd.h>
// wxAUI
#include <wx/aui/aui.h>
@@ -76,15 +77,6 @@
#include "slony/slSet.h"
-enum
-{
- NBP_PROPERTIES=0,
- NBP_STATISTICS,
- NBP_DEPENDENCIES,
- NBP_DEPENDENTS
-};
-
-
#if wxDIALOG_UNIT_COMPATIBILITY
#error wxWindows must be compiled with wxDIALOG_UNIT_COMPATIBILITY=0!
#endif
@@ -128,7 +120,7 @@ frmMain::frmMain(const wxString& title)
// notify wxAUI which frame to use
manager.SetManagedWindow(this);
- manager.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_TRANSPARENT_DRAG);
+ manager.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_TRANSPARENT_DRAG | wxAUI_MGR_ALLOW_ACTIVE_PANE);
SetMinSize(wxSize(600, 450));
@@ -150,10 +142,10 @@ frmMain::frmMain(const wxString& title)
wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), true);
#endif
- properties = new ctlListView(listViews, CTL_PROPVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER | wxLC_SINGLE_SEL);
- statistics = new ctlListView(listViews, CTL_STATVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER | wxLC_SINGLE_SEL);
- dependencies = new ctlListView(listViews, CTL_DEPVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER | wxLC_SINGLE_SEL);
- dependents = new ctlListView(listViews, CTL_REFVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER | wxLC_SINGLE_SEL);
+ properties = new ctlListView(listViews, CTL_PROPVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
+ statistics = new ctlListView(listViews, CTL_STATVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
+ dependencies = new ctlListView(listViews, CTL_DEPVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
+ dependents = new ctlListView(listViews, CTL_REFVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
// Switch back to the native list control.
#ifdef __WXMAC__
@@ -563,6 +555,70 @@ void frmMain::Refresh(pgObject *data)
EndMsg(done);
}
+void frmMain::OnCopy(wxCommandEvent &ev)
+{
+ for (uint i = 0; i < manager.GetAllPanes().GetCount(); i++)
+ {
+ wxAuiPaneInfo& pane = manager.GetAllPanes()[i];
+ if (pane.HasFlag(wxAuiPaneInfo::optionActive))
+ {
+ if (pane.name == wxT("sqlPane"))
+ {
+ sqlPane->Copy();
+ }
+ else
+ {
+ ctlListView *list;
+ int row, col;
+ wxString text;
+
+ switch(listViews->GetSelection())
+ {
+ case NBP_PROPERTIES:
+ list = properties;
+ break;
+ case NBP_STATISTICS:
+ list = statistics;
+ break;
+ case NBP_DEPENDENCIES:
+ list = dependencies;
+ break;
+ case NBP_DEPENDENTS:
+ list = dependents;
+ break;
+ default:
+ // This shouldn't happen.
+ // If it does, it's no big deal, we just need to get out.
+ return;
+ break;
+ }
+
+ row = list->GetFirstSelected();
+
+ while (row >= 0)
+ {
+ for (col = 0; col < list->GetColumnCount(); col++)
+ {
+ text.Append(list->GetText(row, col) + wxT("\t"));
+ }
+#ifdef __WXMSW__
+ text.Append(wxT("\r\n"));
+#else
+ text.Append(wxT("\n"));
+#endif
+ row = list->GetNextSelected(row);
+ }
+
+ if (text.Length() > 0 && wxTheClipboard->Open())
+ {
+ wxTheClipboard->SetData(new wxTextDataObject(text));
+ wxTheClipboard->Close();
+ }
+ }
+ }
+ }
+}
+
void frmMain::GetExpandedChildNodes(wxTreeItemId node, wxArrayString &expandedNodes)
{
wxTreeItemIdValue cookie;
diff --git a/pgadmin/include/frm/frmMain.h b/pgadmin/include/frm/frmMain.h
index c8a37c9..e40acdf 100644
--- a/pgadmin/include/frm/frmMain.h
+++ b/pgadmin/include/frm/frmMain.h
@@ -60,6 +60,16 @@ typedef struct PluginUtility {
bool set_password;
} PluginUtility;
+
+enum
+{
+ NBP_PROPERTIES=0,
+ NBP_STATISTICS,
+ NBP_DEPENDENCIES,
+ NBP_DEPENDENTS
+};
+
+
// Class declarations
class frmMain : public pgFrame
{
@@ -137,6 +147,7 @@ private:
void OnEraseBackground(wxEraseEvent& event);
void OnSize(wxSizeEvent& event);
+ void OnSelectItem(wxListEvent &event);
void CreateMenus();
void OnContents(wxCommandEvent& event);
@@ -164,7 +175,7 @@ private:
void OnNew(wxCommandEvent& event);
void OnDelete(wxCommandEvent &ev);
- void OnCopy(wxCommandEvent &ev) { sqlPane->Copy(); };
+ void OnCopy(wxCommandEvent &ev);
void OnCheckAlive(wxCommandEvent& event);
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers