2001-08-22 11:02:40 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dynamicsash.h
|
|
|
|
// Purpose: A window which can be dynamically split to an arbitrary depth
|
|
|
|
// and later reunified through the user interface
|
|
|
|
// Author: Matt Kimball
|
|
|
|
// Modified by:
|
|
|
|
// Created: 7/15/2001
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2001 Matt Kimball
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_DYNAMICSASH_H_
|
|
|
|
#define _WX_DYNAMICSASH_H_
|
|
|
|
|
2003-07-19 08:03:47 -04:00
|
|
|
#include "wx/gizmos/gizmos.h"
|
2001-11-26 14:58:06 -05:00
|
|
|
|
2001-08-22 11:02:40 -04:00
|
|
|
/*
|
|
|
|
|
|
|
|
wxDynamicSashWindow
|
|
|
|
|
|
|
|
wxDynamicSashWindow widgets manages the way other widgets are viewed.
|
|
|
|
When a wxDynamicSashWindow is first shown, it will contain one child
|
|
|
|
view, a viewport for that child, and a pair of scrollbars to allow the
|
|
|
|
user to navigate the child view area. Next to each scrollbar is a small
|
|
|
|
tab. By clicking on either tab and dragging to the appropriate spot, a
|
|
|
|
user can split the view area into two smaller views separated by a
|
|
|
|
draggable sash. Later, when the user wishes to reunify the two subviews,
|
|
|
|
the user simply drags the sash to the side of the window.
|
|
|
|
wxDynamicSashWindow will automatically reparent the appropriate child
|
|
|
|
view back up the window hierarchy, and the wxDynamicSashWindow will have
|
|
|
|
only one child view once again.
|
|
|
|
|
|
|
|
As an application developer, you will simply create a wxDynamicSashWindow
|
|
|
|
using either the Create() function or the more complex constructor
|
|
|
|
provided below, and then create a view window whose parent is the
|
|
|
|
wxDynamicSashWindow. The child should respond to
|
|
|
|
wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
|
|
|
|
constructing a new view window whose parent is also the
|
|
|
|
wxDynamicSashWindow. That's it! Now your users can dynamically split
|
|
|
|
and reunify the view you provided.
|
|
|
|
|
|
|
|
If you wish to handle the scrollbar events for your view, rather than
|
|
|
|
allowing wxDynamicSashWindow to do it for you, things are a bit more
|
|
|
|
complex. (You might want to handle scrollbar events yourself, if,
|
|
|
|
for instance, you wish to scroll a subwindow of the view you add to
|
|
|
|
your wxDynamicSashWindow object, rather than scrolling the whole view.)
|
|
|
|
In this case, you will need to construct your wxDynamicSashWindow without
|
2001-11-25 03:51:43 -05:00
|
|
|
the wxDS_MANAGE_SCROLLBARS style and you will need to use the
|
2001-08-22 11:02:40 -04:00
|
|
|
GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
|
|
|
|
controls and call SetEventHanler() on them to redirect the scrolling
|
|
|
|
events whenever your window is reparented by wxDyanmicSashWindow.
|
|
|
|
You will need to set the scrollbars' event handler at three times:
|
|
|
|
|
|
|
|
* When your view is created
|
|
|
|
* When your view receives a wxDynamicSashSplitEvent
|
|
|
|
* When your view receives a wxDynamicSashUnifyEvent
|
|
|
|
|
|
|
|
See the dynsash_switch sample application for an example which does this.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2005-03-24 05:27:27 -05:00
|
|
|
#include "wx/event.h"
|
|
|
|
#include "wx/window.h"
|
2001-08-22 11:02:40 -04:00
|
|
|
|
2005-03-24 05:27:27 -05:00
|
|
|
class WXDLLIMPEXP_CORE wxScrollBar;
|
2001-08-22 11:02:40 -04:00
|
|
|
|
2005-03-24 05:27:27 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// dynamic sash styles
|
|
|
|
// ----------------------------------------------------------------------------
|
2001-08-22 11:02:40 -04:00
|
|
|
|
|
|
|
/*
|
2001-11-25 03:51:43 -05:00
|
|
|
wxDS_MANAGE_SCROLLBARS is a default style of wxDynamicSashWindow which
|
2001-08-22 11:02:40 -04:00
|
|
|
will cause it to respond to scrollbar events for your application by
|
|
|
|
automatically scrolling the child view.
|
|
|
|
*/
|
2001-11-25 03:51:43 -05:00
|
|
|
#define wxDS_MANAGE_SCROLLBARS 0x0010
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
wxDS_DRAG_CORNER style indicates that the views can also be resized by
|
|
|
|
dragging the corner piece between the scrollbars, and which is reflected up
|
|
|
|
to the frame if necessary.
|
|
|
|
*/
|
|
|
|
#define wxDS_DRAG_CORNER 0x0020
|
2001-08-22 11:02:40 -04:00
|
|
|
|
2005-03-24 05:27:27 -05:00
|
|
|
/*
|
|
|
|
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))
|
|
|
|
|
2001-08-22 11:02:40 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
|
|
|
|
whenever your view is being split by the user. It is your
|
|
|
|
responsibility to handle this event by creating a new view window as
|
|
|
|
a child of the wxDynamicSashWindow. wxDynamicSashWindow will
|
|
|
|
automatically reparent it to the proper place in its window hierarchy.
|
|
|
|
*/
|
2005-03-24 05:27:27 -05:00
|
|
|
class WXDLLIMPEXP_GIZMOS wxDynamicSashSplitEvent : public wxCommandEvent
|
|
|
|
{
|
2001-08-22 11:02:40 -04:00
|
|
|
public:
|
|
|
|
wxDynamicSashSplitEvent();
|
2005-03-24 05:27:27 -05:00
|
|
|
wxDynamicSashSplitEvent(const wxDynamicSashSplitEvent& event)
|
|
|
|
: wxCommandEvent(event) { }
|
2001-08-22 11:02:40 -04:00
|
|
|
wxDynamicSashSplitEvent(wxObject *target);
|
|
|
|
|
2001-11-23 07:37:00 -05:00
|
|
|
virtual wxEvent* Clone() const { return new wxDynamicSashSplitEvent(*this); }
|
|
|
|
|
2001-08-22 11:02:40 -04:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxDynamicSashSplitEvent)
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
|
|
|
|
whenever the sash which splits your view and its sibling is being
|
|
|
|
reunified such that your view is expanding to replace its sibling.
|
|
|
|
You needn't do anything with this event if you are allowing
|
|
|
|
wxDynamicSashWindow to manage your view's scrollbars, but it is useful
|
|
|
|
if you are managing the scrollbars yourself so that you can keep
|
|
|
|
the scrollbars' event handlers connected to your view's event handler
|
|
|
|
class.
|
|
|
|
*/
|
2005-03-24 05:27:27 -05:00
|
|
|
class WXDLLIMPEXP_GIZMOS wxDynamicSashUnifyEvent : public wxCommandEvent
|
|
|
|
{
|
2001-08-22 11:02:40 -04:00
|
|
|
public:
|
|
|
|
wxDynamicSashUnifyEvent();
|
2001-11-23 07:37:00 -05:00
|
|
|
wxDynamicSashUnifyEvent(const wxDynamicSashUnifyEvent& event): wxCommandEvent(event) {}
|
2001-08-22 11:02:40 -04:00
|
|
|
wxDynamicSashUnifyEvent(wxObject *target);
|
|
|
|
|
2001-11-23 07:37:00 -05:00
|
|
|
virtual wxEvent* Clone() const { return new wxDynamicSashUnifyEvent(*this); }
|
|
|
|
|
2001-08-22 11:02:40 -04:00
|
|
|
private:
|
2005-02-09 09:14:21 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxDynamicSashUnifyEvent)
|
2001-08-22 11:02:40 -04:00
|
|
|
};
|
|
|
|
|
2002-03-07 05:06:23 -05:00
|
|
|
typedef void (wxEvtHandler::*wxDynamicSashSplitEventFunction)(wxDynamicSashSplitEvent&);
|
2004-01-08 03:35:31 -05:00
|
|
|
typedef void (wxEvtHandler::*wxDynamicSashUnifyEventFunction)(wxDynamicSashUnifyEvent&);
|
2002-03-07 05:06:23 -05:00
|
|
|
|
2005-03-24 05:27:27 -05:00
|
|
|
#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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-07-25 20:18:57 -04:00
|
|
|
WXDLLIMPEXP_GIZMOS extern const wxChar* wxDynamicSashWindowNameStr;
|
2002-12-18 01:24:15 -05:00
|
|
|
|
2005-03-24 05:27:27 -05:00
|
|
|
class WXDLLIMPEXP_GIZMOS wxDynamicSashWindow : public wxWindow
|
|
|
|
{
|
2001-08-22 11:02:40 -04:00
|
|
|
public:
|
|
|
|
wxDynamicSashWindow();
|
|
|
|
wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
2005-03-24 05:27:27 -05:00
|
|
|
long style = wxDS_DEFAULT,
|
2002-12-18 01:24:15 -05:00
|
|
|
const wxString& name = wxDynamicSashWindowNameStr);
|
2001-08-22 11:02:40 -04:00
|
|
|
virtual ~wxDynamicSashWindow();
|
|
|
|
|
|
|
|
virtual bool Create(wxWindow *parent, wxWindowID id,
|
2005-03-24 05:27:27 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDS_DEFAULT,
|
2002-12-18 01:24:15 -05:00
|
|
|
const wxString& name = wxDynamicSashWindowNameStr);
|
2001-08-22 11:02:40 -04:00
|
|
|
virtual wxScrollBar *GetHScrollBar(const wxWindow *child) const;
|
|
|
|
virtual wxScrollBar *GetVScrollBar(const wxWindow *child) const;
|
|
|
|
|
|
|
|
/* This is overloaded from wxWindowBase. It's not here for you to
|
|
|
|
call directly. */
|
|
|
|
virtual void AddChild(wxWindowBase *child);
|
|
|
|
|
|
|
|
private:
|
|
|
|
class wxDynamicSashWindowImpl *m_impl;
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxDynamicSashWindow)
|
|
|
|
};
|
|
|
|
|
2005-03-24 05:27:27 -05:00
|
|
|
#endif // _WX_DYNAMICSASH_H_
|
2001-08-22 11:02:40 -04:00
|
|
|
|