mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 13:59:31 +02:00
LazControls: Add TAdvancedTabControl (TabControl with toolbar)
git-svn-id: trunk@42578 -
This commit is contained in:
parent
276a50bbd4
commit
a37e86a5c1
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1862,6 +1862,9 @@ components/jcf2/readme.txt svneol=native#text/plain
|
||||
components/lazcontrols/Makefile svneol=native#text/plain
|
||||
components/lazcontrols/Makefile.compiled svneol=native#text/plain
|
||||
components/lazcontrols/Makefile.fpc svneol=native#text/plain
|
||||
components/lazcontrols/design/lazcontroldsgn.lpk svneol=native#text/pascal
|
||||
components/lazcontrols/design/lazcontroldsgn.pas svneol=native#text/pascal
|
||||
components/lazcontrols/design/registerlazcontrols.pas svneol=native#text/pascal
|
||||
components/lazcontrols/dividerbevel.pas svneol=native#text/pascal
|
||||
components/lazcontrols/dividerbevel_icon.lrs svneol=native#text/pascal
|
||||
components/lazcontrols/extendednotebook.pas svneol=native#text/pascal
|
||||
|
45
components/lazcontrols/design/lazcontroldsgn.lpk
Normal file
45
components/lazcontrols/design/lazcontroldsgn.lpk
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<Package Version="4">
|
||||
<PathDelim Value="\"/>
|
||||
<Name Value="LazControlDsgn"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)\"/>
|
||||
</SearchPaths>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<MsgFileName Value=""/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Files Count="1">
|
||||
<Item1>
|
||||
<Filename Value="registerlazcontrols.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="registerlazcontrols"/>
|
||||
</Item1>
|
||||
</Files>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<RequiredPkgs Count="3">
|
||||
<Item1>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LazControls"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="FCL"/>
|
||||
</Item3>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
21
components/lazcontrols/design/lazcontroldsgn.pas
Normal file
21
components/lazcontrols/design/lazcontroldsgn.pas
Normal file
@ -0,0 +1,21 @@
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit LazControlDsgn;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
RegisterLazControls, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterUnit('RegisterLazControls', @RegisterLazControls.Register);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPackage('LazControlDsgn', @Register);
|
||||
end.
|
116
components/lazcontrols/design/registerlazcontrols.pas
Normal file
116
components/lazcontrols/design/registerlazcontrols.pas
Normal file
@ -0,0 +1,116 @@
|
||||
unit RegisterLazControls;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, ExtendedTabControls, ComponentEditors, ObjInspStrConsts, PropEdits,
|
||||
ComCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TAdvancedTabControlComponentEditor }
|
||||
|
||||
TAdvancedTabControlComponentEditor = class(TOldTabControlComponentEditor)
|
||||
public
|
||||
procedure ExecuteVerb(Index: Integer); override;
|
||||
function GetVerb(Index: Integer): string; override;
|
||||
function GetVerbCount: Integer; override;
|
||||
function ToolBar: TToolBar; virtual;
|
||||
end;
|
||||
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('LazControls',[TAdvancedTabControl]);
|
||||
RegisterNoIcon([TAdvancedToolbar, TAdvancedToolButton]);
|
||||
RegisterComponentEditor(TAdvancedTabControl, TAdvancedTabControlComponentEditor);
|
||||
end;
|
||||
|
||||
{ TAdvancedTabControlComponentEditor }
|
||||
|
||||
procedure TAdvancedTabControlComponentEditor.ExecuteVerb(Index: Integer);
|
||||
var
|
||||
NewStyle: TToolButtonStyle;
|
||||
Hook: TPropertyEditorHook;
|
||||
NewToolButton: TToolButton;
|
||||
NewName: string;
|
||||
CurToolBar: TToolBar;
|
||||
SiblingButton: TToolButton;
|
||||
c: Integer;
|
||||
begin
|
||||
c := inherited GetVerbCount;
|
||||
if Index < c then begin
|
||||
inherited ExecuteVerb(Index);
|
||||
exit;
|
||||
end;
|
||||
|
||||
Index := Index - c;
|
||||
Hook:=nil;
|
||||
if not GetHook(Hook) then exit;
|
||||
case Index of
|
||||
0: NewStyle := tbsButton;
|
||||
1: NewStyle := tbsCheck;
|
||||
2: NewStyle := tbsSeparator;
|
||||
3: NewStyle := tbsDivider;
|
||||
else
|
||||
exit;
|
||||
end;
|
||||
CurToolBar := ToolBar;
|
||||
NewToolButton := TAdvancedToolButton.Create(CurToolBar.Owner);
|
||||
NewName := GetDesigner.CreateUniqueComponentName(NewToolButton.ClassName);
|
||||
NewToolButton.Caption := NewName;
|
||||
NewToolButton.Name := NewName;
|
||||
NewToolButton.Style := NewStyle;
|
||||
if NewStyle = tbsDivider then
|
||||
NewToolButton.Width := 3;
|
||||
// position the button next to the last button
|
||||
if CurToolBar.ButtonCount > 0 then
|
||||
begin
|
||||
SiblingButton := CurToolBar.Buttons[CurToolBar.ButtonCount - 1];
|
||||
NewToolButton.SetBounds(SiblingButton.Left + SiblingButton.Width,
|
||||
SiblingButton.Top, NewToolButton.Width, NewToolButton.Height);
|
||||
end;
|
||||
NewToolButton.Parent := CurToolBar;
|
||||
Hook.PersistentAdded(NewToolButton, True);
|
||||
Modified;
|
||||
end;
|
||||
|
||||
function TAdvancedTabControlComponentEditor.GetVerb(Index: Integer): string;
|
||||
var
|
||||
c: Integer;
|
||||
begin
|
||||
c := inherited GetVerbCount;
|
||||
if Index < c then
|
||||
Result := inherited GetVerb(Index)
|
||||
else
|
||||
case Index - c of
|
||||
0: Result := tbceNewButton;
|
||||
1: Result := tbceNewCheckbutton;
|
||||
2: Result := tbceNewSeparator;
|
||||
3: Result := tbceNewDivider;
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
end;
|
||||
|
||||
function TAdvancedTabControlComponentEditor.GetVerbCount: Integer;
|
||||
begin
|
||||
Result := inherited GetVerbCount + 4;
|
||||
end;
|
||||
|
||||
function TAdvancedTabControlComponentEditor.ToolBar: TToolBar;
|
||||
begin
|
||||
Result := nil;
|
||||
if TabControl = nil then
|
||||
exit;
|
||||
Result := TAdvancedTabControlNoteBookStrings(TCustomAdvancedTabControl(TabControl).Tabs).ToolBar;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<Package Version="4">
|
||||
<PathDelim Value="\"/>
|
||||
@ -19,7 +19,7 @@
|
||||
<Description Value="Some extra LCL controls needed by the IDE."/>
|
||||
<License Value="modified LGPL-2"/>
|
||||
<Version Major="1" Release="1"/>
|
||||
<Files Count="12">
|
||||
<Files Count="13">
|
||||
<Item1>
|
||||
<Filename Value="dividerbevel.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
@ -74,6 +74,10 @@
|
||||
<Filename Value="listfilteredit_icon.lrs"/>
|
||||
<Type Value="LRS"/>
|
||||
</Item12>
|
||||
<Item13>
|
||||
<Filename Value="extendedtabcontrols.pas"/>
|
||||
<UnitName Value="ExtendedTabControls"/>
|
||||
</Item13>
|
||||
</Files>
|
||||
<LazDoc Paths="docs"/>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
@ -89,5 +93,8 @@
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
</PublishOptions>
|
||||
<CustomOptions Items="ExternHelp" Version="2">
|
||||
<_ExternHelp Items="Count"/>
|
||||
</CustomOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
||||
|
@ -7,8 +7,8 @@ unit LazControls;
|
||||
interface
|
||||
|
||||
uses
|
||||
DividerBevel, ExtendedNotebook, ListFilterEdit, TreeFilterEdit,
|
||||
ShortPathEdit, LvlGraphCtrl, LazarusPackageIntf;
|
||||
DividerBevel, ExtendedNotebook, ListFilterEdit, TreeFilterEdit, ShortPathEdit,
|
||||
LvlGraphCtrl, ExtendedTabControls, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -744,6 +744,7 @@ type
|
||||
procedure Paint; virtual;
|
||||
procedure AdjustDisplayRectWithBorder(var ARect: TRect); virtual;
|
||||
procedure AdjustClientRect(var ARect: TRect); override;
|
||||
function CreateTabNoteBookStrings: TTabControlNoteBookStrings; virtual;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
@ -2054,8 +2055,8 @@ type
|
||||
procedure MoveSubMenuItems(SrcMenuItem, DestMenuItem: TMenuItem);
|
||||
procedure AddButton(Button: TToolButton);
|
||||
procedure RemoveButton(Button: TToolButton);
|
||||
function IsVertical: Boolean;
|
||||
protected
|
||||
function IsVertical: Boolean; virtual;
|
||||
class procedure WSRegisterClass; override;
|
||||
procedure AdjustClientRect(var ARect: TRect); override;
|
||||
class function GetControlClassDefaultSize: TSize; override;
|
||||
|
@ -665,6 +665,11 @@ begin
|
||||
AdjustDisplayRect(ARect);
|
||||
end;
|
||||
|
||||
function TTabControl.CreateTabNoteBookStrings: TTabControlNoteBookStrings;
|
||||
begin
|
||||
Result := TTabControlNoteBookStrings.Create(Self);
|
||||
end;
|
||||
|
||||
constructor TTabControl.Create(TheOwner: TComponent);
|
||||
begin
|
||||
FTabControlCreating:=true;
|
||||
@ -674,7 +679,7 @@ begin
|
||||
FTabPosition:=tpTop;
|
||||
FImageChangeLink := TChangeLink.Create;
|
||||
FImageChangeLink.OnChange := @ImageListChange;
|
||||
FTabs:=TTabControlNoteBookStrings.Create(Self);
|
||||
FTabs := CreateTabNoteBookStrings;
|
||||
with GetControlClassDefaultSize do
|
||||
SetInitialBounds(0, 0, CX, CY);
|
||||
BorderWidth:=0;
|
||||
|
Loading…
Reference in New Issue
Block a user