Hi Guillaume,

PFA.

Right click on GQB will popup a menu (Refresh).
This will adjust the size of the scroll windows, if the table's size goes
beyond the current size.

1200x800 is the default minimum size of the scrolled window defined by the
constants:
*#define GQB_MIN_WIDTH  1280*
*#define GQB_MIN_HEIGHT 800*
*
*
I tried adding the same code, when adding a new table/view.
But, if I select a table for next to get created (by double click on
left-side tree) and then press left clicks few times, the application is
crashing.. Hence, just added this code to work with the pop-up menu. :-(

--
Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise Postgres Company<http://www.enterprisedb.com>


On Mon, Apr 12, 2010 at 1:04 PM, Guillaume Lelarge
<guilla...@lelarge.info>wrote:

> Hi Ashesh,
>
> Le 12/04/2010 03:44, Ashesh Vashi a écrit :
> > Hi Guillaume,
> >
> > On Sat, Apr 10, 2010 at 2:40 PM, Guillaume Lelarge
> > <guilla...@lelarge.info>wrote:
> >
> >> Le 17/03/2010 12:34, Guillaume Lelarge a écrit :
> >>> Le 16/03/2010 17:29, Michael Haltrecht a écrit :
> >>>> Even when I rotate my monitor (so it's taller than wider), I can't
> >> scroll to
> >>>> access past the 55th field.
> >>>> The window scroll bars don't seem to take into account the actual size
> >> of
> >>>> the table.
> >>>>
> >>>> This is still an issue in 1.10.2
> >>>>
> >>>
> >>> I added this in our bugtracker :
> http://code.pgadmin.org/trac/ticket/151
> >>>
> >>> Thanks for your report.
> >>>
> >>
> >> I reproduce this quite easily. In fact, we don't have scroll bars in
> >> tables' graphic representation and 55 fields is the maximum number of
> >> fields we can render on the canvas. So, you're right, you can't see past
> >> the 55th field.
> >>
> >> A simple way to fix this would be to have a bigger canvas. A smarter way
> >> to fix this would be to have a growable canvas. The better way would be
> >> to have a growable canvas and resizable tables' graphic representation.
> >>
> >> Ashesh, is there something we can do on this issue?
> >>
> >
> > I have sent a fix for the same for the same in my The-print-support.
> > But, It was never got revisited. :-(
> >
> > If you want, I can resend a patch, which takes care about this only..
> >
>
> If you can do so, yes, that would be great.
>
> Thanks.
>
>
> --
> Guillaume.
>  http://www.postgresqlfr.org
>  http://dalibo.com
>
Index: include/gqb/gqbEvents.h
===================================================================
--- include/gqb/gqbEvents.h	(revision 8266)
+++ include/gqb/gqbEvents.h	(working copy)
@@ -24,6 +24,7 @@
     GQB_RMJ_DELETE = 2000,
     GQB_RMJ_SETTYPE,
     GQB_RMT_DELETE,
-    GQB_RMT_SETALIAS
+    GQB_RMT_SETALIAS,
+    GQB_REFRESH
 };
 #endif
Index: include/gqb/gqbViewController.h
===================================================================
--- include/gqb/gqbViewController.h	(revision 8266)
+++ include/gqb/gqbViewController.h	(working copy)
@@ -30,6 +30,9 @@
 #include "gqb/gqbGridJoinTable.h"
 #include "gqb/gqbBrowser.h"
 
+#define GQB_MIN_WIDTH  1280
+#define GQB_MIN_HEIGHT 800
+
 class gqbView;
 
 enum pointerMode
@@ -124,29 +127,30 @@
     void newTableAdded(gqbQueryObject *item);
     bool clickOnJoin (gqbQueryJoin *join, wxPoint &pt, wxPoint &origin, wxPoint &dest);
     void updateTable(gqbQueryObject *table);
+    const wxSize& getModelSize() { return modelSize; }
 
-	// Functions for all gqb extra Panels (projection, criteria..)
+    // Functions for all gqb extra Panels (projection, criteria..)
     void emptyPanelsData();
 
 private:
-    gqbController *controller;									// owned by caller application shouldn't be destroy 
-																// by this class
-    gqbModel *model;											// owned by caller application shouldn't be destroy 
-																// by this class
-    gqbGraphBehavior *graphBehavior;							// This points to the Graph behavior for objects, 
-																// if change the way objects were draw changes too.
-    gqbIteratorBase *iterator;									//include here for reuse of iterator, should be 
-																// delete when class destroy
+    gqbController *controller;                                  // owned by caller application shouldn't be destroy 
+                                                                // by this class
+    gqbModel *model;                                            // owned by caller application shouldn't be destroy 
+                                                                // by this class
+    gqbGraphBehavior *graphBehavior;                            // This points to the Graph behavior for objects, 
+                                                                // if change the way objects were draw changes too.
+    gqbIteratorBase *iterator;                                  //include here for reuse of iterator, should be 
+                                                                // delete when class destroy
     wxPanel *projectionPanel, *criteriaPanel, *orderPanel, *joinsPanel;
-    gqbGridProjTable *gridTable;								// Data model for the columns grid internals
-    gqbGridRestTable *restrictionsGridTable;					// Data model for restricions grid internals
-    gqbGridJoinTable *joinsGridTable;                            // Data model for joins grid internals
+    gqbGridProjTable *gridTable;                                // Data model for the columns grid internals
+    gqbGridRestTable *restrictionsGridTable;                    // Data model for restricions grid internals
+    gqbGridJoinTable *joinsGridTable;                           // Data model for joins grid internals
                           
-    gqbGridOrderTable *orderByLGridTable, *orderByRGridTable;	// Data model for order by grid internals
-    wxSize canvasSize;
+    gqbGridOrderTable *orderByLGridTable, *orderByRGridTable;   // Data model for order by grid internals
+    wxSize canvasSize, modelSize;
     bool changeTOpressed;
     
-	// just a point to the selected item on the collection, shouldn't be destroy inside this class
+    // just a point to the selected item on the collection, shouldn't be destroy inside this class
     gqbQueryObject *collectionSelected, *joinSource, *joinDest, *cTempSelected;
     gqbQueryJoin *joinSelected, *jTempSelected;
     gqbColumn *joinSCol, *joinDCol;
@@ -155,11 +159,15 @@
     pointerMode mode;             // pointer is used as normally or as in joins by example
     wxImage joinCursorImage;
     wxCursor joinCursor;
-    wxMenu *m_rightJoins, *m_rightTables;
+    wxMenu *m_rightJoins, *m_rightTables, *m_gqbPopup;
     void OnMenuJoinDelete(wxCommandEvent& event);
     void OnMenuTableDelete(wxCommandEvent& event);
     void OnMenuTableSetAlias(wxCommandEvent& event);
+    void OnRefresh(wxCommandEvent& ev);
+    void updateModelSize(gqbQueryObject* obj, bool updateAnyWay);
+
     wxArrayString joinTypeChoices;
+
     DECLARE_EVENT_TABLE()
 };
 
Index: frm/frmQuery.cpp
===================================================================
--- frm/frmQuery.cpp	(revision 8266)
+++ frm/frmQuery.cpp	(working copy)
@@ -467,7 +467,7 @@
     // Graphical Canvas
     // initialize values
     model=new gqbModel();
-    controller = new gqbController(model,sqlNotebook, outputPane, wxSize(1280,800));
+    controller = new gqbController(model,sqlNotebook, outputPane, wxSize(GQB_MIN_WIDTH, GQB_MIN_HEIGHT));
     firstTime=true;                               // Inform to GQB that the tree of table haven't filled.
     gqbUpdateRunning = false;                      // Are we already updating the SQL query - event recursion protection.
     adjustSizesTimer=NULL;                        // Timer used to avoid a bug when close outputPane
Index: gqb/gqbView.cpp
===================================================================
--- gqb/gqbView.cpp	(revision 8266)
+++ gqb/gqbView.cpp	(working copy)
@@ -47,6 +47,7 @@
 EVT_MENU(GQB_RMJ_DELETE,	gqbView::OnMenuJoinDelete)
 EVT_MENU(GQB_RMT_DELETE,	gqbView::OnMenuTableDelete)
 EVT_MENU(GQB_RMT_SETALIAS,	gqbView::OnMenuTableSetAlias)
+EVT_MENU(GQB_REFRESH,           gqbView::OnRefresh)
 END_EVENT_TABLE()
 
 gqbView::gqbView(wxWindow *gqbParent, wxNotebook *gridParent, wxSize size, gqbController *controller, gqbModel *model)
@@ -72,6 +73,7 @@
     joinCursor= wxCursor(joinCursorImage);
     m_rightJoins=NULL;
     m_rightTables=NULL;
+    m_gqbPopup=NULL;
     jTempSelected=NULL;
     cTempSelected=NULL;
 
@@ -117,6 +119,9 @@
 
     if(m_rightJoins)
         delete m_rightJoins;
+
+    if (m_gqbPopup)
+        delete m_gqbPopup;
 }
 
 
