views:

97

answers:

1

Hi All,

I mainly program plugins using wxWidgets within a Carbon bundle which is loaded at runtime. The host-applications where my plugins are running in provide a native window handle (WindowRef), which I can use to add my custom, wxWidgets-based GUI-classes.

To use the native window handle with wxWidgets classes I had to write a wxTopLevelWindow wrapper class, which does all the WindowRef encapsulation. So far, this works pretty well, but under some circumstances I got vertical mouse offsets within a wxGLCanvas if the window class of the native window handle is not of the type "kFloatingWindowClass". I am able to bypass the problem if I display an info panel (wxPanel) over the whole wxGlCanvas and if the user hides the info panel then the mouse offset is gone.

Now my questions:

  1. Is there a "simple" explanation for this behaviour?
  2. Is it possible to use certain method calls to imitate info panel effect without using the panel itself? I tried several combinations of Update() and Refresh() calls of all involved components, but none of them worked so far. Even the use of wxSizer couldn't help here.

Window hierarchy used by plugin-applications:

wxCustomTopLevelWindow (WindowRef provided by host-application)
 wxPanel (parent window for all application panel)
  wxPanel (application info panel)
  wxPanel (application main panel)
   wxPanel (opengl main panel)
    wxGlCanvas (main opengl canvas)

Any ideas? Any help is very appreciated.

A: 

Is it a co-ordinate system mismatch? Some Mac OS X APIs use the top-left as the origin (positive y goes down), whereas others use the lower-left (positive y goes up).

This can seem intermittent, as the error will be small near the vertical center of the screen; farther from the center, the co-ordinate will appear to be wildly inaccurate (indeed, it's on the opposite side of the screen).

I am able to bypass the problem if I display an info panel (wxPanel) over the whole wxGlCanvas and if the user hides the info panel then the mouse offset is gone.

This could be a red herring, if you were popping up this panel in the middle of the screen and closing it with the mouse.

Peter Hosey
Hey Peter,thanks for your answer. The wxGlCanvas itself is drawn on the correct position, but the mouse has always a constant offset whether I'm in the center or far from the center. The coordinate system mismatch migth be a problem, but to verify this I have debug this in depth. Are you familiar with the wxWidgets API?
srose
Nope. Is it 22 pixels?
Peter Hosey
It's actually a bit more (26-28 pixels) as of the title bar (22 pixels). But I will measure the exact offset.
srose
The menu bar is also 22 pixels; that's what I was thinking.
Peter Hosey

related questions