\section{\class{wxPanel}}\label{wxpanel}
-A panel is a window on which controls are placed. It is usually placed within a frame.
-It contains minimal extra functionality over and above its parent class wxWindow; its main
-purpose is to be similar in appearance and functionality to a dialog, but with the flexibility of
-having any window as a parent.
+A panel is a window on which controls are placed. It is usually placed within
+a frame. Its main feature over its parent class wxWindow is code for handling
+child windows and TAB traversal. Since wxWidgets 2.9, there is support both
+for TAB traversal implemented by wxWidgets itself as well as native TAB
+traversal (such as for GTK 2.0).
-{\it Note:} if not all characters are being intercepted by your OnKeyDown or OnChar handler,
-it may be because you are using the wxTAB\_TRAVERSAL style, which grabs some keypresses for use
-by child controls.
+{\it Note:} Tab traversal is implemented through an otherwise undocumented
+intermediate wxControlContainer class from which any class can derive
+in addition to the normal wxWindow base class. Please see <wx/containr.h>
+and <wx/panel.h> to find out how this is achieved.
+
+{\it Note:} if not all characters are being intercepted by your OnKeyDown or
+OnChar handler, it may be because you are using the wxTAB\_TRAVERSAL style,
+which grabs some keypresses for use by child controls.
\wxheading{Derived from}
Used for two-step panel construction. See \helpref{wxPanel::wxPanel}{wxpanelctor}\rtfsp
for details.
+
+\membersection{wxPanel::AcceptsFocus}\label{wxpanelacceptsfocus}
+
+\constfunc{bool}{AcceptsFocus}{\void}
+
+This method is overridden from \helpref{wxWindow::AcceptsFocus}{wxwindowacceptsfocus}
+and returns true only if there is no child window in the panel which
+can accept the focus. This is reevaluated each time a child
+window is added or removed from the panel.
+
+
\membersection{wxPanel::InitDialog}\label{wxpanelinitdialog}
\func{void}{InitDialog}{\void}
\helpref{wxWindow::GetBackgroundStyle}{wxwindowgetbackgroundstyle}
-\membersection{wxWindow::SetInitialSize}\label{wxwindowsetinitialsize}
-
-\func{void}{SetInitialSize}{\param{const wxSize\& }{size = wxDefaultSize}}
-A {\it smart} SetSize that will fill in default size components with the
-window's {\it best} size values. Also sets the window's minsize to
-the value passed in for use with sizers. This means that if a full or
-partial size is passed to this function then the sizers will use that
-size instead of the results of GetBestSize to determine the minimum
-needs of the window for layout.
+\membersection{wxWindow::SetCanFocus}\label{wxwindowsetcanfocus}
-Most controls will use this to set their initial size, and their min
-size to the passed in value (if any.)
+\func{virtual void}{SetCanFocus}{\param{bool}{ canFocus}}
+This method is only implemented by ports which have support for
+native TAB traversal (such as GTK+ 2.0). It is called by wxWidgets'
+container control code to give the native system a hint when
+doing TAB traversal. A call to this does not disable or change
+the effect of programmatically calling
+\helpref{wxWindow::SetFocus}{wxwindowsetfocus}.
\wxheading{See also}
-\helpref{wxWindow::SetSize}{wxwindowsetsize},\rtfsp
-\helpref{wxWindow::GetBestSize}{wxwindowgetbestsize},\rtfsp
-\helpref{wxWindow::GetEffectiveMinSize}{wxwindowgeteffectiveminsize}
+\helpref{wxFocusEvent}{wxfocusevent}
+\helpref{wxPanel::SetFocus}{wxpanelsetfocus}
+\helpref{wxPanel::SetFocusIgnoringChildren}{wxpanelsetfocusignoringchildren}
\membersection{wxWindow::SetCaret}\label{wxwindowsetcaret}
-\membersection{wxWindow::SetInitialBestSize}\label{wxwindowsetinitialbestsize}
-
-\func{virtual void}{SetInitialBestSize}{\param{const wxSize\& }{size}}
-
-Sets the initial window size if none is given (i.e. at least one of the
-components of the size passed to ctor/Create() is wxDefaultCoord).
-
\membersection{wxWindow::SetEventHandler}\label{wxwindowseteventhandler}
\func{void}{SetEventHandler}{\param{wxEvtHandler* }{handler}}
central implementation of event-handling for a variety of different
window classes.
-It is usually better to use \helpref{wxWindow::PushEventHandler}{wxwindowpusheventhandler} since
-this sets up a chain of event handlers, where an event not handled by one event handler is
-handed to the next one in the chain.
+It is usually better to use \helpref{wxWindow::PushEventHandler}{wxwindowpusheventhandler}
+since this sets up a chain of event handlers, where an event not handled by
+one event handler is handed to the next one in the chain.
\wxheading{See also}
+\membersection{wxWindow::SetInitialBestSize}\label{wxwindowsetinitialbestsize}
+
+\func{virtual void}{SetInitialBestSize}{\param{const wxSize\& }{size}}
+
+Sets the initial window size if none is given (i.e. at least one of the
+components of the size passed to ctor/Create() is wxDefaultCoord).
+
+
+\membersection{wxWindow::SetInitialSize}\label{wxwindowsetinitialsize}
+
+\func{void}{SetInitialSize}{\param{const wxSize\& }{size = wxDefaultSize}}
+
+A {\it smart} SetSize that will fill in default size components with the
+window's {\it best} size values. Also sets the window's minsize to
+the value passed in for use with sizers. This means that if a full or
+partial size is passed to this function then the sizers will use that
+size instead of the results of GetBestSize to determine the minimum
+needs of the window for layout.
+
+Most controls will use this to set their initial size, and their min
+size to the passed in value (if any.)
+
+
+\wxheading{See also}
+
+\helpref{wxWindow::SetSize}{wxwindowsetsize},\rtfsp
+\helpref{wxWindow::GetBestSize}{wxwindowgetbestsize},\rtfsp
+\helpref{wxWindow::GetEffectiveMinSize}{wxwindowgeteffectiveminsize}
+
+
\membersection{wxWindow::SetLabel}\label{wxwindowsetlabel}
\func{virtual void}{SetLabel}{\param{const wxString\& }{label}}
// wxListCtrl) and so should get focus for ourselves
bool AcceptsFocusRecursively() const { return true; }
- // call this when the number of children of the window changes
- //
- // note that we have any children, this panel (used just as container for
- // them) shouldn't get focus for itself
+ // Call this when the number of children of the window changes.
+ // If we have any children, this panel (used just as container for
+ // them) shouldn't get focus for itself.
void UpdateCanFocus() { SetCanFocus(!HasAnyFocusableChildren()); }
protected:
\
void classname::SetFocusIgnoringChildren() \
{ \
- basename::SetFocusIgnoringChildren(); \
+ basename::SetFocus(); \
}
#else // !wxHAS_NATIVE_TAB_TRAVERSAL
virtual bool IsRetained() const;
virtual void SetFocus();
- virtual void SetFocusIgnoringChildren();
+
+ // hint from wx to native GTK+ tab traversal code
virtual void SetCanFocus(bool canFocus);
virtual bool Reparent( wxWindowBase *newParent );
#include "wx/settings.h"
#include "wx/msgdlg.h"
#include "wx/textctrl.h"
- #include "wx/radiobut.h"
#include "wx/toolbar.h"
#include "wx/combobox.h"
#include "wx/layout.h"
return false;
}
-void wxWindowGTK::SetFocusIgnoringChildren()
+void wxWindowGTK::SetFocus()
{
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
if ( m_hasFocus )
if (m_wxwindow)
{
+ // wxWindow::SetFocus() should really set the focus to
+ // this control, whatever the flags are
if (!GTK_WIDGET_CAN_FOCUS(m_wxwindow))
GTK_WIDGET_SET_FLAGS(m_wxwindow, GTK_CAN_FOCUS);
- }
-
- wxWindowGTK::SetFocus();
-}
-
-void wxWindowGTK::SetFocus()
-{
- wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
- if ( m_hasFocus )
- {
- // don't do anything if we already have focus
- return;
- }
-
- if (m_wxwindow)
- {
+
if (!GTK_WIDGET_HAS_FOCUS (m_wxwindow))
{
gtk_widget_grab_focus (m_wxwindow);
}
else if (m_widget)
{
+ // wxWindow::SetFocus() should really set the focus to
+ // this control, whatever the flags are
+ if (!GTK_WIDGET_CAN_FOCUS(m_widget))
+ GTK_WIDGET_SET_FLAGS(m_widget, GTK_CAN_FOCUS);
+
if (GTK_IS_CONTAINER(m_widget))
{
-#if wxUSE_RADIOBTN
- if (IsKindOf(CLASSINFO(wxRadioButton)))
+ if (GTK_IS_RADIO_BUTTON(m_widget))
{
gtk_widget_grab_focus (m_widget);
return;
}
-#endif // wxUSE_RADIOBTN
gtk_widget_child_focus( m_widget, GTK_DIR_TAB_FORWARD );
}