Search code examples
delphidelphi-7sptbxlib

SpTBX: can I use Panels' DockedWidth/FloatingWidth


Moving from TBX to SpTBX. I used in the past TTbxDockablePanel which has such props:

DockedWidth
DockedHeight
FloatingWidth
FloatingHeight

I can't find such properties in SpTBX panels, so how should I change my code to use such props? ie. i need to get/set SpTBX panel's docked width/height and floating width/height.


Solution

  • DockedWidth and DockedHeight

    A TSpTBXDockablePanel now has a property DefaultDockedSize. A docked panel is docked to either a vertical or horizontal dock, so it only needs one size, which specifies the width (in a vertical dock) or height (in a horizontal dock.) The length of the other axis is a result of either the dock size or the other panels in the same dock. If there are other panels, the size it becomes is the width of the other panels in the dock. If there aren't, it will use either the previous size (if DefaultDockedSize is 0) or try to use DefaultDockedSize.

    See TSpTBXCustomDockablePanel.SetParent for the code. You'll be interested in the two branches beginning if ToDock then... and if ToFloating then.... There are some comments there that I've tried to interpret to write the above.

    From memory, when I converted from TBX to SpTBX years ago, this was the hardest area to get behaving exactly the same. However, you can get it to behave 'okay', ie with behaviour that makes sense, easily.

    FloatingWidth and FloatingHeight

    Replaced by FloatingClientWidth and FloatingClientHeight. Note that these are the client sizes not window sizes, but in general they should be direct replacements.

    In addition

    There is a comment at the top of the SpTBXDkPanels.pas file,

    // - To handle the size constraints use GetMinMaxSize when the DP is floating,
    //   and ConstrainedResize when is Docked (explicitly check if it's docked).
    

    You might find that useful too.

    There are a reasonable number of comments scattered through the code. The SpTBX library doesn't have very good documentation, but it does come with high-quality source... Use the source, Luke :)