contents up previous next

wxsplitterwindow

wxsplitterwindow overview

this class manages up to two subwindows. the current view can be split into two programmatically (perhaps from a menu command), and unsplit either programmatically or via the wxsplitterwindow user interface.

window styles

wxsp_3d draws a 3d effect border and sash.
wxsp_3dsash draws a 3d effect sash.
wxsp_3dborder synonym for wxsp_border.
wxsp_border draws a standard border.
wxsp_noborder no border (default).
wxsp_no_xp_theme under windows xp, switches off the attempt to draw the splitter using windows xp theming, so the borders and sash will take on the pre-xp look.
wxsp_permit_unsplit always allow to unsplit, even with the minimum pane size other than zero.
wxsp_live_update don't draw xor line but resize the child windows immediately.

see also window styles overview.

derived from

wxwindow
wxevthandler
wxobject

include files

<wx/splitter.h>

event handling

to process input from a splitter control, use the following event handler macros to direct input to member functions that take a wxsplitterevent argument.

evt_splitter_sash_pos_changing(id, func) the sash position is in the process of being changed. may be used to modify the position of the tracking bar to properly reflect the position that would be set if the drag were to be completed at this point. processes a wxevt_command_splitter_sash_pos_changing event.
evt_splitter_sash_pos_changed(id, func) the sash position was changed. may be used to modify the sash position before it is set, or to prevent the change from taking place. processes a wxevt_command_splitter_sash_pos_changed event.
evt_splitter_unsplit(id, func) the splitter has been just unsplit. processes a wxevt_command_splitter_unsplit event.
evt_splitter_dclick(id, func) the sash was double clicked. the default behaviour is to unsplit the window when this happens (unless the minimum pane size has been set to a value greater than zero). processes a wxevt_command_splitter_doubleclicked event.
see also

wxsplitterevent

members

wxsplitterwindow::wxsplitterwindow
wxsplitterwindow::~wxsplitterwindow
wxsplitterwindow::create
wxsplitterwindow::getminimumpanesize
wxsplitterwindow::getsashgravity
wxsplitterwindow::getsashposition
wxsplitterwindow::getsplitmode
wxsplitterwindow::getwindow1
wxsplitterwindow::getwindow2
wxsplitterwindow::initialize
wxsplitterwindow::issplit
wxsplitterwindow::ondoubleclicksash
wxsplitterwindow::onunsplit
wxsplitterwindow::onsashpositionchange
wxsplitterwindow::replacewindow
wxsplitterwindow::setsashgravity
wxsplitterwindow::setsashposition
wxsplitterwindow::setsashsize
wxsplitterwindow::setminimumpanesize
wxsplitterwindow::setsplitmode
wxsplitterwindow::splithorizontally
wxsplitterwindow::splitvertically
wxsplitterwindow::unsplit
wxsplitterwindow::updatesize


wxsplitterwindow::wxsplitterwindow

wxsplitterwindow()

default constructor.

wxsplitterwindow(wxwindow* parent, wxwindowid id, const wxpoint& point = wxdefaultposition, const wxsize& size = wxdefaultsize, long style=wxsp_3d, const wxstring& name = "splitterwindow")

constructor for creating the window.

parameters

parent

id

pos

size

style

name

remarks

after using this constructor, you must create either one or two subwindows with the splitter window as parent, and then call one of wxsplitterwindow::initialize, wxsplitterwindow::splitvertically and wxsplitterwindow::splithorizontally in order to set the pane(s).

you can create two windows, with one hidden when not being shown; or you can create and delete the second pane on demand.

see also

wxsplitterwindow::initialize, wxsplitterwindow::splitvertically, wxsplitterwindow::splithorizontally, wxsplitterwindow::create


wxsplitterwindow::~wxsplitterwindow

~wxsplitterwindow()

destroys the wxsplitterwindow and its children.


wxsplitterwindow::create

bool create(wxwindow* parent, wxwindowid id, const wxpoint& point = wxdefaultposition, const wxsize& size = wxdefaultsize, long style=wxsp_3d, const wxstring& name = "splitterwindow")

creation function, for two-step construction. see wxsplitterwindow::wxsplitterwindow for details.


wxsplitterwindow::getminimumpanesize

int getminimumpanesize() const

returns the current minimum pane size (defaults to zero).

see also

wxsplitterwindow::setminimumpanesize


wxsplitterwindow::getsashgravity

double getsashgravity()

returns the current sash gravity.

see also

wxsplitterwindow::setsashgravity


wxsplitterwindow::getsashposition

int getsashposition()

returns the current sash position.

see also

wxsplitterwindow::setsashposition


wxsplitterwindow::getsplitmode

int getsplitmode() const

gets the split mode.

see also

wxsplitterwindow::setsplitmode, wxsplitterwindow::splitvertically, wxsplitterwindow::splithorizontally.


wxsplitterwindow::getwindow1

wxwindow* getwindow1() const

returns the left/top or only pane.


wxsplitterwindow::getwindow2

wxwindow* getwindow2() const

returns the right/bottom pane.


wxsplitterwindow::initialize

void initialize(wxwindow* window)

initializes the splitter window to have one pane. the child window is shown if it is currently hidden.

parameters

window

remarks

this should be called if you wish to initially view only a single pane in the splitter window.

see also

wxsplitterwindow::splitvertically, wxsplitterwindow::splithorizontally


wxsplitterwindow::issplit

bool issplit() const

returns true if the window is split, false otherwise.


