Allow better control over splitter position on resize

Add an event which can be handled by the application to determine the
splitter position when the splitter window itself is resized.

This can be used to e.g. preserve the splitter at the given proportion
of the window (and not just in the middle, as it would be already
possible by using gravity 0.5).

Closes #22035.
This commit is contained in:
Gerhard Gruber
2022-01-20 23:12:52 +01:00
committed by Vadim Zeitlin
parent 8f58562fea
commit 1533026945
4 changed files with 129 additions and 10 deletions

View File

@@ -68,6 +68,17 @@ enum
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 @c wxEVT_SPLITTER_SASH_POS_CHANGING event.
@event{EVT_SPLITTER_SASH_POS_RESIZE(id, func)}
The sash position is in the process of being updated.
May be used to modify the position of the tracking bar to properly
reflect the position that would be set if the update were to be completed.
This can happen e.g. when the window is resized and the sash is moved
according to the gravity setting.
This event is sent when the window is resized and allows the application to select
the desired new sash position. If it doesn't process the event, the position
is determined by the gravity setting.
Processes a @c wxEVT_SPLITTER_SASH_POS_RESIZE event and is only
available in wxWidgets 3.1.6 or newer.
@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.
@@ -514,7 +525,8 @@ public:
Returns the new sash position.
May only be called while processing
@c wxEVT_SPLITTER_SASH_POS_CHANGING and
@c wxEVT_SPLITTER_SASH_POS_CHANGING,
@c wxEVT_SPLITTER_SASH_POS_RESIZE and
@c wxEVT_SPLITTER_SASH_POS_CHANGED events.
*/
int GetSashPosition() const;
@@ -553,17 +565,62 @@ public:
the event handler code to prevent repositioning.
May only be called while processing
@c wxEVT_SPLITTER_SASH_POS_CHANGING and
@c wxEVT_SPLITTER_SASH_POS_CHANGING,
@c wxEVT_SPLITTER_SASH_POS_RESIZE and
@c wxEVT_SPLITTER_SASH_POS_CHANGED events.
@param pos
New sash position.
*/
void SetSashPosition(int pos);
/**
Sets the size values of the window size. This size
is adjusted to the sash orientation.
For a vertical sash it should be the width and for
a horizontal sash it's the height.
May only be called while processing
@c wxEVT_SPLITTER_SASH_POS_CHANGING,
@c wxEVT_SPLITTER_SASH_POS_RESIZE and
@c wxEVT_SPLITTER_SASH_POS_CHANGED events.
@since 3.1.6
*/
void SetSize(int oldSize, int newSize);
/**
Returns the old size before the update. The size value
is already adjusted to the orientation of the sash. So
for a vertical sash it's the width and for a horizontal
sash it's the height.
May only be called while processing
@c wxEVT_SPLITTER_SASH_POS_CHANGING,
@c wxEVT_SPLITTER_SASH_POS_RESIZE and
@c wxEVT_SPLITTER_SASH_POS_CHANGED events.
@since 3.1.6
*/
int GetOldSize() const
/**
Returns the new size which is set after the update.
The size value is already adjusted to the orientation
of the sash. So for a vertical sash it's the width
and for a horizontal sash it's the height.
May only be called while processing
@c wxEVT_SPLITTER_SASH_POS_CHANGING,
@c wxEVT_SPLITTER_SASH_POS_RESIZE and
@c wxEVT_SPLITTER_SASH_POS_CHANGED events.
@since 3.1.6
*/
int GetNewSize() const;
};
wxEventType wxEVT_SPLITTER_SASH_POS_CHANGED;
wxEventType wxEVT_SPLITTER_SASH_POS_CHANGING;
wxEventType wxEVT_SPLITTER_SASH_POS_RESIZE;
wxEventType wxEVT_SPLITTER_DOUBLECLICKED;
wxEventType wxEVT_SPLITTER_UNSPLIT;