1#ifndef PROPORTIONALSPLITTER
2#define PROPORTIONALSPLITTER
16#include <wx/splitter.h>
48 const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_3D)
49 : wxSplitterWindow(parent, id, pos, size, style),
splitPercent_(fabs(proportion))
51 wxASSERT_MSG( GetParent(), wxT(
"wxProportionalSplitterWindow parent window ptr cannot be null") );
57 Connect(GetId(), wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED,
69 if ( splitPercent_ < 0.0 || splitPercent_ > 1.0 )
87 return wxSplitterWindow::SplitHorizontally(window1, window2, splitSize);
100 virtual bool SplitVertically(wxWindow* window1, wxWindow* window2,
float proportion = 0)
103 return wxSplitterWindow::SplitVertically(window1, window2, splitSize);
117 SetSashPosition(splitSize);
133 int nSashSize = GetSashSize();
142 SetSashPosition(parSize - 20 *
m_charHeight + nSashSize,
false);
164 float percent =
event.GetSashPosition() / parSize;
166 if (percent > 0.0 && percent < 1.0)
210 return (GetSplitMode() == wxSPLIT_HORIZONTAL);
224 ? (
float)GetParent()->GetClientSize().GetHeight()
225 : (
float)GetParent()->GetClientSize().GetWidth());
239 SetSplitMode(
isHorizontal ? wxSPLIT_HORIZONTAL : wxSPLIT_VERTICAL);
250 proportion = fabs(proportion);
255 splitPercent_ = (proportion < 0.0 || proportion > 1.0) ? 0.5f : proportion;
This class represents a splitter window, which can controlled using a floating point proportion inste...
void SetCharHeigth(int _charheight)
Change the character height in pixels.
ProportionalSplitterWindow(wxWindow *parent, wxWindowID id=wxID_ANY, float proportion=0.5f, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSP_3D)
Construct a proportional splitter window using a set of parameters.
virtual bool SplitVertically(wxWindow *window1, wxWindow *window2, float proportion=0)
Split this window vertically using the selected porportion.
void OnSize(wxSizeEvent &event)
Handle the window size event. Will automatically adapt the sash position to achieve a multiple of a c...
void OnSashPosChanged(wxSplitterEvent &event)
Handle the size event, when the sash position has been changed. Will automatically adapt the sash pos...
float GetSplitPercentage()
Return the current splitting proportion.
virtual bool SplitHorizontally(wxWindow *window1, wxWindow *window2, float proportion=0)
Split this window horizontally using the selected porportion.
ProportionalSplitterWindow()
Default constructor.
void SetSashPositionFloat(float proportion)
Set the sash position using a floating point proportion.
float parentSize() const
Return the free space of the parent as a floating point number. Considers the orientation of the spli...
bool isHorizontal() const
Return true, if the splitter is horizontal.
int initSplitSize(float proportion, bool isHorizontal)
Calculates the initial sash position after splitting the window.
value_type rint(value_type v)