added wxDynamicSashWindow (patch 441518)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11437 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
6
contrib/configure
vendored
6
contrib/configure
vendored
@@ -822,6 +822,7 @@ trap 'rm -fr `echo "
|
|||||||
src/plot/Makefile
|
src/plot/Makefile
|
||||||
src/applet/Makefile
|
src/applet/Makefile
|
||||||
src/fl/Makefile
|
src/fl/Makefile
|
||||||
|
src/net/Makefile
|
||||||
samples/Makefile
|
samples/Makefile
|
||||||
samples/mmedia/Makefile
|
samples/mmedia/Makefile
|
||||||
samples/ogl/Makefile
|
samples/ogl/Makefile
|
||||||
@@ -835,6 +836,8 @@ trap 'rm -fr `echo "
|
|||||||
samples/gizmos/multicell/Makefile
|
samples/gizmos/multicell/Makefile
|
||||||
samples/gizmos/splittree/Makefile
|
samples/gizmos/splittree/Makefile
|
||||||
samples/gizmos/editlbox/Makefile
|
samples/gizmos/editlbox/Makefile
|
||||||
|
samples/gizmos/dynsash/Makefile
|
||||||
|
samples/gizmos/dynsash_switch/Makefile
|
||||||
samples/xrc/Makefile
|
samples/xrc/Makefile
|
||||||
samples/plot/Makefile
|
samples/plot/Makefile
|
||||||
samples/applet/Makefile
|
samples/applet/Makefile
|
||||||
@@ -936,6 +939,7 @@ CONFIG_FILES=\${CONFIG_FILES-"src/Makefile
|
|||||||
src/plot/Makefile
|
src/plot/Makefile
|
||||||
src/applet/Makefile
|
src/applet/Makefile
|
||||||
src/fl/Makefile
|
src/fl/Makefile
|
||||||
|
src/net/Makefile
|
||||||
samples/Makefile
|
samples/Makefile
|
||||||
samples/mmedia/Makefile
|
samples/mmedia/Makefile
|
||||||
samples/ogl/Makefile
|
samples/ogl/Makefile
|
||||||
@@ -949,6 +953,8 @@ CONFIG_FILES=\${CONFIG_FILES-"src/Makefile
|
|||||||
samples/gizmos/multicell/Makefile
|
samples/gizmos/multicell/Makefile
|
||||||
samples/gizmos/splittree/Makefile
|
samples/gizmos/splittree/Makefile
|
||||||
samples/gizmos/editlbox/Makefile
|
samples/gizmos/editlbox/Makefile
|
||||||
|
samples/gizmos/dynsash/Makefile
|
||||||
|
samples/gizmos/dynsash_switch/Makefile
|
||||||
samples/xrc/Makefile
|
samples/xrc/Makefile
|
||||||
samples/plot/Makefile
|
samples/plot/Makefile
|
||||||
samples/applet/Makefile
|
samples/applet/Makefile
|
||||||
|
@@ -61,6 +61,8 @@ AC_OUTPUT([
|
|||||||
samples/gizmos/multicell/Makefile
|
samples/gizmos/multicell/Makefile
|
||||||
samples/gizmos/splittree/Makefile
|
samples/gizmos/splittree/Makefile
|
||||||
samples/gizmos/editlbox/Makefile
|
samples/gizmos/editlbox/Makefile
|
||||||
|
samples/gizmos/dynsash/Makefile
|
||||||
|
samples/gizmos/dynsash_switch/Makefile
|
||||||
samples/xrc/Makefile
|
samples/xrc/Makefile
|
||||||
samples/plot/Makefile
|
samples/plot/Makefile
|
||||||
samples/applet/Makefile
|
samples/applet/Makefile
|
||||||
|
148
contrib/include/wx/gizmos/dynamicsash.h
Normal file
148
contrib/include/wx/gizmos/dynamicsash.h
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: dynamicsash.h
|
||||||
|
// Purpose: A window which can be dynamically split to an arbitrary depth
|
||||||
|
// and later reunified through the user interface
|
||||||
|
// Author: Matt Kimball
|
||||||
|
// Modified by:
|
||||||
|
// Created: 7/15/2001
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2001 Matt Kimball
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_DYNAMICSASH_H_
|
||||||
|
#define _WX_DYNAMICSASH_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
wxDynamicSashWindow
|
||||||
|
|
||||||
|
wxDynamicSashWindow widgets manages the way other widgets are viewed.
|
||||||
|
When a wxDynamicSashWindow is first shown, it will contain one child
|
||||||
|
view, a viewport for that child, and a pair of scrollbars to allow the
|
||||||
|
user to navigate the child view area. Next to each scrollbar is a small
|
||||||
|
tab. By clicking on either tab and dragging to the appropriate spot, a
|
||||||
|
user can split the view area into two smaller views separated by a
|
||||||
|
draggable sash. Later, when the user wishes to reunify the two subviews,
|
||||||
|
the user simply drags the sash to the side of the window.
|
||||||
|
wxDynamicSashWindow will automatically reparent the appropriate child
|
||||||
|
view back up the window hierarchy, and the wxDynamicSashWindow will have
|
||||||
|
only one child view once again.
|
||||||
|
|
||||||
|
As an application developer, you will simply create a wxDynamicSashWindow
|
||||||
|
using either the Create() function or the more complex constructor
|
||||||
|
provided below, and then create a view window whose parent is the
|
||||||
|
wxDynamicSashWindow. The child should respond to
|
||||||
|
wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
|
||||||
|
constructing a new view window whose parent is also the
|
||||||
|
wxDynamicSashWindow. That's it! Now your users can dynamically split
|
||||||
|
and reunify the view you provided.
|
||||||
|
|
||||||
|
If you wish to handle the scrollbar events for your view, rather than
|
||||||
|
allowing wxDynamicSashWindow to do it for you, things are a bit more
|
||||||
|
complex. (You might want to handle scrollbar events yourself, if,
|
||||||
|
for instance, you wish to scroll a subwindow of the view you add to
|
||||||
|
your wxDynamicSashWindow object, rather than scrolling the whole view.)
|
||||||
|
In this case, you will need to construct your wxDynamicSashWindow without
|
||||||
|
the wxMANAGE_SCROLLBARS style and you will need to use the
|
||||||
|
GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
|
||||||
|
controls and call SetEventHanler() on them to redirect the scrolling
|
||||||
|
events whenever your window is reparented by wxDyanmicSashWindow.
|
||||||
|
You will need to set the scrollbars' event handler at three times:
|
||||||
|
|
||||||
|
* When your view is created
|
||||||
|
* When your view receives a wxDynamicSashSplitEvent
|
||||||
|
* When your view receives a wxDynamicSashUnifyEvent
|
||||||
|
|
||||||
|
See the dynsash_switch sample application for an example which does this.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <wx/event.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
class wxScrollBar;
|
||||||
|
|
||||||
|
|
||||||
|
#define wxEVT_DYNAMIC_SASH_BASE (((int)('d' - 'a') << 11) | ((int)('s' - 'a') << 6) | ((int)('h' - 'a') << 1))
|
||||||
|
#define wxEVT_DYNAMIC_SASH_SPLIT (wxEVT_DYNAMIC_SASH_BASE + 1)
|
||||||
|
#define wxEVT_DYNAMIC_SASH_UNIFY (wxEVT_DYNAMIC_SASH_BASE + 2)
|
||||||
|
|
||||||
|
#define EVT_DYNAMIC_SASH_SPLIT(id, func) EVT_CUSTOM(wxEVT_DYNAMIC_SASH_SPLIT, (id), (func))
|
||||||
|
#define EVT_DYNAMIC_SASH_UNIFY(id, func) EVT_CUSTOM(wxEVT_DYNAMIC_SASH_UNIFY, (id), (func))
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
wxMANAGE_SCROLLBARS is a default style of wxDynamicSashWindow which
|
||||||
|
will cause it to respond to scrollbar events for your application by
|
||||||
|
automatically scrolling the child view.
|
||||||
|
*/
|
||||||
|
#define wxMANAGE_SCROLLBARS 0x00800000
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
|
||||||
|
whenever your view is being split by the user. It is your
|
||||||
|
responsibility to handle this event by creating a new view window as
|
||||||
|
a child of the wxDynamicSashWindow. wxDynamicSashWindow will
|
||||||
|
automatically reparent it to the proper place in its window hierarchy.
|
||||||
|
*/
|
||||||
|
class wxDynamicSashSplitEvent : public wxCommandEvent {
|
||||||
|
public:
|
||||||
|
wxDynamicSashSplitEvent();
|
||||||
|
wxDynamicSashSplitEvent(wxObject *target);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxDynamicSashSplitEvent)
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
|
||||||
|
whenever the sash which splits your view and its sibling is being
|
||||||
|
reunified such that your view is expanding to replace its sibling.
|
||||||
|
You needn't do anything with this event if you are allowing
|
||||||
|
wxDynamicSashWindow to manage your view's scrollbars, but it is useful
|
||||||
|
if you are managing the scrollbars yourself so that you can keep
|
||||||
|
the scrollbars' event handlers connected to your view's event handler
|
||||||
|
class.
|
||||||
|
*/
|
||||||
|
class wxDynamicSashUnifyEvent : public wxCommandEvent {
|
||||||
|
public:
|
||||||
|
wxDynamicSashUnifyEvent();
|
||||||
|
wxDynamicSashUnifyEvent(wxObject *target);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxDynamicSashUnifyEvent);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
wxDynamicSashWindow. See above.
|
||||||
|
*/
|
||||||
|
class wxDynamicSashWindow : public wxWindow {
|
||||||
|
public:
|
||||||
|
wxDynamicSashWindow();
|
||||||
|
wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
|
||||||
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||||
|
long style = wxCLIP_CHILDREN | wxMANAGE_SCROLLBARS,
|
||||||
|
const wxString& name = "dynamicSashWindow");
|
||||||
|
virtual ~wxDynamicSashWindow();
|
||||||
|
|
||||||
|
virtual bool Create(wxWindow *parent, wxWindowID id,
|
||||||
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||||
|
long style = wxCLIP_CHILDREN | wxMANAGE_SCROLLBARS,
|
||||||
|
const wxString& name = "dynamicSashWindow");
|
||||||
|
virtual wxScrollBar *GetHScrollBar(const wxWindow *child) const;
|
||||||
|
virtual wxScrollBar *GetVScrollBar(const wxWindow *child) const;
|
||||||
|
|
||||||
|
/* This is overloaded from wxWindowBase. It's not here for you to
|
||||||
|
call directly. */
|
||||||
|
virtual void AddChild(wxWindowBase *child);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class wxDynamicSashWindowImpl *m_impl;
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxDynamicSashWindow)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@@ -1,6 +1,6 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
CONTRIB_SAMPLES=multicell splittree editlbox
|
CONTRIB_SAMPLES=multicell splittree editlbox dynsash dynsash_switch
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@for d in $(CONTRIB_SAMPLES); do (cd $$d && $(MAKE)); done
|
@for d in $(CONTRIB_SAMPLES); do (cd $$d && $(MAKE)); done
|
||||||
|
23
contrib/samples/gizmos/dynsash/Makefile.in
Normal file
23
contrib/samples/gizmos/dynsash/Makefile.in
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#
|
||||||
|
# File: Makefile.in
|
||||||
|
# Author: Matt Kimball
|
||||||
|
# Created: 2001
|
||||||
|
# Updated:
|
||||||
|
# Copyright: (c) 2001 Matt Kimball
|
||||||
|
#
|
||||||
|
# "%W% %G%"
|
||||||
|
#
|
||||||
|
# Makefile for the dynsash example (UNIX).
|
||||||
|
|
||||||
|
top_srcdir = @top_srcdir@/..
|
||||||
|
top_builddir = ../../../..
|
||||||
|
program_dir = contrib/samples/gizmos/dynsash
|
||||||
|
|
||||||
|
PROGRAM=dynsash
|
||||||
|
OBJECTS=dynsash.o
|
||||||
|
|
||||||
|
APPEXTRALIBS=$(top_builddir)/lib/libgizmos.@WX_TARGET_LIBRARY_TYPE@
|
||||||
|
APPEXTRADEFS=-I$(top_srcdir)/contrib/include
|
||||||
|
|
||||||
|
include $(top_builddir)/src/makeprog.env
|
||||||
|
|
86
contrib/samples/gizmos/dynsash/dynsash.cpp
Normal file
86
contrib/samples/gizmos/dynsash/dynsash.cpp
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <wx/app.h>
|
||||||
|
#include <wx/gizmos/dynamicsash.h>
|
||||||
|
#include <wx/html/htmlwin.h>
|
||||||
|
#include <wx/image.h>
|
||||||
|
|
||||||
|
class Demo : public wxApp {
|
||||||
|
public:
|
||||||
|
bool OnInit();
|
||||||
|
};
|
||||||
|
|
||||||
|
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 = "sashHtmlWindow");
|
||||||
|
|
||||||
|
wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void OnSplit(wxDynamicSashSplitEvent& event);
|
||||||
|
|
||||||
|
wxWindow *m_dyn_sash;
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_APP(Demo)
|
||||||
|
|
||||||
|
char *HTML_content =
|
||||||
|
"<P><H1>wxDynamicSashWindow demo</H1>"
|
||||||
|
"<P>Here is an example of how you can use <TT>wxDynamicSashWindow</TT> to allow your users to "
|
||||||
|
"dynamically split and unify the views of your windows. Try dragging out a few splits "
|
||||||
|
"and then reunifying the window."
|
||||||
|
"<P>Also, see the <TT>dynsash_switch</TT> sample for an example of an application which "
|
||||||
|
"manages the scrollbars provided by <TT>wxDynamicSashWindow</TT> itself."
|
||||||
|
;
|
||||||
|
|
||||||
|
bool Demo::OnInit() {
|
||||||
|
wxInitAllImageHandlers();
|
||||||
|
|
||||||
|
wxFrame *frame = new wxFrame(NULL, -1, "Dynamic Sash Demo");
|
||||||
|
frame->SetSize(480, 480);
|
||||||
|
|
||||||
|
wxDynamicSashWindow *sash = new wxDynamicSashWindow(frame, -1);
|
||||||
|
wxHtmlWindow *html = new SashHtmlWindow(sash, -1);
|
||||||
|
html->SetPage(HTML_content);
|
||||||
|
|
||||||
|
frame->Show();
|
||||||
|
|
||||||
|
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)&SashHtmlWindow::OnSplit);
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SashHtmlWindow::OnSplit(wxDynamicSashSplitEvent& event) {
|
||||||
|
wxHtmlWindow *html = new SashHtmlWindow(m_dyn_sash, -1);
|
||||||
|
html->SetPage(HTML_content);
|
||||||
|
}
|
23
contrib/samples/gizmos/dynsash_switch/Makefile.in
Normal file
23
contrib/samples/gizmos/dynsash_switch/Makefile.in
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#
|
||||||
|
# File: Makefile.in
|
||||||
|
# Author: Matt Kimball
|
||||||
|
# Created: 2001
|
||||||
|
# Updated:
|
||||||
|
# Copyright: (c) 2001 Matt Kimball
|
||||||
|
#
|
||||||
|
# "%W% %G%"
|
||||||
|
#
|
||||||
|
# Makefile for the dynsash_switch example (UNIX).
|
||||||
|
|
||||||
|
top_srcdir = @top_srcdir@/..
|
||||||
|
top_builddir = ../../../..
|
||||||
|
program_dir = contrib/samples/gizmos/dynsash_switch
|
||||||
|
|
||||||
|
PROGRAM=dynsash_switch
|
||||||
|
OBJECTS=dynsash_switch.o
|
||||||
|
|
||||||
|
APPEXTRALIBS=$(top_builddir)/lib/libgizmos.@WX_TARGET_LIBRARY_TYPE@
|
||||||
|
APPEXTRADEFS=-I$(top_srcdir)/contrib/include
|
||||||
|
|
||||||
|
include $(top_builddir)/src/makeprog.env
|
||||||
|
|
219
contrib/samples/gizmos/dynsash_switch/dynsash_switch.cpp
Normal file
219
contrib/samples/gizmos/dynsash_switch/dynsash_switch.cpp
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: dynsash_switch.cpp
|
||||||
|
// Purpose: Test custom scrollbar handling of wxDynamicSashWindow by
|
||||||
|
// creating a dynamic sash window where the client scrolls a
|
||||||
|
// a subwindow of the client window by responding to scroll
|
||||||
|
// events itself
|
||||||
|
// Author: Matt Kimball
|
||||||
|
// Modified by:
|
||||||
|
// Created: 7/15/2001
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2001 Matt Kimball
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <wx/app.h>
|
||||||
|
#include <wx/choice.h>
|
||||||
|
#include <wx/dcclient.h>
|
||||||
|
#include <wx/gizmos/dynamicsash.h>
|
||||||
|
#include <wx/layout.h>
|
||||||
|
#include <wx/scrolbar.h>
|
||||||
|
|
||||||
|
class SwitchDemo : public wxApp {
|
||||||
|
public:
|
||||||
|
bool OnInit();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class SwitchView : public wxWindow {
|
||||||
|
public:
|
||||||
|
SwitchView(wxDynamicSashWindow *parent);
|
||||||
|
|
||||||
|
wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void OnSize(wxSizeEvent& event);
|
||||||
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
void OnChoice(wxCommandEvent& event);
|
||||||
|
void OnScroll(wxScrollEvent& event);
|
||||||
|
void OnFocus(wxFocusEvent& event);
|
||||||
|
void OnErase(wxEraseEvent& event);
|
||||||
|
void OnSplit(wxDynamicSashSplitEvent& event);
|
||||||
|
void OnUnify(wxDynamicSashUnifyEvent& event);
|
||||||
|
|
||||||
|
wxDynamicSashWindow *m_dyn_sash;
|
||||||
|
wxWindow *m_bar;
|
||||||
|
wxChoice *m_choice;
|
||||||
|
wxWindow *m_view;
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_APP(SwitchDemo)
|
||||||
|
|
||||||
|
|
||||||
|
SwitchView::SwitchView(wxDynamicSashWindow *win) {
|
||||||
|
Create(win, -1);
|
||||||
|
|
||||||
|
m_dyn_sash = win;
|
||||||
|
|
||||||
|
m_bar = new wxWindow(this, -1, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER, "bar");
|
||||||
|
m_choice = new wxChoice(m_bar, -1);
|
||||||
|
m_choice->SetEventHandler(this);
|
||||||
|
m_view = new wxWindow(this, -1, wxDefaultPosition, wxDefaultSize, 0, "view");
|
||||||
|
m_view->SetBackgroundColour(*wxWHITE);
|
||||||
|
m_view->SetEventHandler(this);
|
||||||
|
|
||||||
|
m_choice->Append("Triangle");
|
||||||
|
m_choice->Append("Square");
|
||||||
|
m_choice->SetSelection(0);
|
||||||
|
|
||||||
|
wxLayoutConstraints *layout;
|
||||||
|
|
||||||
|
layout = new wxLayoutConstraints();
|
||||||
|
layout->left.Absolute(0);
|
||||||
|
layout->top.Absolute(0);
|
||||||
|
layout->height.Absolute(36);
|
||||||
|
layout->width.SameAs(this, wxWidth);
|
||||||
|
m_bar->SetConstraints(layout);
|
||||||
|
|
||||||
|
layout = new wxLayoutConstraints();
|
||||||
|
layout->left.Absolute(3);
|
||||||
|
layout->width.AsIs();
|
||||||
|
layout->height.AsIs();
|
||||||
|
layout->top.Absolute(3);
|
||||||
|
m_choice->SetConstraints(layout);
|
||||||
|
|
||||||
|
layout = new wxLayoutConstraints();
|
||||||
|
layout->left.Absolute(0);
|
||||||
|
layout->width.SameAs(this, wxWidth);
|
||||||
|
layout->top.Below(m_bar);
|
||||||
|
layout->bottom.SameAs(this, wxBottom);
|
||||||
|
m_view->SetConstraints(layout);
|
||||||
|
|
||||||
|
wxScrollBar *hscroll = m_dyn_sash->GetHScrollBar(this);
|
||||||
|
wxScrollBar *vscroll = m_dyn_sash->GetVScrollBar(this);
|
||||||
|
|
||||||
|
hscroll->SetEventHandler(this);
|
||||||
|
vscroll->SetEventHandler(this);
|
||||||
|
|
||||||
|
Connect(GetId(), wxEVT_SIZE, (wxObjectEventFunction)&SwitchView::OnSize);
|
||||||
|
Connect(m_choice->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&SwitchView::OnChoice);
|
||||||
|
Connect(m_view->GetId(), wxEVT_PAINT, (wxObjectEventFunction)&SwitchView::OnPaint);
|
||||||
|
|
||||||
|
Connect(-1, wxEVT_SET_FOCUS, (wxObjectEventFunction)&SwitchView::OnFocus);
|
||||||
|
Connect(-1, wxEVT_SCROLL_TOP, (wxObjectEventFunction)&SwitchView::OnScroll);
|
||||||
|
Connect(-1, wxEVT_SCROLL_BOTTOM, (wxObjectEventFunction)&SwitchView::OnScroll);
|
||||||
|
Connect(-1, wxEVT_SCROLL_LINEUP, (wxObjectEventFunction)&SwitchView::OnScroll);
|
||||||
|
Connect(-1, wxEVT_SCROLL_LINEDOWN, (wxObjectEventFunction)&SwitchView::OnScroll);
|
||||||
|
Connect(-1, wxEVT_SCROLL_PAGEUP, (wxObjectEventFunction)&SwitchView::OnScroll);
|
||||||
|
Connect(-1, wxEVT_SCROLL_PAGEDOWN, (wxObjectEventFunction)&SwitchView::OnScroll);
|
||||||
|
Connect(-1, wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&SwitchView::OnScroll);
|
||||||
|
Connect(-1, wxEVT_SCROLL_THUMBRELEASE, (wxObjectEventFunction)&SwitchView::OnScroll);
|
||||||
|
Connect(-1, wxEVT_ERASE_BACKGROUND, (wxObjectEventFunction)&SwitchView::OnErase);
|
||||||
|
|
||||||
|
Connect(-1, wxEVT_DYNAMIC_SASH_SPLIT, (wxObjectEventFunction)&SwitchView::OnSplit);
|
||||||
|
Connect(-1, wxEVT_DYNAMIC_SASH_UNIFY, (wxObjectEventFunction)&SwitchView::OnUnify);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize SwitchView::DoGetBestSize() const {
|
||||||
|
return wxSize(64, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchView::OnSize(wxSizeEvent& event) {
|
||||||
|
Layout();
|
||||||
|
|
||||||
|
wxScrollBar *hscroll = m_dyn_sash->GetHScrollBar(this);
|
||||||
|
wxScrollBar *vscroll = m_dyn_sash->GetVScrollBar(this);
|
||||||
|
|
||||||
|
if (hscroll && vscroll) {
|
||||||
|
int hpos = hscroll->GetThumbPosition();
|
||||||
|
int vpos = vscroll->GetThumbPosition();
|
||||||
|
|
||||||
|
wxSize size = m_view->GetSize();
|
||||||
|
if (hpos + size.GetWidth() > 300)
|
||||||
|
hpos = 300 - size.GetWidth();
|
||||||
|
if (vpos + size.GetHeight() > 300)
|
||||||
|
vpos = 300 - size.GetHeight();
|
||||||
|
|
||||||
|
hscroll->SetScrollbar(hpos, size.GetWidth(), 300, size.GetWidth());
|
||||||
|
vscroll->SetScrollbar(vpos, size.GetHeight(), 300, size.GetHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchView::OnPaint(wxPaintEvent& event) {
|
||||||
|
wxPaintDC dc(m_view);
|
||||||
|
|
||||||
|
wxScrollBar *hscroll = m_dyn_sash->GetHScrollBar(this);
|
||||||
|
wxScrollBar *vscroll = m_dyn_sash->GetVScrollBar(this);
|
||||||
|
|
||||||
|
dc.Clear();
|
||||||
|
dc.SetDeviceOrigin(-hscroll->GetThumbPosition(), -vscroll->GetThumbPosition());
|
||||||
|
|
||||||
|
if (m_choice->GetSelection()) {
|
||||||
|
dc.DrawLine(20, 20, 280, 20);
|
||||||
|
dc.DrawLine(280, 20, 280, 280);
|
||||||
|
dc.DrawLine(280, 280, 20, 280);
|
||||||
|
dc.DrawLine(20, 280, 20, 20);
|
||||||
|
} else {
|
||||||
|
dc.DrawLine(150, 20, 280, 280);
|
||||||
|
dc.DrawLine(280, 280, 20, 280);
|
||||||
|
dc.DrawLine(20, 280, 150, 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchView::OnErase(wxEraseEvent& event) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchView::OnSplit(wxDynamicSashSplitEvent& event) {
|
||||||
|
SwitchView *view = new SwitchView(m_dyn_sash);
|
||||||
|
view->m_choice->SetSelection(m_choice->GetSelection());
|
||||||
|
|
||||||
|
wxScrollBar *hscroll = m_dyn_sash->GetHScrollBar(this);
|
||||||
|
wxScrollBar *vscroll = m_dyn_sash->GetVScrollBar(this);
|
||||||
|
|
||||||
|
hscroll->SetEventHandler(this);
|
||||||
|
vscroll->SetEventHandler(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchView::OnUnify(wxDynamicSashUnifyEvent& event) {
|
||||||
|
wxScrollBar *hscroll = m_dyn_sash->GetHScrollBar(this);
|
||||||
|
wxScrollBar *vscroll = m_dyn_sash->GetVScrollBar(this);
|
||||||
|
|
||||||
|
hscroll->SetEventHandler(this);
|
||||||
|
vscroll->SetEventHandler(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchView::OnChoice(wxCommandEvent& event) {
|
||||||
|
m_view->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchView::OnScroll(wxScrollEvent& event) {
|
||||||
|
m_view->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchView::OnFocus(wxFocusEvent& event) {
|
||||||
|
wxScrollBar *hscroll = m_dyn_sash->GetHScrollBar(this);
|
||||||
|
wxScrollBar *vscroll = m_dyn_sash->GetVScrollBar(this);
|
||||||
|
|
||||||
|
if (event.m_eventObject == hscroll || event.m_eventObject == vscroll) {
|
||||||
|
m_view->SetFocus();
|
||||||
|
} else {
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool SwitchDemo::OnInit() {
|
||||||
|
wxFrame *frame;
|
||||||
|
wxDynamicSashWindow *dyn;
|
||||||
|
|
||||||
|
frame = new wxFrame(NULL, -1, "Dynamic Sash Window Switch Demo");
|
||||||
|
dyn = new wxDynamicSashWindow(frame, -1, wxDefaultPosition, wxDefaultSize, wxCLIP_CHILDREN);
|
||||||
|
new SwitchView(dyn);
|
||||||
|
|
||||||
|
frame->SetSize(480, 480);
|
||||||
|
frame->Show();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
@@ -97,6 +97,10 @@ SOURCE=..\..\include\wx\gizmos\editlbox.h
|
|||||||
|
|
||||||
SOURCE=..\..\include\wx\gizmos\splittree.h
|
SOURCE=..\..\include\wx\gizmos\splittree.h
|
||||||
# End Source File
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\include\wx\gizmos\dynamicsash.h
|
||||||
|
# End Source File
|
||||||
# End Group
|
# End Group
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
@@ -110,5 +114,9 @@ SOURCE=.\editlbox.cpp
|
|||||||
|
|
||||||
SOURCE=.\splittree.cpp
|
SOURCE=.\splittree.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\dynamicsash.cpp
|
||||||
|
# End Source File
|
||||||
# End Target
|
# End Target
|
||||||
# End Project
|
# End Project
|
||||||
|
@@ -13,9 +13,9 @@ LIBVERSION_AGE=0
|
|||||||
HEADER_PATH=$(top_srcdir)/contrib/include/wx
|
HEADER_PATH=$(top_srcdir)/contrib/include/wx
|
||||||
HEADER_SUBDIR=gizmos
|
HEADER_SUBDIR=gizmos
|
||||||
|
|
||||||
HEADERS=multicell.h splittree.h editlbox.h
|
HEADERS=multicell.h splittree.h editlbox.h dynamicsash.h
|
||||||
|
|
||||||
OBJECTS=multicell.o splittree.o editlbox.o
|
OBJECTS=multicell.o splittree.o editlbox.o dynamicsash.o
|
||||||
|
|
||||||
APPEXTRADEFS=-I$(top_srcdir)/contrib/include
|
APPEXTRADEFS=-I$(top_srcdir)/contrib/include
|
||||||
|
|
||||||
|
1242
contrib/src/gizmos/dynamicsash.cpp
Normal file
1242
contrib/src/gizmos/dynamicsash.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@ WXDIR = $(WXWIN)
|
|||||||
|
|
||||||
LIBTARGET=$(WXDIR)\lib\gizmos.lib
|
LIBTARGET=$(WXDIR)\lib\gizmos.lib
|
||||||
|
|
||||||
OBJECTS = multicell.obj splittree.obj editlbox.obj
|
OBJECTS = multicell.obj splittree.obj editlbox.obj dynamicsash.obj
|
||||||
|
|
||||||
!include $(WXDIR)\src\makelib.b32
|
!include $(WXDIR)\src\makelib.b32
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ WXDIR = $(WXWIN)
|
|||||||
|
|
||||||
LIBTARGET=$(WXDIR)\lib\gizmos.lib
|
LIBTARGET=$(WXDIR)\lib\gizmos.lib
|
||||||
|
|
||||||
OBJECTS = multicell.obj splittree.obj editlbox.obj
|
OBJECTS = multicell.obj splittree.obj editlbox.obj dynamicsash.obj
|
||||||
|
|
||||||
!include $(WXDIR)\src\makelib.bcc
|
!include $(WXDIR)\src\makelib.bcc
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
WXDIR = ../../..
|
WXDIR = ../../..
|
||||||
|
|
||||||
LIBTARGET=$(WXDIR)/lib/libgizmos.a
|
LIBTARGET=$(WXDIR)/lib/libgizmos.a
|
||||||
OBJECTS = multicell.o splittree.o editlbox.o
|
OBJECTS = multicell.o splittree.o editlbox.o dynamicsash.o
|
||||||
|
|
||||||
include $(WXDIR)/src/makelib.g95
|
include $(WXDIR)/src/makelib.g95
|
||||||
|
|
||||||
|
@@ -16,7 +16,8 @@ LIB_CPP_SRC=\
|
|||||||
\
|
\
|
||||||
multicell.o\
|
multicell.o\
|
||||||
editlbox.o\
|
editlbox.o\
|
||||||
splittree.o
|
splittree.o\
|
||||||
|
dynamicsash.o
|
||||||
|
|
||||||
all: $(GIZMOSLIB)
|
all: $(GIZMOSLIB)
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ LOCALDOCDIR=$(WXDIR)\contrib\docs\latex\gizmos
|
|||||||
|
|
||||||
!include $(WXDIR)\src\makevc.env
|
!include $(WXDIR)\src\makevc.env
|
||||||
|
|
||||||
OBJECTS = $(D)\multicell.obj $(D)\splittree.obj $(D)\editlbox.obj
|
OBJECTS = $(D)\multicell.obj $(D)\splittree.obj $(D)\editlbox.obj $(D)\dynamicsash.obj
|
||||||
|
|
||||||
LIBTARGET=$(WXDIR)\lib\gizmos$(LIBEXT).lib
|
LIBTARGET=$(WXDIR)\lib\gizmos$(LIBEXT).lib
|
||||||
|
|
||||||
@@ -65,6 +65,11 @@ $(D)\editlbox.obj: editlbox.$(SRCSUFF)
|
|||||||
$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF)
|
$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF)
|
||||||
<<
|
<<
|
||||||
|
|
||||||
|
$(D)\dynamicsash.obj: dynamicsash.$(SRCSUFF)
|
||||||
|
cl @<<
|
||||||
|
$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF)
|
||||||
|
<<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-erase $(D)\*.obj
|
-erase $(D)\*.obj
|
||||||
-erase *.sbr
|
-erase *.sbr
|
||||||
|
@@ -10,7 +10,7 @@ THISDIR = $(WXDIR)\contrib\src\gizmos
|
|||||||
NAME = gizmos
|
NAME = gizmos
|
||||||
LNK = $(name).lnk
|
LNK = $(name).lnk
|
||||||
|
|
||||||
OBJECTS = multicell.obj splittree.obj editlbox.obj
|
OBJECTS = multicell.obj splittree.obj editlbox.obj dynamicsash.obj
|
||||||
|
|
||||||
all: $(GIZMOSLIB)
|
all: $(GIZMOSLIB)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user