+static inline int _DoFixupDistance(int vDistance, int cDistance)
+{
+ // If the virtual distance is wxDefaultCoord, set it to the client distance
+ // This definitely has to be done or else we literally get views with a -1 size component!
+ if(vDistance == wxDefaultCoord)
+ vDistance = cDistance;
+ // NOTE: Since cDistance should always be >= 0 and since wxDefaultCoord is -1, the above
+ // test is more or less useless because it gets covered by the next one. However, just in
+ // case anyone decides that the next test is not correct, I want them to be aware that
+ // the above test would still be needed.
+
+ // I am not entirely sure about this next one but I believe it makes sense because
+ // otherwise the virtual view (which is the m_cocoaNSView that got wrapped by the scrolling
+ // machinery) can be smaller than the NSClipView (the client area) which
+ // means that, for instance, mouse clicks inside the client area as wx sees it but outside
+ // the virtual area as wx sees it won't be seen by the m_cocoaNSView.
+ // We make the assumption that if a virtual distance is less than the client distance that
+ // the real view must already be or will soon be positioned at coordinate 0 within the
+ // NSClipView that represents the client area. This way, when we increase the distance to
+ // be the client distance, the real view will exactly fit in the clip view.
+ else if(vDistance < cDistance)
+ vDistance = cDistance;
+ return vDistance;
+}
+