Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_calb.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_calb.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_calb.cpp (revision 8187)
@@ -0,0 +1,58 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// xh_calb.cpp - wxCalendarBox handler
+//
+//////////////////////////////////////////////////////////////////////////
+ 
+#include "pgAdmin3.h"
+
+#include "wx/wx.h"
+#include "ctl/xh_calb.h"
+#include "ctl/calbox.h"
+
+
+IMPLEMENT_DYNAMIC_CLASS(wxCalendarBoxXmlHandler, wxXmlResourceHandler)
+
+wxCalendarBoxXmlHandler::wxCalendarBoxXmlHandler() 
+: wxXmlResourceHandler() 
+{
+    AddWindowStyles();
+}
+
+
+wxObject *wxCalendarBoxXmlHandler::DoCreateResource()
+{ 
+    XRC_MAKE_INSTANCE(calendar, wxCalendarBox);
+
+#if pgUSE_WX_CAL
+    calendar->Create(m_parentAsWindow,
+                     GetID(),
+                     wxDefaultDateTime,
+                     GetPosition(), GetSize(),
+                     wxDP_DEFAULT | wxDP_SHOWCENTURY | wxDP_ALLOWNONE,
+                     wxDefaultValidator,
+                     GetName());
+
+#else
+    calendar->Create(m_parentAsWindow,
+                     GetID(),
+                     wxDefaultDateTime,
+                     GetPosition(), GetSize(),
+                     GetStyle(),
+                     GetName());
+#endif
+    
+    SetupWindow(calendar);
+    
+    return calendar;
+}
+
+bool wxCalendarBoxXmlHandler::CanHandle(wxXmlNode *node)
+{
+    return IsOfClass(node, wxT("wxCalendarBox"));
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSQLResult.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSQLResult.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSQLResult.cpp (revision 8187)
@@ -0,0 +1,346 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlSQLResult.cpp - SQL Query result window
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/clipbrd.h>
+
+#include "db/pgConn.h"
+#include "db/pgQueryThread.h"
+#include "ctl/ctlSQLResult.h"
+#include "utils/sysSettings.h"
+#include "frm/frmExport.h"
+
+
+
+ctlSQLResult::ctlSQLResult(wxWindow *parent, pgConn *_conn, wxWindowID id, const wxPoint& pos, const wxSize& size)
+: ctlSQLGrid(parent, id, pos, size)
+{
+    conn=_conn;
+    thread=0;
+
+    SetTable(new sqlResultTable(), true);
+
+    EnableEditing(false);
+    SetSizer(new wxBoxSizer(wxVERTICAL));
+
+    Connect(wxID_ANY, wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEventHandler(ctlSQLResult::OnGridSelect));
+}
+
+
+
+ctlSQLResult::~ctlSQLResult()
+{
+    Abort();
+}
+
+
+void ctlSQLResult::SetConnection(pgConn *_conn)
+{
+    conn=_conn;
+}
+
+
+bool ctlSQLResult::Export()
+{
+    if (NumRows() > 0)
+    {
+        frmExport dlg(this);
+        if (dlg.ShowModal() == wxID_OK)
+            return dlg.Export(NULL);
+    }
+    return false;
+}
+
+bool ctlSQLResult::ToFile()
+{
+    if (NumRows() > 0)
+    {
+        frmExport dlg(this);
+        if (dlg.ShowModal() == wxID_OK)
+            return dlg.Export(thread->DataSet());
+    }
+    return false;
+}
+
+bool ctlSQLResult::IsColText(int col)
+{
+	switch (colTypClasses.Item(col))
+	{
+	case PGTYPCLASS_NUMERIC:
+	case PGTYPCLASS_BOOL:
+		return false;
+	}
+
+    return true;
+}
+
+
+int ctlSQLResult::Execute(const wxString &query, int resultToRetrieve, wxWindow *caller, long eventId, void *data)
+{
+    colSizes.Empty();
+    colHeaders.Empty();
+    for (int col=0 ; col < GetNumberCols() ; col++)
+    {
+        colSizes.Add(GetColSize(col));
+        colHeaders.Add(this->GetColLabelValue(col));
+    }
+
+    wxGridTableMessage *msg;
+    sqlResultTable *table = (sqlResultTable *)GetTable();
+    msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, GetNumberRows());
+    ProcessTableMessage(*msg);
+    delete msg;
+    msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_DELETED, 0, GetNumberCols());
+    ProcessTableMessage(*msg);
+    delete msg;
+
+    Abort();
+
+    colNames.Empty();
+    colTypes.Empty();
+    colTypClasses.Empty();
+
+    thread = new pgQueryThread(conn, query, resultToRetrieve, caller, eventId, data);
+
+    if (thread->Create() != wxTHREAD_NO_ERROR)
+    {
+        Abort();
+        return -1;
+    }
+
+    ((sqlResultTable *)GetTable())->SetThread(thread);
+
+    thread->Run();
+    return RunStatus();
+}
+
+
+int ctlSQLResult::Abort()
+{
+    if (thread)
+    {
+        ((sqlResultTable *)GetTable())->SetThread(0);
+
+        thread->Delete();
+        delete thread;
+    }
+    thread=0;
+    return 0;
+}
+
+
+
+void ctlSQLResult::DisplayData(bool single)
+{
+    if (!thread || !thread->DataValid())
+        return;
+
+    if (thread->ReturnCode() != PGRES_TUPLES_OK)
+		return;
+
+	rowcountSuppressed = single;
+    Freeze();
+
+    /*
+     * Resize and repopulate by informing it to delete all the rows and
+     * columns, then append the correct number of them. Probably is a
+     * better way to do this.
+     */
+    wxGridTableMessage *msg;
+    sqlResultTable *table = (sqlResultTable *)GetTable();
+    msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, GetNumberRows());
+    ProcessTableMessage(*msg);
+    delete msg;
+    msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_DELETED, 0, GetNumberCols());
+    ProcessTableMessage(*msg);
+    delete msg;
+    msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, NumRows());
+    ProcessTableMessage(*msg);
+    delete msg;
+    msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_APPENDED, thread->DataSet()->NumCols());
+    ProcessTableMessage(*msg);
+    delete msg;
+
+	if (single)
+    {
+        int w, h;
+        if (colSizes.GetCount() == 1)
+            w = colSizes.Item(0);
+        else
+            GetSize(&w, &h);
+
+        colNames.Add(thread->DataSet()->ColName(0));
+        colTypes.Add(wxT(""));
+        colTypClasses.Add(0L);
+
+        SetColSize(0, w);
+    }
+	else
+    {
+        wxString colName, colType;
+        int w;
+
+        size_t hdrIndex=0;
+		long col, nCols=thread->DataSet()->NumCols();
+
+        for (col=0 ; col < nCols ; col++)
+        {
+            colName = thread->DataSet()->ColName(col);
+            colType = thread->DataSet()->ColFullType(col);
+            colNames.Add(colName);
+            colTypes.Add(colType);
+            colTypClasses.Add(thread->DataSet()->ColTypClass(col));
+            
+            wxString colHeader = colName + wxT("\n") + colType;
+
+            if (hdrIndex < colHeaders.GetCount() && colHeaders.Item(hdrIndex) == colHeader)
+                w = colSizes.Item(hdrIndex++);
+            else
+                w=-1;
+
+            SetColSize(col, w);
+        }
+    }
+    Thaw();
+}
+
+
+
+wxString ctlSQLResult::GetMessagesAndClear()
+{
+    if (thread)
+        return thread->GetMessagesAndClear();
+    return wxEmptyString;
+}
+
+
+wxString ctlSQLResult::GetErrorMessage()
+{
+    return conn->GetLastError();
+}
+
+pgError ctlSQLResult::GetResultError()
+{
+    return conn->GetLastResultError();
+}
+
+long ctlSQLResult::NumRows() const
+{
+    if (thread && thread->DataValid())
+        return thread->DataSet()->NumRows();
+    return 0;
+}
+
+
+long ctlSQLResult::InsertedCount() const
+{
+    if (thread)
+        return thread->RowsInserted();
+    return -1;
+}
+
+
+OID ctlSQLResult::InsertedOid() const
+{
+    if (thread)
+        return thread->InsertedOid();
+    return (OID)-1;
+}
+
+
+int ctlSQLResult::RunStatus()
+{
+    if (!thread)
+        return -1;
+    
+    if (thread->IsRunning())
+        return CTLSQL_RUNNING;
+
+    return thread->ReturnCode();
+}
+
+
+wxString ctlSQLResult::OnGetItemText(long item, long col) const
+{
+    if (thread && thread->DataValid())
+	{
+		if (!rowcountSuppressed)
+		{
+			if (col)
+				col--;
+			else
+				return NumToStr(item+1L);
+		}
+		if (item >= 0)
+		{
+			thread->DataSet()->Locate(item+1);
+			return thread->DataSet()->GetVal(col);
+		}
+		else
+			return thread->DataSet()->ColName(col);
+	}
+	return wxEmptyString;
+}
+
+void ctlSQLResult::OnGridSelect(wxGridRangeSelectEvent& event)
+{
+    SetFocus();
+}
+
+wxString sqlResultTable::GetValue(int row, int col)
+{
+    if (thread && thread->DataValid())
+	{
+		if (col >= 0)
+		{
+			thread->DataSet()->Locate(row+1);
+            if (settings->GetIndicateNull() && thread->DataSet()->IsNull(col))
+                return wxT("<NULL>");
+            else
+			    return thread->DataSet()->GetVal(col);
+		}
+		else
+			return thread->DataSet()->ColName(col);
+	}
+	return wxEmptyString;
+}
+
+sqlResultTable::sqlResultTable()
+{
+    thread = 0;
+}
+
+int sqlResultTable::GetNumberRows()
+{
+    if (thread && thread->DataValid())
+        return thread->DataSet()->NumRows();
+    return 0;
+}
+
+
+wxString sqlResultTable::GetColLabelValue(int col)
+{
+    if (thread && thread->DataValid())
+        return thread->DataSet()->ColName(col) + wxT("\n") +
+            thread->DataSet()->ColFullType(col);
+    return wxEmptyString;
+}
+
+int sqlResultTable::GetNumberCols()
+{
+    if (thread && thread->DataValid())
+        return thread->DataSet()->NumCols();
+    return 0;
+}
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_ctlcombo.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_ctlcombo.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_ctlcombo.cpp (revision 8187)
@@ -0,0 +1,33 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// xh_ctlcombo.cpp - ctlComboBox handler
+//
+//////////////////////////////////////////////////////////////////////////
+ 
+#include "pgAdmin3.h"
+
+#include "wx/wx.h"
+#include "ctl/ctlComboBox.h"
+#include "ctl/xh_ctlcombo.h"
+
+IMPLEMENT_DYNAMIC_CLASS(ctlComboBoxXmlHandler, wxComboBoxXmlHandler)
+
+
+wxObject *ctlComboBoxXmlHandler::DoCreateResource()
+{ 
+    ctlComboBox *ctl=new ctlComboBox(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle());
+    
+    SetupWindow(ctl);
+   
+    return ctl;
+}
+
+bool ctlComboBoxXmlHandler::CanHandle(wxXmlNode *node)
+{
+    return IsOfClass(node, wxT("ctlComboBox"));
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_ctltree.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_ctltree.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_ctltree.cpp (revision 8187)
@@ -0,0 +1,35 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// xh_ctltree.cpp - ctlTree handler
+//
+//////////////////////////////////////////////////////////////////////////
+ 
+#include "pgAdmin3.h"
+
+#include "wx/wx.h"
+
+#include "utils/misc.h"
+#include "ctl/ctlTree.h"
+#include "ctl/xh_ctltree.h"
+
+IMPLEMENT_DYNAMIC_CLASS(ctlTreeXmlHandler, wxTreeCtrlXmlHandler)
+
+
+wxObject *ctlTreeXmlHandler::DoCreateResource()
+{ 
+    ctlTree *ctl=new ctlTree(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle());
+    
+    SetupWindow(ctl);
+   
+    return ctl;
+}
+
+bool ctlTreeXmlHandler::CanHandle(wxXmlNode *node)
+{
+    return IsOfClass(node, wxT("ctlTree"));
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlTree.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlTree.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlTree.cpp (revision 8187)
@@ -0,0 +1,342 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlTree.cpp - wxTreeCtrl containing pgObjects
+//
+//////////////////////////////////////////////////////////////////////////
+
+// wxWindows headers
+#include <wx/wx.h>
+
+// App headers
+#include "pgAdmin3.h"
+#include "ctl/ctlTree.h"
+
+#include "schema/pgObject.h"
+#include "schema/pgCollection.h"
+#include "schema/pgServer.h"
+
+BEGIN_EVENT_TABLE(ctlTree, wxTreeCtrl)
+    EVT_CHAR(ctlTree::OnChar)
+END_EVENT_TABLE()
+
+
+wxTreeItemId ctlTree::FindItem(const wxTreeItemId& idParent, const wxString& prefixOrig)
+{
+    // match is case insensitive as this is more convenient to the user: having
+    // to press Shift-letter to go to the item starting with a capital letter
+    // would be too bothersome
+    wxString prefix = prefixOrig.Lower();
+
+    // determine the starting point: we shouldn't take the current item (this
+    // allows to switch between two items starting with the same letter just by
+    // pressing it) but we shouldn't jump to the next one if the user is
+    // continuing to type as otherwise he might easily skip the item he wanted
+    wxTreeItemId id = idParent;
+
+    if ( prefix.length() == 1 )
+    {
+        wxCookieType cookie;
+        if (HasChildren(id))
+            id = GetFirstChild(id, cookie);
+        else
+        {
+             // Try a sibling of this or ancestor instead
+             wxTreeItemId p = id;
+             wxTreeItemId toFind;
+             do
+             {
+                  toFind = GetNextSibling(p);
+                  p = GetItemParent(p);
+             } while (p.IsOk() && !toFind.IsOk());
+             id = toFind;
+        }
+    }
+
+    // look for the item starting with the given prefix after it
+    while ( id.IsOk() &&
+            ( ( GetItemText(id) == wxT("Dummy") && !GetItemData(id) ) ||
+             !GetItemText(id).Lower().StartsWith(prefix) ))
+    {
+        wxCookieType cookie;
+        if ( HasChildren(id) )
+            id = GetFirstChild(id, cookie);
+        else
+        {
+             // Try a sibling of this or ancestor instead
+             wxTreeItemId p = id;
+             wxTreeItemId toFind;
+             do
+             {
+                  toFind = GetNextSibling(p);
+                  p = GetItemParent(p);
+             } while (p.IsOk() && !toFind.IsOk());
+             id = toFind;
+        }
+    }
+
+    // if we haven't found anything...
+    if ( !id.IsOk() )
+    {
+        // ... wrap to the beginning
+        id = GetRootItem();
+        if ( HasFlag(wxTR_HIDE_ROOT) )
+        {
+            wxCookieType cookie;
+            // can't select virtual root
+            if ( HasChildren(id) )
+                id = GetFirstChild(id, cookie);
+            else
+            {
+                 // Try a sibling of this or ancestor instead
+                 wxTreeItemId p = id;
+                 wxTreeItemId toFind;
+                 do
+                 {
+                      toFind = GetNextSibling(p);
+                      p = GetItemParent(p);
+                 } while (p.IsOk() && !toFind.IsOk());
+                 id = toFind;
+            }
+        }
+
+        // and try all the items (stop when we get to the one we started from)
+        while ( id.IsOk() && id != idParent &&
+                (( GetItemText(id) == wxT("Dummy") && !GetItemData(id) ) ||
+                 !GetItemText(id).Lower().StartsWith(prefix) ))
+        {
+            wxCookieType cookie;
+            if ( HasChildren(id) )
+                id = GetFirstChild(id, cookie);
+            else
+            {
+                 // Try a sibling of this or ancestor instead
+                 wxTreeItemId p = id;
+                 wxTreeItemId toFind;
+                 do
+                 {
+                      toFind = GetNextSibling(p);
+                      p = GetItemParent(p);
+                 } while (p.IsOk() && !toFind.IsOk());
+                 id = toFind;
+            }
+        }
+        // If we haven't found the item, id.IsOk() will be false, as per
+        // documentation
+    }
+
+    return id;
+}
+
+void ctlTree::OnChar(wxKeyEvent& event)
+{
+    int keyCode = event.GetKeyCode();
+    if ( !event.HasModifiers() &&
+         ((keyCode >= '0' && keyCode <= '9') ||
+          (keyCode >= 'a' && keyCode <= 'z') ||
+          (keyCode >= 'A' && keyCode <= 'Z')))
+    {
+        wxTreeItemId currItem = GetSelection();
+
+        if (!currItem.IsOk())
+            return;
+
+        wxTreeItemId matchItem = FindItem(currItem, m_findPrefix + (wxChar)keyCode);
+
+        if ( matchItem.IsOk() )
+        {
+            EnsureVisible(matchItem);
+            SelectItem(matchItem);
+
+            m_findPrefix += (wxChar)keyCode;
+
+            // also start the timer to reset the current prefix if the user
+            // doesn't press any more alnum keys soon -- we wouldn't want
+            // to use this prefix for a new item search
+            if ( !m_findTimer )
+            {
+                m_findTimer = new ctlTreeFindTimer(this);
+            }
+
+            m_findTimer->Start(ctlTreeFindTimer::CTLTREE_DELAY, wxTIMER_ONE_SHOT);
+            return;
+        }
+    }
+    else
+    {
+        event.Skip(true);
+    }
+}
+
+ctlTree::ctlTree(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
+: wxTreeCtrl(parent, id, pos, size, style), m_findTimer(NULL)
+{
+}
+
+ctlTree::~ctlTree()
+{
+    if ( m_findTimer )
+        delete m_findTimer;
+    m_findTimer = NULL;
+}
+
+
+void ctlTree::RemoveDummyChild(pgObject *obj)
+{
+    wxCookieType cookie;
+    wxTreeItemId childItem=GetFirstChild(obj->GetId(), cookie);
+    if (childItem && !GetItemData(childItem))
+    {
+        // The child was a dummy item, which will be replaced by the following ShowTreeDetail by true items
+        Delete(childItem);
+    }
+}
+
+
+pgObject *ctlTree::GetObject(wxTreeItemId id)
+{
+    if (id)
+        return (pgObject*)GetItemData(id);
+    return 0;
+}
+
+
+pgCollection *ctlTree::GetParentCollection(wxTreeItemId id)
+{
+    pgCollection *coll=(pgCollection*)GetParentObject(id);
+    if (coll && coll->IsCollection())
+        return coll;
+    return 0;
+}
+
+
+void ctlTree::SetItemImage(const wxTreeItemId& item, int image, wxTreeItemIcon which)
+{
+    wxTreeCtrl::SetItemImage(item, image, which);
+    
+    wxTreeItemData *data = GetItemData(item);
+
+    // Set the item colour
+    if (data)
+    {
+       if (((pgObject *)data)->GetMetaType() == PGM_SERVER)
+       {
+           if (!((pgServer *)data)->GetColour().IsEmpty())
+               SetItemBackgroundColour(item, wxColour(((pgServer *)data)->GetColour()));
+       }
+       else if (((pgObject *)data)->GetServer())
+       {
+           if (!((pgObject *)data)->GetServer()->GetColour().IsEmpty())
+               SetItemBackgroundColour(item, wxColour(((pgObject *)data)->GetServer()->GetColour()));
+       }
+    }
+}
+
+wxTreeItemId ctlTree::AppendItem(const wxTreeItemId& parent, const wxString& text, int image, int selImage, wxTreeItemData* data)
+{
+    wxTreeItemId itm = wxTreeCtrl::AppendItem(parent, text, image, selImage, data); 
+
+    // Set the item colour
+    if (data)
+    {
+        if (((pgObject *)data)->GetMetaType() == PGM_SERVER)
+        {
+            if (!((pgServer *)data)->GetColour().IsEmpty())
+                SetItemBackgroundColour(itm, wxColour(((pgServer *)data)->GetColour()));
+        }
+        else if (((pgObject *)data)->GetServer())
+        {
+            if (!((pgObject *)data)->GetServer()->GetColour().IsEmpty())
+                SetItemBackgroundColour(itm, wxColour(((pgObject *)data)->GetServer()->GetColour()));
+        }
+    }
+
+    return itm;
+}
+
+wxTreeItemId ctlTree::AppendObject(pgObject *parent, pgObject *object)
+{
+    wxString label;
+    wxTreeItemId item;
+
+    if (object->IsCollection())
+        label = object->GetTypeName();
+    else
+        label = object->GetDisplayName();
+    item = AppendItem(parent->GetId(), label, object->GetIconId(), -1, object);
+    if (object->IsCollection())
+        object->ShowTreeDetail(this);
+    else if (object->WantDummyChild())
+        AppendItem(object->GetId(), wxT("Dummy"));
+
+    return item;
+}
+
+
+pgCollection *ctlTree::AppendCollection(pgObject *parent, pgaFactory &factory)
+{
+    pgCollection *collection=factory.CreateCollection(parent);
+    AppendObject(parent, collection);
+    return collection;
+}
+
+
+pgObject *ctlTree::FindObject(pgaFactory &factory, wxTreeItemId parent)
+{
+    wxCookieType cookie;
+    wxTreeItemId item = GetFirstChild(parent, cookie);
+    while (item)
+    {
+        pgObject *obj=(pgObject*)GetItemData(item);
+        if (obj && obj->IsCreatedBy(factory))
+            return obj;
+        item = GetNextChild(parent, cookie);
+    }
+    return 0;
+}
+
+
+pgCollection *ctlTree::FindCollection(pgaFactory &factory, wxTreeItemId parent)
+{
+    pgaFactory *cf=factory.GetCollectionFactory();
+    if (!cf)
+        return 0;
+
+    pgCollection *collection=(pgCollection*)FindObject(*cf, parent);
+
+    if (!collection || !collection->IsCollection())
+        return 0;
+    return collection;
+}
+
+
+//////////////////////
+
+treeObjectIterator::treeObjectIterator(ctlTree *brow, pgObject *obj)
+{
+    browser=brow;
+    object=obj;
+}
+
+
+pgObject *treeObjectIterator::GetNextObject()
+{
+    if (!object ||!browser)
+        return 0;
+
+    if (!lastItem)
+        lastItem = browser->GetFirstChild(object->GetId(), cookie);
+    else
+        lastItem = browser->GetNextChild(object->GetId(), cookie);
+
+    if (lastItem)
+        return browser->GetObject(lastItem);
+    else
+        object=0;
+
+    return 0;
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_sqlbox.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_sqlbox.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_sqlbox.cpp (revision 8187)
@@ -0,0 +1,45 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// xh_sqlbox.cpp - ctlSQLBox handler
+//
+//////////////////////////////////////////////////////////////////////////
+ 
+#include "pgAdmin3.h"
+
+#include "wx/wx.h"
+#include "ctl/xh_sqlbox.h"
+#include "ctl/ctlSQLBox.h"
+
+
+IMPLEMENT_DYNAMIC_CLASS(ctlSQLBoxXmlHandler, wxXmlResourceHandler)
+
+ctlSQLBoxXmlHandler::ctlSQLBoxXmlHandler() 
+: wxXmlResourceHandler() 
+{
+    XRC_ADD_STYLE(wxTE_MULTILINE);
+    XRC_ADD_STYLE(wxSIMPLE_BORDER);
+    XRC_ADD_STYLE(wxSUNKEN_BORDER);
+    XRC_ADD_STYLE(wxTE_RICH2);
+
+    AddWindowStyles();
+}
+
+
+wxObject *ctlSQLBoxXmlHandler::DoCreateResource()
+{ 
+    ctlSQLBox *sqlbox=new ctlSQLBox(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle());
+    
+    SetupWindow(sqlbox);
+   
+    return sqlbox;
+}
+
+bool ctlSQLBoxXmlHandler::CanHandle(wxXmlNode *node)
+{
+    return IsOfClass(node, wxT("ctlSQLBox"));
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/calbox.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/calbox.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/calbox.cpp (revision 8187)
@@ -0,0 +1,496 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// calbox.cpp - Date-picker control box
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+#include <wx/wx.h>
+
+#include "ctl/calbox.h"
+
+#if defined(__WXMSW__)
+    #define TXTCTRL_FLAGS     wxNO_BORDER
+    #define CALBORDER         0
+    #define TXTPOSX           0
+    #define TXTPOSY           1
+#elif defined(__WXGTK__)
+    #define TXTCTRL_FLAGS     0
+    #define CALBORDER         4
+    #define TXTPOSX           0
+    #define TXTPOSY           0
+#else
+    #define TXTCTRL_FLAGS     0
+    #define CALBORDER         4
+    #define TXTPOSX           0
+    #define TXTPOSY           0
+#endif
+
+
+#define CTRLID_TXT  101
+#define CTRLID_CAL  102
+#define CTRLID_BTN  103
+#define CTRLID_PAN  104
+
+BEGIN_EVENT_TABLE(wxCalendarBox, wxControl)
+    EVT_BUTTON(CTRLID_BTN, wxCalendarBox::OnClick)
+    EVT_TEXT(CTRLID_TXT, wxCalendarBox::OnText)
+    EVT_CHILD_FOCUS(wxCalendarBox::OnChildSetFocus)
+    EVT_SIZE(wxCalendarBox::OnSize)
+END_EVENT_TABLE()
+
+IMPLEMENT_DYNAMIC_CLASS(wxCalendarBox, wxControl)
+
+
+
+wxCalendarBox::wxCalendarBox(wxWindow *parent,
+                            wxWindowID id,
+                            const wxDateTime& date,
+                            const wxPoint& pos,
+                            const wxSize& size,
+                            long style,
+                            const wxString& name)
+{
+    Init();
+    Create(parent, id, date, pos, size, style, name);
+}
+
+
+bool wxCalendarBox::Create(wxWindow *parent,
+                            wxWindowID id,
+                            const wxDateTime& date,
+                            const wxPoint& pos,
+                            const wxSize& size,
+                            long style,
+                            const wxString& name)
+{
+    wxString txt;
+    if (date.IsValid())
+        txt = date.FormatISODate();
+
+    if ( !wxControl::Create(parent, id, pos, size,
+                            style | wxCLIP_CHILDREN | wxWANTS_CHARS,
+                            wxDefaultValidator, name) )
+
+    {
+        return false;
+    }
+
+    InheritAttributes();
+
+    wxSize cs=GetClientSize();
+    wxSize bs=ConvertDialogToPixels(wxSize(10, 0));
+
+    wxBitmap bmp(8, 4);
+    {
+        wxMemoryDC dc;
+
+        dc.SelectObject(bmp);
+        dc.SetBrush(wxBrush(GetBackgroundColour()));
+        dc.SetPen(wxPen(GetBackgroundColour()));
+        dc.DrawRectangle(0,0, 8,4);
+
+        dc.SetBrush(wxBrush(GetForegroundColour()));
+        dc.SetPen(wxPen(GetForegroundColour()));
+        wxPoint pt[3] = { wxPoint(0,0), wxPoint(6,0), wxPoint(3,3) };
+        dc.DrawPolygon(3, pt);
+        dc.SelectObject(wxNullBitmap);
+    }
+    
+    m_txt=new wxTextCtrl(this, CTRLID_TXT, txt, wxDefaultPosition, size, TXTCTRL_FLAGS);
+    m_txt->Connect(wxID_ANY, wxID_ANY, wxEVT_KEY_DOWN, wxKeyEventHandler(wxCalendarBox::OnEditKey), 0, this);
+    m_txt->Connect(wxID_ANY, wxID_ANY, wxEVT_KILL_FOCUS, wxFocusEventHandler(wxCalendarBox::OnKillFocus), 0, this);
+    SetFormat(wxT("%Y-%m-%d"));
+
+    m_btn = new wxBitmapButton(this, CTRLID_BTN, bmp, wxDefaultPosition, bs);
+
+    m_dlg = new wxDialog(this, CTRLID_CAL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
+    m_dlg->SetFont(GetFont());
+
+    wxPanel *panel=new wxPanel(m_dlg, CTRLID_PAN, wxPoint(0, 0), wxDefaultSize, wxSUNKEN_BORDER|wxCLIP_CHILDREN);
+    m_cal = new wxCalendarCtrl(panel, CTRLID_CAL, wxDefaultDateTime, wxPoint(0,0), wxDefaultSize, wxSUNKEN_BORDER);
+    m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_SEL_CHANGED, wxCalendarEventHandler(wxCalendarBox::OnSelChange), 0, this);
+    m_cal->Connect(wxID_ANY, wxID_ANY, wxEVT_KEY_DOWN, wxKeyEventHandler(wxCalendarBox::OnCalKey), 0, this);
+    m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DOUBLECLICKED, wxCalendarEventHandler(wxCalendarBox::OnSelChange), 0, this);
+    m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DAY_CHANGED, wxCalendarEventHandler(wxCalendarBox::OnSelChange), 0, this);
+    m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_MONTH_CHANGED, wxCalendarEventHandler(wxCalendarBox::OnSelChange), 0, this);
+    m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_YEAR_CHANGED, wxCalendarEventHandler(wxCalendarBox::OnSelChange), 0, this);
+
+    wxWindow *yearControl = m_cal->GetYearControl();
+
+    Connect(wxID_ANY, wxID_ANY, wxEVT_SET_FOCUS, wxFocusEventHandler(wxCalendarBox::OnSetFocus));
+
+    wxClientDC dc(yearControl);
+    dc.SetFont(m_font);
+    wxCoord width, dummy;
+    dc.GetTextExtent(wxT("2000"), &width, &dummy);
+    width += ConvertDialogToPixels(wxSize(20,0)).x;
+
+    wxSize calSize = m_cal->GetBestSize();
+    wxSize yearSize = yearControl->GetSize();
+    yearSize.x = width;
+
+    wxPoint yearPosition = yearControl->GetPosition();
+
+    width = yearPosition.x + yearSize.x+2+CALBORDER/2;
+    if (width < calSize.x-4)
+        width = calSize.x-4;
+
+	int calPos = (width-calSize.x)/2;
+	if (calPos == -1)
+	{
+		calPos = 0;
+		width += 2;
+	}
+    m_cal->SetSize(calPos, 0, calSize.x, calSize.y);
+    yearControl->SetSize(width-yearSize.x-CALBORDER/2, yearPosition.y, yearSize.x, yearSize.y);
+	m_cal->GetMonthControl()->Move(0, 0);
+
+    SetInitialSize(size);
+
+    panel->SetClientSize(width+CALBORDER/2, calSize.y-2+CALBORDER);
+    m_dlg->SetClientSize(panel->GetSize());
+
+    return true;
+}
+
+
+void wxCalendarBox::Init()
+{
+    m_dlg = NULL;
+    m_txt = NULL;
+    m_cal = NULL;
+    m_btn = NULL;
+
+    m_dropped = false;
+    m_ignoreDrop = false;
+}
+
+
+bool wxCalendarBox::Destroy()
+{
+    if (m_cal)
+        m_cal->Destroy();
+    if (m_dlg)
+        m_dlg->Destroy();
+    if (m_txt)
+        m_txt->Destroy();
+    if (m_btn)
+        m_btn->Destroy();
+
+    m_dlg = NULL;
+    m_txt = NULL;
+    m_cal = NULL;
+    m_btn = NULL;
+
+    return wxControl::Destroy();
+}
+
+
+void wxCalendarBox::DoMoveWindow(int x, int y, int w, int h)
+{
+    wxControl::DoMoveWindow(x, y, w, h);
+    if (m_dropped)
+    {
+        DropDown();
+    }
+}
+
+
+wxSize wxCalendarBox::DoGetBestSize() const
+{
+    int bh=m_btn->GetBestSize().y;
+    int eh=m_txt->GetBestSize().y;
+    return wxSize(100, bh > eh ? bh : eh);
+}
+
+
+void wxCalendarBox::OnSize(wxSizeEvent& event)
+{
+    if ( m_btn )
+    {
+        wxSize sz = GetClientSize();
+
+        wxSize bs=m_btn->GetSize();
+        int eh=m_txt->GetBestSize().y;
+
+        m_txt->SetSize(TXTPOSX, TXTPOSY, sz.x-bs.x-TXTPOSX, sz.y > eh ? eh-TXTPOSY : sz.y-TXTPOSY);
+        m_btn->SetSize(sz.x - bs.x, 0, bs.x, sz.y);
+    }
+
+    event.Skip();
+}
+
+
+bool wxCalendarBox::Show(bool show)
+{
+    if ( !wxControl::Show(show) )
+    {
+        return false;
+    }
+
+    if (!show)
+    {
+        if (m_dlg)
+        {
+            m_dlg->Hide();
+            m_dropped = false;
+        }
+    }
+
+    return true;
+}
+
+
+bool wxCalendarBox::Enable(bool enable)
+{
+    if ( !wxControl::Enable(enable) )
+    {
+        return false;
+    }
+
+    if (!enable)
+    {
+        if (m_cal)
+            m_cal->Hide();
+    }
+    if (m_btn)
+        m_btn->Enable(enable);
+    return true;
+}
+
+
+bool wxCalendarBox::SetFormat(const wxChar *fmt)
+{
+    wxDateTime dt;
+    dt.ParseFormat(wxT("2003-10-13"), wxT("%Y-%m-%d"));
+    wxString str=dt.Format(fmt);
+    wxChar *p=(wxChar*)str.c_str();
+
+    m_format=wxEmptyString;
+
+    while (*p)
+    {
+        int n=wxAtoi(p);
+        if (n == dt.GetDay())
+        {
+            m_format.Append(wxT("%d"));
+            p += 2;
+        }
+        else if (n == (int)dt.GetMonth()+1)
+        {
+            m_format.Append(wxT("%m"));
+            p += 2;
+        }
+        else if (n == dt.GetYear())
+        {
+            m_format.Append(wxT("%Y"));
+            p += 4;
+        }
+        else
+            m_format.Append(*p++);
+    }
+
+    if (m_txt)
+    {
+        wxArrayString valArray;
+        wxChar c;
+        for (c='0'; c <= '9'; c++)
+            valArray.Add(wxString(c, 1));
+        wxChar *p=(wxChar*)m_format.c_str();
+        while (*p)
+        {
+            if (*p == '%')
+                p += 2;
+            else
+                valArray.Add(wxString(*p++, 1));
+        }
+        wxTextValidator tv(wxFILTER_INCLUDE_CHAR_LIST);
+        tv.SetIncludes(valArray);
+        
+        m_txt->SetValidator(tv);
+    }
+    return true;
+}
+
+
+wxDateTime wxCalendarBox::GetValue()
+{
+    wxDateTime dt;
+    wxString txt=m_txt->GetValue();
+
+    if (!txt.IsEmpty())
+        dt.ParseFormat(txt, m_format);
+
+    return dt;
+}
+
+
+bool wxCalendarBox::SetValue(const wxDateTime& date)
+{
+    bool retval=false;
+
+    if (m_cal)
+    {
+        if (date.IsValid())
+            m_txt->SetValue(date.FormatISODate());
+        else
+            m_txt->SetValue(wxEmptyString);
+    }
+    return retval;
+}
+
+
+void wxCalendarBox::DropDown(bool down)
+{
+    if (m_dlg)
+    {
+        if (down)
+        {
+            if (m_txt->GetValue().IsEmpty())
+                m_cal->SetDate(wxDateTime::Today());
+            else
+            {
+                wxDateTime dt;
+                dt.ParseFormat(m_txt->GetValue(), m_format);
+                m_cal->SetDate(dt);
+            }
+            wxPoint pos=GetParent()->ClientToScreen(GetPosition());
+
+            m_dlg->Move(pos.x, pos.y + GetSize().y);
+            m_dlg->Show();
+            m_dropped = true;
+        }
+        else
+        {
+			if (m_dropped)
+				m_dlg->Hide();
+            m_dropped = false;
+        }
+    }
+}
+
+
+void wxCalendarBox::OnChildSetFocus(wxChildFocusEvent &ev)
+{
+    ev.Skip();
+    m_ignoreDrop = false;
+
+	wxWindow  *w=(wxWindow*)ev.GetEventObject();
+	while (w)
+	{
+		if (w == m_dlg)
+			return;
+		w = w->GetParent();
+	}
+
+	if (m_dropped)
+	{
+		DropDown(false);
+		if (ev.GetEventObject() == m_btn)
+			m_ignoreDrop = true;
+    }
+}
+
+    
+void wxCalendarBox::OnClick(wxCommandEvent& event)
+{
+    if (m_ignoreDrop)
+    {
+        m_ignoreDrop = false;
+        m_txt->SetFocus();
+    }
+    else
+    {
+        DropDown();
+        m_cal->SetFocus();
+    }
+}
+
+
+void wxCalendarBox::OnSetFocus(wxFocusEvent &ev)
+{
+    if (m_txt)
+    {
+        m_txt->SetFocus();
+        m_txt->SetSelection(0, 100);
+    }
+}
+
+
+void wxCalendarBox::OnKillFocus(wxFocusEvent &ev)
+{
+#ifdef __WXGTK__
+    ev.Skip();
+#endif
+
+    wxDateTime dt;
+    dt.ParseFormat(m_txt->GetValue(), m_format);
+    if (!dt.IsValid())
+        m_txt->SetValue(wxEmptyString);
+    else
+        m_txt->SetValue(dt.Format(m_format));
+}
+
+
+void wxCalendarBox::OnSelChange(wxCalendarEvent &ev)
+{
+    if (m_cal)
+    {
+        m_txt->SetValue(m_cal->GetDate().FormatISODate());
+        if (ev.GetEventType() == wxEVT_CALENDAR_DOUBLECLICKED)
+        {
+            DropDown(false);
+            m_txt->SetFocus();
+        }
+    }
+    ev.SetEventObject(this);
+    ev.SetId(GetId());
+    GetParent()->ProcessEvent(ev);
+}
+
+
+void wxCalendarBox::OnText(wxCommandEvent &ev)
+{
+    ev.SetEventObject(this);
+    ev.SetId(GetId());
+    GetParent()->ProcessEvent(ev);
+
+    // We'll create an additional event if the date is valid.
+    // If the date isn't valid, the user's probable in the middle of typing
+    wxString txt=m_txt->GetValue();
+    wxDateTime dt;
+    if (!txt.IsEmpty())
+        dt.ParseFormat(txt, m_format);
+
+    wxCalendarEvent cev(m_cal, wxEVT_CALENDAR_SEL_CHANGED);
+    cev.SetEventObject(this);
+    cev.SetId(GetId());
+    cev.SetDate(dt);
+
+    GetParent()->ProcessEvent(cev);
+}
+
+
+void wxCalendarBox::OnEditKey(wxKeyEvent & ev)
+{
+    if (ev.GetKeyCode() == WXK_DOWN && !ev.HasModifiers())
+        DropDown();
+    else
+        ev.Skip();
+}
+
+
+void wxCalendarBox::OnCalKey(wxKeyEvent & ev)
+{
+    if (ev.GetKeyCode() == WXK_ESCAPE && !ev.HasModifiers())
+        DropDown(false);
+    else
+        ev.Skip();
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSQLGrid.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSQLGrid.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSQLGrid.cpp (revision 8187)
@@ -0,0 +1,297 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlSQLGrid.cpp - SQL Query result window
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/clipbrd.h>
+
+#include "db/pgConn.h"
+#include "ctl/ctlSQLGrid.h"
+#include "utils/sysSettings.h"
+#include "frm/frmExport.h"
+
+
+BEGIN_EVENT_TABLE(ctlSQLGrid, wxGrid)
+    EVT_MENU(MNU_COPY, ctlSQLGrid::OnCopy)
+END_EVENT_TABLE()
+
+IMPLEMENT_DYNAMIC_CLASS(ctlSQLGrid, wxGrid)
+
+ctlSQLGrid::ctlSQLGrid()
+{
+}
+
+ctlSQLGrid::ctlSQLGrid(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size)
+: wxGrid(parent, id, pos, size, wxWANTS_CHARS|wxVSCROLL|wxHSCROLL)
+{
+    wxFont fntLabel(settings->GetSystemFont());
+    fntLabel.SetWeight(wxBOLD);
+    SetLabelFont(fntLabel);
+    SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
+    SetRowLabelSize(50);
+    SetColLabelSize(fntLabel.GetPointSize() *4);
+    SetDefaultCellOverflow(false);
+
+    wxAcceleratorEntry entries[1];
+    entries[0].Set(wxACCEL_CTRL,                (int)'C',      MNU_COPY);
+    wxAcceleratorTable accel(1, entries);
+    SetAcceleratorTable(accel);
+
+    Connect(wxID_ANY, wxEVT_GRID_LABEL_LEFT_DCLICK, wxGridEventHandler(ctlSQLGrid::OnLabelDoubleClick));
+}
+
+void ctlSQLGrid::OnCopy(wxCommandEvent& ev)
+{
+    Copy();
+}
+
+wxString ctlSQLGrid::GetExportLine(int row)
+{
+    return GetExportLine(row, 0, GetNumberCols() - 1);
+}
+
+
+wxString ctlSQLGrid::GetExportLine(int row, int col1, int col2)
+{
+    wxArrayInt cols;
+    wxString str;
+    int i;
+
+    if (col2 < col1)
+        return str;
+
+    cols.Alloc(col2 - col1 + 1);
+    for (i = col1; i <= col2; i++) 
+	{
+        cols.Add(i);
+    }
+
+    return GetExportLine(row, cols);
+}
+
+wxString ctlSQLGrid::GetExportLine(int row, wxArrayInt cols)
+{
+    wxString str;
+    unsigned int col;
+
+    if (GetNumberCols() == 0)
+        return str;
+
+    for (col=0 ; col < cols.Count() ; col++)
+    {
+        if (col > 0)
+            str.Append(settings->GetCopyColSeparator());
+
+        wxString text = GetCellValue(row, cols[col]);
+
+		bool needQuote  = false;
+		if (settings->GetCopyQuoting() == 1)
+		{
+            needQuote = IsColText(cols[col]);
+		}
+		else if (settings->GetCopyQuoting() == 2)
+			/* Quote everything */
+			needQuote = true;
+
+		if (needQuote)
+            str.Append(settings->GetCopyQuoteChar());
+        str.Append(text);
+        if (needQuote)
+            str.Append(settings->GetCopyQuoteChar());
+    }    
+    return str;
+}
+
+int ctlSQLGrid::Copy()
+{
+    wxString str;
+    int copied = 0;
+    size_t i;
+
+    if (GetSelectedRows().GetCount()) 
+	{
+        wxArrayInt rows = GetSelectedRows();
+
+        for (i=0 ; i < rows.GetCount() ; i++)
+        {
+            str.Append(GetExportLine(rows.Item(i)));
+    
+            if (rows.GetCount() > 1)
+                str.Append(END_OF_LINE);
+        }
+
+        copied = rows.GetCount();
+    }
+    else if (GetSelectedCols().GetCount()) 
+	{
+        wxArrayInt cols = GetSelectedCols();
+        size_t numRows = GetNumberRows();
+
+        for (i=0 ; i < numRows ; i++)
+        {
+            str.Append(GetExportLine(i, cols));
+    
+            if (numRows > 1)
+                str.Append(END_OF_LINE);
+        }
+
+        copied = numRows;
+    }
+    else if (GetSelectionBlockTopLeft().GetCount() > 0 &&
+        GetSelectionBlockBottomRight().GetCount() > 0) 
+	{
+        unsigned int x1, x2, y1, y2;
+
+        x1 = GetSelectionBlockTopLeft()[0].GetCol();
+        x2 = GetSelectionBlockBottomRight()[0].GetCol();
+        y1 = GetSelectionBlockTopLeft()[0].GetRow();
+        y2 = GetSelectionBlockBottomRight()[0].GetRow();
+
+        for (i = y1; i <= y2; i++) 
+		{
+            str.Append(GetExportLine(i, x1, x2));
+
+            if (y2 > y1)
+                str.Append(END_OF_LINE);
+        }
+
+        copied = y2 - y1 + 1;
+    }
+    else 
+	{
+        int row, col;
+
+        row = GetGridCursorRow();
+        col = GetGridCursorCol();
+
+        str.Append(GetExportLine(row, col, col));
+        copied = 1;
+    }
+
+    if (copied && wxTheClipboard->Open())
+    {
+        wxTheClipboard->SetData(new wxTextDataObject(str));
+        wxTheClipboard->Close();
+    }
+    else {
+        copied = 0;
+    }
+
+    return copied;
+}
+
+#define EXTRAEXTENT_HEIGHT 6
+#define EXTRAEXTENT_WIDTH  6
+
+void ctlSQLGrid::OnLabelDoubleClick(wxGridEvent& event)
+{
+    int maxHeight, maxWidth;
+    GetClientSize(&maxWidth, &maxHeight);
+    int row = event.GetRow();
+    int col = event.GetCol();
+
+    int extent, extentWant=0;
+
+    if (row >= 0)
+    {
+        for (col=0 ; col < GetNumberCols() ; col++)
+        {
+            extent = GetBestSize(row, col).GetHeight();
+            if (extent > extentWant)
+                extentWant = extent;
+        }
+
+        extentWant += EXTRAEXTENT_HEIGHT;
+        extentWant = wxMax(extentWant, GetRowMinimalAcceptableHeight());
+        extentWant = wxMin(extentWant, maxHeight*3/4);
+        int currentHeight = GetRowHeight(row);
+            
+        if (currentHeight >= maxHeight*3/4 || currentHeight == extentWant)
+            extentWant = GetRowMinimalAcceptableHeight();
+        else if (currentHeight < maxHeight/4)
+            extentWant = wxMin(maxHeight/4, extentWant);
+        else if (currentHeight < maxHeight/2)
+            extentWant = wxMin(maxHeight/2, extentWant);
+        else if (currentHeight < maxHeight*3/4)
+            extentWant = wxMin(maxHeight*3/4, extentWant);
+
+        if (extentWant != currentHeight)
+        {
+            BeginBatch();
+            if(IsCellEditControlShown())
+            {
+                HideCellEditControl();
+                SaveEditControlValue();
+            }
+
+            SetRowHeight(row, extentWant);
+            EndBatch();
+        }
+    }
+    else if (col >= 0)
+    {
+        for (row=0 ; row < GetNumberRows() ; row++)
+        {
+            if (CheckRowPresent(row))
+            {
+                extent = GetBestSize(row, col).GetWidth();
+                if (extent > extentWant)
+                    extentWant=extent;
+            }
+        }
+
+        extentWant += EXTRAEXTENT_WIDTH;
+        extentWant = wxMax(extentWant, GetColMinimalAcceptableWidth());
+        extentWant = wxMin(extentWant, maxWidth*3/4);
+        int currentWidth=GetColumnWidth(col);
+            
+        if (currentWidth >= maxWidth*3/4 || currentWidth == extentWant)
+            extentWant = GetColMinimalAcceptableWidth();
+        else if (currentWidth < maxWidth/4)
+            extentWant = wxMin(maxWidth/4, extentWant);
+        else if (currentWidth < maxWidth/2)
+            extentWant = wxMin(maxWidth/2, extentWant);
+        else if (currentWidth < maxWidth*3/4)
+            extentWant = wxMin(maxWidth*3/4, extentWant);
+
+        if (extentWant != currentWidth)
+        {
+            BeginBatch();
+            if(IsCellEditControlShown())
+            {
+                HideCellEditControl();
+                SaveEditControlValue();
+            }
+            SetColumnWidth(col, extentWant);
+            EndBatch();
+        }
+    }
+}
+
+wxSize ctlSQLGrid::GetBestSize(int row, int col)
+{
+    wxSize size;
+
+    wxGridCellAttr* attr = GetCellAttr(row, col);
+    wxGridCellRenderer* renderer = attr->GetRenderer(this, row, col);
+    if ( renderer )
+    {
+        wxClientDC dc(GetGridWindow());
+        size = renderer->GetBestSize(*this, *attr, dc, row, col);
+        renderer->DecRef();
+    }
+
+    attr->DecRef();
+
+    return size;
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlListView.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlListView.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlListView.cpp (revision 8187)
@@ -0,0 +1,107 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlListView.cpp - enhanced listview control
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/imaglist.h>
+
+// App headers
+#include "ctl/ctlListView.h"
+#include "utils/misc.h"
+
+
+ctlListView::ctlListView(wxWindow *p, int id, wxPoint pos, wxSize siz, long attr)
+: wxListView(p, id, pos, siz, attr | wxLC_REPORT)
+{
+}
+
+
+long ctlListView::GetSelection()
+{
+    return GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+}
+
+
+wxString ctlListView::GetText(long row, long col)
+{
+    wxListItem item;
+    item.SetId(row);
+    item.SetColumn(col);
+    item.SetMask(wxLIST_MASK_TEXT);
+    GetItem(item);
+    return item.GetText();
+};
+
+
+void ctlListView::AddColumn(const wxChar *text, int size, int format)
+{
+    if (size == wxLIST_AUTOSIZE || size == wxLIST_AUTOSIZE_USEHEADER)
+    {
+        InsertColumn(GetColumnCount(), text, format, size);
+    }
+    else
+    {
+        InsertColumn(GetColumnCount(), text, format, ConvertDialogToPixels(wxPoint(size,0)).x);
+    }
+}
+
+
+long ctlListView::AppendItem(int icon, const wxChar *val, const wxChar *val2, const wxChar *val3, const wxChar *val4)
+{
+    long pos=InsertItem(GetItemCount(), val, icon);
+    if (val2 && *val2)
+        SetItem(pos, 1, val2);
+    if (val3 && *val3)
+        SetItem(pos, 2, val3);
+    if (val4 && *val4)
+        SetItem(pos, 3, val4);
+
+    return pos;
+}
+
+
+void ctlListView::CreateColumns(wxImageList *images, const wxString &left, const wxString &right, int leftSize)
+{
+    int rightSize;
+    if (leftSize < 0)
+    {
+#ifdef __WXMAC__
+        leftSize = rightSize = (GetParent()->GetSize().GetWidth() - 20)/2;
+#else
+        leftSize = rightSize = GetSize().GetWidth()/2;
+#endif
+    }
+    else
+    {
+        if (leftSize)
+            leftSize = ConvertDialogToPixels(wxPoint(leftSize, 0)).x;
+
+#ifdef __WXMAC__
+        rightSize = (GetParent()->GetSize().GetWidth() - 20) - leftSize;
+#else
+        rightSize = GetClientSize().GetWidth()-leftSize;
+#endif
+    }
+    if (!leftSize)
+    {
+        InsertColumn(0, left, wxLIST_FORMAT_LEFT, GetClientSize().GetWidth());
+    }
+    else
+    {
+        InsertColumn(0, left, wxLIST_FORMAT_LEFT, leftSize);
+        InsertColumn(1, right, wxLIST_FORMAT_LEFT, rightSize);
+    }
+
+    if (images)
+        SetImageList(images, wxIMAGE_LIST_SMALL);
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/module.mk
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/module.mk (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/module.mk (revision 8187)
@@ -0,0 +1,34 @@
+#######################################################################
+#
+# pgAdmin III - PostgreSQL Tools
+# $Id$
+# Copyright (C) 2002 - 2010, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# module.mk - pgadmin/ctl/ Makefile fragment
+#
+#######################################################################
+
+pgadmin3_SOURCES += \
+	$(srcdir)/ctl/calbox.cpp \
+        $(srcdir)/ctl/ctlComboBox.cpp \
+        $(srcdir)/ctl/ctlListView.cpp \
+        $(srcdir)/ctl/ctlMenuToolbar.cpp \
+        $(srcdir)/ctl/ctlSQLBox.cpp \
+        $(srcdir)/ctl/ctlSQLGrid.cpp \
+        $(srcdir)/ctl/ctlSQLResult.cpp \
+        $(srcdir)/ctl/ctlSecurityPanel.cpp \
+        $(srcdir)/ctl/ctlTree.cpp \
+        $(srcdir)/ctl/explainCanvas.cpp \
+        $(srcdir)/ctl/explainShape.cpp \
+        $(srcdir)/ctl/timespin.cpp \
+        $(srcdir)/ctl/xh_calb.cpp \
+        $(srcdir)/ctl/xh_ctlcombo.cpp \
+        $(srcdir)/ctl/xh_ctltree.cpp \
+        $(srcdir)/ctl/xh_sqlbox.cpp \
+        $(srcdir)/ctl/xh_timespin.cpp
+
+EXTRA_DIST += \
+        $(srcdir)/ctl/module.mk
+
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlComboBox.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlComboBox.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlComboBox.cpp (revision 8187)
@@ -0,0 +1,237 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlComboBox.cpp - enhanced combobox control
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+// App headers
+#include "ctl/ctlComboBox.h"
+#include "db/pgConn.h"
+#include "db/pgSet.h"
+
+
+class StringClientData : public wxClientData
+{
+public:
+    StringClientData(const wxChar *c) { str=c; }
+    wxString str;
+};
+
+
+
+
+int ctlComboBoxFix::Append(const wxString& item, const wxString &str)
+{
+    return wxComboBox::Append(item, new StringClientData(str));
+}
+
+
+int ctlComboBoxFix::Append(const wxString& item, long l)
+{
+    return wxComboBox::Append(item, (void*)l);
+}
+
+
+int ctlComboBoxFix::Append(const wxString& item, OID oid)
+{
+    return wxComboBox::Append(item, (void*)oid);
+}
+
+
+int ctlComboBoxFix::FillLongKey(pgConn *conn, const wxChar *qry)
+{
+    int cnt=0;
+    pgSetIterator set(conn->ExecuteSet(qry));
+    while (set.RowsLeft())
+    {
+        long l=set.GetLong(0);
+        wxString txt=set.GetVal(1);
+        Append(txt, l);
+        cnt++;
+    }
+    return cnt;
+}
+
+
+int ctlComboBoxFix::FillOidKey(pgConn *conn, const wxChar *qry)
+{
+    int cnt=0;
+    pgSetIterator set(conn->ExecuteSet(qry));
+    while (set.RowsLeft())
+    {
+        OID oid=set.GetOid(0);
+        wxString txt=set.GetVal(1);
+        Append(txt, oid);
+        cnt++;
+    }
+    return cnt;
+}
+
+
+int ctlComboBoxFix::FillStringKey(pgConn *conn, const wxChar *qry)
+{
+    int cnt=0;
+    pgSetIterator set(conn->ExecuteSet(qry));
+    while (set.RowsLeft())
+    {
+        wxString str=set.GetVal(0);
+        wxString txt=set.GetVal(1);
+        Append(txt, str);
+        cnt++;
+    }
+    return cnt;
+}
+
+long ctlComboBoxFix::GetLongKey(int sel)
+{
+    if (sel < 0)
+        sel = GetSelection();
+    return (long)GetClientData(sel);
+}
+
+OID ctlComboBoxFix::GetOIDKey(int sel)
+{
+    if (sel < 0)
+        sel = GetSelection();
+    return (OID)GetClientData(sel);
+}
+
+wxString ctlComboBoxFix::GetStringKey(int sel)
+{
+    if (sel < 0)
+        sel = GetSelection();
+    StringClientData *scd=(StringClientData*)GetClientObject(sel);
+    if (scd)
+        return scd->str;
+    return wxEmptyString;
+}
+
+
+ctlComboBoxFix::ctlComboBoxFix(wxWindow *wnd, int id, wxPoint pos, wxSize siz, long attr)
+: wxComboBox(wnd, id, wxEmptyString, pos, siz, 0, NULL, attr)
+{
+}
+
+
+bool ctlComboBoxFix::SetKey(long val)
+{
+    unsigned int i;
+    for (i=0 ; i < GetCount() ; i++)
+    {
+        if (GetLongKey(i) == val)
+        {
+            SetSelection(i);
+            return true;
+        }
+    }
+    SetSelection(wxNOT_FOUND);
+    return false;
+}
+
+
+bool ctlComboBoxFix::SetKey(OID val)
+{
+    unsigned int i;
+    for (i=0 ; i < GetCount() ; i++)
+    {
+        if (GetOIDKey(i) == val)
+        {
+            SetSelection(i);
+            return true;
+        }
+    }
+    SetSelection(wxNOT_FOUND);
+    return false;
+}
+
+
+bool ctlComboBoxFix::SetKey(const wxString &val)
+{
+    unsigned int i;
+    for (i=0 ; i < GetCount() ; i++)
+    {
+        if (GetStringKey(i) == val)
+        {
+            SetSelection(i);
+            return true;
+        }
+    }
+    SetSelection(wxNOT_FOUND);
+    return false;
+}
+
+
+////////////////////////////////////////////
+
+ctlComboBox::ctlComboBox(wxWindow *wnd, int id, wxPoint pos, wxSize siz, long attr)
+: ctlComboBoxFix(wnd, id, pos, siz, attr)
+{
+#ifdef __WXGTK__
+    SetEditable(false);
+#endif
+}
+
+
+int ctlComboBox::GuessSelection(wxCommandEvent &ev)
+{
+    if (ev.GetEventType() != wxEVT_COMMAND_TEXT_UPDATED)
+        return GetGuessedSelection();
+
+    wxString str=wxComboBox::GetValue();
+    if (str.Length())
+    {
+        long pos=GetInsertionPoint();
+    
+        long sel, count=GetCount();
+        int len=str.Length();
+        for (sel = 0 ; sel < count ; sel++)
+        {
+            if (str == GetString(sel).Left(len))
+            {
+                SetSelection(sel);
+                wxString current = GetString(sel);
+                SetSelection(pos, current.Length());
+                return sel;
+            }
+        }
+    }
+    return -1;
+}
+
+
+int ctlComboBox::GetGuessedSelection() const
+{
+    int sel=GetCurrentSelection();
+
+    if (sel < 0)
+        sel = FindString(GetValue());
+    return sel;
+}
+
+int ctlComboBox::GetSelection() const
+{
+    int sel=0;
+#ifdef __WXMSW__
+    sel=GetCurrentSelection();
+
+    if (sel < 0)
+#endif
+        sel = FindString(GetValue());
+    return sel;
+}
+
+wxString ctlComboBox::GetGuessedStringSelection() const
+{
+    int sel=GetGuessedSelection();
+    if (sel < 0)
+        return wxEmptyString;
+    else
+        return GetString(sel);
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSQLBox.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSQLBox.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSQLBox.cpp (revision 8187)
@@ -0,0 +1,604 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlSQLBox.cpp - SQL syntax highlighting textbox
+//
+//////////////////////////////////////////////////////////////////////////
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/stc/stc.h>
+#include <wx/sysopt.h>
+
+// App headers
+#include "pgAdmin3.h"
+#include "db/pgSet.h"
+#include "ctl/ctlSQLBox.h"
+#include "dlg/dlgFindReplace.h"
+#include "frm/menu.h"
+
+// Must be last for reasons I haven't fully grokked...
+#include <wx/regex.h>
+
+wxString ctlSQLBox::sqlKeywords;
+
+// Additional pl/pgsql keywords we should highlight
+wxString plpgsqlKeywords = wxT(" elsif exception exit loop raise record return text while");
+//
+// Additional Text Search keywords we should highlight
+wxString ftsKeywords = wxT(" gettoken lextypes headline init lexize");
+
+// Additional pgScript keywords we should highlight
+wxString pgscriptKeywords = wxT(" assert break columns continue date datetime file go lines ")
+                        wxT(" log print record reference regexrmline string waitfor while");
+
+BEGIN_EVENT_TABLE(ctlSQLBox, wxStyledTextCtrl)
+    EVT_KEY_DOWN(ctlSQLBox::OnKeyDown)
+    EVT_MENU(MNU_FIND,ctlSQLBox::OnSearchReplace)
+    EVT_MENU(MNU_AUTOCOMPLETE,ctlSQLBox::OnAutoComplete)
+    EVT_KILL_FOCUS(ctlSQLBox::OnKillFocus)
+    EVT_STC_UPDATEUI(-1,  ctlSQLBox::OnPositionStc)
+END_EVENT_TABLE()
+
+
+
+IMPLEMENT_DYNAMIC_CLASS(ctlSQLBox, wxStyledTextCtrl)
+
+
+ctlSQLBox::ctlSQLBox()
+{
+    m_dlgFindReplace=0;
+    m_autoIndent=false;
+    m_autocompDisabled=false;
+}
+
+
+ctlSQLBox::ctlSQLBox(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
+{
+    m_dlgFindReplace=0;
+
+    m_database=NULL;
+
+    m_autocompDisabled=false;
+
+    Create(parent, id, pos, size, style);
+}
+
+
+void ctlSQLBox::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
+{
+    wxStyledTextCtrl::Create(parent,id , pos, size, style);
+
+    // Clear all styles
+    StyleClearAll();
+    
+    // Font
+    extern sysSettings *settings;
+    wxFont fntSQLBox = settings->GetSQLFont();
+
+    StyleSetFont(wxSTC_STYLE_DEFAULT, fntSQLBox);
+    StyleSetFont(0, fntSQLBox);
+    StyleSetFont(1, fntSQLBox);
+    StyleSetFont(2, fntSQLBox);
+    StyleSetFont(3, fntSQLBox);
+    StyleSetFont(4, fntSQLBox);
+    StyleSetFont(5, fntSQLBox);
+    StyleSetFont(6, fntSQLBox);
+    StyleSetFont(7, fntSQLBox);
+    StyleSetFont(8, fntSQLBox);
+    StyleSetFont(9, fntSQLBox);
+    StyleSetFont(10, fntSQLBox);
+    StyleSetFont(11, fntSQLBox);
+
+    SetMarginWidth(1, 0);
+    SetTabWidth(settings->GetIndentSpaces());
+    SetUseTabs(!settings->GetSpacesForTabs());
+    
+    // Setup the different highlight colurs
+    StyleSetForeground(0,  wxColour(0x80, 0x80, 0x80));
+    StyleSetForeground(1,  wxColour(0x00, 0x7f, 0x00));
+    StyleSetForeground(2,  wxColour(0x00, 0x7f, 0x00));
+    StyleSetForeground(3,  wxColour(0x7f, 0x7f, 0x7f));
+    StyleSetForeground(4,  wxColour(0x00, 0x7f, 0x7f));
+    StyleSetForeground(5,  wxColour(0x00, 0x00, 0x7f));
+    StyleSetForeground(6,  wxColour(0x7f, 0x00, 0x7f));
+    StyleSetForeground(7,  wxColour(0x7f, 0x00, 0x7f));
+    StyleSetForeground(8,  wxColour(0x00, 0x7f, 0x7f));
+    StyleSetForeground(9,  wxColour(0x7f, 0x7f, 0x7f));
+    StyleSetForeground(10, wxColour(0x00, 0x00, 0x00));
+    StyleSetForeground(11, wxColour(0x00, 0x00, 0x00));
+
+    // Brace maching styles
+    StyleSetBackground(34, wxColour(0x99, 0xF9, 0xFF));
+    StyleSetBackground(35, wxColour(0xFF, 0xCF, 0x27));
+
+    // SQL Lexer and keywords.
+    if (sqlKeywords.IsEmpty())
+        FillKeywords(sqlKeywords);
+    SetLexer(wxSTC_LEX_SQL);
+    SetKeyWords(0, sqlKeywords + plpgsqlKeywords + ftsKeywords + pgscriptKeywords);
+
+    wxAcceleratorEntry entries[2];
+    entries[0].Set(wxACCEL_CTRL, (int)'F', MNU_FIND);
+    entries[1].Set(wxACCEL_CTRL, (int)' ', MNU_AUTOCOMPLETE);
+    wxAcceleratorTable accel(2, entries);
+    SetAcceleratorTable(accel);
+
+    // Autocompletion configuration
+    AutoCompSetSeparator('\t');
+    AutoCompSetChooseSingle(true);
+    AutoCompSetIgnoreCase(true);
+    AutoCompSetFillUps(wxT(" \t"));
+    AutoCompSetDropRestOfWord(true);
+
+    SetEOLMode(settings->GetLineEndingType());
+}
+
+void ctlSQLBox::SetDatabase(pgConn *db)
+{
+    m_database = db;
+}
+
+void ctlSQLBox::OnSearchReplace(wxCommandEvent& ev)
+{
+    if (!m_dlgFindReplace)
+    {
+        m_dlgFindReplace = new dlgFindReplace(this);
+        m_dlgFindReplace->Show(true);
+        m_dlgFindReplace->FocusSearch();
+    }
+    else
+    {
+        m_dlgFindReplace->Show(true);
+        m_dlgFindReplace->SetFocus();
+        m_dlgFindReplace->FocusSearch();
+    }
+}
+
+bool ctlSQLBox::Find(const wxString &find, bool wholeWord, bool matchCase, bool useRegexps, bool startAtTop, bool reverse)
+{
+    if (!DoFind(find, wxString(wxEmptyString), false, wholeWord, matchCase, useRegexps, startAtTop, reverse))
+    {
+        wxMessageBox(_("Reached the end of the document"), _("Find text"), wxICON_EXCLAMATION | wxOK, this);
+        return false;
+    }
+    return true;
+}
+
+bool ctlSQLBox::Replace(const wxString &find, const wxString &replace, bool wholeWord, bool matchCase, bool useRegexps, bool startAtTop, bool reverse)
+{
+    if (!DoFind(find, replace, true, wholeWord, matchCase, useRegexps, startAtTop, reverse))
+    {
+        wxMessageBox(_("Reached the end of the document"), _("Replace text"), wxICON_EXCLAMATION | wxOK, this);
+        return false;
+    }
+    return true;
+}
+
+bool ctlSQLBox::ReplaceAll(const wxString &find, const wxString &replace, bool wholeWord, bool matchCase, bool useRegexps)
+{
+    // Use DoFind to repeatedly replace text
+    int count = 0;
+    int initialPos = GetCurrentPos();
+    GotoPos(0);
+
+    while(DoFind(find, replace, true, wholeWord, matchCase, useRegexps, false, false))
+        count++;
+
+    GotoPos(initialPos);
+
+    wxString msg;
+    msg.Printf(wxPLURAL("%d replacement made.", "%d replacements made.", count), count);
+    wxMessageBox(msg, _("Replace all"));
+
+    if (count)
+        return true;
+    else
+        return false;
+}
+
+bool ctlSQLBox::DoFind(const wxString &find, const wxString &replace, bool doReplace, bool wholeWord, bool matchCase, bool useRegexps, bool startAtTop, bool reverse)
+{
+    int flags = 0;
+    int startPos = GetSelectionStart();
+    int endPos = GetTextLength();
+
+    // Setup flags
+    if (wholeWord)
+        flags |= wxSTC_FIND_WHOLEWORD;
+
+    if (matchCase)
+        flags |= wxSTC_FIND_MATCHCASE;
+
+    // Replace the current selection, if there is one and it matches the find param.
+    wxString current = GetSelectedText();
+    if (doReplace)
+    {
+        if (useRegexps)
+        {
+            CharacterRange cr = RegexFindText(GetSelectionStart(), GetSelectionEnd(), find);
+            if (GetSelectionStart() == cr.cpMin && GetSelectionEnd() == cr.cpMax)
+            {
+                if (cr.cpMin == cr.cpMax) // Must be finding a special char, such as $ (line end)
+                {
+                    InsertText(cr.cpMax, replace);
+                    SetSelection(cr.cpMax, cr.cpMax + replace.Length());
+                    SetCurrentPos(cr.cpMax + replace.Length());
+
+                    // Stop if we've got to the end. This is important for the $
+                    // case where it'll just keep finding the end of the line!!
+                    if ((int)(cr.cpMin + replace.Length()) == GetLength())
+                        return false;
+                }
+                else
+                {
+                    ReplaceSelection(replace);
+                    SetSelection(startPos, startPos + replace.Length());
+                    SetCurrentPos(startPos + replace.Length());
+                }
+            }
+        }
+        else if ((matchCase && current == find) || (!matchCase && current.Upper() == find.Upper()))
+        {
+            ReplaceSelection(replace);
+            if (!reverse)
+            {
+                SetSelection(startPos, startPos + replace.Length());
+                SetCurrentPos(startPos + replace.Length());
+            }
+            else
+            {
+                SetSelection(startPos + replace.Length(), startPos);
+                SetCurrentPos(startPos);
+            }
+        }
+    }
+
+    ////////////////////////////////////////////////////////////////////////
+    // Figure out the starting position for the next search
+    ////////////////////////////////////////////////////////////////////////
+
+    if (startAtTop)
+    {
+        startPos = 0;
+        endPos = GetTextLength();
+    }
+    else
+    {
+        if (reverse)
+        {
+            endPos = 0;
+            startPos = GetCurrentPos();
+        }
+        else
+        {
+            endPos = GetTextLength();
+            startPos = GetCurrentPos();
+        }
+    }
+
+    size_t selStart = 0, selEnd = 0;
+    
+    if (useRegexps)
+    {
+        CharacterRange cr = RegexFindText(startPos, endPos, find);
+        selStart = cr.cpMin;
+        selEnd = cr.cpMax;
+    }
+    else
+    {
+        selStart = FindText(startPos, endPos, find, flags);
+        selEnd = selStart + find.Length();
+    }
+
+    if (selStart >= 0 && selStart != (size_t)(-1))
+    {
+        if (reverse)
+        {
+            SetCurrentPos(selStart);
+            SetSelection(selEnd, selStart);
+        }
+        else
+        {
+            SetCurrentPos(selEnd);
+            SetSelection(selStart, selEnd);
+        }
+        EnsureCaretVisible();
+        return true;
+    }
+    else
+        return false;
+}
+
+void ctlSQLBox::OnKeyDown(wxKeyEvent& event)
+{
+#ifdef __WXGTK__
+    event.m_metaDown=false;
+#endif
+
+    // Get the line ending type
+    wxString lineEnd;
+    switch (GetEOLMode())
+    {
+        case wxSTC_EOL_LF:
+            lineEnd = wxT("\n");
+            break;
+        case wxSTC_EOL_CRLF:
+            lineEnd = wxT("\r\n");
+            break;
+        case wxSTC_EOL_CR:
+            lineEnd = wxT("\r");
+            break;
+    }
+
+    // Block comment/uncomment
+    if (event.GetKeyCode() == 'K')
+    {
+        // Comment (Ctrl+k)
+        if (event.GetModifiers() == wxMOD_CONTROL)
+        {
+            if (BlockComment(false))
+                return;
+        }
+        // Uncomment (Ctrl+Shift+K)
+        else if (event.GetModifiers() == (wxMOD_CONTROL | wxMOD_SHIFT))
+        {
+            if (BlockComment(true))
+                return;
+        }
+    }
+
+    // Autoindent
+    if (m_autoIndent && event.GetKeyCode() == WXK_RETURN)
+    {
+        wxString indent, line;
+        line = GetLine(GetCurrentLine());
+
+        // Get the offset for the current line - basically, whether
+        // or not it ends with a \r\n, \n or \r, and if so, the length
+        int offset =  0;
+        if (line.EndsWith(wxT("\r\n")))
+            offset = 2;
+        else if (line.EndsWith(wxT("\n")))
+            offset = 1;
+        else if (line.EndsWith(wxT("\r")))
+            offset = 1;
+
+        // Get the indent. This is every leading space or tab on the
+        // line, up until the current cursor position.
+        int x = 0;
+        int max = line.Length() - (GetLineEndPosition(GetCurrentLine()) - GetCurrentPos()) - offset;
+        while ((line[x] == '\t' || line[x] == ' ') && x < max)
+            indent += line[x++];
+
+        // Select any indent in front of the cursor to be removed. If
+        // the cursor is positioned after any non-indent characters, 
+        // we don't remove anything. If there is already some selected,
+        // don't select anything new at all.
+        if (indent.Length() != 0 && 
+            (unsigned int)GetCurrentPos() <= ((GetLineEndPosition(GetCurrentLine()) - line.Length()) + indent.Length() + offset) && 
+            GetSelectedText() == wxEmptyString)
+            SetSelection(GetLineEndPosition(GetCurrentLine()) - line.Length() + offset, GetLineEndPosition(GetCurrentLine()) - line.Length() + indent.Length() + offset);
+
+        // Lose any selected text.
+        ReplaceSelection(wxEmptyString);
+
+        // Insert a replacement \n (or whatever), and the indent at the insertion point.
+        InsertText(GetCurrentPos(), lineEnd + indent);
+
+        // Now, reset the position, and clear the selection
+        SetCurrentPos(GetCurrentPos() + indent.Length() + lineEnd.Length());
+        SetSelection(GetCurrentPos(), GetCurrentPos());
+    }
+    else if (m_dlgFindReplace && event.GetKeyCode() == WXK_F3)
+    {
+        m_dlgFindReplace->FindNext();
+    }
+    else
+        event.Skip();
+}
+
+bool ctlSQLBox::BlockComment(bool uncomment)
+{
+    wxString lineEnd;
+    switch (GetEOLMode())
+    {
+        case wxSTC_EOL_LF:
+            lineEnd = wxT("\n");
+            break;
+        case wxSTC_EOL_CRLF:
+            lineEnd = wxT("\r\n");
+            break;
+        case wxSTC_EOL_CR:
+            lineEnd = wxT("\r");
+            break;
+    }
+
+    // Save the start position
+    int start = GetSelectionStart();
+
+    if (!GetSelectedText().IsEmpty())
+    {
+        wxString selection = GetSelectedText();
+        if (!uncomment)
+        {
+            selection.Replace(lineEnd, lineEnd + wxT("-- "));
+            selection.Prepend(wxT("-- "));
+        }
+        else
+        {
+            selection.Replace(lineEnd + wxT("-- "), lineEnd);
+            if (selection.StartsWith(wxT("-- ")))
+                selection = selection.Right(selection.Length() - 3);
+        }
+        ReplaceSelection(selection);
+        SetSelection(start, start + selection.Length());
+        return true;
+    }
+    return false;
+}
+
+void ctlSQLBox::OnKillFocus(wxFocusEvent& event)
+{
+    AutoCompCancel();
+    event.Skip();
+}
+
+void ctlSQLBox::OnPositionStc(wxStyledTextEvent& event)
+{
+    int pos = GetCurrentPos();
+    wxChar ch = GetCharAt(pos-1);
+    int st = GetStyleAt(pos-1);
+    int match;
+
+    // Clear all highlighting
+    BraceBadLight(wxSTC_INVALID_POSITION);
+
+    // Check for braces that aren't in comment styles,
+    // double quoted styles or single quoted styles
+    if ((ch == '{' || ch == '}' ||
+         ch == '[' || ch == ']' ||
+         ch == '(' || ch == ')') &&
+         st != 2 && st != 6 && st != 7) 
+    {
+        match = BraceMatch(pos-1);
+        if (match != wxSTC_INVALID_POSITION)
+            BraceHighlight(pos-1, match);
+    }
+
+    // Roll back through the doc and highlight any unmatched braces
+    while ((pos--) >= 0)
+    {
+        ch = GetCharAt(pos);
+        st = GetStyleAt(pos);
+
+        if ((ch == '{' || ch == '}' ||
+             ch == '[' || ch == ']' ||
+             ch == '(' || ch == ')') &&
+             st != 2 && st != 6 && st != 7)
+        {
+            match = BraceMatch(pos);
+            if (match == wxSTC_INVALID_POSITION)
+            {
+                BraceBadLight(pos);
+                break;
+            }
+        }
+    }
+    
+    event.Skip();
+}
+
+extern "C" char *tab_complete(const char *allstr, const int startptr, const int endptr, void *dbptr);
+void ctlSQLBox::OnAutoComplete(wxCommandEvent& rev)
+{
+    if (GetReadOnly())
+        return;
+    if (m_database == NULL)
+        return;
+    if (m_autocompDisabled)
+        return;
+
+    wxString what = GetCurLine().Left(GetCurrentPos()-PositionFromLine(GetCurrentLine()));;
+    int spaceidx = what.Find(' ',true);
+    
+    char *tab_ret;
+    if (spaceidx == -1)
+        tab_ret = tab_complete(what.mb_str(wxConvUTF8), 0, what.Len()+1, m_database);
+    else
+        tab_ret = tab_complete(what.mb_str(wxConvUTF8), spaceidx+1, what.Len()+1, m_database);
+
+    if (tab_ret == NULL || tab_ret[0] == '\0')
+        return; /* No autocomplete available for this string */
+
+    wxString wxRet = wxString(tab_ret, wxConvUTF8);
+    free(tab_ret);
+
+    // Switch to the generic list control. Native doesn't play well with
+    // autocomplete on Mac.
+#ifdef __WXMAC__
+    wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), true);
+#endif
+
+    if (spaceidx == -1)
+        AutoCompShow(what.Len(), wxRet);
+    else
+        AutoCompShow(what.Len()-spaceidx-1, wxRet);
+ 
+    // Now switch back
+#ifdef __WXMAC__
+    wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), false);
+#endif
+}
+
+
+ctlSQLBox::~ctlSQLBox()
+{
+    if (m_dlgFindReplace)
+    {
+        m_dlgFindReplace->Destroy();
+        m_dlgFindReplace=0;
+    }
+}
+
+
+/*
+ * Callback function from tab-complete.c, bridging the gap between C++ and C.
+ * Execute a query using the C++ APIs, returning it as a tab separated
+ * "char*-string"
+ * The query is expected to return only one column, and will have an ORDER BY
+ * clause for this column added automatically.
+ */
+extern "C"
+char *pg_query_to_single_ordered_string(char *query, void *dbptr)
+{
+    pgConn *db = (pgConn *)dbptr;
+    pgSet *res = db->ExecuteSet(wxString(query, wxConvUTF8) + wxT(" ORDER BY 1"));
+    if (!res)
+        return NULL;
+
+    wxString ret = wxString();
+    wxString tmp;
+
+    while (!res->Eof())
+    {
+        tmp =  res->GetVal(0);
+        if (tmp.Mid(tmp.Length() - 1) == wxT("."))
+            ret += tmp + wxT("\t");
+        else
+            ret += tmp + wxT(" \t");
+
+        res->MoveNext();
+    }
+
+    ret.Trim();
+    // Trims both space and tab, but we want to keep the space!
+    if (ret.Length() > 0)
+        ret += wxT(" ");
+
+    return strdup(ret.mb_str(wxConvUTF8));
+}
+
+
+
+// Find some text in the document.
+CharacterRange ctlSQLBox::RegexFindText(int minPos, int maxPos, const wxString& text) 
+{
+    TextToFind  ft;
+    ft.chrg.cpMin = minPos;
+    ft.chrg.cpMax = maxPos;
+    wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
+    ft.lpstrText = (char*)(const char*)buf;
+
+    if (SendMsg(2150, wxSTC_FIND_REGEXP, (long)&ft) == -1)
+    {
+        ft.chrgText.cpMin = -1;
+        ft.chrgText.cpMax = -1;
+    }
+    
+    return ft.chrgText;
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/explainShape.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/explainShape.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/explainShape.cpp (revision 8187)
@@ -0,0 +1,493 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// explainShape.cpp - Explain Shapes
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+
+// wxWindows headers
+#include <wx/wx.h>
+
+// App headers
+#include "pgAdmin3.h"
+#include "ctl/explainCanvas.h"
+
+#include <wx/docview.h>
+
+#include "images/ex_aggregate.xpm"
+#include "images/ex_append.xpm"
+#include "images/ex_bmp_heap.xpm"
+#include "images/ex_bmp_index.xpm"
+#include "images/ex_cte_scan.xpm"
+#include "images/ex_group.xpm"
+#include "images/ex_hash.xpm"
+#include "images/ex_hash_anti_join.xpm"
+#include "images/ex_hash_semi_join.xpm"
+#include "images/ex_hash_setop_except.xpm"
+#include "images/ex_hash_setop_except_all.xpm"
+#include "images/ex_hash_setop_intersect.xpm"
+#include "images/ex_hash_setop_intersect_all.xpm"
+#include "images/ex_hash_setop_unknown.xpm"
+#include "images/ex_index_scan.xpm"
+#include "images/ex_join.xpm"
+#include "images/ex_limit.xpm"
+#include "images/ex_materialize.xpm"
+#include "images/ex_merge.xpm"
+#include "images/ex_merge_anti_join.xpm"
+#include "images/ex_merge_semi_join.xpm"
+#include "images/ex_nested.xpm"
+#include "images/ex_nested_loop_anti_join.xpm"
+#include "images/ex_nested_loop_semi_join.xpm"
+#include "images/ex_recursive_union.xpm"
+#include "images/ex_result.xpm"
+#include "images/ex_scan.xpm"
+#include "images/ex_seek.xpm"
+#include "images/ex_setop.xpm"
+#include "images/ex_sort.xpm"
+#include "images/ex_subplan.xpm"
+#include "images/ex_tid_scan.xpm"
+#include "images/ex_unique.xpm"
+#include "images/ex_unknown.xpm"
+#include "images/ex_window_aggregate.xpm"
+#include "images/ex_worktable_scan.xpm"
+
+// Greenplum images
+#include "images/ex_broadcast_motion.xpm"
+#include "images/ex_redistribute_motion.xpm"
+#include "images/ex_gather_motion.xpm"
+
+#define BMP_BORDER 3
+
+ExplainShape::ExplainShape(const char *bmp[], const wxString &description, long tokenNo, long detailNo)
+{
+    SetBitmap(wxBitmap(bmp));
+    SetLabel(description, tokenNo, detailNo);
+    kidCount=0;
+    totalShapes=0;
+    usedShapes=0;
+}
+
+
+void ExplainShape::SetLabel(const wxString &str, int tokenNo, int detailNo)
+{
+    if (tokenNo < 0)
+    {
+        description = str;
+        label = str;
+    }
+    else
+    {
+        wxStringTokenizer tokens(str, wxT(" "));
+
+        while (tokenNo-- >= 0)
+        {
+            label = tokens.GetNextToken();
+
+            if (detailNo <= 0)
+            {
+                if (!description.IsEmpty())
+                    description.Append(wxT(" "));
+            
+                description.Append(label);
+            }
+        }
+        if (detailNo > 0)
+        {
+            tokens.SetString(str, wxT(" "));
+
+            while (detailNo--)
+            {
+                if (!description.IsEmpty())
+                    description.Append(wxT(" "));
+                
+                description.Append(tokens.GetNextToken());
+            }
+            detail = tokens.GetString();
+        }
+    }
+}
+
+void ExplainShape::OnDraw(wxDC& dc)
+{
+    wxBitmap &bmp=GetBitmap();
+    if (!bmp.Ok())
+        return;
+
+    int x, y;
+    x = WXROUND(m_xpos - bmp.GetWidth() / 2.0);
+    y = WXROUND(m_ypos - GetHeight() / 2.0);
+
+    dc.DrawBitmap(bmp, x, y, true);
+
+    int w, h;
+    dc.SetFont(GetCanvas()->GetFont());
+    dc.GetTextExtent(label, &w, &h);
+
+    x = WXROUND(m_xpos - w / 2.0);
+    y +=bmp.GetHeight() + BMP_BORDER;
+
+    dc.DrawText(label, x, y);
+}
+
+
+void ExplainShape::OnLeftClick(double x, double y, int keys, int attachment)
+{
+    ((ExplainCanvas*)GetCanvas())->ShowPopup(this);
+}
+
+
+#define ARROWMARGIN 5
+wxRealPoint ExplainShape::GetStartPoint()
+{
+    wxRealPoint rp(GetX() + GetBitmap().GetWidth() / 2.0 + ARROWMARGIN, GetY() - (GetHeight()-GetBitmap().GetHeight()) / 2.);
+    return rp;
+}
+
+
+wxRealPoint ExplainShape::GetEndPoint(int kidNo)
+{
+    wxRealPoint rp(GetX() - GetBitmap().GetWidth() / 2.0 - ARROWMARGIN, GetY() - (GetHeight()-GetBitmap().GetHeight()) / 2. + (kidCount>1 ? GetBitmap().GetHeight() * 2. /3. * kidNo / (2*kidCount-2) : 0 ));
+    return rp;
+}
+
+
+
+ExplainShape *ExplainShape::Create(long level, ExplainShape *last, const wxString &str)
+{
+    ExplainShape *s=0;
+
+    int costPos=str.Find(wxT("(cost="));
+
+    wxStringTokenizer tokens(str, wxT(" "));
+    wxString token = tokens.GetNextToken();
+    wxString token2 = tokens.GetNextToken();
+    wxString token3 = tokens.GetNextToken();
+    wxString token4;
+    if (tokens.HasMoreTokens())
+        token4 = tokens.GetNextToken();
+    wxString descr = costPos > 0 ? str.Left(costPos) : str;
+
+    // possible keywords can be found in postgresql/src/backend/commands/explain.c
+
+    if (token == wxT("Total"))              return 0;
+    else if (token == wxT("Trigger"))       return 0;
+    else if (token == wxT("Settings:"))		return 0;		/* Greenplum */
+    else if (token == wxT("Slice"))			return 0;		/* Greenplum */
+    else if (token.Mid(0,6) == wxT("(slice"))	return 0;	/* Greenplum */
+    else if (token == wxT("Result"))        s = new ExplainShape(ex_result_xpm, descr);
+    else if (token == wxT("Append"))        s = new ExplainShape(ex_append_xpm, descr);
+    else if (token == wxT("Nested"))
+    {
+        if (token2 == wxT("Loop") && token4 == wxT("Join"))
+        {
+            // Nested Loop Anti Join
+            if (token3 == wxT("Anti"))
+            {
+                s = new ExplainShape(ex_nested_loop_anti_join_xpm, descr);
+            }
+            // Nested Loop Semi Join
+            else
+            {
+                s = new ExplainShape(ex_nested_loop_semi_join_xpm, descr);
+            }
+        }
+        if (!s)
+            s = new ExplainShape(ex_nested_xpm, descr);
+    }
+    else if (token == wxT("Merge"))
+    {
+        if (token3 == wxT("Join"))
+        {
+            // Merge Anti Join
+            if (token2 == wxT("Anti"))
+            {
+                s = new ExplainShape(ex_merge_anti_join_xpm, descr);
+            }
+            // Merge Semi Join
+            else
+            {
+                s = new ExplainShape(ex_merge_semi_join_xpm, descr);
+            }
+        }
+        else
+        {
+            s = new ExplainShape(ex_merge_xpm, descr);
+        }
+    }
+    else if (token == wxT("Hash"))
+    {
+        if (token2 == wxT("Join"))
+        {
+            s = new ExplainShape(ex_join_xpm, descr);
+        }
+        else
+        {
+            if (token3 == wxT("Join"))
+            {
+                // Hash Anti Join
+                if (token2 == wxT("Anti"))
+                {
+                    s = new ExplainShape(ex_hash_anti_join_xpm, descr);
+                }
+                // Hash Semi Join
+                else if (token2 == wxT("Semi"))
+                {
+                    s = new ExplainShape(ex_hash_semi_join_xpm, descr);
+                }
+                else
+                {
+                    s = new ExplainShape(ex_hash_xpm, descr);
+                }
+            }
+            else
+            {
+                s = new ExplainShape(ex_hash_xpm, descr);
+            }
+        }
+    }
+    else if (token == wxT("HashSetOp"))
+    {
+        if (token2 == wxT("Except"))
+        {
+            // HashSetOp Except ALL
+            if (token3 == wxT("ALL"))
+            {
+                s = new ExplainShape(ex_hash_setop_except_all_xpm, descr);
+            }
+            // HashSetOp Except
+            else
+            {
+                s = new ExplainShape(ex_hash_setop_except_xpm, descr);
+            }
+        }
+        else if (token2 == wxT("Intersect"))
+        {
+            // HashSetOp Intersect ALL
+            if (token3 == wxT("ALL"))
+            {
+                s = new ExplainShape(ex_hash_setop_intersect_all_xpm, descr);
+            }
+            // HashSetOp Intersect
+            else
+            {
+                s = new ExplainShape(ex_hash_setop_intersect_xpm, descr);
+            }
+        }
+        else
+        {
+           // HashSetOp ???
+           s = new ExplainShape(ex_hash_setop_unknown_xpm, descr);
+        }
+    }
+    else if (token == wxT("Subquery"))      s = new ExplainShape(ex_subplan_xpm, descr, 0, 2);
+    else if (token == wxT("Function"))      s = new ExplainShape(ex_result_xpm, descr, 0, 2);
+    else if (token == wxT("Materialize"))   s = new ExplainShape(ex_materialize_xpm, descr);
+    else if (token == wxT("Sort"))          s = new ExplainShape(ex_sort_xpm, descr);
+    else if (token == wxT("Group"))         s = new ExplainShape(ex_group_xpm, descr);
+    else if (token == wxT("Aggregate") || token == wxT("GroupAggregate") || token == wxT("HashAggregate"))
+        s = new ExplainShape(ex_aggregate_xpm, descr);
+    else if (token == wxT("Unique"))        s = new ExplainShape(ex_unique_xpm, descr);
+    else if (token == wxT("SetOp"))         s = new ExplainShape(ex_setop_xpm, descr);
+    else if (token == wxT("Limit"))         s = new ExplainShape(ex_limit_xpm, descr);
+    else if (token == wxT("Bitmap"))
+    {
+        if (token2 == wxT("Index"))         s = new ExplainShape(ex_bmp_index_xpm, descr, 4, 3);
+        else                                s = new ExplainShape(ex_bmp_heap_xpm, descr, 4, 3);
+    }
+    else if (token2 == wxT("Scan"))
+    {
+        if (token == wxT("Index"))
+            // Scan Index Backword
+            if (token3 == wxT("Backward"))
+                s = new ExplainShape(ex_index_scan_xpm, descr, 4, 3);
+            else
+                s = new ExplainShape(ex_index_scan_xpm, descr, 3, 2);
+        // Tid Scan
+        else if (token == wxT("Tid"))
+            s = new ExplainShape(ex_tid_scan_xpm, descr, 3, 2);
+        // WorkTable scan
+        else if (token == wxT("WorkTable"))
+            s = new ExplainShape(ex_worktable_scan_xpm, descr, 3, 2);
+        // CTE Scan
+        else if (token == wxT("CTE"))
+            s = new ExplainShape(ex_cte_scan_xpm, descr, 3, 2);
+        else
+            s = new ExplainShape(ex_scan_xpm, descr, 3, 2);
+    }
+    else if (token2 == wxT("Seek"))         s = new ExplainShape(ex_seek_xpm, descr, 3, 2);
+     // Recursive Union
+    else if (token == wxT("Recursive") && token2 == wxT("Union"))
+        s = new ExplainShape(ex_recursive_union_xpm, descr);
+    else if (token == wxT("WindowAgg"))
+        s = new ExplainShape(ex_window_aggregate_xpm, descr);
+
+    // Greenplum additions
+    else if (token == wxT("Gather") && token2 ==wxT("Motion"))
+        s = new ExplainShape(ex_gather_motion_xpm, descr);
+    else if (token == wxT("Broadcast") && token2 ==wxT("Motion"))
+        s = new ExplainShape(ex_broadcast_motion_xpm, descr);
+    else if (token == wxT("Redistribute") && token2 ==wxT("Motion"))
+        s = new ExplainShape(ex_redistribute_motion_xpm, descr);
+
+    if (!s)
+        s = new ExplainShape(ex_unknown_xpm, descr);
+    
+    s->SetDraggable(false);
+
+    s->level = level;
+
+    if (costPos > 0)
+    {
+        int actPos = str.Find(wxT("(actual"));
+        if (actPos > 0)
+        {
+            s->actual = str.Mid(actPos);
+            s->cost = str.Mid(costPos, actPos-costPos);
+        }
+        else
+            s->cost = str.Mid(costPos);
+    }
+    
+    int w=50, h=20;
+
+    wxBitmap &bmp=s->GetBitmap();
+    if (w < bmp.GetWidth())
+        w = bmp.GetWidth();
+
+    s->SetHeight(bmp.GetHeight() + BMP_BORDER + h);
+    s->SetWidth(w);
+
+    s->upperShape = last;
+    if (last)
+    {
+        s->kidNo = last->kidCount;
+        last->kidCount++;
+    }
+    else
+        s->kidNo = 0;
+
+    if (costPos > 0)
+    {
+        wxChar *cl=(wxChar*)str.c_str() + costPos+6;
+        wxChar *ch=wxStrstr(cl, wxT(".."));
+        if (ch)
+        {
+            *ch=0;
+            ch += 2;
+        }
+        s->costLow = StrToDouble(cl);
+        if (ch)
+        {
+            wxChar *r=wxStrstr(ch, wxT(" rows="));
+            if (r)
+            {
+                *r=0;
+                r += 6;
+            }
+            s->costHigh = StrToDouble(ch);
+            if (r)
+            {
+                wxChar *w=wxStrstr(r, wxT(" width="));
+                if (w)
+                {
+                    *w=0;
+                    w += 7;
+                }
+                s->rows = StrToLong(r);
+                if (w)
+                    s->width = StrToLong(w);
+            }
+        }
+    }
+    return s;
+}
+
+
+ExplainLine::ExplainLine(ExplainShape *from, ExplainShape *to, double weight)
+{
+    SetCanvas(from->GetCanvas());
+    from->AddLine(this, to);
+    MakeLineControlPoints(4);
+
+    width = (int) log(from->GetAverageCost());
+    if (width > 10)
+        width = 10;
+
+    // If we got an average cost of 0, width is probably negative
+    // which will look pretty darn ugly as an arrow width!
+    // This may happen on Greenplum.
+    if (width < 1)
+        width = 1;
+
+    wxNode *first = GetLineControlPoints()->GetFirst();
+    wxNode *last  = GetLineControlPoints()->GetLast();
+    *(wxRealPoint *)first->GetData() = from->GetStartPoint();
+    *(wxRealPoint *)last->GetData() = to->GetEndPoint(from->GetKidno());
+
+    wxRealPoint *p1=(wxRealPoint *)first->GetNext()->GetData();
+    wxRealPoint *p2=(wxRealPoint *)last->GetPrevious()->GetData();
+    *p1 = from->GetStartPoint();
+    *p2 = to->GetEndPoint(from->GetKidno());
+    p1->x -= (p1->x - p2->x)/3. +8;
+    p2->x += (p1->x - p2->x)/3. -8;
+
+    Initialise();
+}
+
+
+#define ARROWWIDTH  4
+
+
+void ExplainLine::OnDraw(wxDC& dc)
+{
+    if (m_lineControlPoints)
+    {
+        dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 1, wxSOLID));
+        dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(*wxLIGHT_GREY, wxSOLID));
+
+        wxPoint *points = new wxPoint[11];
+        wxRealPoint *point0 = (wxRealPoint*) m_lineControlPoints->Item(0)->GetData();
+        wxRealPoint *point1 = (wxRealPoint*) m_lineControlPoints->Item(1)->GetData();
+        wxRealPoint *point2 = (wxRealPoint*) m_lineControlPoints->Item(2)->GetData();
+        wxRealPoint *point3 = (wxRealPoint*) m_lineControlPoints->Item(3)->GetData();
+    
+        double phi  = atan2(point2->y - point1->y, point2->x - point1->x);
+        double offs = width * tan(phi/2);
+
+        points[0].x  = WXROUND(point0->x);
+        points[0].y  = WXROUND(point0->y) - width;
+        points[10].x = WXROUND(point0->x);
+        points[10].y = WXROUND(point0->y) + width;
+
+        points[1].x  = WXROUND(point1->x + offs);
+        points[1].y  = WXROUND(point1->y) - width;
+        points[9].x  = WXROUND(point1->x - offs);
+        points[9].y  = WXROUND(point1->y) + width;
+
+        points[2].x  = WXROUND(point2->x + offs);
+        points[2].y  = WXROUND(point2->y) - width;
+        points[8].x  = WXROUND(point2->x - offs);
+        points[8].y  = WXROUND(point2->y) + width;
+
+        points[3].x  = WXROUND(point3->x) - width - ARROWWIDTH;
+        points[3].y  = WXROUND(point3->y) - width;
+        points[7].x  = WXROUND(point3->x) - width - ARROWWIDTH;
+        points[7].y  = WXROUND(point3->y) + width;
+
+        points[4].x  = points[3].x;
+        points[4].y  = points[3].y - ARROWWIDTH;
+        points[6].x  = points[7].x;
+        points[6].y  = points[7].y + ARROWWIDTH;
+
+        points[5].x  = WXROUND(point3->x);
+        points[5].y  = WXROUND(point3->y);
+
+        dc.DrawPolygon(11, points, 0, 0);
+    }
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_timespin.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_timespin.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/xh_timespin.cpp (revision 8187)
@@ -0,0 +1,49 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// xh_timespin.cpp - wxTimeSpinCtrl handler
+//
+//////////////////////////////////////////////////////////////////////////
+ 
+#include "pgAdmin3.h"
+
+#include "wx/wx.h"
+#include "ctl/timespin.h"
+#include "ctl/xh_timespin.h"
+
+
+IMPLEMENT_DYNAMIC_CLASS(wxTimeSpinXmlHandler, wxXmlResourceHandler)
+
+wxTimeSpinXmlHandler::wxTimeSpinXmlHandler() 
+: wxXmlResourceHandler() 
+{
+    XRC_ADD_STYLE(wxSP_WRAP);
+    XRC_ADD_STYLE(wxSP_ARROW_KEYS);
+
+    AddWindowStyles();
+}
+
+
+wxObject *wxTimeSpinXmlHandler::DoCreateResource()
+{ 
+    XRC_MAKE_INSTANCE(timespin, wxTimeSpinCtrl);
+
+    timespin->Create(m_parentAsWindow,
+                     GetID(),
+                     GetPosition(), GetSize(),
+                     GetStyle(),
+                     GetName());
+    
+    SetupWindow(timespin);
+    
+    return timespin;
+}
+
+bool wxTimeSpinXmlHandler::CanHandle(wxXmlNode *node)
+{
+    return IsOfClass(node, wxT("wxTimeSpinCtrl"));
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/timespin.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/timespin.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/timespin.cpp (revision 8187)
@@ -0,0 +1,449 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// timespin.cpp - timeSpin SpinCtrl
+//
+//////////////////////////////////////////////////////////////////////////
+ 
+#include "pgAdmin3.h"
+
+#include <wx/wx.h>
+#include "ctl/timespin.h"
+
+
+#define CTRLID_TXT  101
+#define CTRLID_SPN  102
+
+
+BEGIN_EVENT_TABLE(wxTimeSpinCtrl, wxControl)
+    EVT_TEXT(CTRLID_TXT, wxTimeSpinCtrl::OnText)
+    EVT_NAVIGATION_KEY(wxTimeSpinCtrl::OnNavigate)
+    EVT_SPIN_UP(CTRLID_SPN, wxTimeSpinCtrl::OnSpinUp)
+    EVT_SPIN_DOWN(CTRLID_SPN, wxTimeSpinCtrl::OnSpinDown)
+    EVT_SET_FOCUS(wxTimeSpinCtrl::OnSetFocus)
+    EVT_SIZE(wxTimeSpinCtrl::OnSize)
+END_EVENT_TABLE()
+
+
+IMPLEMENT_DYNAMIC_CLASS(wxTimeSpinCtrl, wxControl)
+
+
+wxTimeSpinCtrl::wxTimeSpinCtrl(wxWindow *parent,
+                            wxWindowID id,
+                            const wxPoint& pos,
+                            const wxSize& size,
+                            long style,
+                            const wxString& name)
+{
+    Init();
+    Create(parent, id, pos, size, style, name);
+}
+
+
+bool wxTimeSpinCtrl::Create(wxWindow *parent,
+                            wxWindowID id,
+                            const wxPoint& pos,
+                            const wxSize& size,
+                            long style,
+                            const wxString& name)
+{
+    wxControl::Create(parent, id, pos, size, style & ~(wxSP_WRAP|wxSP_ARROW_KEYS), wxDefaultValidator, name);
+    SetFont(parent->GetFont());
+
+    m_spn=new wxSpinButton(this, CTRLID_SPN, wxDefaultPosition, wxDefaultSize, wxSP_WRAP | wxSP_VERTICAL | (style & wxSP_ARROW_KEYS));
+
+    wxSize cs=GetClientSize();
+    wxSize ss=m_spn->GetBestSize();
+
+    m_txt=new wxTextCtrl(this, CTRLID_TXT, wxEmptyString, wxPoint(0,0), wxSize(cs.x-ss.x, cs.y), wxNO_BORDER|wxWANTS_CHARS);
+    m_txt->Connect(wxID_ANY, wxID_ANY, wxEVT_KEY_DOWN, wxKeyEventHandler(wxTimeSpinCtrl::OnEditKey), 0, this);
+    m_txt->Connect(wxID_ANY, wxID_ANY, wxEVT_KILL_FOCUS, wxFocusEventHandler(wxTimeSpinCtrl::OnKillFocus), 0, this);
+
+    wxArrayString valArray;
+    wxChar c;
+    for (c='0'; c <= '9'; c++)
+        valArray.Add(wxString(c, 1));
+    valArray.Add(wxT(":"));
+    wxTextValidator tv(wxFILTER_INCLUDE_CHAR_LIST);
+    tv.SetIncludes(valArray);
+    m_txt->SetValidator(tv);
+
+    m_spn->SetSize(ss.x, cs.y);
+    m_spn->SetPosition(wxPoint(cs.x-ss.x, 0));
+
+    canWrap = (style & wxSP_WRAP) != 0;
+    SetMax(24*60*60 -1);
+
+    SetInitialSize(size);
+
+    return true;
+}
+
+#define TXTPOSX 0
+#define TXTPOSY 0
+void wxTimeSpinCtrl::OnSize(wxSizeEvent& event)
+{
+    if ( m_spn )
+    {
+        wxSize sz = GetClientSize();
+
+        wxSize ss=m_spn->GetSize();
+        int eh=m_txt->GetBestSize().y;
+
+        m_txt->SetSize(TXTPOSX, TXTPOSY, sz.x-ss.x-TXTPOSX, sz.y > eh ? eh-TXTPOSY : sz.y-TXTPOSY);
+        m_spn->SetSize(sz.x - ss.x, 0, ss.x, sz.y);
+    }
+
+    event.Skip();
+}
+
+
+bool wxTimeSpinCtrl::Destroy()
+{
+    if (m_txt)
+    {
+        m_txt->Destroy();
+        m_txt = NULL;
+    }
+    if (m_spn)
+    {
+        m_spn->Destroy();
+        m_spn = NULL;
+    }
+    return true;
+}
+
+
+void wxTimeSpinCtrl::Init()
+{
+    m_txt = NULL;
+    m_spn = NULL;
+    spinValue = 0;
+}
+
+
+wxSize wxTimeSpinCtrl::DoGetBestSize() const
+{
+#ifdef __WXGTK__
+    return wxSize(100, m_spn->GetBestSize().y);
+#else
+    return wxSize(100, m_txt->GetBestSize().y);
+#endif
+}
+
+
+bool wxTimeSpinCtrl::Enable(bool enable)
+{
+    if ( !wxControl::Enable(enable) )
+    {
+        return false;
+    }
+
+    m_txt->Enable(enable);
+    m_spn->Enable(enable);
+
+    return true;
+}
+
+void wxTimeSpinCtrl::SetMax(long seconds, bool useDay)
+{
+    hasDay = useDay;
+    if (hasDay)
+        m_format = wxT("%D:%H:%M:%S");
+    else
+        m_format = wxT("%H:%M:%S");
+    maxSpinValue = seconds+1;
+    if (maxSpinValue < 2)
+        maxSpinValue = 2;
+    m_spn->SetRange(0, 32767);
+}
+
+
+bool wxTimeSpinCtrl::SetTime(const wxDateTime& time)
+{
+    if (time.IsValid())
+    {
+        wxDateTime tt(time);
+        tt.ResetTime();
+        return SetValue(time - tt);
+    }
+    else
+    {
+        m_txt->SetValue(wxEmptyString);
+        return false;
+    }
+}
+
+
+bool wxTimeSpinCtrl::SetValue(const wxTimeSpan& span)
+{
+    m_txt->SetValue(span.Format(m_format));
+    spinValue = span.GetSeconds().GetLo();
+    return true;
+}
+
+
+
+wxTimeSpan wxTimeSpinCtrl::GetValue()
+{
+    return wxTimeSpan(0, 0, spinValue);
+}
+
+
+int wxTimeSpinCtrl::GetTimePart()
+{
+    wxString strAfter=m_txt->GetRange(m_txt->GetInsertionPoint(), 9999);
+    int cnt=0;
+    wxChar *p=(wxChar*)strAfter.c_str();
+    while (*p)
+    {
+        if (*p++ == ':')
+            cnt++;
+    }
+    return cnt;
+}
+
+
+void wxTimeSpinCtrl::Highlight(int tp)
+{
+    wxString txt=m_txt->GetValue();
+    long from=0, to;
+    int i;
+
+    for (i=3-tp - (hasDay ? 0 : 1) ; i > 0 ; i--)
+        from += txt.Mid(from).Find(':') +1;
+
+    to=txt.Mid(from).Find(':') + from;
+    if (to < from)
+        to = 999;
+
+    m_txt->SetSelection(from, to);
+}
+
+        
+void wxTimeSpinCtrl::OnSpinUp(wxSpinEvent &ev)
+{
+#ifdef __WXMSW__
+    m_txt->SetFocus();
+#endif
+    DoSpin(1);
+}
+
+void wxTimeSpinCtrl::OnSpinDown(wxSpinEvent &ev)
+{
+#ifdef __WXMSW__
+    m_txt->SetFocus();
+#endif
+    DoSpin(-1);
+}
+
+void wxTimeSpinCtrl::DoSpin(int diff)
+{
+    int tp=GetTimePart();
+    long oldValue=0, maxValue=0, mult=0;
+
+    switch (tp)
+    {
+        case 0: 
+            oldValue = spinValue;
+            maxValue = 60;
+            mult = 1;
+            break;
+        case 1:
+            oldValue = spinValue/60;
+            maxValue = 60;
+            mult = 60;
+            break;
+
+        case 2:
+            oldValue = spinValue/60/60;
+            if (hasDay)
+                maxValue = 24;
+            else
+                maxValue = maxSpinValue/60/60;
+            mult = 60*60;
+            break;
+        case 3:
+            oldValue = spinValue/60/60/24;
+            maxValue = maxSpinValue/60/60/24;
+            mult = 60*60*24;
+            break;
+        default:
+            // can't happen
+            break;
+    }
+    oldValue %= maxValue;
+    int newValue = oldValue + diff;
+
+    if (!canWrap)
+    {
+        if (newValue < 0)
+            diff += maxValue;
+        else if (newValue >= maxValue)
+            diff -= maxValue;
+    }
+
+    long newSpinValue = spinValue + diff*mult;
+    if (newSpinValue < 0)
+        newSpinValue = maxSpinValue-1;
+    else if (newSpinValue > maxSpinValue)
+        newSpinValue = 0;
+
+    if (spinValue != newSpinValue)
+    {
+        spinValue = newSpinValue;
+        wxTimeSpan span(0, 0, spinValue);
+        wxString txt=span.Format(m_format);
+        m_txt->SetValue(txt);
+        Highlight(tp);
+
+        wxSpinEvent ev;
+        ev.SetEventObject(this);
+        ev.SetId(GetId());
+        GetParent()->ProcessEvent(ev);
+    }
+}
+
+
+void wxTimeSpinCtrl::OnText(wxCommandEvent &ev)
+{
+    long time=GetTextTime();
+    if (time >= 0)
+    {
+        spinValue = time;
+        ev.SetEventObject(this);
+        ev.SetId(GetId());
+        GetParent()->ProcessEvent(ev);
+    }
+}
+
+
+void wxTimeSpinCtrl::OnNavigate(wxNavigationKeyEvent &ev)
+{
+    if (wxWindow::FindFocus() == m_txt)
+    {
+        int tp=GetTimePart();
+        if (ev.GetDirection())
+            tp++;
+        else
+            tp--;
+        if ((tp >= 0 && tp < 3) || (hasDay && tp == 3))
+        {
+            Highlight(tp);
+            return;
+        }
+    }
+    ev.Skip();
+}
+
+
+void wxTimeSpinCtrl::OnEditKey(wxKeyEvent &ev)
+{
+    if (!ev.HasModifiers())
+    {
+        switch(ev.GetKeyCode())
+        {
+            case WXK_LEFT:
+            {
+                if (!ev.ShiftDown())
+                {
+                    int tp=GetTimePart()+1;
+                    if (tp < 3 || (hasDay && tp == 3))
+                    {
+                        Highlight(tp);
+                        return;
+                    }
+                }
+                break;
+            }
+            case WXK_RIGHT:
+            {
+                if (!ev.ShiftDown())
+                {
+                    int tp=GetTimePart()-1;
+                    if (tp >= 0)
+                    {
+                        Highlight(tp);
+                        return;
+                    }
+                }
+                break;
+            }
+            case WXK_UP:
+                DoSpin(1);
+                return;
+                break;
+            case WXK_DOWN:
+                DoSpin(-1);
+                return;
+                break;
+            default:
+                break;
+        }
+    }
+    ev.Skip();
+}
+
+
+long wxTimeSpinCtrl::GetTextTime()
+{
+    int t1, t2, t3, t4;
+    int scanned=wxSscanf(m_txt->GetValue(), wxT("%d:%d:%d:%d"), &t1, &t2, &t3, &t4);
+
+    switch (scanned)
+    {
+        case 1:
+            if (t1 >= 0)
+                return t1;
+            break;
+        case 2:
+            if (t1 >= 0 && t2 >= 0 && t2 < 60)
+                return t1*60+t2;
+            break;
+        case 3:
+            if (t1 >= 0 && t2 >= 0 && t2 < 60 && t3 >= 0 && t3 < 60)
+                return (t1*60+t2)*60+t3;
+            break;
+        case 4:
+            if (t1 >= 0 && t2 >= 0 && t2 < 24 && t3 >= 0 && t3 < 60 && t4 >= 0 && t4 < 60)
+                return ((t1*24+t2)*60+t3)*60+t4;
+            break;
+        default:
+            break;
+    }
+    return -1;
+}
+
+
+void wxTimeSpinCtrl::OnKillFocus(wxFocusEvent &ev)
+{
+#ifdef __WXGTK__
+    ev.Skip();
+#endif
+
+    long time=GetTextTime();
+
+    if (time < 0)
+    {
+        m_txt->SetValue(wxEmptyString);
+        spinValue = 0;
+        m_spn->SetValue(0);
+    }
+	else
+	{
+		int tp=GetTimePart();
+		SetValue(wxTimeSpan(0,0,time));
+		Highlight(tp);
+	}
+}
+
+
+void wxTimeSpinCtrl::OnSetFocus(wxFocusEvent &ev)
+{
+    m_txt->SetFocus();
+    Highlight(hasDay ? 3 : 2);
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSecurityPanel.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSecurityPanel.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlSecurityPanel.cpp (revision 8187)
@@ -0,0 +1,422 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlSecurityPanel.cpp - Panel with security information
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/settings.h>
+#include <wx/imaglist.h>
+
+// App headers
+#include "pgAdmin3.h"
+#include "utils/sysLogger.h"
+#include "ctl/ctlSecurityPanel.h"
+#include "db/pgConn.h"
+#include "schema/pgObject.h"
+#include "schema/pgGroup.h"
+#include "schema/pgUser.h"
+
+
+
+BEGIN_EVENT_TABLE(ctlSecurityPanel, wxPanel)
+    EVT_LIST_ITEM_SELECTED(CTL_LBPRIV,  ctlSecurityPanel::OnPrivSelChange)
+    EVT_BUTTON(CTL_ADDPRIV,             ctlSecurityPanel::OnAddPriv)
+    EVT_BUTTON(CTL_DELPRIV,             ctlSecurityPanel::OnDelPriv)
+    EVT_TEXT(CTL_CBGROUP,               ctlSecurityPanel::OnGroupChange)
+    EVT_COMBOBOX(CTL_CBGROUP,           ctlSecurityPanel::OnGroupChange)
+    EVT_CHECKBOX(CTL_ALLPRIV,           ctlSecurityPanel::OnPrivCheckAll)
+    EVT_CHECKBOX(CTL_ALLPRIVGRANT,      ctlSecurityPanel::OnPrivCheckAllGrant)
+    EVT_CHECKBOX(CTL_PRIVCB,            ctlSecurityPanel::OnPrivCheck)
+    EVT_CHECKBOX(CTL_PRIVCB+2,          ctlSecurityPanel::OnPrivCheck)
+    EVT_CHECKBOX(CTL_PRIVCB+4,          ctlSecurityPanel::OnPrivCheck)
+    EVT_CHECKBOX(CTL_PRIVCB+6,          ctlSecurityPanel::OnPrivCheck)
+    EVT_CHECKBOX(CTL_PRIVCB+8,          ctlSecurityPanel::OnPrivCheck)
+    EVT_CHECKBOX(CTL_PRIVCB+10,         ctlSecurityPanel::OnPrivCheck)
+    EVT_CHECKBOX(CTL_PRIVCB+12,         ctlSecurityPanel::OnPrivCheck)
+    EVT_CHECKBOX(CTL_PRIVCB+14,         ctlSecurityPanel::OnPrivCheck)
+    EVT_CHECKBOX(CTL_PRIVCB+16,         ctlSecurityPanel::OnPrivCheck)
+END_EVENT_TABLE();
+
+DEFINE_EVENT_TYPE(EVT_SECURITYPANEL_CHANGE)
+
+ctlSecurityPanel::ctlSecurityPanel(wxNotebook *nb, const wxString &privList, const char *privChars, wxImageList *imgList)
+: wxPanel(nb, -1, wxDefaultPosition, wxDefaultSize)
+{
+    nbNotebook = nb;
+    nbNotebook->AddPage(this, _("Privileges"));
+
+    connection = 0;
+    privilegeChars=privChars;
+    allPrivileges=0;
+
+    privCheckboxes=0;
+
+    wxStringTokenizer privileges(privList, wxT(","));
+    privilegeCount=privileges.CountTokens();
+    
+    wxFlexGridSizer *item0 = new wxFlexGridSizer(3, 1, 5, 5);
+    item0->AddGrowableCol(0);
+    item0->AddGrowableRow(0);
+
+    if (privilegeCount)
+    {
+        bool needAll=(privilegeCount > 1);
+        privCheckboxes = new wxCheckBox*[privilegeCount*2];
+        int i=0;
+
+        wxFlexGridSizer *itemSizer1 = new wxFlexGridSizer(1, 1, 5, 5);
+        itemSizer1->AddGrowableCol(0);
+        itemSizer1->AddGrowableRow(0);
+        lbPrivileges = new ctlListView(this, CTL_LBPRIV, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxLC_REPORT);
+        lbPrivileges->SetImageList(imgList, wxIMAGE_LIST_SMALL);
+        lbPrivileges->AddColumn(_("User/Group"), 70, wxLIST_FORMAT_LEFT);
+        lbPrivileges->AddColumn(_("Privileges"), 70, wxLIST_FORMAT_LEFT);
+        itemSizer1->Add(lbPrivileges, 0, wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT, 4);
+        item0->Add(itemSizer1, 0, wxEXPAND|wxALL, 5);
+
+        wxBoxSizer* itemSizer2 = new wxBoxSizer(wxHORIZONTAL);
+        btnAddPriv = new wxButton(this, CTL_ADDPRIV, _("Add/Change"));
+        itemSizer2->Add(btnAddPriv, 0, wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT, 4);
+        btnDelPriv = new wxButton(this, CTL_DELPRIV, _("Remove"));
+        itemSizer2->Add(btnDelPriv, 0, wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT, 4);
+        item0->Add(itemSizer2, 0, wxEXPAND|wxALL, 0);
+
+        wxStaticBox* sb = new wxStaticBox(this, -1, _("Privileges"));
+        wxBoxSizer* itemSizer3 = new wxStaticBoxSizer( sb, wxVERTICAL );
+        item0->Add(itemSizer3, 0, wxEXPAND|wxALL, 5);
+
+        wxBoxSizer* itemSizer4 = new wxBoxSizer(wxHORIZONTAL);
+        stGroup = new wxStaticText(this, CTL_STATICGROUP, _("Group"));
+        itemSizer4->Add(stGroup, 0, wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT, 4);
+        cbGroups = new ctlComboBox(this, CTL_CBGROUP, wxDefaultPosition, wxDefaultSize);
+        cbGroups->Append(wxT("public"));
+        cbGroups->SetSelection(0);
+        itemSizer4->Add(cbGroups, wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT);
+        itemSizer3->Add(itemSizer4, 0, wxEXPAND|wxALL, 0);
+
+        /* border size depends on the plateform */
+        #ifdef __WXMSW__
+        int bordersize = 4;
+        #endif
+        #ifdef __WXMAC__
+        int bordersize = 3;
+        #endif
+        #ifdef __WXGTK__
+        int bordersize = 0;
+        #endif
+
+        if (needAll)
+        {
+            wxBoxSizer* itemSizer5 = new wxBoxSizer(wxHORIZONTAL);
+            allPrivileges = new wxCheckBox(this, CTL_ALLPRIV, wxT("ALL"));
+            itemSizer5->Add(allPrivileges, wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT);
+            allPrivilegesGrant = new wxCheckBox(this, CTL_ALLPRIVGRANT, wxT("WITH GRANT OPTION"));
+            itemSizer5->Add(allPrivilegesGrant, wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT);
+            allPrivilegesGrant->Disable();
+            itemSizer3->Add(itemSizer5, 0, wxALL, bordersize);
+        }
+
+        while (privileges.HasMoreTokens())
+        {
+            wxString priv=privileges.GetNextToken();
+            wxCheckBox *cb;
+            wxBoxSizer* itemSizer6 = new wxBoxSizer(wxHORIZONTAL);
+            cb=new wxCheckBox(this, CTL_PRIVCB+i, priv);
+            itemSizer6->Add(cb, wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT);
+            privCheckboxes[i++] = cb;
+            cb=new wxCheckBox(this, CTL_PRIVCB+i, wxT("WITH GRANT OPTION"));
+            itemSizer6->Add(cb, wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT);
+            cb->Disable();
+            privCheckboxes[i++] = cb;
+            itemSizer3->Add(itemSizer6, 0, wxALL, bordersize);
+        }
+    }
+    
+    this->SetSizer(item0);
+    item0->Fit(this);
+}
+
+
+ctlSecurityPanel::~ctlSecurityPanel()
+{
+    if (privCheckboxes)
+        delete[] privCheckboxes;
+}
+
+
+void ctlSecurityPanel::SetConnection(pgConn *conn)
+{
+    connection=conn;
+    if (connection && stGroup && connection->BackendMinimumVersion(8, 1))
+        stGroup->SetLabel(_("Role"));
+}
+
+
+wxString ctlSecurityPanel::GetGrant(const wxString &allPattern, const wxString &grantObject, wxArrayString *currentAcl, wxString column)
+{
+    wxArrayString tmpAcl;
+    if (currentAcl)
+        tmpAcl = *currentAcl;
+
+    wxString sql;
+    int cnt=lbPrivileges->GetItemCount();
+    int pos;
+    unsigned int i;
+
+    for (pos=0 ; pos < cnt ; pos++)
+    {
+        wxString name=lbPrivileges->GetText(pos);
+        wxString value=lbPrivileges->GetText(pos, 1);
+
+        int nameLen=name.Length();
+
+        bool privWasAssigned=false;
+        bool privPartiallyAssigned=false;
+        for (i=0 ; i < tmpAcl.GetCount() ; i++)
+        {
+            if (tmpAcl.Item(i).Left(nameLen) == name)
+            {
+                privPartiallyAssigned=true;
+                if (tmpAcl.Item(i).Mid(nameLen+1) == value)
+                    privWasAssigned=true;
+                tmpAcl.RemoveAt(i);
+                break;
+            }
+        }
+
+        if (name.Left(6).IsSameAs(wxT("group "), false))
+            name = wxT("GROUP ") + qtIdent(name.Mid(6));
+        else
+            name=qtIdent(name);
+
+        if (!privWasAssigned)
+        {
+            if (privPartiallyAssigned)
+                sql += pgObject::GetPrivileges(allPattern, wxT(""), grantObject, name, column);
+            sql += pgObject::GetPrivileges(allPattern, value, grantObject, name, column);
+        }
+    }
+
+    for (i=0 ; i < tmpAcl.GetCount() ; i++)
+    {
+        wxString name=tmpAcl.Item(i).BeforeLast('=');
+
+        if (name.Left(6).IsSameAs(wxT("group "), false))
+            name = wxT("GROUP ") + qtIdent(name.Mid(6));
+        else
+            name=qtIdent(name);
+        sql += pgObject::GetPrivileges(allPattern, wxT(""), grantObject, name, column);
+    }
+    return sql;
+}
+
+
+void ctlSecurityPanel::OnGroupChange(wxCommandEvent &ev)
+{
+    cbGroups->GuessSelection(ev);
+    wxString name=cbGroups->GetGuessedStringSelection();
+
+    btnAddPriv->Enable(!name.Strip(wxString::both).IsEmpty());
+}
+
+    
+void ctlSecurityPanel::OnPrivCheckAll(wxCommandEvent& ev)
+{
+    bool all=allPrivileges->GetValue();
+    int i;
+    for (i=0 ; i < privilegeCount ; i++)
+    {
+        if (all)
+        {
+            // We use the Name property of the checkboxes as a flag to note if that
+            // box should remain disabled (eg. CONNECT for a DB on PG < 8.2
+            if (privCheckboxes[i*2]->GetName() != wxT("DISABLE"))
+            {
+                privCheckboxes[i*2]->SetValue(true);
+                privCheckboxes[i*2]->Disable();
+                privCheckboxes[i*2+1]->Disable();
+                allPrivilegesGrant->Enable(GrantAllowed());
+            }
+        }
+        else
+        {
+            if (privCheckboxes[i*2]->GetName() != wxT("DISABLE"))
+            {
+                allPrivilegesGrant->Disable();
+                allPrivilegesGrant->SetValue(false);
+                privCheckboxes[i*2]->Enable();
+                CheckGrantOpt(i);
+            }
+        }
+    }
+}
+
+
+
+void ctlSecurityPanel::OnPrivCheckAllGrant(wxCommandEvent& ev)
+{
+    bool grant=allPrivilegesGrant->GetValue();
+    int i;
+    for (i=0 ; i < privilegeCount ; i++)
+        privCheckboxes[i*2+1]->SetValue(grant);
+}
+
+
+void ctlSecurityPanel::OnPrivCheck(wxCommandEvent& ev)
+{
+    int id=(ev.GetId()-CTL_PRIVCB) /2;
+    CheckGrantOpt(id);
+}
+
+
+void ctlSecurityPanel::CheckGrantOpt(int id)
+{
+    bool canGrant=(GrantAllowed() && privCheckboxes[id*2]->GetValue());
+    if (canGrant)
+        privCheckboxes[id*2+1]->Enable();
+    else
+    {
+        privCheckboxes[id*2+1]->SetValue(false);
+        privCheckboxes[id*2+1]->Disable();
+    }
+}
+
+
+void ctlSecurityPanel::OnDelPriv(wxCommandEvent &ev)
+{
+    if (lbPrivileges->GetFirstSelected() == -1)
+        return;
+        
+    lbPrivileges->DeleteCurrentItem();
+    
+    wxCommandEvent event( EVT_SECURITYPANEL_CHANGE, GetId() );
+    event.SetEventObject( this );
+    GetEventHandler()->ProcessEvent( event );
+
+    ev.Skip();
+}
+
+
+void ctlSecurityPanel::OnAddPriv(wxCommandEvent &ev)
+{
+    wxString name=cbGroups->GetGuessedStringSelection();
+
+    long pos=lbPrivileges->FindItem(-1, name);
+    if (pos < 0)
+    {
+        pos = lbPrivileges->GetItemCount();
+        int icon=userFactory.GetIconId();
+
+        if (name.Left(6).IsSameAs(wxT("group "), false))
+            icon = groupFactory.GetIconId();
+        else if (name.IsSameAs(wxT("public"), false))
+            icon = PGICON_PUBLIC;
+
+        lbPrivileges->InsertItem(pos, name, icon);
+    }
+    wxString value;
+    int i;
+    for (i=0 ; i < privilegeCount ; i++)
+    {
+        if (privCheckboxes[i*2]->GetValue())
+        {
+            value += privilegeChars[i];
+            if (privCheckboxes[i*2+1]->GetValue())
+                value += '*';
+        }
+    }
+    lbPrivileges->SetItem(pos, 1, value);
+
+    wxCommandEvent event( EVT_SECURITYPANEL_CHANGE, GetId() );
+    event.SetEventObject( this );
+    GetEventHandler()->ProcessEvent( event );
+
+    ev.Skip();
+}
+
+
+void ctlSecurityPanel::OnPrivSelChange(wxListEvent &ev)
+{
+    if (!cbGroups)
+        return;
+    if (allPrivileges)
+    {
+        allPrivileges->SetValue(false);
+        allPrivilegesGrant->SetValue(false);
+        allPrivilegesGrant->Disable();
+    }
+    long pos=lbPrivileges->GetSelection();
+    if (pos >= 0)
+    {
+        wxString name=lbPrivileges->GetText(pos);
+        wxString value=lbPrivileges->GetText(pos, 1);
+
+        pos=cbGroups->FindString(name);
+        if (pos < 0)
+        {
+            cbGroups->Append(name);
+            pos=cbGroups->GetCount()-1;
+        }
+        cbGroups->SetSelection(pos);
+
+        int i;
+        for (i=0 ; i < privilegeCount ; i++)
+        {
+            if (privCheckboxes[i*2]->GetName() != wxT("DISABLE"))
+            {
+                privCheckboxes[i*2]->Enable();
+                int index=value.Find(privilegeChars[i]);
+                if (index >= 0)
+                {
+                    privCheckboxes[i*2]->SetValue(true);
+                    privCheckboxes[i*2+1]->SetValue(value.Mid(index+1, 1) == wxT("*"));
+                }
+                else
+                    privCheckboxes[i*2]->SetValue(false);
+            }
+            CheckGrantOpt(i);
+        }
+    }
+    btnAddPriv->Enable();
+}
+
+
+
+bool ctlSecurityPanel::GrantAllowed() const
+{
+    if (!connection->BackendMinimumVersion(7, 4))
+        return false;
+
+    wxString user=cbGroups->GetValue();
+    if (user.IsSameAs(wxT("public"), false))
+        return false;
+
+    if (!connection->BackendMinimumVersion(8, 1) &&
+        user.Left(6).IsSameAs(wxT("group "), false))
+        return false;
+
+    return true;
+}
+
+bool ctlSecurityPanel::DisablePrivilege(const wxString &priv)
+{
+    for (int i=0; i < privilegeCount; i++)
+    {
+        if (privCheckboxes[i*2]->GetLabel() == priv)
+        {
+            // Use the Name property as a flag so we don't accidently reenable the control later
+            privCheckboxes[i*2]->SetName(wxT("DISABLE"));
+            privCheckboxes[i*2]->Disable();
+            return true;
+        }
+    }
+    return false;
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlMenuToolbar.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlMenuToolbar.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/ctlMenuToolbar.cpp (revision 8187)
@@ -0,0 +1,192 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlMenuToolbar.cpp - Menu tool bar
+//
+// This code is essentially stolen (with the authors permission) from 
+// Paul Nelson (http://www.pnelsoncomposer.com/)
+//
+//////////////////////////////////////////////////////////////////////////
+
+// wxWindows headers
+#include <wx/wx.h>
+
+// App headers
+#include "pgAdmin3.h"
+#include "ctl/ctlMenuToolbar.h"
+
+#include <wx/listimpl.cpp>
+WX_DEFINE_LIST(ctlMenuToolList);
+
+/* XPM */
+static const char *pulldown_xpm[] = {
+"16 16 2 1",
+". c Black",
+"  c None",
+/* pixels */
+"                ",
+"                ",
+"                ",
+"                ",
+"                ",
+"                ",
+"     .......    ",
+"      .....     ",
+"       ...      ",
+"        .       ",
+"                ",
+"                ",
+"                ",
+"                ",
+"                ",
+"                "
+};
+
+
+DEFINE_EVENT_TYPE(wxEVT_FILL_MENU)
+
+//////////////////
+// ctlMenuButton
+//////////////////
+
+void ctlMenuButton::Create(wxWindow *window, wxToolBar *toolBar, int ID, wxMenu *menu)
+{
+    wxBitmap bmpPulldown(pulldown_xpm);
+    wxSize pulldownSize;
+
+#ifdef __WXMSW__
+    pulldownSize.Set(12,16);
+#else
+#ifdef __WXGTK__
+    pulldownSize.Set(18,16);
+#else
+    pulldownSize.Set(10,16);
+#endif
+#endif
+
+    m_toolBar = toolBar;
+    m_menu = menu;
+
+    ((wxBitmapButton *)this)->Create(window, ID, bmpPulldown, wxDefaultPosition, pulldownSize, wxNO_BORDER);
+    Connect(ID, wxEVT_LEFT_DOWN, wxMouseEventHandler(ctlMenuButton::DoProcessLeftClick) );
+}
+
+
+void ctlMenuButton::DoProcessLeftClick(wxMouseEvent& event)
+{
+    wxPoint menu_pos;
+
+    if(m_toolBar) 
+	{
+        wxSize tool_size = m_toolBar->GetToolSize();
+        wxSize button_size = GetSize();
+
+        // ** Assume that pulldown is to the right of a standard toolbar button,
+        //    so, move the x position back one standard toolbar button's width
+        menu_pos.x = - tool_size.GetWidth();
+        menu_pos.y =  button_size.GetHeight()/2 + tool_size.GetHeight()/2;
+
+#ifdef __WXMAC__
+        wxSize tbar_size = m_toolBar->GetSize();
+        wxPoint button_pos = GetPosition();
+        int iToolSep = m_toolBar->GetToolSeparation();
+        if(iToolSep == 0) iToolSep = 5;
+
+        menu_pos.x += - iToolSep;
+        menu_pos.y = tbar_size.GetHeight() - button_pos.y/2;
+#endif
+    }
+    else 
+	{
+        wxSize button_size;
+        button_size = GetSize();
+        menu_pos.x = 0;
+        menu_pos.y = button_size.GetHeight();
+    }
+
+    PopupMenu(m_menu, menu_pos);
+}
+
+
+
+////////////////
+// ctlMenuTool
+////////////////
+
+ctlMenuTool::ctlMenuTool(wxToolBarToolBase *new_tool, int toolId)
+{
+    m_tool = new_tool;
+    m_menu = NULL;
+    m_toolId = toolId;
+}
+
+
+////////////////////
+// ctlMenuToolbar
+////////////////////
+
+ctlMenuToolbar::ctlMenuToolbar(wxFrame* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
+: wxToolBar(parent, id, pos, size, style, name)
+{
+    m_frame = parent;
+    m_menuTools = NULL;
+
+    Connect(id, wxEVT_LEFT_DOWN, wxMouseEventHandler(ctlMenuToolbar::DoProcessLeftClick) );
+}
+
+
+ctlMenuToolbar::~ctlMenuToolbar()
+{
+    if(m_menuTools)  
+	    delete m_menuTools;
+}
+
+ctlMenuButton *ctlMenuToolbar::AddMenuPulldownTool(int toolId, const wxString& label, const wxString& shortHelpString, wxMenu *popupmenu)
+{
+    ctlMenuButton *menu_button = new ctlMenuButton(this, toolId, popupmenu);
+
+    AddControl(menu_button);
+
+    return menu_button;
+}
+
+
+void ctlMenuToolbar::DoProcessLeftClick(wxMouseEvent& event)
+{
+    ctlMenuToolList::Node *node = NULL;
+    ctlMenuTool *menu_tool = NULL;
+    wxToolBarToolBase *clickTool = FindToolForPosition(event.m_x, event.m_y);
+
+    if(clickTool == NULL || m_menuTools == NULL) 
+	{  
+	    event.Skip();  
+		return;  
+	}
+
+    // search for clickTool in the list of menu tools
+    node = m_menuTools->GetFirst();
+    for( ; node ; node = node->GetNext()) 
+	{
+        menu_tool = node->GetData();
+        if(menu_tool->m_tool == clickTool) 
+		    break;
+    }
+  
+    if(node == NULL) 
+	{  
+	    event.Skip();  
+		return;  
+	}
+
+    wxSize tbar_size = GetSize();
+    wxPoint menu_pos;
+
+    menu_pos.x = event.m_x - 20;
+    menu_pos.y = tbar_size.GetHeight() - 2;
+
+    PopupMenu(menu_tool->m_menu, menu_pos);
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/explainCanvas.cpp
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/explainCanvas.cpp (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/ctl/explainCanvas.cpp (revision 8187)
@@ -0,0 +1,333 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// explainCanvas.cpp - Explain Canvas
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+// wxWindows headers
+#include <wx/wx.h>
+
+// App headers
+#include "pgAdmin3.h"
+
+#include "ctl/explainCanvas.h"
+
+
+
+ExplainCanvas::ExplainCanvas(wxWindow *parent)
+: wxShapeCanvas(parent)
+{
+    SetDiagram(new wxDiagram);
+    GetDiagram()->SetCanvas(this);
+    SetBackgroundColour(*wxWHITE);
+    lastShape=0;
+    popup = new ExplainPopup(this);
+}
+
+
+ExplainCanvas::~ExplainCanvas()
+{
+}
+
+
+void ExplainCanvas::Clear()
+{
+    GetDiagram()->DeleteAllShapes();
+    lastShape=0;
+}
+
+
+void ExplainCanvas::SetExplainString(const wxString &str)
+{
+    Clear();
+
+    ExplainShape *last=0;
+    int maxLevel=0;
+
+    wxStringTokenizer lines(str, wxT("\n"));
+
+    while (lines.HasMoreTokens())
+    {
+        wxString tmp=lines.GetNextToken();
+        wxString line=tmp.Strip(wxString::both);
+
+		int braceCount=0;
+		do
+		{
+			const wxChar *cp=line.c_str();
+			while (*cp)
+			{
+				if (*cp == '(')
+					braceCount++;
+				else if (*cp == ')')
+					braceCount--;
+				cp++;
+			}
+			if (braceCount > 0)
+			{
+		        wxString tmp=lines.GetNextToken();
+				line += wxT(" ") + tmp.Strip(wxString::both);
+				braceCount=0;
+			}
+			else
+				break;
+		}
+		while (lines.HasMoreTokens());
+
+        long level = (tmp.Length() - line.Length() +4) / 6;
+
+        if (last)
+        {
+            if (level)
+            {
+                if (line.Left(4) == wxT("->  "))
+                    line = line.Mid(4);
+                else
+                {
+                    last->SetCondition(line);
+                    continue;
+                }
+            }
+
+            while (last && level <= last->GetLevel())
+                last = last->GetUpper();
+        }
+
+
+        ExplainShape *s=ExplainShape::Create(level, last, line);
+        if (!s)
+            continue;
+        s->SetCanvas(this);
+        InsertShape(s);
+        s->Show(true);
+
+        if (level > maxLevel)
+            maxLevel = level;
+        
+        if (!last)
+            rootShape = s;
+        last=s;
+    }
+
+
+    int x0 = (int)(rootShape->GetWidth()*3);
+    int y0 = (int)(rootShape->GetHeight()*3/2);
+    int xoffs = (int)(rootShape->GetWidth()*3);
+    int yoffs = (int)(rootShape->GetHeight()*5/4);
+
+    wxNode *current = GetDiagram()->GetShapeList()->GetFirst();
+    while (current)
+    {
+        ExplainShape *s = (ExplainShape*)current->GetData();
+
+        if (!s->totalShapes)
+            s->totalShapes = 1;
+        if (s->GetUpper())
+            s->GetUpper()->totalShapes += s->totalShapes;
+        current = current->GetNext();
+    }
+
+    current = GetDiagram()->GetShapeList()->GetLast();
+    while (current)
+    {
+        ExplainShape *s = (ExplainShape*)current->GetData();
+
+        s->SetX(y0 + (maxLevel - s->GetLevel()) * xoffs);
+        ExplainShape *upper = s->GetUpper();
+
+        if (upper)
+        {
+            s->SetY(upper->GetY() + upper->usedShapes * yoffs);
+            upper->usedShapes += s->totalShapes;
+
+            wxLineShape *l=new ExplainLine(s, upper);
+            l->Show(true);
+            AddShape(l);
+        }
+        else
+        {
+            s->SetY(y0);
+        }
+
+        current = current->GetPrevious();
+    }
+
+#define PIXPERUNIT  20
+    int w=(maxLevel * xoffs + x0*2 + PIXPERUNIT - 1) / PIXPERUNIT;
+    int h=(rootShape->totalShapes * yoffs + y0*2 + PIXPERUNIT - 1) / PIXPERUNIT;
+
+    SetScrollbars(PIXPERUNIT, PIXPERUNIT, w, h);
+}
+
+
+void ExplainCanvas::ShowPopup(ExplainShape *s)
+{
+    int sx, sy;
+    CalcScrolledPosition((int)s->GetX(), (int)s->GetY(), &sx, &sy);
+
+    popup->SetShape(s);
+
+    if (sy > GetClientSize().y*2/3)
+        sy -= popup->GetSize().y;
+    sx -= popup->GetSize().x / 2;
+    if (sx < 0) sx=0;
+
+    popup->Popup();
+    popup->Move(ClientToScreen(wxPoint(sx, sy)));
+}
+
+
+class ExplainText : public wxWindow
+{
+public:
+    ExplainText(wxWindow *parent, ExplainShape *s);
+
+private:
+    ExplainShape *shape;
+    void OnPaint(wxPaintEvent &ev);
+
+    DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(ExplainText, wxWindow)
+    EVT_PAINT(ExplainText::OnPaint)
+END_EVENT_TABLE()
+
+
+ExplainText::ExplainText(wxWindow *parent, ExplainShape *s) : wxWindow(parent, -1)
+{
+    SetBackgroundColour(wxColour(255,255,224));
+
+    shape=s;
+
+    wxWindowDC dc(this);
+    dc.SetFont(settings->GetSystemFont());
+
+    int w1, w2, h;
+    dc.GetTextExtent(shape->description, &w1, &h);
+
+    dc.GetTextExtent(shape->detail, &w2, &h);
+    if (w1 < w2)    w1=w2;
+    dc.GetTextExtent(shape->condition, &w2, &h);
+    if (w1 < w2)    w1=w2;
+    dc.GetTextExtent(shape->cost, &w2, &h);
+    if (w1 < w2)    w1=w2;
+    dc.GetTextExtent(shape->actual, &w2, &h);
+    if (w1 < w2)    w1=w2;
+
+    int n=2;
+    if (!shape->detail.IsEmpty())
+        n++;
+    if (!shape->condition.IsEmpty())
+        n++;
+    if (!shape->cost.IsEmpty())
+        n++;
+    if (!shape->actual.IsEmpty())
+        n++;
+
+    if (!h)
+        h = GetCharHeight();
+
+    SetSize(GetCharHeight() + w1, GetCharHeight() + h * n + h/3);
+}
+
+    
+void ExplainText::OnPaint(wxPaintEvent &ev)
+{
+    wxPaintDC dc(this);
+
+    wxFont stdFont = settings->GetSystemFont();
+    wxFont boldFont = stdFont;
+    boldFont.SetWeight(wxBOLD);
+
+    int x = GetCharHeight() / 2;
+    int y = GetCharHeight() / 2;
+    int w, yoffs;
+    dc.GetTextExtent(wxT("Dummy"), &w, &yoffs);
+
+    dc.SetFont(boldFont);
+    dc.DrawText(shape->description, x, y);
+
+    dc.SetFont(stdFont);
+
+    if (!shape->detail.IsEmpty())
+    {
+        y += yoffs;
+        dc.DrawText(shape->detail, x, y);
+
+    }
+    y += yoffs/3;
+
+    if (!shape->condition.IsEmpty())
+    {
+        y += yoffs;
+        dc.DrawText(shape->condition, x, y);
+    }
+    if (!shape->cost.IsEmpty())
+    {
+        y += yoffs;
+        dc.DrawText(shape->cost, x, y);
+    }
+    if (!shape->actual.IsEmpty())
+    {
+        y += yoffs;
+        dc.DrawText(shape->actual, x, y);
+    }
+}
+
+
+BEGIN_EVENT_TABLE(ExplainPopup, wxDialog)
+EVT_MOTION(ExplainPopup::OnMouseMove)
+END_EVENT_TABLE()
+
+ExplainPopup::ExplainPopup(wxWindow *w) : wxDialog(w, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER)
+{
+    explainText=0;
+}
+
+
+void ExplainPopup::SetShape(ExplainShape *s)
+{
+    if (explainText)
+        delete explainText;
+    explainText = new ExplainText(this, s);
+    SetSize(explainText->GetSize());
+}
+
+
+void ExplainPopup::Popup()
+{
+    Show();
+	Raise();
+    wxTheApp->Yield(true);
+
+    popupPoint = wxDefaultPosition;
+    CaptureMouse();
+}
+
+
+#define POPUP_HISTERESIS 5
+
+void ExplainPopup::OnMouseMove(wxMouseEvent &ev)
+{
+    if (popupPoint == wxDefaultPosition)
+    {
+        popupPoint = ev.GetPosition();
+    }
+    else
+    {
+        if (abs(popupPoint.x - ev.GetX()) > POPUP_HISTERESIS || abs(popupPoint.y - ev.GetY()) > POPUP_HISTERESIS)
+        {
+            ReleaseMouse();
+            delete explainText;
+            explainText=0;
+            wxDialog::Hide();
+        }
+    }
+}
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlMenuToolbar.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlMenuToolbar.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlMenuToolbar.h (revision 8187)
@@ -0,0 +1,88 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlMenuToolbar.h - Menu tool bar
+//
+// This code is essentially stolen (with the authors permission) from 
+// Paul Nelson (http://www.pnelsoncomposer.com/)
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLMENUTOOLBAR_H
+#define CTLMENUTOOLBAR_H
+
+#include "wx/frame.h"
+
+// ctlMenuButton - Can be used wherever you can use a standard wxBitmapButton
+//
+// Implements a small pull-down triangle (v), which, when clicked, will display
+// a pop-up menu. 
+
+class ctlMenuButton : public wxBitmapButton
+{
+public:
+    ctlMenuButton(wxToolBar *toolBar, int ID, wxMenu *menu)  { Create(toolBar, toolBar, ID, menu); }
+    void DoProcessLeftClick(wxMouseEvent& event);
+
+    wxMenu *m_menu;
+
+    void FillMenu();
+
+private:
+    void Create(wxWindow *window, wxToolBar *toolBar, int ID, wxMenu *menu);
+    wxToolBar *m_toolBar;
+};
+
+
+// ctlMenuTool - is only used internal to the implementation of ctlMenuToolbar.
+//
+// You should never have to use it yourself
+
+class ctlMenuTool
+{
+public:
+    ctlMenuTool(wxToolBarToolBase *new_tool, int toolId);
+    wxToolBarToolBase *m_tool;
+    wxMenu *m_menu;
+	
+private:
+    int m_toolId;
+    ctlMenuButton *m_button;
+};
+
+WX_DECLARE_LIST(ctlMenuTool, ctlMenuToolList);
+
+
+// *** ctlMenuToolbar  -  A replacement for wxToolBar which implements menu buttons
+//                       and pull-down buttons
+//
+// A menu button is a standard looking toolbar tool which, when clicked, pops up a 
+// menu which can be selected.
+//
+// A pull-down button presents a small black triangle which, when clicked, pops up
+// a menu which can be selected. These buttons are typically used for a list of previous
+// actions (for example, previous web pages visited).
+
+class ctlMenuToolbar : public wxToolBar
+{
+public:
+    ctlMenuToolbar();
+    ctlMenuToolbar(wxFrame* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTB_HORIZONTAL | wxNO_BORDER, const wxString& name = wxPanelNameStr);
+    ~ctlMenuToolbar();
+
+    // NOTE:  label, shortHelpString, are not implemented on all platforms and are only 
+    //        included for possible future upgrades
+    ctlMenuButton *AddMenuPulldownTool(int toolId, const wxString& label, const wxString& shortHelpString = wxEmptyString, wxMenu *popupmenu=0);
+    void DoProcessLeftClick(wxMouseEvent& event);
+
+private:
+    wxFrame *m_frame;
+    ctlMenuToolList *m_menuTools;
+};
+
+#endif
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSecurityPanel.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSecurityPanel.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSecurityPanel.h (revision 8187)
@@ -0,0 +1,82 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlSecurityPanel.h - Panel with security information
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef CTL_SECPANEL_H
+#define CTL_SECPANEL_H
+
+#include <wx/wx.h>
+#include <wx/notebook.h>
+
+enum
+{
+    CTL_PROPSQL=250,
+    CTL_MSG,
+    CTL_LBPRIV,
+    CTL_STATICGROUP,
+    CTL_CBGROUP,
+    CTL_ADDPRIV,
+    CTL_DELPRIV,
+    CTL_ALLPRIV,
+    CTL_ALLPRIVGRANT,
+    CTL_PRIVCB          // base for all privilege checkboxes, must be last
+};
+
+DECLARE_EVENT_TYPE(EVT_SECURITYPANEL_CHANGE, -1)
+
+class pgConn;
+
+class ctlSecurityPanel : public wxPanel
+{
+
+public:
+
+    ctlSecurityPanel(wxNotebook *nb, const wxString &privList, const char *privChars, wxImageList *imgList);
+    ~ctlSecurityPanel();
+
+    ctlListView *lbPrivileges;
+    ctlComboBox *cbGroups;
+    wxStaticText *stGroup;
+    void SetConnection(pgConn *conn);
+
+    /*
+     *  Except column level privileges, column will be always an empty string in any case
+     */
+    wxString GetGrant(const wxString &allPattern, const wxString &grantObject, wxArrayString *currentAcl=0, wxString column = wxEmptyString);
+    bool DisablePrivilege(const wxString &priv);
+protected:
+    wxNotebook *nbNotebook;
+    pgConn *connection;
+
+    wxButton *btnAddPriv, *btnDelPriv;
+    int privilegeCount;
+    const char *privilegeChars;
+    wxCheckBox **privCheckboxes;
+    wxCheckBox *allPrivileges, *allPrivilegesGrant;
+
+    void OnPrivSelChange(wxListEvent &ev);
+    void OnAddPriv(wxCommandEvent& ev);
+    void OnGroupChange(wxCommandEvent &ev);
+    void OnDelPriv(wxCommandEvent& ev);
+    void OnPrivCheck(wxCommandEvent& ev);
+    void OnPrivCheckAll(wxCommandEvent& ev);
+    void OnPrivCheckAllGrant(wxCommandEvent& ev);
+
+    void CheckGrantOpt(int index);
+    bool GrantAllowed() const;
+
+
+    DECLARE_EVENT_TABLE()
+};
+
+
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/explainCanvas.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/explainCanvas.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/explainCanvas.h (revision 8187)
@@ -0,0 +1,107 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// explainCanvas.cpp - Explain Canvas
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef EXPLAINCANVAS_H
+#define EXPLAINCANVAS_H
+
+#include <wx/ogl/ogl.h>
+
+
+#if wxUSE_DEPRECATED
+#error wxUSE_DEPRECATED should be 0!
+#endif
+
+
+class ExplainShape;
+class ExplainPopup;
+class ExplainText;
+
+class ExplainCanvas : public wxShapeCanvas
+{
+public:
+    ExplainCanvas(wxWindow *parent);
+    ~ExplainCanvas();
+
+    void ShowPopup(ExplainShape *s);
+    void SetExplainString(const wxString &str);
+    void Clear();
+
+private:
+
+    ExplainShape *rootShape, *lastShape;
+    ExplainPopup *popup;
+};
+
+
+class ExplainShape : public wxBitmapShape
+{
+public:
+    ExplainShape(const char *bmp[], const wxString &description, long tokenNo=-1, long detailNo=-1);
+    static ExplainShape *Create(long level, ExplainShape *last, const wxString &str); 
+
+    void SetCondition(const wxString &str) { if (condition.Length()==0) condition = str; else condition += wxT(" ") + str; }
+    long GetLevel() { return level; }
+    wxRealPoint GetStartPoint();
+    wxRealPoint GetEndPoint(int kidNo);
+    int GetKidno() { return kidNo; }
+
+    ExplainShape *GetUpper() { return upperShape; }
+    double GetAverageCost() { return (costHigh - costLow) / 2 + costLow; }
+
+protected:
+    void OnDraw(wxDC& dc);
+    void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
+
+    ExplainShape *upperShape;
+
+    void SetLabel(const wxString &str, int tokenNo=-1, int detailNo=-1);
+
+    long level;
+    wxString description, detail, condition, label;
+    wxString cost, actual;
+    double costLow, costHigh;
+    long rows, width;
+    int kidCount, kidNo;
+    int totalShapes; // horizontal space usage by shape and its kids
+    int usedShapes;
+
+    friend class ExplainCanvas;
+    friend class ExplainText;
+};
+
+
+class ExplainLine : public wxLineShape
+{
+public:
+    ExplainLine(ExplainShape *from, ExplainShape *to, double weight=0);
+
+private:
+    int width;
+    void OnDraw(wxDC& dc);
+};
+
+
+class ExplainPopup : public wxDialog
+{
+public:
+    ExplainPopup(wxWindow *w);
+    void SetShape(ExplainShape *s);
+    void Popup();
+
+private:
+    void OnMouseMove(wxMouseEvent &ev);
+
+    ExplainText *explainText;
+    wxPoint popupPoint;
+    DECLARE_EVENT_TABLE()
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_calb.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_calb.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_calb.h (revision 8187)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// xh_calb.h - wxCalendarBox handler
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef _WX_XH_CALB_H_
+#define _WX_XH_CALB_H_
+
+
+#include "wx/xrc/xmlres.h"
+
+//class WXDLLIMPEXP_XRC 
+class wxCalendarBoxXmlHandler : public wxXmlResourceHandler
+{
+DECLARE_DYNAMIC_CLASS(wxCalendarBoxXmlHandler)
+public:
+    wxCalendarBoxXmlHandler();
+    virtual wxObject *DoCreateResource();
+    virtual bool CanHandle(wxXmlNode *node);
+};
+
+
+#endif // _WX_XH_CALB_H_
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSQLResult.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSQLResult.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSQLResult.h (revision 8187)
@@ -0,0 +1,91 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlSQLResult.h - SQL Query result window
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLSQLRESULT_H
+#define CTLSQLRESULT_H
+
+// wxWindows headers
+#include <wx/thread.h>
+
+#include "db/pgSet.h"
+#include "db/pgConn.h"
+#include "ctlSQLGrid.h"
+
+#define CTLSQL_RUNNING 100  // must be greater than ExecStatusType PGRES_xxx values
+
+class ctlSQLResult : public ctlSQLGrid
+{
+public:
+    ctlSQLResult(wxWindow *parent, pgConn *conn, wxWindowID id, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize);
+    ~ctlSQLResult();
+
+
+    int Execute(const wxString &query, int resultToDisplay=0, wxWindow *caller=0, long eventId=0, void *data=0); // > 0: resultset to display, <=0: last result
+    void SetConnection(pgConn *conn);
+    long NumRows() const;
+    long InsertedCount() const;
+    OID  InsertedOid() const;
+
+    int Abort();
+
+    bool Export();
+	bool ToFile();
+    bool CanExport() { return NumRows() >0 && colNames.GetCount() > 0; }
+
+	wxString OnGetItemText(long item, long col) const;
+    bool IsColText(int col);
+	bool hasRowNumber() { return !rowcountSuppressed; }
+
+    int RunStatus();
+    wxString GetMessagesAndClear();
+    wxString GetErrorMessage();
+    pgError GetResultError();
+
+	void DisplayData(bool single=false);
+
+    bool GetRowCountSuppressed() { return rowcountSuppressed; };
+
+    void SetMaxRows(int rows);
+    void ResultsFinished();
+    void OnGridSelect(wxGridRangeSelectEvent& event);
+
+    wxArrayString colNames;
+    wxArrayString colTypes;
+    wxArrayLong colTypClasses;
+
+    wxArrayInt  colSizes;
+    wxArrayString colHeaders;
+
+private:
+    pgQueryThread *thread;
+    pgConn *conn;
+	bool rowcountSuppressed;
+};
+
+class sqlResultTable : public wxGridTableBase
+{
+public:
+    sqlResultTable();
+    wxString GetValue(int row, int col);
+    int GetNumberRows();
+    int GetNumberCols();
+    bool IsEmptyCell(int row, int col) { return false; }
+    wxString GetColLabelValue(int col);
+    void SetValue(int row, int col, const wxString& value) { return; }
+    void SetThread(pgQueryThread *t) { thread = t; }
+    bool DeleteRows(size_t pos = 0, size_t numRows = 1) { return true; }
+    bool DeleteCols(size_t pos = 0, size_t numCols = 1) { return true; }
+
+private:
+    pgQueryThread *thread;
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_ctlcombo.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_ctlcombo.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_ctlcombo.h (revision 8187)
@@ -0,0 +1,31 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// xh_ctlcombo.h - ctlComboBox handler
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef _WX_XH_CTLCOMBO_H_
+#define _WX_XH_CTLCOMBO_H_
+
+
+#include "wx/xrc/xmlres.h"
+#include "wx/xrc/xh_combo.h"
+
+//class WXDLLIMPEXP_XRC 
+class ctlComboBoxXmlHandler : public wxComboBoxXmlHandler
+{
+DECLARE_DYNAMIC_CLASS(ctlComboBoxXmlHandler)
+public:
+    ctlComboBoxXmlHandler() : wxComboBoxXmlHandler() {}
+    virtual wxObject *DoCreateResource();
+    virtual bool CanHandle(wxXmlNode *node);
+};
+
+
+#endif 
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_ctltree.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_ctltree.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_ctltree.h (revision 8187)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// xh_ctltree.h - ctlTree handler
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef _WX_XH_CTLTREE_H_
+#define _WX_XH_CTLTREE_H_
+
+#include "wx/xrc/xmlres.h"
+#include "wx/xrc/xh_tree.h"
+
+//class WXDLLIMPEXP_XRC 
+class ctlTreeXmlHandler : public wxTreeCtrlXmlHandler
+{
+DECLARE_DYNAMIC_CLASS(ctlTreeXmlHandler)
+public:
+    ctlTreeXmlHandler() : wxTreeCtrlXmlHandler() {}
+    virtual wxObject *DoCreateResource();
+    virtual bool CanHandle(wxXmlNode *node);
+};
+
+
+#endif 
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlTree.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlTree.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlTree.h (revision 8187)
@@ -0,0 +1,87 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlTree.h - wxTreeCtrl containing pgObjects
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLTREE_H
+#define CTLTREE_H
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/treectrl.h>
+#include <wx/timer.h>
+
+class pgObject;
+class pgCollection;
+class pgaFactory;
+class ctlTreeFindTimer;
+
+class ctlTree : public wxTreeCtrl
+{
+public:
+    ctlTree(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS);
+    void SetItemImage(const wxTreeItemId& item, int image, wxTreeItemIcon which = wxTreeItemIcon_Normal);
+    wxTreeItemId AppendItem(const wxTreeItemId& parent, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL);
+    wxTreeItemId AppendObject(pgObject *parent, pgObject *object);
+    void RemoveDummyChild(pgObject *obj);
+    pgCollection *AppendCollection(pgObject *parent, pgaFactory &factory);
+    pgObject *GetObject(wxTreeItemId id);
+    pgObject *GetParentObject(wxTreeItemId id) { return GetObject(GetItemParent(id)); }
+    pgCollection *GetParentCollection(wxTreeItemId id);
+    pgObject *FindObject(pgaFactory &factory, wxTreeItemId parent);
+    pgCollection *FindCollection(pgaFactory &factory, wxTreeItemId parent);
+    wxTreeItemId FindItem(const wxTreeItemId& item, const wxString& str);
+    virtual ~ctlTree();
+
+    DECLARE_EVENT_TABLE()
+
+private:
+    void OnChar(wxKeyEvent& event);
+    wxString m_findPrefix;
+    ctlTreeFindTimer * m_findTimer;
+
+friend class ctlTreeFindTimer;
+};
+
+
+// timer used to clear ctlTreeCtrl::m_findPrefix if no key was pressed
+// for a sufficiently long time
+class ctlTreeFindTimer : public wxTimer
+{
+public:
+    // reset the current prefix after half a second of inactivity
+    enum { CTLTREE_DELAY = 500 };
+
+    ctlTreeFindTimer( ctlTree *owner ) { m_owner = owner; }
+
+    virtual void Notify() { m_owner->m_findPrefix.clear(); }
+
+private:
+    ctlTree *m_owner;
+
+    DECLARE_NO_COPY_CLASS(ctlTreeFindTimer)
+};
+
+
+class treeObjectIterator
+{
+public:
+    treeObjectIterator(ctlTree *browser, pgObject *obj);
+    pgObject *GetNextObject();
+
+private:
+    wxTreeItemId lastItem;
+    ctlTree *browser;
+    pgObject *object;
+    wxCookieType cookie;
+};
+
+
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/module.mk
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/module.mk (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/module.mk (revision 8187)
@@ -0,0 +1,34 @@
+#######################################################################
+#
+# pgAdmin III - PostgreSQL Tools
+# $Id$
+# Copyright (C) 2002 - 2010, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# module.mk - pgadmin/include/ctl/ Makefile fragment
+#
+#######################################################################
+
+pgadmin3_SOURCES += \
+    $(srcdir)/include/ctl/calbox.h \
+	$(srcdir)/include/ctl/ctlComboBox.h \
+	$(srcdir)/include/ctl/ctlListView.h \
+	$(srcdir)/include/ctl/ctlMenuToolbar.h \
+	$(srcdir)/include/ctl/ctlSecurityPanel.h \
+	$(srcdir)/include/ctl/ctlSQLBox.h \
+	$(srcdir)/include/ctl/ctlSQLGrid.h \
+	$(srcdir)/include/ctl/ctlSQLResult.h \
+	$(srcdir)/include/ctl/ctlTree.h \
+    $(srcdir)/include/ctl/explainCanvas.h \
+	$(srcdir)/include/ctl/timespin.h \
+	$(srcdir)/include/ctl/wxgridsel.h \
+	$(srcdir)/include/ctl/xh_calb.h \
+	$(srcdir)/include/ctl/xh_ctlcombo.h \
+	$(srcdir)/include/ctl/xh_ctltree.h \
+	$(srcdir)/include/ctl/xh_sqlbox.h \
+	$(srcdir)/include/ctl/xh_timespin.h
+
+EXTRA_DIST += \
+    $(srcdir)/include/ctl/module.mk
+
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_sqlbox.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_sqlbox.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_sqlbox.h (revision 8187)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// xh_sqlbox.h - wxSqlBox handler
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef _WX_XH_SQLBOX_H_
+#define _WX_XH_SQLBOX_H_
+
+
+#include "wx/xrc/xmlres.h"
+
+//class WXDLLIMPEXP_XRC 
+class ctlSQLBoxXmlHandler : public wxXmlResourceHandler
+{
+DECLARE_DYNAMIC_CLASS(ctlSQLBoxXmlHandler)
+public:
+    ctlSQLBoxXmlHandler();
+    virtual wxObject *DoCreateResource();
+    virtual bool CanHandle(wxXmlNode *node);
+};
+
+
+#endif // _WX_XH_SQLBOX_H_
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/calbox.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/calbox.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/calbox.h (revision 8187)
@@ -0,0 +1,89 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// calbox.h - Date-picker control box
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_CALBOX_H_
+#define _WX_CALBOX_H_
+
+#include "wx/calctrl.h"
+
+class wxCalendarBox : public wxControl
+{
+public:
+    wxCalendarBox() { Init(); }
+    wxCalendarBox(wxWindow *parent,
+                   wxWindowID id,
+                   const wxDateTime& date = wxDefaultDateTime,
+                   const wxPoint& pos = wxDefaultPosition,
+                   const wxSize& size = wxDefaultSize,
+                   long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS, const wxString& name=wxCalendarNameStr);
+
+    bool Destroy();
+
+    bool Create(wxWindow *parent,
+                            wxWindowID id,
+                            const wxDateTime& date,
+                            const wxPoint& pos,
+                            const wxSize& size,
+                            long style,
+                            const wxString& name);
+
+    bool SetValue(const wxDateTime& date);
+    wxDateTime GetValue();
+
+    bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime) { return m_cal->SetLowerDateLimit(date); }
+    const wxDateTime& GetLowerDateLimit() const { return m_cal->GetLowerDateLimit(); }
+    bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime) { return m_cal->SetUpperDateLimit(date); }
+    const wxDateTime& GetUpperDateLimit() const { return m_cal->GetUpperDateLimit(); }
+
+    bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime, const wxDateTime& upperdate = wxDefaultDateTime)
+    { return m_cal->SetDateRange(lowerdate, upperdate); }
+
+    wxCalendarDateAttr *GetAttr(size_t day) const { return m_cal->GetAttr(day); }
+    void SetAttr(size_t day, wxCalendarDateAttr *attr) { m_cal->SetAttr(day, attr); }
+    void SetHoliday(size_t day) { m_cal->SetHoliday(day); }
+    void ResetAttr(size_t day) { m_cal->ResetAttr(day); }
+    bool SetFormat(const wxChar *fmt);
+
+    virtual bool Enable(bool enable = true);
+    virtual bool Show(bool show = true);
+    virtual void DoMoveWindow(int x, int y, int width, int height);
+
+private:
+    wxDialog *m_dlg;
+    wxTextCtrl *m_txt;
+    wxCalendarCtrl *m_cal;
+    wxButton *m_btn;
+    wxString m_format;
+
+    bool m_dropped, m_ignoreDrop;
+
+    void Init();
+    void DropDown(bool down=true);
+
+    wxSize DoGetBestSize() const;
+    void OnSize(wxSizeEvent& event);
+
+    void OnText(wxCommandEvent &ev);
+    void OnEditKey(wxKeyEvent & event);
+    void OnCalKey(wxKeyEvent & event);
+    void OnClick(wxCommandEvent &ev);
+    void OnSelChange(wxCalendarEvent &ev);
+    void OnSetFocus(wxFocusEvent &ev);
+    void OnKillFocus(wxFocusEvent &ev);
+    void OnChildSetFocus(wxChildFocusEvent &ev);
+
+    DECLARE_DYNAMIC_CLASS(wxCalendarBox)
+    DECLARE_EVENT_TABLE()
+    DECLARE_NO_COPY_CLASS(wxCalendarBox)
+};
+
+#endif // _WX_CALBOX_H_
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSQLGrid.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSQLGrid.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSQLGrid.h (revision 8187)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlSQLGrid.h - SQL Data Display Grid
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLSQLGRID_H
+#define CTLSQLGRID_H
+
+// wxWindows headers
+#include <wx/grid.h>
+
+
+class ctlSQLGrid : public wxGrid
+{
+public:
+    ctlSQLGrid(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size);
+    ctlSQLGrid();
+
+    wxString GetExportLine(int row);
+    wxString GetExportLine(int row, wxArrayInt cols);
+    wxString GetExportLine(int row, int col1, int col2);
+    virtual bool IsColText(int col) { return false; }
+    int Copy();
+
+    virtual bool CheckRowPresent(int row) { return true; }
+    wxSize GetBestSize(int row, int col);
+    void OnLabelDoubleClick(wxGridEvent& event);
+
+    DECLARE_DYNAMIC_CLASS(ctlSQLGrid)
+    DECLARE_EVENT_TABLE()
+
+private:
+    void OnCopy(wxCommandEvent& event);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/wxgridsel.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/wxgridsel.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/wxgridsel.h (revision 8187)
@@ -0,0 +1,26 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// wxgridsel.h - replacement for wx/generic/gridsel.h
+// if binary wxWindows 2.4.0 distribution is used.
+// This file is necessary until wxGrid supports multiple wxGrid::SetTable() calls
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef __WXGRIDSEL_H
+#define __WXGRIDSEL_H
+
+
+class wxGridSelection
+{
+    wxGridCellCoordsArray dummy1[3];
+    wxArrayInt dummy2[2];
+    void *dummy3;
+    wxGrid::wxGridSelectionModes dummy4;
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlListView.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlListView.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlListView.h (revision 8187)
@@ -0,0 +1,55 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlListView.h - enhanced listview control
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLLISTVIEW_H
+#define CTLLISTVIEW_H
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/listctrl.h>
+#include "utils/misc.h"
+
+class frmMain;
+
+class ctlListView : public wxListView
+{
+public:
+    ctlListView(wxWindow *p, int id, wxPoint pos, wxSize siz, long attr=0);
+    long GetSelection();
+    wxString GetText(long row, long col=0);
+
+    void CreateColumns(wxImageList *images, const wxString &left, const wxString &right, int leftSize=60);
+
+    void AddColumn(const wxChar *text, int size=wxLIST_AUTOSIZE_USEHEADER, int format=wxLIST_FORMAT_LEFT);
+
+    long AppendItem(int icon, const wxChar *val, const wxChar *val2=0, const wxChar *val3=0, const wxChar *val4=0);
+    long AppendItem(const wxChar *val, const wxChar *val2=0, const wxChar *val3=0)
+        {  return AppendItem(PGICON_PROPERTY, val, val2, val3); }
+    void AppendItem(const wxChar *str, const long l)
+        { AppendItem(str, NumToStr(l)); }
+    void AppendItem(const wxChar *str, const bool b)
+        { AppendItem(str, BoolToYesNo(b)); }
+    void AppendItem(const wxChar *str, const double d)
+        { AppendItem(str, NumToStr(d)); }
+    void AppendItem(const wxChar *str, const OID o)
+        { AppendItem(str, NumToStr(o)); }
+    void AppendItem(const wxChar *str, const wxDateTime &d)
+        { AppendItem(str, DateToStr(d)); }
+    void AppendItem(const wxChar *str, const wxLongLong &l)
+        { AppendItem(str, l.ToString()); }
+    void AppendItem(const wxChar *str, const wxULongLong &l)
+        { AppendItem(str, l.ToString()); }
+
+    void DeleteCurrentItem() { DeleteItem(GetSelection()); }
+};
+
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlComboBox.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlComboBox.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlComboBox.h (revision 8187)
@@ -0,0 +1,55 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlComboBox.h - enhanced combobox control
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef __COMBOBOX_H
+#define __COMBOBOX_H
+
+// wxWindows headers
+#include <wx/wx.h>
+#include "utils/misc.h"
+
+
+
+class pgConn;
+class ctlComboBoxFix : public wxComboBox
+{
+public:
+    ctlComboBoxFix(wxWindow *wnd, int id, wxPoint pos, wxSize siz, long attr);
+
+    int FillLongKey(pgConn *conn, const wxChar *qry);
+    int FillOidKey(pgConn *conn, const wxChar *qry);
+    int FillStringKey(pgConn *conn, const wxChar *qry);
+    long GetLongKey(int sel=-1);
+    OID GetOIDKey(int sel=-1);
+    wxString GetStringKey(int sel=-1);
+    bool SetKey(long val);
+    bool SetKey(OID val);
+    bool SetKey(const wxString &val);
+
+    int Append(const wxString& item) { return wxComboBox::Append(item); }
+    int Append(const wxString& item, void *data) { return wxComboBox::Append(item, data); }
+    int Append(const wxString& item, const wxString &str);
+    int Append(const wxString& item, long l);
+    int Append(const wxString& item, OID oid);
+};
+
+class ctlComboBox : public ctlComboBoxFix
+{
+public:
+    ctlComboBox(wxWindow *wnd, int id, wxPoint pos, wxSize siz, long attr=0);
+    int GuessSelection(wxCommandEvent &ev);
+    int GetGuessedSelection() const;
+    wxString GetGuessedStringSelection() const;
+    int GetSelection() const;
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSQLBox.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSQLBox.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/ctlSQLBox.h (revision 8187)
@@ -0,0 +1,77 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlSQLBox.h - SQL syntax highlighting textbox
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLSQLBOX_H
+#define CTLSQLBOX_H
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/stc/stc.h>
+#include <wx/fdrepdlg.h>
+
+#include "db/pgConn.h"
+#include "dlg/dlgFindReplace.h"
+
+// These structs are from Scintilla.h which isn't easily #included :-(
+struct CharacterRange {
+	long cpMin;
+	long cpMax;
+};
+
+struct TextToFind {
+	struct CharacterRange chrg;
+	char *lpstrText;
+	struct CharacterRange chrgText;
+};
+
+// Class declarations
+class ctlSQLBox : public wxStyledTextCtrl
+{
+    static wxString sqlKeywords;
+
+public:
+    ctlSQLBox(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0);
+    ctlSQLBox();
+    ~ctlSQLBox();
+
+    void Create(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0);
+
+	void SetDatabase(pgConn *db);
+
+    void OnKeyDown(wxKeyEvent& event);
+	void OnAutoComplete(wxCommandEvent& event);
+    void OnSearchReplace(wxCommandEvent& event);
+	void OnKillFocus(wxFocusEvent& event);
+
+    bool Find(const wxString &find, bool wholeWord, bool matchCase, bool useRegexps, bool startAtTop, bool reverse);
+    bool Replace(const wxString &find, const wxString &replace, bool wholeWord, bool matchCase, bool useRegexps, bool startAtTop, bool reverse);
+    bool ReplaceAll(const wxString &find, const wxString &replace, bool wholeWord, bool matchCase, bool useRegexps);
+    bool DoFind(const wxString &find, const wxString &replace, bool doReplace, bool wholeWord, bool matchCase, bool useRegexps, bool startAtTop, bool reverse);
+    void SetAutoIndent(bool on) { m_autoIndent = on; }
+    void EnableAutoComp(bool on) { m_autocompDisabled = on; }
+    bool BlockComment(bool uncomment=false);
+
+    CharacterRange RegexFindText(int minPos, int maxPos, const wxString& text);
+
+    DECLARE_DYNAMIC_CLASS(ctlSQLBox)
+    DECLARE_EVENT_TABLE()
+		
+private:
+
+    void OnPositionStc(wxStyledTextEvent& event);
+
+    dlgFindReplace* m_dlgFindReplace;
+	pgConn *m_database;
+    bool m_autoIndent, m_autocompDisabled;
+};
+
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_timespin.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_timespin.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/xh_timespin.h (revision 8187)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// xh_timespin.h - wxTimeSpinCtrl handler
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef _WX_XH_TIMESPIN_H_
+#define _WX_XH_TIMESPIN_H_
+
+
+#include "wx/xrc/xmlres.h"
+
+//class WXDLLIMPEXP_XRC 
+class wxTimeSpinXmlHandler : public wxXmlResourceHandler
+{
+DECLARE_DYNAMIC_CLASS(wxTimeSpinXmlHandler)
+public:
+    wxTimeSpinXmlHandler();
+    virtual wxObject *DoCreateResource();
+    virtual bool CanHandle(wxXmlNode *node);
+};
+
+
+#endif // _WX_XH_TIMESPIN_H_
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/timespin.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/timespin.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/ctl/timespin.h (revision 8187)
@@ -0,0 +1,131 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// timespin.h - timeSpan SpinCtrl
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_TIMESPIN_H_
+#define _WX_TIMESPIN_H_
+
+#include "wx/datetime.h"
+#include "wx/spinbutt.h"
+
+
+class wxTimeSpinCtrl : public wxControl
+{
+public:
+    wxTimeSpinCtrl() { Init(); }
+    wxTimeSpinCtrl(wxWindow *parent,
+                   wxWindowID id,
+                   const wxPoint& pos = wxDefaultPosition,
+                   const wxSize& size = wxDefaultSize,
+                   long style = wxWANTS_CHARS, const wxString& name=wxT("wxTimeSpinCtrl"));
+
+    bool Create(wxWindow *parent,
+                   wxWindowID id,
+                   const wxPoint& pos = wxDefaultPosition,
+                   const wxSize& size = wxDefaultSize,
+                   long style = wxWANTS_CHARS, const wxString& name=wxT("wxTimeSpinCtrl"));
+
+    bool Destroy();
+    bool Enable(bool enable=true);
+
+    void SetMax(long seconds, bool useDay=false);
+    bool SetValue(const wxTimeSpan& span);
+    bool SetTime(const wxDateTime& time);
+    wxTimeSpan GetValue();
+
+private:
+    void Init();
+
+    void OnSpinUp(wxSpinEvent &ev);
+    void OnSpinDown(wxSpinEvent &ev);
+    void OnText(wxCommandEvent &ev);
+    void OnSetFocus(wxFocusEvent &ev);
+    void OnKillFocus(wxFocusEvent &ev);
+    void OnEditKey(wxKeyEvent &ev);
+    void OnNavigate(wxNavigationKeyEvent &ev);
+
+    long GetTextTime();
+    int  GetTimePart();
+    void DoSpin(int diff);
+    void Highlight(int tp);
+
+    wxTextCtrl *m_txt;
+    wxSpinButton *m_spn;
+    wxString m_format;
+    long spinValue, maxSpinValue;
+    bool canWrap, hasDay;
+
+    wxSize DoGetBestSize() const;
+    void OnSize(wxSizeEvent& event);
+
+    DECLARE_DYNAMIC_CLASS(wxTimeSpinCtrl)
+    DECLARE_EVENT_TABLE()
+    DECLARE_NO_COPY_CLASS(wxTimeSpinCtrl)
+};
+
+
+#if 0
+class wxTimeSpinCtrl : public wxSpinCtrl //wxControl
+{
+public:
+    wxTimeSpinCtrl() { }
+    wxTimeSpinCtrl(wxWindow *parent,
+                   wxWindowID id,
+                   const wxDateTime& date = wxDefaultDateTime,
+                   const wxPoint& pos = wxDefaultPosition,
+                   const wxSize& size = wxDefaultSize,
+                   long style = wxWANTS_CHARS, const wxString& name=wxT("wxTimeSpinCtrl"));
+
+    bool Destroy();
+
+
+    bool Create(wxWindow *parent,
+                            wxWindowID id,
+                            const wxDateTime& date,
+                            const wxPoint& pos,
+                            const wxSize& size,
+                            long style,
+                            const wxString& name);
+
+    bool SetValue(const wxTimeSpan& span);
+    wxTimeSpan GetValue();
+
+    virtual bool Enable(bool enable = true);
+    virtual bool Show(bool show = true);
+    virtual void DoMoveWindow(int x, int y, int width, int height);
+
+private:
+    wxTextCtrl *m_txt;
+    wxSpinCtrl *m_spn;
+    wxButton *m_btn;
+    wxString m_format;
+
+    bool m_dropped, m_processing;
+
+    void Init();
+    void DropDown(bool down=true);
+
+    void OnEditKey(wxKeyEvent & event);
+    void OnCalKey(wxKeyEvent & event);
+    void OnClick(wxMouseEvent &ev);
+    void OnSelChange(wxCalendarEvent &ev);
+    void OnActivate(wxActivateEvent &ev);
+    void OnSetFocus(wxFocusEvent &ev);
+    void OnKillFocus(wxFocusEvent &ev);
+
+    DECLARE_DYNAMIC_CLASS(wxTimeSpinCtrl)
+    DECLARE_EVENT_TABLE()
+    DECLARE_NO_COPY_CLASS(wxTimeSpinCtrl)
+};
+#endif
+
+
+#endif // _WX_TIMESPIN_H_
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/frmDebugger.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/frmDebugger.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/frmDebugger.h (revision 8187)
@@ -0,0 +1,151 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmDebugger.h - debugger
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+//	class frmDebugger
+//
+//  frmDebugger manages the user interface for the workstation. This class
+//  manages the toolbar, menu, status bar, and top-level windows.  
+//
+//	This class also defines event handlers for a number of high-level events
+//	(such as window sizing and layout, and creation of new windows).
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMDEBUGGER_H
+#define FRMDEBUGGER_H
+
+#include <wx/aui/aui.h>
+
+#include "ctl/ctlSQLBox.h"
+#include "frm/frmMain.h"
+#include "debugger/dbgConnProp.h"
+#include "debugger/ctlTabWindow.h"
+
+#define FRMDEBUGGER_PERPSECTIVE_VER wxT("$Rev$")
+
+#ifdef __WXMAC__
+#define FRMDEBUGGER_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Toolbar;state=2108144;dir=1;layer=10;row=0;pos=1;prop=100000;bestw=154;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sourcePane;caption=Source pane;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=stackPane;caption=Stack pane;state=2099196;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=2099196;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=237|dock_size(2,0,0)=237|dock_size(3,0,0)=156|")
+#else
+#ifdef __WXGTK__
+#define FRMDEBUGGER_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Toolbar;state=2108144;dir=1;layer=10;row=0;pos=1;prop=100000;bestw=205;besth=30;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sourcePane;caption=Source pane;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=stackPane;caption=Stack pane;state=2099196;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=2099196;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=237|dock_size(2,0,0)=237|dock_size(3,0,0)=156|")
+#else
+#define FRMDEBUGGER_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Toolbar;state=2108144;dir=1;layer=10;row=0;pos=1;prop=100000;bestw=154;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sourcePane;caption=Source pane;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=stackPane;caption=Stack pane;state=2099196;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=2099196;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=237|dock_size(2,0,0)=237|dock_size(3,0,0)=156|")
+#endif
+#endif
+
+enum
+{
+    MENU_ID_EXECUTE = 10001,            // Execute command entered by user
+
+    MENU_ID_TOGGLE_BREAK,               // Set/Unset breakpoint
+    MENU_ID_CLEAR_ALL_BREAK,            // Clear all breakpoints
+    MENU_ID_CONTINUE,                   // Continue
+    MENU_ID_STEP_OVER,                  // Step over    
+    MENU_ID_STEP_INTO,                  // Step into
+    MENU_ID_STOP,                       // Stop debugging
+
+    MENU_ID_SPAWN_DEBUGGER,             // Spawn a separate debugger process
+    MENU_ID_NOTICE_RECEIVED,            // NOTICE received from server
+    WINDOW_ID_STACK,                    // Tree-control window
+    WINDOW_ID_CONSOLE,                  // Console window
+    WINDOW_ID_TABS,                     // Tab window
+    WINDOW_ID_BREAKPOINTS,              // Breakpoints window
+    WINDOW_ID_RESULT_GRID,              // Results window
+    WINDOW_ID_COMMAND,                  // Command window
+    SOCKET_ID_DEBUG,                    // Debugger Socket ID
+
+    MENU_ID_VIEW_TOOLBAR,               // View menu options
+    MENU_ID_VIEW_STACKPANE,
+    MENU_ID_VIEW_OUTPUTPANE,
+    MENU_ID_VIEW_DEFAULTVIEW,
+
+    RESULT_ID_ATTACH_TO_PORT,           // Debugger - attach to port completed
+    RESULT_ID_BREAKPOINT,               // Debugger - breakpoint reached
+    RESULT_ID_GET_VARS,                 // Debugger - variable list complete
+    RESULT_ID_GET_STACK,                // Debugger - stack trace complete
+    RESULT_ID_GET_BREAKPOINTS,          // Debugger - breakpoint list complete
+    RESULT_ID_GET_SOURCE,               // Debugger - source code listing complete
+    RESULT_ID_NEW_BREAKPOINT,           // Debugger - set breakpoint complete
+    RESULT_ID_NEW_BREAKPOINT_WAIT,      // Debugger - set breakpoint complete, wait for target progress
+    RESULT_ID_DEL_BREAKPOINT,           // Debugger - drop breakpoint complete
+    RESULT_ID_DEPOSIT_VALUE,            // Debugger - deposit value complete
+    RESULT_ID_ABORT_TARGET,             // Debugger - abort target (cancel function)
+    RESULT_ID_ADD_BREAKPOINT,           // Debugger - target info received, now set a breakpoint
+    RESULT_ID_LISTENER_CREATED,         // Debugger - global listener created
+    RESULT_ID_TARGET_READY,             // Debugger - target session attached
+    RESULT_ID_LAST_BREAKPOINT,          // Debugger - last breakpoint created
+
+    RESULT_ID_DIRECT_TARGET_COMPLETE,   // DirectDebug - target function complete
+
+    ID_DEBUG_INITIALIZER,               // Debugger - debug package initializer? checkbox
+};
+
+class ctlResultGrid;
+class ctlVarWindow;
+class ctlCodeWindow;
+class dlgDirectDbg;
+class wxSizeReportCtrl;
+
+class frmDebugger : public pgFrame
+{    
+    DECLARE_CLASS( frmDebugger )
+
+  public:
+    frmDebugger(frmMain *parent, const wxString &title);
+    virtual ~frmDebugger();
+
+    dlgDirectDbg   *addDirectDbg( const dbgConnProp & connProp );       // Create a new direct-debugging window
+    ctlCodeWindow  *addDebug( const dbgConnProp & props );              // Create a new debugger window
+    wxStatusBar   *getStatusBar() { return( m_statusBar ); }            // Returns pointer to the status bar
+
+    wxMenuBar     *m_menuBar;       // Menu bar
+    ctlMenuToolbar     *m_toolBar;       // Frames' toolbar
+    wxMenu        *m_viewMenu;      // View menu (can be modified by wxCodeWindow)
+    wxMenu        *m_debugMenu;     // Debug menu (can be modified by wxCodeWindow)
+
+    wxAuiManager manager;
+    ctlCodeWindow   *m_standaloneDebugger;      // Standalone debugger window
+    dlgDirectDbg    *m_standaloneDirectDbg;     // Standalone direct debugger
+
+  private:
+    wxStatusBar    *m_statusBar;    // Frame's status bar
+
+    wxMenuBar    *setupMenuBar( void );
+    ctlMenuToolbar    *setupToolBar( void );
+    wxStatusBar  *setupStatusBar( void );
+
+    frmMain *m_parent;
+
+    DECLARE_EVENT_TABLE()
+
+    void OnExecute( wxCommandEvent & event );
+    void OnDebugCommand( wxCommandEvent & event );
+    void OnSelectFrame( wxCommandEvent & event );
+    void OnMarginClick( wxStyledTextEvent & event );    // Set/clear breakpoint on margin click
+    void OnPositionStc( wxStyledTextEvent & event ); 
+    void OnVarChange( wxGridEvent & event ); 
+    void OnClose( wxCloseEvent & event );
+    void OnExit( wxCommandEvent & event );
+	void OnSize( wxSizeEvent & event );
+    void OnEraseBackground(wxEraseEvent& event);
+    void OnHelp(wxCommandEvent& event);
+    void OnContents(wxCommandEvent& event);
+
+    void OnToggleToolBar(wxCommandEvent& event);
+    void OnToggleStackPane(wxCommandEvent& event);
+    void OnToggleOutputPane(wxCommandEvent& event);
+    void OnAuiUpdate(wxAuiManagerEvent& event);
+    void OnDefaultView(wxCommandEvent& event);
+
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlStackWindow.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlStackWindow.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlStackWindow.h (revision 8187)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlStackWindow.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+//	class ctlStackWindow
+//
+//	This class implements the window that displays the current call stack at 
+//  bottom of the debugger window.  When we create a ctlStackWindow, the parent
+//	is a ctlTabWindow (the ctlStackWindow becomes a tab in a tab control).
+//
+//	It is a simple grid control - the grid contains two columns:
+//		the RowLabel column displays the stack level 
+//		column 0 displays the function name, line number and argument list
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLSTACKWINDOW_H
+#define CTLSTACKWINDOW_H
+
+#include <wx/grid.h>
+#include <wx/laywin.h>
+#include <wx/listbox.h>
+
+class ctlStackWindow : public wxListBox
+{
+    DECLARE_CLASS( ctlVarWindow )
+
+public:
+
+	ctlStackWindow(wxWindow *parent, wxWindowID id, const wxPoint & pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLIP_CHILDREN | wxSW_3D, const wxString& name = wxT( "stackWindow" ));
+	void clear();											// Remove all frames from the stack trace
+	void setStack(const wxArrayString &stack);			// Add an array of frames to the stack trace 
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlTabWindow.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlTabWindow.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlTabWindow.h (revision 8187)
@@ -0,0 +1,64 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:	$Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlTabWindow.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+//	class ctlTabWindow
+//
+//	The ctlTabWindow class implements the tab control that displays at the
+//	bottom of the debugger window.  
+//
+//	A ctlTabWindow object holds a notebook control, a result window (a window
+//  that displays the result set generated by a query), and a varWindow (a
+//  window that displays the local variables when debugging a PL function).
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLTABWINDOW_H
+#define CTLTABWINDOW_H
+
+#include <wx/notebook.h>
+
+#include "debugger/ctlVarWindow.h"
+#include "debugger/ctlMessageWindow.h"
+#include "debugger/ctlStackWindow.h"
+#include "debugger/ctlResultGrid.h"
+
+WX_DECLARE_HASH_MAP( int, int, wxIntegerHash, wxIntegerEqual, wsTabHash );
+
+class ctlTabWindow : public wxNotebook
+{
+	DECLARE_CLASS( ctlTabWindow )
+
+  public:
+
+	ctlTabWindow(wxWindow *parent, wxWindowID id, const wxPoint & pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLIP_CHILDREN | wxSW_3D, const wxString& name = wxT( "layoutWindow" ));
+
+	ctlVarWindow	*getVarWindow( bool create = true );		// Returns a pointer to the local-variables window (creates it if requested)
+	ctlVarWindow	*getPkgVarWindow( bool create = true );	// Returns a pointer to the package-variables window (creates it if requested)
+	ctlVarWindow	*getParamWindow( bool create = true );		// Returns a pointer to the parameters window (creates it if requested)
+
+	ctlResultGrid	*getResultWindow( void );					// Returns a pointer to the result window (creates it if necessary)
+	ctlStackWindow	*getStackWindow( void );					// Returns a pointer to the stack-trace window (creates it if necessary)
+	ctlMessageWindow *getMessageWindow( void );					// Returns a pointer to the DBMS messages window (creates it if necessary)
+	void	selectTab( wxWindowID id );
+
+  private:
+	ctlResultGrid	*m_resultWindow;	// Displays the result set from a query
+	ctlVarWindow	*m_varWindow;		// Displays the local variables when debugging a PL function
+	ctlVarWindow	*m_pkgVarWindow;	// Displays the package variables when debugging a PL function
+	ctlStackWindow	*m_stackWindow;		// Displays the current call stack
+	ctlVarWindow	*m_paramWindow;		// Displays the parameters when debugging a PL function
+	ctlMessageWindow	*m_messageWindow;	// Displays the DBMS messages when debugging a PL function
+
+	wsTabHash	*m_tabMap;		// Map window ID's to tab numbers;
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgDbResult.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgDbResult.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgDbResult.h (revision 8187)
@@ -0,0 +1,47 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dbgDbResult.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// class dbgDbResult
+//
+//	This class is used to convert a PGresult (a query result set) into a wxEvent
+//  We create a dbgDbResult object whenever a result set arrives from the server
+//  and then we send that object (which is really a wxEvent) through the normal
+//  wxWidgets event handler mechanism.
+//
+//  The arrival of a result set thus becomes a wxEvent.  We create dbgDbResult 
+//  objects in dbgPgThread.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef DBGDBRESULT_H
+#define DBGDBRESULT_H
+
+#include <libpq-fe.h>
+
+BEGIN_DECLARE_EVENT_TYPES()
+    DECLARE_EVENT_TYPE( dbgDBRESULT, wxID_HIGHEST+1 )
+END_DECLARE_EVENT_TYPES()
+
+class dbgDbResult : public wxEvent
+{
+
+public:
+	dbgDbResult( PGresult * result ) : wxEvent( 0, dbgDBRESULT ), m_result( result ) { }
+
+	wxEvent  * Clone( void ) const { return( new dbgDbResult( *this )); }
+	PGresult * getResult( void )   { return( m_result ); }
+
+private:
+	PGresult	*m_result;
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgPgConn.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgPgConn.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgPgConn.h (revision 8187)
@@ -0,0 +1,97 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dbgPgConn.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// class dbgPgConn
+//
+//    A dbgPgConn object encapsulates the connection to a PostgreSQL server.  This
+//  class is a wrapper around a Pgconn that provides a convenient constructor 
+//  and a few member functions.  
+//
+//    This class doesn't do much - instead, the real work happens in a dbgPgThread
+//  (a separate thread) that initiates commands and processes result sets.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef DBGPGCONN_H
+#define DBGPGCONN_H
+
+#include <libpq-fe.h>
+
+#include "debugger/frmDebugger.h"
+#include "debugger/dbgPgThread.h"
+#include "debugger/dbgConnProp.h"
+
+enum DebuggerApiVersions
+{
+    DEBUGGER_UNKNOWN_API = 0,
+    DEBUGGER_V1_API = 1,
+    DEBUGGER_V2_API = 2,
+    DEBUGGER_V3_API = 3
+};
+
+class dbgPgParams 
+{
+public:
+    int nParams;
+    Oid *paramTypes;
+    char **paramValues;
+    int *paramModes;
+};
+
+class dbgPgConn 
+{
+  public:
+
+    dbgPgConn( frmDebugger *frame,
+              const wxString &server   = wxT( "" ), 
+              const wxString &database = wxT( "" ), 
+              const wxString &username = wxT( "" ), 
+              const wxString &password = wxT( "" ), 
+              const wxString &port     = wxT( "5432" ), 
+              int sslmode               = 0 );
+
+    dbgPgConn( frmDebugger *frame, const dbgConnProp & props, bool startThread = true );
+
+    ~dbgPgConn();
+
+    bool BackendMinimumVersion(int major, int minor);
+    bool EdbMinimumVersion(int major, int minor);
+    bool GetIsEdb();
+    bool GetIsGreenplum();
+    DebuggerApiVersions DebuggerApiVersion();
+    wxString GetVersionString();
+    bool isConnected() const;               // Returns true if the connection attempt succeeded
+    const wxString  getName() const;        // Returns human-friendly name for this connection
+    const wxString  getHost() const;        // Returns the host-name (or IP address) for this connection
+    const wxString  getDatabase() const;    // Returns the name of the database that we're connected to
+    PGconn *getConnection();                // Returns the libpq connection handle
+    void Close();                           // Close this connection
+    void Cancel();                          // Cancel any ongoing queries
+
+    void startCommand( const wxString &command, wxEvtHandler * caller, wxEventType eventType = wxEVT_NULL, dbgPgParams *params = NULL );    // Starts executing a command    
+    void setNoticeHandler( PQnoticeProcessor handler, void * arg ); // Registers a NOTICE handler
+    PGresult *waitForCommand( const wxString &command );            // Starts a command and waits for completion
+
+  private:
+
+    void Init( const wxString &server, const wxString &database, const wxString &userName, const wxString &password, const wxString &port, int sslmode, bool startThread );
+
+    PGconn *m_pgConn;               // libpq connection handler
+    dbgPgThread *m_workerThread;    // Worker thread (this thread interacts with the server)
+    frmDebugger *m_frame;
+    int m_minorVersion, m_majorVersion;
+    bool m_isEdb;
+    bool m_isGreenplum;
+    DebuggerApiVersions m_debuggerApiVersion;
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgConst.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgConst.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgConst.h (revision 8187)
@@ -0,0 +1,33 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dbgConst.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Constants and enumerator Identifiers for the entire debugger
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef DBGCONST_H
+#define DBGCONST_H
+
+const int 	ID_BTNNEXT	   = 1800;
+const int  	ID_GRDFUNCARGS = 1810;
+const int  	ID_TXTMESSAGE  = 1820;
+const int  	ID_TIMER	   = 1830;
+const int  	ID_BTNCANCEL   = 1840;
+
+const int  	ID_PARAMGRID   = 1000;
+const int  	ID_VARGRID	   = 1001;
+const int 	ID_MSG_PAGE	   = 1002;
+const int	ID_PKGVARGRID  = 1003;
+
+#endif
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/module.mk
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/module.mk (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/module.mk (revision 8187)
@@ -0,0 +1,34 @@
+#######################################################################
+#
+# pgAdmin III - PostgreSQL Tools
+# $Id$
+# Copyright (C) 2002 - 2010, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# module.mk - pgadmin/debugger/include/ Makefile fragment
+#
+#######################################################################
+
+pgadmin3_SOURCES += \
+	$(srcdir)/include/debugger/ctlCodeWindow.h \
+	$(srcdir)/include/debugger/ctlMessageWindow.h \
+	$(srcdir)/include/debugger/ctlResultGrid.h \
+	$(srcdir)/include/debugger/ctlStackWindow.h \
+	$(srcdir)/include/debugger/ctlTabWindow.h \
+	$(srcdir)/include/debugger/ctlVarWindow.h \
+	$(srcdir)/include/debugger/dbgBreakPoint.h \
+	$(srcdir)/include/debugger/dbgConnProp.h \
+	$(srcdir)/include/debugger/dbgConst.h \
+	$(srcdir)/include/debugger/dbgDbResult.h \
+	$(srcdir)/include/debugger/dbgPgConn.h \
+	$(srcdir)/include/debugger/dbgPgThread.h \
+ 	$(srcdir)/include/debugger/dbgResultset.h \
+	$(srcdir)/include/debugger/dbgTargetInfo.h \
+ 	$(srcdir)/include/debugger/debugger.h \
+	$(srcdir)/include/debugger/dlgDirectDbg.h \
+	$(srcdir)/include/debugger/frmDebugger.h
+
+EXTRA_DIST += \
+	$(srcdir)/include/debugger/module.mk
+
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlCodeWindow.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlCodeWindow.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlCodeWindow.h (revision 8187)
@@ -0,0 +1,219 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlCodeWindow.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// class ctlCodeWindow
+//
+//	This class implements the debugger window.  The constructor expects a string
+//  that contains a TCP port number - the constructor connects to the debugger
+//  server waiting at that port.  
+//
+//  A ctlCodeWindow object creates (and manages) a toolbar and handles toolbar
+//  and keystroke messages. The input messages are treated as debugger commands.
+//
+//	The m_view member is a ctlSQLBox that displays the code for the PL
+//  function that you're debugging.  The m_hilite member tracks the current 
+//  line (that is, the line about to execute).  We use hilight the current line.
+//  If m_hilite is -1, there is no current line.  
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLCODEWINDOW_H
+#define CTLCODEWINDOW_H
+
+#include <wx/progdlg.h>
+
+#include "ctl/ctlSQLBox.h"
+#include "debugger/frmDebugger.h"
+#include "debugger/dbgBreakPoint.h"
+#include "debugger/ctlTabWindow.h"
+
+class dbgPgConn;
+class dbgResultset;
+class dbgConnProp;
+class wsWaitingDialog;
+class ctlStackWindow;
+class ctlMessageWindow;
+class ctlVarWindow;
+class ctlResultGrid;
+
+
+#define MARKERINDEX_TO_MARKERMASK( MI ) ( 1 << MI )
+
+class wsCodeCache
+{
+public:
+	wsCodeCache() {}
+	wsCodeCache(const wxString &packageOID, const wxString &funcOID, const wxString &source, const wxString &signature);
+
+	const wxString &getSource()   { return( m_sourceCode ); }
+	const wxString &getSignature(){ return( m_signature ); }
+
+private:
+	wxString	m_packageOID;	// Package OID
+	wxString	m_funcOID;	// Function OID
+	wxString	m_sourceCode;	// Source code for this function
+    wxString    m_signature; // Function sig
+
+};
+
+class ctlCodeWindow : public pgFrame  
+{
+    DECLARE_CLASS( ctlCodeWindow )
+
+ public:
+	ctlCodeWindow( frmDebugger *parent, wxWindowID id, const dbgConnProp & connProps );
+    
+    void OnClose(wxCloseEvent& event);
+	void startLocalDebugging();	 	                    // Start debugging 
+	void resumeLocalDebugging();		                // Start debugging, already attached to the proxy
+	void startGlobalDebugging(); 		                // Start debugging 
+	void OnCommand( wxCommandEvent & event );		    // Handle menu/toolbar commands
+    void OnSelectFrame( wxCommandEvent & event );	    // Select a different stack frame
+    void OnMarginClick( wxStyledTextEvent & event );    // Set/clear breakpoint on margin click
+    void OnPositionStc( wxStyledTextEvent & event );    // update the status bar text
+    void OnVarChange( wxGridEvent & event );		    // User changed a variable
+	void processResult( wxString & result );		    // Handle a message from the debugger server
+	void OnNoticeReceived( wxCommandEvent & event );    // NOTICE received from server
+	void OnResultSet( PGresult * result );			    // Result set received from server
+	void disableTools();			                    // Disable toolbar tools
+	void enableTools();		 	                        // Enable toolbar tools
+
+	frmDebugger *GetFrame() { return m_parent; }
+
+    bool	m_targetAborted;		    // Have we aborted the target? (true) or are we waiting for a breakpoint? (false)
+    bool	m_targetComplete;		    // Is the target complete? (true) or is it still running (or aborted)? (false)
+	dbgBreakPointList & getBreakpointList();
+
+	WX_DECLARE_STRING_HASH_MAP( wsCodeCache, sourceHash );
+
+ private:
+
+    bool isBreakpoint(int lineNumber) { return (m_view->MarkerGet( lineNumber ) & MARKERINDEX_TO_MARKERMASK( MARKER_BREAKPOINT ) ? true : false); }
+	void clearBreakpoint( int lineNumber, bool requestUpdate );
+	void setBreakpoint( int lineNumber );
+
+	ctlStackWindow   *getStackWindow()   { return( m_stackWindow ); }
+	ctlMessageWindow *getMessageWindow() { return( m_tabWindow->getMessageWindow()); }
+
+	ctlVarWindow     *getVarWindow( bool create )     { return( m_tabWindow->getVarWindow( create )); }
+	ctlVarWindow     *getParamWindow( bool create )   { return( m_tabWindow->getParamWindow( create )); }
+	ctlVarWindow	 *getPkgVarWindow( bool create )  { return( m_tabWindow->getPkgVarWindow( create )); } 
+	ctlResultGrid    *getResultWindow()               { return( m_tabWindow->getResultWindow()); }
+
+	void	setTools(bool enable);		            // Enable/disable debugger options
+	void	OnIdle( wxIdleEvent & event );			// Idle processor
+	void	OnTimer( wxTimerEvent & event );		// Clock tick
+
+	int		getLineNo( );				                    // Compute line number for current cursor position
+	void 	closeConnection();								// Closes proxy connection
+	void	updateUI( dbgResultset & breakpoint );		    // Update the lazy parts of the UI
+	void	updateSourceCode( dbgResultset & breakpoint );	// Update the source code window
+	bool	connectionLost( dbgResultset & resultSet );	    // Returns true if proxy lost it's connection
+	bool	gotFatalError( dbgResultset & resultSet );	    // Returns true if result set indicates a fatal error has occurred
+	void 	popupError(dbgResultset &resultSet);
+	void	addBreakpoint( dbgBreakPoint * breakpoint, wxEventType nextStep );
+
+	void	ResultPortAttach( wxCommandEvent & event );			// Attach to debugger port complete
+	void	ResultBreakpoint( wxCommandEvent & event );			// Breakpoint encountered
+	void	ResultVarList( wxCommandEvent & event );			// Variable list complete
+	void	ResultStack( wxCommandEvent & event );				// Stack trace retrieval complete
+	void	ResultSource( wxCommandEvent & event );				// Source code retrieval complete
+	void 	ResultBreakpoints( wxCommandEvent & event );		// Breakpoint list retrieval complete
+	void	ResultNewBreakpoint( wxCommandEvent & event );		// Set Breakpoint command complete
+	void	ResultNewBreakpointWait( wxCommandEvent & event );	// Set Breakpoint command complete, wait for a target process
+	void	ResultDeletedBreakpoint( wxCommandEvent & event );	// Drop Breakpoint command complete
+	void	ResultDepositValue( wxCommandEvent & event );		// Deposit Value command complete
+	void	ResultAbortTarget( wxCommandEvent & event );		// Abort target command complete
+	void	ResultAddBreakpoint( wxCommandEvent & event );		// getTargetInfo() complete, add a breakpoint
+	void	ResultListenerCreated( wxCommandEvent & event );	// Global listener created, ready to wait for a target
+	void	ResultTargetReady( wxCommandEvent & event );		// Target session attached, ready to wait for a breakpoint
+	void	ResultLastBreakpoint( wxCommandEvent & event );		// Adding last breakpoint 
+
+	dbgPgConn	*m_dbgConn;	    // Network connection to debugger server
+	wxString	m_debugPort;	// Port at which debugger server is listening
+
+	frmDebugger 	*m_parent;		// Parent window
+	int	m_currentLineNumber;	// Current line number
+
+	ctlSQLBox       *m_view;	    // Window that displays function source code
+	ctlStackWindow	*m_stackWindow;	// Stack Window
+	ctlTabWindow	*m_tabWindow;	    // Tab Window
+
+	typedef enum
+	{
+		SESSION_TYPE_UNKNOWN,	// Session could be in-context or direct
+		SESSION_TYPE_INCONTEXT,	// Session is configured for in-context debugging
+		SESSION_TYPE_DIRECT		// Session is configured for direct debugging
+	} eSessionType;
+
+	eSessionType	m_sessionType;		// Debugging mode is in-context or direct?
+	bool	m_updateVars;			    // Update variable window in next idle period?
+	bool    m_updateStack;			    // Update stack window in next idle period?
+	bool	m_updateBreakpoints;	    // Update breakpoints in next idle period?
+	dbgBreakPointList    m_breakpoints;	// List of initial breakpoints to create
+
+	enum
+	{
+		MARKER_CURRENT    = 0x02,		// Current line marker
+		MARKER_CURRENT_BG = 0x04,		// Current line marker - background hilight
+		MARKER_BREAKPOINT = 0x01,		// Breakpoint marker
+	};
+
+	sourceHash	m_sourceCodeMap;
+
+	wxString	m_focusPackageOid;	    // Which package has the debug focus?
+	wxString	m_focusFuncOid;		    // Which function has the debug focus?
+	wxString	m_displayedFuncOid;	    // Which function are we currently displaying? (function OID component)
+	wxString	m_displayedPackageOid;	// Which function are we currently displaying? (package OID component)
+	wxString	m_sessionHandle;	    // Handle to proxy's server session
+	wxString	m_targetName;		    // User-friendly target name
+
+	wxProgressDialog *m_progressBar;	// "Waiting for target" dialog
+	wxTimer	m_timer;
+	bool	findSourceInCache( const wxString &packageOID, const wxString &funcOID);
+	void	getSource(const wxString &packageOID, const wxString &funcOID);
+	void	cacheSource(const wxString &packageOID, const wxString &funcOID, const wxString &sourceCode, const wxString &signature);
+	void	displaySource(const wxString &packageOID, const wxString &funcID);
+	void	unhilightCurrentLine();
+	void	launchWaitingDialog();
+
+	void	clearAllBreakpoints();
+	void	clearBreakpointMarkers();
+	void	stopDebugging();
+
+	static wxString	m_commandAttach;
+	static wxString m_commandWaitForBreakpoint;
+	static wxString m_commandGetVars;
+	static wxString m_commandGetStack;
+	static wxString m_commandGetBreakpoints;
+	static wxString m_commandGetSourceV1;
+    static wxString m_commandGetSourceV2;
+	static wxString m_commandStepOver;
+	static wxString m_commandStepInto;
+	static wxString m_commandContinue;
+	static wxString m_commandSetBreakpointV1;
+	static wxString m_commandSetBreakpointV2;
+	static wxString m_commandClearBreakpointV1;
+    static wxString m_commandClearBreakpointV2;
+	static wxString m_commandSelectFrame;
+	static wxString m_commandDepositValue;
+	static wxString m_commandAbortTarget;
+	static wxString m_commandGetTargetInfo;
+	static wxString m_commandAddBreakpointEDB;
+    static wxString m_commandAddBreakpointPG;
+	static wxString m_commandCreateListener;
+	static wxString m_commandWaitForTarget;
+
+    DECLARE_EVENT_TABLE()
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgResultset.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgResultset.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgResultset.h (revision 8187)
@@ -0,0 +1,49 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dbgResultset.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// class dbgResultset
+//
+//	A dbgResultset object encapsulates a result set produced by executing a 
+//  database command. This class is a wrapper around a PGresult handle that 
+//	provides a few convenient member functions.  
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef DBGRESULTSET_H
+#define DBGRESULTSET_H
+
+#include <libpq-fe.h>
+
+class dbgResultset
+{
+public:
+	dbgResultset( PGresult * handle );
+
+	const char	*getRawErrorMessage();	// Return error message as a char *
+	const wxString getErrorMessage();	// Return error message as a wxString
+	const wxString getString(int column, int row = 0);
+	const wxString getString(const wxString &columnName, int row = 0);
+	long	getLong(int column, int row = 0);
+	long	getLong(const wxString &columnName, int row = 0);
+	bool	getBool(int column, int row = 0);
+	bool	getBool(const wxString &columnName, int row = 0);
+	int	getRowCount() { return(PQntuples( m_handle)); }
+    bool	columnExists(const wxString &columnname);
+
+	ExecStatusType getCommandStatus();
+
+private:
+
+	PGresult *m_handle;
+
+};
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgBreakPoint.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgBreakPoint.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgBreakPoint.h (revision 8187)
@@ -0,0 +1,47 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dbgBreakPoint.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// class dbgBreakPoint
+//
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef DBGBREAKPOINT_H
+#define DBGBREAKPOINT_H
+
+class dbgBreakPoint
+{
+public:
+
+	enum eTargetType
+	{
+		TRIGGER,
+		FUNCTION,
+		PROCEDURE,
+		OID
+	};
+
+	dbgBreakPoint(eTargetType targetType, const wxString &target, const wxString &process ): m_targetType(targetType), m_target(target), m_targetProcess(process) {}
+
+	eTargetType   getTargetType() 	 { return( m_targetType ); }
+	wxString    & getTarget() 	 { return( m_target ); }
+	wxString    & getTargetProcess() { return( m_targetProcess ); }
+private:
+	eTargetType 	m_targetType;
+	wxString	m_target;
+	wxString	m_targetProcess;
+
+};
+
+WX_DECLARE_LIST( dbgBreakPoint, dbgBreakPointList );
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgConnProp.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgConnProp.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgConnProp.h (revision 8187)
@@ -0,0 +1,37 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dbgConnProp.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// class dbgConnProp
+//
+//  dbgConnProp object is used to hold a set of connection properties, that is.
+//  it's a collection of all of the information that we need in order to connect
+//  to a server.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef DBGCONNPROP_H
+#define DBGCONNPROP_H
+
+class dbgConnProp
+{
+
+public:
+	wxString	m_host;			// Host name (or IP-address)
+	wxString	m_database;		// Database name
+	wxString	m_userName;		// User name	
+	wxString	m_password;		// Password
+	wxString	m_port;			// Port number
+	wxString	m_debugPort;	// Port number for debugger connection
+	int		    m_sslMode;		// SSL Mode
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgPgThread.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgPgThread.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgPgThread.h (revision 8187)
@@ -0,0 +1,83 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dbgPgThread.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// class dbgPgThread
+//
+//    A dbgPgThread object encapsulates a separate execution thread that interacts
+//  with a PostgreSQL server.  We use a separate thread to keep the main thread
+//  (and thus the user interface) responsive while we're waiting for the server.
+//
+//    The startCommand() member function initiates a new command - this function 
+//  is called by the UI thread. It stores the command text (and the caller) in 
+//  the dbgPgThread object and then awakens the thread.  The dbgPgThread then sends
+//  the command string to the server and waits for a reply. When the reply (a 
+//  result set) arrives from the server, the Entry() member function converts
+//  the result set (a Pgresult) into a wxEvent (specifically, a dbgDbResult) and
+//  posts that event to the UI thread's event queue.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef DBGPGTHREAD_H
+#define DBGPGTHREAD_H
+
+// #include "debugger/dbgPgConn.h"
+class dbgPgConn;
+class dbgPgParams;
+
+class dbgPgThreadCommand
+{
+public:
+    dbgPgThreadCommand( const wxString &command, wxEvtHandler * caller, wxEventType eventType = wxEVT_NULL, dbgPgParams *params = NULL ) : m_command( command ), m_caller( caller ), m_eventType( eventType ), m_params( params ) {};
+
+    wxString    &getCommand()   { return m_command; }
+    dbgPgParams *getParams()    { return m_params; }
+
+    wxEvtHandler    *getCaller()    { return( m_caller ); }
+    wxEventType    getEventType() { return( m_eventType ); }
+
+private:
+    wxString    m_command;    // Text of the command we're supposed to execute
+    wxEvtHandler    *m_caller;    // Event handler that we post results to
+    wxEventType    m_eventType;    // Event to report when result set arrives
+    dbgPgParams *m_params;
+};
+
+WX_DECLARE_LIST( dbgPgThreadCommand, ThreadCommandList );
+
+class dbgPgThread : public wxThread
+{
+
+public:
+    dbgPgThread(dbgPgConn &owner);
+
+    virtual void * Entry();
+    void startCommand( const wxString &command, wxEvtHandler * caller, wxEventType eventType = wxEVT_NULL, dbgPgParams *params = NULL );
+    void Die();
+	
+private:
+
+    static void noticeHandler( void * arg, const char * message );
+
+    dbgPgThreadCommand * getNextCommand();    // Grab next command from queue 
+
+    dbgPgConn &m_owner;        // Connection to the PostgreSQL server
+    wxSemaphore m_queueCounter;        // Number of entries in queue (thread synchronizer)
+    wxMutex m_queueMutex;        // Mutex to serialize access to m_commandQueue
+    ThreadCommandList m_commandQueue;        // Queue of pending commands
+
+    dbgPgThreadCommand *m_currentCommand;    // Currently executing command
+    wxMBConv *conv;
+    long run;
+	bool die;
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dlgDirectDbg.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dlgDirectDbg.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dlgDirectDbg.h (revision 8187)
@@ -0,0 +1,98 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dlgDirectDbg.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// class dlgDirectDbg
+//
+//	This class implements 'direct-debugging'. In direct-debugging, the user 
+//  provides a function signature, procedure signature, or OID on the command
+//  line (this identifies the debug target).  We query the server for the 
+//  names, types, and in/out modes for each target parameter and then prompt
+//	the user to enter a value for each of the IN (and IN/OUT) parameters.
+//
+//  When the user fills in the parameter values and clicks OK, we set a 
+//  breakpoint at the target and then execute a SELECT statement or an 
+//  EXEC statement that invokes the target (with the parameter values 
+//  provided by the user).
+//
+//  A dlgDirectDbg object is typically a child of the frmDebugger object
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef DBGDIRECT_H
+#define DBGDIRECT_H
+
+#include "dlg/dlgClasses.h"
+#include "debugger/dbgBreakPoint.h"
+#include "debugger/dbgConnProp.h"
+#include "debugger/frmDebugger.h"
+
+class dbgTargetInfo;
+class dbgPgConn;
+class ctlCodeWindow;
+
+class dlgDirectDbg : public pgDialog
+{
+	DECLARE_CLASS( dlgDirectDbg )
+
+public:
+
+	dlgDirectDbg( frmDebugger *parent, wxWindowID id, const dbgConnProp & connProp );
+	dbgBreakPointList & getBreakpointList();
+    void setupParamWindow();
+	bool startDebugging();
+    bool GetCancelled() { return m_cancelled; };
+
+private:
+
+	enum
+	{
+		COL_NAME = 0,	// Column 0 contains the variable name
+		COL_TYPE,	// This column contains the variable type
+		COL_VALUE	// This column contains the variable value
+	};
+
+	wxString	m_target;	// Target name (function/procedure signature or OID)
+	bool		m_isFunc;
+	const dbgConnProp &m_connProp;	// Connection properties (used to connect to the server)
+	dbgTargetInfo     *m_targetInfo;	// Detailed information about the target (like argument types, name, ...)
+	dbgPgConn         *m_conn;		// The connection to the server
+	ctlCodeWindow     *m_codeWindow;		// A pointer to the debugger window that we'll create
+	dbgBreakPointList m_breakpoints;		// List of initial breakpoints to create
+	frmDebugger		 *m_parent;
+    bool m_cancelled;
+
+	bool loadTargetInfo( const wxString &target, const dbgConnProp & connProp, char targetType );
+	void populateParamGrid();
+	void OnOk( wxCommandEvent & event );
+	void OnCancel( wxCommandEvent & event );
+	void OnClose( wxCloseEvent & event );
+	void OnTargetComplete( wxCommandEvent & event );
+	void OnDebug( wxCommandEvent & event );
+	void OnNoticeReceived( wxCommandEvent & event );
+	bool activateDebugger( );
+
+	void saveSettings();
+	void loadSettings();
+	void setBreakpoint( long pkgOid, long funcOid );
+	void invokeTarget();
+	void invokeTargetCallable();
+	void invokeTargetStatement();
+
+#ifdef __WXMSW__
+    void InitLibpq();
+#endif
+
+    DECLARE_EVENT_TABLE()
+
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlMessageWindow.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlMessageWindow.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlMessageWindow.h (revision 8187)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlMessageWindow.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+//	class ctlMessageWindow
+//
+//	This class implements the window that displays DBMS messages at the 
+//  bottom of the debugger window.  When we create a ctlMessageWindow, the parent
+//	is a ctlTabWindow (the ctlMessageWindow becomes a tab in a tab control).
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLMESSAGEWINDOW_H
+#define CTLMESSAGEWINDOW_H
+
+class ctlMessageWindow : public wxTextCtrl
+{
+    DECLARE_CLASS( ctlMessageWindow )
+
+public:
+	ctlMessageWindow( wxWindow * parent, wxWindowID id );
+
+	void	addMessage( wxString message );	// Add a message to the window
+	void	delMessage( const char * name = NULL );								    // Remove a message from the window
+	wxString	getMessage( int row );
+
+private:
+
+    typedef struct
+    {
+	int	m_row;		// Row number for this variable/grid cell
+    } gridCell;
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgTargetInfo.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgTargetInfo.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/dbgTargetInfo.h (revision 8187)
@@ -0,0 +1,114 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dbgTargetInfo.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+#ifndef DBGTARGETINFO_H
+#define DBGTARGETINFO_H
+
+////////////////////////////////////////////////////////////////////////////////
+// class wsArgInfo
+//
+//	A wsArgInfo object contains information about a function (or procedure) 
+//  argument.  Inside of each wsArgInfo object, we store the name of the argument,
+//	the argument type, and the argument mode (IN (i), OUT (o), or INOUT (b)).
+//
+//	Once the user has had a chance to enter values for each of the IN and INOUT
+//	arguments, we store those values inside of the corresponding wsArgInfo objects
+
+class wsArgInfo
+{
+public:
+	wsArgInfo( const wxString &argName, const wxString &argType, const wxString &argMode, const wxString &argTypeOid );
+
+	const wxString &getName()    { return m_name; }
+	const wxString &getType()    { return m_type; }
+	const wxString &getMode()    { return m_mode; }
+    const Oid getTypeOid()       { return m_typeOid; }
+  	wxString & getValue()   { return m_value; } // NOTE: non-const, caller may modifiy value
+	const wxString   quoteValue();
+	void  setValue( const wxString &newValue ) { m_value = newValue; }
+
+private:	
+	wxString	m_name;
+	wxString	m_type;
+	wxString	m_mode;
+	wxString	m_value;
+    Oid         m_typeOid;
+};
+
+WX_DECLARE_OBJARRAY(wsArgInfo, wsArgInfoArray);
+
+////////////////////////////////////////////////////////////////////////////////
+// class dbgTargetInfo
+//
+//	This class implements a container that holds information necessary to invoke
+//  a debugger target (a function or procedure).
+//
+//  When the constructor is called, it sends a query to the server to retreive:
+//		the OID of the target,
+//		the name of the target,
+//		the name of the schema in which the target is defined
+//		the name of the language in which the target is defined
+//		the number of arguments expected by the target
+//		the argument names
+//		the argument types
+//		the argument modes (IN, OUT, or INOUT)
+//		the target type (function or procedure)
+//
+//	This class offers a number of (inline) member functions that you can call
+//  to extract the above information after it's been queried from the server.
+
+class dbgPgConn;
+
+class dbgTargetInfo
+{
+public:
+	dbgTargetInfo( const wxString &target, dbgPgConn * conn, char targetType );
+
+	int	getArgInCount() 	{ return( m_argInCount ); }
+	int 	getArgOutCount()   { return( m_argOutCount ); }
+	int 	getArgInOutCount() { return( m_argInOutCount ); }
+	int	getArgCount() 		{ return( m_argInCount + m_argOutCount + m_argInOutCount ); }
+
+	const wxString &getLanguage()      { return( m_language ); }
+	const wxString &getSchema()        { return( m_schema ); }
+	const wxString &getName()          { return( m_name ); }
+	const wxString &getFQName()        { return( m_fqName ); } 
+	const wxString &getReturnType()    { return( m_returnType ); }
+	long	getOid()           { return( m_oid ); }
+	long	getPkgOid()        { return( m_pkgOid ); }
+	long	getPkgInitOid()    { return( m_pkgInitOid ); }
+	bool	getIsFunction()    { return( m_isFunction ); } 
+	bool	getReturnsSet()    { return( m_returnsSet ); } 
+
+	wsArgInfo & operator[]( int index );
+
+private:
+	wxString	m_name;		 // Target name (function or procedure)
+	wxString	m_schema;	 // Schema in which target resides
+	wxString	m_language;	 // Language in which target is defined
+	wxString	m_argNames;	 // Argument names
+	wxString	m_argModes;	 // Argument modes
+	wxString	m_argTypes;	 // Argument types
+	wxString	m_argTypeOids; // Argument type OIDs
+	wxString	m_fqName;	 // Fully-qualified name (schema.package.func or package.func)
+    wxString    m_returnType;// Return type
+	bool	m_isFunction;	 // true->target is a function, false->target is a procedure
+    bool    m_returnsSet;    // Returns a set?
+	int	m_argInCount;	 // Number of IN arguments
+	int	m_argOutCount;	 // Number of OUT arguments
+	int	m_argInOutCount; // Number of INOUT arguments	
+	long	m_oid;		 // Target function/procedure OID
+	long	m_pkgOid;	 // Package in which target defined (if non-zero)
+    long    m_pkgInitOid; // OID of the package initializer function.
+	wsArgInfoArray	m_argInfo;
+
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlVarWindow.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlVarWindow.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlVarWindow.h (revision 8187)
@@ -0,0 +1,78 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlVarWindow.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+//	class ctlVarWindow
+//
+//	This class implements the window that displays PL variable values at the 
+//  bottom of the debugger window.  When we create a ctlVarWindow, the parent
+//	is a ctlTabWindow (the ctlVarWindow becomes a tab in a tab control).
+//
+//	It is a simple grid control - the grid contains three columns:
+//		the RowLabel column displays the name of each variable
+//		column 0 displays the value of each variable
+//		column 1 displays the data type of each variable
+//
+//	Each ctlVarWindow contains a hash map that can locate a grid cell given a
+//  variable name
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLVARWINDOW_H
+#define CTLVARWINDOW_H
+
+#include <wx/hashmap.h>
+#include <wx/hashset.h>
+#include <wx/grid.h>
+
+class ctlVarWindow : public wxGrid
+{
+    DECLARE_CLASS( ctlVarWindow )
+
+public:
+	ctlVarWindow( wxWindow * parent, wxWindowID id );
+
+	void	addVar( wxString name, wxString value, wxString type, bool readOnly );	// Add a variable to the window
+	void	delVar( wxString name = wxEmptyString);								    // Remove a variable from the window
+	wxString	getVarName( int row );
+	wxString	getVarValue( int row );
+
+private:
+
+	// The content of a grid cell is defined by the gridCell structure
+
+    typedef struct
+    {
+	int		m_row;	 // Row number for this variable/grid cell
+	wxString	m_value; // Variable value
+	wxString	m_type;	 // Variable type
+    } gridCell;
+
+	enum
+	{
+		COL_NAME = 0,		// Column 0 contains the variable name
+		COL_TYPE,		// This column contains the variable type
+		COL_VALUE		// This column contains the variable value
+	};
+
+	// The m_cells hash translates variable names into gridCell references
+public:
+    WX_DECLARE_STRING_HASH_MAP( gridCell, wsCellHash );
+	WX_DECLARE_HASH_SET( wxString, wxStringHash, wxStringEqual, wsStringSet );
+
+private:
+	wsStringSet	m_hiddenNames;	// List of hidden variable names
+	wsStringSet	m_hiddenTypes;	// List of hidden variable types
+	wsCellHash	*m_cells;	// name-to-gridCell map
+	wxFont		m_nameFont;	// Font used to display field names
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/debugger.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/debugger.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/debugger.h (revision 8187)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// debugger.h - Debugger factories
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef DEBUGGER_H
+#define DEBUGGER_H
+
+// wxWindows headers
+#include <wx/wx.h>
+
+///////////////////////////////////////////////////
+// Debugger factory
+///////////////////////////////////////////////////
+class debuggerFactory : public actionFactory
+{
+public:
+    debuggerFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+///////////////////////////////////////////////////
+// Breakpoint factory
+///////////////////////////////////////////////////
+class breakpointFactory : public actionFactory
+{
+public:
+    breakpointFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+#endif
+
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlResultGrid.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlResultGrid.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/debugger/ctlResultGrid.h (revision 8187)
@@ -0,0 +1,36 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// ctlResultGrid.h - debugger 
+//
+//////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// class ctlResultGrid
+//
+//	A ctlResultGrid is a grid control that knows how to display that result set
+//	generated by a PostgreSQL query. In the workstation application, a ctlResultGrid
+//	is a child of the notebook owned by a ctlTabWindow.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef CTLRESULTGRID_H
+#define CTLRESULTGRID_H
+
+#include <wx/grid.h>
+
+class ctlResultGrid : public wxGrid
+{
+    DECLARE_CLASS( ctlResultGrid )
+
+public:
+	ctlResultGrid( wxWindow * parent, wxWindowID id );
+
+	void	fillGrid( PGresult * result );	// Copy a result set into the grid
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmMain.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmMain.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmMain.h (revision 8187)
@@ -0,0 +1,286 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmMain.h - The main form
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMMAIN_H
+#define FRMMAIN_H
+
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/listctrl.h>
+#include <wx/notebook.h>
+
+// wxAUI
+#include <wx/aui/aui.h>
+
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+#define FRMMAIN_PERPSECTIVE_VER wxT("$Rev$")
+
+#ifdef __WXMAC__
+#define FRMMAIN_DEFAULT_PERSPECTIVE wxT("layout2|name=objectBrowser;caption=Object browser;state=16779260;dir=4;layer=1;row=0;pos=0;prop=100000;bestw=200;besth=450;minw=100;minh=200;maxw=-1;maxh=-1;floatx=236;floaty=222;floatw=-1;floath=-1|name=listViews;caption=Info pane;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlPane;caption=SQL pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=520;besth=39;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(5,0,0)=18|dock_size(3,0,0)=228|dock_size(1,10,0)=41|dock_size(4,1,0)=233|")
+#else
+#ifdef __WXGTK__
+#define FRMMAIN_DEFAULT_PERSPECTIVE wxT("layout2|name=objectBrowser;caption=Object browser;state=16779260;dir=4;layer=1;row=0;pos=0;prop=100000;bestw=200;besth=450;minw=100;minh=200;maxw=-1;maxh=-1;floatx=236;floaty=222;floatw=-1;floath=-1|name=listViews;caption=Info pane;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlPane;caption=SQL pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=586;besth=44;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(5,0,0)=18|dock_size(3,0,0)=228|dock_size(1,10,0)=41|dock_size(4,1,0)=233|")
+#else
+#define FRMMAIN_DEFAULT_PERSPECTIVE wxT("layout2|name=objectBrowser;caption=Object browser;state=16779260;dir=4;layer=1;row=0;pos=0;prop=100000;bestw=200;besth=450;minw=100;minh=200;maxw=-1;maxh=-1;floatx=236;floaty=222;floatw=-1;floath=-1|name=listViews;caption=Info pane;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlPane;caption=SQL pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=506;besth=39;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(5,0,0)=18|dock_size(3,0,0)=228|dock_size(1,10,0)=41|dock_size(4,1,0)=233|")
+
+#endif
+#endif
+class pgServer;
+class pgServerCollection;
+class ctlSQLBox;
+class ctlTree;
+class dlgProperty;
+class serverCollection;
+
+class propertyFactory;
+class pluginUtilityFactory;
+class ctlMenuButton;
+
+// A plugin utility
+typedef struct PluginUtility {
+    wxString title;
+    wxString command;
+    wxString description;
+    wxString keyfile;
+    wxString platform;
+    wxArrayString server_types;
+    bool database;
+    wxArrayString applies_to;
+    bool set_password;
+} PluginUtility;
+
+// Class declarations
+class frmMain : public pgFrame
+{
+public:
+    frmMain(const wxString& title);
+    ~frmMain();
+    
+    void OnAction(wxCommandEvent &ev);
+    void OnReport(wxCommandEvent &ev);
+    wxString GetHelpPage() const;
+
+    void StartMsg(const wxString& msg);
+    void EndMsg(bool done=true);
+    void SetStatusText(const wxString &msg);
+    void SetCurrentObject(pgObject *data) { currentObject = data; }
+    bool CheckAlive();
+
+    void execSelChange(wxTreeItemId item, bool currentNode);
+    void Refresh(pgObject *data);
+    void ExecDrop(bool cascaded);
+    void ShowObjStatistics(pgObject *data, int sel);
+
+    wxImageList *GetImageList() { return imageList; }
+    ctlTree *GetBrowser() { return browser; }
+    ctlSQLBox *GetSqlPane() { return sqlPane; }
+    ctlListView *GetProperties() { return properties; }
+    ctlListView *GetStatistics();
+    ctlListView *GetStatisticsCtl();
+    ctlListView *GetDependencies();
+    ctlListView *GetDependenciesCtl();
+    ctlListView *GetReferencedBy();
+    ctlListView *GetReferencedByCtl();
+    void SelectStatisticsTab() { listViews->SetSelection(1); };
+    void StoreServers();
+    int ReconnectServer(pgServer *server, bool restore = true);
+    void ReportConnError(pgServer *server);
+    pgServerCollection *GetServerCollection() { return serversObj; }
+    pgServer *ConnectToServer(const wxString& servername, bool restore = false);
+
+    void SetLastPluginUtility(pluginUtilityFactory *pluginFactory) { lastPluginUtility = pluginFactory; }
+    pluginUtilityFactory *GetLastPluginUtility() { return lastPluginUtility; }
+    wxMenu *GetPluginsMenu() { return pluginsMenu; }
+
+    wxString GetCurrentNodePath();
+    bool SetCurrentNode(wxTreeItemId node, const wxString &path);
+
+private:
+    wxAuiManager manager;
+    ctlTree *browser;
+    ctlListView *properties;
+    ctlListView *statistics;
+    ctlListView *dependents, *dependencies;
+    wxNotebook *listViews;
+    ctlSQLBox *sqlPane;
+    wxMenu *newMenu, *debuggingMenu, *reportMenu, *toolsMenu, *pluginsMenu, *viewMenu, 
+          *treeContextMenu, *newContextMenu, *slonyMenu, *scriptingMenu, *viewDataMenu;
+    pgServerCollection *serversObj;
+
+    pluginUtilityFactory *lastPluginUtility;
+    int pluginUtilityCount;
+
+    propertyFactory *propFactory;
+    actionFactory *newMenuFactory;
+    actionFactory *debuggingMenuFactory;
+    actionFactory *reportMenuFactory;
+    actionFactory *scriptingMenuFactory;
+    actionFactory *viewdataMenuFactory;
+
+    wxStopWatch stopwatch;
+    wxString timermsg;
+    long msgLevel;
+
+    wxTreeItemId denyCollapseItem;
+    pgObject *currentObject;
+
+    void OnEraseBackground(wxEraseEvent& event);
+    void OnSize(wxSizeEvent& event);
+    
+    void CreateMenus();
+    void OnContents(wxCommandEvent& event);
+    void OnExit(wxCommandEvent& event);
+    void ViewData(bool filter = false);
+    void OnSaveDefinition(wxCommandEvent& event);
+    void OnToggleSqlPane(wxCommandEvent& event);
+    void OnToggleObjectBrowser(wxCommandEvent& event);
+    void OnToggleToolBar(wxCommandEvent& event);
+    void OnDefaultView(wxCommandEvent& event);
+    void OnAuiUpdate(wxAuiManagerEvent& event);
+    void OnContextMenu(wxCommandEvent& event);
+
+    void OnPageChange(wxNotebookEvent& event);
+    void OnPropSelChanged(wxListEvent& event);
+    void OnPropSelActivated(wxListEvent& event);
+    void OnPropRightClick(wxListEvent& event);
+    void OnTreeSelChanged(wxTreeEvent &event);
+    void OnTreeKeyDown(wxTreeEvent& event);
+    void OnSelActivated(wxTreeEvent& event);
+    void OnSelRightClick(wxTreeEvent& event);
+    void OnCollapse(wxTreeEvent& event);
+    void OnExpand(wxTreeEvent& event);
+    void OnClose(wxCloseEvent& event);
+
+    void OnNew(wxCommandEvent& event);
+    void OnDelete(wxCommandEvent &ev);
+    void OnCopy(wxCommandEvent &ev) { sqlPane->Copy(); };
+
+    void OnCheckAlive(wxCommandEvent& event);
+
+    void OnPositionStc(wxStyledTextEvent& event);
+
+    bool dropSingleObject(pgObject *data, bool updateFinal, bool cascaded);
+    void doPopup(wxWindow *win, wxPoint point, pgObject *object);
+    void setDisplay(pgObject *data, ctlListView *props=0, ctlSQLBox *sqlbox=0);
+    void RetrieveServers();
+    bool reportError(const wxString &error, const wxString &msgToIdentify, const wxString &hint);
+    wxTreeItemId RestoreEnvironment(pgServer *server);
+
+    void GetExpandedChildNodes(wxTreeItemId node, wxArrayString &expandedNodes);
+    void ExpandChildNodes(wxTreeItemId node, wxArrayString &expandedNodes);
+    wxString GetNodePath(wxTreeItemId node);
+
+    void PopulatePluginButtonMenu(wxCommandEvent& event); 
+
+    // In plugins.cpp
+    void LoadPluginUtilities();
+    void AddPluginUtility(PluginUtility *util);
+    void CreatePluginUtility(PluginUtility *util);
+    void ClearPluginUtility(PluginUtility *util);
+
+    DECLARE_EVENT_TABLE()
+};
+
+enum
+{
+    CTL_BROWSER = 301,
+    CTL_NOTEBOOK,
+    CTL_PROPVIEW,
+    CTL_STATVIEW,
+    CTL_DEPVIEW,
+    CTL_REFVIEW,
+    CTL_SQLPANE
+};
+
+class contentsFactory : public actionFactory
+{
+public:
+    contentsFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+
+class pgsqlHelpFactory : public actionFactory
+{
+public:
+    pgsqlHelpFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar, bool bigTool);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+
+class edbHelpFactory : public actionFactory
+{
+public:
+    edbHelpFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar, bool bigTool);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+class greenplumHelpFactory : public actionFactory
+{
+public:
+    greenplumHelpFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar, bool bigTool);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+class slonyHelpFactory : public actionFactory
+{
+public:
+    slonyHelpFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar, bool bigTool);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+
+class faqFactory : public actionFactory
+{
+public:
+    faqFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+
+class bugReportFactory : public actionFactory
+{
+public:
+    bugReportFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+class pluginUtilityFactory : public actionFactory
+{
+public:
+    pluginUtilityFactory(menuFactoryList *list, wxMenu *menu, PluginUtility *util);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+
+private:
+    bool HaveDatabase(pgObject *obj);
+
+    wxString title, command, description;
+    bool database, set_password;
+    wxArrayString applies_to, server_types;
+};
+
+class pluginButtonMenuFactory : public actionFactory
+{
+public:
+    pluginButtonMenuFactory(menuFactoryList *list, wxMenu *popupmenu, ctlMenuToolbar *toolbar, int pluginCount);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+
+private:
+    ctlMenuButton *pulldownButton;
+    bool enableButton;
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmSplash.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmSplash.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmSplash.h (revision 8187)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmSplash.h - Splash Screen
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef SPLASH_H
+#define SPLASH_H
+
+// Class declarations
+class frmSplash : public wxFrame
+{
+public:
+    frmSplash(wxFrame *parent);
+    void OnPaint(wxPaintEvent&);
+    
+private:
+    void SetWindowShape();
+    void OnWindowCreate(wxWindowCreateEvent& WXUNUSED(evt));
+
+    wxBitmap splash;
+    DECLARE_EVENT_TABLE()
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmEditGrid.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmEditGrid.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmEditGrid.h (revision 8187)
@@ -0,0 +1,298 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmEditGrid.h - The SQL Edit Grid form
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef __FRMEDITGRID_H
+#define __FRMEDITGRID_H
+
+#include <wx/grid.h>
+
+// wxAUI
+#include <wx/aui/aui.h>
+
+#define CTL_EDITGRID 357
+#include "dlg/dlgClasses.h"
+#include "ctl/ctlSQLGrid.h"
+
+#define FRMEDITGRID_PERPSECTIVE_VER wxT("$Rev$")
+
+#ifdef __WXMAC__
+#define FRMEDITGRID_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=240;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=limitBar;caption=Limit bar;state=16788208;dir=1;layer=10;row=0;pos=243;prop=100000;bestw=120;besth=21;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=415;floaty=793;floatw=-1;floath=-1|name=sqlGrid;caption=Data grid;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=300;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=300;besth=150;minw=200;minh=100;maxw=-1;maxh=-1;floatx=347;floaty=725;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=84|dock_size(3,0,0)=173|")
+#else
+#ifdef __WXGTK__
+#define FRMEDITGRID_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=305;besth=30;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=limitBar;caption=Limit bar;state=16788208;dir=1;layer=10;row=0;pos=243;prop=100000;bestw=120;besth=30;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=415;floaty=793;floatw=-1;floath=-1|name=sqlGrid;caption=Data grid;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=300;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=300;besth=150;minw=200;minh=100;maxw=-1;maxh=-1;floatx=347;floaty=725;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=84|dock_size(3,0,0)=173|")
+#else
+#define FRMEDITGRID_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=232;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=limitBar;caption=Limit bar;state=16788208;dir=1;layer=10;row=0;pos=243;prop=100000;bestw=100;besth=21;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=415;floaty=793;floatw=-1;floath=-1|name=sqlGrid;caption=Data grid;state=1020;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=300;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=300;besth=150;minw=200;minh=100;maxw=-1;maxh=-1;floatx=347;floaty=725;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=84|dock_size(3,0,0)=173|")
+#endif
+#endif
+
+class cacheLine
+{
+public:
+    cacheLine() { cols=0; stored=false; readOnly=false; }
+    ~cacheLine() { if (cols) delete[] cols; }
+
+    wxString *cols;
+    bool stored, readOnly;
+};
+
+
+class cacheLinePool
+{
+public:
+    cacheLinePool(int initialLines);
+    ~cacheLinePool();
+    cacheLine *operator[] (int line) { return Get(line); }
+    cacheLine *Get(int lineNo);
+    bool IsFilled(int lineNo);
+    void Delete(int lineNo);
+
+private:
+    cacheLine **ptr;
+    int anzLines;
+};
+
+
+class sqlCell
+{
+public:
+    sqlCell() { ClearCell(); }
+
+    void SetCell(long r, long c) { row = r; col = c; }
+    void ClearCell() { row = -1; col = -1; }
+    bool IsSet() { return row != -1 && col != -1; }
+
+    long GetRow() { return row; }
+    long GetCol() { return col; }
+
+private:
+    long row;
+    long col;
+};
+
+// we cannot derive from wxGridCellAttr because destructor is private but not virtual 
+class sqlCellAttr
+{
+public:
+    sqlCellAttr()  { attr = new wxGridCellAttr; isPrimaryKey=false; needResize=false; }
+    ~sqlCellAttr() { attr->DecRef(); }
+    int size();
+    int precision();
+
+    wxGridCellAttr *attr;
+    wxString Quote(pgConn *conn, const wxString &value);
+    OID type;
+    long typlen, typmod;
+    wxString name, typeName, displayTypeName;
+    bool numeric, isPrimaryKey, needResize;
+};
+
+
+class sqlTable;
+
+class ctlSQLEditGrid : public ctlSQLGrid
+{
+public:
+    ctlSQLEditGrid(wxFrame *parent, wxWindowID id, const wxPoint& pos, const wxSize& size);
+
+    sqlTable *GetTable() { return (sqlTable*)wxGrid::GetTable(); }
+    //wxSize GetBestSize(int row, int col);
+    void ResizeEditor(int row, int col);
+    wxArrayInt GetSelectedRows() const;
+    bool CheckRowPresent(int row);
+    virtual bool IsColText(int col);
+};
+
+class sqlTable : public wxGridTableBase
+{
+public:
+    sqlTable(pgConn *conn, pgQueryThread *thread, const wxString& tabName, const OID relid, bool _hasOid, const wxString& _pkCols, char _relkind);
+    ~sqlTable();
+    bool StoreLine();
+    void UndoLine(int row);
+
+    int GetNumberRows();
+    int GetNumberStoredRows();
+    int GetNumberCols();
+    wxString GetColLabelValue(int col);
+    wxString GetColLabelValueUnformatted(int col);
+    wxString GetRowLabelValue(int row);
+    wxGridCellAttr* GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind);
+
+    wxString GetValue(int row, int col);
+    void SetValue(int row, int col, const wxString &value);
+
+    bool IsEmptyCell(int row, int col) { return false; }
+    bool needsResizing(int col) { return columns[col].needResize; }
+    bool AppendRows(size_t rows);
+    bool DeleteRows(size_t pos, size_t rows);
+    int  LastRow() { return lastRow; }
+    bool IsColText(int col);
+    bool IsColBoolean(int col);
+
+    bool CheckInCache(int row);
+    bool IsLineSaved(int row) { return GetLine(row)->stored; }
+
+    bool Paste();
+
+private:
+    pgQueryThread *thread;
+    pgConn *connection;
+    bool hasOids;
+    char relkind;
+    wxString tableName;
+    OID relid;
+    wxString primaryKeyColNumbers;
+
+    cacheLine *GetLine(int row);
+    wxString MakeKey(cacheLine *line);
+    void SetNumberEditor(int col, int len);
+
+    cacheLinePool *dataPool, *addPool;
+    cacheLine savedLine;
+    int lastRow;
+
+    int *lineIndex;     // reindex of lines in dataSet to handle deleted rows
+
+    int nCols;          // columns from dataSet
+    int nRows;          // rows initially returned by dataSet
+    int rowsCached;     // rows read from dataset; if nRows=rowsCached, dataSet can be deleted
+    int rowsAdded;      // rows added (never been in dataSet)
+    int rowsStored;     // rows added and stored to db
+    int rowsDeleted;    // rows deleted from initial dataSet
+    sqlCellAttr *columns;
+
+	wxArrayInt colMap;
+
+    friend class ctlSQLEditGrid;
+};
+
+
+class frmMain;
+class pgSchemaObject;
+
+class frmEditGrid : public pgFrame
+{
+public:
+    frmEditGrid(frmMain *form, const wxString& _title, pgConn *conn, pgSchemaObject *obj);
+    ~frmEditGrid();
+
+    void ShowForm(bool filter = false);
+    void Go();
+    wxString GetSortCols() const { return orderBy; } ;
+    void SetSortCols(const wxString &cols);
+    wxString GetFilter() const { return rowFilter; } ;
+    void SetFilter(const wxString &filter);
+    int GetLimit() const { return limit; } ;
+    void SetLimit(const int rowlimit);
+    wxMenu *GetFileMenu() { return fileMenu; };
+    wxMenu *GetEditMenu() { return editMenu; };
+
+private:
+    void OnEraseBackground(wxEraseEvent& event);
+    void OnSize(wxSizeEvent& event);
+    
+    void OnCloseWindow(wxCloseEvent& event);
+    void OnClose(wxCommandEvent& event);
+    void OnHelp(wxCommandEvent& event);
+    void OnContents(wxCommandEvent& event);
+    void OnRefresh(wxCommandEvent& event);
+    void OnDelete(wxCommandEvent& event);
+    void OnOptions(wxCommandEvent& event);
+    void OnSave(wxCommandEvent& event);
+    bool DoSave();
+	void CancelChange();
+    void OnUndo(wxCommandEvent& event);
+    void OnCellChange(wxGridEvent& event);
+    void OnGridSelectCells(wxGridRangeSelectEvent& event);
+    void OnEditorShown(wxGridEvent& event);
+    void OnEditorHidden(wxGridEvent& event);
+    void OnKey(wxKeyEvent& event);
+    void OnCopy(wxCommandEvent& event);
+    void OnIncludeFilter(wxCommandEvent& event);
+    void OnExcludeFilter(wxCommandEvent& event);
+    void OnRemoveFilters(wxCommandEvent& event);
+    void OnAscSort(wxCommandEvent& event);
+    void OnDescSort(wxCommandEvent& event);
+    void OnRemoveSort(wxCommandEvent& event);
+    void OnPaste(wxCommandEvent& event);
+    void OnLabelDoubleClick(wxGridEvent& event);
+    void OnLabelRightClick(wxGridEvent& event);
+    void OnCellRightClick(wxGridEvent& event);
+    void Abort();
+    void OnToggleScratchPad(wxCommandEvent& event);
+    void OnToggleLimitBar(wxCommandEvent& event);
+    void OnToggleToolBar(wxCommandEvent& event);
+    void OnAuiUpdate(wxAuiManagerEvent& event);
+    void OnDefaultView(wxCommandEvent& event);
+
+    wxAuiManager manager;
+    ctlSQLEditGrid *sqlGrid;
+
+    frmMain *mainForm;
+    pgConn *connection;
+    pgQueryThread *thread;
+    wxMenu *fileMenu, *editMenu, *viewMenu, *toolsMenu, *helpMenu;
+    ctlMenuToolbar *toolBar;
+    ctlComboBoxFix *cbLimit;
+    wxTextCtrl *scratchPad;
+
+    char relkind;
+    OID relid;
+    bool hasOids;
+    wxString tableName;
+    wxString primaryKeyColNumbers;
+    wxString orderBy;
+    wxString rowFilter;
+    int limit;
+    sqlCell *editorCell;
+    bool closing;
+
+    DECLARE_EVENT_TABLE()
+};
+
+
+class editGridFactoryBase : public contextActionFactory
+{
+public:
+    bool CheckEnable(pgObject *obj);
+
+protected:
+    editGridFactoryBase(menuFactoryList *list) : contextActionFactory(list) { rowlimit = 0; }
+    wxWindow *ViewData(frmMain *form, pgObject *obj, bool filter);
+	int rowlimit;
+};
+
+
+class editGridFactory : public editGridFactoryBase
+{
+public:
+    editGridFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+
+class editGridFilteredFactory : public editGridFactoryBase
+{
+public:
+    editGridFilteredFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+class editGridLimitedFactory : public editGridFactoryBase
+{
+public:
+	editGridLimitedFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar, int limit);
+	wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+#endif
+
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmOptions.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmOptions.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmOptions.h (revision 8187)
@@ -0,0 +1,63 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmOptions.h - The main options dialogue
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMOPTIONS_H
+#define FRMOPTIONS_H
+
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+class frmMain;
+
+class ItemWithString : public wxClientData
+{
+public:
+	wxString data;
+};
+
+// Class declarations
+class frmOptions : public pgDialog
+{
+public:
+    frmOptions(frmMain *parent);
+    ~frmOptions();
+    
+private:
+    frmMain *mainForm;
+    wxFont currentFont, currentSqlFont;
+
+    void OnBrowseLogFile(wxCommandEvent &ev);
+    void OnSqlFontSelect(wxCommandEvent &ev);
+    void OnSlonyPathSelect(wxCommandEvent &ev);
+    void OnPostgresqlPathSelect(wxCommandEvent &ev);
+    void OnEnterprisedbPathSelect(wxCommandEvent &ev);
+    void OnGPDBPathSelect(wxCommandEvent &ev);
+    void OnFontSelect(wxCommandEvent &ev);
+    void OnOK(wxCommandEvent &ev);
+    void OnCancel(wxCommandEvent &ev);
+    void OnHelp(wxCommandEvent &ev);
+    void OnDefault(wxCommandEvent &ev);
+    void OnSuppressHints(wxCommandEvent &ev);
+    void OnResetHints(wxCommandEvent &ev);
+	void OnChangeCopyQuote(wxCommandEvent &ev);
+    DECLARE_EVENT_TABLE()
+};
+
+
+class optionsFactory : public actionFactory
+{
+public:
+    optionsFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmBackupServer.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmBackupServer.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmBackupServer.h (revision 8187)
@@ -0,0 +1,54 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmBackupServer.h - Backup server dialogue
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef FRMBACKUPSERVER_H
+#define FRMBACKUPSERVER_H
+
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+class frmMain;
+
+class frmBackupServer : public ExternProcessDialog
+{
+public:
+    frmBackupServer(frmMain *form, pgObject *_object);
+    ~frmBackupServer();
+
+    void Go();
+    wxString GetDisplayCmd(int step);
+    wxString GetCmd(int step);
+    
+private:
+    wxString GetHelpPage() const;
+    void OnChange(wxCommandEvent &ev);
+    void OnSelectFilename(wxCommandEvent &ev);
+    wxString getCmdPart1();
+    wxString getCmdPart2();
+    void OnOK(wxCommandEvent &ev);
+
+    pgObject *object;
+    wxString processedFile;
+
+    DECLARE_EVENT_TABLE()
+};
+
+
+class backupServerFactory : public contextActionFactory
+{
+public:
+    backupServerFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmGrantWizard.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmGrantWizard.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmGrantWizard.h (revision 8187)
@@ -0,0 +1,58 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmGrantWizard.h - Grant Wizard Dialogue
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMGRANTWIZARD_H
+#define FRMGRANTWIZARD_H
+
+#include <wx/notebook.h>
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+class ctlSecurityPanel;
+
+DECLARE_EVENT_TYPE(EVT_SECURITYPANEL_CHANGE, -1)
+
+class frmGrantWizard : public ExecutionDialog
+{
+public:
+    frmGrantWizard(frmMain *form, pgObject *_object);
+    ~frmGrantWizard();
+
+    void Go();
+    wxString GetSql();
+    wxString GetHelpPage() const;
+    
+private:
+
+    void OnPageSelect(wxNotebookEvent& event);
+    void OnCheckAll(wxCommandEvent &event);
+    void OnUncheckAll(wxCommandEvent &event);
+    void OnChange(wxCommandEvent& event);
+
+    void AddObjects(pgCollection *collection);
+
+    wxArrayPtrVoid objectArray;
+    ctlSQLBox *sqlPane;
+    wxNotebook *nbNotebook;
+    ctlSecurityPanel *securityPage;
+
+    DECLARE_EVENT_TABLE()
+};
+
+class grantWizardFactory : public contextActionFactory
+{
+public:
+    grantWizardFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/menu.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/menu.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/menu.h (revision 8187)
@@ -0,0 +1,126 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// misc.h - Miscellaneous Utilties
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef __MENU_H
+#define __MENU_H
+
+// Menu options
+enum
+{
+    MNU_ADDSERVER = 101,
+    MNU_SAVEDEFINITION,
+    MNU_EXIT,
+    MNU_CONTEXTMENU,
+    MNU_SQLPANE,
+    MNU_OBJECTBROWSER,
+    MNU_TOOLBAR,
+    MNU_LIMITBAR,
+    MNU_DATABASEBAR,
+    MNU_SCRATCHPAD,
+    MNU_OUTPUTPANE,
+    MNU_DEFAULTVIEW,
+    MNU_BACK,
+    MNU_FORWARD,
+    MNU_REFRESH,
+
+    MNU_ADDCOLUMN,
+    MNU_CLOSE,
+    MNU_MIN,
+    MNU_RECORD,
+    MNU_STOP,
+    MNU_APPEND,
+    MNU_DELETE,
+    MNU_OPEN,
+    MNU_SAVE,
+    MNU_SAVEAS,
+    MNU_EXPORT,
+    MNU_OPTIONS,
+    MNU_CUT,
+    MNU_COPY,
+    MNU_INCLUDEFILTER,
+    MNU_EXCLUDEFILTER,
+    MNU_REMOVEFILTERS,
+    MNU_ASCSORT,
+    MNU_DESCSORT,
+    MNU_REMOVESORT,
+    MNU_PASTE,
+    MNU_CLEAR,
+    MNU_FIND,
+    MNU_REPLACE,
+    MNU_UNDO,
+    MNU_REDO,
+    MNU_CANCEL,
+    MNU_EXECUTE,
+    MNU_EXECFILE,
+    MNU_EXPLAIN,
+    MNU_EXPLAINOPTIONS,
+    MNU_VERBOSE,
+    MNU_ANALYZE,
+    MNU_CLEARHISTORY,
+    MNU_SAVEHISTORY,
+    MNU_CHECKALIVE,
+    MNU_SELECTALL,
+    MNU_EXECPGS,
+
+    MNU_CONTENTS,
+    MNU_HELP,
+    MNU_HINT,
+
+    MNU_CONFIGSUBMENU,
+    MNU_SLONY_SUBMENU,
+
+    MNU_ONLINEUPDATE_NEWDATA,
+
+    MNU_AUTOCOMPLETE,
+    MNU_AUTOINDENT,
+    MNU_WORDWRAP,
+    MNU_SHOWWHITESPACE,
+    MNU_SHOWLINEENDS,
+    MNU_SHOWINDENTGUIDES,
+    MNU_QUICKREPORT,
+
+    MNU_UPPER_CASE,
+    MNU_LOWER_CASE,
+    MNU_BLOCK_INDENT,
+    MNU_BLOCK_OUTDENT,
+    MNU_COMMENT_TEXT,
+    MNU_UNCOMMENT_TEXT,
+
+    MNU_PLUGINBUTTONLIST,
+
+    MNU_LINEENDS,
+    MNU_CR,
+    MNU_CRLF,
+    MNU_LF,
+
+    MNU_RECENT,
+    MNU_NEW=MNU_RECENT+15,  // leave space for recent file entries
+
+    MNU_ACTION=MNU_NEW+1000, // leave space for objects
+
+    MNU_FAVOURITES_ADD=MNU_ACTION+1000, // leave space for actions
+    MNU_FAVOURITES_MANAGE,
+
+    MNU_MACROS_MANAGE=MNU_FAVOURITES_MANAGE+1000, //leave space for favourites
+
+    // This is used by the Query Tool - the event is fired when the query completes
+    QUERY_COMPLETE=MNU_MACROS_MANAGE+100,
+    PGSCRIPT_COMPLETE,
+
+    // This is a dummy menu item
+    MNU_DUMMY=QUERY_COMPLETE+1000,
+
+	//Menu Test
+	MNU_GENERATESQL
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/module.mk
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/module.mk (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/module.mk (revision 8187)
@@ -0,0 +1,38 @@
+#######################################################################
+#
+# pgAdmin III - PostgreSQL Tools
+# $Id$
+# Copyright (C) 2002 - 2010, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# module.mk - pgadmin/include/frm/ Makefile fragment
+#
+#######################################################################
+
+pgadmin3_SOURCES += \
+	$(srcdir)/include/frm/frmAbout.h \
+	$(srcdir)/include/frm/frmBackup.h \
+	$(srcdir)/include/frm/frmBackupGlobals.h \
+	$(srcdir)/include/frm/frmBackupServer.h \
+	$(srcdir)/include/frm/frmConfig.h \
+	$(srcdir)/include/frm/frmEditGrid.h \
+	$(srcdir)/include/frm/frmExport.h \
+  	$(srcdir)/include/frm/frmGrantWizard.h \
+  	$(srcdir)/include/frm/frmHbaConfig.h \
+	$(srcdir)/include/frm/frmHint.h \
+	$(srcdir)/include/frm/frmMain.h \
+	$(srcdir)/include/frm/frmMainConfig.h \
+	$(srcdir)/include/frm/frmMaintenance.h \
+	$(srcdir)/include/frm/frmOptions.h \
+	$(srcdir)/include/frm/frmPassword.h \
+	$(srcdir)/include/frm/frmPgpassConfig.h \
+	$(srcdir)/include/frm/frmQuery.h \
+	$(srcdir)/include/frm/frmReport.h \
+	$(srcdir)/include/frm/frmRestore.h \
+	$(srcdir)/include/frm/frmSplash.h \
+	$(srcdir)/include/frm/frmStatus.h \
+    $(srcdir)/include/frm/menu.h
+
+EXTRA_DIST += \
+    $(srcdir)/include/frm/module.mk
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmHint.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmHint.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmHint.h (revision 8187)
@@ -0,0 +1,76 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmHint.h - PostgreSQL Guru hints
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef __FRMHINT
+#define __FRMHINT
+
+
+#define HINT_CONNECTSERVER      wxT("conn-listen")
+#define HINT_MISSINGHBA         wxT("conn-hba")
+#define HINT_MISSINGIDENT       wxT("conn-ident")
+#define HINT_PRIMARYKEY         wxT("pk")
+#define HINT_FKINDEX            wxT("fki")
+#define HINT_VACUUM             wxT("vacuum")
+#define HINT_QUERYRUNTIME       wxT("query-runtime")
+#define HINT_INSTRUMENTATION    wxT("instrumentation")
+#define HINT_ENCODING_ASCII     wxT("encoding-ascii")
+#define HINT_ENCODING_UNICODE   wxT("encoding-unicode")
+#define HINT_READONLY_NOPK      wxT("view-without-pk")
+#define HINT_AUTOVACUUM         wxT("autovacuum")
+#define HINT_OBJECT_EDITING     wxT("object-editing")
+#define HINT_SAVING_PASSWORDS   wxT("saving-passwords")
+
+#define HINT_RC_FIX             42
+
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+class frmMain;
+class frmHint : public DialogWithHelp
+{
+public:
+    static int ShowHint(wxWindow *fr,  const wxString &hint, const wxString &info=wxEmptyString, bool force=false);
+    static int ShowHint(wxWindow *fr,  const wxArrayString &hints, const wxString &info=wxEmptyString, bool force=false);
+    static bool WantHint(const wxString &hint);
+    static void ResetHints();
+
+    void SetHint(int hint, const wxString &info);
+    void SetHint(const wxArrayInt &hintnos, const wxString &info);
+
+private:
+    frmHint(wxWindow *fr, bool force);
+    ~frmHint();
+
+    void SetHint(const wxString &info);
+    void OnFix(wxCommandEvent &ev);
+    static int GetHintNo(const wxString &hint);
+    static bool WantHint(int hintno);
+    wxString GetPage(const wxChar *hintpage);
+    wxString GetHelpPage() const;
+
+    DECLARE_EVENT_TABLE()
+
+    wxArrayInt hintnos;
+    int currentHint;
+    bool force;
+};
+
+
+class hintFactory : public actionFactory
+{
+public:
+    hintFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar, bool bigTool);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmPassword.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmPassword.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmPassword.h (revision 8187)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmPassword.h - Change password
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMPASSWORD_H
+#define FRMPASSWORD_H
+
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+class pgServer;
+// Class declarations
+class frmPassword : public pgDialog
+{
+public:
+    frmPassword(wxFrame *parent, pgObject *obj);
+    ~frmPassword();
+    
+private:
+    pgServer *server;
+    void OnHelp(wxCommandEvent& ev);
+    void OnOK(wxCommandEvent& event);
+    void OnCancel(wxCommandEvent& event);
+    DECLARE_EVENT_TABLE()
+};
+
+
+class passwordFactory : public actionFactory
+{
+public:
+    passwordFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmQuery.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmQuery.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmQuery.h (revision 8187)
@@ -0,0 +1,306 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmQuery.h - The SQL Query form
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef __FRM_QUERY_H
+#define __FRM_QUERY_H
+
+#include "dlg/dlgClasses.h"
+#include "gqb/gqbViewController.h"
+#include "gqb/gqbModel.h"
+#include "utils/factory.h"
+#include "utils/favourites.h"
+#include "utils/macros.h"
+
+#include <wx/sstream.h>
+#include <wx/txtstrm.h>
+
+// wxAUI
+#include <wx/aui/aui.h>
+#include <wx/textctrl.h>
+#include <wx/dcbuffer.h>
+#include <wx/timer.h>
+
+#define FRMQUERY_PERPSECTIVE_VER wxT("$Rev$")
+
+#ifdef __WXMAC__
+#define FRMQUERY_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=415;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=21;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlQuery;caption=SQL query;state=17404;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=200|dock_size(3,0,0)=290|dock_size(2,0,0)=255|")
+#else
+#ifdef __WXGTK__
+#define FRMQUERY_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=525;besth=30;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=30;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlQuery;caption=SQL query;state=17404;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=200|dock_size(3,0,0)=290|dock_size(2,0,0)=255|")
+#else
+#define FRMQUERY_DEFAULT_PERSPECTIVE wxT("layout2|name=toolBar;caption=Tool bar;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=415;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=databaseBar;caption=Database bar;state=16788208;dir=1;layer=10;row=0;pos=396;prop=100000;bestw=250;besth=21;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=sqlQuery;caption=SQL query;state=17404;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=350;besth=200;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPane;caption=Output pane;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=550;besth=300;minw=200;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=scratchPad;caption=Scratch pad;state=16779260;dir=2;layer=0;row=0;pos=0;prop=100000;bestw=250;besth=200;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(1,10,0)=25|dock_size(5,0,0)=200|dock_size(3,0,0)=290|dock_size(2,0,0)=255|")
+#endif
+#endif
+
+class ExplainCanvas;
+class ctlSQLResult;
+class pgsApplication;
+class pgScriptTimer;
+
+class QueryExecInfo
+{
+public:
+    int queryOffset;
+    bool toFile;
+    bool singleResult;
+    bool explain;
+    bool verbose;
+};
+
+class frmQuery : public pgFrame
+{
+public:
+    frmQuery(frmMain *form, const wxString& _title, pgConn *conn, const wxString& qry, const wxString& file = wxEmptyString);
+    ~frmQuery();
+    void Go();
+    
+    void writeScriptOutput();
+
+private:
+    frmMain *mainForm;
+    wxAuiManager manager;
+    ctlSQLBox *sqlQuery;
+    wxNotebook *outputPane;
+    ctlSQLResult *sqlResult;
+    ExplainCanvas *explainCanvas;
+    wxTextCtrl *msgResult, *msgHistory;
+    ctlComboBoxFix *cbConnection;
+    wxTextCtrl *scratchPad;
+
+	// Query timing/status update
+    wxTimer timer;
+    wxLongLong elapsedQuery, startTimeQuery;
+    
+    // pgScript interface
+    pgsApplication * pgScript;
+    wxString pgsOutputString;
+    wxStringOutputStream pgsStringOutput;
+    wxTextOutputStream pgsOutput;
+    pgScriptTimer * pgsTimer;
+
+	//GQB related
+    void OnChangeNotebook(wxNotebookEvent& event);
+    void OnAdjustSizesTimer(wxTimerEvent & event);
+	void OnResizeHorizontally(wxSplitterEvent& event);
+    void adjustGQBSizes();
+	bool updateFromGqb(bool executing);
+    wxNotebook *sqlNotebook;
+    gqbModel *model;
+    gqbController *controller;
+    bool firstTime;
+	bool gqbUpdateRunning;
+    wxTimer *adjustSizesTimer;
+
+	// Our connection
+    pgConn *conn;
+
+	// These status flags are required to work round some wierdness on wxGTK,
+	// particularly on Solaris.
+    bool closing, loading;
+
+    void OnEraseBackground(wxEraseEvent& event);
+    void OnSize(wxSizeEvent& event);
+
+    void OnChangeStc(wxStyledTextEvent& event);
+    void OnPositionStc(wxStyledTextEvent& event);
+    void OnClose(wxCloseEvent& event);
+    void OnSetFocus(wxFocusEvent& event);
+    void OnContents(wxCommandEvent& event);
+    void OnHelp(wxCommandEvent& event);
+    void OnCancel(wxCommandEvent& event);
+    void OnExecute(wxCommandEvent& event);
+    void OnExecScript(wxCommandEvent& event);
+    void OnExecFile(wxCommandEvent& event);
+    void OnExplain(wxCommandEvent& event);
+    void OnNew(wxCommandEvent& event);
+    void OnOpen(wxCommandEvent& event);
+    void OnSave(wxCommandEvent& event);
+    void OnSaveAs(wxCommandEvent& event);
+    void OnExport(wxCommandEvent& event);
+    void OnExit(wxCommandEvent& event);
+    void OnCut(wxCommandEvent& event);
+    void OnCopy(wxCommandEvent& event);
+    void OnPaste(wxCommandEvent& event);
+    void OnClear(wxCommandEvent& event);
+    void OnSearchReplace(wxCommandEvent& event);
+    void OnUndo(wxCommandEvent& event);
+    void OnRedo(wxCommandEvent& event);
+    void OnSaveHistory(wxCommandEvent& event);
+    void OnChangeConnection(wxCommandEvent &ev);
+    void OnClearHistory(wxCommandEvent& event);
+    void OnActivate(wxActivateEvent& event);
+    void OnFocus(wxFocusEvent& event);
+    void OnSelectAll(wxCommandEvent& event);
+    void OnAddFavourite(wxCommandEvent& event);
+    void OnManageFavourites(wxCommandEvent& event);
+    void OnSelectFavourite(wxCommandEvent& event);
+    void OnQuickReport(wxCommandEvent& event);
+    void OnAutoIndent(wxCommandEvent& event);
+    void OnWordWrap(wxCommandEvent& event);
+    void OnShowIndentGuides(wxCommandEvent& event);
+    void OnShowWhitespace(wxCommandEvent& event);
+    void OnShowLineEnds(wxCommandEvent& event);
+
+    void OnToggleScratchPad(wxCommandEvent& event);
+    void OnToggleDatabaseBar(wxCommandEvent& event);
+    void OnToggleToolBar(wxCommandEvent& event);
+    void OnToggleOutputPane(wxCommandEvent& event);
+    void OnAuiUpdate(wxAuiManagerEvent& event);
+    void OnDefaultView(wxCommandEvent& event);
+    void OnBlockIndent(wxCommandEvent& event);
+    void OnBlockOutDent(wxCommandEvent& event);
+    void OnChangeToUpperCase(wxCommandEvent& event);
+    void OnChangeToLowerCase(wxCommandEvent& event);
+    void OnCommentText(wxCommandEvent& event);
+    void OnUncommentText(wxCommandEvent& event);
+
+    void OnTimer(wxTimerEvent & event);
+
+    bool CheckChanged(bool canVeto);
+    void OpenLastFile();
+    void updateMenu(wxObject *obj=0);
+    void execQuery(const wxString &query, int resultToRetrieve=0, bool singleResult=false, const int queryOffset=0, bool toFile=false, bool explain=false, bool verbose=false);
+    void OnQueryComplete(wxCommandEvent &ev);
+    void completeQuery(bool done, bool explain, bool verbose);
+    void OnScriptComplete(wxCommandEvent &ev);
+    void setTools(const bool running);
+    void showMessage(const wxString& msg, const wxString &msgShort=wxT(""));
+    void setExtendedTitle();
+    void UpdateFavouritesList();
+    void SetLineEndingStyle();
+    int GetLineEndingStyle();
+    void OnSetEOLMode(wxCommandEvent& event);
+    void SetEOLModeDisplay(int mode);
+    void OnMacroInvoke(wxCommandEvent& event);
+    void OnMacroManage(wxCommandEvent& event);
+    void UpdateMacrosList();
+    wxWindow *currentControl();
+    wxMenu *queryMenu;
+    wxMenu *favouritesMenu;
+    wxMenu *macrosMenu;
+    wxMenu *lineEndMenu;
+    wxMenu *formatMenu;
+    wxString title;
+    wxString lastFilename, lastDir;
+
+    queryFavouriteFolder *favourites;
+    queryMacroList *macros;
+
+    bool aborted;
+    bool lastFileFormat;
+
+    // A simple mutex-like flag to prevent concurrent script execution.
+    // Required because the pgScript parser isn't currently thread-safe :-(
+    static bool    ms_pgScriptRunning;
+
+    DECLARE_EVENT_TABLE()
+};
+
+// Position of status line fields
+enum
+{
+    STATUSPOS_MSGS = 1,
+    STATUSPOS_FORMAT,
+    STATUSPOS_POS,
+    STATUSPOS_ROWS,
+    STATUSPOS_SECS
+};
+
+enum
+{
+    CTL_SQLQUERY=331,
+    CTL_SQLRESULT,
+    CTL_MSGRESULT,
+    CTL_MSGHISTORY,
+    CTL_NTBKCENTER,
+    CTL_COLSGRID,
+    CTL_TIMERSIZES,
+    CTL_TIMERFRM,
+    CTL_NTBKGQB
+};
+
+///////////////////////////////////////////////////////
+
+class queryToolBaseFactory : public actionFactory
+{
+protected:
+    queryToolBaseFactory(menuFactoryList *list) : actionFactory(list) {}
+    wxWindow *StartDialogSql(frmMain *form, pgObject *obj, const wxString &sql);
+public:
+    bool CheckEnable(pgObject *obj);
+};
+
+class queryToolDataFactory : public queryToolBaseFactory
+{
+protected:
+    queryToolDataFactory(menuFactoryList *list) : queryToolBaseFactory(list) {}
+public:
+    bool CheckEnable(pgObject *obj);
+};
+
+class queryToolFactory : public queryToolBaseFactory
+{
+public:
+    queryToolFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+class queryToolSqlFactory : public queryToolBaseFactory
+{
+public:
+    queryToolSqlFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+class queryToolSelectFactory : public queryToolDataFactory
+{
+public:
+    queryToolSelectFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+class queryToolDeleteFactory : public queryToolDataFactory
+{
+public:
+    queryToolDeleteFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+class queryToolInsertFactory : public queryToolDataFactory
+{
+public:
+    queryToolInsertFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+class queryToolUpdateFactory : public queryToolDataFactory
+{
+public:
+    queryToolUpdateFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+///////////////////////////////////////////////////////
+class pgScriptTimer : public wxTimer
+{
+private:
+    frmQuery * m_parent;
+
+public:
+    pgScriptTimer(frmQuery * parent);
+    void Notify();
+};
+
+#endif // __FRM_QUERY_H
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmBackup.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmBackup.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmBackup.h (revision 8187)
@@ -0,0 +1,57 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmBackup.h - Backup database dialogue
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef FRMBACKUP_H
+#define FRMBACKUP_H
+
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+class frmMain;
+
+class frmBackup : public ExternProcessDialog
+{
+public:
+    frmBackup(frmMain *form, pgObject *_object);
+    ~frmBackup();
+
+    void Go();
+    wxString GetDisplayCmd(int step);
+    wxString GetCmd(int step);
+    
+private:
+    wxString GetHelpPage() const;
+    void OnChange(wxCommandEvent &ev);
+    void OnSelectFilename(wxCommandEvent &ev);
+    void OnChangePlain(wxCommandEvent &ev);
+    wxString getCmdPart1();
+    wxString getCmdPart2();
+    void OnOK(wxCommandEvent &ev);
+
+    pgObject *object;
+
+    bool canBlob;
+    wxString processedFile;
+
+    DECLARE_EVENT_TABLE()
+};
+
+
+class backupFactory : public contextActionFactory
+{
+public:
+    backupFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmConfig.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmConfig.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmConfig.h (revision 8187)
@@ -0,0 +1,82 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmConfig.h - Configuration tool
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMCONFIG_H
+#define FRMCONFIG_H
+
+#include <wx/textbuf.h>
+
+class pgConn;
+class ctlListView;
+class frmMain;
+
+
+extern wxImageList *configImageList;
+
+class frmConfig : public pgFrame
+{
+public:
+
+    enum tryMode
+    {
+        NONE=0,
+        ANYFILE,
+        HBAFILE,
+        MAINFILE,
+		PGPASSFILE
+    };
+
+    static frmConfig *Create(const wxString &title, const wxString &configFile, tryMode mode);
+    void Go();
+    void DoOpen(const wxString &fn=wxEmptyString);
+
+
+protected:
+    frmConfig(const wxString& title, const wxString &configFile);
+    frmConfig(frmMain *parent, const wxString& title, pgConn *conn);
+    ~frmConfig();
+
+    virtual void DisplayFile(const wxString &str) =0;
+    virtual void WriteFile(pgConn *conn=0) =0;
+    virtual wxString GetHintString() { return wxEmptyString; }
+
+    void OpenLastFile();
+    void InitFrame(const wxChar *frameName);
+    bool DoWriteFile(const wxChar *str, pgConn *conn);
+    bool CheckChanged(bool canVeto);
+
+private:
+
+    virtual void OnOpen(wxCommandEvent& event);
+    void OnSave(wxCommandEvent& event);
+    void OnSaveAs(wxCommandEvent& event);
+
+    void OnClose(wxCloseEvent& event);
+    void OnExecute(wxCommandEvent& event);
+	void OnHelp(wxCommandEvent& event);
+    void OnHint(wxCommandEvent& event);
+    void OnBugreport(wxCommandEvent& event);
+
+    void DisplayHint(bool force);
+
+protected:
+    pgConn *conn;
+    frmMain *mainForm;
+    wxString serverFileName;
+
+    wxTextFileType filetype;
+
+    DECLARE_EVENT_TABLE()
+};
+
+
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmBackupGlobals.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmBackupGlobals.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmBackupGlobals.h (revision 8187)
@@ -0,0 +1,54 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmBackupGlobals.h - Backup globals dialogue
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef FRMBACKUPGLOBALS_H
+#define FRMBACKUPGLOBALS_H
+
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+class frmMain;
+
+class frmBackupGlobals : public ExternProcessDialog
+{
+public:
+    frmBackupGlobals(frmMain *form, pgObject *_object);
+    ~frmBackupGlobals();
+
+    void Go();
+    wxString GetDisplayCmd(int step);
+    wxString GetCmd(int step);
+    
+private:
+    wxString GetHelpPage() const;
+    void OnChange(wxCommandEvent &ev);
+    void OnSelectFilename(wxCommandEvent &ev);
+    wxString getCmdPart1();
+    wxString getCmdPart2();
+    void OnOK(wxCommandEvent &ev);
+
+    pgObject *object;
+    wxString processedFile;
+
+    DECLARE_EVENT_TABLE()
+};
+
+
+class backupGlobalsFactory : public contextActionFactory
+{
+public:
+    backupGlobalsFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmAbout.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmAbout.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmAbout.h (revision 8187)
@@ -0,0 +1,41 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmAbout.h - About Box
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMABOUT_H
+#define FRMABOUT_H
+
+// Class declarations
+class frmAbout : public wxFrame
+{
+public:
+    frmAbout(wxFrame *parent);
+
+    void OnPaint(wxPaintEvent&);
+    
+private:
+    void SetWindowShape();
+    void OnWindowCreate(wxWindowCreateEvent& WXUNUSED(evt));
+    void OnLeftDown(wxMouseEvent& WXUNUSED(evt));
+    void OnKeyUp(wxKeyEvent& evt);
+
+    wxBitmap about;
+    DECLARE_EVENT_TABLE()
+};
+
+class aboutFactory : public actionFactory
+{
+public:
+    aboutFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmMainConfig.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmMainConfig.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmMainConfig.h (revision 8187)
@@ -0,0 +1,83 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmMainConfig.h - Backend configuration tool
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMMAINCONFIG_H
+#define FRMMAINCONFIG_H
+
+#include "utils/pgconfig.h"
+#include "frm/frmConfig.h"
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+class ctlListView;
+class pgServer;
+
+WX_DECLARE_OBJARRAY(pgConfigOrgLine, pgConfigOrgLineArray);
+
+class frmMainConfig : public frmConfig
+{
+public:
+    frmMainConfig(const wxString& title, const wxString &configFile);
+    frmMainConfig(frmMain *parent, pgServer *server=0);
+
+    ~frmMainConfig();
+
+protected:
+    void DisplayFile(const wxString &str);
+    void WriteFile(pgConn *conn=0);
+    wxString GetHintString();
+    wxString GetHelpPage() const;
+
+private:
+    void Init();
+    void Init(pgSettingReader *reader);
+    void InitForm();
+
+    void FillList(const wxString &categoryMember, const wxString &altCategoryMember = wxEmptyString);
+    void FillList(wxArrayString *category);
+
+    void OnContents(wxCommandEvent& event);
+    void OnUndo(wxCommandEvent& event);
+    void OnEditSetting(wxListEvent& event);
+    void OnSelectSetting(wxListEvent& event);
+
+    void UpdateLine(int line);
+
+    void OnOpen(wxCommandEvent& event);
+
+
+    ctlListView *cfgList;
+
+    pgSettingItemHashmap options;
+    pgCategoryHashmap categories;
+    pgConfigOrgLineArray lines;
+
+    DECLARE_EVENT_TABLE()
+};
+
+
+class mainConfigFactory : public actionFactory
+{
+public:
+    mainConfigFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+
+class mainConfigFileFactory : public actionFactory
+{
+public:
+    mainConfigFileFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmReport.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmReport.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmReport.h (revision 8187)
@@ -0,0 +1,159 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmReport.h - The report file dialogue
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMREPORT_H
+#define FRMREPORT_H
+
+#include "dlg/dlgClasses.h"
+#include "ctl/ctlListView.h"
+#include "ctl/ctlSQLResult.h"
+
+// Class declarations
+class frmReport : public pgDialog
+{
+public:
+    frmReport(wxWindow *p);
+    ~frmReport();
+
+    void SetReportTitle(const wxString &t);
+
+    void XmlAddHeaderValue(const wxString &name, const wxString &value);
+    int XmlCreateSection(const wxString &name);
+    void XmlSetSectionTableHeader(const int section, const int columns, const wxChar *name,...);
+    void XmlAddSectionTableRow(const int section, const int number, const int columns, const wxChar *value,...);
+    void XmlAddSectionTableFromListView(const int section, ctlListView *list);
+    void XmlAddSectionTableFromGrid(const int section, ctlSQLResult *grid);
+    void XmlSetSectionTableInfo(const int section, const wxString &info) { sectionTableInfo[section-1] = info; };
+    void XmlSetSectionSql(int section, const wxString &sql);
+    void XmlAddSectionValue(const int section, const wxString &name, const wxString &value);
+
+private:
+    void OnChange(wxCommandEvent &ev);
+    void OnHelp(wxCommandEvent& ev);
+    void OnOK(wxCommandEvent &ev);
+    void OnCancel(wxCommandEvent &ev);
+    void OnBrowseFile(wxCommandEvent &ev);
+    void OnBrowseStylesheet(wxCommandEvent &ev);
+
+    wxString GetSectionTableColumns(const int section);
+    wxString GetSectionTableRows(const int section);
+    wxString GetSectionTable(const int section);
+    wxString GetSection(const int section);
+    wxString GetXmlReport(const wxString &stylesheet);
+    wxString XslProcessReport(const wxString &xml, const wxString &xsl);
+
+    wxString GetCssLink(const wxString &file);
+    wxString GetEmbeddedCss(const wxString &css);
+    const wxString GetDefaultCss();
+    wxString GetDefaultXsl(const wxString &css);
+
+    wxWindow *parent;
+    wxString header;
+    wxArrayString sectionName, sectionData, sectionTableHeader, sectionTableRows, sectionTableInfo, sectionSql;
+
+    DECLARE_EVENT_TABLE()
+};
+
+///////////////////////////////////////////////////////
+// Report Factory base class
+///////////////////////////////////////////////////////
+class reportBaseFactory : public actionFactory
+{
+protected:
+	reportBaseFactory(menuFactoryList *list) : actionFactory(list) {}
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    frmMain *GetFrmMain() { return parent; };
+    virtual void GenerateReport(frmReport *report, pgObject *object) {};
+
+    frmMain *parent;
+public:
+    bool CheckEnable(pgObject *obj) { return false; };
+};
+
+
+///////////////////////////////////////////////////////
+// Object properties report
+///////////////////////////////////////////////////////
+class reportObjectPropertiesFactory : public reportBaseFactory
+{
+public:
+    reportObjectPropertiesFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    bool CheckEnable(pgObject *obj);
+    void GenerateReport(frmReport *report, pgObject *object);
+};
+
+///////////////////////////////////////////////////////
+// Object DDL report
+///////////////////////////////////////////////////////
+class reportObjectDdlFactory : public reportBaseFactory
+{
+public:
+    reportObjectDdlFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    bool CheckEnable(pgObject *obj);
+    void GenerateReport(frmReport *report, pgObject *object);
+};
+
+///////////////////////////////////////////////////////
+// Object Data dictionary report
+///////////////////////////////////////////////////////
+class reportObjectDataDictionaryFactory : public reportBaseFactory
+{
+public:
+    reportObjectDataDictionaryFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    bool CheckEnable(pgObject *obj);
+    void GenerateReport(frmReport *report, pgObject *object);
+};
+
+///////////////////////////////////////////////////////
+// Object statistics report
+///////////////////////////////////////////////////////
+class reportObjectStatisticsFactory : public reportBaseFactory
+{
+public:
+    reportObjectStatisticsFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    bool CheckEnable(pgObject *obj);
+    void GenerateReport(frmReport *report, pgObject *object);
+};
+
+///////////////////////////////////////////////////////
+// Object dependencies report
+///////////////////////////////////////////////////////
+class reportObjectDependenciesFactory : public reportBaseFactory
+{
+public:
+    reportObjectDependenciesFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    bool CheckEnable(pgObject *obj);
+    void GenerateReport(frmReport *report, pgObject *object);
+};
+
+///////////////////////////////////////////////////////
+// Object Dependents report
+///////////////////////////////////////////////////////
+class reportObjectDependentsFactory : public reportBaseFactory
+{
+public:
+    reportObjectDependentsFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    bool CheckEnable(pgObject *obj);
+    void GenerateReport(frmReport *report, pgObject *object);
+};
+
+///////////////////////////////////////////////////////
+// Object list report
+///////////////////////////////////////////////////////
+class reportObjectListFactory : public reportBaseFactory
+{
+public:
+    reportObjectListFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    bool CheckEnable(pgObject *obj);
+    void GenerateReport(frmReport *report, pgObject *object);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmHbaConfig.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmHbaConfig.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmHbaConfig.h (revision 8187)
@@ -0,0 +1,71 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmHbaConfig.h - Backend access configuration tool
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMHBACONFIG_H
+#define FRMHBACONFIG_H
+
+#include "frm/frmConfig.h"
+#include "utils/pgconfig.h"
+
+class pgConn;
+class pgServer;
+class ctlListView;
+
+
+WX_DECLARE_OBJARRAY(pgHbaConfigLine, pgHbaConfigLineArray);
+
+class frmHbaConfig : public frmConfig
+{
+public:
+    frmHbaConfig(const wxString& title, const wxString &configFile);
+    frmHbaConfig(frmMain *parent, pgServer *server=0);
+    ~frmHbaConfig();
+
+protected:
+    void DisplayFile(const wxString &str);
+    void WriteFile(pgConn *conn=0);
+    wxString GetHintString();
+    wxString GetHelpPage() const;
+
+private:
+    void Init();
+    void UpdateDisplay(pgHbaConfigLine &line);
+
+    void OnContents(wxCommandEvent& event);
+    void OnUndo(wxCommandEvent& event);
+	void OnDelete(wxCommandEvent& event);
+    void OnEditSetting(wxListEvent& event);
+    void OnSelectSetting(wxListEvent& event);
+
+    ctlListView *listEdit;
+    pgHbaConfigLineArray lines;
+
+
+    DECLARE_EVENT_TABLE()
+};
+
+class hbaConfigFactory : public actionFactory
+{
+public:
+    hbaConfigFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+
+class hbaConfigFileFactory : public actionFactory
+{
+public:
+    hbaConfigFileFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmExport.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmExport.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmExport.h (revision 8187)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmExport.h - The export file dialogue
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMEXPORT_H
+#define FRMEXPORT_H
+
+
+class ctlSQLResult;
+class pgSet;
+
+#include "dlg/dlgClasses.h"
+
+// Class declarations
+class frmExport : public pgDialog
+{
+public:
+    frmExport(wxWindow *parent);
+    ~frmExport();
+
+    bool Export(pgSet *set);
+    
+private:
+    void OnChange(wxCommandEvent &ev);
+    void OnHelp(wxCommandEvent& ev);
+    void OnOK(wxCommandEvent &ev);
+    void OnCancel(wxCommandEvent &ev);
+    void OnBrowseFile(wxCommandEvent &ev);
+
+    wxWindow *parent;
+
+    DECLARE_EVENT_TABLE()
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmMaintenance.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmMaintenance.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmMaintenance.h (revision 8187)
@@ -0,0 +1,45 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmMaintenance.h - Maintenance options selection dialogue
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef FRMMAINTENANCE_H
+#define FRMMAINTENANCE_H
+
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+// Class declarations
+class frmMaintenance : public ExecutionDialog
+{
+public:
+    frmMaintenance(frmMain *form, pgObject *_object);
+    ~frmMaintenance();
+    wxString GetSql();
+
+    void Go();
+    
+private:
+    wxString GetHelpPage() const;
+    void OnAction(wxCommandEvent& ev);
+
+    DECLARE_EVENT_TABLE()
+};
+
+
+class maintenanceFactory : public contextActionFactory
+{
+public:
+    maintenanceFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmPgpassConfig.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmPgpassConfig.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmPgpassConfig.h (revision 8187)
@@ -0,0 +1,62 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmPgpassConfig.h - Pgpass.conf editor
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef frmPgpassConfig_H
+#define frmPgpassConfig_H
+
+#include "frm/frmConfig.h"
+#include "utils/pgconfig.h"
+
+class pgConn;
+class pgServer;
+class ctlListView;
+
+
+WX_DECLARE_OBJARRAY(pgPassConfigLine, pgPassConfigLineArray);
+
+class frmPgpassConfig : public frmConfig
+{
+public:
+    frmPgpassConfig(const wxString& title, const wxString &configFile);
+	frmPgpassConfig(frmMain *parent);
+    ~frmPgpassConfig();
+
+protected:
+    void DisplayFile(const wxString &str);
+    void WriteFile(pgConn *conn=0);
+    wxString GetHintString();
+    wxString GetHelpPage() const;
+
+private:
+    void Init();
+    void UpdateDisplay(pgPassConfigLine &line);
+
+    void OnContents(wxCommandEvent& event);
+    void OnUndo(wxCommandEvent& event);
+	void OnDelete(wxCommandEvent& event);
+    void OnEditSetting(wxListEvent& event);
+    void OnSelectSetting(wxListEvent& event);
+
+    ctlListView *listEdit;
+    pgPassConfigLineArray lines;
+
+
+    DECLARE_EVENT_TABLE()
+};
+
+class pgpassConfigFileFactory : public actionFactory
+{
+public:
+    pgpassConfigFileFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmRestore.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmRestore.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmRestore.h (revision 8187)
@@ -0,0 +1,64 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmRestore.h - Restore database dialogue
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef FRMRESTORE_H
+#define FRMRESTORE_H
+
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+class pgServer;
+class frmRestore : public ExternProcessDialog
+{
+public:
+    frmRestore(frmMain *_form, pgObject *_object);
+    ~frmRestore();
+
+    void Go();
+    wxString GetDisplayCmd(int step);
+    wxString GetCmd(int step);
+    
+private:
+    wxString GetHelpPage() const;
+    void OnChangeName(wxCommandEvent &ev);
+    void OnChange(wxCommandEvent &ev);
+    void OnSelectFilename(wxCommandEvent &ev);
+    void OnView(wxCommandEvent &ev);
+    void OnOK(wxCommandEvent &ev);
+    void OnChangeData(wxCommandEvent &ev);
+    void OnChangeSchema(wxCommandEvent &ev);
+    void OnChangeList(wxListEvent &ev);
+    void OnEndProcess(wxProcessEvent& event);
+
+    wxString getCmdPart1();
+    wxString getCmdPart2(int step);
+
+    frmMain *form;
+    pgObject *object;
+    pgServer *server;
+    bool viewRunning, filenameValid;
+    wxString processedFile;
+
+    DECLARE_EVENT_TABLE()
+};
+
+
+class restoreFactory : public contextActionFactory
+{
+public:
+    restoreFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmStatus.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmStatus.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/frm/frmStatus.h (revision 8187)
@@ -0,0 +1,197 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// frmStatus.h - Status Screen
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef __FRMSTATUS_H
+#define __FRMSTATUS_H
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/image.h>
+#include <wx/listctrl.h>
+#include <wx/spinctrl.h>
+#include <wx/notebook.h>
+
+// wxAUI
+#include <wx/aui/aui.h>
+#include <wx/aui/auibook.h>
+
+#include "dlg/dlgClasses.h"
+#include "utils/factory.h"
+
+enum
+{
+    CTL_RATECBO=250,
+    CTL_REFRESHBTN,
+    CTL_CANCELBTN,
+    CTL_TERMINATEBTN,
+    CTL_COMMITBTN,
+    CTL_ROLLBACKBTN,
+    CTL_LOGCBO,
+    CTL_ROTATEBTN,
+    CTL_STATUSLIST,
+    CTL_LOCKLIST,
+    CTL_XACTLIST,
+    CTL_LOGLIST,
+    MNU_STATUSPAGE,
+    MNU_LOCKPAGE,
+    MNU_XACTPAGE,
+    MNU_LOGPAGE,
+    MNU_TERMINATE,
+    MNU_COMMIT,
+    MNU_ROLLBACK,
+    TIMER_REFRESHUI_ID,
+    TIMER_STATUS_ID,
+    TIMER_LOCKS_ID,
+    TIMER_XACT_ID,
+    TIMER_LOG_ID
+};
+
+
+enum
+{
+    PANE_STATUS=1,
+    PANE_LOCKS,
+    PANE_XACT,
+    PANE_LOG
+};
+
+
+#define FRMSTATUS_PERSPECTIVE_VER wxT("$Rev$")
+
+#ifdef __WXMAC__
+#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=Activity;caption=Activity;state=6293500;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=321;besth=244;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=462;floaty=165;floatw=595;floath=282|name=Locks;caption=Locks;state=6293500;dir=4;layer=0;row=0;pos=1;prop=100000;bestw=321;besth=244;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-231;floaty=235;floatw=595;floath=282|name=Transactions;caption=Transactions;state=6293500;dir=4;layer=0;row=0;pos=2;prop=100000;bestw=0;besth=0;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=461;floaty=527;floatw=595;floath=282|name=Logfile;caption=Logfile;state=6293500;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=0;besth=0;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-103;floaty=351;floatw=595;floath=282|name=toolBar;caption=Tool bar;state=2124528;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=608;besth=33;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=888;floaty=829;floatw=558;floath=49|dock_size(4,0,0)=583|dock_size(5,0,0)=10|dock_size(1,10,0)=35|")
+#else
+#ifdef __WXGTK__
+#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=Activity;caption=Activity;state=6293500;dir=4;layer=0;row=0;pos=2;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=Locks;caption=Locks;state=6293500;dir=4;layer=0;row=0;pos=1;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=Transactions;caption=Transactions;state=6293500;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=Logfile;caption=Logfile;state=6293500;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=2108144;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=720;besth=31;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|dock_size(4,0,0)=549|dock_size(5,0,0)=22|dock_size(1,10,0)=33|")
+#else
+#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=Activity;caption=Activity;state=6309884;dir=4;layer=0;row=1;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=174;floaty=216;floatw=578;floath=282|name=Locks;caption=Locks;state=6293500;dir=4;layer=0;row=1;pos=1;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=136;floaty=339;floatw=576;floath=283|name=Transactions;caption=Transactions;state=6293500;dir=4;layer=0;row=1;pos=2;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=133;floaty=645;floatw=577;floath=283|name=Logfile;caption=Logfile;state=6293500;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=20;besth=20;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=toolBar;caption=Tool bar;state=2108144;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=516;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=586;floaty=525;floatw=483;floath=49|dock_size(5,0,0)=22|dock_size(1,10,0)=25|dock_size(4,0,1)=627|")
+#endif
+#endif
+
+
+static wxCriticalSection gs_critsect;
+
+
+// Class declarations
+
+class frmStatus : public pgFrame
+{
+public:
+    frmStatus(frmMain *form, const wxString& _title, pgConn *conn);
+    ~frmStatus();
+    void Go();
+    
+private:
+    wxAuiManager manager;
+    
+    frmMain *mainForm;
+    pgConn *connection;
+
+    wxString logFormat;
+    bool logHasTimestamp, logFormatKnown;
+    int logFmtPos;
+
+    wxDateTime logfileTimestamp, latestTimestamp;
+    wxString logDirectory, logfileName;
+
+    wxString savedPartialLine;
+
+    bool showCurrent, isCurrent;
+    
+    long backend_pid;
+
+	bool loaded;
+    long logfileLength;
+    
+    int currentPane;
+
+    ctlComboBoxFix    *cbRate;
+    wxComboBox    *cbLogfiles;
+    wxButton      *btnRotateLog;
+    
+    wxTimer *refreshUITimer;
+    wxTimer *statusTimer, *locksTimer, *xactTimer, *logTimer;
+    int statusRate, locksRate, xactRate, logRate;
+
+    ctlListView   *statusList;
+    ctlListView   *lockList;
+    ctlListView   *xactList;
+    ctlListView   *logList;
+    
+    int cboToRate();
+    wxString rateToCboString(int rate);
+    
+    void AddStatusPane();
+    void AddLockPane();
+    void AddXactPane();
+    void AddLogPane();
+
+    void OnHelp(wxCommandEvent& ev);
+    void OnExit(wxCommandEvent& event);
+    
+    void OnCopy(wxCommandEvent& ev);
+
+    void OnToggleStatusPane(wxCommandEvent& event);
+    void OnToggleLockPane(wxCommandEvent& event);
+    void OnToggleXactPane(wxCommandEvent& event);
+    void OnToggleLogPane(wxCommandEvent& event);
+    void OnToggleToolBar(wxCommandEvent& event);
+    void OnDefaultView(wxCommandEvent& event);
+    
+    void OnRefreshUITimer(wxTimerEvent &event);
+    void OnRefreshStatusTimer(wxTimerEvent &event);
+    void OnRefreshLocksTimer(wxTimerEvent &event);
+    void OnRefreshXactTimer(wxTimerEvent &event);
+    void OnRefreshLogTimer(wxTimerEvent &event);
+    
+    void OnRateChange(wxCommandEvent &event);
+    
+    void OnPaneClose(wxAuiManagerEvent& evt);
+
+    void OnClose(wxCloseEvent &event);
+    void OnRefresh(wxCommandEvent &event);
+    void OnCancelBtn(wxCommandEvent &event);
+    void OnStatusCancelBtn(wxCommandEvent &event);
+    void OnLocksCancelBtn(wxCommandEvent &event);
+    void OnTerminateBtn(wxCommandEvent &event);
+    void OnStatusTerminateBtn(wxCommandEvent &event);
+    void OnLocksTerminateBtn(wxCommandEvent &event);
+	void OnSelStatusItem(wxListEvent &event);
+	void OnSelLockItem(wxListEvent &event);
+    void OnSelXactItem(wxListEvent &event);
+    void OnSelLogItem(wxListEvent &event);
+	void OnLoadLogfile(wxCommandEvent &event);
+    void OnRotateLogfile(wxCommandEvent &event);
+    void OnCommit(wxCommandEvent &event);
+    void OnRollback(wxCommandEvent &event);
+
+    int fillLogfileCombo();
+    void emptyLogfileCombo();
+
+    void addLogFile(wxDateTime *dt, bool skipFirst);
+    void addLogFile(const wxString &filename, const wxDateTime timestamp, long len, long &read, bool skipFirst);
+    void addLogLine(const wxString &str, bool formatted=true, bool csv_log_format=false);
+
+	void checkConnection();
+    
+    DECLARE_EVENT_TABLE()
+};
+
+
+class serverStatusFactory : public actionFactory
+{
+public:
+    serverStatusFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar);
+    wxWindow *StartDialog(frmMain *form, pgObject *obj);
+    bool CheckEnable(pgObject *obj);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/pgSet.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/pgSet.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/pgSet.h (revision 8187)
@@ -0,0 +1,138 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// pgSet.h - PostgreSQL ResultSet class
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef PGSET_H
+#define PGSET_H
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/datetime.h>
+
+// PostgreSQL headers
+#include <libpq-fe.h>
+
+#include "utils/misc.h"
+
+typedef enum
+{
+    PGTYPCLASS_NUMERIC = 1,
+    PGTYPCLASS_BOOL,
+    PGTYPCLASS_STRING,
+    PGTYPCLASS_DATE,
+    PGTYPCLASS_OTHER
+} pgTypClass;
+
+class pgConn;
+
+// Class declarations
+class pgSet
+{
+public:
+    pgSet(PGresult *newRes, pgConn *newConn, wxMBConv &cnv, bool needColQt);
+    ~pgSet();
+    long NumRows() const { return nRows; }
+    long NumCols() const { return nCols; }
+
+    void MoveNext() { if (pos <= nRows) pos++; }
+    void MovePrevious() { if (pos > 0) pos--; }
+    void MoveFirst() { if (nRows) pos=1; else pos=0; }
+    void MoveLast() { pos=nRows; }
+    void Locate(long l) { pos=l; }
+    long CurrentPos() const { return pos; }
+    bool Bof() const { return (!nRows || pos < 1); }
+    bool Eof() const { return (!nRows || pos > nRows); }
+    wxString ColName(const int col) const;
+    OID ColTypeOid(const int col) const;
+    long ColTypeMod(const int col) const;
+    wxString ColType(const int col) const;
+    wxString ColFullType(const int col) const;
+    pgTypClass ColTypClass(const int col) const;
+
+    OID GetInsertedOid() const { return PQoidValue(res); }
+    long GetInsertedCount() const;
+    int ColSize(const int col) const { return PQfsize(res, col); }
+    bool IsNull(const int col) const { return (PQgetisnull(res, pos-1, col) != 0); }
+    int ColScale(const int col) const;
+    int ColNumber(const wxString &colName) const;
+    bool HasColumn(const wxString &colname) const;
+
+
+    wxString GetVal(const int col) const;
+    wxString GetVal(const wxString& col) const;
+    long GetLong(const int col) const;
+    long GetLong(const wxString &col) const;
+    bool GetBool(const int col) const;
+    bool GetBool(const wxString &col) const;
+    double GetDouble(const int col) const;
+    double GetDouble(const wxString &col) const;
+    wxDateTime GetDateTime(const int col) const;
+    wxDateTime GetDateTime(const wxString &col) const;
+    wxDateTime GetDate(const int col) const;
+    wxDateTime GetDate(const wxString &col) const;
+    wxULongLong GetLongLong(const int col) const;
+    wxULongLong GetLongLong(const wxString &col) const;
+    OID GetOid(const int col) const;
+    OID GetOid(const wxString &col) const;
+
+    char *GetCharPtr(const int col) const;
+    char *GetCharPtr(const wxString &col) const;
+
+    wxMBConv &GetConversion() const { return conv; }
+
+
+protected:
+    pgConn *conn;
+    PGresult *res;
+    long pos, nRows, nCols;
+    wxString ExecuteScalar(const wxString& sql) const;
+    wxMBConv &conv;
+    bool needColQuoting;
+    wxArrayString colTypes, colFullTypes;
+	wxArrayInt colClasses;
+};
+
+
+
+class pgSetIterator
+{
+public:
+    pgSetIterator(pgSet *s);
+    pgSetIterator(pgConn *conn, const wxString &sql);
+    ~pgSetIterator();
+
+    bool RowsLeft();
+    bool MovePrev();
+	bool IsValid() { return set != 0; }
+    pgSet *Set() { return set; }
+
+    wxString GetVal(const int col) const { return set->GetVal(col); }
+    wxString GetVal(const wxString& col) const { return set->GetVal(col); }
+    long GetLong(const int col) const { return set->GetLong(col); }
+	long GetLong(const wxString &col) const { return set->GetLong(col); }
+    bool GetBool(const int col) const { return set->GetBool(col); }
+    bool GetBool(const wxString &col) const { return set->GetBool(col); }
+    double GetDouble(const int col) const { return set->GetDouble(col); }
+    double GetDouble(const wxString &col) const { return set->GetDouble(col); }
+    wxDateTime GetDateTime(const int col) const { return set->GetDateTime(col); }
+    wxDateTime GetDateTime(const wxString &col) const  { return set->GetDateTime(col); }
+    wxDateTime GetDate(const int col) const { return set->GetDate(col); }
+    wxDateTime GetDate(const wxString &col) const  { return set->GetDate(col); }
+    wxULongLong GetLongLong(const int col) const { return set->GetLongLong(col); }
+    wxULongLong GetLongLong(const wxString &col) const { return set->GetLongLong(col); }
+    OID GetOid(const int col) const { return set->GetOid(col); }
+    OID GetOid(const wxString &col) const { return set->GetOid(col); }
+
+protected:
+    pgSet *set;
+    bool first;
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/pgConn.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/pgConn.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/pgConn.h (revision 8187)
@@ -0,0 +1,183 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// pgConn.h - PostgreSQL Connection class
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef PGCONN_H
+#define PGCONN_H
+
+// wxWindows headers
+#include <wx/wx.h>
+
+// PostgreSQL headers
+#include <libpq-fe.h>
+
+// App headers
+#include "pgSet.h"
+
+// status enums
+enum 
+{
+    PGCONN_OK = CONNECTION_OK,
+    PGCONN_BAD = CONNECTION_BAD,
+    PGCONN_REFUSED,
+    PGCONN_DNSERR,
+    PGCONN_ABORTED,     // connect user aborted
+    PGCONN_BROKEN       // tcp/pipe broken
+};
+
+enum 
+{
+    PGCONN_EMPTY_QUERY = PGRES_EMPTY_QUERY,
+    PGCONN_COMMAND_OK = PGRES_COMMAND_OK,
+    PGCONN_TUPLES_OK = PGRES_TUPLES_OK,
+    PGCONN_COPY_OUT = PGRES_COPY_OUT,
+    PGCONN_COPY_IN = PGRES_COPY_IN,
+    PGCONN_BAD_RESPONSE = PGRES_BAD_RESPONSE,
+    PGCONN_NONFATAL_ERROR = PGRES_NONFATAL_ERROR,
+    PGCONN_FATAL_ERROR = PGRES_FATAL_ERROR
+};
+
+enum
+{
+    PGCONN_TXSTATUS_IDLE = PQTRANS_IDLE,
+    PGCONN_TXSTATUS_ACTIVE = PQTRANS_ACTIVE,
+    PGCONN_TXSTATUS_INTRANS = PQTRANS_INTRANS,
+    PGCONN_TXSTATUS_INERROR = PQTRANS_INERROR,
+    PGCONN_TXSTATUS_UNKNOWN = PQTRANS_UNKNOWN
+};
+
+// Our version of a pgNotify
+typedef struct pgNotification {
+    wxString name;
+    int pid;
+    wxString data;
+} pgNotification;
+
+// An error record
+typedef struct pgError {
+    wxString severity;
+    wxString sql_state;
+    wxString msg_primary;
+    wxString msg_detail;
+    wxString msg_hint;
+    wxString statement_pos;
+    wxString internal_pos;
+    wxString internal_query;
+    wxString context;
+    wxString source_file;
+    wxString source_line;
+    wxString source_function;
+    wxString formatted_msg;
+} pgError;
+
+
+class pgConn
+{
+public:
+    pgConn(const wxString& server = wxT(""), const wxString& database = wxT(""), const wxString& username = wxT(""), const wxString& password = wxT(""), int port = 5432, int sslmode=0, OID oid=0);
+    ~pgConn();
+
+    bool HasPrivilege(const wxString &objTyp, const wxString &objName, const wxString &priv);
+    bool HasFeature(int feature=0);
+    bool BackendMinimumVersion(int major, int minor);
+    bool BackendMinimumVersion(int major, int minor, int patch);
+    bool EdbMinimumVersion(int major, int minor);
+    wxString SystemNamespaceRestriction(const wxString &nsp);
+    int GetMajorVersion() const { return majorVersion; }
+    int GetMinorVersion() const { return minorVersion; }
+    bool GetIsEdb();
+    bool GetIsGreenplum();
+    wxString EncryptPassword(const wxString &user, const wxString &password);
+    wxString qtDbString(const wxString& value);
+    pgConn *Duplicate();
+
+    static void ExamineLibpqVersion();
+    static double GetLibpqVersion() { return libpqVersion; }
+
+    static bool IsValidServerEncoding(int encid) { return pg_valid_server_encoding_id(encid); }
+
+    void Close();
+    bool ExecuteVoid(const wxString& sql, bool reportError = true);
+    wxString ExecuteScalar(const wxString& sql);
+    pgSet *ExecuteSet(const wxString& sql);
+    wxString GetUser() const { return wxString(PQuser(conn), *conv); }
+    wxString GetPassword() const { return wxString(PQpass(conn), *conv); }
+    wxString GetHost() const { return dbHost; }
+    wxString GetHostName() const { return dbHostName; }
+    wxString GetHostAddress() const { return dbHostAddress; }
+    wxString GetDbname() const { return dbname; }
+    wxString GetName() const;
+    bool GetNeedUtfConnectString() { return utfConnectString; }
+    int GetPort() const { return atoi(PQport(conn)); };
+    wxString GetTTY() const { return wxString(PQtty(conn), *conv); }
+    wxString GetOptions() const { return wxString(PQoptions(conn), *conv); }
+    int GetSslMode() const { return save_sslmode; }
+    wxString GetSslModeName();
+    int GetBackendPID() const { return PQbackendPID(conn); }
+    int GetStatus() const;
+    int GetLastResultStatus() const { return lastResultStatus; }
+    bool IsAlive();
+    wxString GetLastError() const;
+    pgError GetLastResultError() const { return lastResultError; }
+    wxString GetVersionString();
+    OID GetLastSystemOID() const { return lastSystemOID; }
+    OID GetDbOid() const { return dbOid; }
+    void RegisterNoticeProcessor(PQnoticeProcessor proc, void *arg);
+    wxMBConv *GetConv() { return conv; };
+
+    void LogError(const bool quiet=false);
+
+    bool IsSSLconnected();
+    PGconn *connection() { return conn; }
+    void Notice(const char *msg);
+    pgNotification *GetNotification();
+    int GetTxStatus();
+
+    bool TableHasColumn(wxString schemaname, wxString tblname, const wxString& colname);
+
+protected:
+    PGconn *conn;
+    int lastResultStatus;
+
+    int connStatus;
+
+    void SetLastResultError(PGresult *res, const wxString &msg = wxEmptyString);
+    pgError lastResultError;
+
+    wxMBConv *conv;
+    bool needColQuoting, utfConnectString;
+    wxString dbHost, dbHostName, dbHostAddress, dbname;
+    OID lastSystemOID;
+    OID dbOid;
+
+    void *noticeArg;
+    PQnoticeProcessor noticeProc;
+    static double libpqVersion;
+
+    friend class pgQueryThread;
+
+private:
+    wxString qtString(const wxString& value);
+
+    bool features[32];
+    int minorVersion, majorVersion, patchVersion;
+    bool isEdb;
+    bool isGreenplum;
+
+    wxString reservedNamespaces;
+
+    wxString save_server, save_database, save_username, save_password;
+    int save_port, save_sslmode;
+    OID save_oid;
+};
+
+#endif
+
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/pgQueryThread.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/pgQueryThread.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/pgQueryThread.h (revision 8187)
@@ -0,0 +1,53 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// pgQueryThread.h - PostgreSQL threaded query class header
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef PGQUERYTHREAD_H
+#define PGQUERYTHREAD_H
+
+class pgSet;
+
+class pgQueryThread : public wxThread
+{
+public:
+    pgQueryThread(pgConn *_conn, const wxString &qry, int resultToRetrieve=-1, wxWindow *_caller=0, long eventId=0, void *_data=0);
+    ~pgQueryThread();
+
+    virtual void *Entry();
+    bool DataValid() const { return dataSet != NULL; }
+    pgSet *DataSet() { return dataSet; }
+    int ReturnCode() const { return rc; }
+    long RowsInserted() const { return rowsInserted; }
+    OID InsertedOid() const { return insertedOid; }
+    wxString GetMessagesAndClear();
+    void appendMessage(const wxString &str);
+
+private:
+    int rc;
+    int resultToRetrieve;
+    long rowsInserted;
+    OID insertedOid;
+
+    wxString query;
+    pgConn *conn;
+    PGresult *result;
+    wxString messages;
+    pgSet *dataSet;
+    wxCriticalSection criticalSection;
+
+    void *data;
+    wxWindow *caller;
+    long eventId;
+
+    int execute();
+    int raiseEvent(int retval=0);
+};
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/module.mk
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/module.mk (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/db/module.mk (revision 8187)
@@ -0,0 +1,20 @@
+#######################################################################
+#
+# pgAdmin III - PostgreSQL Tools
+# $Id$
+# Copyright (C) 2002 - 2010, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# module.mk - pgadmin/include/db/ Makefile fragment
+#
+#######################################################################
+
+pgadmin3_SOURCES += \
+	  $(srcdir)/include/db/pgConn.h \
+	  $(srcdir)/include/db/pgQueryThread.h \
+	  $(srcdir)/include/db/pgSet.h
+
+
+EXTRA_DIST += \
+    $(srcdir)/include/db/module.mk
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgAdmin3.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgAdmin3.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgAdmin3.h (revision 8187)
@@ -0,0 +1,203 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// pgAdmin3.h - The main application header
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef PGADMIN3_H
+#define PGADMIN3_H
+
+// wxWindows headers
+#include <wx/wx.h>
+#include <wx/hashmap.h>
+#include <wx/listctrl.h>
+#include <wx/xrc/xmlres.h>
+
+#include "utils/misc.h"
+#include <ctl/ctlTree.h>
+#include "ctl/ctlSQLBox.h"
+#include "ctl/ctlListView.h"
+#include "ctl/ctlComboBox.h"
+#include "dlg/dlgClasses.h"
+#include "db/pgConn.h"
+#include "db/pgSet.h"
+#include "utils/factory.h"
+
+#include "precomp.h"
+
+// App headers
+#include "utils/sysSettings.h"
+
+#ifdef __WXMSW__
+#else
+#include "config.h"
+#undef VERSION
+#endif
+
+// Check the wxWidgets config
+#if !wxCHECK_VERSION(2, 8, 0)
+#error wxWidgets 2.8.0 or higher is required to compile this version of pgAdmin.
+#endif
+
+#if !wxUSE_UNICODE
+#error wxWidgets must be compiled with Unicode support to build pgAdmin.
+#endif
+
+// Supported server minimum and maximum values.
+const short SERVER_MIN_VERSION_N = 0x0703;
+const wxString SERVER_MIN_VERSION_T = wxT("7.3");
+const short SERVER_MAX_VERSION_N = 0x0804;
+const wxString SERVER_MAX_VERSION_T = wxT("8.4");
+
+// The registry file
+#ifndef __WXMSW__
+#define REGISTRY_FILE wxT("/etc/postgres-reg.ini")
+#endif
+
+// Some redefines for modern Microsoft compilers
+#if defined(_MSC_VER) 
+#define creat _creat
+#define close _close
+#define mkdir _mkdir
+#define sprintf _sprintf
+#define snprintf _snprintf
+#define strcat _strcat
+#define strdup _strdup
+#define stricmp _stricmp
+#define strincmp _strincmp
+#endif
+
+extern wxPathList path;                 // The search path
+extern wxString loadPath;               // Where the program is loaded from
+extern wxString docPath;                // Where docs are stored
+extern wxString uiPath;                 // Where ui data is stored
+extern wxString i18nPath;               // Where i18n data is stored
+extern wxString pluginsIni;             // The plugins ini
+extern wxString settingsIni;            // The default settings file
+
+extern sysSettings *settings;           // The settings manager
+
+extern frmMain *winMain;                // The main app window
+
+extern wxLocale *locale;                // Application locale
+extern wxArrayInt existingLangs;        // Language IDs
+extern wxArrayString existingLangNames; // Language Names
+
+// Helper app paths - PG
+extern wxString pgBackupExecutable;
+extern wxString pgBackupAllExecutable;
+extern wxString pgRestoreExecutable;
+
+// Helper app paths - EDB
+extern wxString edbBackupExecutable;
+extern wxString edbBackupAllExecutable;
+extern wxString edbRestoreExecutable;
+
+// Helper app paths - Greenplum
+extern wxString gpBackupExecutable;
+extern wxString gpBackupAllExecutable;
+extern wxString gpRestoreExecutable;
+
+// 
+// Support for additional functions included in the EnterpriseDB
+// version of libpq. These are enable via runtime loading of the
+// functions on Windows, and a configure time macro on other 
+// platforms (EDB_LIBPQ).
+//
+// Currently, these are only use to support EDB callable statements
+// so the debugger can grab OUT/INOUT parameters from EDB stored
+// procedures.
+//
+#ifdef __WXMSW__
+// Dynamically loaded PQgetOutResult
+typedef PGresult* (*PQGETOUTRESULT)(PGconn*);
+extern PQGETOUTRESULT PQiGetOutResult;
+#define PQiGetOutResult (PQiGetOutResult)
+
+// Dynamically loaded PQprepareOut
+typedef PGresult* (*PQPREPAREOUT)(PGconn*, const char*, const char*, int, const Oid*, const int*);
+extern PQPREPAREOUT PQiPrepareOut;
+#define PQiPrepareOut (PQiPrepareOut)
+
+// Dynamically loaded PQsendQueryPreparedOut
+typedef int (*PQSENDQUERYPREPAREDOUT)(PGconn*, const char*, int, const char *const *, const int *, const int *, int);
+extern PQSENDQUERYPREPAREDOUT PQiSendQueryPreparedOut;
+#define PQiSendQueryPreparedOut (PQiSendQueryPreparedOut)
+
+#else
+#ifdef EDB_LIBPQ
+#define PQiGetOutResult PQgetOutResult
+#define PQiPrepareOut PQprepareOut
+#define PQiSendQueryPreparedOut PQsendQueryPreparedOut
+#endif
+#endif
+
+// Simple hash map used as an ad-hoc data cache
+WX_DECLARE_STRING_HASH_MAP(wxString, cacheMap);
+
+// Class declarations
+class pgAdmin3 : public wxApp
+{
+public:
+    virtual bool OnInit();
+    virtual int OnExit();
+    
+#ifdef __WXMAC__
+    void MacOpenFile(const wxString &fileName); 
+#endif
+
+private:
+    wxString LocatePath(const wxString &pathToFind, const bool isFile);
+    wxString GenerateHelpPath(const wxString &file, const wxString &current, wxPathList stdPaths, wxPathList dbmsPaths);
+    bool LoadAllXrc(const wxString dir);
+
+#ifdef __WXMAC__
+    wxString macFileToOpen;
+#endif
+    
+protected:
+    void InitAppPaths();
+    void InitXtraPaths();
+    void InitHelp();
+    void InitLogger();
+    void InitNetwork();
+    void InitXml();
+};
+
+class pgAppearanceFactory
+{
+public:
+    pgAppearanceFactory();
+
+    void SetIcons(wxDialog *dlg);
+    void SetIcons(wxTopLevelWindow *dlg);
+    wxIcon GetSmallIconImage();
+    wxIcon GetBigIconImage();
+    wxBitmap GetSplashImage() { return wxBitmap(splash_image); };
+    wxFont GetSplashTextFont();
+    wxColour GetSplashTextColour() { return splash_text_colour; };
+    long GetSplashTextOffset() { return splash_pos_offset; };
+    wxPoint GetSplashTextPos() { return wxPoint(splash_pos_x, splash_pos_y); };
+    wxString GetShortAppName() { return short_appname; };
+    wxString GetLongAppName() { return long_appname; };
+    wxString GetWebsiteUrl() { return website_url; };
+    wxColour GetReportKeyColour() { return report_key_colour; };
+    bool IsBranded() { return is_branded; };
+
+private:
+    wxString long_appname, short_appname, website_url, icon;
+    wxImage large_icon, small_icon, splash_image;
+    long splash_font_size, splash_pos_x, splash_pos_y, splash_pos_offset;
+    wxColor splash_text_colour, report_key_colour;
+    bool is_branded;
+};
+
+extern pgAppearanceFactory *appearanceFactory;
+
+
+#endif // PGADMIN3_H
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/module.mk
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/module.mk (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/module.mk (revision 8187)
@@ -0,0 +1,36 @@
+#######################################################################
+#
+# pgAdmin III - PostgreSQL Tools
+# $Id$
+# Copyright (C) 2002 - 2010, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# module.mk - pgadmin/include/ Makefile fragment
+#
+#######################################################################
+
+pgadmin3_SOURCES += \
+	$(srcdir)/include/copyright.h \
+	$(srcdir)/include/pgAdmin3.h \
+	$(srcdir)/include/postgres.h \
+	$(srcdir)/include/precomp.h \
+	$(srcdir)/include/svnversion.h \
+	$(srcdir)/include/version.h
+
+EXTRA_DIST += \
+    $(srcdir)/include/module.mk
+
+include $(srcdir)/include/agent/module.mk
+include $(srcdir)/include/db/module.mk
+include $(srcdir)/include/dlg/module.mk
+include $(srcdir)/include/debugger/module.mk
+include $(srcdir)/include/ctl/module.mk
+include $(srcdir)/include/frm/module.mk
+include $(srcdir)/include/images/module.mk
+include $(srcdir)/include/parser/module.mk
+include $(srcdir)/include/pgscript/module.mk
+include $(srcdir)/include/schema/module.mk
+include $(srcdir)/include/slony/module.mk
+include $(srcdir)/include/gqb/module.mk
+include $(srcdir)/include/utils/module.mk
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/parser.tab.hh
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/parser.tab.hh (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/parser.tab.hh (revision 8187)
@@ -0,0 +1,403 @@
+/* A Bison parser, made by GNU Bison 2.3.  */
+
+/* Skeleton interface for Bison LALR(1) parsers in C++
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   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, 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., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+/* C++ LALR(1) parser skeleton written by Akim Demaille.  */
+
+#ifndef PARSER_HEADER_H
+# define PARSER_HEADER_H
+
+#include <string>
+#include <iostream>
+#include "stack.hh"
+
+namespace pgscript
+{
+  class position;
+  class location;
+}
+
+/* First part of user declarations.  */
+#line 1 "pgscript/pgsParser.yy"
+ /*** C/C++ Declarations ***/
+	
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id: pgsParser.yy,v 1.6 2008/08/10 22:11:29 pgunittest Exp $
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgscript/pgScript.h"
+#include "pgscript/statements/pgsStatements.h"
+#include "pgscript/expressions/pgsExpressions.h"
+#include "pgscript/objects/pgsObjects.h"
+#include "pgscript/utilities/pgsContext.h"
+
+
+
+/* Line 35 of lalr1.cc.  */
+#line 73 "pgscript/parser.tab.hh"
+
+#include "location.hh"
+
+/* Enabling traces.  */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages.  */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 1
+#endif
+
+/* Enabling the token table.  */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+   If N is 0, then set CURRENT to the empty location which ends
+   the previous symbol: RHS[0] (always defined).  */
+
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N)		\
+do {							\
+  if (N)						\
+    {							\
+      (Current).begin = (Rhs)[1].begin;			\
+      (Current).end   = (Rhs)[N].end;			\
+    }							\
+  else							\
+    {							\
+      (Current).begin = (Current).end = (Rhs)[0].end;	\
+    }							\
+} while (false)
+#endif
+
+namespace pgscript
+{
+
+  /// A Bison parser.
+  class pgsParser
+  {
+  public:
+    /// Symbol semantic values.
+#ifndef YYSTYPE
+    union semantic_type
+#line 106 "pgscript/pgsParser.yy"
+{
+	const wxString * str;
+	int integer;
+	pgsExpression * expr;
+	pgsStmt * stmt;
+	pgsStmtList * stmt_list;
+}
+/* Line 35 of lalr1.cc.  */
+#line 133 "pgscript/parser.tab.hh"
+	;
+#else
+    typedef YYSTYPE semantic_type;
+#endif
+    /// Symbol locations.
+    typedef location location_type;
+    /// Tokens.
+    struct token
+    {
+      /* Tokens.  */
+   enum yytokentype {
+     PGS_END = 0,
+     PGS_WHILE = 258,
+     PGS_BREAK = 259,
+     PGS_RETURN = 260,
+     PGS_CONTINUE = 261,
+     PGS_IF = 262,
+     PGS_ELSE = 263,
+     PGS_WAITFOR = 264,
+     PGS_AS = 265,
+     PGS_OPEN = 266,
+     PGS_CLOSE = 267,
+     PGS_ASSERT = 268,
+     PGS_PRINT = 269,
+     PGS_LOG = 270,
+     PGS_CNT_COLUMNS = 271,
+     PGS_CNT_LINES = 272,
+     PGS_TRIM = 273,
+     PGS_RM_LINE = 274,
+     PGS_CAST = 275,
+     PGS_RECORD = 276,
+     PGS_INTEGER = 277,
+     PGS_REAL = 278,
+     PGS_STRING = 279,
+     PGS_REGEX = 280,
+     PGS_FILE = 281,
+     PGS_DATE = 282,
+     PGS_TIME = 283,
+     PGS_DATE_TIME = 284,
+     PGS_REFERENCE = 285,
+     PGS_LE_OP = 286,
+     PGS_GE_OP = 287,
+     PGS_EQ_OP = 288,
+     PGS_AE_OP = 289,
+     PGS_NE_OP = 290,
+     PGS_AND_OP = 291,
+     PGS_OR_OP = 292,
+     PGS_NOT_OP = 293,
+     PGS_UNKNOWN = 294,
+     PGS_SET_ASSIGN = 295,
+     PGS_DECLARE_ASSGN = 296,
+     PGS_ABORT = 297,
+     PGS_ALTER = 298,
+     PGS_ANALYZE = 299,
+     PGS_BEGIN = 300,
+     PGS_CHECKPOINT = 301,
+     PGS_CLOSE_ST = 302,
+     PGS_CLUSTER = 303,
+     PGS_COMMENT = 304,
+     PGS_COMMIT = 305,
+     PGS_COPY = 306,
+     PGS_CREATE = 307,
+     PGS_DEALLOCATE = 308,
+     PGS_DECLARE = 309,
+     PGS_DELETE = 310,
+     PGS_DISCARD = 311,
+     PGS_DROP = 312,
+     PGS_END_ST = 313,
+     PGS_EXECUTE = 314,
+     PGS_EXPLAIN = 315,
+     PGS_FETCH = 316,
+     PGS_GRANT = 317,
+     PGS_INSERT = 318,
+     PGS_LISTEN = 319,
+     PGS_LOAD = 320,
+     PGS_LOCK = 321,
+     PGS_MOVE = 322,
+     PGS_NOTIFY = 323,
+     PGS_PREPARE = 324,
+     PGS_REASSIGN = 325,
+     PGS_REINDEX = 326,
+     PGS_RELEASE = 327,
+     PGS_RESET = 328,
+     PGS_REVOKE = 329,
+     PGS_ROLLBACK = 330,
+     PGS_SAVEPOINT = 331,
+     PGS_SELECT = 332,
+     PGS_SET = 333,
+     PGS_SHOW = 334,
+     PGS_START = 335,
+     PGS_TRUNCATE = 336,
+     PGS_UNLISTEN = 337,
+     PGS_UPDATE = 338,
+     PGS_VACUUM = 339,
+     PGS_VALUES = 340,
+     PGS_IDENTIFIER = 341,
+     PGS_VAL_INT = 342,
+     PGS_VAL_REAL = 343,
+     PGS_VAL_STR = 344
+   };
+
+    };
+    /// Token type.
+    typedef token::yytokentype token_type;
+
+    /// Build a parser object.
+    pgsParser (class pgsDriver & driver_yyarg);
+    virtual ~pgsParser ();
+
+    /// Parse.
+    /// \returns  0 iff parsing succeeded.
+    virtual int parse ();
+
+    /// The current debugging stream.
+    std::ostream& debug_stream () const;
+    /// Set the current debugging stream.
+    void set_debug_stream (std::ostream &);
+
+    /// Type for debugging levels.
+    typedef int debug_level_type;
+    /// The current debugging level.
+    debug_level_type debug_level () const;
+    /// Set the current debugging level.
+    void set_debug_level (debug_level_type l);
+
+  private:
+    /// Report a syntax error.
+    /// \param loc    where the syntax error is found.
+    /// \param msg    a description of the syntax error.
+    virtual void error (const location_type& loc, const std::string& msg);
+
+    /// Generate an error message.
+    /// \param state   the state where the error occurred.
+    /// \param tok     the look-ahead token.
+    virtual std::string yysyntax_error_ (int yystate, int tok);
+
+#if YYDEBUG
+    /// \brief Report a symbol value on the debug stream.
+    /// \param yytype       The token type.
+    /// \param yyvaluep     Its semantic value.
+    /// \param yylocationp  Its location.
+    virtual void yy_symbol_value_print_ (int yytype,
+					 const semantic_type* yyvaluep,
+					 const location_type* yylocationp);
+    /// \brief Report a symbol on the debug stream.
+    /// \param yytype       The token type.
+    /// \param yyvaluep     Its semantic value.
+    /// \param yylocationp  Its location.
+    virtual void yy_symbol_print_ (int yytype,
+				   const semantic_type* yyvaluep,
+				   const location_type* yylocationp);
+#endif /* ! YYDEBUG */
+
+
+    /// State numbers.
+    typedef int state_type;
+    /// State stack type.
+    typedef stack<state_type>    state_stack_type;
+    /// Semantic value stack type.
+    typedef stack<semantic_type> semantic_stack_type;
+    /// location stack type.
+    typedef stack<location_type> location_stack_type;
+
+    /// The state stack.
+    state_stack_type yystate_stack_;
+    /// The semantic value stack.
+    semantic_stack_type yysemantic_stack_;
+    /// The location stack.
+    location_stack_type yylocation_stack_;
+
+    /// Internal symbol numbers.
+    typedef unsigned char token_number_type;
+    /* Tables.  */
+    /// For a state, the index in \a yytable_ of its portion.
+    static const short int yypact_[];
+    static const signed char yypact_ninf_;
+
+    /// For a state, default rule to reduce.
+    /// Unless\a  yytable_ specifies something else to do.
+    /// Zero means the default is an error.
+    static const unsigned char yydefact_[];
+
+    static const short int yypgoto_[];
+    static const short int yydefgoto_[];
+
+    /// What to do in a state.
+    /// \a yytable_[yypact_[s]]: what to do in state \a s.
+    /// - if positive, shift that token.
+    /// - if negative, reduce the rule which number is the opposite.
+    /// - if zero, do what YYDEFACT says.
+    static const unsigned short int yytable_[];
+    static const signed char yytable_ninf_;
+
+    static const short int yycheck_[];
+
+    /// For a state, its accessing symbol.
+    static const unsigned char yystos_[];
+
+    /// For a rule, its LHS.
+    static const unsigned char yyr1_[];
+    /// For a rule, its RHS length.
+    static const unsigned char yyr2_[];
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+    /// For a symbol, its name in clear.
+    static const char* const yytname_[];
+#endif
+
+#if YYERROR_VERBOSE
+    /// Convert the symbol name \a n to a form suitable for a diagnostic.
+    virtual std::string yytnamerr_ (const char *n);
+#endif
+
+#if YYDEBUG
+    /// A type to store symbol numbers and -1.
+    typedef short int rhs_number_type;
+    /// A `-1'-separated list of the rules' RHS.
+    static const rhs_number_type yyrhs_[];
+    /// For each rule, the index of the first RHS symbol in \a yyrhs_.
+    static const unsigned short int yyprhs_[];
+    /// For each rule, its source line number.
+    static const unsigned short int yyrline_[];
+    /// For each scanner token number, its symbol number.
+    static const unsigned short int yytoken_number_[];
+    /// Report on the debug stream that the rule \a r is going to be reduced.
+    virtual void yy_reduce_print_ (int r);
+    /// Print the state stack on the debug stream.
+    virtual void yystack_print_ ();
+#endif
+
+    /// Convert a scanner token number \a t to a symbol number.
+    token_number_type yytranslate_ (int t);
+
+    /// \brief Reclaim the memory associated to a symbol.
+    /// \param yymsg        Why this token is reclaimed.
+    /// \param yytype       The symbol type.
+    /// \param yyvaluep     Its semantic value.
+    /// \param yylocationp  Its location.
+    inline void yydestruct_ (const char* yymsg,
+			     int yytype,
+			     semantic_type* yyvaluep,
+			     location_type* yylocationp);
+
+    /// Pop \a n symbols the three stacks.
+    inline void yypop_ (unsigned int n = 1);
+
+    /* Constants.  */
+    static const int yyeof_;
+    /* LAST_ -- Last index in TABLE_.  */
+    static const int yylast_;
+    static const int yynnts_;
+    static const int yyempty_;
+    static const int yyfinal_;
+    static const int yyterror_;
+    static const int yyerrcode_;
+    static const int yyntokens_;
+    static const unsigned int yyuser_token_number_max_;
+    static const token_number_type yyundef_token_;
+
+    /* Debugging.  */
+    int yydebug_;
+    std::ostream* yycdebug_;
+
+
+    /* User arguments.  */
+    class pgsDriver & driver;
+  };
+}
+
+
+#endif /* ! defined PARSER_HEADER_H */
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsParameterException.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsParameterException.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsParameterException.h (revision 8187)
@@ -0,0 +1,34 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSPARAMETEREXCEPTION_H_
+#define PGSPARAMETEREXCEPTION_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/exceptions/pgsException.h"
+
+class pgsParameterException : public pgsException
+{
+	
+protected:
+	
+	const wxString m_message;
+	
+public:
+	
+	pgsParameterException(const wxString & message = wxT("unknown"));
+	
+	virtual ~pgsParameterException();
+	
+	virtual const wxString message() const;
+	
+};
+
+#endif /*PGSPARAMETEREXCEPTION_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsAssertException.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsAssertException.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsAssertException.h (revision 8187)
@@ -0,0 +1,34 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSASSERTEXCEPTION_H_
+#define PGSASSERTEXCEPTION_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/exceptions/pgsException.h"
+
+class pgsAssertException : public pgsException
+{
+	
+protected:
+		
+	const wxString m_message;
+	
+public:
+	
+	pgsAssertException(const wxString & message);
+	
+	virtual ~pgsAssertException();
+	
+	virtual const wxString message() const;
+	
+};
+
+#endif /*PGSASSERTEXCEPTION_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsBreakException.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsBreakException.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsBreakException.h (revision 8187)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSBREAKEXCEPTION_H_
+#define PGSBREAKEXCEPTION_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/exceptions/pgsException.h"
+
+class pgsBreakException : public pgsException
+{
+	
+public:
+	
+	pgsBreakException();
+	
+	virtual ~pgsBreakException();
+	
+	virtual const wxString message() const;
+	
+};
+
+#endif /*PGSBREAKEXCEPTION_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsContinueException.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsContinueException.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsContinueException.h (revision 8187)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSCONTINUEEXCEPTION_H_
+#define PGSCONTINUEEXCEPTION_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/exceptions/pgsException.h"
+
+class pgsContinueException : public pgsException
+{
+	
+public:
+	
+	pgsContinueException();
+	
+	virtual ~pgsContinueException();
+	
+	virtual const wxString message() const;
+	
+};
+
+#endif /*PGSCONTINUEEXCEPTION_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsArithmeticException.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsArithmeticException.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsArithmeticException.h (revision 8187)
@@ -0,0 +1,35 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSARITHMETICEXCEPTION_H_
+#define PGSARITHMETICEXCEPTION_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/exceptions/pgsException.h"
+
+class pgsArithmeticException : public pgsException
+{
+	
+protected:
+	
+	const wxString m_left;
+	const wxString m_right;
+	
+public:
+	
+	pgsArithmeticException(const wxString & left, const wxString & right);
+	
+	virtual ~pgsArithmeticException();
+	
+	virtual const wxString message() const;
+	
+};
+
+#endif /*PGSARITHMETICEXCEPTION_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsCastException.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsCastException.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsCastException.h (revision 8187)
@@ -0,0 +1,35 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSCASTEXCEPTION_H_
+#define PGSCASTEXCEPTION_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/exceptions/pgsException.h"
+
+class pgsCastException : public pgsException
+{
+	
+protected:
+	
+	const wxString m_value;
+	const wxString m_type;
+	
+public:
+	
+	pgsCastException(const wxString & value, const wxString & type);
+	
+	virtual ~pgsCastException();
+	
+	virtual const wxString message() const;
+	
+};
+
+#endif /*PGSCASTEXCEPTION_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/module.mk
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/module.mk (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/module.mk (revision 8187)
@@ -0,0 +1,24 @@
+#######################################################################
+#
+# pgAdmin III - PostgreSQL Tools
+# $Id$
+# Copyright (C) 2002 - 2010, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# module.mk - pgadmin/include/pgscript/exceptions/ Makefile fragment
+#
+#######################################################################
+
+pgadmin3_SOURCES += \
+	$(srcdir)/include/pgscript/exceptions/pgsArithmeticException.h \
+	$(srcdir)/include/pgscript/exceptions/pgsAssertException.h \
+	$(srcdir)/include/pgscript/exceptions/pgsBreakException.h \
+	$(srcdir)/include/pgscript/exceptions/pgsCastException.h \
+	$(srcdir)/include/pgscript/exceptions/pgsContinueException.h \
+	$(srcdir)/include/pgscript/exceptions/pgsException.h \
+	$(srcdir)/include/pgscript/exceptions/pgsInterruptException.h \
+	$(srcdir)/include/pgscript/exceptions/pgsParameterException.h
+
+EXTRA_DIST += \
+	$(srcdir)/include/pgscript/exceptions/module.mk
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsInterruptException.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsInterruptException.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsInterruptException.h (revision 8187)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSINTERRUPTEXCEPTION_H_
+#define PGSINTERRUPTEXCEPTION_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/exceptions/pgsException.h"
+
+class pgsInterruptException : public pgsException
+{
+	
+public:
+	
+	pgsInterruptException();
+	
+	virtual ~pgsInterruptException();
+	
+	virtual const wxString message() const;
+	
+};
+
+#endif /*PGSINTERRUPTEXCEPTION_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsException.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsException.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/exceptions/pgsException.h (revision 8187)
@@ -0,0 +1,31 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSEXCEPTION_H_
+#define PGSEXCEPTION_H_
+
+#include "pgscript/pgScript.h"
+
+class pgsException
+{
+	
+protected:
+	
+	pgsException();
+	
+public:
+	
+	virtual ~pgsException();
+	
+	virtual const wxString message() const = 0;
+	
+};
+
+#endif /*PGSEXCEPTION_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/pgScript.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/pgScript.h (revision 7664)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/pgScript.h (revision 7664)
@@ -0,0 +1,45 @@
+#ifndef PGSNITTEST_H_
+#define PGSNITTEST_H_
+
+/*** TYPEDEFS ***/
+
+typedef unsigned char UCHAR;
+typedef unsigned short int USHORT;
+
+/*** DEFINES ***/
+
+#define pgsReal true
+#define pgsInt false
+
+/*** PGADMIN ***/
+
+#include "pgAdmin3.h"
+
+/*** INCLUDES ***/
+
+#if defined(HAVE_CONFIG_H) && defined(PGSCLI)
+#include "config.h"
+#endif
+
+#include <wx/wx.h>
+
+/*** OUTPUT ***/
+
+#include <wx/txtstrm.h>
+#define pgsOutputStream wxTextOutputStream
+
+const wxString PGSOUTPGSCRIPT (wxT("[PGSCRIPT ] "));
+const wxString PGSOUTEXCEPTION(wxT("[EXCEPTION] "));
+const wxString PGSOUTQUERY    (wxT("[QUERY    ] "));
+const wxString PGSOUTWARNING  (wxT("[WARNING  ] "));
+const wxString PGSOUTERROR    (wxT("[ERROR    ] "));
+
+/*** LOGGING ***/
+
+#include "utils/sysLogger.h"
+
+/*** MEMORY LEAK DETECTION ***/
+
+#include "pgscript/utilities/pgsAlloc.h"
+
+#endif /*PGSNITTEST_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGreaterEqual.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGreaterEqual.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGreaterEqual.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSGREATEREQUAL_H_
+#define PGSGREATEREQUAL_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsGreaterEqual : public pgsOperation
+{
+	
+public:
+
+	pgsGreaterEqual(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsGreaterEqual();
+
+	virtual pgsExpression * clone() const;
+
+	pgsGreaterEqual(const pgsGreaterEqual & that);
+
+	pgsGreaterEqual & operator =(const pgsGreaterEqual & that);
+
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSGREATEREQUAL_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsTimes.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsTimes.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsTimes.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSTIMES_H_
+#define PGSTIMES_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsTimes : public pgsOperation
+{
+	
+public:
+
+	pgsTimes(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsTimes();
+
+	virtual pgsExpression * clone() const;
+	
+	pgsTimes(const pgsTimes & that);
+
+	pgsTimes & operator =(const pgsTimes & that);
+	
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSTIMES_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsPlus.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsPlus.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsPlus.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSPLUS_H_
+#define PGSPLUS_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsPlus : public pgsOperation
+{
+	
+public:
+
+	pgsPlus(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsPlus();
+
+	virtual pgsExpression * clone() const;
+	
+	pgsPlus(const pgsPlus & that);
+
+	pgsPlus & operator =(const pgsPlus & that);
+	
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSPLUS_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsAssign.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsAssign.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsAssign.h (revision 8187)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSASSIGN_H_
+#define PGSASSIGN_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsAssign : public pgsExpression
+{
+
+protected:
+
+	wxString m_name;
+	const pgsExpression * m_var;
+
+public:
+
+	pgsAssign(const wxString & name, const pgsExpression * var);
+
+	virtual ~pgsAssign();
+
+	pgsAssign(const pgsAssign & that);
+
+	pgsAssign & operator=(const pgsAssign & that);
+	
+	virtual pgsExpression * clone() const;
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSASSIGN_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsParenthesis.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsParenthesis.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsParenthesis.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSPARENTHESIS_H_
+#define PGSPARENTHESIS_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsParenthesis : public pgsOperation
+{
+	
+public:
+
+	pgsParenthesis(const pgsExpression * left);
+
+	virtual ~pgsParenthesis();
+
+	virtual pgsExpression * clone() const;
+
+	pgsParenthesis(const pgsParenthesis & that);
+
+	pgsParenthesis & operator =(const pgsParenthesis & that);
+
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSPARENTHESIS_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsAssignToRecord.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsAssignToRecord.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsAssignToRecord.h (revision 8187)
@@ -0,0 +1,44 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSASSIGNTORECORD_H_
+#define PGSASSIGNTORECORD_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsAssign.h"
+
+class pgsAssignToRecord : public pgsAssign
+{
+
+private:
+
+	const pgsExpression * m_line;
+	const pgsExpression * m_column;
+
+public:
+
+	pgsAssignToRecord(const wxString & name, const pgsExpression * line,
+			const pgsExpression * column, const pgsExpression * var);
+
+	virtual ~pgsAssignToRecord();
+	
+	pgsAssignToRecord(const pgsAssignToRecord & that);
+
+	pgsAssignToRecord & operator=(const pgsAssignToRecord & that);
+	
+	virtual pgsExpression * clone() const;
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSASSIGNTORECORD_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsLower.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsLower.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsLower.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSLOWER_H_
+#define PGSLOWER_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsLower : public pgsOperation
+{
+	
+public:
+
+	pgsLower(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsLower();
+
+	virtual pgsExpression * clone() const;
+
+	pgsLower(const pgsLower & that);
+
+	pgsLower & operator =(const pgsLower & that);
+
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSLOWER_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenReference.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenReference.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenReference.h (revision 8187)
@@ -0,0 +1,53 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSGENREFERENCE_H_
+#define PGSGENREFERENCE_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsThread;
+
+class pgsGenReference : public pgsExpression
+{
+
+private:
+
+	const pgsExpression * m_table;
+	const pgsExpression * m_column;
+	const pgsExpression * m_sequence;
+	const pgsExpression * m_seed;
+	
+	pgsThread * m_app;
+
+public:
+
+	pgsGenReference(const pgsExpression * table, const pgsExpression * column,
+			const pgsExpression * sequence, const pgsExpression * seed,
+			pgsThread * app = 0);
+
+	virtual ~pgsGenReference();
+
+	virtual pgsExpression * clone() const;
+
+	pgsGenReference(const pgsGenReference & that);
+
+	pgsGenReference & operator =(const pgsGenReference & that);
+
+public:
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSGENREFERENCE_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGreater.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGreater.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGreater.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSGREATER_H_
+#define PGSGREATER_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsGreater : public pgsOperation
+{
+	
+public:
+
+	pgsGreater(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsGreater();
+
+	virtual pgsExpression * clone() const;
+
+	pgsGreater(const pgsGreater & that);
+
+	pgsGreater & operator =(const pgsGreater & that);
+
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSGREATER_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsCast.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsCast.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsCast.h (revision 8187)
@@ -0,0 +1,46 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSCAST_H_
+#define PGSCAST_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsCast : public pgsExpression
+{
+
+private:
+
+	int m_cast_type;
+	
+	const pgsExpression * m_var;
+
+public:
+
+	pgsCast(const int & cast_type, const pgsExpression * var);
+
+	virtual ~pgsCast();
+	
+	virtual pgsExpression * clone() const;
+
+	pgsCast(const pgsCast & that);
+
+	pgsCast & operator=(const pgsCast & that);
+	
+public:
+	
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSCAST_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsMinus.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsMinus.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsMinus.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSMINUS_H_
+#define PGSMINUS_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsMinus : public pgsOperation
+{
+	
+public:
+
+	pgsMinus(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsMinus();
+
+	virtual pgsExpression * clone() const;
+
+	pgsMinus(const pgsMinus & that);
+
+	pgsMinus & operator =(const pgsMinus & that);
+
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSMINUS_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/module.mk
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/module.mk (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/module.mk (revision 8187)
@@ -0,0 +1,54 @@
+#######################################################################
+#
+# pgAdmin III - PostgreSQL Tools
+# $Id$
+# Copyright (C) 2002 - 2010, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# module.mk - pgadmin/include/pgscript/expressions/ Makefile fragment
+#
+#######################################################################
+
+pgadmin3_SOURCES += \
+	$(srcdir)/include/pgscript/expressions/pgsAnd.h \
+	$(srcdir)/include/pgscript/expressions/pgsAssign.h \
+	$(srcdir)/include/pgscript/expressions/pgsAssignToRecord.h \
+	$(srcdir)/include/pgscript/expressions/pgsCast.h \
+	$(srcdir)/include/pgscript/expressions/pgsColumns.h \
+	$(srcdir)/include/pgscript/expressions/pgsDifferent.h \
+	$(srcdir)/include/pgscript/expressions/pgsEqual.h \
+	$(srcdir)/include/pgscript/expressions/pgsExecute.h \
+	$(srcdir)/include/pgscript/expressions/pgsExpression.h \
+	$(srcdir)/include/pgscript/expressions/pgsExpressions.h \
+	$(srcdir)/include/pgscript/expressions/pgsGenDate.h \
+	$(srcdir)/include/pgscript/expressions/pgsGenDateTime.h \
+	$(srcdir)/include/pgscript/expressions/pgsGenDictionary.h \
+	$(srcdir)/include/pgscript/expressions/pgsGenInt.h \
+	$(srcdir)/include/pgscript/expressions/pgsGenReal.h \
+	$(srcdir)/include/pgscript/expressions/pgsGenReference.h \
+	$(srcdir)/include/pgscript/expressions/pgsGenRegex.h \
+	$(srcdir)/include/pgscript/expressions/pgsGenString.h \
+	$(srcdir)/include/pgscript/expressions/pgsGenTime.h \
+	$(srcdir)/include/pgscript/expressions/pgsGreater.h \
+	$(srcdir)/include/pgscript/expressions/pgsGreaterEqual.h \
+	$(srcdir)/include/pgscript/expressions/pgsIdent.h \
+	$(srcdir)/include/pgscript/expressions/pgsIdentRecord.h \
+	$(srcdir)/include/pgscript/expressions/pgsLines.h \
+	$(srcdir)/include/pgscript/expressions/pgsLower.h \
+	$(srcdir)/include/pgscript/expressions/pgsLowerEqual.h \
+	$(srcdir)/include/pgscript/expressions/pgsMinus.h \
+	$(srcdir)/include/pgscript/expressions/pgsModulo.h \
+	$(srcdir)/include/pgscript/expressions/pgsNegate.h \
+	$(srcdir)/include/pgscript/expressions/pgsNot.h \
+	$(srcdir)/include/pgscript/expressions/pgsOperation.h \
+	$(srcdir)/include/pgscript/expressions/pgsOr.h \
+	$(srcdir)/include/pgscript/expressions/pgsOver.h \
+	$(srcdir)/include/pgscript/expressions/pgsParenthesis.h \
+	$(srcdir)/include/pgscript/expressions/pgsPlus.h \
+	$(srcdir)/include/pgscript/expressions/pgsRemoveLine.h \
+	$(srcdir)/include/pgscript/expressions/pgsTimes.h \
+	$(srcdir)/include/pgscript/expressions/pgsTrim.h
+
+EXTRA_DIST += \
+	$(srcdir)/include/pgscript/expressions/module.mk
+
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsModulo.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsModulo.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsModulo.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSMODULO_H_
+#define PGSMODULO_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsModulo : public pgsOperation
+{
+	
+public:
+
+	pgsModulo(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsModulo();
+
+	virtual pgsExpression * clone() const;
+
+	pgsModulo(const pgsModulo & that);
+
+	pgsModulo & operator =(const pgsModulo & that);
+	
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSMODULO_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenDictionary.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenDictionary.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenDictionary.h (revision 8187)
@@ -0,0 +1,49 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSGENDICTIONARY_H_
+#define PGSGENDICTIONARY_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsGenDictionary : public pgsExpression
+{
+
+private:
+
+	const pgsExpression * m_file_path;
+	const pgsExpression * m_sequence;
+	const pgsExpression * m_seed;
+	const pgsExpression * m_wx_conv;
+
+public:
+
+	pgsGenDictionary(const pgsExpression * file_path,
+			const pgsExpression * sequence,
+			const pgsExpression * seed, const pgsExpression * wx_conv);
+
+	virtual ~pgsGenDictionary();
+
+	virtual pgsExpression * clone() const;
+
+	pgsGenDictionary(const pgsGenDictionary & that);
+
+	pgsGenDictionary & operator =(const pgsGenDictionary & that);
+
+public:
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSGENDICTIONARY_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenString.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenString.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenString.h (revision 8187)
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSGENSTRING_H_
+#define PGSGENSTRING_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsGenString : public pgsExpression
+{
+
+private:
+
+	const pgsExpression * m_min;
+	const pgsExpression * m_max;
+	const pgsExpression * m_nb_words;
+	const pgsExpression * m_seed;
+
+public:
+
+	pgsGenString(const pgsExpression * min, const pgsExpression * max,
+			const pgsExpression * nb_words, const pgsExpression * seed);
+
+	virtual ~pgsGenString();
+
+	virtual pgsExpression * clone() const;
+
+	pgsGenString(const pgsGenString & that);
+
+	pgsGenString & operator =(const pgsGenString & that);
+
+public:
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSGENSTRING_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsOperation.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsOperation.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsOperation.h (revision 8187)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSOPERATION_H_
+#define PGSOPERATION_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsOperation : public pgsExpression
+{
+
+protected:
+
+	const pgsExpression * m_left;
+	const pgsExpression * m_right;
+
+public:
+
+	pgsOperation(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsOperation();
+
+	virtual pgsExpression * clone() const = 0;
+
+	pgsOperation(const pgsOperation & that);
+
+	pgsOperation & operator =(const pgsOperation & that);
+	
+	virtual wxString value() const = 0;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const = 0;
+
+};
+
+#endif /*PGSOPERATION_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsNot.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsNot.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsNot.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSNOT_H_
+#define PGSNOT_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsNot : public pgsOperation
+{
+	
+public:
+
+	pgsNot(const pgsExpression * left);
+
+	virtual ~pgsNot();
+
+	virtual pgsExpression * clone() const;
+
+	pgsNot(const pgsNot & that);
+
+	pgsNot & operator =(const pgsNot & that);
+
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSNOT_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsAnd.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsAnd.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsAnd.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSAND_H_
+#define PGSAND_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsAnd : public pgsOperation
+{
+	
+public:
+
+	pgsAnd(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsAnd();
+
+	virtual pgsExpression * clone() const;
+
+	pgsAnd(const pgsAnd & that);
+
+	pgsAnd & operator =(const pgsAnd & that);
+
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSAND_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsRemoveLine.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsRemoveLine.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsRemoveLine.h (revision 8187)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSREMOVELINE_H_
+#define PGSREMOVELINE_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsRemoveLine : public pgsExpression
+{
+
+private:
+
+	wxString m_rec;
+	const pgsExpression * m_line;
+
+public:
+
+	pgsRemoveLine(const wxString & rec, const pgsExpression * line);
+
+	virtual ~pgsRemoveLine();
+
+	pgsRemoveLine(const pgsRemoveLine & that);
+
+	pgsRemoveLine & operator=(const pgsRemoveLine & that);
+	
+	virtual pgsExpression * clone() const;
+	
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSREMOVELINE_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsOver.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsOver.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsOver.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSOVER_H_
+#define PGSOVER_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsOver : public pgsOperation
+{
+	
+public:
+
+	pgsOver(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsOver();
+
+	virtual pgsExpression * clone() const;
+	
+	pgsOver(const pgsOver & that);
+
+	pgsOver & operator =(const pgsOver & that);
+	
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSOVER_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenReal.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenReal.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenReal.h (revision 8187)
@@ -0,0 +1,50 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSGENREAL_H_
+#define PGSGENREAL_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsGenReal : public pgsExpression
+{
+
+private:
+
+	const pgsExpression * m_min;
+	const pgsExpression * m_max;
+	const pgsExpression * m_precision;
+	const pgsExpression * m_sequence;
+	const pgsExpression * m_seed;
+
+public:
+
+	pgsGenReal(const pgsExpression * min, const pgsExpression * max,
+			const pgsExpression * precision,
+			const pgsExpression * sequence, const pgsExpression * seed);
+
+	virtual ~pgsGenReal();
+
+	virtual pgsExpression * clone() const;
+
+	pgsGenReal(const pgsGenReal & that);
+
+	pgsGenReal & operator =(const pgsGenReal & that);
+
+public:
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSGENREAL_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsOr.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsOr.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsOr.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSOR_H_
+#define PGSOR_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsOr : public pgsOperation
+{
+	
+public:
+
+	pgsOr(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsOr();
+
+	virtual pgsExpression * clone() const;
+
+	pgsOr(const pgsOr & that);
+
+	pgsOr & operator =(const pgsOr & that);
+
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSOR_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsColumns.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsColumns.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsColumns.h (revision 8187)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSCOLUMNS_H_
+#define PGSCOLUMNS_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsColumns : public pgsExpression
+{
+	
+private:
+	
+	wxString m_name;
+	
+public:
+
+	pgsColumns(const wxString & name);
+
+	virtual ~pgsColumns();
+
+	/* pgsColumns(const pgsColumns & that); */
+
+	/* pgsColumns & operator=(const pgsColumns & that); */
+
+	virtual pgsExpression * clone() const;
+	
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSCOLUMNS_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsLowerEqual.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsLowerEqual.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsLowerEqual.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSLOWEREQUAL_H_
+#define PGSLOWEREQUAL_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsLowerEqual : public pgsOperation
+{
+	
+public:
+
+	pgsLowerEqual(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsLowerEqual();
+
+	virtual pgsExpression * clone() const;
+
+	pgsLowerEqual(const pgsLowerEqual & that);
+
+	pgsLowerEqual & operator =(const pgsLowerEqual & that);
+
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSLOWEREQUAL_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsExpressions.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsExpressions.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsExpressions.h (revision 8187)
@@ -0,0 +1,52 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSEXPRESSIONS_H_
+#define PGSEXPRESSIONS_H_
+
+#include "pgsAnd.h"
+#include "pgsAssign.h"
+#include "pgsAssignToRecord.h"
+#include "pgsCast.h"
+#include "pgsColumns.h"
+#include "pgsDifferent.h"
+#include "pgsEqual.h"
+#include "pgsExecute.h"
+#include "pgsExpression.h"
+#include "pgsGenDate.h"
+#include "pgsGenDateTime.h"
+#include "pgsGenDictionary.h"
+#include "pgsGenInt.h"
+#include "pgsGenReal.h"
+#include "pgsGenReference.h"
+#include "pgsGenRegex.h"
+#include "pgsGenString.h"
+#include "pgsGenTime.h"
+#include "pgsGreater.h"
+#include "pgsGreaterEqual.h"
+#include "pgsIdent.h"
+#include "pgsIdentRecord.h"
+#include "pgsLines.h"
+#include "pgsLower.h"
+#include "pgsLowerEqual.h"
+#include "pgsMinus.h"
+#include "pgsModulo.h"
+#include "pgsNegate.h"
+#include "pgsNot.h"
+#include "pgsOperation.h"
+#include "pgsOr.h"
+#include "pgsOver.h"
+#include "pgsParenthesis.h"
+#include "pgsPlus.h"
+#include "pgsRemoveLine.h"
+#include "pgsTimes.h"
+#include "pgsTrim.h"
+
+#endif /*PGSEXPRESSIONS_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenInt.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenInt.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenInt.h (revision 8187)
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSGENINT_H_
+#define PGSGENINT_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsGenInt : public pgsExpression
+{
+
+private:
+
+	const pgsExpression * m_min;
+	const pgsExpression * m_max;
+	const pgsExpression * m_sequence;
+	const pgsExpression * m_seed;
+
+public:
+
+	pgsGenInt(const pgsExpression * min, const pgsExpression * max,
+			const pgsExpression * sequence, const pgsExpression * seed);
+
+	virtual ~pgsGenInt();
+
+	virtual pgsExpression * clone() const;
+
+	pgsGenInt(const pgsGenInt & that);
+
+	pgsGenInt & operator =(const pgsGenInt & that);
+
+public:
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSGENINT_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenDateTime.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenDateTime.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenDateTime.h (revision 8187)
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSGENDATETIME_H_
+#define PGSGENDATETIME_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsGenDateTime : public pgsExpression
+{
+
+private:
+
+	const pgsExpression * m_min;
+	const pgsExpression * m_max;
+	const pgsExpression * m_sequence;
+	const pgsExpression * m_seed;
+
+public:
+
+	pgsGenDateTime(const pgsExpression * min, const pgsExpression * max,
+			const pgsExpression * sequence, const pgsExpression * seed);
+
+	virtual ~pgsGenDateTime();
+
+	virtual pgsExpression * clone() const;
+
+	pgsGenDateTime(const pgsGenDateTime & that);
+
+	pgsGenDateTime & operator =(const pgsGenDateTime & that);
+
+public:
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSGENDATETIME_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenTime.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenTime.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenTime.h (revision 8187)
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSGENTIME_H_
+#define PGSGENTIME_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsGenTime : public pgsExpression
+{
+
+private:
+
+	const pgsExpression * m_min;
+	const pgsExpression * m_max;
+	const pgsExpression * m_sequence;
+	const pgsExpression * m_seed;
+
+public:
+
+	pgsGenTime(const pgsExpression * min, const pgsExpression * max,
+			const pgsExpression * sequence, const pgsExpression * seed);
+
+	virtual ~pgsGenTime();
+
+	virtual pgsExpression * clone() const;
+
+	pgsGenTime(const pgsGenTime & that);
+
+	pgsGenTime & operator =(const pgsGenTime & that);
+
+public:
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSGENTIME_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsExpression.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsExpression.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsExpression.h (revision 8187)
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSEXPRESSION_H_
+#define PGSEXPRESSION_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/utilities/pgsCopiedPtr.h"
+
+class pgsProgram;
+class pgsVariable;
+
+WX_DECLARE_STRING_HASH_MAP(pgsCopiedPtr<pgsVariable>, pgsVarMap);
+typedef pgsCopiedPtr<pgsVariable> pgsOperand;
+
+class pgsExpression
+{
+
+protected:
+
+	pgsExpression();
+
+public:
+
+	virtual ~pgsExpression();
+
+	virtual pgsExpression * clone() const = 0;
+
+	/* pgsExpression(const pgsExpression & that); */
+
+	/* pgsExpression & operator =(const pgsExpression & that); */
+
+public:
+
+	virtual wxString value() const = 0;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const = 0;
+	
+};
+
+#endif /*PGSEXPRESSION_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsExecute.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsExecute.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsExecute.h (revision 8187)
@@ -0,0 +1,50 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSEXECUTE_H_
+#define PGSEXECUTE_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsOutputStream;
+class pgsThread;
+
+class pgsExecute : public pgsExpression
+{
+
+private:
+
+	wxString m_query;
+	
+	pgsOutputStream * m_cout;
+	
+	pgsThread * m_app;
+
+public:
+
+	pgsExecute(const wxString & query, pgsOutputStream * cout = 0,
+			pgsThread * app = 0);
+
+	virtual ~pgsExecute();
+
+	/* pgsExecute(const pgsExecute & that); */
+
+	pgsExecute & operator=(const pgsExecute & that);
+
+	virtual pgsExpression * clone() const;
+	
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSEXECUTE_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsIdentRecord.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsIdentRecord.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsIdentRecord.h (revision 8187)
@@ -0,0 +1,44 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSIDENTRECORD_H_
+#define PGSIDENTRECORD_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsIdent.h"
+
+class pgsIdentRecord : public pgsIdent
+{
+
+private:
+
+	const pgsExpression * m_line;
+	const pgsExpression * m_column;
+
+public:
+
+	pgsIdentRecord(const wxString & name, const pgsExpression * line,
+			const pgsExpression * column = 0);
+
+	virtual ~pgsIdentRecord();
+
+	pgsIdentRecord(const pgsIdentRecord & that);
+
+	pgsIdentRecord & operator=(const pgsIdentRecord & that);
+
+	virtual pgsExpression * clone() const;
+	
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSIDENTRECORD_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsNegate.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsNegate.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsNegate.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSNEGATE_H_
+#define PGSNEGATE_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsNegate : public pgsOperation
+{
+	
+public:
+
+	pgsNegate(const pgsExpression * left);
+
+	virtual ~pgsNegate();
+
+	virtual pgsExpression * clone() const;
+
+	pgsNegate(const pgsNegate & that);
+
+	pgsNegate & operator =(const pgsNegate & that);
+
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSNEGATE_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsIdent.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsIdent.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsIdent.h (revision 8187)
@@ -0,0 +1,46 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSIDENT_H_
+#define PGSIDENT_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsIdent : public pgsExpression
+{
+
+protected:
+
+	wxString m_name;
+
+public:
+
+	pgsIdent(const wxString & name);
+
+	virtual ~pgsIdent();
+
+	/* pgsIdent(const pgsIdent & that); */
+
+	/* pgsIdent & operator=(const pgsIdent & that); */
+
+	virtual pgsExpression * clone() const;
+	
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+public:
+	
+	static const wxString m_now;
+
+};
+
+#endif /*PGSIDENT_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenRegex.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenRegex.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenRegex.h (revision 8187)
@@ -0,0 +1,45 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSGENREGEX_H_
+#define PGSGENREGEX_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsGenRegex : public pgsExpression
+{
+
+private:
+
+	const pgsExpression * m_regex;
+	const pgsExpression * m_seed;
+
+public:
+
+	pgsGenRegex(const pgsExpression * regex, const pgsExpression * seed);
+
+	virtual ~pgsGenRegex();
+
+	virtual pgsExpression * clone() const;
+
+	pgsGenRegex(const pgsGenRegex & that);
+
+	pgsGenRegex & operator =(const pgsGenRegex & that);
+
+public:
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSGENREGEX_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsDifferent.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsDifferent.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsDifferent.h (revision 8187)
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSDIFFERENT_H_
+#define PGSDIFFERENT_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsDifferent : public pgsOperation
+{
+
+public:
+
+	pgsDifferent(const pgsExpression * left, const pgsExpression * right);
+
+	virtual ~pgsDifferent();
+
+	virtual pgsExpression * clone() const;
+
+	pgsDifferent(const pgsDifferent & that);
+
+	pgsDifferent & operator =(const pgsDifferent & that);
+
+	virtual wxString value() const;
+	
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSDIFFERENT_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsEqual.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsEqual.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsEqual.h (revision 8187)
@@ -0,0 +1,43 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSEQUAL_H_
+#define PGSEQUAL_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsOperation.h"
+
+class pgsEqual : public pgsOperation
+{
+	
+private:
+	
+	bool m_case_sensitive;
+
+public:
+
+	pgsEqual(const pgsExpression * left, const pgsExpression * right,
+			bool case_sensitive = true);
+
+	virtual ~pgsEqual();
+
+	virtual pgsExpression * clone() const;
+
+	pgsEqual(const pgsEqual & that);
+
+	pgsEqual & operator =(const pgsEqual & that);
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSEQUAL_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenDate.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenDate.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsGenDate.h (revision 8187)
@@ -0,0 +1,48 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSGENDATE_H_
+#define PGSGENDATE_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsGenDate : public pgsExpression
+{
+
+private:
+
+	const pgsExpression * m_min;
+	const pgsExpression * m_max;
+	const pgsExpression * m_sequence;
+	const pgsExpression * m_seed;
+
+public:
+
+	pgsGenDate(const pgsExpression * min, const pgsExpression * max,
+			const pgsExpression * sequence, const pgsExpression * seed);
+
+	virtual ~pgsGenDate();
+
+	virtual pgsExpression * clone() const;
+
+	pgsGenDate(const pgsGenDate & that);
+
+	pgsGenDate & operator =(const pgsGenDate & that);
+
+public:
+
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+
+};
+
+#endif /*PGSGENDATE_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsLines.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsLines.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsLines.h (revision 8187)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSLINES_H_
+#define PGSLINES_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsLines : public pgsExpression
+{
+	
+private:
+	
+	wxString m_name;
+	
+public:
+
+	pgsLines(const wxString & name);
+
+	virtual ~pgsLines();
+
+	/* pgsLines(const pgsLines & that); */
+
+	/* pgsLines & operator=(const pgsLines & that); */
+
+	virtual pgsExpression * clone() const;
+	
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSLINES_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsTrim.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsTrim.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/expressions/pgsTrim.h (revision 8187)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSTRIM_H_
+#define PGSTRIM_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/expressions/pgsExpression.h"
+
+class pgsTrim : public pgsExpression
+{
+	
+private:
+	
+	const pgsExpression * m_exp;
+	
+public:
+
+	pgsTrim(const pgsExpression * exp);
+
+	virtual ~pgsTrim();
+
+	pgsTrim(const pgsTrim & that);
+
+	pgsTrim & operator=(const pgsTrim & that);
+
+	virtual pgsExpression * clone() const;
+	
+	virtual wxString value() const;
+
+	virtual pgsOperand eval(pgsVarMap & vars) const;
+	
+};
+
+#endif /*PGSTRIM_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/position.hh
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/position.hh (revision 7464)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/position.hh (revision 7464)
@@ -0,0 +1,142 @@
+/* A Bison parser, made by GNU Bison 2.3.  */
+
+/* Positions for Bison parsers in C++
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   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, 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., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+/**
+ ** \file position.hh
+ ** Define the pgscript::position class.
+ */
+
+#ifndef BISON_POSITION_HH
+# define BISON_POSITION_HH
+
+# include <iostream>
+# include <string>
+
+namespace pgscript
+{
+  /// Abstract a position.
+  class position
+  {
+  public:
+
+    /// Construct a position.
+    position ()
+      : filename (0), line (1), column (0)
+    {
+    }
+
+
+    /// Initialization.
+    inline void initialize (std::string* fn)
+    {
+      filename = fn;
+      line = 1;
+      column = 0;
+    }
+
+    /** \name Line and Column related manipulators
+     ** \{ */
+  public:
+    /// (line related) Advance to the COUNT next lines.
+    inline void lines (int count = 1)
+    {
+      column = 0;
+      line += count;
+    }
+
+    /// (column related) Advance to the COUNT next columns.
+    inline void columns (int count = 1)
+    {
+      int leftmost = 0;
+      int current  = column;
+      if (leftmost <= current + count)
+	column += count;
+      else
+	column = 0;
+    }
+    /** \} */
+
+  public:
+    /// File name to which this position refers.
+    std::string* filename;
+    /// Current line number.
+    unsigned int line;
+    /// Current column number.
+    unsigned int column;
+  };
+
+  /// Add and assign a position.
+  inline const position&
+  operator+= (position& res, const int width)
+  {
+    res.columns (width);
+    return res;
+  }
+
+  /// Add two position objects.
+  inline const position
+  operator+ (const position& begin, const int width)
+  {
+    position res = begin;
+    return res += width;
+  }
+
+  /// Add and assign a position.
+  inline const position&
+  operator-= (position& res, const int width)
+  {
+    return res += -width;
+  }
+
+  /// Add two position objects.
+  inline const position
+  operator- (const position& begin, const int width)
+  {
+    return begin + -width;
+  }
+
+  /** \brief Intercept output stream redirection.
+   ** \param ostr the destination output stream
+   ** \param pos a reference to the position to redirect
+   */
+  inline std::ostream&
+  operator<< (std::ostream& ostr, const position& pos)
+  {
+    if (pos.filename)
+      ostr << *pos.filename << ':';
+    return ostr << pos.line << '.' << pos.column;
+  }
+
+}
+#endif // not BISON_POSITION_HH
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/pgsApplication.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/pgsApplication.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/pgsApplication.h (revision 8187)
@@ -0,0 +1,128 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSAPP_H_
+#define PGSAPP_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/utilities/pgsThread.h"
+
+class pgsApplication
+{
+	
+public:
+	
+	static const int default_port = 5432;
+	
+private:
+	
+	/** Global symbol table shared between different runs. */
+	pgsVarMap m_vars;
+	
+	/** In order to have only one thread at once. */
+	wxSemaphore m_mutex;
+	
+	/** Protects stream accesses. */
+	wxSemaphore m_stream;
+	
+	/** Connection to the database. */
+	pgConn * m_connection;
+	
+	/** Is m_connection provided in the constructor or has it been created. */
+	bool m_defined_conn;
+	
+	/** Detached thread running a pgScript (parses a file or a string). */
+	pgsThread * m_thread;
+	
+	/** pgAdmin specific: post an event to this window when m_thread is done. */
+	wxWindow * m_caller;
+	
+	/** pgAdmin specific: post this event when m_thread is done. */
+	long m_event_id;
+	
+	/** Location of the last error if there was one. */
+	int m_last_error_line;
+	
+public:
+	
+	/** Creates an application and creates a connection. */
+	pgsApplication(const wxString & host, const wxString & database,
+			const wxString & user, const wxString & password, int port = default_port);
+	
+	/** Creates an application and uses an existing connection. This connection
+	 * is not deleted when the application is deleted. */
+	pgsApplication(pgConn * connection);
+	
+	/** Deletes custom connection if one was created (first constructor). */
+	~pgsApplication();
+	
+	/** Parses a file by creating a new thread. */
+	bool ParseFile(const wxString & file, pgsOutputStream & out,
+			wxMBConv * conv = &wxConvLocal);
+	
+	/** Parses a string by creating a new thread. */
+	bool ParseString(const wxString & string, pgsOutputStream & out);
+	
+	/** Is m_thread running? */
+	bool IsRunning();
+	
+	/** If m_thread is running then wait for it to terminate. */
+	void Wait();
+	
+	/** If m_thread is running then delete it. */
+	void Terminate();
+	
+	/** Called by m_thread when the thread is finished: IsRunning() becomes
+	 * false and m_event_id is pushed into the event queue if m_caller exists. */
+	void Complete();
+	
+	/** Uses a new database connection instead of the previous one. If the
+	 * previous one was user-defined then it is deleted otherwise it is just
+	 * replaced with the new one. */
+	void SetConnection(pgConn * conn);
+	
+	/** Deletes everything in the symbol table. */
+	void ClearSymbols();
+	
+#if !defined(PGSCLI)
+	/** Used in pgAdmin integration for sending an event to the caller when the
+	 * thread is finishing its task. */
+	void SetCaller(wxWindow * caller, long event_id);
+#endif // PGSCLI
+	
+	/** Tells whether the database connection is valid. */
+	bool IsConnectionValid() const;
+	
+	/** Gets a lock on the output stream. */
+	void LockOutput();
+	
+	/** Releases the lock on the output stream. */
+	void UnlockOutput();
+	
+	/** Was there an error? */
+	bool errorOccurred() const;
+	
+	/** Get the position (line) of the last error. */
+	int errorLine() const;
+	
+private:
+	
+	/** Common method for parse_file & parse_string: runs the thread. */
+	bool RunThread();
+	
+private:
+
+	pgsApplication(const pgsApplication & that);
+
+	pgsApplication & operator=(const pgsApplication & that);
+	
+};
+
+#endif /*PGSAPP_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/stack.hh
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/stack.hh (revision 8034)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/stack.hh (revision 8034)
@@ -0,0 +1,152 @@
+/* A Bison parser, made by GNU Bison 2.3.  */
+
+/* Stack handling for Bison parsers in C++
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   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, 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., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+#ifndef BISON_STACK_HH
+# define BISON_STACK_HH
+
+/* The Sun compiler defines _T, which conflicts with wxWidgets, so
+   we must un-define it if needed. */
+#if defined(__SUNPRO_CC)
+#ifdef _T
+#undef _T
+#define _T_is_defined
+#endif
+#endif /*__SUNPRO_CC */
+
+#include <deque>
+
+namespace pgscript
+{
+  template <class T, class S = std::deque<T> >
+  class stack
+  {
+  public:
+
+    // Hide our reversed order.
+    typedef typename S::reverse_iterator iterator;
+    typedef typename S::const_reverse_iterator const_iterator;
+
+    stack () : seq_ ()
+    {
+    }
+
+    stack (unsigned int n) : seq_ (n)
+    {
+    }
+
+    inline
+    T&
+    operator [] (unsigned int i)
+    {
+      return seq_[i];
+    }
+
+    inline
+    const T&
+    operator [] (unsigned int i) const
+    {
+      return seq_[i];
+    }
+
+    inline
+    void
+    push (const T& t)
+    {
+      seq_.push_front (t);
+    }
+
+    inline
+    void
+    pop (unsigned int n = 1)
+    {
+      for (; n; --n)
+	seq_.pop_front ();
+    }
+
+    inline
+    unsigned int
+    height () const
+    {
+      return seq_.size ();
+    }
+
+    inline const_iterator begin () const { return seq_.rbegin (); }
+    inline const_iterator end () const { return seq_.rend (); }
+
+  private:
+
+    S seq_;
+  };
+
+  /// Present a slice of the top of a stack.
+  template <class T, class S = stack<T> >
+  class slice
+  {
+  public:
+
+    slice (const S& stack,
+	   unsigned int range) : stack_ (stack),
+				 range_ (range)
+    {
+    }
+
+    inline
+    const T&
+    operator [] (unsigned int i) const
+    {
+      return stack_[range_ - i];
+    }
+
+  private:
+
+    const S& stack_;
+    unsigned int range_;
+  };
+}
+
+/* Redefine _T if we un-defined it for the Sun compiler. */
+#if defined(__SUNPRO_CC)
+#ifdef _T_is_defined
+#undef _T_is_defined
+/* we need to define it back only if _T already was defined. */
+#if !wxUSE_UNICODE
+#define _T(x) x
+#else /* Unicode */
+/* use wxCONCAT_HELPER so that x could be expanded if it's a macro */
+#define _T(x) wxCONCAT_HELPER(L, x)
+#endif /* ASCII/Unicode */
+#endif /* T_is_defined */
+#endif /*__SUNPRO_CC */
+
+#endif // not BISON_STACK_HH
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/FlexLexer.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/FlexLexer.h (revision 7465)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/FlexLexer.h (revision 7465)
@@ -0,0 +1,204 @@
+// -*-C++-*-
+// FlexLexer.h -- define interfaces for lexical analyzer classes generated
+// by flex
+
+// Copyright (c) 1993 The Regents of the University of California.
+// All rights reserved.
+//
+// This code is derived from software contributed to Berkeley by
+// Kent Williams and Tom Epperly.
+//
+//  Redistribution and use in source and binary forms, with or without
+//  modification, are permitted provided that the following conditions
+//  are met:
+
+//  1. Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//  2. Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+
+//  Neither the name of the University nor the names of its contributors
+//  may be used to endorse or promote products derived from this software
+//  without specific prior written permission.
+
+//  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+//  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+//  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+//  PURPOSE.
+
+// This file defines FlexLexer, an abstract class which specifies the
+// external interface provided to flex C++ lexer objects, and yyFlexLexer,
+// which defines a particular lexer class.
+//
+// If you want to create multiple lexer classes, you use the -P flag
+// to rename each yyFlexLexer to some other xxFlexLexer.  You then
+// include <FlexLexer.h> in your other sources once per lexer class:
+//
+//	#undef yyFlexLexer
+//	#define yyFlexLexer xxFlexLexer
+//	#include <FlexLexer.h>
+//
+//	#undef yyFlexLexer
+//	#define yyFlexLexer zzFlexLexer
+//	#include <FlexLexer.h>
+//	...
+
+#ifndef __FLEX_LEXER_H
+// Never included before - need to define base class.
+#define __FLEX_LEXER_H
+
+#include <iostream>
+#  ifndef FLEX_STD
+#    define FLEX_STD std::
+#  endif
+
+extern "C++" {
+
+struct yy_buffer_state;
+typedef int yy_state_type;
+
+class FlexLexer {
+public:
+	virtual ~FlexLexer()	{ }
+
+	const char* YYText()	{ return yytext; }
+	int YYLeng()		{ return yyleng; }
+
+	virtual void
+		yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
+	virtual struct yy_buffer_state*
+		yy_create_buffer( FLEX_STD istream* s, int size ) = 0;
+	virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
+	virtual void yyrestart( FLEX_STD istream* s ) = 0;
+
+	virtual int yylex() = 0;
+
+	// Call yylex with new input/output sources.
+	int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 )
+		{
+		switch_streams( new_in, new_out );
+		return yylex();
+		}
+
+	// Switch to new input/output streams.  A nil stream pointer
+	// indicates "keep the current one".
+	virtual void switch_streams( FLEX_STD istream* new_in = 0,
+					FLEX_STD ostream* new_out = 0 ) = 0;
+
+	int lineno() const		{ return yylineno; }
+
+	int debug() const		{ return yy_flex_debug; }
+	void set_debug( int flag )	{ yy_flex_debug = flag; }
+
+protected:
+	char* yytext;
+	int yyleng;
+	int yylineno;		// only maintained if you use %option yylineno
+	int yy_flex_debug;	// only has effect with -d or "%option debug"
+};
+
+}
+#endif
+
+#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
+// Either this is the first time through (yyFlexLexerOnce not defined),
+// or this is a repeated include to define a different flavor of
+// yyFlexLexer, as discussed in the flex man page.
+#define yyFlexLexerOnce
+
+extern "C++" {
+
+class yyFlexLexer : public FlexLexer {
+public:
+	// arg_yyin and arg_yyout default to the cin and cout, but we
+	// only make that assignment when initializing in yylex().
+	yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 );
+
+	virtual ~yyFlexLexer();
+
+	void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
+	struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size );
+	void yy_delete_buffer( struct yy_buffer_state* b );
+	void yyrestart( FLEX_STD istream* s );
+
+    void yypush_buffer_state( struct yy_buffer_state* new_buffer );
+    void yypop_buffer_state(void);
+
+	virtual int yylex();
+	virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out );
+
+protected:
+	virtual int LexerInput( char* buf, int max_size );
+	virtual void LexerOutput( const char* buf, int size );
+	virtual void LexerError( const char* msg );
+
+	void yyunput( int c, char* buf_ptr );
+	int yyinput();
+
+	void yy_load_buffer_state();
+	void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s );
+	void yy_flush_buffer( struct yy_buffer_state* b );
+
+	int yy_start_stack_ptr;
+	int yy_start_stack_depth;
+	int* yy_start_stack;
+
+	void yy_push_state( int new_state );
+	void yy_pop_state();
+	int yy_top_state();
+
+	yy_state_type yy_get_previous_state();
+	yy_state_type yy_try_NUL_trans( yy_state_type current_state );
+	int yy_get_next_buffer();
+
+	FLEX_STD istream* yyin;	// input source for default LexerInput
+	FLEX_STD ostream* yyout;	// output sink for default LexerOutput
+
+	// yy_hold_char holds the character lost when yytext is formed.
+	char yy_hold_char;
+
+	// Number of characters read into yy_ch_buf.
+	int yy_n_chars;
+
+	// Points to current character in buffer.
+	char* yy_c_buf_p;
+
+	int yy_init;		// whether we need to initialize
+	int yy_start;		// start state number
+
+	// Flag which is used to allow yywrap()'s to do buffer switches
+	// instead of setting up a fresh yyin.  A bit of a hack ...
+	int yy_did_buffer_switch_on_eof;
+
+
+    size_t yy_buffer_stack_top; /**< index of top of stack. */
+    size_t yy_buffer_stack_max; /**< capacity of stack. */
+    struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
+    void yyensure_buffer_stack(void);
+
+	// The following are not always needed, but may be depending
+	// on use of certain flex features (like REJECT or yymore()).
+
+	yy_state_type yy_last_accepting_state;
+	char* yy_last_accepting_cpos;
+
+	yy_state_type* yy_state_buf;
+	yy_state_type* yy_state_ptr;
+
+	char* yy_full_match;
+	int* yy_full_state;
+	int yy_full_lp;
+
+	int yy_lp;
+	int yy_looking_for_trail_begin;
+
+	int yy_more_flag;
+	int yy_more_len;
+	int yy_more_offset;
+	int yy_prev_more_offset;
+};
+
+}
+
+#endif
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/location.hh
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/location.hh (revision 7464)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/location.hh (revision 7464)
@@ -0,0 +1,145 @@
+/* A Bison parser, made by GNU Bison 2.3.  */
+
+/* Locations for Bison parsers in C++
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   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, 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., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+/**
+ ** \file location.hh
+ ** Define the pgscript::location class.
+ */
+
+#ifndef BISON_LOCATION_HH
+# define BISON_LOCATION_HH
+
+# include <iostream>
+# include <string>
+# include "position.hh"
+
+namespace pgscript
+{
+
+  /// Abstract a location.
+  class location
+  {
+  public:
+
+    /// Construct a location.
+    location ()
+      : begin (), end ()
+    {
+    }
+
+
+    /// Initialization.
+    inline void initialize (std::string* fn)
+    {
+      begin.initialize (fn);
+      end = begin;
+    }
+
+    /** \name Line and Column related manipulators
+     ** \{ */
+  public:
+    /// Reset initial location to final location.
+    inline void step ()
+    {
+      begin = end;
+    }
+
+    /// Extend the current location to the COUNT next columns.
+    inline void columns (unsigned int count = 1)
+    {
+      end += count;
+    }
+
+    /// Extend the current location to the COUNT next lines.
+    inline void lines (unsigned int count = 1)
+    {
+      end.lines (count);
+    }
+    /** \} */
+
+
+  public:
+    /// Beginning of the located region.
+    position begin;
+    /// End of the located region.
+    position end;
+  };
+
+  /// Join two location objects to create a location.
+  inline const location operator+ (const location& begin, const location& end)
+  {
+    location res = begin;
+    res.end = end.end;
+    return res;
+  }
+
+  /// Add two location objects.
+  inline const location operator+ (const location& begin, unsigned int width)
+  {
+    location res = begin;
+    res.columns (width);
+    return res;
+  }
+
+  /// Add and assign a location.
+  inline location& operator+= (location& res, unsigned int width)
+  {
+    res.columns (width);
+    return res;
+  }
+
+  /** \brief Intercept output stream redirection.
+   ** \param ostr the destination output stream
+   ** \param loc a reference to the location to redirect
+   **
+   ** Avoid duplicate information.
+   */
+  inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
+  {
+    position last = loc.end - 1;
+    ostr << loc.begin;
+    if (last.filename
+	&& (!loc.begin.filename
+	    || *loc.begin.filename != *last.filename))
+      ostr << '-' << last;
+    else if (loc.begin.line != last.line)
+      ostr << '-' << last.line  << '.' << last.column;
+    else if (loc.begin.column != last.column)
+      ostr << '-' << last.column;
+    return ostr;
+  }
+
+}
+
+#endif // not BISON_LOCATION_HH
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/statements/pgsWhileStmt.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/statements/pgsWhileStmt.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/statements/pgsWhileStmt.h (revision 8187)
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSWHILESTMT_H_
+#define PGSWHILESTMT_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/statements/pgsStmt.h"
+
+class pgsWhileStmt : public pgsStmt
+{
+
+private:
+
+	const pgsExpression * m_cond;
+	const pgsStmt * m_stmt_list;
+
+public:
+
+	pgsWhileStmt(const pgsExpression * cond, const pgsStmt * stmt_list,
+			pgsThread * app = 0);
+
+	virtual ~pgsWhileStmt();
+
+	virtual void eval(pgsVarMap & vars) const;
+
+private:
+
+	pgsWhileStmt(const pgsWhileStmt & that);
+
+	pgsWhileStmt & operator=(const pgsWhileStmt & that);
+
+};
+
+#endif /*PGSWHILESTMT_H_*/
Index: /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/statements/pgsStmtList.h
===================================================================
--- /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/statements/pgsStmtList.h (revision 8187)
+++ /tags/REL-1_10_2/pgadmin3/pgadmin/include/pgscript/statements/pgsStmtList.h (revision 8187)
@@ -0,0 +1,52 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgScript - PostgreSQL Tools
+// RCS-ID:      $Id$
+// Copyright (C) 2002 - 2010, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef PGSSTMTLIST_H_
+#define PGSSTMTLIST_H_
+
+#include "pgscript/pgScript.h"
+#include "pgscript/statements/pgsStmt.h"
+
