grid events

Hi,
I am having trouble intercepting events on a wxGrid control.
I have a grid and another window side by side. I want to "scroll" the other
window to keep insync with the vertical scroll on the grid window.

I have found I need a combination of many event handlers and liberal use of
wxCallAfter to update the gfx in the other window to match the contents of
the grid for all possible scrolling methods on the grid.
I tried an EVT_PAINT message to catch any redrawing of the grid - but this
was never called when scrolling via mouse or cursors.
Any ideas?

Regards,
Andrew

Dr Andrew Perella
Programming Manager
ajp@eutechnyx.com

···

_____________________________________________________________________
This e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. No communication sent by e-mail to or from Eutechnyx is intended to give rise to contractual or other legal liability, apart from liability which cannot be excluded under English law.

This message has been checked for all known viruses by Star Internet delivered through the MessageLabs Virus Control Centre.

www.eutechnyx.com Eutechnyx Limited. Registered in England No: 2172322

Andrew Perella wrote:

Hi,
I am having trouble intercepting events on a wxGrid control.
I have a grid and another window side by side. I want to "scroll" the other
window to keep insync with the vertical scroll on the grid window.

I have found I need a combination of many event handlers and liberal use of
wxCallAfter to update the gfx in the other window to match the contents of
the grid for all possible scrolling methods on the grid.

Isn't EVT_SCROLLWIN enough?

I tried an EVT_PAINT message to catch any redrawing of the grid - but this
was never called when scrolling via mouse or cursors.

The wxGrid is actually composed of several component windows, so they are the ones getting mouse and paint events, not the main grid window. YOu can get a reference to the windwo implementing the main part of the grid with grid.GetGridWindow()

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thanks Robin,
EVT_SCROLLWIN doesnt seem to be enough - for example moving the cursor up
and down off the page - but I can trap these separately.
If I want the evt_scrollwin handling to allow update to the other window
while dragging the scroll bar I can do a wxYield():

def OnScroll(self,event):
    print event
    wxCallAfter(self.ScrollAfter, 0) # scroll back to top after initial events
    wxYield()
    event.Skip()

def ScrollAfter(self,event):
  (x,y)=self.CalcUnscrolledPosition(0,0)
  self.frame.Change(x,y) #notify other window to move

Unfortunately the CalcUnscrolledPosition is wrong until the mouse is
released (it looks like the previous position)

How would I intercept repainting of the grid.GetGridWindow()?
Cheers,
Andrew

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: 30 April 2003 20:18
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] grid events

Andrew Perella wrote:

Hi,
I am having trouble intercepting events on a wxGrid control.
I have a grid and another window side by side. I want to "scroll" the

other

window to keep insync with the vertical scroll on the grid window.

I have found I need a combination of many event handlers and liberal use

of

wxCallAfter to update the gfx in the other window to match the contents of
the grid for all possible scrolling methods on the grid.

Isn't EVT_SCROLLWIN enough?

I tried an EVT_PAINT message to catch any redrawing of the grid - but this
was never called when scrolling via mouse or cursors.

The wxGrid is actually composed of several component windows, so they
are the ones getting mouse and paint events, not the main grid window.
YOu can get a reference to the windwo implementing the main part of the
grid with grid.GetGridWindow()

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

_____________________________________________________________________
This e-mail is confidential and may be privileged. It may be read, copied
and used only by the intended recipient. No communication sent by e-mail to
or from Eutechnyx is intended to give rise to contractual or other legal
liability, apart from liability which cannot be excluded under English law.

This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Control Centre.

www.eutechnyx.com Eutechnyx Limited. Registered in England No: 2172322

_____________________________________________________________________
This e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. No communication sent by e-mail to or from Eutechnyx is intended to give rise to contractual or other legal liability, apart from liability which cannot be excluded under English law.

This message has been checked for all known viruses by Star Internet delivered through the MessageLabs Virus Control Centre.

www.eutechnyx.com Eutechnyx Limited. Registered in England No: 2172322

Andrew Perella wrote:

Thanks Robin,
EVT_SCROLLWIN doesnt seem to be enough - for example moving the cursor up
and down off the page - but I can trap these separately.
If I want the evt_scrollwin handling to allow update to the other window
while dragging the scroll bar I can do a wxYield():

def OnScroll(self,event):
    print event
    wxCallAfter(self.ScrollAfter, 0) # scroll back to top after initial events
    wxYield()
    event.Skip()

def ScrollAfter(self,event):
  (x,y)=self.CalcUnscrolledPosition(0,0)
  self.frame.Change(x,y) #notify other window to move

Unfortunately the CalcUnscrolledPosition is wrong until the mouse is
released (it looks like the previous position)

How would I intercept repainting of the grid.GetGridWindow()?

  EVT_PAINT(grid.GetGridWindow(), self.OnGridPaint)

But becareful with this as there will be *LOTS* of paint events that have nothing to do with scrolling.

Maybe another solution is to set a timer with a fairly low timeout and then just update your other window's scroll position at that time....

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!