From ca82d6ce04bb53730d53ae71c00dc43b70da5f70 Mon Sep 17 00:00:00 2001 From: guillaume Date: Fri, 18 Dec 2009 14:49:07 +0000 Subject: [PATCH] Forgot to add the new files in the previous commit. I still have to grow my git-fu. git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@8137 a7884b65-44f6-0310-8a51-81a127f17b15 --- pgadmin/ctl/ctlCheckTreeView.cpp | 80 +++++++++++++++++++++++ pgadmin/ctl/xh_ctlchecktreeview.cpp | 33 ++++++++++ pgadmin/include/ctl/ctlCheckTreeView.h | 35 ++++++++++ pgadmin/include/ctl/xh_ctlchecktreeview.h | 30 +++++++++ pgadmin/include/images/disabled.xpm | 24 +++++++ pgadmin/pgAdmin3.vcproj | 16 +++++ 6 files changed, 218 insertions(+) create mode 100644 pgadmin/ctl/ctlCheckTreeView.cpp create mode 100644 pgadmin/ctl/xh_ctlchecktreeview.cpp create mode 100644 pgadmin/include/ctl/ctlCheckTreeView.h create mode 100644 pgadmin/include/ctl/xh_ctlchecktreeview.h create mode 100644 pgadmin/include/images/disabled.xpm diff --git a/pgadmin/ctl/ctlCheckTreeView.cpp b/pgadmin/ctl/ctlCheckTreeView.cpp new file mode 100644 index 000000000..984f707e0 --- /dev/null +++ b/pgadmin/ctl/ctlCheckTreeView.cpp @@ -0,0 +1,80 @@ +////////////////////////////////////////////////////////////////////////// +// +// pgAdmin III - PostgreSQL Tools +// RCS-ID: $Id$ +// Copyright (C) 2002 - 2009, The pgAdmin Development Team +// This software is released under the BSD Licence +// +// ctlCheckTreeView.cpp - TreeView with Checkboxes +// +////////////////////////////////////////////////////////////////////////// + +// wxWindows headers +#include +#include +#include +#include +#include + +// App headers +#include "pgAdmin3.h" +#include "ctl/ctlCheckTreeView.h" +#include "images/checked.xpm" +#include "images/disabled.xpm" +#include "images/unchecked.xpm" + +BEGIN_EVENT_TABLE(ctlCheckTreeView, wxTreeCtrl) + EVT_LEFT_DOWN( ctlCheckTreeView::OnLeftClick) +END_EVENT_TABLE() + + +ctlCheckTreeView::ctlCheckTreeView(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) +:wxTreeCtrl(parent, id, pos, size, style) +{ + wxImageList *treeimages = new wxImageList(16, 16, true, 3); + treeimages->Add(wxIcon(unchecked_xpm)); + treeimages->Add(wxIcon(checked_xpm)); + treeimages->Add(wxIcon(disabled_xpm)); + SetImageList(treeimages); +} + + +void ctlCheckTreeView::OnLeftClick(wxMouseEvent &evt) +{ + int flags; + wxTreeItemId node = HitTest(evt.GetPosition(), flags); + int newimage; + + if ((flags & wxTREE_HITTEST_ONITEMLABEL) || (flags & wxTREE_HITTEST_ONITEMICON)) + { + if (GetItemImage(node) == 0) + newimage = 1; + else if (GetItemImage(node) == 1) + newimage = 0; + + if (GetItemImage(node) == 0 || GetItemImage(node) == 1) + { + SetParentAndChildImage(node, newimage); + } + } + + evt.Skip(); +} + +void ctlCheckTreeView::SetParentAndChildImage(wxTreeItemId node, int newimage) +{ + SetItemImage(node, newimage); + wxTreeItemIdValue childData; + wxTreeItemId child = GetFirstChild(node, childData); + while (child.IsOk()) + { + SetParentAndChildImage(child, newimage); + child = GetNextChild(node, childData); + } +} + +bool ctlCheckTreeView::IsChecked(const wxTreeItemId& node) +{ + return (GetItemImage(node) == 1); +} + diff --git a/pgadmin/ctl/xh_ctlchecktreeview.cpp b/pgadmin/ctl/xh_ctlchecktreeview.cpp new file mode 100644 index 000000000..9fc852739 --- /dev/null +++ b/pgadmin/ctl/xh_ctlchecktreeview.cpp @@ -0,0 +1,33 @@ +////////////////////////////////////////////////////////////////////////// +// +// pgAdmin III - PostgreSQL Tools +// RCS-ID: $Id$ +// Copyright (C) 2002 - 2009, The pgAdmin Development Team +// This software is released under the BSD Licence +// +// xh_ctlchecktreeview.cpp - ctlCheckTreeView handler +// +////////////////////////////////////////////////////////////////////////// + +#include "pgAdmin3.h" + +#include "wx/wx.h" +#include "ctl/ctlCheckTreeView.h" +#include "ctl/xh_ctlchecktreeview.h" + +IMPLEMENT_DYNAMIC_CLASS(ctlCheckTreeViewXmlHandler, wxTreeCtrlXmlHandler) + + +wxObject *ctlCheckTreeViewXmlHandler::DoCreateResource() +{ + ctlCheckTreeView *ctl=new ctlCheckTreeView(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle()); + + SetupWindow(ctl); + + return ctl; +} + +bool ctlCheckTreeViewXmlHandler::CanHandle(wxXmlNode *node) +{ + return IsOfClass(node, wxT("ctlCheckTreeView")); +} diff --git a/pgadmin/include/ctl/ctlCheckTreeView.h b/pgadmin/include/ctl/ctlCheckTreeView.h new file mode 100644 index 000000000..c7139ace2 --- /dev/null +++ b/pgadmin/include/ctl/ctlCheckTreeView.h @@ -0,0 +1,35 @@ +////////////////////////////////////////////////////////////////////////// +// +// pgAdmin III - PostgreSQL Tools +// RCS-ID: $Id$ +// Copyright (C) 2002 - 2009, The pgAdmin Development Team +// This software is released under the BSD Licence +// +// ctlCheckTreeView.cpp - TreeView with Checkboxes +// +////////////////////////////////////////////////////////////////////////// + +#ifndef _CTLCHECKTREEVIEW_H +#define _CTLCHECKTREEVIEW_H + + +// wxWindows headers +#include +#include +#include +#include + +class ctlCheckTreeView : public wxTreeCtrl +{ +public: + ctlCheckTreeView(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS); + bool IsChecked(const wxTreeItemId& node); + +private: + void OnLeftClick(wxMouseEvent &evt); + void SetParentAndChildImage(wxTreeItemId node, int newimage); + + DECLARE_EVENT_TABLE() +}; + +#endif diff --git a/pgadmin/include/ctl/xh_ctlchecktreeview.h b/pgadmin/include/ctl/xh_ctlchecktreeview.h new file mode 100644 index 000000000..6eb650ac6 --- /dev/null +++ b/pgadmin/include/ctl/xh_ctlchecktreeview.h @@ -0,0 +1,30 @@ +////////////////////////////////////////////////////////////////////////// +// +// pgAdmin III - PostgreSQL Tools +// RCS-ID: $Id$ +// Copyright (C) 2002 - 2009, The pgAdmin Development Team +// This software is released under the BSD Licence +// +// xh_ctltree.h - ctlTree handler +// +////////////////////////////////////////////////////////////////////////// + + +#ifndef _WX_XH_CTLCHECKTREEVIEW_H_ +#define _WX_XH_CTLCHECKTREEVIEW_H_ + +#include "wx/xrc/xmlres.h" +#include "wx/xrc/xh_tree.h" + +//class WXDLLIMPEXP_XRC +class ctlCheckTreeViewXmlHandler : public wxTreeCtrlXmlHandler +{ +DECLARE_DYNAMIC_CLASS(ctlCheckTreeViewXmlHandler) +public: + ctlCheckTreeViewXmlHandler() : wxTreeCtrlXmlHandler() {} + virtual wxObject *DoCreateResource(); + virtual bool CanHandle(wxXmlNode *node); +}; + + +#endif diff --git a/pgadmin/include/images/disabled.xpm b/pgadmin/include/images/disabled.xpm new file mode 100644 index 000000000..b07a60f12 --- /dev/null +++ b/pgadmin/include/images/disabled.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static const char * disabled_xpm[] = { +"16 16 5 1", +" c None", +". c #D4D0C8", +"+ c #808080", +"@ c #FFFFFF", +"# c #404040", +" ", +" ", +" ++++++++++++@ ", +" +##########.@ ", +" +#+++++++++.@ ", +" +#+++++++++.@ ", +" +#+++++++++.@ ", +" +#+++++++++.@ ", +" +#+++++++++.@ ", +" +#+++++++++.@ ", +" +#+++++++++.@ ", +" +#+++++++++.@ ", +" +#+++++++++.@ ", +" +...........@ ", +" @@@@@@@@@@@@@ ", +" "}; diff --git a/pgadmin/pgAdmin3.vcproj b/pgadmin/pgAdmin3.vcproj index 2b3bf6115..2fd55bf81 100644 --- a/pgadmin/pgAdmin3.vcproj +++ b/pgadmin/pgAdmin3.vcproj @@ -383,6 +383,10 @@ RelativePath=".\ctl\ctlCheckTreeView.cpp" > + + @@ -439,6 +443,10 @@ RelativePath=".\ctl\xh_ctlchecktreeview.cpp" > + + @@ -930,6 +938,10 @@ RelativePath=".\include\ctl\ctlCheckTreeView.h" > + + @@ -986,6 +998,10 @@ RelativePath=".\include\ctl\xh_ctlchecktreeview.h" > + + -- 2.39.5