2001-08-22 11:02:40 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dynsash.cpp
|
|
|
|
// Purpose: Test the wxDynamicSash class by creating a dynamic sash which
|
|
|
|
// contains an HTML view
|
|
|
|
// Author: Matt Kimball
|
|
|
|
// Modified by:
|
|
|
|
// Created: 7/15/2001
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2001 Matt Kimball
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2002-03-07 05:06:23 -05:00
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// for all others, include the necessary headers (this file is usually all you
|
2004-05-25 07:20:37 -04:00
|
|
|
// need because it includes almost all "standard" wxWidgets headers)
|
2002-03-07 05:06:23 -05:00
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
2001-08-22 11:02:40 -04:00
|
|
|
#include <wx/app.h>
|
2002-01-13 12:37:23 -05:00
|
|
|
#include <wx/frame.h>
|
2001-08-22 11:02:40 -04:00
|
|
|
#include <wx/gizmos/dynamicsash.h>
|
|
|
|
#include <wx/html/htmlwin.h>
|
|
|
|
#include <wx/image.h>
|
2002-03-07 05:06:23 -05:00
|
|
|
#include <wx/cmdline.h>
|
2001-08-22 11:02:40 -04:00
|
|
|
|
|
|
|
class Demo : public wxApp {
|
|
|
|
public:
|
|
|
|
bool OnInit();
|
|
|
|
};
|
|
|
|
|
|
|
|
class SashHtmlWindow : public wxHtmlWindow {
|
|
|
|
public:
|
2004-06-08 15:27:42 -04:00
|
|
|
SashHtmlWindow(wxWindow *parent, wxWindowID id = wxID_ANY,
|
2001-08-22 11:02:40 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
2003-07-10 07:44:49 -04:00
|
|
|
long style = wxHW_SCROLLBAR_NEVER, const wxString& name = wxT("sashHtmlWindow"));
|
2001-08-22 11:02:40 -04:00
|
|
|
|
|
|
|
wxSize DoGetBestSize() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void OnSplit(wxDynamicSashSplitEvent& event);
|
|
|
|
|
|
|
|
wxWindow *m_dyn_sash;
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_APP(Demo)
|
|
|
|
|
2003-07-10 07:44:49 -04:00
|
|
|
wxChar *HTML_content =
|
2004-01-08 03:35:31 -05:00
|
|
|
wxT("<P><H1>wxDynamicSashWindow demo</H1>")
|
|
|
|
wxT("<P>Here is an example of how you can use <TT>wxDynamicSashWindow</TT> to allow your users to ")
|
|
|
|
wxT("dynamically split and unify the views of your windows. Try dragging out a few splits ")
|
|
|
|
wxT("and then reunifying the window.")
|
|
|
|
wxT("<P>Also, see the <TT>dynsash_switch</TT> sample for an example of an application which ")
|
|
|
|
wxT("manages the scrollbars provided by <TT>wxDynamicSashWindow</TT> itself.");
|
2001-08-22 11:02:40 -04:00
|
|
|
|
|
|
|
bool Demo::OnInit() {
|
|
|
|
wxInitAllImageHandlers();
|
|
|
|
|
2004-06-08 15:27:42 -04:00
|
|
|
wxFrame *frame = new wxFrame(NULL, wxID_ANY, wxT("Dynamic Sash Demo"));
|
2001-08-22 11:02:40 -04:00
|
|
|
frame->SetSize(480, 480);
|
|
|
|
|
2004-06-08 15:27:42 -04:00
|
|
|
wxDynamicSashWindow *sash = new wxDynamicSashWindow(frame, wxID_ANY);
|
|
|
|
wxHtmlWindow *html = new SashHtmlWindow(sash, wxID_ANY);
|
2001-08-22 11:02:40 -04:00
|
|
|
html->SetPage(HTML_content);
|
|
|
|
|
|
|
|
frame->Show();
|
|
|
|
|
2004-06-08 15:27:42 -04:00
|
|
|
return true;
|
2001-08-22 11:02:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SashHtmlWindow::SashHtmlWindow(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos, const wxSize& size, long style, const wxString& name) :
|
|
|
|
wxHtmlWindow(parent, id, pos, size, style, name) {
|
2004-06-08 15:27:42 -04:00
|
|
|
Connect(wxID_ANY, wxEVT_DYNAMIC_SASH_SPLIT, (wxObjectEventFunction)
|
2004-01-08 03:35:31 -05:00
|
|
|
(wxEventFunction)
|
|
|
|
(wxDynamicSashSplitEventFunction)&SashHtmlWindow::OnSplit);
|
2001-08-22 11:02:40 -04:00
|
|
|
|
|
|
|
m_dyn_sash = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxSize SashHtmlWindow::DoGetBestSize() const {
|
|
|
|
wxHtmlContainerCell *cell = GetInternalRepresentation();
|
|
|
|
wxSize size = GetSize();
|
|
|
|
|
|
|
|
if (cell) {
|
|
|
|
cell->Layout(size.GetWidth());
|
|
|
|
return wxSize(cell->GetWidth(), cell->GetHeight());
|
|
|
|
} else
|
|
|
|
return wxHtmlWindow::GetBestSize();
|
|
|
|
}
|
|
|
|
|
2004-01-08 03:35:31 -05:00
|
|
|
void SashHtmlWindow::OnSplit(wxDynamicSashSplitEvent& WXUNUSED(event)) {
|
2004-06-08 15:27:42 -04:00
|
|
|
wxHtmlWindow *html = new SashHtmlWindow(m_dyn_sash, wxID_ANY);
|
2001-08-22 11:02:40 -04:00
|
|
|
html->SetPage(HTML_content);
|
|
|
|
}
|