Fixed some broken things related to context help, fixed memory leak

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
This commit is contained in:
Julian Smart
2000-09-08 13:52:10 +00:00
parent fb6261e9ba
commit 57591e0edb
16 changed files with 58 additions and 18 deletions

View File

@@ -57,6 +57,7 @@ public:
const wxValidator &validator = wxDefaultValidator, const wxValidator &validator = wxDefaultValidator,
const wxString& name = wxTreeCtrlNameStr) const wxString& name = wxTreeCtrlNameStr)
{ {
Init();
Create(parent, id, pos, size, style, validator, name); Create(parent, id, pos, size, style, validator, name);
} }

View File

@@ -270,6 +270,9 @@ WXDLLEXPORT wxWindow* wxFindWindowByName(const wxString& name, wxWindow *parent
// Returns menu item id or -1 if none. // Returns menu item id or -1 if none.
WXDLLEXPORT int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, const wxString& itemString); 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); WXDLLEXPORT wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -191,8 +191,8 @@ bool wxContextHelp::DispatchEvent(wxWindow* win, const wxPoint& pt)
#if !defined(__WXMSW__) #if !defined(__WXMSW__)
static char * csquery_xpm[] = { static char * csquery_xpm[] = {
"12 11 2 1", "12 11 2 1",
" c None", " c None",
". c Black", ". c #000000",
" ", " ",
" .... ", " .... ",
" .. .. ", " .. .. ",
@@ -228,7 +228,7 @@ wxContextHelpButton::wxContextHelpButton(wxWindow* parent, wxWindowID id,
void wxContextHelpButton::OnContextHelp(wxCommandEvent& event) void wxContextHelpButton::OnContextHelp(wxCommandEvent& event)
{ {
wxContextHelp contextHelp; wxContextHelp contextHelp(GetParent());
} }
#endif // wxUSE_HELP #endif // wxUSE_HELP

View File

@@ -694,16 +694,19 @@ wxWindow* wxFindWindowAtPoint(wxWindow* win, const wxPoint& pt)
return NULL; 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) while (node)
{ {
wxWindow* win = (wxWindow*) node->Data(); wxWindow* win = (wxWindow*) node->Data();
wxWindow* found = wxFindWindowAtPoint(win, pt); wxWindow* found = wxFindWindowAtPoint(win, pt);
if (found) if (found)
return found; return found;
node = node->Next(); node = node->Previous();
} }
return NULL; return NULL;
} }

View File

@@ -638,8 +638,6 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, wxWindowID id,
const wxValidator &validator, const wxValidator &validator,
const wxString& name ) const wxString& name )
{ {
Init();
wxScrolledWindow::Create( parent, id, pos, size, style|wxHSCROLL|wxVSCROLL, name ); wxScrolledWindow::Create( parent, id, pos, size, style|wxHSCROLL|wxVSCROLL, name );
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS

View File

@@ -111,6 +111,12 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
return wxGTK; return wxGTK;
} }
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{
return wxGenericFindWindowAtPoint(pt);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// subprocess routines // subprocess routines
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -3777,6 +3777,8 @@ wxPoint wxGetMousePosition()
int x, y; int x, y;
GdkWindow* windowAtPtr = gdk_window_at_pointer(& x, & y); GdkWindow* windowAtPtr = gdk_window_at_pointer(& x, & y);
if (!windowAtPtr)
return wxPoint(-999, -999);
Display *display = GDK_WINDOW_XDISPLAY(windowAtPtr); Display *display = GDK_WINDOW_XDISPLAY(windowAtPtr);
Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display)); Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));

View File

@@ -111,6 +111,12 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
return wxGTK; return wxGTK;
} }
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{
return wxGenericFindWindowAtPoint(pt);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// subprocess routines // subprocess routines
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -3777,6 +3777,8 @@ wxPoint wxGetMousePosition()
int x, y; int x, y;
GdkWindow* windowAtPtr = gdk_window_at_pointer(& x, & y); GdkWindow* windowAtPtr = gdk_window_at_pointer(& x, & y);
if (!windowAtPtr)
return wxPoint(-999, -999);
Display *display = GDK_WINDOW_XDISPLAY(windowAtPtr); Display *display = GDK_WINDOW_XDISPLAY(windowAtPtr);
Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display)); Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));

View File

@@ -329,3 +329,7 @@ void wxDisplaySize(int *width, int *height)
#endif #endif
} }
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{
return wxGenericFindWindowAtPoint(pt);
}

View File

@@ -2369,7 +2369,8 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
// Get the current mouse position. // Get the current mouse position.
wxPoint wxGetMousePosition() wxPoint wxGetMousePosition()
{ {
wxFAIL_MSG(_("Not implemented")); int x, y;
return wxPoint; wxGetMousePosition(& x, & y);
return wxPoint(x, y);
} }

View File

@@ -329,3 +329,7 @@ void wxDisplaySize(int *width, int *height)
#endif #endif
} }
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{
return wxGenericFindWindowAtPoint(pt);
}

View File

@@ -2369,7 +2369,8 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
// Get the current mouse position. // Get the current mouse position.
wxPoint wxGetMousePosition() wxPoint wxGetMousePosition()
{ {
wxFAIL_MSG(_("Not implemented")); int x, y;
return wxPoint; wxGetMousePosition(& x, & y);
return wxPoint(x, y);
} }

View File

@@ -706,6 +706,11 @@ wxString wxGetDisplayName()
return gs_displayName; return gs_displayName;
} }
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{
return wxGenericFindWindowAtPoint(pt);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// accelerators // accelerators
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -2992,9 +2992,7 @@ wxWindow *wxGetActiveWindow()
// position. // position.
wxWindow* wxFindWindowAtPointer(wxPoint& pt) wxWindow* wxFindWindowAtPointer(wxPoint& pt)
{ {
pt = wxGetMousePosition(); return wxFindWindowAtPoint(wxGetMousePosition());
wxWindow* found = wxFindWindowAtPoint(pt);
return found;
} }
// Get the current mouse position. // Get the current mouse position.

View File

@@ -4389,9 +4389,15 @@ static TEXTMETRIC wxGetTextMetrics(const wxWindow *win)
// position. // position.
wxWindow* wxFindWindowAtPointer(wxPoint& pt) wxWindow* wxFindWindowAtPointer(wxPoint& pt)
{ {
// Use current message to find last mouse position return wxFindWindowAtPoint(wxGetMousePosition());
extern MSG s_currentMsg; }
HWND hWndHit = ::WindowFromPoint(s_currentMsg.pt);
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{
POINT pt2;
pt2.x = pt.x;
pt2.y = pt.y;
HWND hWndHit = ::WindowFromPoint(pt2);
wxWindow* win = wxFindWinFromHandle((WXHWND) hWndHit) ; wxWindow* win = wxFindWinFromHandle((WXHWND) hWndHit) ;
HWND hWnd = hWndHit; HWND hWnd = hWndHit;