cleanup: define events correctly, define type-safe event macros, reformatted
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33017 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -61,18 +61,14 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <wx/event.h>
|
||||
#include <wx/window.h>
|
||||
class wxScrollBar;
|
||||
#include "wx/event.h"
|
||||
#include "wx/window.h"
|
||||
|
||||
class WXDLLIMPEXP_CORE wxScrollBar;
|
||||
|
||||
#define wxEVT_DYNAMIC_SASH_BASE (((int)('d' - 'a') << 11) | ((int)('s' - 'a') << 6) | ((int)('h' - 'a') << 1))
|
||||
#define wxEVT_DYNAMIC_SASH_SPLIT (wxEVT_DYNAMIC_SASH_BASE + 1)
|
||||
#define wxEVT_DYNAMIC_SASH_UNIFY (wxEVT_DYNAMIC_SASH_BASE + 2)
|
||||
|
||||
#define EVT_DYNAMIC_SASH_SPLIT(id, func) EVT_CUSTOM(wxEVT_DYNAMIC_SASH_SPLIT, (id), (func))
|
||||
#define EVT_DYNAMIC_SASH_UNIFY(id, func) EVT_CUSTOM(wxEVT_DYNAMIC_SASH_UNIFY, (id), (func))
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// dynamic sash styles
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
wxDS_MANAGE_SCROLLBARS is a default style of wxDynamicSashWindow which
|
||||
@@ -89,6 +85,26 @@ class wxScrollBar;
|
||||
*/
|
||||
#define wxDS_DRAG_CORNER 0x0020
|
||||
|
||||
/*
|
||||
Default style for wxDynamicSashWindow.
|
||||
*/
|
||||
#define wxDS_DEFAULT wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// dynamic sash events
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern WXDLLIMPEXP_GIZMOS const wxEventType wxEVT_DYNAMIC_SASH_SPLIT;
|
||||
extern WXDLLIMPEXP_GIZMOS const wxEventType wxEVT_DYNAMIC_SASH_UNIFY;
|
||||
|
||||
#define EVT_DYNAMIC_SASH_SPLIT(id, func) \
|
||||
wx__DECLARE_EVT1(wxEVT_DYNAMIC_SASH_SPLIT, id, \
|
||||
wxDynamicSashSplitEventHandler(func))
|
||||
|
||||
#define EVT_DYNAMIC_SASH_UNIFY(id, func) \
|
||||
wx__DECLARE_EVT1(wxEVT_DYNAMIC_SASH_UNIFY, id, \
|
||||
wxDynamicSashUnifyEventHandler(func))
|
||||
|
||||
|
||||
/*
|
||||
wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
|
||||
@@ -97,10 +113,12 @@ class wxScrollBar;
|
||||
a child of the wxDynamicSashWindow. wxDynamicSashWindow will
|
||||
automatically reparent it to the proper place in its window hierarchy.
|
||||
*/
|
||||
class WXDLLIMPEXP_GIZMOS wxDynamicSashSplitEvent : public wxCommandEvent {
|
||||
class WXDLLIMPEXP_GIZMOS wxDynamicSashSplitEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
wxDynamicSashSplitEvent();
|
||||
wxDynamicSashSplitEvent(const wxDynamicSashSplitEvent& event): wxCommandEvent(event) { }
|
||||
wxDynamicSashSplitEvent(const wxDynamicSashSplitEvent& event)
|
||||
: wxCommandEvent(event) { }
|
||||
wxDynamicSashSplitEvent(wxObject *target);
|
||||
|
||||
virtual wxEvent* Clone() const { return new wxDynamicSashSplitEvent(*this); }
|
||||
@@ -119,7 +137,8 @@ private:
|
||||
the scrollbars' event handlers connected to your view's event handler
|
||||
class.
|
||||
*/
|
||||
class WXDLLIMPEXP_GIZMOS wxDynamicSashUnifyEvent : public wxCommandEvent {
|
||||
class WXDLLIMPEXP_GIZMOS wxDynamicSashUnifyEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
wxDynamicSashUnifyEvent();
|
||||
wxDynamicSashUnifyEvent(const wxDynamicSashUnifyEvent& event): wxCommandEvent(event) {}
|
||||
@@ -134,23 +153,37 @@ private:
|
||||
typedef void (wxEvtHandler::*wxDynamicSashSplitEventFunction)(wxDynamicSashSplitEvent&);
|
||||
typedef void (wxEvtHandler::*wxDynamicSashUnifyEventFunction)(wxDynamicSashUnifyEvent&);
|
||||
|
||||
/*
|
||||
wxDynamicSashWindow. See above.
|
||||
*/
|
||||
#define wxDynamicSashSplitEventHandler(func) \
|
||||
(wxObjectEventFunction)(wxEventFunction) \
|
||||
wxStaticCastEvent(wxDynamicSashSplitEventFunction, &func)
|
||||
|
||||
#define wxDynamicSashUnifyEventHandler(func) \
|
||||
(wxObjectEventFunction)(wxEventFunction) \
|
||||
wxStaticCastEvent(wxDynamicSashUnifyEventFunction, &func)
|
||||
|
||||
#define wx__DECLARE_TREEEVT(evt, id, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_ ## evt, id, wxTreeEventHandler(fn))
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDynamicSashWindow itself
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WXDLLIMPEXP_GIZMOS extern const wxChar* wxDynamicSashWindowNameStr;
|
||||
|
||||
class WXDLLIMPEXP_GIZMOS wxDynamicSashWindow : public wxWindow {
|
||||
class WXDLLIMPEXP_GIZMOS wxDynamicSashWindow : public wxWindow
|
||||
{
|
||||
public:
|
||||
wxDynamicSashWindow();
|
||||
wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
|
||||
long style = wxDS_DEFAULT,
|
||||
const wxString& name = wxDynamicSashWindowNameStr);
|
||||
virtual ~wxDynamicSashWindow();
|
||||
|
||||
virtual bool Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDS_DEFAULT,
|
||||
const wxString& name = wxDynamicSashWindowNameStr);
|
||||
virtual wxScrollBar *GetHScrollBar(const wxWindow *child) const;
|
||||
virtual wxScrollBar *GetVScrollBar(const wxWindow *child) const;
|
||||
@@ -165,5 +198,5 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxDynamicSashWindow)
|
||||
};
|
||||
|
||||
#endif // _WX_DYNAMICSASH_H_
|
||||
|
||||
#endif
|
||||
|
@@ -23,23 +23,27 @@
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include <wx/app.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/gizmos/dynamicsash.h>
|
||||
#include <wx/html/htmlwin.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/cmdline.h>
|
||||
#include "wx/app.h"
|
||||
#include "wx/frame.h"
|
||||
#include "wx/gizmos/dynamicsash.h"
|
||||
#include "wx/html/htmlwin.h"
|
||||
#include "wx/image.h"
|
||||
#include "wx/cmdline.h"
|
||||
|
||||
class Demo : public wxApp {
|
||||
class Demo : public wxApp
|
||||
{
|
||||
public:
|
||||
bool OnInit();
|
||||
};
|
||||
|
||||
class SashHtmlWindow : public wxHtmlWindow {
|
||||
class SashHtmlWindow : public wxHtmlWindow
|
||||
{
|
||||
public:
|
||||
SashHtmlWindow(wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = wxHW_SCROLLBAR_NEVER, const wxString& name = wxT("sashHtmlWindow"));
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxHW_SCROLLBAR_NEVER,
|
||||
const wxString& name = wxT("sashHtmlWindow"));
|
||||
|
||||
wxSize DoGetBestSize() const;
|
||||
|
||||
@@ -51,7 +55,7 @@ private:
|
||||
|
||||
IMPLEMENT_APP(Demo)
|
||||
|
||||
wxChar *HTML_content =
|
||||
const wxChar *HTML_content =
|
||||
wxT("<P><H1>wxDynamicSashWindow demo</H1>")
|
||||
wxT("<P>Here is an example of how you can use <TT>wxDynamicSashWindow</TT> to allow your users to ")
|
||||
wxT("dynamically split and unify the views of your windows. Try dragging out a few splits ")
|
||||
@@ -59,7 +63,8 @@ wxT("and then reunifying the window.")
|
||||
wxT("<P>Also, see the <TT>dynsash_switch</TT> sample for an example of an application which ")
|
||||
wxT("manages the scrollbars provided by <TT>wxDynamicSashWindow</TT> itself.");
|
||||
|
||||
bool Demo::OnInit() {
|
||||
bool Demo::OnInit()
|
||||
{
|
||||
wxInitAllImageHandlers();
|
||||
|
||||
wxFrame *frame = new wxFrame(NULL, wxID_ANY, wxT("Dynamic Sash Demo"));
|
||||
@@ -76,27 +81,34 @@ bool Demo::OnInit() {
|
||||
|
||||
|
||||
SashHtmlWindow::SashHtmlWindow(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name) :
|
||||
wxHtmlWindow(parent, id, pos, size, style, name) {
|
||||
Connect(wxID_ANY, wxEVT_DYNAMIC_SASH_SPLIT, (wxObjectEventFunction)
|
||||
(wxEventFunction)
|
||||
(wxDynamicSashSplitEventFunction)&SashHtmlWindow::OnSplit);
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
: wxHtmlWindow(parent, id, pos, size, style, name)
|
||||
{
|
||||
Connect(wxEVT_DYNAMIC_SASH_SPLIT,
|
||||
wxDynamicSashSplitEventHandler(SashHtmlWindow::OnSplit));
|
||||
|
||||
m_dyn_sash = parent;
|
||||
}
|
||||
|
||||
wxSize SashHtmlWindow::DoGetBestSize() const {
|
||||
wxSize SashHtmlWindow::DoGetBestSize() const
|
||||
{
|
||||
wxHtmlContainerCell *cell = GetInternalRepresentation();
|
||||
wxSize size = GetSize();
|
||||
|
||||
if (cell) {
|
||||
if (cell)
|
||||
{
|
||||
cell->Layout(size.GetWidth());
|
||||
return wxSize(cell->GetWidth(), cell->GetHeight());
|
||||
} else
|
||||
}
|
||||
|
||||
return wxHtmlWindow::GetBestSize();
|
||||
}
|
||||
|
||||
void SashHtmlWindow::OnSplit(wxDynamicSashSplitEvent& WXUNUSED(event)) {
|
||||
void SashHtmlWindow::OnSplit(wxDynamicSashSplitEvent& WXUNUSED(event))
|
||||
{
|
||||
wxHtmlWindow *html = new SashHtmlWindow(m_dyn_sash, wxID_ANY);
|
||||
html->SetPage(HTML_content);
|
||||
}
|
||||
|
@@ -92,9 +92,9 @@ const wxChar* wxDynamicSashWindowNameStr = wxT("dynamicSashWindow");
|
||||
#include <wx/settings.h>
|
||||
|
||||
|
||||
#define wxEVT_DYNAMIC_SASH_PRIVATE (wxEVT_DYNAMIC_SASH_BASE + 8)
|
||||
#define wxEVT_DYNAMIC_SASH_REPARENT (wxEVT_DYNAMIC_SASH_PRIVATE + 1)
|
||||
|
||||
const wxEventType wxEVT_DYNAMIC_SASH_SPLIT = wxNewEventType();
|
||||
const wxEventType wxEVT_DYNAMIC_SASH_UNIFY = wxNewEventType();
|
||||
const wxEventType wxEVT_DYNAMIC_SASH_REPARENT = wxNewEventType();
|
||||
|
||||
/*
|
||||
wxDynamicSashReparentEvent is generated by the AddChild() method of
|
||||
|
Reference in New Issue
Block a user