TPairSplitter
│
English (en) │
français (fr) │
日本語 (ja) │
русский (ru) │
A TPairSplitter is a component that can be placed on a panel or form and provides two TPairSplitterSide sub-components.
In the example below, a TPaintBox item is dropped onto each TPairSplitterSide.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms,
Controls, PairSplitter, ExtCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
PaintBox2: TPaintBox;
PairSplitter1: TPairSplitter;
PairSplitterSide1: TPairSplitterSide;
PairSplitterSide2: TPairSplitterSide;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
end.
Differences in TSplitter and TPairSplitter behaviour
TPairSplitter behaves and looks like a TSplitter with two TPanel client areas attached to each side of it in a single control. The TPairSplitter control itself is usually set to alClient to fill its parent space entirely. Each side can be filled with other controls, which usually are also set to alClient. The property SplitterType controls wether to use horizontal or vertical splitting.
The divider position in between the containers is defined by the property Position in terms of pixels (absolute positioning). A TPairSplitter behaves exactly like a TSplitter during run-time in terms of distribution of additional space when resizing the outer container element: There is one side that acts like the fixed part as if aligned to alTop/alBottom or alLeft/alRight (depending on split orientation vertically or horizontally) and one that acts like if aligned to alClient. Additional space will be distributed asymmetrically, that is only the alClient part will receive additional space in both directions (becomes evident considering the absolute pixel value of the position property which is not recomputed automatically).
The splitter divider element cannot be manipulated by mouse during design-time, but can be adjusted by the position property in the Object Inspector. Changing the width/height of controls on either side does not work during design-time (neither using the mouse nor the Object Inspector). This is probably true for run-time also, since the position property is to be used in this case.
By using the position property, an evenly distribution of additional space can be achieved easily in code by making an assignment in the OnResize event handler like: Splitter.Position := Splitter.Width div 2
. This is not exactly the same as a proportional distribution though, which would need to store and restore a position value before/after the resizing. If something like that is needed, see the article on TSplitter and AnchorSides.
See also