2008-02-03 12:05:55 +00:00
|
|
|
{*********************************************************}
|
|
|
|
{* VPNABED.PAS 1.03 *}
|
|
|
|
{*********************************************************}
|
|
|
|
|
|
|
|
{* ***** BEGIN LICENSE BLOCK ***** *}
|
|
|
|
{* Version: MPL 1.1 *}
|
|
|
|
{* *}
|
|
|
|
{* The contents of this file are subject to the Mozilla Public License *}
|
|
|
|
{* Version 1.1 (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.mozilla.org/MPL/ *}
|
|
|
|
{* *}
|
|
|
|
{* Software distributed under the License is distributed on an "AS IS" basis, *}
|
|
|
|
{* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License *}
|
|
|
|
{* for the specific language governing rights and limitations under the *}
|
|
|
|
{* License. *}
|
|
|
|
{* *}
|
|
|
|
{* The Original Code is TurboPower Visual PlanIt *}
|
|
|
|
{* *}
|
|
|
|
{* The Initial Developer of the Original Code is TurboPower Software *}
|
|
|
|
{* *}
|
|
|
|
{* Portions created by TurboPower Software Inc. are Copyright (C) 2002 *}
|
|
|
|
{* TurboPower Software Inc. All Rights Reserved. *}
|
|
|
|
{* *}
|
|
|
|
{* Contributor(s): *}
|
|
|
|
{* *}
|
|
|
|
{* ***** END LICENSE BLOCK ***** *}
|
|
|
|
|
2016-06-22 07:59:17 +00:00
|
|
|
{$I vp.inc}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
unit VpNabEd;
|
|
|
|
{-property editor for the NavBar}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2018-05-02 21:50:54 +00:00
|
|
|
lazlogger,
|
2018-05-02 15:52:08 +00:00
|
|
|
|
2016-07-12 18:00:32 +00:00
|
|
|
LCLProc, LCLType, LCLIntf,
|
2018-05-02 15:52:08 +00:00
|
|
|
PropEdits, LazarusPackageIntf, FieldsEditor, ComponentEditors,
|
|
|
|
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
2008-02-03 12:05:55 +00:00
|
|
|
StdCtrls, ExtCtrls, Buttons,
|
2018-05-04 12:04:31 +00:00
|
|
|
VpBase, VpNavBar, Types;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
type
|
2018-05-02 21:50:54 +00:00
|
|
|
|
|
|
|
{ TVpNavBarEditor }
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
TVpNavBarEditor = class(TComponentEditor)
|
|
|
|
procedure ExecuteVerb(Index : Integer); override;
|
|
|
|
function GetVerb(Index : Integer) : string; override;
|
|
|
|
function GetVerbCount : Integer; override;
|
|
|
|
end;
|
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
{ TfrmNavBarEd }
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
TfrmNavBarEd = class(TForm)
|
2018-05-04 10:01:26 +00:00
|
|
|
Bevel1: TBevel;
|
2018-05-04 12:04:31 +00:00
|
|
|
Label4: TLabel;
|
|
|
|
lbImages: TListBox;
|
2018-05-02 15:52:08 +00:00
|
|
|
pnlFoldersAndItems: TPanel;
|
2008-02-03 12:05:55 +00:00
|
|
|
pnlItems: TPanel;
|
|
|
|
pnlFolders: TPanel;
|
|
|
|
lbItems: TListBox;
|
|
|
|
lbFolders: TListBox;
|
|
|
|
Panel1: TPanel;
|
|
|
|
btnItemAdd: TSpeedButton;
|
|
|
|
btnItemDelete: TSpeedButton;
|
|
|
|
btnItemUp: TSpeedButton;
|
|
|
|
btnItemDown: TSpeedButton;
|
|
|
|
Panel4: TPanel;
|
|
|
|
Label2: TLabel;
|
|
|
|
Panel5: TPanel;
|
|
|
|
btnFolderAdd: TSpeedButton;
|
|
|
|
btnFolderDelete: TSpeedButton;
|
|
|
|
btnFolderUp: TSpeedButton;
|
|
|
|
btnFolderDown: TSpeedButton;
|
|
|
|
Panel6: TPanel;
|
|
|
|
Label1: TLabel;
|
2018-05-02 15:52:08 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure btnFolderAddClick(Sender: TObject);
|
2018-05-02 15:52:08 +00:00
|
|
|
procedure btnFolderDeleteClick(Sender: TObject);
|
|
|
|
procedure btnFolderDownClick(Sender: TObject);
|
|
|
|
procedure btnFolderUpClick(Sender: TObject);
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure btnItemAddClick(Sender: TObject);
|
2018-05-02 15:52:08 +00:00
|
|
|
procedure btnItemDeleteClick(Sender: TObject);
|
|
|
|
procedure btnItemDownClick(Sender: TObject);
|
|
|
|
procedure btnItemUpClick(Sender: TObject);
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
2018-05-02 15:52:08 +00:00
|
|
|
procedure FormCreate(Sender: TObject);
|
2018-05-02 21:50:54 +00:00
|
|
|
procedure FormDestroy(Sender: TObject);
|
2018-05-02 15:52:08 +00:00
|
|
|
// procedure FormResize(Sender: TObject);
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
|
|
|
procedure lbFoldersClick(Sender: TObject);
|
2018-05-04 12:04:31 +00:00
|
|
|
procedure lbImagesClick(Sender: TObject);
|
|
|
|
procedure lbImagesDrawItem(Control: TWinControl; Index: Integer;
|
|
|
|
ARect: TRect; State: TOwnerDrawState);
|
2018-05-02 15:52:08 +00:00
|
|
|
procedure lbItemsClick(Sender: TObject);
|
|
|
|
procedure lbItemsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
2018-05-02 21:50:54 +00:00
|
|
|
procedure lbItemsMeasureItem(Control: TWinControl; Index: Integer; var Height: Integer);
|
2018-05-02 15:52:08 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
private
|
2018-05-02 15:52:08 +00:00
|
|
|
FBar: TVpNavBar;
|
|
|
|
function FindBtnIndex(APersistent: TPersistent): Integer;
|
|
|
|
function FindFolderIndex(APersistent: TPersistent): Integer;
|
2018-05-03 09:45:11 +00:00
|
|
|
function GetFolderDisplayName(AFolder: TVpNavFolder): String;
|
|
|
|
function GetItemDisplayName(AItem: TVpNavBtnItem): String;
|
2018-05-02 21:50:54 +00:00
|
|
|
procedure SelectionChanged(AOrderChanged: Boolean = false);
|
|
|
|
procedure SelectList(SelList: TPersistentSelectionList);
|
2018-05-03 13:19:15 +00:00
|
|
|
procedure UpdateBtnStates;
|
2018-05-02 15:52:08 +00:00
|
|
|
|
2018-05-03 09:45:11 +00:00
|
|
|
private
|
|
|
|
FDesigner: TComponentEditorDesigner;
|
|
|
|
procedure AddDesignHookHandlers;
|
|
|
|
procedure OnGetSelection(const ASelection: TPersistentSelectionList);
|
|
|
|
procedure OnPersistentAdded(APersistent: TPersistent; Select: boolean);
|
|
|
|
procedure OnPersistentDeleting(APersistent: TPersistent);
|
2018-05-04 09:17:09 +00:00
|
|
|
procedure OnRefreshPropertyValues;
|
2018-05-03 09:45:11 +00:00
|
|
|
procedure OnSetSelection(const ASelection: TPersistentSelectionList);
|
|
|
|
|
2018-05-04 12:35:39 +00:00
|
|
|
protected
|
|
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
public
|
|
|
|
{ Public declarations }
|
2018-05-02 21:50:54 +00:00
|
|
|
constructor Create(AOwner: TComponent; ABar: TVpNavBar;
|
|
|
|
ADesigner: TComponentEditorDesigner); reintroduce;
|
|
|
|
destructor Destroy; override;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure PopulateFolderList;
|
2018-05-04 12:04:31 +00:00
|
|
|
procedure PopulateImagesList;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure PopulateItemList;
|
2018-05-02 21:50:54 +00:00
|
|
|
procedure SetData(ADesigner: TComponentEditorDesigner; ABar: TVpNavBar);
|
2018-05-02 15:52:08 +00:00
|
|
|
property Bar: TVpNavBar read FBar;
|
2018-05-02 21:50:54 +00:00
|
|
|
property Designer: TComponentEditorDesigner read FDesigner;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
{$R *.lfm}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-07-12 18:00:32 +00:00
|
|
|
uses
|
2018-05-04 12:04:31 +00:00
|
|
|
PropEditUtils, StrUtils, ImgList,
|
2016-07-12 18:00:32 +00:00
|
|
|
VpMisc;
|
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
const
|
|
|
|
ITEMS_MARGIN = 2;
|
|
|
|
IMG_MARGIN = 4;
|
2018-05-04 12:04:31 +00:00
|
|
|
IMG_MARGIN_HOR = 8;
|
|
|
|
IMG_MARGIN_VERT = 4;
|
2018-05-02 21:50:54 +00:00
|
|
|
|
2018-05-03 22:12:30 +00:00
|
|
|
|
|
|
|
{-------------------------------------------------------------------------------
|
|
|
|
TVpNavBarEditor
|
|
|
|
-------------------------------------------------------------------------------}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
procedure TVpNavBarEditor.ExecuteVerb(Index : Integer);
|
2018-05-03 09:45:11 +00:00
|
|
|
var
|
|
|
|
bar: TVpNavBar;
|
|
|
|
editor: TObject;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2018-05-03 09:45:11 +00:00
|
|
|
if Index = 0 then begin
|
|
|
|
bar := Component as TVpNavBar;
|
|
|
|
editor := FindEditorForm(bar);
|
|
|
|
if editor = nil then begin
|
|
|
|
DebugLn('EditorForm not found.');
|
|
|
|
editor := TfrmNavBarEd.Create(Application, bar, Designer);
|
|
|
|
RegisterEditorForm(editor, bar);
|
|
|
|
end else
|
|
|
|
TfrmNavBarEd(editor).SetData(Designer, bar);
|
|
|
|
if editor <> nil then
|
|
|
|
TfrmNavBarEd(editor).ShowOnTop;
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TVpNavBarEditor.GetVerb(Index : Integer) : string;
|
|
|
|
begin
|
|
|
|
if Index = 0 then
|
|
|
|
Result := 'Layout Tool...';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TVpNavBarEditor.GetVerbCount : Integer;
|
|
|
|
begin
|
|
|
|
Result := 1;
|
|
|
|
end;
|
|
|
|
|
2016-11-21 17:12:05 +00:00
|
|
|
|
2018-05-03 22:12:30 +00:00
|
|
|
{-------------------------------------------------------------------------------
|
|
|
|
TfrmNavBarEd
|
|
|
|
-------------------------------------------------------------------------------}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
constructor TfrmNavBarEd.Create(AOwner: TComponent; ABar: TVpNavBar;
|
|
|
|
ADesigner: TComponentEditorDesigner);
|
|
|
|
begin
|
|
|
|
inherited Create(AOwner);
|
|
|
|
|
|
|
|
FBar := ABar;
|
|
|
|
FDesigner := ADesigner;
|
|
|
|
|
|
|
|
PopulateFolderList;
|
2018-05-03 09:45:11 +00:00
|
|
|
AddDesignHookHandlers;
|
2018-05-02 21:50:54 +00:00
|
|
|
SelectionChanged;
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2018-05-02 21:50:54 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TfrmNavBarEd.Destroy;
|
|
|
|
begin
|
2018-05-03 09:45:11 +00:00
|
|
|
UnregisterEditorForm(Self);
|
2018-05-02 21:50:54 +00:00
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2018-05-03 09:45:11 +00:00
|
|
|
procedure TfrmNavBarEd.AddDesignHookHandlers;
|
|
|
|
begin
|
|
|
|
if GlobalDesignHook <> nil then
|
|
|
|
begin
|
|
|
|
GlobalDesignHook.RemoveAllHandlersForObject(Self);
|
|
|
|
if FBar <> nil then
|
|
|
|
begin
|
2018-05-04 09:17:09 +00:00
|
|
|
GlobalDesignHook.AddHandlerGetSelection(OnGetSelection);
|
2018-05-03 09:45:11 +00:00
|
|
|
GlobalDesignHook.AddHandlerPersistentAdded(OnPersistentAdded);
|
|
|
|
GlobalDesignHook.AddHandlerPersistentDeleting(OnPersistentDeleting);
|
2018-05-04 09:17:09 +00:00
|
|
|
GlobalDesignHook.AddHandlerRefreshPropertyValues(OnRefreshPropertyValues);
|
2018-05-03 09:45:11 +00:00
|
|
|
GlobalDesignHook.AddHandlerSetSelection(OnSetSelection);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
procedure TfrmNavBarEd.FormClose(Sender: TObject;
|
|
|
|
var Action: TCloseAction);
|
|
|
|
begin
|
2018-05-03 09:45:11 +00:00
|
|
|
UnregisterEditorForm(Self);
|
2018-05-02 21:50:54 +00:00
|
|
|
Action := caFree;
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TfrmNavBarEd.FormCreate(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Top := (Screen.Height - Height) div 3;
|
|
|
|
Left := (Screen.Width - Width) div 2;
|
|
|
|
end;
|
2018-05-02 15:52:08 +00:00
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
procedure TfrmNavBarEd.FormDestroy(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2018-05-02 21:50:54 +00:00
|
|
|
if GlobalDesignHook = nil then
|
|
|
|
exit;
|
|
|
|
if Assigned(FBar) and ((lbFolders.SelCount > 0) or (lbItems.SelCount > 0)) then
|
|
|
|
GlobalDesignHook.SelectOnlyThis(FBar);
|
|
|
|
GlobalDesignHook.RemoveAllHandlersForObject(Self);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
procedure TfrmNavBarEd.FormShow(Sender: TObject);
|
|
|
|
begin
|
2018-05-04 12:04:31 +00:00
|
|
|
PopulateImagesList;
|
2018-05-03 22:12:30 +00:00
|
|
|
lbFolders.SetFocus;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2018-05-02 15:52:08 +00:00
|
|
|
|
|
|
|
function TfrmNavBarEd.FindFolderIndex(APersistent: TPersistent): Integer;
|
|
|
|
begin
|
|
|
|
for Result := 0 to lbFolders.Items.Count-1 do
|
|
|
|
if TPersistent(lbFolders.Items.Objects[Result]) = APersistent then
|
|
|
|
exit;
|
|
|
|
Result := -1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TfrmNavBarEd.FindBtnIndex(APersistent: TPersistent): Integer;
|
|
|
|
begin
|
|
|
|
for Result := 0 to lbItems.Items.Count-1 do
|
|
|
|
if TPersistent(lbItems.Items.Objects[Result]) = APersistent then
|
|
|
|
exit;
|
|
|
|
Result := -1;
|
|
|
|
end;
|
|
|
|
|
2018-05-03 09:45:11 +00:00
|
|
|
function TfrmNavBarEd.GetFolderDisplayName(AFolder: TVpNavFolder): String;
|
|
|
|
begin
|
|
|
|
Result := IfThen(AFolder.Caption <> '', AFolder.Caption, AFolder.Name);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TfrmNavBarEd.GetItemDisplayName(AItem: TVpNavBtnItem): String;
|
|
|
|
begin
|
|
|
|
Result := IfThen(AItem.Caption <> '', AItem.Caption, AItem.Name);
|
|
|
|
end;
|
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
procedure TfrmNavBarEd.OnGetSelection(const ASelection: TPersistentSelectionList);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if not Assigned(ASelection) then
|
|
|
|
exit;
|
|
|
|
if ASelection.Count > 0 then
|
|
|
|
ASelection.Clear;
|
|
|
|
|
|
|
|
if lbFolders.Focused then begin
|
|
|
|
for i:=0 to lbFolders.Items.Count-1 do
|
|
|
|
if lbFolders.Selected[i] then
|
|
|
|
ASelection.Add(TPersistent(lbFolders.Items.Objects[i]));
|
|
|
|
end else
|
|
|
|
if lbItems.Focused then begin
|
|
|
|
for i:=0 to lbItems.Items.Count-1 do
|
|
|
|
if lbItems.Selected[i] then
|
|
|
|
ASelection.Add(TPersistent(lbItems.Items.Objects[i]));
|
|
|
|
end;
|
2018-05-03 09:45:11 +00:00
|
|
|
end;
|
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
procedure TfrmNavBarEd.OnPersistentAdded(APersistent: TPersistent; Select: boolean);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
2018-05-02 21:50:54 +00:00
|
|
|
if APersistent = nil then
|
2018-05-04 09:17:09 +00:00
|
|
|
DebugLn('OnPersistentAdded: Persistent = nil')
|
|
|
|
else
|
|
|
|
DebugLn('OnPersistentAdded: Persistent = ' + APersistent.ClassName);
|
2018-05-02 21:50:54 +00:00
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
if not Assigned(APersistent) then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
if (APersistent is TVpNavFolder) then
|
|
|
|
begin
|
|
|
|
PopulateFolderList;
|
|
|
|
if Select then begin
|
|
|
|
i := FindFolderIndex(APersistent);
|
|
|
|
lbFolders.ItemIndex := i;
|
|
|
|
end;
|
|
|
|
end else
|
|
|
|
if (APersistent is TVpNavBtnItem) then
|
|
|
|
begin
|
|
|
|
PopulateItemList;
|
|
|
|
if Select then begin
|
|
|
|
i := FindBtnIndex(APersistent);
|
|
|
|
lbItems.ItemIndex := i;
|
|
|
|
end;
|
|
|
|
end;
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.OnPersistentDeleting(APersistent: TPersistent);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if APersistent is TVpNavFolder then
|
|
|
|
begin
|
|
|
|
i := FindFolderIndex(APersistent);
|
|
|
|
if i <> -1 then lbFolders.Items.Delete(i);
|
|
|
|
end else
|
|
|
|
if APersistent is TVpNavBtnItem then
|
|
|
|
begin
|
|
|
|
i := FindBtnIndex(APersistent);
|
|
|
|
if i <> -1 then lbItems.Items.Delete(i);
|
|
|
|
end;
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
|
|
|
|
2018-05-04 09:17:09 +00:00
|
|
|
procedure TfrmNavBarEd.OnRefreshPropertyValues;
|
|
|
|
var
|
|
|
|
selections: TPersistentSelectionList;
|
|
|
|
i: Integer;
|
|
|
|
begin
|
2018-05-04 12:35:39 +00:00
|
|
|
if FBar = nil then
|
|
|
|
exit;
|
|
|
|
|
2018-05-04 09:17:09 +00:00
|
|
|
selections := TPersistentSelectionList.Create;
|
|
|
|
try
|
|
|
|
Assert(Assigned(GlobalDesignHook));
|
|
|
|
GlobalDesignHook.GetSelection(selections);
|
|
|
|
for i:=0 to selections.Count-1 do begin
|
|
|
|
if selections[i] is TVpNavFolder then
|
|
|
|
lbFolders.Items[i] := GetFolderDisplayName(TVpNavFolder(selections[i]))
|
|
|
|
else if selections[i] is TVpNavBtnItem then
|
2018-05-04 12:04:31 +00:00
|
|
|
lbItems.Items[i] := GetItemDisplayName(TVpNavBtnItem(selections[i]))
|
|
|
|
else if (selections[i] is TCustomImageList) and (TCustomImageList(selections[i]) = FBar.Images) then
|
|
|
|
PopulateImagesList;
|
2018-05-04 09:17:09 +00:00
|
|
|
end;
|
|
|
|
finally
|
|
|
|
selections.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
procedure TfrmNavBarEd.OnSetSelection(const ASelection: TPersistentSelectionList);
|
|
|
|
var
|
|
|
|
i, j: Integer;
|
|
|
|
begin
|
|
|
|
if Assigned(ASelection) and (ASelection.Count > 0) then
|
|
|
|
begin
|
2018-05-04 12:35:39 +00:00
|
|
|
if ASelection[0] is TVpNavFolder then begin
|
2018-05-02 15:52:08 +00:00
|
|
|
//Unselect all
|
2018-05-04 12:35:39 +00:00
|
|
|
lbFolders.ClearSelection;
|
2018-05-02 15:52:08 +00:00
|
|
|
//select from list
|
|
|
|
for i := 0 to ASelection.Count - 1 do begin
|
|
|
|
j := FindFolderIndex(ASelection[i]);
|
|
|
|
if j <> -1 then lbFolders.Selected[j] := true;
|
|
|
|
end;
|
|
|
|
end else
|
2018-05-04 12:35:39 +00:00
|
|
|
if ASelection[0] is TVpNavBtnItem then
|
2018-05-02 15:52:08 +00:00
|
|
|
begin
|
|
|
|
// Unselect all
|
2018-05-04 12:35:39 +00:00
|
|
|
lbItems.ClearSelection;
|
2018-05-02 15:52:08 +00:00
|
|
|
// Select from list
|
|
|
|
for i := 0 to ASelection.Count - 1 do begin
|
|
|
|
j := FindBtnIndex(ASelection[i]);
|
|
|
|
if j <> -1 then lbItems.Selected[j] := true;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TfrmNavBarEd.PopulateFolderList;
|
|
|
|
var
|
|
|
|
I : Integer;
|
|
|
|
S : string;
|
|
|
|
begin
|
|
|
|
lbFolders.Clear;
|
2018-05-04 12:35:39 +00:00
|
|
|
if FBar = nil then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
for I := 0 to FBar.FolderCount-1 do begin
|
|
|
|
S := GetFolderDisplayName(FBar.Folders[I]);
|
|
|
|
lbFolders.Items.AddObject(S, FBar.Folders[I]);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-05-04 12:04:31 +00:00
|
|
|
procedure TfrmNavbarEd.PopulateImagesList;
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
lbImages.Clear;
|
|
|
|
if (FBar = nil) or (FBar.Images = nil) then
|
|
|
|
exit;
|
|
|
|
|
2018-05-04 12:35:39 +00:00
|
|
|
for i:=0 to FBar.Images.Count-1 do
|
2018-05-04 12:04:31 +00:00
|
|
|
lbImages.Items.Add('');
|
|
|
|
|
|
|
|
lbImages.ItemHeight := FBar.Images.Width + 2*IMG_MARGIN_HOR;
|
|
|
|
lbImages.ClientWidth := FBar.Images.Width + 2*IMG_MARGIN_VERT + GetScrollbarWidth;
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TfrmNavBarEd.PopulateItemList;
|
|
|
|
var
|
|
|
|
I : Integer;
|
|
|
|
S : string;
|
|
|
|
begin
|
|
|
|
lbItems.Clear;
|
2018-05-04 12:35:39 +00:00
|
|
|
if (lbFolders.ItemIndex = -1) or (FBar = nil) then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
with FBar.Folders[lbFolders.ItemIndex] do
|
|
|
|
for I := 0 to ItemCount-1 do begin
|
2018-05-03 09:45:11 +00:00
|
|
|
S := GetItemDisplayName(Items[I]);
|
2018-05-04 12:35:39 +00:00
|
|
|
lbItems.Items.AddObject(S, Items[i]);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
procedure TfrmNavBarEd.SetData(ADesigner: TComponentEditorDesigner; ABar: TVpNavBar);
|
2018-05-02 15:52:08 +00:00
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if FBar <> nil then
|
|
|
|
FBar.RemoveFreeNotification(self);
|
|
|
|
|
|
|
|
FBar := ABar;
|
|
|
|
FDesigner := ADesigner;
|
|
|
|
|
|
|
|
if FBar <> nil then
|
|
|
|
FBar.FreeNotification(self);
|
|
|
|
|
|
|
|
PopulateFolderList;
|
2018-05-04 12:04:31 +00:00
|
|
|
PopulateImagesList;
|
2018-05-02 15:52:08 +00:00
|
|
|
|
2018-05-03 09:45:11 +00:00
|
|
|
AddDesignHookHandlers;
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TfrmNavBarEd.lbFoldersClick(Sender: TObject);
|
2018-05-02 15:52:08 +00:00
|
|
|
var
|
|
|
|
SelList: TPersistentSelectionList;
|
|
|
|
i: Integer;
|
|
|
|
begin
|
2018-05-04 12:35:39 +00:00
|
|
|
if FBar = nil then
|
|
|
|
exit;
|
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
PopulateItemList;
|
2018-05-04 12:35:39 +00:00
|
|
|
FBar.ActiveFolder := lbFolders.ItemIndex;
|
2018-05-04 12:04:31 +00:00
|
|
|
lbImages.ItemIndex := -1;
|
2018-05-02 15:52:08 +00:00
|
|
|
|
|
|
|
SelList := TPersistentSelectionList.Create;
|
|
|
|
SelList.ForceUpdate := true;
|
2018-05-02 21:50:54 +00:00
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
for i := 0 to pred(lbFolders.Items.Count) do
|
|
|
|
if lbFolders.Selected[i] then begin
|
|
|
|
SelList.Add(TPersistent(lbFolders.Items.Objects[i]));
|
2018-05-04 12:35:39 +00:00
|
|
|
FBar.FolderCollection.DoOnItemSelected(i);
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
if SelList.Count > 0 then
|
|
|
|
SelectList(SelList);
|
2018-05-02 21:50:54 +00:00
|
|
|
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2018-05-04 12:04:31 +00:00
|
|
|
procedure TfrmNavBarEd.lbImagesClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
btn: TVpNavBtnItem;
|
|
|
|
res: Integer;
|
|
|
|
begin
|
|
|
|
if (lbImages.ItemIndex <> -1) and (lbItems.ItemIndex <> -1) then begin
|
|
|
|
btn := TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]);
|
|
|
|
if btn.IconIndex <> -1 then begin
|
|
|
|
res := MessageDlg('Do you want to replace the button icon by this one?',
|
|
|
|
mtConfirmation, [mbYes, mbNo, mbCancel], 0);
|
|
|
|
if res <> mrYes then
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
btn.IconIndex := lbImages.ItemIndex;
|
|
|
|
lbItems.Invalidate;
|
|
|
|
if Assigned(Designer) then
|
|
|
|
Designer.Modified;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.lbImagesDrawItem(Control: TWinControl; Index: Integer;
|
|
|
|
ARect: TRect; State: TOwnerDrawState);
|
|
|
|
var
|
|
|
|
x, y: Integer;
|
|
|
|
begin
|
|
|
|
if [odSelected, odFocused] * State <> [] then
|
|
|
|
lbImages.Canvas.Brush.Color := clHighlight
|
|
|
|
else
|
|
|
|
lbImages.Canvas.Brush.Color := clWindow;
|
|
|
|
lbImages.Canvas.FillRect(ARect);
|
2018-05-04 12:35:39 +00:00
|
|
|
|
|
|
|
if (FBar = nil) or (FBar.Images = nil) then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
x := (ARect.Left + ARect.Right - FBar.Images.Width) div 2;
|
|
|
|
y := (ARect.Top + ARect.Bottom - FBar.Images.Height) div 2;
|
2018-05-04 12:04:31 +00:00
|
|
|
FBar.Images.Draw(lbImages.Canvas, x, y, Index);
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TfrmNavBarEd.lbItemsMeasureItem(Control: TWinControl;
|
|
|
|
Index: Integer; var Height: Integer);
|
|
|
|
begin
|
2016-07-12 18:00:32 +00:00
|
|
|
Unused(Control, Index);
|
2018-05-04 12:35:39 +00:00
|
|
|
if (FBar <> nil) and (Bar.Images <> nil) then
|
2018-05-02 15:52:08 +00:00
|
|
|
Height := Bar.Images.Height + 2 * ITEMS_MARGIN;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.lbItemsDrawItem(Control: TWinControl;
|
|
|
|
Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
2018-05-02 15:52:08 +00:00
|
|
|
var
|
|
|
|
btn: TVpNavBtnItem;
|
|
|
|
lb: TListbox;
|
|
|
|
ts: TTextStyle;
|
|
|
|
x, y: Integer;
|
|
|
|
delta: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-07-12 18:00:32 +00:00
|
|
|
Unused(State);
|
2018-05-02 15:52:08 +00:00
|
|
|
lb := TListBox(Control);
|
|
|
|
lb.Canvas.FillRect(Rect);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2018-05-04 12:35:39 +00:00
|
|
|
if (FBar = nil) or (Index = -1) then
|
2018-05-02 15:52:08 +00:00
|
|
|
exit;
|
|
|
|
|
|
|
|
// Draw button image
|
|
|
|
delta := ITEMS_MARGIN;
|
|
|
|
btn := TVpNavBtnItem(lbItems.Items.Objects[Index]);
|
2018-05-04 12:35:39 +00:00
|
|
|
if (FBar.Images <> nil) and (btn <> nil) and
|
|
|
|
(btn.IconIndex > -1) and (btn.IconIndex < Bar.Images.Count) then
|
2018-05-02 15:52:08 +00:00
|
|
|
begin
|
2018-05-04 12:35:39 +00:00
|
|
|
FBar.Images.Draw(
|
2018-05-02 15:52:08 +00:00
|
|
|
lb.Canvas,
|
|
|
|
Rect.Right - Bar.Images.Width - delta,
|
|
|
|
(Rect.Top + Rect.Bottom - Bar.Images.Height) div 2,
|
|
|
|
btn.IconIndex
|
|
|
|
);
|
|
|
|
end;
|
|
|
|
|
|
|
|
// Draw text
|
|
|
|
ts := lb.Canvas.TextStyle;
|
|
|
|
ts.Alignment := taLeftJustify;
|
|
|
|
ts.Layout := tlCenter;
|
|
|
|
ts.EndEllipsis := true;
|
|
|
|
ts.Singleline := true;
|
|
|
|
ts.Wordbreak := false;
|
|
|
|
x := Rect.Left + 2;
|
|
|
|
y := (Rect.Top + Rect.Bottom - lb.Canvas.TextHeight('Tg')) div 2;
|
|
|
|
lb.Canvas.TextRect(Rect, x, y, lb.Items[Index]);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.lbItemsClick(Sender: TObject);
|
2018-05-02 15:52:08 +00:00
|
|
|
var
|
|
|
|
SelList: TPersistentSelectionList;
|
|
|
|
i: Integer;
|
|
|
|
btn: TVpNavBtnItem;
|
|
|
|
begin
|
2018-05-02 21:50:54 +00:00
|
|
|
if (FBar <> nil) and (FBar.ActiveFolder <> -1) and (lbItems.ItemIndex <> -1) then
|
2018-05-02 15:52:08 +00:00
|
|
|
begin
|
|
|
|
btn := TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]);
|
2018-05-04 12:04:31 +00:00
|
|
|
lbImages.ItemIndex := btn.IconIndex;
|
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
SelList := TPersistentSelectionList.Create;
|
|
|
|
SelList.ForceUpdate := true;
|
|
|
|
for i:=0 to lbItems.Items.Count-1 do
|
|
|
|
if lbItems.Selected[i] then
|
|
|
|
begin
|
|
|
|
SelList.Add(TPersistent(lbItems.Items.Objects[i]));
|
2018-05-04 12:35:39 +00:00
|
|
|
FBar.Folders[FBar.ActiveFolder].ItemCollection.DoOnItemSelected(I);
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
|
|
|
if SelList.Count > 0 then
|
|
|
|
SelectList(SelList);
|
|
|
|
end;
|
|
|
|
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2018-05-02 21:50:54 +00:00
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
procedure TfrmNavBarEd.btnItemUpClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
SaveItemIndex : Integer;
|
|
|
|
Item: TVpNavBtnItem;
|
|
|
|
begin
|
|
|
|
if (lbItems.ItemIndex > 0) then begin
|
|
|
|
SaveItemIndex := lbItems.ItemIndex;
|
|
|
|
Item := TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]);
|
|
|
|
if Item.Index > 0 then
|
2018-05-02 15:52:08 +00:00
|
|
|
Item.Index := Item.Index - 1;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
PopulateItemList;
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2018-05-02 21:50:54 +00:00
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
if Assigned(Designer) then begin
|
|
|
|
GlobalDesignHook.SelectOnlyThis(nil);
|
|
|
|
GlobalDesignHook.SelectOnlyThis(Item);
|
2008-02-03 12:05:55 +00:00
|
|
|
Designer.Modified;
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.btnItemDownClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
Item: TVpNavBtnItem;
|
|
|
|
begin
|
|
|
|
if (lbItems.ItemIndex > -1) then begin
|
|
|
|
Item := TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]);
|
|
|
|
|
|
|
|
if Item.Index < Pred(lbItems.Items.Count) then
|
|
|
|
Item.Index := Item.Index + 1;
|
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
PopulateItemList;
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2018-05-02 21:50:54 +00:00
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
if Assigned(Designer) then begin
|
|
|
|
GlobalDesignHook.SelectOnlyThis(nil);
|
|
|
|
GlobalDesignHook.SelectOnlyThis(Item);
|
2008-02-03 12:05:55 +00:00
|
|
|
Designer.Modified;
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.btnFolderUpClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
SaveItemIndex : Integer;
|
|
|
|
Folder: TVpNavFolder;
|
|
|
|
begin
|
|
|
|
if (lbFolders.ItemIndex > 0) then begin
|
|
|
|
SaveItemIndex := lbFolders.ItemIndex;
|
|
|
|
Folder := TVpNavFolder(lbFolders.Items.Objects[lbFolders.ItemIndex]);
|
|
|
|
|
|
|
|
if Folder.Index > 0 then
|
|
|
|
Folder.Index := Folder.Index - 1;
|
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
PopulateFolderList;
|
|
|
|
lbFolders.ItemIndex := SaveItemIndex - 1;
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2018-05-02 21:50:54 +00:00
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
if Assigned(Designer) then begin
|
|
|
|
GlobalDesignHook.SelectOnlyThis(nil);
|
|
|
|
GlobalDesignHook.SelectOnlyThis(folder);
|
2008-02-03 12:05:55 +00:00
|
|
|
Designer.Modified;
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.btnFolderDownClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
Folder: TVpNavFolder;
|
|
|
|
begin
|
|
|
|
if (lbFolders.ItemIndex > -1) then begin
|
|
|
|
Folder := TVpNavFolder(lbFolders.Items.Objects[lbFolders.ItemIndex]);
|
|
|
|
|
|
|
|
if Folder.Index < pred(lbFolders.Items.Count) then
|
|
|
|
Folder.Index := Folder.Index + 1;
|
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
PopulateFolderList;
|
|
|
|
lbFolders.ItemIndex := Folder.Index;
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2018-05-02 21:50:54 +00:00
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
if Assigned(Designer) then begin
|
|
|
|
GlobalDesignHook.SelectOnlyThis(nil);
|
|
|
|
GlobalDesignHook.SelectOnlyThis(folder);
|
2008-02-03 12:05:55 +00:00
|
|
|
Designer.Modified;
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.btnItemDeleteClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if (lbItems.ItemIndex <> -1) then begin
|
|
|
|
TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]).Free;
|
|
|
|
lbItems.ItemIndex := -1;
|
2018-05-04 12:04:31 +00:00
|
|
|
lbImages.ItemIndex := -1;
|
2008-02-03 12:05:55 +00:00
|
|
|
PopulateItemList;
|
2018-05-02 21:50:54 +00:00
|
|
|
if Assigned(Designer) then
|
2008-02-03 12:05:55 +00:00
|
|
|
Designer.Modified;
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.btnFolderDeleteClick(Sender: TObject);
|
|
|
|
begin
|
2018-05-04 12:35:39 +00:00
|
|
|
if (lbFolders.ItemIndex <> -1) and (FBar <> nil) then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
TVpNavFolder(lbFolders.Items.Objects[lbFolders.ItemIndex]).Free;
|
|
|
|
lbFolders.ItemIndex := -1;
|
2018-05-03 13:19:15 +00:00
|
|
|
FBar.Activefolder := -1;
|
2018-05-04 12:04:31 +00:00
|
|
|
lbImages.ItemIndex := -1;
|
2008-02-03 12:05:55 +00:00
|
|
|
PopulateFolderList;
|
|
|
|
PopulateItemList;
|
2018-05-02 21:50:54 +00:00
|
|
|
if Assigned(Designer) then
|
2008-02-03 12:05:55 +00:00
|
|
|
Designer.Modified;
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.btnFolderAddClick(Sender: TObject);
|
2018-05-03 22:12:30 +00:00
|
|
|
var
|
|
|
|
folder: TVpNavFolder;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2018-05-04 12:35:39 +00:00
|
|
|
if FBar = nil then
|
|
|
|
exit;
|
2018-05-03 22:12:30 +00:00
|
|
|
folder := TVpNavFolder(FBar.FolderCollection.Add);
|
|
|
|
GlobalDesignHook.PersistentAdded(folder, true);
|
|
|
|
lbFoldersClick(self);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.btnItemAddClick(Sender: TObject);
|
2018-05-03 22:12:30 +00:00
|
|
|
var
|
|
|
|
folder: TVpNavFolder;
|
|
|
|
item: TVpNavBtnItem;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if (lbFolders.ItemIndex <> -1) then begin
|
2018-05-03 22:12:30 +00:00
|
|
|
folder := TVpNavFolder(lbFolders.Items.Objects[lbFolders.ItemIndex]);
|
|
|
|
item := TVpNavBtnItem(folder.ItemCollection.Add);
|
|
|
|
GlobalDesignHook.PersistentAdded(item, true);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2018-05-03 13:19:15 +00:00
|
|
|
UpdateBtnStates;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
procedure TfrmNavBarEd.SelectionChanged(AOrderChanged: Boolean = false);
|
|
|
|
var
|
|
|
|
SelList: TPersistentSelectionList;
|
|
|
|
begin
|
|
|
|
{
|
|
|
|
if (FUpdateSelectionCount>0) or (GlobalDesignHook=nil) then
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
GlobalDesignHook.RemoveHandlerSetSelection(OnSetSelection);
|
|
|
|
try
|
|
|
|
SelList := TPersistentSelectionList.Create;
|
|
|
|
SelList.ForceUpdate := AOrderChanged;
|
|
|
|
try
|
|
|
|
OnGetSelection(SelList);
|
|
|
|
FDesigner.PropertyEditorHook.SetSelection(SelList) ;
|
|
|
|
finally
|
|
|
|
SelList.Free;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
GlobalDesignHook.AddHandlerSetSelection(OnSetSelection);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
procedure TfrmNavBarEd.Selectlist(SelList: TPersistentSelectionList);
|
|
|
|
begin
|
2018-05-04 12:35:39 +00:00
|
|
|
if (GlobalDesignHook <> nil) and (FBar <> nil) then
|
2018-05-02 15:52:08 +00:00
|
|
|
begin
|
|
|
|
GlobalDesignHook.SetSelection(SelList);
|
2018-05-04 12:35:39 +00:00
|
|
|
GlobalDesignHook.LookupRoot := GetLookupRootForComponent(FBar);
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
|
|
|
SelList.Free;
|
|
|
|
end;
|
2018-05-02 21:50:54 +00:00
|
|
|
|
2018-05-03 13:19:15 +00:00
|
|
|
procedure TfrmNavBarEd.UpdateBtnStates;
|
2018-05-02 21:50:54 +00:00
|
|
|
var
|
|
|
|
canChangeFolders: Boolean;
|
|
|
|
canChangeItems: Boolean;
|
|
|
|
begin
|
|
|
|
canChangeFolders := (FBar <> nil);
|
|
|
|
canChangeItems := (FBar <> nil) and (FBar.ActiveFolder <> -1) and
|
|
|
|
not FBar.Folders[FBar.ActiveFolder].ItemCollection.ReadOnly;
|
|
|
|
|
|
|
|
btnFolderAdd.Enabled := canChangeFolders;
|
|
|
|
btnFolderDelete.Enabled := canChangeFolders and (lbFolders.ItemIndex > -1);
|
|
|
|
btnFolderUp.Enabled := canChangeFolders and (lbFolders.ItemIndex > 0);
|
|
|
|
btnFolderDown.Enabled := canChangeFolders and (lbFolders.ItemIndex < lbFolders.Items.Count-1);
|
|
|
|
|
|
|
|
btnItemAdd.Enabled := canChangeItems;
|
|
|
|
btnItemDelete.Enabled := canChangeItems and (lbItems.ItemIndex > -1);
|
|
|
|
btnItemUp.Enabled := canChangeItems and (lbItems.ItemIndex > 0);
|
|
|
|
btnItemDown.Enabled := canChangeItems and (lbItems.ItemIndex < lbItems.Items.Count-1);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2018-05-02 21:50:54 +00:00
|
|
|
|
2018-05-04 12:35:39 +00:00
|
|
|
procedure TfrmNavBarEd.Notification(AComponent: TComponent; Operation: TOperation);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
if Operation = opRemove then begin
|
|
|
|
if AComponent = FBar then FBar := nil;
|
|
|
|
end;
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
end.
|
|
|
|
|