]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/gizmos/dynsash/dynsash.cpp
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 /////////////////////////////////////////////////////////////////////////////
14 #include <wx/gizmos/dynamicsash.h>
15 #include <wx/html/htmlwin.h>
18 class Demo
: public wxApp
{
23 class SashHtmlWindow
: public wxHtmlWindow
{
25 SashHtmlWindow(wxWindow
*parent
, wxWindowID id
= -1,
26 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
27 long style
= wxHW_SCROLLBAR_NEVER
, const wxString
& name
= "sashHtmlWindow");
29 wxSize
DoGetBestSize() const;
32 void OnSplit(wxDynamicSashSplitEvent
& event
);
40 "<P><H1>wxDynamicSashWindow demo</H1>"
41 "<P>Here is an example of how you can use <TT>wxDynamicSashWindow</TT> to allow your users to "
42 "dynamically split and unify the views of your windows. Try dragging out a few splits "
43 "and then reunifying the window."
44 "<P>Also, see the <TT>dynsash_switch</TT> sample for an example of an application which "
45 "manages the scrollbars provided by <TT>wxDynamicSashWindow</TT> itself."
49 wxInitAllImageHandlers();
51 wxFrame
*frame
= new wxFrame(NULL
, -1, "Dynamic Sash Demo");
52 frame
->SetSize(480, 480);
54 wxDynamicSashWindow
*sash
= new wxDynamicSashWindow(frame
, -1);
55 wxHtmlWindow
*html
= new SashHtmlWindow(sash
, -1);
56 html
->SetPage(HTML_content
);
64 SashHtmlWindow::SashHtmlWindow(wxWindow
*parent
, wxWindowID id
,
65 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
) :
66 wxHtmlWindow(parent
, id
, pos
, size
, style
, name
) {
67 Connect(-1, wxEVT_DYNAMIC_SASH_SPLIT
, (wxObjectEventFunction
)&SashHtmlWindow::OnSplit
);
72 wxSize
SashHtmlWindow::DoGetBestSize() const {
73 wxHtmlContainerCell
*cell
= GetInternalRepresentation();
74 wxSize size
= GetSize();
77 cell
->Layout(size
.GetWidth());
78 return wxSize(cell
->GetWidth(), cell
->GetHeight());
80 return wxHtmlWindow::GetBestSize();
83 void SashHtmlWindow::OnSplit(wxDynamicSashSplitEvent
& event
) {
84 wxHtmlWindow
*html
= new SashHtmlWindow(m_dyn_sash
, -1);
85 html
->SetPage(HTML_content
);