Remove DLL export declaration from wxScrolled.

As this class has only inline methods it doesn't need to be exported from the
DLL and actually exporting it results in linking problems when using
wxScrolled<wxWindow> (which, unlike wxScrolled<wxPanel>, is not used in wx
itself and so doesn't seem to be instantiated) in DLL client even with VC > 6.

An alternative solution would be to change WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE
macro to explicitly instantiate the template in the DLL even for VC > 6 but
this wouldn't solve the problem for wxScrolled<CustomClass> while removing the
DLL export declaration should.

Also use wxScrolled<wxWindow> in addition to wxScrolled<wxPanel> in the scroll
sample to test that it links correctly.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62036 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-09-23 14:28:42 +00:00
parent 5ec3853fa6
commit cb7c02fd46
2 changed files with 33 additions and 39 deletions

View File

@@ -333,9 +333,9 @@ struct WXDLLIMPEXP_CORE wxScrolledT_Helper
// but wxScrolledWindow includes wxControlContainer functionality and that's // but wxScrolledWindow includes wxControlContainer functionality and that's
// not always desirable. // not always desirable.
template<class T> template<class T>
class WXDLLIMPEXP_CORE wxScrolled : public T, class wxScrolled : public T,
public wxScrollHelper, public wxScrollHelper,
private wxScrolledT_Helper private wxScrolledT_Helper
{ {
public: public:
wxScrolled() : wxScrollHelper(this) { } wxScrolled() : wxScrollHelper(this) { }
@@ -409,12 +409,6 @@ private:
#endif #endif
}; };
// VC++ <= 6 requires this; it's unlikely any other specializations would
// be needed by user code _and_ they were using VC6, so we list only wxWindow
// (typical use) and wxPanel (wxScrolledWindow use) specializations here
WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE( wxScrolled<wxPanel> )
WXDLLIMPEXP_TEMPLATE_INSTANCE_CORE( wxScrolled<wxWindow> )
// for compatibility with existing code, we provide wxScrolledWindow // for compatibility with existing code, we provide wxScrolledWindow
// "typedef" for wxScrolled<wxPanel>. It's not a real typedef because we // "typedef" for wxScrolled<wxPanel>. It's not a real typedef because we
// want wxScrolledWindow to show in wxRTTI information (the class is widely // want wxScrolledWindow to show in wxRTTI information (the class is widely

View File

@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: scroll.cpp // Name: scroll.cpp
// Purpose: wxScrolledWindow sample // Purpose: wxScrolled sample
// Author: Robert Roebling // Author: Robert Roebling
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (C) 1998 Robert Roebling, 2002 Ron Lee, 2003 Matt Gregory // Copyright: (C) 1998 Robert Roebling, 2002 Ron Lee, 2003 Matt Gregory
@@ -31,7 +31,7 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// MySimpleCanvas: a scrolled window which draws a simple rectangle // MySimpleCanvas: a scrolled window which draws a simple rectangle
class MySimpleCanvas : public wxScrolledWindow class MySimpleCanvas : public wxScrolled<wxWindow>
{ {
public: public:
enum enum
@@ -44,7 +44,7 @@ public:
}; };
MySimpleCanvas(wxWindow *parent) MySimpleCanvas(wxWindow *parent)
: wxScrolledWindow(parent, wxID_ANY) : wxScrolled<wxWindow>(parent, wxID_ANY)
{ {
SetScrollRate( 10, 10 ); SetScrollRate( 10, 10 );
SetVirtualSize( WIDTH, HEIGHT ); SetVirtualSize( WIDTH, HEIGHT );
@@ -90,7 +90,7 @@ public:
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// MyCanvas // MyCanvas
class MyCanvas : public wxScrolledWindow class MyCanvas : public wxScrolled<wxPanel>
{ {
public: public:
MyCanvas(wxWindow *parent); MyCanvas(wxWindow *parent);
@@ -149,13 +149,13 @@ private:
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// example using sizers with wxScrolledWindow // example using sizers with wxScrolled
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
const wxSize SMALL_BUTTON( 100, 50 ); const wxSize SMALL_BUTTON( 100, 50 );
const wxSize LARGE_BUTTON( 300, 200 ); const wxSize LARGE_BUTTON( 300, 200 );
class MySizerScrolledWindow : public wxScrolledWindow class MySizerScrolledWindow : public wxScrolled<wxWindow>
{ {
public: public:
MySizerScrolledWindow(wxWindow *parent); MySizerScrolledWindow(wxWindow *parent);
@@ -193,7 +193,7 @@ public:
class MySubColLabels : public wxWindow class MySubColLabels : public wxWindow
{ {
public: public:
MySubColLabels(wxScrolledWindow *parent) MySubColLabels(wxScrolled<wxWindow> *parent)
: wxWindow(parent, wxID_ANY) : wxWindow(parent, wxID_ANY)
{ {
m_owner = parent; m_owner = parent;
@@ -222,13 +222,13 @@ private:
dc.DrawText("Column 3", 205, 5); dc.DrawText("Column 3", 205, 5);
} }
wxScrolledWindow *m_owner; wxScrolled<wxWindow> *m_owner;
}; };
class MySubRowLabels : public wxWindow class MySubRowLabels : public wxWindow
{ {
public: public:
MySubRowLabels(wxScrolledWindow *parent) MySubRowLabels(wxScrolled<wxWindow> *parent)
: wxWindow(parent, wxID_ANY) : wxWindow(parent, wxID_ANY)
{ {
m_owner = parent; m_owner = parent;
@@ -260,13 +260,13 @@ private:
dc.DrawText("Row 6", 5, 130); dc.DrawText("Row 6", 5, 130);
} }
wxScrolledWindow *m_owner; wxScrolled<wxWindow> *m_owner;
}; };
class MySubCanvas : public wxPanel class MySubCanvas : public wxPanel
{ {
public: public:
MySubCanvas(wxScrolledWindow *parent, wxWindow *cols, wxWindow *rows) MySubCanvas(wxScrolled<wxWindow> *parent, wxWindow *cols, wxWindow *rows)
: wxPanel(parent, wxID_ANY) : wxPanel(parent, wxID_ANY)
{ {
m_owner = parent; m_owner = parent;
@@ -358,12 +358,12 @@ private:
} }
} }
wxScrolledWindow *m_owner; wxScrolled<wxWindow> *m_owner;
wxWindow *m_colLabels, wxWindow *m_colLabels,
*m_rowLabels; *m_rowLabels;
}; };
class MySubScrolledWindow : public wxScrolledWindow class MySubScrolledWindow : public wxScrolled<wxWindow>
{ {
public: public:
enum enum
@@ -373,7 +373,7 @@ public:
}; };
MySubScrolledWindow(wxWindow *parent) MySubScrolledWindow(wxWindow *parent)
: wxScrolledWindow(parent, wxID_ANY) : wxScrolled<wxWindow>(parent, wxID_ANY)
{ {
// create the children // create the children
MySubColLabels *cols = new MySubColLabels(this); MySubColLabels *cols = new MySubColLabels(this);
@@ -444,17 +444,17 @@ public:
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// more simple examples of wxScrolledWindow usage // more simple examples of wxScrolled usage
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// base class for both of them // base class for both of them
class MyScrolledWindowBase : public wxScrolledWindow class MyScrolledWindowBase : public wxScrolled<wxWindow>
{ {
public: public:
MyScrolledWindowBase(wxWindow *parent) MyScrolledWindowBase(wxWindow *parent)
: wxScrolledWindow(parent, wxID_ANY, : wxScrolled<wxWindow>(parent, wxID_ANY,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
wxBORDER_SUNKEN) wxBORDER_SUNKEN)
{ {
m_nLines = 50; m_nLines = 50;
m_winSync = NULL; m_winSync = NULL;
@@ -476,7 +476,7 @@ public:
virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL) virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL)
{ {
wxScrolledWindow::ScrollWindow(dx, dy, rect); wxScrolled<wxWindow>::ScrollWindow(dx, dy, rect);
DoSyncIfNecessary(); DoSyncIfNecessary();
} }
@@ -551,7 +551,7 @@ public:
// functionality // functionality
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class MyAutoScrollingWindow : public wxScrolledWindow class MyAutoScrollingWindow : public wxScrolled<wxWindow>
{ {
public: public:
MyAutoScrollingWindow( wxWindow* parent ); MyAutoScrollingWindow( wxWindow* parent );
@@ -660,7 +660,7 @@ const wxWindowID ID_QUERYPOS = wxWindow::NewControlId();
const wxWindowID ID_NEWBUTTON = wxWindow::NewControlId(); const wxWindowID ID_NEWBUTTON = wxWindow::NewControlId();
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) BEGIN_EVENT_TABLE(MyCanvas, wxScrolled<wxPanel>)
EVT_PAINT( MyCanvas::OnPaint) EVT_PAINT( MyCanvas::OnPaint)
EVT_RIGHT_DOWN( MyCanvas::OnMouseRightDown) EVT_RIGHT_DOWN( MyCanvas::OnMouseRightDown)
EVT_MOUSEWHEEL( MyCanvas::OnMouseWheel) EVT_MOUSEWHEEL( MyCanvas::OnMouseWheel)
@@ -672,9 +672,9 @@ BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
MyCanvas::MyCanvas(wxWindow *parent) MyCanvas::MyCanvas(wxWindow *parent)
: wxScrolledWindow(parent, wxID_ANY, : wxScrolled<wxPanel>(parent, wxID_ANY,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
wxSUNKEN_BORDER | wxTAB_TRAVERSAL) wxSUNKEN_BORDER | wxTAB_TRAVERSAL)
{ {
// you can use either a single SetScrollbars() call or these 2 functions, // you can use either a single SetScrollbars() call or these 2 functions,
// usually using them is better because you normally won't need to change // usually using them is better because you normally won't need to change
@@ -781,7 +781,7 @@ void MyCanvas::OnScrollWin( wxCommandEvent &WXUNUSED(event) )
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
MySizerScrolledWindow::MySizerScrolledWindow(wxWindow *parent) MySizerScrolledWindow::MySizerScrolledWindow(wxWindow *parent)
: wxScrolledWindow(parent) : wxScrolled<wxWindow>(parent)
{ {
SetBackgroundColour( "GREEN" ); SetBackgroundColour( "GREEN" );
@@ -963,7 +963,7 @@ void MyFrame::OnQuit(wxCommandEvent &WXUNUSED(event))
void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) ) void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
{ {
(void)wxMessageBox( "wxScrolledWindow sample\n" (void)wxMessageBox( "Scrolled window sample\n"
"\n" "\n"
"Robert Roebling (c) 1998\n" "Robert Roebling (c) 1998\n"
"Vadim Zeitlin (c) 2008\n" "Vadim Zeitlin (c) 2008\n"
@@ -1046,7 +1046,7 @@ void MyScrolledWindowSmart::OnDraw(wxDC& dc)
// MyAutoScrollingWindow // MyAutoScrollingWindow
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(MyAutoScrollingWindow, wxScrolledWindow) BEGIN_EVENT_TABLE(MyAutoScrollingWindow, wxScrolled<wxWindow>)
EVT_LEFT_DOWN(MyAutoScrollingWindow::OnMouseLeftDown) EVT_LEFT_DOWN(MyAutoScrollingWindow::OnMouseLeftDown)
EVT_LEFT_UP(MyAutoScrollingWindow::OnMouseLeftUp) EVT_LEFT_UP(MyAutoScrollingWindow::OnMouseLeftUp)
EVT_MOTION(MyAutoScrollingWindow::OnMouseMove) EVT_MOTION(MyAutoScrollingWindow::OnMouseMove)
@@ -1055,8 +1055,8 @@ BEGIN_EVENT_TABLE(MyAutoScrollingWindow, wxScrolledWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
MyAutoScrollingWindow::MyAutoScrollingWindow(wxWindow* parent) MyAutoScrollingWindow::MyAutoScrollingWindow(wxWindow* parent)
: wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, : wxScrolled<wxWindow>(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxVSCROLL | wxHSCROLL | wxSUNKEN_BORDER), wxVSCROLL | wxHSCROLL | wxSUNKEN_BORDER),
m_selStart(-1, -1), m_selStart(-1, -1),
m_cursor(-1, -1), m_cursor(-1, -1),
m_font(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL) m_font(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)