]> git.saurik.com Git - wxWidgets.git/blame - contrib/samples/gizmos/dynsash/dynsash.cpp
Removed very out of date files in docs/msw
[wxWidgets.git] / contrib / samples / gizmos / dynsash / dynsash.cpp
CommitLineData
eacb91fc
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: dynsash.cpp
3// Purpose: Test the wxDynamicSash class by creating a dynamic sash which
4// contains an HTML view
5// Author: Matt Kimball
6// Modified by:
7// Created: 7/15/2001
8// RCS-ID: $Id$
9// Copyright: (c) 2001 Matt Kimball
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
cd72551c
JS
13// For compilers that support precompilation, includes "wx/wx.h".
14#include "wx/wxprec.h"
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20// for all others, include the necessary headers (this file is usually all you
be5a51fb 21// need because it includes almost all "standard" wxWidgets headers)
cd72551c
JS
22#ifndef WX_PRECOMP
23 #include "wx/wx.h"
24#endif
25
0ed0bcc8
VZ
26#include "wx/app.h"
27#include "wx/frame.h"
28#include "wx/gizmos/dynamicsash.h"
29#include "wx/html/htmlwin.h"
30#include "wx/image.h"
31#include "wx/cmdline.h"
32
33class Demo : public wxApp
34{
eacb91fc
VZ
35public:
36 bool OnInit();
37};
38
0ed0bcc8
VZ
39class SashHtmlWindow : public wxHtmlWindow
40{
eacb91fc 41public:
a2d49353 42 SashHtmlWindow(wxWindow *parent, wxWindowID id = wxID_ANY,
0ed0bcc8
VZ
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = wxHW_SCROLLBAR_NEVER,
46 const wxString& name = wxT("sashHtmlWindow"));
eacb91fc
VZ
47
48 wxSize DoGetBestSize() const;
49
50private:
51 void OnSplit(wxDynamicSashSplitEvent& event);
52
53 wxWindow *m_dyn_sash;
54};
55
56IMPLEMENT_APP(Demo)
57
0ed0bcc8 58const wxChar *HTML_content =
ba597ca8
JS
59wxT("<P><H1>wxDynamicSashWindow demo</H1>")
60wxT("<P>Here is an example of how you can use <TT>wxDynamicSashWindow</TT> to allow your users to ")
61wxT("dynamically split and unify the views of your windows. Try dragging out a few splits ")
62wxT("and then reunifying the window.")
63wxT("<P>Also, see the <TT>dynsash_switch</TT> sample for an example of an application which ")
64wxT("manages the scrollbars provided by <TT>wxDynamicSashWindow</TT> itself.");
eacb91fc 65
0ed0bcc8
VZ
66bool Demo::OnInit()
67{
eacb91fc
VZ
68 wxInitAllImageHandlers();
69
a2d49353 70 wxFrame *frame = new wxFrame(NULL, wxID_ANY, wxT("Dynamic Sash Demo"));
eacb91fc
VZ
71 frame->SetSize(480, 480);
72
a2d49353
WS
73 wxDynamicSashWindow *sash = new wxDynamicSashWindow(frame, wxID_ANY);
74 wxHtmlWindow *html = new SashHtmlWindow(sash, wxID_ANY);
eacb91fc
VZ
75 html->SetPage(HTML_content);
76
77 frame->Show();
78
a2d49353 79 return true;
eacb91fc
VZ
80}
81
82
83SashHtmlWindow::SashHtmlWindow(wxWindow *parent, wxWindowID id,
0ed0bcc8
VZ
84 const wxPoint& pos,
85 const wxSize& size,
86 long style,
87 const wxString& name)
88 : wxHtmlWindow(parent, id, pos, size, style, name)
89{
90 Connect(wxEVT_DYNAMIC_SASH_SPLIT,
91 wxDynamicSashSplitEventHandler(SashHtmlWindow::OnSplit));
eacb91fc
VZ
92
93 m_dyn_sash = parent;
94}
95
0ed0bcc8
VZ
96wxSize SashHtmlWindow::DoGetBestSize() const
97{
eacb91fc
VZ
98 wxHtmlContainerCell *cell = GetInternalRepresentation();
99 wxSize size = GetSize();
100
0ed0bcc8
VZ
101 if (cell)
102 {
eacb91fc
VZ
103 cell->Layout(size.GetWidth());
104 return wxSize(cell->GetWidth(), cell->GetHeight());
0ed0bcc8
VZ
105 }
106
107 return wxHtmlWindow::GetBestSize();
eacb91fc
VZ
108}
109
0ed0bcc8
VZ
110void SashHtmlWindow::OnSplit(wxDynamicSashSplitEvent& WXUNUSED(event))
111{
a2d49353 112 wxHtmlWindow *html = new SashHtmlWindow(m_dyn_sash, wxID_ANY);
eacb91fc
VZ
113 html->SetPage(HTML_content);
114}