# wxPanel Class Reference
[Miscellaneous Windows]

`#include <wx/panel.h>`

Inheritance diagram for wxPanel:
[legend]

## Detailed Description

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).

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.

  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.

Remarks:
  By default, a panel has the same colouring as a dialog.

## Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxNavigationKeyEvent& event)
Event macros for events emitted by this class:

- EVT_NAVIGATION_KEY(func):
  Process a navigation key event.

##

Library: wxBase

Category: Miscellaneous Windows

See also:
  wxDialog

## Public Member Functions
| wxPanel ()
| Default constructor.
| wxPanel (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxPanelNameStr)
| Constructor.
virtual | ~wxPanel ()
| Destructor.
bool | AcceptsFocus () const
| This method is overridden from wxWindow::AcceptsFocus() and returns true only if there is no child window in the panel which can accept the focus.
bool | Create (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxPanelNameStr)
| Used for two-step panel construction.
virtual void | InitDialog ()
| Sends a wxInitDialogEvent, which in turn transfers data to the dialog via validators.
virtual bool | Layout ()
| See wxWindow::SetAutoLayout(): when auto layout is on, this function gets called automatically when the window is resized.
void | OnSysColourChanged (wxSysColourChangedEvent &event)
| The default handler for `wxEVT_SYS_COLOUR_CHANGED`.
void | SetBackgroundBitmap (const wxBitmap &bmp)
| Set the background bitmap for this panel.
virtual void | SetFocus ()
| Overrides wxWindow::SetFocus().
void | SetFocusIgnoringChildren ()
| In contrast to SetFocus() (see above) this will set the focus to the panel even if there are child windows in the panel.

List of all members.

## Constructor & Destructor Documentation

wxPanel::wxPanel | ( |  | ) |

Default constructor.

wxPanel::wxPanel | ( | wxWindow * | parent,
|  | wxWindowID | id = `wxID_ANY`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `wxTAB_TRAVERSAL`,
|  | const wxString & | name = `wxPanelNameStr` |
| ) |  |  |

Constructor.

Parameters:

  | parent | The parent window.
  | id | An identifier for the panel. `wxID_ANY` is taken to mean a default.
  | pos | The panel position. The value wxDefaultPosition indicates a default position, chosen by either the windowing system or wxWidgets, depending on platform.
  | size | The panel size. The value wxDefaultSize indicates a default size, chosen by either the windowing system or wxWidgets, depending on platform.
  | style | The window style. See wxPanel.
  | name | Window name.

See also:
  Create()

virtual wxPanel::~wxPanel | ( |  | ) | `[virtual]`

Destructor.

Deletes any child windows before deleting the physical window.

## Member Function Documentation

bool wxPanel::AcceptsFocus | ( |  | ) | const`[virtual]`

This method is overridden from wxWindow::AcceptsFocus() 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.

Reimplemented from wxWindow.

bool wxPanel::Create | ( | wxWindow * | parent,
|  | wxWindowID | id = `wxID_ANY`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `wxTAB_TRAVERSAL`,
|  | const wxString & | name = `wxPanelNameStr` |
| ) |  |  |

Used for two-step panel construction.

See wxPanel() for details.

Reimplemented from wxWindow.

Reimplemented in wxGrid, wxHtmlListBox, wxVListBox, wxVScrolledWindow, wxHScrolledWindow, wxHVScrolledWindow, and wxScrolled< wxPanel >.

virtual void wxPanel::InitDialog | ( |  | ) | `[virtual]`

Sends a wxInitDialogEvent, which in turn transfers data to the dialog via validators.

See also:
  wxInitDialogEvent

Reimplemented from wxWindow.

virtual bool wxPanel::Layout | ( |  | ) | `[virtual]`

See wxWindow::SetAutoLayout(): when auto layout is on, this function gets called automatically when the window is resized.

Reimplemented from wxWindow.

void wxPanel::OnSysColourChanged | ( | wxSysColourChangedEvent & | event | ) |

The default handler for `wxEVT_SYS_COLOUR_CHANGED`.

Parameters:

  | event | The colour change event.

Remarks:
  Changes the panel's colour to conform to the current settings (Windows only). Add an event table entry for your panel class if you wish the behaviour to be different (such as keeping a user-defined background colour). If you do override this function, call wxEvent::Skip() to propagate the notification to child windows and controls.

See also:
  wxSysColourChangedEvent

void wxPanel::SetBackgroundBitmap | ( | const wxBitmap & | bmp | ) |

Set the background bitmap for this panel.

If bmp is a valid bitmap, this bitmap will be tiled over the panel background and show through any of its transparent children. Passing an invalid bitmap reverts to the default background appearance.

Notice that you must not prevent the base class EVT_ERASE_BACKGROUND handler from running (i.e. not to handle this event yourself) for this to work.

Since:
  2.9.2

virtual void wxPanel::SetFocus | ( |  | ) | `[virtual]`

Overrides wxWindow::SetFocus().

This method uses the (undocumented) mix-in class wxControlContainer which manages the focus and TAB logic for controls which usually have child controls.

In practice, if you call this method and the control has at least one child window, the focus will be given to the child window.

See also:
  wxFocusEvent, wxWindow::SetFocus()

Reimplemented from wxWindow.

void wxPanel::SetFocusIgnoringChildren | ( |  | ) |

In contrast to SetFocus() (see above) this will set the focus to the panel even if there are child windows in the panel.

This is only rarely needed.

|  | [ top ]