Class TSplitterWnd (unit SplitterWnd) |
TCustomPanel
Constructors |
Functions |
procedure TSplitterWnd.
Properties |
Events |
Variables |
Constructors |
************************************************************************) (***************************** TSplitterWnd ******************************) (*************************************************************************) { Overridden methods } // Constructor TSplitterWnd.Create( AOwner : TComponent ); // Initialize things like the size, etc. Allocate memory // for the pane list.
Functions |
Destructor TSplitterWnd.Destroy; Deallocate the panes list.
procedure TSplitterWnd.InvertBarRect( pos : TPoint ); This draws an inverted rectangle on the splitter window and its children. I used a call to GetDCEx to make the rectangle draw itself over the children and the parent. Otherwise, the rectangle would have been hidden by any children placed on the splitter window, including the panes themselves.
procedure TSplitterWnd.AdjustLastPaneSize; This procedure is usually called after some pane sizes have been changed. It makes the last pane exactly fill the remaining space in the splitter window so that no weird effects happen near the right/bottom edges of the window.
procedure TSplitterWnd.CheckMouseBounds( var pos : TPoint ); This simply checks to see if the mouse can drag the bar any further than it already has. If it can, it will. Otherwise, it will not.
procedure TSplitterWnd.CMDesignHitTest( var Message: TCMDesignHitTest ); This procedure returns 1 if mouse messages are to be processed in the design environment, or 0 if not. Since the only time a mouse message would be received would be when trying to move the drag bar, we could always return 1. But this would result in never being able to move the SplitterWnd at design time. Therefore, we permit drag bar movement when the shift key is held.
procedure TSplitterWnd.CreateWnd; By the time this procedure is called, all of the panes have been loaded and the caption has been auto-set. This overrides the caption and updates the panes.
function TSplitterWnd.GetBarRect( bIndex : Integer ) : TRect; bIndex : Bar Index. Which bar to get the rectangle for. This returns the bar's rectangle so that panes can be resized after the dragging operation has stopped.
procedure TSplitterWnd.GetChildren( Proc : TGetChildProc ); I don't know why this is in here, but it has to be to avoid access violations at design time when loading panes. Oh, well. It works.
function TSplitterWnd.GetDefaultPaneSize:Integer; Just a wrapper for the constants found at the beginning of the unit. It was cumbersome to put a lot of case statements into the code, so they are found in all of these little functions.
function TSplitterWnd.GetDifferenceBetweenPaneAndPoint( pIndex : Integer; pt : TPoint ):Integer; // pIndex : index in pane list of pane to check pt : current point. The purpose of this function is to find out how big a pane should be given the current cursor position. It returns a pixel value that is dependent on orientation.
function TSplitterWnd.GetDistance( bIndex : Integer ): Integer; bIndex : index of pane to find the "distance" of. The function returns the total distance from the left or top of the splitter window to the right or bottom of the pane specified in pixels.
function TSplitterWnd.GetMinimumPaneSize:Integer; This simply returns twice the size of a scroll bar if the MinPaneSize property is 0 and FMinPaneSize if not. The type of scroll bar is determined by the orientation.
function TSplitterWnd.GetNumPanes : Byte; Gets the number of panes. A read property function.
function TSplitterWnd.GetPane( paneIndex : Byte ) : TPane; Read Property function for the Panes array property.
function TSplitterWnd.GetRectAtDistance( d : Integer ) : TRect; d : pixel distance from left or top of splitter window. This function returns a rectangle that will show when the mouse is dragging a bar around.
function TSplitterWnd.GetRectAtPoint( p : TPoint ) : TRect; p : point at which to find the rectangle. This is very similar to GetRectAtDistance, except it works on a point.
procedure TSplitterWnd.InsertPane( p : TPane ); This inserts a new pane into the control. If the new pane is being inserted by the compiler (ie, being loaded), then the new pane sizes should NOT be recalculated. If it is being inserted by the developer through the design interface or during runtime, the pane sizes will be recalculated to give it space.
function TSplitterWnd.LeftBar( value : Integer ):Integer; Gets the left half width (or top half) of the splitter bars. The bar positions are defined by their centers, so this function truncates the floating point value, and the right function rounds it to account for odd thicknesses.
Added code - may not work (* if ((csDesigning in ComponentState) and (not Initialized)) then begin designer := (Owner as TForm).Designer as TFormDesigner; pane := TPane.Create(designer.Form); pane.Name := designer.UniqueName(TPane.ClassName); pane.Parent := Self; pane.SplitterWnd := Self; pane.FPaneSize := GetDefaultPaneSize; pane := TPane.Create(designer.Form); pane.Name := designer.UniqueName(TPane.ClassName); pane.Parent := Self; pane.SplitterWnd := self; pane.FPaneSize := GetDefaultPaneSize; RecalculatePaneSizes(true); Initialized := true; end;*) end of added code UpdatePaneRects;
used to determine whether to generate two new panes or not
procedure TSplitterWnd.MouseDown( Button: TMouseButton; Shift: TShiftState; Overridden mouseDown procedure. If the SplitterWnd receives any mouse events at all, that means that the cursor is on a drag bar, since any of the non-draggable areas of the window are covered by panes. This sets the BarDragging variable, which specifies which bar is in the dragging mode. It also calls the InvertBarRect procedure, which draws an inverted bar on the splitter window and its children.
procedure TSplitterWnd.MouseMove( Shift: TShiftState; X, Y: Integer); Overridden MouseMove procedure. If any bars are dragging, then the inverted rectangle needs to be updated. Boundary checking is also done here so that the user can see just where the dragging limit is.
procedure TSplitterWnd.MouseUp( Button: TMouseButton; Shift: TShiftState; Overridden MouseUp procedure. If any splitter bars were in drag mode, the pane sizes need to be updated according to where the user has dropped the bar.
procedure TSplitterWnd.MovePane( oldIndex, newIndex : Integer ); Swaps pane positions in the list and changes their indices. This allows for panes to be moved around if desired.
procedure TSplitterWnd.RecalculatePaneSizes( IncludeLast : Boolean ); IncludeLast : this is set to True if ALL of the panes are to be recalculated, and it is set to False if all but the last pane are to be resized. The IncludeLast parameter is always FALSE when a new pane has just been added and the others are shifting around to get out of its way. This allows for immediate deletion of the new pane without disturbing the original positions of the preceding panes.
procedure TSplitterWnd.RemovePane( p : TPane ); This takes a pane out of the control, but does NOT free up the resources associated with it. It resets the pane indices so there are no "holes" in the PaneIndex properties, and it recalculates the pane sizes so they fill up the splitter window.
procedure TSplitterWnd.ResetPaneIndices; Very simple. Goes through the list and assigns the pane indices to their indices in the list. The panes are always in order.
procedure TSplitterWnd.ResetPaneSizes; This sets all of the pane sizes the same.
function TSplitterWnd.RightBar( value : Integer ):Integer; See TSplitterWnd.LeftBar.
procedure TSplitterWnd.SetChildOrder(Child: TComponent; Order: Integer); Just sets the child order. I am not sure it even needs to be here.
procedure TSplitterWnd.SetCursorHorz( ch : TCursor ); Sets the CursorHorz property. If the orientation is correct, it also sets the cursor.
procedure TSplitterWnd.SetCursorVert( ch : TCursor ); Sets the CursorVert property. See SetCursorHorz.
procedure TSplitterWnd.SetOrientation( o : TOrientation ); Changes the orientation of the splitter window. It is the Orientation property's write procedure. This procedure does a couple of important things. It sets the pane sizes to the same relative percentage that they had in the previous orientation (with some error, I would imagine) and it changes the SplitterWnd cursor.
procedure TSplitterWnd.SetThickness( t : Byte ); Thickness write property. Updates the pane appearance to account for a thicker or thinner drag bar.
procedure TSplitterWnd.UpdatePaneRects; This procedure is the meat and bones of the visual appearance of the splitter window. It checks all of the pane sizes and it draws them correctly on the splitter window. Depending on the orientation and whether or not a pane is the first or last, special cases come into consideration, since the bar positions are calculated according to their middles and not their edges.
procedure TSplitterWnd.WMSize( var message : TWMSize ); Windows size message sent to the splitter window. All of the panes will need to be resized. The recalculatePaneSizes procedure maintains the size percentage of all of the panes.
Properties |
Redeclared properties } {Properties
Events |
Events
Events
Variables |