@@ -154,6 +159,9 @@
                 m_rightTables = new wxMenu;
                 m_rightTables->Append(GQB_RMT_SETALIAS, _("&Set Alias for table"));
                 m_rightTables->Append(GQB_RMT_DELETE, _("&Delete Table"));
+                m_rightTables->AppendSeparator();
+                m_rightTables->Append(GQB_REFRESH, _("&Refresh"));
+
             }
             cTempSelected=(gqbQueryObject *) (gqbObjectCollection *) anySelected;
             jTempSelected=NULL;
@@ -166,12 +174,23 @@
             {
                 m_rightJoins = new wxMenu;
                 m_rightJoins->Append(GQB_RMJ_DELETE, _("&Delete Join"));
+                m_rightJoins->AppendSeparator();
+                m_rightJoins->Append(GQB_REFRESH, _("&Refresh"));
             }
             cTempSelected=NULL;
             jTempSelected=(gqbQueryJoin *) anySelected;;
             PopupMenu(m_rightJoins, event.GetPosition());
         }
     }
+    else
+    {
+        if(!m_gqbPopup)
+        {
+            m_gqbPopup = new wxMenu;
+            m_gqbPopup->Append(GQB_REFRESH, _("&Refresh"));
+        }
+        PopupMenu(m_gqbPopup, event.GetPosition());
+    }
 }
 
 
