]>
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 /////////////////////////////////////////////////////////////////////////////
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" wxWidgets headers)
28 #include "wx/gizmos/dynamicsash.h"
29 #include "wx/html/htmlwin.h"
31 #include "wx/cmdline.h"
33 class Demo
: public wxApp
39 class SashHtmlWindow
: public wxHtmlWindow
42 SashHtmlWindow(wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
45 long style
= wxHW_SCROLLBAR_NEVER
,
46 const wxString
& name
= wxT("sashHtmlWindow"));
48 wxSize
DoGetBestSize() const;
51 void OnSplit(wxDynamicSashSplitEvent
& event
);
58 const wxChar
*HTML_content
=
59 wxT("<P><H1>wxDynamicSashWindow demo</H1>")
60 wxT("<P>Here is an example of how you can use <TT>wxDynamicSashWindow</TT> to allow your users to ")
61 wxT("dynamically split and unify the views of your windows. Try dragging out a few splits ")
62 wxT("and then reunifying the window.")
63 wxT("<P>Also, see the <TT>dynsash_switch</TT> sample for an example of an application which ")
64 wxT("manages the scrollbars provided by <TT>wxDynamicSashWindow</TT> itself.");
68 wxInitAllImageHandlers();
70 wxFrame
*frame
= new wxFrame(NULL
, wxID_ANY
, wxT("Dynamic Sash Demo"));
71 frame
->SetSize(480, 480);
73 wxDynamicSashWindow
*sash
= new wxDynamicSashWindow(frame
, wxID_ANY
);
74 wxHtmlWindow
*html
= new SashHtmlWindow(sash
, wxID_ANY
);
75 html
->SetPage(HTML_content
);
83 SashHtmlWindow::SashHtmlWindow(wxWindow
*parent
, wxWindowID id
,
88 : wxHtmlWindow(parent
, id
, pos
, size
, style
, name
)
90 Connect(wxEVT_DYNAMIC_SASH_SPLIT
,
91 wxDynamicSashSplitEventHandler(SashHtmlWindow::OnSplit
));
96 wxSize
SashHtmlWindow::DoGetBestSize() const
98 wxHtmlContainerCell
*cell
= GetInternalRepresentation();
99 wxSize size
= GetSize();
103 cell
->Layout(size
.GetWidth());
104 return wxSize(cell
->GetWidth(), cell
->GetHeight());
107 return wxHtmlWindow::GetBestSize();
110 void SashHtmlWindow::OnSplit(wxDynamicSashSplitEvent
& WXUNUSED(event
))
112 wxHtmlWindow
*html
= new SashHtmlWindow(m_dyn_sash
, wxID_ANY
);
113 html
->SetPage(HTML_content
);