]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed some broken things related to context help, fixed memory leak
authorJulian Smart <julian@anthemion.co.uk>
Fri, 8 Sep 2000 13:52:10 +0000 (13:52 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 8 Sep 2000 13:52:10 +0000 (13:52 +0000)
in wxGenericTreeCtrl (Init should be called before Create, not _in_ Create)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8295 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

16 files changed:
include/wx/generic/treectlg.h
include/wx/utils.h
src/common/cshelp.cpp
src/common/utilscmn.cpp
src/generic/treectlg.cpp
src/gtk/utilsgtk.cpp
src/gtk/window.cpp
src/gtk1/utilsgtk.cpp
src/gtk1/window.cpp
src/mac/carbon/utils.cpp
src/mac/carbon/window.cpp
src/mac/utils.cpp
src/mac/window.cpp
src/motif/utils.cpp
src/motif/window.cpp
src/msw/window.cpp

index 650d518bc312a815fb6af45bf94878fd382248be..1bc9bd11032d2edd01d2a2fefc276b6f76efb332 100644 (file)
@@ -57,6 +57,7 @@ public:
                const wxValidator &validator = wxDefaultValidator,
                const wxString& name = wxTreeCtrlNameStr)
     {
+        Init();
         Create(parent, id, pos, size, style, validator, name);
     }
 
index b907015be346d067f80caa5cb8098bd970fc3424..c47224769049d1b954b01d62059006c69cf4df1d 100644 (file)
@@ -270,6 +270,9 @@ WXDLLEXPORT wxWindow* wxFindWindowByName(const wxString& name, wxWindow *parent
 // Returns menu item id or -1 if none.
 WXDLLEXPORT int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, const wxString& itemString);
 
+// Find the wxWindow at the given point. wxGenericFindWindowAtPoint
+// is always present but may be less reliable than a native version.
+WXDLLEXPORT wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
 WXDLLEXPORT wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
 
 // ----------------------------------------------------------------------------
index fe75524bb8aa408c5388a5252b79a6e534d0dea9..37a3ade54cc0cde1033839f82e1db56160477fee 100644 (file)
@@ -191,8 +191,8 @@ bool wxContextHelp::DispatchEvent(wxWindow* win, const wxPoint& pt)
 #if !defined(__WXMSW__)
 static char * csquery_xpm[] = {
 "12 11 2 1",
-"      c None",
-".     c Black",
+"  c None",
+". c #000000",
 "            ",
 "    ....    ",
 "   ..  ..   ",
@@ -228,7 +228,7 @@ wxContextHelpButton::wxContextHelpButton(wxWindow* parent, wxWindowID id,
 
 void wxContextHelpButton::OnContextHelp(wxCommandEvent& event)
 {
-    wxContextHelp contextHelp;
+    wxContextHelp contextHelp(GetParent());
 }
 
 #endif // wxUSE_HELP
index e35cd29f78847f62df81ff2addb728dba195d74e..e556674f850700ed37ca81ec0e3b803b5b6fad3b 100644 (file)
@@ -694,16 +694,19 @@ wxWindow* wxFindWindowAtPoint(wxWindow* win, const wxPoint& pt)
         return NULL;
 }
 
-wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
+wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt)
 {
-    wxNode* node = wxTopLevelWindows.First();
+    // Go backwards through the list since windows
+    // on top are likely to have been appended most
+    // recently.
+    wxNode* node = wxTopLevelWindows.Last();
     while (node)
     {
         wxWindow* win = (wxWindow*) node->Data();
         wxWindow* found = wxFindWindowAtPoint(win, pt);
         if (found)
             return found;
-        node = node->Next();
+        node = node->Previous();
     }
     return NULL;
 }
index d63cdc8705a8fb9e5d90c5fa4d511eef472aa499..7d9ea69e548b49f8825853db96a88a636e16a1ac 100644 (file)
@@ -638,8 +638,6 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, wxWindowID id,
                         const wxValidator &validator,
                         const wxString& name )
 {
-    Init();
-
     wxScrolledWindow::Create( parent, id, pos, size, style|wxHSCROLL|wxVSCROLL, name );
 
 #if wxUSE_VALIDATORS
index 92aac444826ca27e5be61305eb16a9b3b4e2775d..1f985793be0d99cb775545ad60247a686f08bc7e 100644 (file)
@@ -111,6 +111,12 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
   return wxGTK;
 }
 
+wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
+{
+    return wxGenericFindWindowAtPoint(pt);
+}
+
+
 // ----------------------------------------------------------------------------
 // subprocess routines
 // ----------------------------------------------------------------------------
index d56ab1057d279252182c0f2419ffde5a63b2560c..9d8bd481a93b121b426372d742d8677198acf288 100644 (file)
@@ -3777,6 +3777,8 @@ wxPoint wxGetMousePosition()
 
     int x, y;
     GdkWindow* windowAtPtr = gdk_window_at_pointer(& x, & y);