wxsplitterwindow::ondoubleclicksash

virtual void ondoubleclicksash(int x, int y)

application-overridable function called when the sash is double-clicked with the left mouse button.

parameters

x

y

remarks

the default implementation of this function calls unsplit if the minimum pane size is zero.

see also

wxsplitterwindow::unsplit


wxsplitterwindow::onunsplit

virtual void onunsplit(wxwindow* removed)

application-overridable function called when the window is unsplit, either programmatically or using the wxsplitterwindow user interface.

parameters

removed

remarks

the default implementation of this function simply hides removed. you may wish to delete the window.


wxsplitterwindow::onsashpositionchange

virtual bool onsashpositionchange(int newsashposition)

application-overridable function called when the sash position is changed by user. it may return false to prevent the change or true to allow it.

parameters

newsashposition

remarks

the default implementation of this function verifies that the sizes of both panes of the splitter are greater than minimum pane size.


wxsplitterwindow::replacewindow

bool replacewindow(wxwindow * winold, wxwindow * winnew)

this function replaces one of the windows managed by the wxsplitterwindow with another one. it is in general better to use it instead of calling unsplit() and then resplitting the window back because it will provoke much less flicker (if any). it is valid to call this function whether the splitter has two windows or only one.

both parameters should be non-null and winold must specify one of the windows managed by the splitter. if the parameters are incorrect or the window couldn't be replaced, false is returned. otherwise the function will return true, but please notice that it will not delete the replaced window and you may wish to do it yourself.

see also

wxsplitterwindow::getminimumpanesize

see also

wxsplitterwindow::unsplit
wxsplitterwindow::splitvertically
wxsplitterwindow::splithorizontally


wxsplitterwindow::setsashgravity

void setsashgravity(double gravity)

sets the sash gravity.

parameters

gravity

remarks gravity is real factor which controls position of sash while resizing wxsplitterwindow. gravity tells wxsplitterwindow how much will left/top window grow while resizing.

example values:

gravity should be a real value between 0.0 and 1.0.

default value of sash gravity is 0.0. that value is compatible with previous (before gravity was introduced) behaviour of wxsplitterwindow.

see also

wxsplitterwindow::getsashgravity


wxsplitterwindow::setsashposition

void setsashposition(int position, const bool redraw = true)

sets the sash position.

parameters

position

redraw

remarks

does not currently check for an out-of-range value.

see also

wxsplitterwindow::getsashposition


wxsplitterwindow::setsashsize

void setsashsize(int size)

sets the sash size. normally, the sash size is determined according to the metrics of each platform, but the application can override this, for example to show a thin sash that the user is not expected to drag. if size is more -1, the custom sash size will be used.


wxsplitterwindow::setminimumpanesize

void setminimumpanesize(int panesize)

sets the minimum pane size.

parameters

panesize

remarks

the default minimum pane size is zero, which means that either pane can be reduced to zero by dragging the sash, thus removing one of the panes. to prevent this behaviour (and veto out-of-range sash dragging), set a minimum size, for example 20 pixels. if the wxsp_permit_unsplit style is used when a splitter window is created, the window may be unsplit even if minimum size is non-zero.

see also

wxsplitterwindow::getminimumpanesize


wxsplitterwindow::setsplitmode

void setsplitmode(int mode)

sets the split mode.

parameters

mode

remarks

only sets the internal variable; does not update the display.

see also

wxsplitterwindow::getsplitmode, wxsplitterwindow::splitvertically, wxsplitterwindow::splithorizontally.


wxsplitterwindow::splithorizontally

bool splithorizontally(wxwindow* window1, wxwindow* window2, int sashposition = 0)

initializes the top and bottom panes of the splitter window. the child windows are shown if they are currently hidden.

parameters

window1

window2

sashposition

return value

true if successful, false otherwise (the window was already split).

remarks

this should be called if you wish to initially view two panes. it can also be called at any subsequent time, but the application should check that the window is not currently split using issplit.

see also

wxsplitterwindow::splitvertically, wxsplitterwindow::issplit, wxsplitterwindow::unsplit


wxsplitterwindow::splitvertically

bool splitvertically(wxwindow* window1, wxwindow* window2, int sashposition = 0)

initializes the left and right panes of the splitter window. the child windows are shown if they are currently hidden.

parameters

window1

window2

sashposition

return value

true if successful, false otherwise (the window was already split).

remarks

this should be called if you wish to initially view two panes. it can also be called at any subsequent time, but the application should check that the window is not currently split using issplit.

see also

wxsplitterwindow::splithorizontally, wxsplitterwindow::issplit, wxsplitterwindow::unsplit.


wxsplitterwindow::unsplit

bool unsplit(wxwindow* toremove = null)

unsplits the window.

parameters

toremove

return value

true if successful, false otherwise (the window was not split).

remarks

this call will not actually delete the pane being removed; it calls onunsplit which can be overridden for the desired behaviour. by default, the pane being removed is hidden.

see also

wxsplitterwindow::splithorizontally, wxsplitterwindow::splitvertically, wxsplitterwindow::issplit, wxsplitterwindow::onunsplit


wxsplitterwindow::updatesize

void updatesize()

causes any pending sizing of the sash and child panes to take place immediately.

such resizing normally takes place in idle time, in order to wait for layout to be completed. however, this can cause unacceptable flicker as the panes are resized after the window has been shown. to work around this, you can perform window layout (for example by sending a size event to the parent window), and then call this function, before showing the top-level window.