Sugestion

Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #68867
    SpeedTI
    Participant

    I would like to suggest the creation of a Layout type component similar or equal to the TLayout component used in Delphi for creating Apps.
    I believe it would be very interesting, because in addition to being very “light”, they would partially avoid the use of components of the type TsPanel or TsGroupBox used in many cases just to group other components.

    Thank you.

    Regards
    Valdir Sola

    #68868
    HeDiBo
    Participant

    Why do you think the use of TPanel with Transparent skin is inferior to a layout setup?

    #68869
    SpeedTI
    Participant

    Hello!
    I did not say that the TPanel component configured in this way is better or worse (I don’t particularly like to use it), I am referring to practicality, besides that it does not have the transparency feature itself. The TPanel after being inserted, needs several configurations to fulfill this purpose. If there was a TLayout it would simply be added to the Form without requiring any adjustment, not to mention that it should be more “light” as I said earlier.

    Regards
    Valdir Sola

    #68871
    HeDiBo
    Participant

    I must disagree with you, TLayout is by no means a light component.
    You may find the following lightweight component useful:

    unit acLayout;
    
    interface
    
    uses
      System.SysUtils, System.Classes, Vcl.Controls, Vcl.ExtCtrls, sPanel;
    
    type
      TacLayout = class(TsPanel)
      private
        { Private declarations }
      protected
        { Protected declarations }
      public
        constructor Create(AOwner: TComponent); override;
        procedure Loaded; override;
      published
        { Published declarations }
      end;
    
    procedure Register;
    
    implementation
    
    procedure Register;
    begin
      RegisterComponents('Samples', [TacLayout]);
    end;
    
    { TacLayout }
    
    constructor TacLayout.Create(AOwner: TComponent);
    begin
       inherited;
       SkinData.SkinSection := 'TRANSPARENT';
       BevelOuter := bvNone;
       Ctl3D := False;
       ShowCaption := False;
       ParentCtl3D := False;
       ParentFont  := False;
       // Although the following would make sense, after the Create event
       // ... apparently the BevelKind property is reset again during load.
       // ... So this logic is moved to after the Loaded event.
    // if csDesigning in ComponentState then BevelKind := bkFlat
    //                                  else BevelKind := bkNone;
    end;
    
    procedure TacLayout.Loaded;
    begin
       inherited;
       // Moved from Create event:
       if csDesigning in ComponentState then BevelKind := bkFlat
                                        else BevelKind := bkNone;
    end;
    
    end.

    Hope this helps.

    #68872
    SpeedTI
    Participant

    It’s a great implementation.
    Thank you.

    Regards
    Valdir Sola

    #68873
    HeDiBo
    Participant

    For some reason the BevelKind is bvNone at design time. I don’t know any more where to set it. Maybe Serge can help here.

    #68874
    SpeedTI
    Participant

    I made this change and apparently resolved:

    constructor TsLayout.Create(AOwner: TComponent); begin
    inherited;
    SkinData.SkinSection := ‘TRANSPARENT’;
    BevelOuter := bvNone;
    Ctl3D := False;
    ShowCaption := False;
    ParentCtl3D := False;
    ParentFont := False;
    // Although the following would make sense, after the Create event
    // … apparently the BevelKind property is reset again during load.
    // … So this logic is moved to after the Loaded event.
    BevelKind := bkFlat;
    end;

    procedure TsLayout.Loaded;
    begin
    inherited;
    // Moved from Create event:
    BevelKind := bkNone;
    end;

    Regards
    Valdir Sola

    #68875
    HeDiBo
    Participant

    Serge,
    Why is the BevelKind property changed after the Create constructor?
    And why does this even work. Is Loaded not called at design time?
    Thank you for clarifying this.

    #68876
    HeDiBo
    Participant

    Loaded procedure is only called if the component is streamed in with the form. If it is created dynamically in code, the Loaded procedure is not called. So, this solution may work, but is by no means foolproof.

    #68877
    HeDiBo
    Participant

    I know now why this is such a pain. Every component that is created at design time gets its properties listed in the dfm file. That file is streamed in by the Reader AFTER the creation. Because on design time, the BevelKind is bkFlat, that is the value streamed to the dfm file. At run time, the property is set to bkNone during the component’s create event, but after that its properties are loaded in by the Reader and reset to bkFlat.
    So, the TacLayout component should inherit from TsCustomPanel, where the properties are not published, and selectively publish the properties needed. If Bevelkind is not published, it will not be streamed in by the Reader and all’s well.
    I’ll study which properties are needed for the TacLayout component and make a better one.

    #68878
    HeDiBo
    Participant

    This is the result:

    unit acLayout;
    {$i sDefs.inc}
    
    interface
    
    uses
      System.SysUtils, System.Classes, Vcl.Controls, Vcl.ExtCtrls, sPanel;
    
    type
      TacLayout = class(TsCustomPanel)
      public
        constructor Create(AOwner: TComponent); override;
        property DockManager;
      published
        property Align;
        property Anchors;
        property AutoSize;
        property Constraints;
        property UseDockManager default True;
        property DockSite;
        property DoubleBuffered;
        property DragCursor;
        property DragKind;
        property DragMode;
        property Enabled;
        property FullRepaint;
        property Locked;
      {$IFDEF D2010}
        property Padding;
        property ParentDoubleBuffered;
        property Touch;
        property VerticalAlignment;
        property OnAlignInsertBefore;
    
        property OnAlignPosition;
        property OnGesture;
        property OnMouseActivate;
      {$ENDIF}
        property ParentShowHint;
        property PopupMenu;
        property ShowHint;
        property TabOrder;
        property TabStop;
        property Visible;
        property OnCanResize;
        property OnClick;
        property OnConstrainedResize;
        property OnContextPopup;
        property OnDockDrop;
        property OnDockOver;
        property OnDblClick;
        property OnDragDrop;
        property OnDragOver;
        property OnEndDock;
        property OnEndDrag;
        property OnEnter;
        property OnExit;
        property OnGetSiteInfo;
        property OnMouseDown;
        property OnMouseMove;
        property OnMouseUp;
        property OnResize;
        property OnStartDock;
        property OnStartDrag;
        property OnUnDock;
        property OnMouseEnter;
        property OnMouseLeave;
      end;
    
    implementation
    
    { TacLayout }
    
    uses Forms;
    
    constructor TacLayout.Create(AOwner: TComponent);
    begin
       inherited;
       SkinData.SkinSection := 'TRANSPARENT';
       BevelEdges := [beLeft, beTop, beRight, beBottom];
       BevelInner := bvNone;
       BevelOuter := bvNone;
       BorderWidth := 0;
       BorderStyle := bsNone;
       Caption := ' ';
       ParentCtl3D := False;
       Ctl3D := False;
    {$IFDEF D2010}
       ShowCaption := False;
    {$ENDIF}
    {$IFDEF DELPHI7UP}
       ParentBackground := True;
    {$ENDIF}
       ParentFont  := False;
       SideShadow.Mode := ssmNone;
       if csDesigning in ComponentState then BevelKind := bkFlat
                                        else BevelKind := bkNone;
    end;
    
    end.
    

    Although the skin says TRANSPARENT the control is not really totally transparent. If you move a TacLayout on top of another control, it will still obscure the covered control.
    What is needed here is a type of glass effect. I’m not sure how to accomplish that.
    Serge, can you help me out?

    #68884
    Support
    Keymaster

    Hello, Dick
    You can’t make a really transparent control in VCL, only emulation of transparency may be implemented.

    #68890
    HeDiBo
    Participant

    Hi Serge,
    There is a reason why I called the component TacLayout. That would leave the possibility to include a TsLayout component in the package.
    Are you willing to do so?

    #68891
    Stephane Senecal
    Participant

    Personally, I don’t see the difference between this TacLayout and a simple flat TsPanel.

    Stephane Senecal
    CIS Group
    Delphi programmer since 2001

    #68892
    HeDiBo
    Participant

    Personally, I don’t see the difference between this TacLayout and a simple flat TsPanel.

    There is no difference (yet). It is just an easy way: no hassle with setting SkinDate and other stuff, also the border at design time is handy (you don’t have to guess at design time where the panel is).

    #68893
    SpeedTI
    Participant

    Exact!

    Regards
    Valdir Sola

Viewing 16 posts - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.