You've already forked lazarus-ccr
tvplanit: use a Listbox in VpNavBar component editor for image selection.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6380 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -15,81 +15,16 @@ object frmNavBarEd: TfrmNavBarEd
|
|||||||
OnShow = FormShow
|
OnShow = FormShow
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '1.9.0.0'
|
LCLVersion = '1.9.0.0'
|
||||||
object pnlImages: TPanel
|
|
||||||
Left = 0
|
|
||||||
Height = 85
|
|
||||||
Top = 279
|
|
||||||
Width = 543
|
|
||||||
Align = alBottom
|
|
||||||
AutoSize = True
|
|
||||||
BevelOuter = bvNone
|
|
||||||
ClientHeight = 85
|
|
||||||
ClientWidth = 543
|
|
||||||
TabOrder = 0
|
|
||||||
object Panel8: TPanel
|
|
||||||
Left = 0
|
|
||||||
Height = 27
|
|
||||||
Top = 0
|
|
||||||
Width = 543
|
|
||||||
Align = alTop
|
|
||||||
BevelOuter = bvNone
|
|
||||||
ClientHeight = 27
|
|
||||||
ClientWidth = 543
|
|
||||||
TabOrder = 0
|
|
||||||
object Label3: TLabel
|
|
||||||
AnchorSideLeft.Control = Panel8
|
|
||||||
AnchorSideTop.Control = Panel8
|
|
||||||
Left = 4
|
|
||||||
Height = 15
|
|
||||||
Top = 8
|
|
||||||
Width = 89
|
|
||||||
BorderSpacing.Left = 4
|
|
||||||
BorderSpacing.Top = 8
|
|
||||||
Caption = 'Available Images'
|
|
||||||
ParentColor = False
|
|
||||||
end
|
|
||||||
end
|
|
||||||
object sbImages: TScrollBox
|
|
||||||
Left = 4
|
|
||||||
Height = 54
|
|
||||||
Top = 27
|
|
||||||
Width = 535
|
|
||||||
HorzScrollBar.Page = 56
|
|
||||||
HorzScrollBar.Tracking = True
|
|
||||||
VertScrollBar.Page = 50
|
|
||||||
Align = alClient
|
|
||||||
AutoSize = True
|
|
||||||
BorderSpacing.Left = 4
|
|
||||||
BorderSpacing.Right = 4
|
|
||||||
BorderSpacing.Bottom = 4
|
|
||||||
ClientHeight = 50
|
|
||||||
ClientWidth = 531
|
|
||||||
Color = clWindow
|
|
||||||
ParentColor = False
|
|
||||||
TabOrder = 1
|
|
||||||
OnResize = sbImagesResize
|
|
||||||
object pnlImageView: TPanel
|
|
||||||
Left = 0
|
|
||||||
Height = 50
|
|
||||||
Top = 0
|
|
||||||
Width = 56
|
|
||||||
Constraints.MinHeight = 40
|
|
||||||
TabOrder = 0
|
|
||||||
OnClick = pnlImageViewClick
|
|
||||||
OnPaint = pnlImageViewPaint
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
object pnlFoldersAndItems: TPanel
|
object pnlFoldersAndItems: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 279
|
Height = 364
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 543
|
Width = 543
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 279
|
ClientHeight = 364
|
||||||
ClientWidth = 543
|
ClientWidth = 543
|
||||||
TabOrder = 1
|
TabOrder = 0
|
||||||
object pnlFolders: TPanel
|
object pnlFolders: TPanel
|
||||||
AnchorSideLeft.Control = pnlFoldersAndItems
|
AnchorSideLeft.Control = pnlFoldersAndItems
|
||||||
AnchorSideTop.Control = pnlFoldersAndItems
|
AnchorSideTop.Control = pnlFoldersAndItems
|
||||||
@ -97,20 +32,27 @@ object frmNavBarEd: TfrmNavBarEd
|
|||||||
AnchorSideBottom.Control = pnlFoldersAndItems
|
AnchorSideBottom.Control = pnlFoldersAndItems
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 279
|
Height = 364
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 269
|
Width = 235
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
|
BorderSpacing.Right = 4
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 279
|
ClientHeight = 364
|
||||||
ClientWidth = 269
|
ClientWidth = 235
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object lbFolders: TListBox
|
object lbFolders: TListBox
|
||||||
|
AnchorSideLeft.Control = pnlFolders
|
||||||
|
AnchorSideTop.Control = Panel6
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = pnlFolders
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
AnchorSideBottom.Control = Panel5
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 227
|
Height = 308
|
||||||
Top = 23
|
Top = 23
|
||||||
Width = 265
|
Width = 231
|
||||||
Align = alClient
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
BorderSpacing.Left = 4
|
BorderSpacing.Left = 4
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
OnClick = lbFoldersClick
|
OnClick = lbFoldersClick
|
||||||
@ -120,11 +62,11 @@ object frmNavBarEd: TfrmNavBarEd
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 269
|
Width = 235
|
||||||
Align = alTop
|
Align = alTop
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 23
|
ClientHeight = 23
|
||||||
ClientWidth = 269
|
ClientWidth = 235
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
Left = 4
|
Left = 4
|
||||||
@ -139,15 +81,16 @@ object frmNavBarEd: TfrmNavBarEd
|
|||||||
object Panel5: TPanel
|
object Panel5: TPanel
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 254
|
Top = 335
|
||||||
Width = 265
|
Width = 231
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 4
|
BorderSpacing.Left = 4
|
||||||
BorderSpacing.Top = 4
|
BorderSpacing.Top = 4
|
||||||
|
BorderSpacing.Bottom = 4
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 25
|
ClientHeight = 25
|
||||||
ClientWidth = 265
|
ClientWidth = 231
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
object btnFolderAdd: TSpeedButton
|
object btnFolderAdd: TSpeedButton
|
||||||
AnchorSideLeft.Control = Panel5
|
AnchorSideLeft.Control = Panel5
|
||||||
@ -253,28 +196,34 @@ object frmNavBarEd: TfrmNavBarEd
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
object pnlItems: TPanel
|
object pnlItems: TPanel
|
||||||
AnchorSideLeft.Control = Bevel1
|
AnchorSideLeft.Control = pnlFolders
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = pnlFoldersAndItems
|
AnchorSideTop.Control = pnlFoldersAndItems
|
||||||
AnchorSideRight.Control = pnlFoldersAndItems
|
AnchorSideRight.Control = pnlFoldersAndItems
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
AnchorSideBottom.Control = pnlFoldersAndItems
|
AnchorSideBottom.Control = pnlFoldersAndItems
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 273
|
Left = 239
|
||||||
Height = 279
|
Height = 364
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 270
|
Width = 300
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
|
BorderSpacing.Right = 4
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 279
|
ClientHeight = 364
|
||||||
ClientWidth = 270
|
ClientWidth = 300
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
object lbItems: TListBox
|
object lbItems: TListBox
|
||||||
|
AnchorSideLeft.Control = pnlItems
|
||||||
|
AnchorSideTop.Control = Panel4
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = lbImages
|
||||||
|
AnchorSideBottom.Control = Panel1
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 227
|
Height = 307
|
||||||
Top = 23
|
Top = 24
|
||||||
Width = 266
|
Width = 248
|
||||||
Align = alClient
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
BorderSpacing.Right = 4
|
BorderSpacing.Right = 4
|
||||||
ItemHeight = 13
|
ItemHeight = 13
|
||||||
OnClick = lbItemsClick
|
OnClick = lbItemsClick
|
||||||
@ -286,15 +235,16 @@ object frmNavBarEd: TfrmNavBarEd
|
|||||||
object Panel1: TPanel
|
object Panel1: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 254
|
Top = 335
|
||||||
Width = 266
|
Width = 296
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Top = 4
|
BorderSpacing.Top = 4
|
||||||
BorderSpacing.Right = 4
|
BorderSpacing.Right = 4
|
||||||
|
BorderSpacing.Bottom = 4
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 25
|
ClientHeight = 25
|
||||||
ClientWidth = 266
|
ClientWidth = 296
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
object btnItemAdd: TSpeedButton
|
object btnItemAdd: TSpeedButton
|
||||||
AnchorSideLeft.Control = Panel1
|
AnchorSideLeft.Control = Panel1
|
||||||
@ -401,13 +351,13 @@ object frmNavBarEd: TfrmNavBarEd
|
|||||||
end
|
end
|
||||||
object Panel4: TPanel
|
object Panel4: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 23
|
Height = 24
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 270
|
Width = 300
|
||||||
Align = alTop
|
Align = alTop
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 23
|
ClientHeight = 24
|
||||||
ClientWidth = 270
|
ClientWidth = 300
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object Label2: TLabel
|
object Label2: TLabel
|
||||||
Left = 0
|
Left = 0
|
||||||
@ -418,15 +368,44 @@ object frmNavBarEd: TfrmNavBarEd
|
|||||||
FocusControl = lbItems
|
FocusControl = lbItems
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
|
object Label4: TLabel
|
||||||
|
AnchorSideTop.Control = Label2
|
||||||
|
AnchorSideRight.Control = Panel4
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
Left = 211
|
||||||
|
Height = 15
|
||||||
|
Top = 4
|
||||||
|
Width = 89
|
||||||
|
Anchors = [akTop, akRight]
|
||||||
|
Caption = 'Available i&mages'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object lbImages: TListBox
|
||||||
|
AnchorSideTop.Control = lbItems
|
||||||
|
AnchorSideRight.Control = pnlItems
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
AnchorSideBottom.Control = lbItems
|
||||||
|
AnchorSideBottom.Side = asrBottom
|
||||||
|
Left = 252
|
||||||
|
Height = 307
|
||||||
|
Top = 24
|
||||||
|
Width = 48
|
||||||
|
Anchors = [akTop, akRight, akBottom]
|
||||||
|
ItemHeight = 0
|
||||||
|
OnClick = lbImagesClick
|
||||||
|
OnDrawItem = lbImagesDrawItem
|
||||||
|
Style = lbOwnerDrawFixed
|
||||||
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object Bevel1: TBevel
|
object Bevel1: TBevel
|
||||||
AnchorSideLeft.Control = pnlFoldersAndItems
|
AnchorSideLeft.Control = pnlFoldersAndItems
|
||||||
AnchorSideLeft.Side = asrCenter
|
AnchorSideLeft.Side = asrCenter
|
||||||
Left = 269
|
Left = 239
|
||||||
Height = 50
|
Height = 50
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 4
|
Width = 64
|
||||||
Shape = bsSpacer
|
Shape = bsSpacer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,7 +40,7 @@ uses
|
|||||||
PropEdits, LazarusPackageIntf, FieldsEditor, ComponentEditors,
|
PropEdits, LazarusPackageIntf, FieldsEditor, ComponentEditors,
|
||||||
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||||
StdCtrls, ExtCtrls, Buttons,
|
StdCtrls, ExtCtrls, Buttons,
|
||||||
VpBase, VpNavBar;
|
VpBase, VpNavBar, Types;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -56,7 +56,8 @@ type
|
|||||||
|
|
||||||
TfrmNavBarEd = class(TForm)
|
TfrmNavBarEd = class(TForm)
|
||||||
Bevel1: TBevel;
|
Bevel1: TBevel;
|
||||||
pnlImageView: TPanel;
|
Label4: TLabel;
|
||||||
|
lbImages: TListBox;
|
||||||
pnlFoldersAndItems: TPanel;
|
pnlFoldersAndItems: TPanel;
|
||||||
pnlItems: TPanel;
|
pnlItems: TPanel;
|
||||||
pnlFolders: TPanel;
|
pnlFolders: TPanel;
|
||||||
@ -76,10 +77,6 @@ type
|
|||||||
btnFolderDown: TSpeedButton;
|
btnFolderDown: TSpeedButton;
|
||||||
Panel6: TPanel;
|
Panel6: TPanel;
|
||||||
Label1: TLabel;
|
Label1: TLabel;
|
||||||
pnlImages: TPanel;
|
|
||||||
Panel8: TPanel;
|
|
||||||
Label3: TLabel;
|
|
||||||
sbImages: TScrollBox;
|
|
||||||
|
|
||||||
procedure btnFolderAddClick(Sender: TObject);
|
procedure btnFolderAddClick(Sender: TObject);
|
||||||
procedure btnFolderDeleteClick(Sender: TObject);
|
procedure btnFolderDeleteClick(Sender: TObject);
|
||||||
@ -98,18 +95,15 @@ type
|
|||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
|
|
||||||
procedure lbFoldersClick(Sender: TObject);
|
procedure lbFoldersClick(Sender: TObject);
|
||||||
|
procedure lbImagesClick(Sender: TObject);
|
||||||
|
procedure lbImagesDrawItem(Control: TWinControl; Index: Integer;
|
||||||
|
ARect: TRect; State: TOwnerDrawState);
|
||||||
procedure lbItemsClick(Sender: TObject);
|
procedure lbItemsClick(Sender: TObject);
|
||||||
procedure lbItemsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
procedure lbItemsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
||||||
procedure lbItemsMeasureItem(Control: TWinControl; Index: Integer; var Height: Integer);
|
procedure lbItemsMeasureItem(Control: TWinControl; Index: Integer; var Height: Integer);
|
||||||
|
|
||||||
procedure pnlImageViewClick(Sender: TObject);
|
|
||||||
procedure pnlImageViewPaint(Sender: TObject);
|
|
||||||
|
|
||||||
procedure sbImagesResize(Sender: TObject);
|
|
||||||
|
|
||||||
private
|
private
|
||||||
FBar: TVpNavBar;
|
FBar: TVpNavBar;
|
||||||
FSelImgIndex: Integer;
|
|
||||||
function FindBtnIndex(APersistent: TPersistent): Integer;
|
function FindBtnIndex(APersistent: TPersistent): Integer;
|
||||||
function FindFolderIndex(APersistent: TPersistent): Integer;
|
function FindFolderIndex(APersistent: TPersistent): Integer;
|
||||||
function GetFolderDisplayName(AFolder: TVpNavFolder): String;
|
function GetFolderDisplayName(AFolder: TVpNavFolder): String;
|
||||||
@ -134,6 +128,7 @@ type
|
|||||||
ADesigner: TComponentEditorDesigner); reintroduce;
|
ADesigner: TComponentEditorDesigner); reintroduce;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure PopulateFolderList;
|
procedure PopulateFolderList;
|
||||||
|
procedure PopulateImagesList;
|
||||||
procedure PopulateItemList;
|
procedure PopulateItemList;
|
||||||
procedure SetData(ADesigner: TComponentEditorDesigner; ABar: TVpNavBar);
|
procedure SetData(ADesigner: TComponentEditorDesigner; ABar: TVpNavBar);
|
||||||
property Bar: TVpNavBar read FBar;
|
property Bar: TVpNavBar read FBar;
|
||||||
@ -146,12 +141,14 @@ implementation
|
|||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
PropEditUtils, StrUtils,
|
PropEditUtils, StrUtils, ImgList,
|
||||||
VpMisc;
|
VpMisc;
|
||||||
|
|
||||||
const
|
const
|
||||||
ITEMS_MARGIN = 2;
|
ITEMS_MARGIN = 2;
|
||||||
IMG_MARGIN = 4;
|
IMG_MARGIN = 4;
|
||||||
|
IMG_MARGIN_HOR = 8;
|
||||||
|
IMG_MARGIN_VERT = 4;
|
||||||
|
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
@ -195,8 +192,6 @@ end;
|
|||||||
|
|
||||||
constructor TfrmNavBarEd.Create(AOwner: TComponent; ABar: TVpNavBar;
|
constructor TfrmNavBarEd.Create(AOwner: TComponent; ABar: TVpNavBar;
|
||||||
ADesigner: TComponentEditorDesigner);
|
ADesigner: TComponentEditorDesigner);
|
||||||
var
|
|
||||||
w: Integer;
|
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
|
|
||||||
@ -204,19 +199,6 @@ begin
|
|||||||
FDesigner := ADesigner;
|
FDesigner := ADesigner;
|
||||||
|
|
||||||
PopulateFolderList;
|
PopulateFolderList;
|
||||||
|
|
||||||
if FBar.Images <> nil then begin
|
|
||||||
w := (FBar.Images.Width + 2*IMG_MARGIN) * FBar.Images.Count;
|
|
||||||
pnlImageView.ClientWidth := w;
|
|
||||||
pnlImageView.Constraints.MinHeight := FBar.Images.Height + 2 * IMG_MARGIN + GetScrollbarHeight;
|
|
||||||
if w > sbImages.ClientWidth then begin
|
|
||||||
sbImages.HorzScrollbar.Range := w - sbImages.ClientWidth;
|
|
||||||
sbImages.HorzScrollbar.Visible := true;
|
|
||||||
end else
|
|
||||||
sbImages.HorzScrollbar.Visible := false;
|
|
||||||
end;
|
|
||||||
FSelImgIndex := -1;
|
|
||||||
|
|
||||||
AddDesignHookHandlers;
|
AddDesignHookHandlers;
|
||||||
SelectionChanged;
|
SelectionChanged;
|
||||||
UpdateBtnStates;
|
UpdateBtnStates;
|
||||||
@ -269,10 +251,7 @@ end;
|
|||||||
|
|
||||||
procedure TfrmNavBarEd.FormShow(Sender: TObject);
|
procedure TfrmNavBarEd.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if (Bar <> nil) and (Bar.Images <> nil) then begin
|
PopulateImagesList;
|
||||||
pnlImages.Height := Bar.Images.Height + GetScrollbarHeight + 2*IMG_MARGIN +
|
|
||||||
Panel8.Height + pnlImages.BorderSpacing.Top + pnlImages.BorderSpacing.Bottom;
|
|
||||||
end;
|
|
||||||
lbFolders.SetFocus;
|
lbFolders.SetFocus;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -417,7 +396,9 @@ begin
|
|||||||
if selections[i] is TVpNavFolder then
|
if selections[i] is TVpNavFolder then
|
||||||
lbFolders.Items[i] := GetFolderDisplayName(TVpNavFolder(selections[i]))
|
lbFolders.Items[i] := GetFolderDisplayName(TVpNavFolder(selections[i]))
|
||||||
else if selections[i] is TVpNavBtnItem then
|
else if selections[i] is TVpNavBtnItem then
|
||||||
lbItems.Items[i] := GetItemDisplayName(TVpNavBtnItem(selections[i]));
|
lbItems.Items[i] := GetItemDisplayName(TVpNavBtnItem(selections[i]))
|
||||||
|
else if (selections[i] is TCustomImageList) and (TCustomImageList(selections[i]) = FBar.Images) then
|
||||||
|
PopulateImagesList;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
selections.Free;
|
selections.Free;
|
||||||
@ -471,6 +452,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TfrmNavbarEd.PopulateImagesList;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
lbImages.Clear;
|
||||||
|
if (FBar = nil) or (FBar.Images = nil) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
for i:=0 to Bar.Images.Count-1 do
|
||||||
|
lbImages.Items.Add('');
|
||||||
|
|
||||||
|
lbImages.ItemHeight := FBar.Images.Width + 2*IMG_MARGIN_HOR;
|
||||||
|
lbImages.ClientWidth := FBar.Images.Width + 2*IMG_MARGIN_VERT + GetScrollbarWidth;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TfrmNavBarEd.PopulateItemList;
|
procedure TfrmNavBarEd.PopulateItemList;
|
||||||
var
|
var
|
||||||
I : Integer;
|
I : Integer;
|
||||||
@ -488,7 +484,6 @@ end;
|
|||||||
procedure TfrmNavBarEd.SetData(ADesigner: TComponentEditorDesigner; ABar: TVpNavBar);
|
procedure TfrmNavBarEd.SetData(ADesigner: TComponentEditorDesigner; ABar: TVpNavBar);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
w: Integer;
|
|
||||||
begin
|
begin
|
||||||
if FBar <> nil then
|
if FBar <> nil then
|
||||||
FBar.RemoveFreeNotification(self);
|
FBar.RemoveFreeNotification(self);
|
||||||
@ -500,18 +495,7 @@ begin
|
|||||||
FBar.FreeNotification(self);
|
FBar.FreeNotification(self);
|
||||||
|
|
||||||
PopulateFolderList;
|
PopulateFolderList;
|
||||||
|
PopulateImagesList;
|
||||||
if FBar.Images <> nil then begin
|
|
||||||
w := (Bar.Images.Width + 2*IMG_MARGIN) * Bar.Images.Count;
|
|
||||||
pnlImageView.ClientWidth := w;
|
|
||||||
pnlImageView.Constraints.MinHeight := Bar.Images.Height + 2 * IMG_MARGIN + GetScrollbarHeight;
|
|
||||||
if w > sbImages.ClientWidth then begin
|
|
||||||
sbImages.HorzScrollbar.Range := w - sbImages.ClientWidth;
|
|
||||||
sbImages.HorzScrollbar.Visible := true;
|
|
||||||
end else
|
|
||||||
sbImages.HorzScrollbar.Visible := false;
|
|
||||||
end;
|
|
||||||
FSelImgIndex := -1;
|
|
||||||
|
|
||||||
AddDesignHookHandlers;
|
AddDesignHookHandlers;
|
||||||
UpdateBtnStates;
|
UpdateBtnStates;
|
||||||
@ -524,8 +508,7 @@ var
|
|||||||
begin
|
begin
|
||||||
PopulateItemList;
|
PopulateItemList;
|
||||||
Bar.ActiveFolder := lbFolders.ItemIndex;
|
Bar.ActiveFolder := lbFolders.ItemIndex;
|
||||||
FSelImgIndex := -1;
|
lbImages.ItemIndex := -1;
|
||||||
pnlImageView.Invalidate;
|
|
||||||
|
|
||||||
SelList := TPersistentSelectionList.Create;
|
SelList := TPersistentSelectionList.Create;
|
||||||
SelList.ForceUpdate := true;
|
SelList.ForceUpdate := true;
|
||||||
@ -542,6 +525,41 @@ begin
|
|||||||
UpdateBtnStates;
|
UpdateBtnStates;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
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);
|
||||||
|
x := (ARect.Left + ARect.Right - Bar.Images.Width) div 2;
|
||||||
|
y := (ARect.Top + ARect.Bottom - Bar.Images.Height) div 2;
|
||||||
|
FBar.Images.Draw(lbImages.Canvas, x, y, Index);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TfrmNavBarEd.lbItemsMeasureItem(Control: TWinControl;
|
procedure TfrmNavBarEd.lbItemsMeasureItem(Control: TWinControl;
|
||||||
Index: Integer; var Height: Integer);
|
Index: Integer; var Height: Integer);
|
||||||
begin
|
begin
|
||||||
@ -601,8 +619,8 @@ begin
|
|||||||
if (FBar <> nil) and (FBar.ActiveFolder <> -1) and (lbItems.ItemIndex <> -1) then
|
if (FBar <> nil) and (FBar.ActiveFolder <> -1) and (lbItems.ItemIndex <> -1) then
|
||||||
begin
|
begin
|
||||||
btn := TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]);
|
btn := TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]);
|
||||||
FSelImgIndex := btn.IconIndex;
|
lbImages.ItemIndex := btn.IconIndex;
|
||||||
pnlImageView.Invalidate;
|
|
||||||
SelList := TPersistentSelectionList.Create;
|
SelList := TPersistentSelectionList.Create;
|
||||||
SelList.ForceUpdate := true;
|
SelList.ForceUpdate := true;
|
||||||
for i:=0 to lbItems.Items.Count-1 do
|
for i:=0 to lbItems.Items.Count-1 do
|
||||||
@ -712,7 +730,7 @@ begin
|
|||||||
if (lbItems.ItemIndex <> -1) then begin
|
if (lbItems.ItemIndex <> -1) then begin
|
||||||
TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]).Free;
|
TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]).Free;
|
||||||
lbItems.ItemIndex := -1;
|
lbItems.ItemIndex := -1;
|
||||||
FSelImgIndex := -1;
|
lbImages.ItemIndex := -1;
|
||||||
PopulateItemList;
|
PopulateItemList;
|
||||||
if Assigned(Designer) then
|
if Assigned(Designer) then
|
||||||
Designer.Modified;
|
Designer.Modified;
|
||||||
@ -726,7 +744,7 @@ begin
|
|||||||
TVpNavFolder(lbFolders.Items.Objects[lbFolders.ItemIndex]).Free;
|
TVpNavFolder(lbFolders.Items.Objects[lbFolders.ItemIndex]).Free;
|
||||||
lbFolders.ItemIndex := -1;
|
lbFolders.ItemIndex := -1;
|
||||||
FBar.Activefolder := -1;
|
FBar.Activefolder := -1;
|
||||||
FSelImgIndex := -1;
|
lbImages.ItemIndex := -1;
|
||||||
PopulateFolderList;
|
PopulateFolderList;
|
||||||
PopulateItemList;
|
PopulateItemList;
|
||||||
if Assigned(Designer) then
|
if Assigned(Designer) then
|
||||||
@ -762,93 +780,11 @@ begin
|
|||||||
if (lbFolders.ItemIndex <> -1) then begin
|
if (lbFolders.ItemIndex <> -1) then begin
|
||||||
folder := TVpNavFolder(lbFolders.Items.Objects[lbFolders.ItemIndex]);
|
folder := TVpNavFolder(lbFolders.Items.Objects[lbFolders.ItemIndex]);
|
||||||
item := TVpNavBtnItem(folder.ItemCollection.Add);
|
item := TVpNavBtnItem(folder.ItemCollection.Add);
|
||||||
// item.Name := Designer.CreateUniqueComponentName('TVpNavBtnItem');
|
|
||||||
GlobalDesignHook.PersistentAdded(item, true);
|
GlobalDesignHook.PersistentAdded(item, true);
|
||||||
(*
|
|
||||||
|
|
||||||
TVpNavFolder(
|
|
||||||
lbFolders.Items.Objects[lbFolders.ItemIndex]).ItemCollection.Add;
|
|
||||||
lbItems.ItemIndex := -1;
|
|
||||||
FSelImgIndex := -1;
|
|
||||||
PopulateItemList;
|
|
||||||
SelectionChanged(true);
|
|
||||||
if assigned(Designer) then
|
|
||||||
Designer.Modified;
|
|
||||||
*)
|
|
||||||
end;
|
end;
|
||||||
UpdateBtnStates;
|
UpdateBtnStates;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmNavBarEd.pnlImageViewPaint(Sender: TObject);
|
|
||||||
var
|
|
||||||
R: TRect;
|
|
||||||
Rimg: TRect;
|
|
||||||
i: Integer;
|
|
||||||
x, y: Integer;
|
|
||||||
wimg, himg: Integer;
|
|
||||||
begin
|
|
||||||
R := Rect(0, 0, sbImages.Width, sbImages.Height);
|
|
||||||
pnlImageView.Canvas.Brush.Color := clWindow;
|
|
||||||
pnlImageView.Canvas.FillRect(R);
|
|
||||||
|
|
||||||
if (Bar.Images = nil) or (Bar.Images.Count = 0) then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
wimg := Bar.Images.Width;
|
|
||||||
himg := Bar.Images.Height;
|
|
||||||
|
|
||||||
x := 0;
|
|
||||||
y := R.Top + IMG_MARGIN;
|
|
||||||
if pnlImageView.Width <= sbImages.Width then // no scrollbar
|
|
||||||
inc(y, GetScrollbarHeight div 2);
|
|
||||||
|
|
||||||
i := 0;
|
|
||||||
while i < Bar.Images.Count do begin
|
|
||||||
if i = FSelImgIndex then begin
|
|
||||||
R := Rect(x, R.Top, x+wimg+2*IMG_MARGIN, R.Bottom);
|
|
||||||
pnlImageView.Canvas.Brush.Color := clHighlight;
|
|
||||||
pnlImageView.Canvas.FillRect(R);
|
|
||||||
end;
|
|
||||||
FBar.Images.Draw(pnlImageView.Canvas, x + IMG_MARGIN, y, i, true);
|
|
||||||
inc(i);
|
|
||||||
inc(x, wimg + 2*IMG_MARGIN);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TfrmNavBarEd.pnlImageViewClick(Sender: TObject);
|
|
||||||
var
|
|
||||||
P: TPoint;
|
|
||||||
btn: TVpNavBtnItem;
|
|
||||||
res: Integer;
|
|
||||||
begin
|
|
||||||
if (Bar.Images = nil) or (Bar.Images.Count = 0) then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
P := pnlImageView.ScreenToClient(Mouse.CursorPos);
|
|
||||||
FSelImgIndex := P.X div (Bar.Images.Width + 2*IMG_MARGIN);
|
|
||||||
if FSelImgIndex >= Bar.Images.Count then FSelImgIndex := Bar.Images.Count - 1;
|
|
||||||
pnlImageView.Invalidate;
|
|
||||||
|
|
||||||
if (FSelImgIndex <> -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 := FSelImgIndex;
|
|
||||||
lbItems.Invalidate;
|
|
||||||
if Assigned(Designer) then
|
|
||||||
Designer.Modified;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TfrmNavBarEd.sbImagesResize(Sender: TObject);
|
|
||||||
begin
|
|
||||||
sbImages.HorzScrollbar.Visible := sbImages.ClientWidth < pnlImageView.ClientWidth;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TfrmNavBarEd.SelectionChanged(AOrderChanged: Boolean = false);
|
procedure TfrmNavBarEd.SelectionChanged(AOrderChanged: Boolean = false);
|
||||||
var
|
var
|
||||||
SelList: TPersistentSelectionList;
|
SelList: TPersistentSelectionList;
|
||||||
|
Reference in New Issue
Block a user