Split wxPanel in wxPanelBase and platform-specific files.

So far we have only wxMSW-specific implementation (and also a trivial
wxUniv-specific one) but it's still tidier to have all platform-specific code
in separate files, especially as we're going to have more of it for wxMSW
soon.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67251 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-03-20 00:00:38 +00:00
parent 0a81f13024
commit 5b87bd6c0b
17 changed files with 479 additions and 355 deletions
+45 -24
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -788,7 +788,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/generic/markuptext.cpp
src/generic/msgdlgg.cpp
src/generic/numdlgg.cpp
src/generic/panelg.cpp
src/generic/progdlgg.cpp
src/generic/printps.cpp
src/generic/renderg.cpp
@@ -1681,6 +1680,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/msw/ole/droptgt.cpp
src/msw/ole/oleutils.cpp
src/msw/palette.cpp
src/msw/panel.cpp
src/msw/pen.cpp
src/msw/popupwin.cpp
src/msw/printdlg.cpp
@@ -2898,6 +2898,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
wx/univ/menu.h
wx/univ/menuitem.h
wx/univ/notebook.h
wx/univ/panel.h
wx/univ/radiobox.h
wx/univ/radiobut.h
wx/univ/renderer.h
+32 -32
View File
File diff suppressed because it is too large Load Diff
+40 -40
View File
File diff suppressed because it is too large Load Diff
+32 -32
View File
File diff suppressed because it is too large Load Diff
+40 -40
View File
File diff suppressed because it is too large Load Diff
+8 -4
View File
@@ -2073,6 +2073,10 @@ SOURCE=..\..\src\msw\palette.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\msw\panel.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\msw\pen.cpp
# End Source File
# Begin Source File
@@ -3166,10 +3170,6 @@ SOURCE=..\..\src\generic\numdlgg.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\generic\panelg.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\generic\printps.cpp
# End Source File
# Begin Source File
@@ -5678,6 +5678,10 @@ SOURCE=..\..\include\wx\univ\notebook.h
# End Source File
# Begin Source File
SOURCE=..\..\include\wx\univ\panel.h
# End Source File
# Begin Source File
SOURCE=..\..\include\wx\univ\radiobox.h
# End Source File
# Begin Source File
+6 -3
View File
@@ -1937,6 +1937,9 @@
RelativePath="..\..\src\msw\palette.cpp">
</File>
<File
RelativePath="..\..\src\msw\panel.cpp">
</File>
<File
RelativePath="..\..\src\msw\pen.cpp">
</File>
<File
@@ -2813,9 +2816,6 @@
<File
RelativePath="..\..\src\generic\numdlgg.cpp">
</File>
<File
RelativePath="..\..\src\generic\panelg.cpp">
</File>
<File
RelativePath="..\..\src\generic\printps.cpp">
</File>
@@ -4855,6 +4855,9 @@
RelativePath="..\..\include\wx\univ\notebook.h">
</File>
<File
RelativePath="..\..\include\wx\univ\panel.h">
</File>
<File
RelativePath="..\..\include\wx\univ\radiobox.h">
</File>
<File
+8 -4
View File
@@ -2616,6 +2616,10 @@
>
</File>
<File
RelativePath="..\..\src\msw\panel.cpp"
>
</File>
<File
RelativePath="..\..\src\msw\pen.cpp"
>
</File>
@@ -3784,10 +3788,6 @@
RelativePath="..\..\src\generic\numdlgg.cpp"
>
</File>
<File
RelativePath="..\..\src\generic\panelg.cpp"
>
</File>
<File
RelativePath="..\..\src\generic\printps.cpp"
>
@@ -6494,6 +6494,10 @@
>
</File>
<File
RelativePath="..\..\include\wx\univ\panel.h"
>
</File>
<File
RelativePath="..\..\include\wx\univ\radiobox.h"
>
</File>
+8 -4
View File
@@ -2612,6 +2612,10 @@
>
</File>
<File
RelativePath="..\..\src\msw\panel.cpp"
>
</File>
<File
RelativePath="..\..\src\msw\pen.cpp"
>
</File>
@@ -3780,10 +3784,6 @@
RelativePath="..\..\src\generic\numdlgg.cpp"
>
</File>
<File
RelativePath="..\..\src\generic\panelg.cpp"
>
</File>
<File
RelativePath="..\..\src\generic\printps.cpp"
>
@@ -6490,6 +6490,10 @@
>
</File>
<File
RelativePath="..\..\include\wx\univ\panel.h"
>
</File>
<File
RelativePath="..\..\include\wx\univ\radiobox.h"
>
</File>
+6 -62
View File
@@ -9,28 +9,13 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PANEL_H_
#define _WX_GENERIC_PANEL_H_
#ifndef _WX_GENERIC_PANELG_H_
#define _WX_GENERIC_PANELG_H_
// ----------------------------------------------------------------------------
// headers and forward declarations
// ----------------------------------------------------------------------------
#include "wx/window.h"
#include "wx/containr.h"
class WXDLLIMPEXP_FWD_CORE wxControlContainer;
extern WXDLLIMPEXP_DATA_CORE(const char) wxPanelNameStr[];
// ----------------------------------------------------------------------------
// wxPanel contains other controls and implements TAB traversal between them
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPanel : public wxWindow
class WXDLLIMPEXP_CORE wxPanel : public wxPanelBase
{
public:
wxPanel() { Init(); }
wxPanel() { }
// Old-style constructor (no default values for coordinates to avoid
// ambiguity with the new one)
@@ -39,8 +24,6 @@ public:
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr)
{
Init();
Create(parent, wxID_ANY, wxPoint(x, y), wxSize(width, height), style, name);
}
@@ -52,50 +35,11 @@ public:
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr)
{
Init();
Create(parent, winid, pos, size, style, name);
}
// Pseudo ctor
bool Create(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr);
virtual ~wxPanel();
// implementation from now on
// --------------------------
virtual void InitDialog();
#ifdef __WXUNIVERSAL__
virtual bool IsCanvasWindow() const { return true; }
#endif
#ifdef __WXMSW__
// This is overridden for MSW to return true for all panels that are child
// of a window with themed background (such as wxNotebook) which should
// show through the child panels.
virtual bool HasTransparentBackground();
#endif // __WXMSW__
WX_DECLARE_CONTROL_CONTAINER();
protected:
// common part of all ctors
void Init();
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxWindowBase::GetDefaultBorder(); }
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxPanel)
DECLARE_EVENT_TABLE()
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxPanel);
};
#endif
// _WX_GENERIC_PANEL_H_
#endif // _WX_GENERIC_PANELG_H_
+50
View File
@@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/panel.h
// Purpose: wxMSW-specific wxPanel class.
// Author: Vadim Zeitlin
// Created: 2011-03-18
// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PANEL_H_
#define _WX_MSW_PANEL_H_
// ----------------------------------------------------------------------------
// wxPanel
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPanel : public wxPanelBase
{
public:
wxPanel() { }
wxPanel(wxWindow *parent,
int x, int y, int width, int height,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr)
{
Create(parent, wxID_ANY, wxPoint(x, y), wxSize(width, height), style, name);
}
wxPanel(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr)
{
Create(parent, winid, pos, size, style, name);
}
// This is overridden for MSW to return true for all panels that are child
// of a window with themed background (such as wxNotebook) which should
// show through the child panels.
virtual bool HasTransparentBackground();
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxPanel);
};
#endif // _WX_MSW_PANEL_H_
+60 -2
View File
@@ -6,13 +6,71 @@
// Created:
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PANEL_H_BASE_
#define _WX_PANEL_H_BASE_
#include "wx/generic/panelg.h"
// ----------------------------------------------------------------------------
// headers and forward declarations
// ----------------------------------------------------------------------------
#include "wx/window.h"
#include "wx/containr.h"
class WXDLLIMPEXP_FWD_CORE wxControlContainer;
extern WXDLLIMPEXP_DATA_CORE(const char) wxPanelNameStr[];
// ----------------------------------------------------------------------------
// wxPanel contains other controls and implements TAB traversal between them
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPanelBase : public wxWindow
{
public:
wxPanelBase();
// Derived classes should also provide this constructor:
/*
wxPanelBase(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr);
*/
// Pseudo ctor
bool Create(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr);
// implementation from now on
// --------------------------
virtual void InitDialog();
WX_DECLARE_CONTROL_CONTAINER();
private:
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS(wxPanelBase);
};
#if defined(__WXUNIVERSAL__)
#include "wx/univ/panel.h"
#elif defined(__WXMSW__)
#include "wx/msw/panel.h"
#else
#include "wx/generic/panelg.h"
#endif
// _WX_PANELH_BASE_
#endif // _WX_PANELH_BASE_
+47
View File
@@ -0,0 +1,47 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/univ/panel.h
// Purpose: wxUniversal-specific wxPanel class.
// Author: Vadim Zeitlin
// Created: 2011-03-18
// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIV_PANEL_H_
#define _WX_UNIV_PANEL_H_
// ----------------------------------------------------------------------------
// wxPanel
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPanel : public wxPanelBase
{
public:
wxPanel() { }
wxPanel(wxWindow *parent,
int x, int y, int width, int height,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr)
{
Create(parent, wxID_ANY, wxPoint(x, y), wxSize(width, height), style, name);
}
wxPanel(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr)
{
Create(parent, winid, pos, size, style, name);
}
virtual bool IsCanvasWindow() const { return true; }
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxPanel);
};
#endif // _WX_UNIV_PANEL_H_
+49
View File
@@ -85,3 +85,52 @@ wxCONSTRUCTOR_6( wxPanel, wxWindow*, Parent, wxWindowID, Id, \
wxString, Name)
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxPanelBase, wxWindow)
WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanelBase)
END_EVENT_TABLE()
// ============================================================================
// implementation
// ============================================================================
WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanelBase, wxWindow)
// ----------------------------------------------------------------------------
// wxPanelBase creation
// ----------------------------------------------------------------------------
wxPanelBase::wxPanelBase()
{
WX_INIT_CONTROL_CONTAINER();
}
bool wxPanelBase::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
if ( !wxWindow::Create(parent, id, pos, size, style, name) )
return false;
// so that non-solid background renders correctly under GTK+:
SetThemeEnabled(true);
#if defined(__WXWINCE__) && (defined(__POCKETPC__) || defined(__SMARTPHONE__))
// Required to get solid control backgrounds under WinCE
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
#endif
return true;
}
void wxPanelBase::InitDialog()
{
wxInitDialogEvent event(GetId());
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
}
-107
View File
@@ -1,107 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/generic/panelg.cpp
// Purpose: wxPanel and the keyboard handling code
// Author: Julian Smart, Robert Roebling, Vadim Zeitlin
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/object.h"
#include "wx/font.h"
#include "wx/colour.h"
#include "wx/settings.h"
#include "wx/log.h"
#include "wx/panel.h"
#include "wx/containr.h"
#endif
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxPanel, wxWindow)
WX_EVENT_TABLE_CONTROL_CONTAINER(wxPanel)
END_EVENT_TABLE()
// ============================================================================
// implementation
// ============================================================================
WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel, wxWindow)
// ----------------------------------------------------------------------------
// wxPanel creation
// ----------------------------------------------------------------------------
void wxPanel::Init()
{
WX_INIT_CONTROL_CONTAINER();
}
bool wxPanel::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
if ( !wxWindow::Create(parent, id, pos, size, style, name) )
return false;
// so that non-solid background renders correctly under GTK+:
SetThemeEnabled(true);
#if defined(__WXWINCE__) && (defined(__POCKETPC__) || defined(__SMARTPHONE__))
// Required to get solid control backgrounds under WinCE
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
#endif
return true;
}
wxPanel::~wxPanel()
{
}
void wxPanel::InitDialog()
{
wxInitDialogEvent event(GetId());
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
}
#ifdef __WXMSW__
bool wxPanel::HasTransparentBackground()
{
for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
{
if ( win->MSWHasInheritableBackground() )
return true;
if ( win->IsTopLevel() )
break;
}
return false;
}
#endif // __WXMSW__
+46
View File
@@ -0,0 +1,46 @@
///////////////////////////////////////////////////////////////////////////////
// Name: src/msw/panel.cpp
// Purpose: Implementation of wxMSW-specific wxPanel class.
// Author: Vadim Zeitlin
// Created: 2011-03-18
// RCS-ID: $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/panel.h"
#endif // WX_PRECOMP
// ============================================================================
// implementation
// ============================================================================
bool wxPanel::HasTransparentBackground()
{
for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
{
if ( win->MSWHasInheritableBackground() )
return true;
if ( win->IsTopLevel() )
break;
}
return false;
}