+    if (!windowAtPtr)
+      return wxPoint(-999, -999);
 
     Display *display = GDK_WINDOW_XDISPLAY(windowAtPtr);
     Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
index 92aac444826ca27e5be61305eb16a9b3b4e2775d..1f985793be0d99cb775545ad60247a686f08bc7e 100644 (file)
@@ -111,6 +111,12 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
   return wxGTK;
 }
 
+wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
+{
+    return wxGenericFindWindowAtPoint(pt);
+}
+
+
 // ----------------------------------------------------------------------------
 // subprocess routines
 // ----------------------------------------------------------------------------
index d56ab1057d279252182c0f2419ffde5a63b2560c..9d8bd481a93b121b426372d742d8677198acf288 100644 (file)
@@ -3777,6 +3777,8 @@ wxPoint wxGetMousePosition()
 
     int x, y;
     GdkWindow* windowAtPtr = gdk_window_at_pointer(& x, & y);
+    if (!windowAtPtr)
+      return wxPoint(-999, -999);
 
     Display *display = GDK_WINDOW_XDISPLAY(windowAtPtr);
     Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
index 0031f1efade1df19e67b0e7d6246b9774b3b4aac..b312321562d22959b355a7e2acb9cb8f95946c60 100644 (file)
@@ -329,3 +329,7 @@ void wxDisplaySize(int *width, int *height)
  #endif
 }
 
+wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
+{
+    return wxGenericFindWindowAtPoint(pt);
+}
index fe831d3d08291e2fe51395551dd4546f34fc9db4..d2696fe6e0bdc955993352efa87ec9265ea9200c 100644 (file)
@@ -2369,7 +2369,8 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
 // Get the current mouse position.
 wxPoint wxGetMousePosition()
 {
-    wxFAIL_MSG(_("Not implemented"));
-    return wxPoint;
+    int x, y;
+    wxGetMousePosition(& x, & y);
+    return wxPoint(x, y);
 }
 
index 0031f1efade1df19e67b0e7d6246b9774b3b4aac..b312321562d22959b355a7e2acb9cb8f95946c60 100644 (file)
@@ -329,3 +329,7 @@ void wxDisplaySize(int *width, int *height)
  #endif
 }
 
+wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
+{
+    return wxGenericFindWindowAtPoint(pt);
+}
index fe831d3d08291e2fe51395551dd4546f34fc9db4..d2696fe6e0bdc955993352efa87ec9265ea9200c 100644 (file)
@@ -2369,7 +2369,8 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
 // Get the current mouse position.
 wxPoint wxGetMousePosition()
 {
-    wxFAIL_MSG(_("Not implemented"));
-    return wxPoint;
+    int x, y;
+    wxGetMousePosition(& x, & y);
+    return wxPoint(x, y);
 }
 
index 2194b1d8356216fef81be6a4e699a797a9c8f7fe..0dab1add9b3e2cbb3f3670065a7c247d0969d393 100644 (file)
@@ -706,6 +706,11 @@ wxString wxGetDisplayName()
     return gs_displayName;
 }
 
+wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
+{
+    return wxGenericFindWindowAtPoint(pt);
+}
+
 // ----------------------------------------------------------------------------
 // accelerators
 // ----------------------------------------------------------------------------
index 5e39ed8eef01a2ad7136062d6bc8ae3df65d6ef5..80302f08d736ac5157241bb41b9ca4972e25dd4d 100644 (file)
@@ -2992,9 +2992,7 @@ wxWindow *wxGetActiveWindow()
 // position.
 wxWindow* wxFindWindowAtPointer(wxPoint& pt)
 {
-    pt = wxGetMousePosition();
-    wxWindow* found = wxFindWindowAtPoint(pt);
-    return found;
+    return wxFindWindowAtPoint(wxGetMousePosition());
 }
 
 // Get the current mouse position.
index 6a4d9c2250771e3b42943a6006a80853596b84a1..c7b28bac0bea9d4a1fb165304d704a82da873822 100644 (file)
@@ -4389,9 +4389,15 @@ static TEXTMETRIC wxGetTextMetrics(const wxWindow *win)
 // position.
 wxWindow* wxFindWindowAtPointer(wxPoint& pt)
 {
-    // Use current message to find last mouse position
-    extern MSG s_currentMsg;
-    HWND hWndHit = ::WindowFromPoint(s_currentMsg.pt);
+    return wxFindWindowAtPoint(wxGetMousePosition());
+}
+
+wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
+{
+    POINT pt2;
+    pt2.x = pt.x;
+    pt2.y = pt.y;
+    HWND hWndHit = ::WindowFromPoint(pt2);
 
     wxWindow* win = wxFindWinFromHandle((WXHWND) hWndHit) ;
     HWND hWnd = hWndHit;