@@ -645,3 +664,87 @@
     this->Refresh();
 }
 
+
+void gqbView::OnRefresh(wxCommandEvent& ev)
+{
+    updateModelSize(NULL, true);
+    this->Update();
+}
+
+
+/*
+*  updateModelSize
+*     - Update the model size.
+*     - Calculate the maximum width and maximum height of the model
+*  * When removed a table/view from model, the obj parameter must be null,
+*    and update parameter should be true, otherwise update parameter should
+*    be false (Dragging event)
+*/
+void gqbView::updateModelSize(gqbQueryObject* obj, bool updateAnyWay)
+{
+    static int callCount = 0;
+    callCount++;
+    if (!obj)
+    {
+        // Do not update model size, everytime it gets called
+        // Update the size once in 10 times
+        // Update the size only if update flag is true
+        if (callCount < 10 && !updateAnyWay)
+            return;
+        callCount = 0;
+        // Figure out the actual model size.
+        // Remove table
+        int w = 0, h = 0, maxW = 0, maxH = 0;
+        if(!iterator)
+            // Get an iterator for the objects (tables/views) in the model.
+            iterator = this->model->createQueryIterator();
+        else
+            iterator->ResetIterator();
+    
+        while (iterator->HasNext())
+        {
+            gqbQueryObject *tmp= (gqbQueryObject *)iterator->Next();;
+            w = tmp->position.x + tmp->getWidth();
+            h = tmp->position.y + tmp->getHeight();
+    
+            if (maxW < w)
+                maxW = w;
+            if (maxH < h)
+                maxH = h;
+        }
+ 
+        // Reset Model size
+        modelSize.Set(maxW, maxH);
+    }
+    else
+    {
+        int w = 0, h = 0;
+        w = obj->position.x + obj->getWidth();
+        h = obj->position.y + obj->getHeight();
+
+        if (w > modelSize.GetWidth())
+            modelSize.SetWidth(w);
+        if (h > modelSize.GetHeight())
+            modelSize.SetHeight(h);
+    }
+    bool updateView = false;
+
+    if ((modelSize.GetWidth() > GQB_MIN_WIDTH || canvasSize.GetWidth() > GQB_MIN_WIDTH) &&
+         modelSize.GetWidth() != canvasSize.GetWidth())
+    {
+        canvasSize.SetWidth((modelSize.GetWidth() > GQB_MIN_WIDTH ? modelSize.GetWidth() : GQB_MIN_WIDTH));
+        updateView = true;
+    }
+    if ((modelSize.GetHeight() > GQB_MIN_HEIGHT || canvasSize.GetHeight() > GQB_MIN_HEIGHT) &&
+         modelSize.GetHeight() != canvasSize.GetHeight())
+    {
+        canvasSize.SetHeight((modelSize.GetHeight() > GQB_MIN_HEIGHT ? modelSize.GetHeight() : GQB_MIN_HEIGHT));
+        updateView = true;
+    }
+
+    if (updateView)
+    {
+        SetVirtualSize(canvasSize);
+    }
+}
+
Index: gqb/gqbController.cpp
===================================================================
--- gqb/gqbController.cpp	(revision 8266)
+++ gqb/gqbController.cpp	(working copy)
@@ -29,7 +29,7 @@
 
 wxWindowID CTL_NTBKPANELS = ::wxNewId();
 
-gqbController::gqbController(gqbModel *_model, wxWindow *gqbParent, wxNotebook *gridParent, wxSize size=wxSize(800,1280))
+gqbController::gqbController(gqbModel *_model, wxWindow *gqbParent, wxNotebook *gridParent, wxSize size=wxSize(GQB_MIN_WIDTH, GQB_MIN_HEIGHT))
 : wxObject()
 {
     pparent = gqbParent;
-- 
Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-support

Reply via email to