X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be5a51fb592f3fa2ba38ac6cd1e488d6d806058c..582ca3535a3680817ec4448141437eb2812df090:/contrib/samples/gizmos/dynsash/dynsash.cpp diff --git a/contrib/samples/gizmos/dynsash/dynsash.cpp b/contrib/samples/gizmos/dynsash/dynsash.cpp index ccc2b4b021..e24229b4c3 100644 --- a/contrib/samples/gizmos/dynsash/dynsash.cpp +++ b/contrib/samples/gizmos/dynsash/dynsash.cpp @@ -23,23 +23,27 @@ #include "wx/wx.h" #endif -#include -#include -#include -#include -#include -#include - -class Demo : public wxApp { +#include "wx/app.h" +#include "wx/frame.h" +#include "wx/gizmos/dynamicsash.h" +#include "wx/html/htmlwin.h" +#include "wx/image.h" +#include "wx/cmdline.h" + +class Demo : public wxApp +{ public: bool OnInit(); }; -class SashHtmlWindow : public wxHtmlWindow { +class SashHtmlWindow : public wxHtmlWindow +{ public: - SashHtmlWindow(wxWindow *parent, wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxHW_SCROLLBAR_NEVER, const wxString& name = wxT("sashHtmlWindow")); + SashHtmlWindow(wxWindow *parent, wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxHW_SCROLLBAR_NEVER, + const wxString& name = wxT("sashHtmlWindow")); wxSize DoGetBestSize() const; @@ -51,7 +55,7 @@ private: IMPLEMENT_APP(Demo) -wxChar *HTML_content = +const wxChar *HTML_content = wxT("

wxDynamicSashWindow demo

") wxT("

Here is an example of how you can use wxDynamicSashWindow to allow your users to ") wxT("dynamically split and unify the views of your windows. Try dragging out a few splits ") @@ -59,44 +63,52 @@ wxT("and then reunifying the window.") wxT("

Also, see the dynsash_switch sample for an example of an application which ") wxT("manages the scrollbars provided by wxDynamicSashWindow itself."); -bool Demo::OnInit() { +bool Demo::OnInit() +{ wxInitAllImageHandlers(); - wxFrame *frame = new wxFrame(NULL, -1, wxT("Dynamic Sash Demo")); + wxFrame *frame = new wxFrame(NULL, wxID_ANY, wxT("Dynamic Sash Demo")); frame->SetSize(480, 480); - wxDynamicSashWindow *sash = new wxDynamicSashWindow(frame, -1); - wxHtmlWindow *html = new SashHtmlWindow(sash, -1); + wxDynamicSashWindow *sash = new wxDynamicSashWindow(frame, wxID_ANY); + wxHtmlWindow *html = new SashHtmlWindow(sash, wxID_ANY); html->SetPage(HTML_content); frame->Show(); - return TRUE; + return true; } SashHtmlWindow::SashHtmlWindow(wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, const wxString& name) : - wxHtmlWindow(parent, id, pos, size, style, name) { - Connect(-1, wxEVT_DYNAMIC_SASH_SPLIT, (wxObjectEventFunction) - (wxEventFunction) - (wxDynamicSashSplitEventFunction)&SashHtmlWindow::OnSplit); + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) + : wxHtmlWindow(parent, id, pos, size, style, name) +{ + Connect(wxEVT_DYNAMIC_SASH_SPLIT, + wxDynamicSashSplitEventHandler(SashHtmlWindow::OnSplit)); m_dyn_sash = parent; } -wxSize SashHtmlWindow::DoGetBestSize() const { +wxSize SashHtmlWindow::DoGetBestSize() const +{ wxHtmlContainerCell *cell = GetInternalRepresentation(); wxSize size = GetSize(); - if (cell) { + if (cell) + { cell->Layout(size.GetWidth()); return wxSize(cell->GetWidth(), cell->GetHeight()); - } else - return wxHtmlWindow::GetBestSize(); + } + + return wxHtmlWindow::GetBestSize(); } -void SashHtmlWindow::OnSplit(wxDynamicSashSplitEvent& WXUNUSED(event)) { - wxHtmlWindow *html = new SashHtmlWindow(m_dyn_sash, -1); +void SashHtmlWindow::OnSplit(wxDynamicSashSplitEvent& WXUNUSED(event)) +{ + wxHtmlWindow *html = new SashHtmlWindow(m_dyn_sash, wxID_ANY); html->SetPage(HTML_content); }