changes to make wxWindow::FindFocus work as expected with composite controls

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29540 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2004-09-29 14:34:28 +00:00
parent adfea104dc
commit 0fe0275981
14 changed files with 33 additions and 13 deletions

View File

@@ -493,7 +493,9 @@ public:
virtual void SetFocusFromKbd() { SetFocus(); }
// return the window which currently has the focus or NULL
static wxWindow *FindFocus() /* = 0: implement in derived classes */;
static wxWindow *FindFocus();
static wxWindow *DoFindFocus() /* = 0: implement in derived classes */;
// can this window have focus?
virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); }
@@ -1072,6 +1074,12 @@ protected:
// Send the wxWindowDestroyEvent
void SendDestroyEvent();
// returns the main window of composite control; this is the window
// that FindFocus returns if the focus is in one of composite control's
// windows
virtual wxWindow *GetMainWindowOfCompositeControl()
{ return (wxWindow*)this; }
// the window id - a number which uniquely identifies a window among
// its siblings unless it is wxID_ANY
wxWindowID m_windowId;

View File

@@ -855,7 +855,7 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
}
// Get the window with the focus
wxWindow *wxWindowBase::FindFocus()
wxWindow *wxWindowBase::DoFindFocus()
{
// TODO
return NULL;

View File

@@ -2467,6 +2467,16 @@ void wxWindowBase::DoMoveInTabOrder(wxWindow *win, MoveKind move)
}
}
// ----------------------------------------------------------------------------
// focus handling
// ----------------------------------------------------------------------------
/*static*/ wxWindow* wxWindowBase::FindFocus()
{
wxWindow *win = DoFindFocus();
return win ? win->GetMainWindowOfCompositeControl() : NULL;
}
// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------

View File

@@ -518,6 +518,8 @@ public:
virtual ~wxListMainWindow();
wxWindow *GetMainWindowOfCompositeControl() { return GetParent(); }
bool HasFlag(int flag) const { return m_parent->HasFlag(flag); }
// return true if this is a virtual list control

View File

@@ -2359,7 +2359,7 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget,
// because it is static and so couldn't be made virtual
// ----------------------------------------------------------------------------
wxWindow *wxWindowBase::FindFocus()
wxWindow *wxWindowBase::DoFindFocus()
{
// the cast is necessary when we compile in wxUniversal mode
return (wxWindow *)g_focusWindow;

View File

@@ -2359,7 +2359,7 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget,
// because it is static and so couldn't be made virtual
// ----------------------------------------------------------------------------
wxWindow *wxWindowBase::FindFocus()
wxWindow *wxWindowBase::DoFindFocus()
{
// the cast is necessary when we compile in wxUniversal mode
return (wxWindow *)g_focusWindow;

View File

@@ -2486,7 +2486,7 @@ void wxWindowMac::MacOnScroll(wxScrollEvent &event )
}
// Get the window with the focus
wxWindowMac *wxWindowBase::FindFocus()
wxWindowMac *wxWindowBase::DoFindFocus()
{
ControlRef control ;
GetKeyboardFocus( GetUserFocusWindow() , &control ) ;

View File

@@ -1332,7 +1332,7 @@ void wxWindowMac::MacOnScroll(wxScrollEvent &event )
}
// Get the window with the focus
wxWindowMac *wxWindowBase::FindFocus()
wxWindowMac *wxWindowBase::DoFindFocus()
{
return gFocusWindow ;
}

View File

@@ -742,7 +742,7 @@ void wxWindowMGL::KillFocus()
// this wxWindowBase function is implemented here (in platform-specific file)
// because it is static and so couldn't be made virtual
// ----------------------------------------------------------------------------
wxWindow *wxWindowBase::FindFocus()
wxWindow *wxWindowBase::DoFindFocus()
{
return (wxWindow*)gs_focusedWindow;
}

View File

@@ -564,7 +564,7 @@ void wxWindow::SetFocus()
}
// Get the window with the focus
wxWindow *wxWindowBase::FindFocus()
wxWindow *wxWindowBase::DoFindFocus()
{
// TODO Problems:
// (1) Can there be multiple focussed widgets in an application?

View File

@@ -581,7 +581,7 @@ void wxWindowMSW::SetFocusFromKbd()
}
// Get the window with the focus
wxWindow *wxWindowBase::FindFocus()
wxWindow *wxWindowBase::DoFindFocus()
{
HWND hWnd = ::GetFocus();
if ( hWnd )

View File

@@ -475,7 +475,7 @@ void wxWindowOS2::SetFocusFromKbd()
wxWindowBase::SetFocusFromKbd();
} // end of wxWindowOS2::SetFocus
wxWindow* wxWindowBase::FindFocus()
wxWindow* wxWindowBase::DoFindFocus()
{
HWND hWnd = ::WinQueryFocus(HWND_DESKTOP);
@@ -484,7 +484,7 @@ wxWindow* wxWindowBase::FindFocus()
return wxFindWinFromHandle((WXHWND)hWnd);
}
return NULL;
} // wxWindowBase::FindFocus
} // wxWindowBase::DoFindFocus
bool wxWindowOS2::Enable(
bool bEnable

View File

@@ -14262,7 +14262,7 @@ EXPORTS
DoMoveWindow__8wxWindowFiN31
;wxWindow::DoClientToScreen(int*,int*) const
DoClientToScreen__8wxWindowCFPiT1
;wxWindowBase::FindFocus()
;wxWindowBase::DoFindFocus()
FindFocus__12wxWindowBaseFv
;wxWindow::OS2OnDrawItem(int,void**)
OS2OnDrawItem__8wxWindowFiPPv

View File

@@ -394,7 +394,7 @@ void wxWindowX11::SetFocus()
}
// Get the window with the focus
wxWindow *wxWindowBase::FindFocus()
wxWindow *wxWindowBase::DoFindFocus()
{
Window xfocus = (Window) 0;
int revert = 0;