Unigui的布局面板控件 TUniRegionPanel

时间:2021-05-22 17:00:36
转自Unigui论坛中的控件,修改为可以在xe3下编译的源友。

下面是包文件dpk内容

package UniRegionPanelDXE;

{$R *.res}
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION OFF}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES ON}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DEFINE DEBUG}
{$ENDIF IMPLICITBUILDING}
{$IMPLICITBUILD ON}

requires
rtl,
vcl,
vclimg,
vcldb,
dbrtl,
uniGUI17,
ExtPascal17,
uIndy17,
uniTools17;

contains
UniRegionPanel in 'UniRegionPanel.pas';

end.


下面是UniRegionPanel.pas的源代码

//------------------------------------------------------------------------------
// TUniRegionPanel Component
//
// Developed By: Babak Yaghoobi
//
// Email: b_yaghobi@yahoo.com
//
// Last Update: 2011-07-30 18:00
//
//------------------------------------------------------------------------------
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//------------------------------------------------------------------------------
unit UniRegionPanel;

interface

uses
SysUtils, Classes, Controls, Ext, uniGUIBaseClasses, uniGUIClasses, uniPanel;

Const PackageVersion = '1.0.0' ;

Type
TUniRegionPanel = class(TUniPanel)
private
FRegion: TExtBoxComponentRegion;
FRegionable: Boolean;
FRegionSplit: Boolean;
FRegionCollapsible: Boolean;
FRegionParent: TUniRegionPanel;
FHTML: TStrings;
FRegionFrame: Boolean;
FRegionTitleCollapse: Boolean;
FResgionTitle: AnsiString;
FVersion: string;
procedure SetHTML(const Value: TStrings);
{ Private declarations }
protected
{ Protected declarations }
Nav: TExtPanel ;
Procedure Loaded; Override;
public
{ Public declarations }
Constructor Create(Owner: TComponent); Override;
Destructor Destroy;
published
{ Published declarations }
Property Regionable: Boolean Read FRegionable Write FRegionable;
Property RegionSplit: Boolean Read FRegionSplit Write FRegionSplit;
Property RegionFrame: Boolean Read FRegionFrame Write FRegionFrame;
Property RegionTitleCollapse: Boolean Read FRegionTitleCollapse Write FRegionTitleCollapse;
Property RegionCollapsible: Boolean Read FRegionCollapsible Write FRegionCollapsible;
Property Region: TExtBoxComponentRegion Read FRegion Write FRegion;
Property RegionParent: TUniRegionPanel Read FRegionParent Write FRegionParent;
Property ResgionTitle: AnsiString Read FResgionTitle Write FResgionTitle;
Property Vesrion : string Read FVersion ;
End;

procedure Register;

Implementation

// -----------------------------------------------------------------------------
procedure Register;
begin
RegisterComponents('uniGUI Custom', [TUniRegionPanel]);
end;

// -----------------------------------------------------------------------------
{ TUniRegionPanel }
Constructor TUniRegionPanel.Create(Owner: TComponent);
begin
Inherited Create(Owner);
FVersion := PackageVersion ;
FHTML := TStringList.Create;
end;

// -----------------------------------------------------------------------------
destructor TUniRegionPanel.Destroy;
begin
FHTML.Free;
inherited;
end;

// -----------------------------------------------------------------------------
procedure TUniRegionPanel.Loaded;
begin
Inherited;
If WebMode Then
Begin
ExtPanel.Frame := Self.RegionFrame ;
ExtPanel.Title := FResgionTitle ;
if Regionable Then
Begin
ExtPanel.Region := Self.Region;
ExtPanel.Collapsible := RegionCollapsible;
ExtPanel.Split := Self.RegionSplit;
//ExtPanel.Width := Self.Width;
Nav := TExtPanel.Create ;
ExtPanel.Bbar := Nav ;
Self.ExtPanel.AddTo(RegionParent.ExtPanel.Items);
ExtPanel.Border := True ;
ExtPanel.TitleCollapse := Self.RegionTitleCollapse ;
ExtPanel.AnimCollapse := True ;
End
Else
Begin
ExtPanel.Layout := lyBorder;
ExtPanel.Defaults := ExtPanel.JSObject('autoScroll:false');
ExtPanel.Closable := true;
End;
End;

End;

// -----------------------------------------------------------------------------
procedure TUniRegionPanel.SetHTML(const Value: TStrings);
begin
FHTML.Assign( Value ) ;
end;

// -----------------------------------------------------------------------------
End.

实际运行效果如图:

Unigui的布局面板控件 TUniRegionPanel