1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Test the wxDynamicSash class by creating a dynamic sash which
4 // contains an HTML view
5 // Author: Matt Kimball
9 // Copyright: (c) 2001 Matt Kimball
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 // For compilers that support precompilation, includes "wx/wx.h".
14 #include "wx/wxprec.h"
20 // for all others, include the necessary headers (this file is usually all you
21 // need because it includes almost all "standard" wxWindows headers)
28 #include <wx/gizmos/dynamicsash.h>
29 #include <wx/html/htmlwin.h>
31 #include <wx/cmdline.h>
33 class Demo
: public wxApp
{
38 class SashHtmlWindow
: public wxHtmlWindow
{
40 SashHtmlWindow(wxWindow
*parent
, wxWindowID id
= -1,
41 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
42 long style
= wxHW_SCROLLBAR_NEVER
, const wxString
& name
= "sashHtmlWindow");
44 wxSize
DoGetBestSize() const;
47 void OnSplit(wxDynamicSashSplitEvent
& event
);
55 "<P><H1>wxDynamicSashWindow demo</H1>"
56 "<P>Here is an example of how you can use <TT>wxDynamicSashWindow</TT> to allow your users to "
57 "dynamically split and unify the views of your windows. Try dragging out a few splits "
58 "and then reunifying the window."
59 "<P>Also, see the <TT>dynsash_switch</TT> sample for an example of an application which "
60 "manages the scrollbars provided by <TT>wxDynamicSashWindow</TT> itself."
64 wxInitAllImageHandlers();
66 wxFrame
*frame
= new wxFrame(NULL
, -1, "Dynamic Sash Demo");
67 frame
->SetSize(480, 480);
69 wxDynamicSashWindow
*sash
= new wxDynamicSashWindow(frame
, -1);
70 wxHtmlWindow
*html
= new SashHtmlWindow(sash
, -1);
71 html
->SetPage(HTML_content
);
79 SashHtmlWindow::SashHtmlWindow(wxWindow
*parent
, wxWindowID id
,
80 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
) :
81 wxHtmlWindow(parent
, id
, pos
, size
, style
, name
) {
82 Connect(-1, wxEVT_DYNAMIC_SASH_SPLIT
,
83 (wxObjectEventFunction
)(wxCommandEventFunction
)(wxDynamicSashSplitEventFunction
) &SashHtmlWindow::OnSplit
);
88 wxSize
SashHtmlWindow::DoGetBestSize() const {
89 wxHtmlContainerCell
*cell
= GetInternalRepresentation();
90 wxSize size
= GetSize();
93 cell
->Layout(size
.GetWidth());
94 return wxSize(cell
->GetWidth(), cell
->GetHeight());
96 return wxHtmlWindow::GetBestSize();
99 void SashHtmlWindow::OnSplit(wxDynamicSashSplitEvent
& event
) {
100 wxHtmlWindow
*html
= new SashHtmlWindow(m_dyn_sash
, -1);
101 html
->SetPage(HTML_content
);