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-04 14:26:36 +00:00
|
|
|
LCLProc, LCLType, LCLIntf, LCLVersion,
|
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-05 23:21:08 +00:00
|
|
|
lblImages: TLabel;
|
2018-05-04 12:04:31 +00:00
|
|
|
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;
|
2018-05-05 23:21:08 +00:00
|
|
|
pnlItemBtns: TPanel;
|
2008-02-03 12:05:55 +00:00
|
|
|
btnItemAdd: TSpeedButton;
|
|
|
|
btnItemDelete: TSpeedButton;
|
|
|
|
btnItemUp: TSpeedButton;
|
|
|
|
btnItemDown: TSpeedButton;
|
2018-05-05 23:21:08 +00:00
|
|
|
lblItems: TLabel;
|
|
|
|
pnlFolderBtns: TPanel;
|
2008-02-03 12:05:55 +00:00
|
|
|
btnFolderAdd: TSpeedButton;
|
|
|
|
btnFolderDelete: TSpeedButton;
|
|
|
|
btnFolderUp: TSpeedButton;
|
|
|
|
btnFolderDown: TSpeedButton;
|
2018-05-05 23:21:08 +00:00
|
|
|
lblFolders: TLabel;
|
2018-05-04 14:26:36 +00:00
|
|
|
btnUseImage: TSpeedButton;
|
2018-05-05 23:21:08 +00:00
|
|
|
Splitter1: TSplitter;
|
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);
|
2018-05-04 14:26:36 +00:00
|
|
|
procedure btnUseImageClick(Sender: TObject);
|
2018-05-02 15:52:08 +00:00
|
|
|
|
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 FormShow(Sender: TObject);
|
|
|
|
|
|
|
|
procedure lbFoldersClick(Sender: TObject);
|
2018-05-04 12:04:31 +00:00
|
|
|
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);
|
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;
|
2018-12-05 20:22:46 +00:00
|
|
|
procedure Modified;
|
2018-05-03 09:45:11 +00:00
|
|
|
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
|
2018-05-04 14:26:36 +00:00
|
|
|
{$IF LCL_FullVersion >= 1080000}
|
|
|
|
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
|
|
|
const AXProportion, AYProportion: Double); override;
|
|
|
|
{$ENDIF}
|
2018-05-04 12:35:39 +00:00
|
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
public
|
|
|
|
{ Public declarations }
|
2018-05-04 13:16:33 +00:00
|
|
|
constructor Create(AOwner: TComponent; ADesigner: TComponentEditorDesigner;
|
|
|
|
ABar: TVpNavBar); reintroduce;
|
2018-05-02 21:50:54 +00:00
|
|
|
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 13:16:33 +00:00
|
|
|
PropEditUtils, IDEWindowIntf, StrUtils, ImgList,
|
2019-01-15 22:14:01 +00:00
|
|
|
{%H-}VpConst, VpMisc;
|
2016-07-12 18:00:32 +00:00
|
|
|
|
2018-05-02 15:52:08 +00:00
|
|
|
const
|
|
|
|
ITEMS_MARGIN = 2;
|
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-04 14:26:36 +00:00
|
|
|
var
|
|
|
|
vITEMS_MARGIN: Integer = ITEMS_MARGIN;
|
|
|
|
vIMG_MARGIN_HOR: Integer = IMG_MARGIN_HOR;
|
|
|
|
vIMG_MARGIN_VERT: Integer = IMG_MARGIN_VERT;
|
|
|
|
|
2018-05-04 13:01:51 +00:00
|
|
|
var
|
|
|
|
EditorForms : TList = nil;
|
|
|
|
|
|
|
|
procedure InitFormsList;
|
|
|
|
begin
|
|
|
|
EditorForms := TList.Create;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure ReleaseFormsList;
|
|
|
|
begin
|
|
|
|
FreeAndNil(EditorForms);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure AddNavBarEditor(Editor: TfrmNavBarEd);
|
|
|
|
begin
|
|
|
|
if Assigned(EditorForms) and (EditorForms.IndexOf(Editor) < 0) then
|
|
|
|
EditorForms.Add(Editor);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function FindNavBarEditor(ABar: TVpNavBar): TfrmNavBarEd;
|
|
|
|
var
|
|
|
|
i : Integer;
|
|
|
|
begin
|
|
|
|
if ABar <> nil then
|
|
|
|
for i:=0 to EditorForms.Count-1 do begin
|
|
|
|
if TfrmNavBarEd(EditorForms[i]).Bar = ABar then
|
|
|
|
Exit(TfrmNavBarEd(EditorForms[i]));
|
|
|
|
end;
|
|
|
|
Result := nil
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure ReleaseNavBarEditor(Editor: TfrmNavBarEd);
|
|
|
|
var
|
|
|
|
i : Integer;
|
|
|
|
begin
|
|
|
|
if not Assigned(EditorForms) then Exit;
|
|
|
|
i := EditorForms.IndexOf(Editor);
|
|
|
|
if i >= 0 then EditorForms.Delete(i);
|
|
|
|
end;
|
|
|
|
|
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;
|
2018-05-04 13:01:51 +00:00
|
|
|
editor := FindNavBarEditor(bar);
|
2018-05-03 09:45:11 +00:00
|
|
|
if editor = nil then begin
|
2018-05-04 13:16:33 +00:00
|
|
|
editor := TfrmNavBarEd.Create(Application, Designer, bar);
|
2018-05-03 09:45:11 +00:00
|
|
|
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-04 13:16:33 +00:00
|
|
|
constructor TfrmNavBarEd.Create(AOwner: TComponent;
|
|
|
|
ADesigner: TComponentEditorDesigner; ABar: TVpNavBar);
|
2018-05-02 21:50:54 +00:00
|
|
|
begin
|
|
|
|
inherited Create(AOwner);
|
2018-05-04 13:01:51 +00:00
|
|
|
Position := poScreenCenter;
|
2018-05-02 21:50:54 +00:00
|
|
|
|
|
|
|
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-04 13:01:51 +00:00
|
|
|
|
|
|
|
AddNavBarEditor(self);
|
2018-05-02 21:50:54 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TfrmNavBarEd.Destroy;
|
|
|
|
begin
|
2018-05-04 13:01:51 +00:00
|
|
|
ReleaseNavBarEditor(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-04 14:26:36 +00:00
|
|
|
{$IF LCL_FullVersion >= 1080000}
|
|
|
|
procedure TFrmNavBarEd.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
|
|
|
const AXProportion, AYProportion: Double);
|
|
|
|
begin
|
|
|
|
inherited DoAutoAdjustLayout(AMode, AXProportion, AYProportion);
|
|
|
|
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
|
|
|
begin
|
|
|
|
DisableAutoSizing;
|
|
|
|
try
|
|
|
|
vITEMS_MARGIN := round(ITEMS_MARGIN * AXProportion);
|
|
|
|
vIMG_MARGIN_HOR := round(IMG_MARGIN_HOR * AXProportion);
|
|
|
|
vIMG_MARGIN_VERT := round(IMG_MARGIN_VERT * AYProportion);
|
|
|
|
finally
|
|
|
|
EnableAutoSizing;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{$ENDIF}
|
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
procedure TfrmNavBarEd.FormClose(Sender: TObject;
|
|
|
|
var Action: TCloseAction);
|
|
|
|
begin
|
2018-05-04 13:16:33 +00:00
|
|
|
IDEDialogLayoutList.SaveLayout(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
|
2018-05-04 13:16:33 +00:00
|
|
|
IDEDialogLayoutList.ApplyLayout(Self);
|
2018-05-04 14:26:36 +00:00
|
|
|
|
|
|
|
{$IFDEF NEW_ICONS}
|
|
|
|
LoadGlyphFromRCDATA(btnUseImage.Glyph, 'VpLArrow', 16, 24, 32);
|
|
|
|
{$ELSE}
|
|
|
|
vtnUseImage.Glyph.LoadFromResourceName(HINSTANCE, 'VPLEFTARROW');
|
|
|
|
{$ENDIF}
|
|
|
|
|
|
|
|
{$IF VP_LCL_SCALING = 0}
|
|
|
|
btnUseImage.Width := ScaleX(btnUseImage.Width, DesignTimeDPI);
|
|
|
|
btnUseImage.Height := ScaleY(btnUseImage.Width, DesignTimeDPI);
|
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
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);
|
2018-05-06 08:47:18 +00:00
|
|
|
var
|
|
|
|
delta: Integer;
|
2018-05-15 20:09:59 +00:00
|
|
|
h: Integer = 0;
|
2018-05-02 15:52:08 +00:00
|
|
|
begin
|
2018-05-04 12:04:31 +00:00
|
|
|
PopulateImagesList;
|
2018-05-06 08:47:18 +00:00
|
|
|
delta := lbFolders.Left;
|
|
|
|
pnlFolders.Constraints.MinWidth := btnFolderDown.Left + btnFolderDown.Width + delta;
|
|
|
|
pnlItems.Constraints.MinWidth := btnItemDown.Left + btnItemDown.Width + lbImages.Width + btnUseImage.Width + delta;
|
|
|
|
Constraints.MinWidth := pnlFolders.Constraints.MinWidth + pnlItems.Constraints.MinWidth;
|
|
|
|
lbItemsMeasureItem(nil, 0, h);
|
|
|
|
Constraints.MinHeight := lbItems.Top + h + pnlItemBtns.Height + 3*delta;
|
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-12-05 20:22:46 +00:00
|
|
|
{ Is called when the selection has been changed within the Component Editor
|
|
|
|
in order pass the new selection to the OI designer }
|
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;
|
2018-12-05 20:22:46 +00:00
|
|
|
selList: TPersistentSelectionList;
|
2018-05-02 15:52:08 +00:00
|
|
|
begin
|
2018-12-05 20:22:46 +00:00
|
|
|
if not Assigned(APersistent) or (FBar = nil) or (GlobalDesignHook = nil) then
|
2018-05-02 15:52:08 +00:00
|
|
|
exit;
|
|
|
|
|
|
|
|
if (APersistent is TVpNavFolder) then
|
|
|
|
begin
|
|
|
|
PopulateFolderList;
|
|
|
|
if Select then begin
|
|
|
|
i := FindFolderIndex(APersistent);
|
|
|
|
lbFolders.ItemIndex := i;
|
2018-12-05 20:22:46 +00:00
|
|
|
|
|
|
|
selList := TPersistentSelectionList.Create;
|
|
|
|
try
|
|
|
|
selList.ForceUpdate := true;
|
|
|
|
for i := 0 to pred(lbFolders.Items.Count) do
|
|
|
|
if lbFolders.Selected[i] then begin
|
|
|
|
SelList.Add(TPersistent(lbFolders.Items.Objects[i]));
|
|
|
|
FBar.FolderCollection.DoOnItemSelected(i);
|
|
|
|
end;
|
|
|
|
|
|
|
|
if (SelList.Count > 0) then begin
|
|
|
|
GlobalDesignHook.SetSelection(SelList);
|
|
|
|
GlobalDesignHook.LookupRoot := GetLookupRootForComponent(FBar);
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
selList.Free;
|
|
|
|
end;
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
|
|
|
end else
|
|
|
|
if (APersistent is TVpNavBtnItem) then
|
|
|
|
begin
|
|
|
|
PopulateItemList;
|
|
|
|
if Select then begin
|
|
|
|
i := FindBtnIndex(APersistent);
|
|
|
|
lbItems.ItemIndex := i;
|
2018-12-05 20:22:46 +00:00
|
|
|
|
|
|
|
selList := TPersistentSelectionList.Create;
|
|
|
|
try
|
|
|
|
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]));
|
|
|
|
FBar.Folders[FBar.ActiveFolder].ItemCollection.DoOnItemSelected(I);
|
|
|
|
end;
|
|
|
|
if selList.Count > 0 then begin
|
|
|
|
GlobalDesignHook.SetSelection(selList);
|
|
|
|
GlobalDesignHook.LookupRoot := GetLookupRootForComponent(FBar);
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
selList.Free;
|
|
|
|
end;
|
2018-05-02 15:52:08 +00:00
|
|
|
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);
|
2018-12-05 20:22:46 +00:00
|
|
|
if i <> -1 then begin
|
|
|
|
lbFolders.Items.Delete(i);
|
|
|
|
lbItems.Clear;
|
|
|
|
end;
|
2018-05-02 15:52:08 +00:00
|
|
|
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;
|
2018-12-05 20:22:46 +00:00
|
|
|
i, idx: Integer;
|
2018-05-04 09:17:09 +00:00
|
|
|
begin
|
2018-12-05 20:22:46 +00:00
|
|
|
if (FBar = nil) or (GlobalDesignHook = nil) then
|
2018-05-04 12:35:39 +00:00
|
|
|
exit;
|
|
|
|
|
2018-05-04 09:17:09 +00:00
|
|
|
selections := TPersistentSelectionList.Create;
|
|
|
|
try
|
|
|
|
GlobalDesignHook.GetSelection(selections);
|
|
|
|
for i:=0 to selections.Count-1 do begin
|
2018-12-05 20:22:46 +00:00
|
|
|
if selections[i] is TVpNavFolder then begin
|
|
|
|
idx := FindFolderIndex(TVpNavFolder(selections[i]));
|
|
|
|
lbFolders.Items[idx] := GetFolderDisplayName(TVpNavFolder(selections[i]))
|
|
|
|
end else
|
|
|
|
if selections[i] is TVpNavBtnItem then begin
|
|
|
|
idx := FindBtnIndex(TVpNavBtnItem(selections[i]));
|
|
|
|
lbItems.Items[idx] := GetItemDisplayName(TVpNavBtnItem(selections[i]))
|
|
|
|
end else
|
|
|
|
if (selections[i] is TCustomImageList) and (TCustomImageList(selections[i]) = FBar.Images) then
|
2018-05-04 12:04:31 +00:00
|
|
|
PopulateImagesList;
|
2018-05-04 09:17:09 +00:00
|
|
|
end;
|
|
|
|
finally
|
|
|
|
selections.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-12-05 20:22:46 +00:00
|
|
|
{ Is called when a new selection has been made in the object tree of the OI.
|
|
|
|
The controls in the component editor must be updated to the new selection. }
|
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]);
|
2018-12-05 20:22:46 +00:00
|
|
|
if j <> -1 then begin
|
|
|
|
lbFolders.Selected[j] := true;
|
|
|
|
PopulateItemList;
|
|
|
|
FBar.ActiveFolder := lbFolders.ItemIndex;
|
|
|
|
lbImages.ItemIndex := -1;
|
|
|
|
end;
|
2018-05-02 15:52:08 +00:00
|
|
|
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('');
|
|
|
|
|
2018-05-04 14:26:36 +00:00
|
|
|
lbImages.ItemHeight := FBar.Images.Width + 2*vIMG_MARGIN_HOR;
|
|
|
|
lbImages.ClientWidth := FBar.Images.Width + 2*vIMG_MARGIN_VERT + GetScrollbarWidth;
|
2018-05-04 12:04:31 +00:00
|
|
|
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
|
|
|
begin
|
|
|
|
if FBar <> nil then
|
|
|
|
FBar.RemoveFreeNotification(self);
|
|
|
|
|
|
|
|
FBar := ABar;
|
|
|
|
FDesigner := ADesigner;
|
|
|
|
|
2018-05-15 20:44:00 +00:00
|
|
|
if FBar <> nil then begin
|
2018-05-02 15:52:08 +00:00
|
|
|
FBar.FreeNotification(self);
|
2018-05-15 20:44:00 +00:00
|
|
|
if FBar.Images = nil then
|
|
|
|
lbItems.Style := lbStandard
|
|
|
|
else begin
|
|
|
|
lbItems.ItemHeight := FBar.Images.Height + 2 * vITEMS_MARGIN;
|
|
|
|
lbItems.Style := lbOwnerDrawFixed;
|
|
|
|
end;
|
|
|
|
end;
|
2018-05-02 15:52:08 +00:00
|
|
|
|
|
|
|
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-12-05 20:22:46 +00:00
|
|
|
if (FBar = nil) or (GlobalDesignHook = nil) then
|
2018-05-04 12:35:39 +00:00
|
|
|
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;
|
2018-12-05 20:22:46 +00:00
|
|
|
try
|
|
|
|
SelList.ForceUpdate := true;
|
2018-05-02 21:50:54 +00:00
|
|
|
|
2018-12-05 20:22:46 +00:00
|
|
|
for i := 0 to pred(lbFolders.Items.Count) do
|
|
|
|
if lbFolders.Selected[i] then begin
|
|
|
|
SelList.Add(TPersistent(lbFolders.Items.Objects[i]));
|
|
|
|
FBar.FolderCollection.DoOnItemSelected(i);
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2018-12-05 20:22:46 +00:00
|
|
|
if SelList.Count > 0 then begin
|
|
|
|
GlobalDesignHook.SetSelection(SelList);
|
|
|
|
GlobalDesignHook.LookupRoot := GetLookupRootForComponent(FBar);
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
SelList.Free;
|
|
|
|
end;
|
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.lbImagesDrawItem(Control: TWinControl; Index: Integer;
|
|
|
|
ARect: TRect; State: TOwnerDrawState);
|
|
|
|
var
|
|
|
|
x, y: Integer;
|
|
|
|
begin
|
2018-05-05 16:09:31 +00:00
|
|
|
Unused(Control);
|
|
|
|
|
2018-05-04 12:04:31 +00:00
|
|
|
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-15 20:09:59 +00:00
|
|
|
Height := Bar.Images.Height + 2 * vITEMS_MARGIN
|
|
|
|
else
|
|
|
|
Height := lbItems.ItemHeight;
|
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
|
2018-05-04 14:26:36 +00:00
|
|
|
delta := vITEMS_MARGIN;
|
2018-05-02 15:52:08 +00:00
|
|
|
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
|
|
|
|
);
|
2018-05-15 20:44:00 +00:00
|
|
|
dec(Rect.Right, Bar.Images.Width + 2*delta);
|
2018-05-02 15:52:08 +00:00
|
|
|
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;
|
2018-05-05 16:09:31 +00:00
|
|
|
lb.Canvas.TextRect(Rect, x, y, lb.Items[Index], ts);
|
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;
|
2018-12-05 20:22:46 +00:00
|
|
|
try
|
|
|
|
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]));
|
|
|
|
FBar.Folders[FBar.ActiveFolder].ItemCollection.DoOnItemSelected(I);
|
|
|
|
end;
|
|
|
|
if SelList.Count > 0 then begin
|
|
|
|
GlobalDesignHook.SetSelection(SelList);
|
|
|
|
GlobalDesignHook.LookupRoot := GetLookupRootForComponent(FBar);
|
2018-05-02 15:52:08 +00:00
|
|
|
end;
|
2018-12-05 20:22:46 +00:00
|
|
|
finally
|
|
|
|
SelList.Free;
|
|
|
|
end;
|
2018-05-02 15:52:08 +00:00
|
|
|
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
|
2018-05-05 16:09:31 +00:00
|
|
|
//SaveItemIndex : Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
Item: TVpNavBtnItem;
|
|
|
|
begin
|
|
|
|
if (lbItems.ItemIndex > 0) then begin
|
2018-05-05 16:09:31 +00:00
|
|
|
//SaveItemIndex := lbItems.ItemIndex;
|
2008-02-03 12:05:55 +00:00
|
|
|
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-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;
|
2018-05-04 12:40:53 +00:00
|
|
|
|
|
|
|
UpdateBtnStates;
|
2008-02-03 12:05:55 +00:00
|
|
|
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-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;
|
2018-05-04 12:40:53 +00:00
|
|
|
|
|
|
|
UpdateBtnStates;
|
2008-02-03 12:05:55 +00:00
|
|
|
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-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;
|
2018-12-05 20:22:46 +00:00
|
|
|
Modified;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2018-05-04 12:40:53 +00:00
|
|
|
|
|
|
|
UpdateBtnStates;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.btnFolderDownClick(Sender: TObject);
|
|
|
|
var
|
2018-12-05 20:22:46 +00:00
|
|
|
folder: TVpNavFolder;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if (lbFolders.ItemIndex > -1) then begin
|
2018-12-05 20:22:46 +00:00
|
|
|
folder := TVpNavFolder(lbFolders.Items.Objects[lbFolders.ItemIndex]);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2018-12-05 20:22:46 +00:00
|
|
|
if folder.Index < pred(lbFolders.Items.Count) then
|
|
|
|
folder.Index := folder.Index + 1;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
PopulateFolderList;
|
2018-12-05 20:22:46 +00:00
|
|
|
lbFolders.ItemIndex := folder.Index;
|
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;
|
2018-12-05 20:22:46 +00:00
|
|
|
Modified;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2018-05-04 12:40:53 +00:00
|
|
|
|
|
|
|
UpdateBtnStates;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.btnFolderDeleteClick(Sender: TObject);
|
2018-12-05 20:22:46 +00:00
|
|
|
var
|
|
|
|
folder: TVpNavFolder;
|
|
|
|
s: String;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2018-05-04 12:35:39 +00:00
|
|
|
if (lbFolders.ItemIndex <> -1) and (FBar <> nil) then begin
|
2018-12-05 20:22:46 +00:00
|
|
|
|
|
|
|
folder := TVpNavFolder(lbFolders.Items.Objects[lbFolders.ItemIndex]);
|
|
|
|
s := folder.Caption;
|
|
|
|
if MessageDlg(Format('Do you really want to delete folder "%s"?', [s]),
|
|
|
|
mtConfirmation, [mbYes, mbNo], 0) <> mrYes
|
|
|
|
then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
FDesigner.DeleteSelection;
|
2008-02-03 12:05:55 +00:00
|
|
|
lbFolders.ItemIndex := -1;
|
2018-12-05 20:22:46 +00:00
|
|
|
FBar.ActiveFolder := -1;
|
2018-05-04 12:04:31 +00:00
|
|
|
lbImages.ItemIndex := -1;
|
2008-02-03 12:05:55 +00:00
|
|
|
PopulateItemList;
|
|
|
|
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-12-05 20:22:46 +00:00
|
|
|
if (FBar = nil) or (GlobalDesignHook = nil) then
|
2018-05-04 12:35:39 +00:00
|
|
|
exit;
|
2018-05-03 22:12:30 +00:00
|
|
|
folder := TVpNavFolder(FBar.FolderCollection.Add);
|
|
|
|
GlobalDesignHook.PersistentAdded(folder, true);
|
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
|
2018-12-05 20:22:46 +00:00
|
|
|
if (lbFolders.ItemIndex = -1) or (GlobalDesignHook = nil) then
|
|
|
|
exit;
|
|
|
|
folder := TVpNavFolder(lbFolders.Items.Objects[lbFolders.ItemIndex]);
|
|
|
|
item := TVpNavBtnItem(folder.ItemCollection.Add);
|
|
|
|
GlobalDesignHook.PersistentAdded(item, true);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmNavBarEd.btnItemDeleteClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
btn: TVpNavBtnItem;
|
|
|
|
s: String;
|
|
|
|
begin
|
|
|
|
if (lbItems.ItemIndex <> -1) then begin
|
|
|
|
btn := TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]);
|
|
|
|
s := btn.Caption;
|
|
|
|
if MessageDlg(Format('Do you really want to delete item "%s"?', [s]),
|
|
|
|
mtConfirmation, [mbYes, mbNo], 0) <> mrYes
|
|
|
|
then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
FDesigner.DeleteSelection;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-05-04 14:26:36 +00:00
|
|
|
procedure TfrmNavBarEd.btnUseImageClick(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 = lbImages.itemIndex then
|
|
|
|
exit;
|
|
|
|
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;
|
|
|
|
|
2018-12-05 20:22:46 +00:00
|
|
|
procedure TfrmNavBarEd.Modified;
|
|
|
|
begin
|
|
|
|
FDesigner.PropertyEditorHook.RefreshPropertyValues;
|
|
|
|
FDesigner.Modified;
|
|
|
|
|
|
|
|
if GlobalDesignHook <> nil then
|
|
|
|
GlobalDesignHook.Modified(self);
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
2018-05-02 21:50:54 +00:00
|
|
|
procedure TfrmNavBarEd.SelectionChanged(AOrderChanged: Boolean = false);
|
|
|
|
var
|
|
|
|
SelList: TPersistentSelectionList;
|
|
|
|
begin
|
|
|
|
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-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
|
|
|
|
2018-05-04 14:26:36 +00:00
|
|
|
|
2018-05-04 13:01:51 +00:00
|
|
|
initialization
|
|
|
|
InitFormsList;
|
|
|
|
|
|
|
|
finalization
|
|
|
|
ReleaseFormsList;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
end.
|
|
|
|
|