From 3627e39793a1b1ecf8fe1bd06d775871a580d166 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 2 May 2018 15:52:08 +0000 Subject: [PATCH] tvplanit: Fix and activate component editor of TVpNavBar (still some issues!). Fix TvNavBar background painting issue (#33675). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6370 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/design/vpnabed.lfm | 647 +++++++++-------- components/tvplanit/source/design/vpnabed.pas | 668 +++++++++++++----- components/tvplanit/source/design/vpreg.pas | 22 +- components/tvplanit/source/vpmisc.pas | 14 + components/tvplanit/source/vpnavbar.pas | 6 +- .../tvplanit/source/vpnavbarpainter.pas | 5 +- 6 files changed, 877 insertions(+), 485 deletions(-) diff --git a/components/tvplanit/source/design/vpnabed.lfm b/components/tvplanit/source/design/vpnabed.lfm index aa07f029c..049926b1e 100644 --- a/components/tvplanit/source/design/vpnabed.lfm +++ b/components/tvplanit/source/design/vpnabed.lfm @@ -1,347 +1,380 @@ object frmNavBarEd: TfrmNavBarEd Left = 374 - Height = 344 + Height = 364 Top = 236 - Width = 426 + Width = 543 HorzScrollBar.Page = 425 VertScrollBar.Page = 322 Caption = 'Nav Bar Layout Tool' - ClientHeight = 344 - ClientWidth = 426 + ClientHeight = 364 + ClientWidth = 543 FormStyle = fsStayOnTop OnClose = FormClose OnCreate = FormCreate - OnResize = FormResize + OnShow = FormShow Position = poScreenCenter - LCLVersion = '1.7' - object pnlItems: TPanel - Left = 217 - Height = 226 - Top = 0 - Width = 209 - Align = alClient - BevelOuter = bvNone - ClientHeight = 226 - ClientWidth = 209 - TabOrder = 1 - object lbItems: TListBox - Left = 0 - Height = 203 - Top = 23 - Width = 173 - Align = alClient - ItemHeight = 13 - OnClick = lbItemsClick - OnDrawItem = lbItemsDrawItem - Style = lbOwnerDrawVariable - TabOrder = 1 - end - object Panel1: TPanel - Left = 173 - Height = 203 - Top = 23 - Width = 32 - Align = alRight - BorderSpacing.Right = 4 - BevelOuter = bvNone - ClientHeight = 203 - ClientWidth = 32 - TabOrder = 2 - object btnItemAdd: TSpeedButton - Left = 4 - Height = 25 - Hint = 'Add Item' - Top = 7 - Width = 25 - Glyph.Data = { - DE000000424DDE0000000000000076000000280000000D0000000D0000000100 - 0400000000006800000000000000000000001000000010000000000000000000 - 80000080000000808000800000008000800080800000C0C0C000808080000000 - FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 - 3000333300000333300033330AAA0333300033330AAA0333300030000AAA0000 - 300030AAAAAAAAA0300030AAAAAAAAA0300030AAAAAAAAA0300030000AAA0000 - 300033330AAA0333300033330AAA033330003333000003333000333333333333 - 3000 - } - Layout = blGlyphTop - Spacing = 1 - OnClick = btnItemAddClick - ShowHint = True - ParentShowHint = False - end - object btnItemDelete: TSpeedButton - Left = 4 - Height = 25 - Hint = 'Remove item' - Top = 39 - Width = 25 - Glyph.Data = { - DE000000424DDE0000000000000076000000280000000D0000000D0000000100 - 0400000000006800000000000000000000001000000010000000000000000000 - 80000080000000808000800000008000800080800000C0C0C000808080000000 - FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 - 3000333333333333300033333333333330003333333333333000300000000000 - 3000309999999990300030999999999030003099999999903000300000000000 - 3000333333333333300033333333333330003333333333333000333333333333 - 3000 - } - Layout = blGlyphTop - Spacing = 1 - OnClick = btnItemDeleteClick - ShowHint = True - ParentShowHint = False - end - object btnItemUp: TSpeedButton - Left = 4 - Height = 25 - Hint = 'Move item up' - Top = 72 - Width = 25 - Glyph.Data = { - DE000000424DDE0000000000000076000000280000000D0000000D0000000100 - 0400000000006800000000000000000000001000000010000000000000000000 - 80000080000000808000800000008000800080800000C0C0C000808080000000 - FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 - 3000333333333333300033330000033330003333066603333000333306660333 - 3000333306660333300030000666000030003306666666033000333066666033 - 3000333306660333300033333060333330003333330333333000333333333333 - 3000 - } - Layout = blGlyphTop - Spacing = 1 - OnClick = btnItemUpClick - ShowHint = True - ParentShowHint = False - end - object btnItemDown: TSpeedButton - Left = 4 - Height = 25 - Hint = 'Move item down' - Top = 104 - Width = 25 - Glyph.Data = { - DE000000424DDE0000000000000076000000280000000D0000000D0000000100 - 0400000000006800000000000000000000001000000010000000000000000000 - 80000080000000808000800000008000800080800000C0C0C000808080000000 - FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 - 3000333333333333300033333303333330003333306033333000333306660333 - 3000333066666033300033066666660330003000066600003000333306660333 - 3000333306660333300033330666033330003333000003333000333333333333 - 3000 - } - Layout = blGlyphTop - Spacing = 1 - OnClick = btnItemDownClick - ShowHint = True - ParentShowHint = False - end - end - object Panel4: TPanel - Left = 0 - Height = 23 - Top = 0 - Width = 209 - Align = alTop - BevelOuter = bvNone - ClientHeight = 23 - ClientWidth = 209 - TabOrder = 0 - object Label2: TLabel - Left = 0 - Height = 15 - Top = 4 - Width = 62 - Caption = '&Items/Icons' - FocusControl = lbItems - ParentColor = False - end - end - end - object pnlFolders: TPanel - Left = 0 - Height = 226 - Top = 0 - Width = 217 - Align = alLeft - BevelOuter = bvNone - ClientHeight = 226 - ClientWidth = 217 - TabOrder = 0 - object lbFolders: TListBox - Left = 4 - Height = 203 - Top = 23 - Width = 181 - Align = alClient - BorderSpacing.Left = 4 - ItemHeight = 0 - OnClick = lbFoldersClick - TabOrder = 1 - end - object Panel6: TPanel - Left = 0 - Height = 23 - Top = 0 - Width = 217 - Align = alTop - BevelOuter = bvNone - ClientHeight = 23 - ClientWidth = 217 - TabOrder = 0 - object Label1: TLabel - Left = 4 - Height = 15 - Top = 4 - Width = 38 - Caption = '&Folders' - FocusControl = lbFolders - ParentColor = False - end - end - object Panel5: TPanel - Left = 185 - Height = 203 - Top = 23 - Width = 32 - Align = alRight - BevelOuter = bvNone - ClientHeight = 203 - ClientWidth = 32 - TabOrder = 2 - object btnFolderAdd: TSpeedButton - Left = 4 - Height = 25 - Hint = 'Add Item' - Top = 7 - Width = 25 - Glyph.Data = { - DE000000424DDE0000000000000076000000280000000D0000000D0000000100 - 0400000000006800000000000000000000001000000010000000000000000000 - 80000080000000808000800000008000800080800000C0C0C000808080000000 - FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 - 3000333300000333300033330AAA0333300033330AAA0333300030000AAA0000 - 300030AAAAAAAAA0300030AAAAAAAAA0300030AAAAAAAAA0300030000AAA0000 - 300033330AAA0333300033330AAA033330003333000003333000333333333333 - 3000 - } - Layout = blGlyphTop - Spacing = 1 - OnClick = btnFolderAddClick - ShowHint = True - ParentShowHint = False - end - object btnFolderDelete: TSpeedButton - Left = 4 - Height = 25 - Hint = 'Remove item' - Top = 39 - Width = 25 - Glyph.Data = { - DE000000424DDE0000000000000076000000280000000D0000000D0000000100 - 0400000000006800000000000000000000001000000010000000000000000000 - 80000080000000808000800000008000800080800000C0C0C000808080000000 - FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 - 3000333333333333300033333333333330003333333333333000300000000000 - 3000309999999990300030999999999030003099999999903000300000000000 - 3000333333333333300033333333333330003333333333333000333333333333 - 3000 - } - Layout = blGlyphTop - Spacing = 1 - OnClick = btnFolderDeleteClick - ShowHint = True - ParentShowHint = False - end - object btnFolderUp: TSpeedButton - Left = 4 - Height = 25 - Hint = 'Move item up' - Top = 72 - Width = 25 - Glyph.Data = { - DE000000424DDE0000000000000076000000280000000D0000000D0000000100 - 0400000000006800000000000000000000001000000010000000000000000000 - 80000080000000808000800000008000800080800000C0C0C000808080000000 - FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 - 3000333333333333300033330000033330003333066603333000333306660333 - 3000333306660333300030000666000030003306666666033000333066666033 - 3000333306660333300033333060333330003333330333333000333333333333 - 3000 - } - Layout = blGlyphTop - Spacing = 1 - OnClick = btnFolderUpClick - ShowHint = True - ParentShowHint = False - end - object btnFolderDown: TSpeedButton - Left = 4 - Height = 25 - Hint = 'Move item down' - Top = 104 - Width = 25 - Glyph.Data = { - DE000000424DDE0000000000000076000000280000000D0000000D0000000100 - 0400000000006800000000000000000000001000000010000000000000000000 - 80000080000000808000800000008000800080800000C0C0C000808080000000 - FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 - 3000333333333333300033333303333330003333306033333000333306660333 - 3000333066666033300033066666660330003000066600003000333306660333 - 3000333306660333300033330666033330003333000003333000333333333333 - 3000 - } - Layout = blGlyphTop - Spacing = 1 - OnClick = btnFolderDownClick - ShowHint = True - ParentShowHint = False - end - end - end + LCLVersion = '1.9.0.0' object pnlImages: TPanel Left = 0 - Height = 118 - Top = 226 - Width = 426 + Height = 85 + Top = 279 + Width = 543 Align = alBottom + AutoSize = True BevelOuter = bvNone - ClientHeight = 118 - ClientWidth = 426 - TabOrder = 2 + ClientHeight = 85 + ClientWidth = 543 + TabOrder = 0 object Panel8: TPanel Left = 0 Height = 27 Top = 0 - Width = 426 + Width = 543 Align = alTop BevelOuter = bvNone ClientHeight = 27 - ClientWidth = 426 + ClientWidth = 543 TabOrder = 0 object Label3: TLabel + AnchorSideLeft.Control = Panel8 + AnchorSideTop.Control = Panel8 Left = 4 Height = 15 Top = 8 Width = 89 - Caption = 'Available I&mages' + BorderSpacing.Left = 4 + BorderSpacing.Top = 8 + Caption = 'Available Images' ParentColor = False end end - object lbImages: TListBox + object sbImages: TScrollBox Left = 4 - Height = 87 + Height = 54 Top = 27 - Width = 418 + Width = 535 + HorzScrollBar.Page = 56 + HorzScrollBar.Tracking = True + VertScrollBar.Page = 50 Align = alClient + AutoSize = True BorderSpacing.Left = 4 BorderSpacing.Right = 4 BorderSpacing.Bottom = 4 - Columns = 10 - ItemHeight = 16 - OnClick = lbImagesClick - OnDrawItem = lbImagesDrawItem - Style = lbOwnerDrawFixed + 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 + Left = 0 + Height = 279 + Top = 0 + Width = 543 + Align = alClient + BevelOuter = bvNone + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 2 + ClientHeight = 279 + ClientWidth = 543 + TabOrder = 1 + object pnlFolders: TPanel + Left = 0 + Height = 279 + Top = 0 + Width = 272 + BevelOuter = bvNone + ClientHeight = 279 + ClientWidth = 272 + TabOrder = 0 + object lbFolders: TListBox + Left = 4 + Height = 256 + Top = 23 + Width = 236 + Align = alClient + BorderSpacing.Left = 4 + ItemHeight = 0 + OnClick = lbFoldersClick + TabOrder = 1 + end + object Panel6: TPanel + Left = 0 + Height = 23 + Top = 0 + Width = 272 + Align = alTop + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 272 + TabOrder = 0 + object Label1: TLabel + Left = 4 + Height = 15 + Top = 4 + Width = 38 + Caption = '&Folders' + FocusControl = lbFolders + ParentColor = False + end + end + object Panel5: TPanel + Left = 240 + Height = 256 + Top = 23 + Width = 32 + Align = alRight + BevelOuter = bvNone + ClientHeight = 256 + ClientWidth = 32 + TabOrder = 2 + object btnFolderAdd: TSpeedButton + Left = 4 + Height = 25 + Hint = 'Add folder' + Top = 7 + Width = 25 + Glyph.Data = { + DE000000424DDE0000000000000076000000280000000D0000000D0000000100 + 0400000000006800000000000000000000001000000010000000000000000000 + 80000080000000808000800000008000800080800000C0C0C000808080000000 + FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 + 3000333300000333300033330AAA0333300033330AAA0333300030000AAA0000 + 300030AAAAAAAAA0300030AAAAAAAAA0300030AAAAAAAAA0300030000AAA0000 + 300033330AAA0333300033330AAA033330003333000003333000333333333333 + 3000 + } + Layout = blGlyphTop + Spacing = 1 + OnClick = btnFolderAddClick + ShowHint = True + ParentShowHint = False + end + object btnFolderDelete: TSpeedButton + Left = 4 + Height = 25 + Hint = 'Remove folder' + Top = 40 + Width = 25 + Glyph.Data = { + DE000000424DDE0000000000000076000000280000000D0000000D0000000100 + 0400000000006800000000000000000000001000000010000000000000000000 + 80000080000000808000800000008000800080800000C0C0C000808080000000 + FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 + 3000333333333333300033333333333330003333333333333000300000000000 + 3000309999999990300030999999999030003099999999903000300000000000 + 3000333333333333300033333333333330003333333333333000333333333333 + 3000 + } + Layout = blGlyphTop + Spacing = 1 + OnClick = btnFolderDeleteClick + ShowHint = True + ParentShowHint = False + end + object btnFolderUp: TSpeedButton + Left = 4 + Height = 25 + Hint = 'Move folder up' + Top = 72 + Width = 25 + Glyph.Data = { + DE000000424DDE0000000000000076000000280000000D0000000D0000000100 + 0400000000006800000000000000000000001000000010000000000000000000 + 80000080000000808000800000008000800080800000C0C0C000808080000000 + FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 + 3000333333333333300033330000033330003333066603333000333306660333 + 3000333306660333300030000666000030003306666666033000333066666033 + 3000333306660333300033333060333330003333330333333000333333333333 + 3000 + } + Layout = blGlyphTop + Spacing = 1 + OnClick = btnFolderUpClick + ShowHint = True + ParentShowHint = False + end + object btnFolderDown: TSpeedButton + Left = 4 + Height = 25 + Hint = 'Move folder down' + Top = 104 + Width = 25 + Glyph.Data = { + DE000000424DDE0000000000000076000000280000000D0000000D0000000100 + 0400000000006800000000000000000000001000000010000000000000000000 + 80000080000000808000800000008000800080800000C0C0C000808080000000 + FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 + 3000333333333333300033333303333330003333306033333000333306660333 + 3000333066666033300033066666660330003000066600003000333306660333 + 3000333306660333300033330666033330003333000003333000333333333333 + 3000 + } + Layout = blGlyphTop + Spacing = 1 + OnClick = btnFolderDownClick + ShowHint = True + ParentShowHint = False + end + end + end + object pnlItems: TPanel + Left = 272 + Height = 279 + Top = 0 + Width = 271 + BevelOuter = bvNone + ClientHeight = 279 + ClientWidth = 271 + TabOrder = 1 + object lbItems: TListBox + Left = 0 + Height = 256 + Top = 23 + Width = 235 + Align = alClient + ItemHeight = 13 + OnClick = lbItemsClick + OnDrawItem = lbItemsDrawItem + OnMeasureItem = lbItemsMeasureItem + Style = lbOwnerDrawVariable + TabOrder = 1 + end + object Panel1: TPanel + Left = 235 + Height = 256 + Top = 23 + Width = 32 + Align = alRight + BorderSpacing.Right = 4 + BevelOuter = bvNone + ClientHeight = 256 + ClientWidth = 32 + TabOrder = 2 + object btnItemAdd: TSpeedButton + Left = 4 + Height = 25 + Hint = 'Add Item' + Top = 7 + Width = 25 + Glyph.Data = { + DE000000424DDE0000000000000076000000280000000D0000000D0000000100 + 0400000000006800000000000000000000001000000010000000000000000000 + 80000080000000808000800000008000800080800000C0C0C000808080000000 + FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 + 3000333300000333300033330AAA0333300033330AAA0333300030000AAA0000 + 300030AAAAAAAAA0300030AAAAAAAAA0300030AAAAAAAAA0300030000AAA0000 + 300033330AAA0333300033330AAA033330003333000003333000333333333333 + 3000 + } + Layout = blGlyphTop + Spacing = 1 + OnClick = btnItemAddClick + ShowHint = True + ParentShowHint = False + end + object btnItemDelete: TSpeedButton + Left = 4 + Height = 25 + Hint = 'Remove item' + Top = 39 + Width = 25 + Glyph.Data = { + DE000000424DDE0000000000000076000000280000000D0000000D0000000100 + 0400000000006800000000000000000000001000000010000000000000000000 + 80000080000000808000800000008000800080800000C0C0C000808080000000 + FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 + 3000333333333333300033333333333330003333333333333000300000000000 + 3000309999999990300030999999999030003099999999903000300000000000 + 3000333333333333300033333333333330003333333333333000333333333333 + 3000 + } + Layout = blGlyphTop + Spacing = 1 + OnClick = btnItemDeleteClick + ShowHint = True + ParentShowHint = False + end + object btnItemUp: TSpeedButton + Left = 4 + Height = 25 + Hint = 'Move item up' + Top = 72 + Width = 25 + Glyph.Data = { + DE000000424DDE0000000000000076000000280000000D0000000D0000000100 + 0400000000006800000000000000000000001000000010000000000000000000 + 80000080000000808000800000008000800080800000C0C0C000808080000000 + FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 + 3000333333333333300033330000033330003333066603333000333306660333 + 3000333306660333300030000666000030003306666666033000333066666033 + 3000333306660333300033333060333330003333330333333000333333333333 + 3000 + } + Layout = blGlyphTop + Spacing = 1 + OnClick = btnItemUpClick + ShowHint = True + ParentShowHint = False + end + object btnItemDown: TSpeedButton + Left = 4 + Height = 25 + Hint = 'Move item down' + Top = 104 + Width = 25 + Glyph.Data = { + DE000000424DDE0000000000000076000000280000000D0000000D0000000100 + 0400000000006800000000000000000000001000000010000000000000000000 + 80000080000000808000800000008000800080800000C0C0C000808080000000 + FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333 + 3000333333333333300033333303333330003333306033333000333306660333 + 3000333066666033300033066666660330003000066600003000333306660333 + 3000333306660333300033330666033330003333000003333000333333333333 + 3000 + } + Layout = blGlyphTop + Spacing = 1 + OnClick = btnItemDownClick + ShowHint = True + ParentShowHint = False + end + end + object Panel4: TPanel + Left = 0 + Height = 23 + Top = 0 + Width = 271 + Align = alTop + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 271 + TabOrder = 0 + object Label2: TLabel + Left = 0 + Height = 15 + Top = 4 + Width = 62 + Caption = '&Items/Icons' + FocusControl = lbItems + ParentColor = False + end + end end end end diff --git a/components/tvplanit/source/design/vpnabed.pas b/components/tvplanit/source/design/vpnabed.pas index b04893180..79cc13a67 100644 --- a/components/tvplanit/source/design/vpnabed.pas +++ b/components/tvplanit/source/design/vpnabed.pas @@ -34,34 +34,29 @@ unit VpNabEd; interface uses - {$IFDEF LCL} - LCLProc, LCLType, LCLIntf, - {$ELSE} - Windows, Messages, - {$ENDIF} - SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + {$IFDEF LCL} + lazlogger, + + LCLProc, LCLType, LCLIntf, + PropEdits, LazarusPackageIntf, FieldsEditor, ComponentEditors, + {$ELSE} + Windows, Messages, {$IFDEF VERSION6} - {$IFNDEF LCL} DesignIntf, DesignEditors, {$ELSE} - PropEdits, - LazarusPackageIntf, - FieldsEditor, - ComponentEditors, - {$ENDIF} - {$ELSE} DsgnIntf, {$ENDIF} - + {$ENDIF} + SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Buttons, VpBase, VpNavBar; type {$IFNDEF LCL} -{$IFDEF VERSION6} + {$IFDEF VERSION6} TProtectedSelList = class(TDesignerSelections); -{$ENDIF} + {$ENDIF} {$ENDIF} TVpNavBarEditor = class(TComponentEditor) @@ -70,7 +65,11 @@ type function GetVerbCount : Integer; override; end; + { TfrmNavBarEd } + TfrmNavBarEd = class(TForm) + pnlImageView: TPanel; + pnlFoldersAndItems: TPanel; pnlItems: TPanel; pnlFolders: TPanel; lbItems: TListBox; @@ -92,47 +91,66 @@ type pnlImages: TPanel; Panel8: TPanel; Label3: TLabel; - lbImages: TListBox; - procedure FormCreate(Sender: TObject); - procedure FormResize(Sender: TObject); - procedure lbFoldersClick(Sender: TObject); - procedure lbItemsMeasureItem(Control: TWinControl; Index: Integer; - var Height: Integer); - procedure lbItemsDrawItem(Control: TWinControl; Index: Integer; - Rect: TRect; State: TOwnerDrawState); - procedure lbImagesDrawItem(Control: TWinControl; Index: Integer; - Rect: TRect; State: TOwnerDrawState); - procedure lbImagesClick(Sender: TObject); - procedure btnItemUpClick(Sender: TObject); - procedure btnItemDownClick(Sender: TObject); - procedure btnFolderUpClick(Sender: TObject); - procedure btnFolderDownClick(Sender: TObject); - procedure btnItemDeleteClick(Sender: TObject); - procedure btnFolderDeleteClick(Sender: TObject); + sbImages: TScrollBox; + procedure btnFolderAddClick(Sender: TObject); + procedure btnFolderDeleteClick(Sender: TObject); + procedure btnFolderDownClick(Sender: TObject); + procedure btnFolderUpClick(Sender: TObject); + procedure btnItemAddClick(Sender: TObject); - procedure lbItemsClick(Sender: TObject); + procedure btnItemDeleteClick(Sender: TObject); + procedure btnItemDownClick(Sender: TObject); + procedure btnItemUpClick(Sender: TObject); + procedure FormClose(Sender: TObject; var Action: TCloseAction); + procedure FormCreate(Sender: TObject); +// procedure FormResize(Sender: TObject); + procedure FormShow(Sender: TObject); + + procedure lbFoldersClick(Sender: TObject); + procedure lbItemsMeasureItem(Control: TWinControl; Index: Integer; var Height: Integer); + procedure lbItemsClick(Sender: TObject); + procedure lbItemsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); + + procedure pnlImageViewClick(Sender: TObject); + procedure pnlImageViewPaint(Sender: TObject); + + procedure sbImagesResize(Sender: TObject); + private + FBar: TVpNavBar; + FDesigner: TIDesigner; RefreshTimer: TTimer; - {$IFDEF VERSION5} - {$IFDEF VERSION6} - {$IFNDEF LCL} - procedure SelectList(SelList : TDesignerSelections); - {$ENDIF} - {$ELSE} - procedure SelectList(SelList : TDesignerSelectionList); - {$ENDIF} + FSelImgIndex: Integer; + {$IFDEF LCL} + function FindBtnIndex(APersistent: TPersistent): Integer; + function FindFolderIndex(APersistent: TPersistent): Integer; + procedure OnGetSelection(const ASelection: TPersistentSelectionList); + procedure OnPersistentAdded(APersistent: TPersistent; Select: boolean); + procedure OnPersistentDeleting(APersistent: TPersistent); + procedure OnSetSelection(const ASelection: TPersistentSelectionList); + procedure SelectList(SelList: TPersistentSelectionList); + {$ELSE} + {$IFDEF VERSION5} + {$IFDEF VERSION6} + procedure SelectList(SelList: TDesignerSelections); {$ELSE} - procedure SelectList(SelList : TComponentList); + procedure SelectList(SelList: TDesignerSelectionList); {$ENDIF} + {$ELSE} + procedure SelectList(SelList: TComponentList); + {$ENDIF} + {$ENDIF} procedure OnTimer(Sender: TObject); + public { Public declarations } - Bar : TVpNavBar; - Designer : TIDesigner; procedure PopulateFolderList; procedure PopulateItemList; + procedure SetData(ADesigner: TIDesigner; ABar: TVpNavBar); + property Bar: TVpNavBar read FBar; + property Designer: TIDesigner read FDesigner; end; var @@ -147,25 +165,26 @@ implementation {$ENDIF} uses + PropEditUtils, VpMisc; -{$IFDEF VERSION6} - procedure EditNavBar(Designer : TIDesigner; Bar : TVpNavBar); +const + ITEMS_MARGIN = 2; + IMG_MARGIN = 4; + +{$IFDEF LCL} +procedure EditNavBar(Designer: TIDesigner; Bar: TVpNavBar); {$ELSE} - procedure EditNavBar(Designer : TIFormDesigner; Bar : TVpNavBar); + {$IFDEF VERSION6} +procedure EditNavBar(Designer: TIDesigner; Bar: TVpNavBar); + {$ELSE} +procedure EditNavBar(Designer: TIFormDesigner; Bar: TVpNavBar); + {$ENDIF} {$ENDIF} -var - i : Integer; begin - frmNavEd := TfrmNavBarEd.Create(Application); - frmNavEd.Bar := Bar; - frmNavEd.PopulateFolderList; - frmNavEd.Designer := Designer; - if Bar.Images <> nil then begin - frmNavEd.lbImages.ItemHeight := Bar.Images.Height + 4; - for i := 0 to pred(Bar.Images.Count) do - frmNavEd.lbImages.Items.Add(IntToStr(i)); - end; + if frmNavEd = nil then + frmNavEd := TfrmNavBarEd.Create(Application); + frmNavEd.SetData(Designer, Bar); frmNavEd.Show; end; @@ -200,14 +219,17 @@ begin RefreshTimer.OnTimer := OnTimer; RefreshTimer.Enabled := true; end; + {=====} procedure TfrmNavBarEd.FormClose(Sender: TObject; var Action: TCloseAction); begin + (* Unused(Action); RefreshTimer.Free; Release; + *) end; {=====} @@ -236,20 +258,149 @@ begin end; end; {=====} - + (* procedure TfrmNavBarEd.FormResize(Sender: TObject); begin pnlFolders.Width := (pnlItems.Width + pnlFolders.Width) div 2; if Bar.Images <> nil then begin pnlImages.Height := 25 + (5 * (Bar.Images.Height div 3)); - lbImages.Columns := lbImages.Width div Bar.Images.Width; + lbImages.Columns := lbImages.ClientWidth div Bar.Images.Width; {Allow for scrollbar if excessive number of images} if (lbImages.Width >= Bar.Images.Width) then pnlImages.Height := pnlImages.Height + 20; end; +end; *) + +procedure TfrmNavBarEd.FormShow(Sender: TObject); +begin + if Bar.Images <> nil then begin +// sbImages.Constraints.MinHeight := Bar.Images.Height + GetScrollbarHeight + 2*IMG_MARGIN; + pnlImages.Height := Bar.Images.Height + GetScrollbarHeight + 2*IMG_MARGIN + + Panel8.Height + pnlImages.BorderSpacing.Top + pnlImages.BorderSpacing.Bottom; + //lbImages.Columns := lbImages.ClientWidth div Bar.Images.Width; + end; end; + {=====} +{$IFDEF LCL} +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; +{$ENDIF} + +{$IFDEF LCL} +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; +end; +{$ENDIF} + +{$IFDEF LCL} +procedure TfrmNavBarEd.OnPersistentAdded(APersistent: TPersistent; Select: boolean); +var + i: Integer; +begin + 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; +end; +{$ENDIF} + +{$IFDEF LCL} +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; +end; +{$ENDIF} + +{$IFDEF LCL} +procedure TfrmNavBarEd.OnSetSelection(const ASelection: TPersistentSelectionList); +var + i, j: Integer; +begin + if Assigned(ASelection) and (ASelection.Count > 0) then + begin + if TPersistent(ASelection[0]) is TVpNavFolder then begin + //Unselect all + for i := 0 to lbFolders.Items.Count-1 do + lbFolders.Selected[i] := false; + //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 + if TPersistent(ASelection[0]) is TVpNavBtnItem then + begin + // Unselect all + for i := 0 to lbItems.Items.Count - 1 do + lbItems.Selected[i] := false; + // 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; +{$ENDIF} + procedure TfrmNavBarEd.PopulateFolderList; var I : Integer; @@ -282,22 +433,92 @@ begin end; {=====} +procedure TfrmNavBarEd.SetData(ADesigner: TIDesigner; ABar: TVpNavBar); +var + i: Integer; + w: Integer; +begin + if FBar <> nil then + FBar.RemoveFreeNotification(self); + + FBar := ABar; + FDesigner := ADesigner; + + if FBar <> nil then + FBar.FreeNotification(self); + + PopulateFolderList; + + 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; + (* + lbImages.ItemHeight := Bar.Images.Height + 4; + for i := 0 to pred(FBar.Images.Count) do + lbImages.Items.Add(IntToStr(i)); + *) + end; + FSelImgIndex := -1; + + if GlobalDesignHook <> nil then + begin + GlobalDesignHook.RemoveAllHandlersForObject(Self); + if FBar <> nil then + begin + GlobalDesignHook.AddHandlerPersistentAdded(OnPersistentAdded); + GlobalDesignHook.AddHandlerPersistentDeleting(OnPersistentDeleting); + GlobalDesignHook.AddHandlerGetSelection(OnGetSelection); + GlobalDesignHook.AddHandlerSetSelection(OnSetSelection); + end; + end; +end; + procedure TfrmNavBarEd.lbFoldersClick(Sender: TObject); +{$IFDEF LCL} +var + SelList: TPersistentSelectionList; + i: Integer; +begin + PopulateItemList; + Bar.ActiveFolder := lbFolders.ItemIndex; + FSelImgIndex := -1; + pnlImageView.Invalidate; + + SelList := TPersistentSelectionList.Create; + 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])); + Bar.FolderCollection.DoOnItemSelected(i); + end; + if not Bar.FolderCollection.ReadOnly then + begin + btnFolderUp.Enabled := SelList.Count = 1; + btnFolderDown.Enabled := btnFolderUp.Enabled; + btnFolderDelete.Enabled := btnFolderUp.Enabled; + end; + if SelList.Count > 0 then + SelectList(SelList); +end; +{$ELSE} var {$IFDEF VERSION5} - {$IFDEF VERSION6} - {$IFNDEF LCL} - SelList : TDesignerSelections; - {$ENDIF} - {$ELSE} - SelList : TDesignerSelectionList; - {$ENDIF} + {$IFDEF VERSION6} + SelList : TDesignerSelections; + {$ELSE} + SelList : TDesignerSelectionList; + {$ENDIF} {$ELSE} SelList : TComponentList; {$ENDIF} {%H-}i : Integer; begin -{$IFNDEF LCL} PopulateItemList; Bar.ActiveFolder := lbFolders.ItemIndex; @@ -335,8 +556,8 @@ begin if SelList.Count > 0 then {$ENDIF} SelectList(SelList); -{$ENDIF} end; +{$ENDIF} {=====} procedure TfrmNavBarEd.lbItemsMeasureItem(Control: TWinControl; @@ -344,103 +565,141 @@ procedure TfrmNavBarEd.lbItemsMeasureItem(Control: TWinControl; begin Unused(Control, Index); if (Bar.Images <> nil) then - Height := Bar.Images.Height + 4; + Height := Bar.Images.Height + 2 * ITEMS_MARGIN; end; {=====} procedure TfrmNavBarEd.lbItemsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); +var + btn: TVpNavBtnItem; + lb: TListbox; + ts: TTextStyle; + x, y: Integer; + delta: Integer; begin Unused(State); - with TListBox(Control).Canvas do - FillRect(Rect); - if (Bar.Images <> nil) - and (TVpNavBtnItem(lbItems.Items.Objects[Index]).IconIndex > -1) - and (TVpNavBtnItem(lbItems.Items.Objects[Index]).IconIndex < - Bar.Images.Count) - then begin - Bar.Images.Draw(TListBox(Control).Canvas, Rect.Right - Bar.Images.Width, - Rect.Top, TVpNavBtnItem(lbItems.Items.Objects[Index]).IconIndex); - with TListBox(Control).Canvas do - TextOut(Rect.Left + 2, Rect.Top + (Rect.Bottom - Rect.Top) div 3, - TListBox(Control).Items[Index]); - end else - with TListBox(Control).Canvas do - TextOut(Rect.Left + 2, Rect.Top, TListBox(Control).Items[Index]); -end; -{=====} + lb := TListBox(Control); + lb.Canvas.FillRect(Rect); -procedure TfrmNavBarEd.lbImagesDrawItem(Control: TWinControl; - Index: Integer; Rect: TRect; State: TOwnerDrawState); -begin - Unused(State); - with TListBox(Control).Canvas do - FillRect(Rect); - if (Bar.Images <> nil) then - Bar.Images.Draw(TListBox(Control).Canvas, Rect.Left + 1, Rect.Top + 1, - Index); + if Index = -1 then + exit; + + // Draw button image + delta := ITEMS_MARGIN; + btn := TVpNavBtnItem(lbItems.Items.Objects[Index]); + if (Bar.Images <> nil) and (btn <> nil) and + (btn.IconIndex > -1) and (btn.IconIndex < Bar.Images.Count) then + begin + Bar.Images.Draw( + 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]); end; {=====} procedure TfrmNavBarEd.lbItemsClick(Sender: TObject); +{$IFDEF LCL} var -{$IFDEF VERSION5} - {$IFDEF VERSION6} - {$IFNDEF LCL} - SelList : TDesignerSelections; - {$ENDIF} - {$ELSE} - SelList : TDesignerSelectionList; - {$ENDIF} -{$ELSE} - SelList : TComponentList; -{$ENDIF} - {%H-}i : Integer; + SelList: TPersistentSelectionList; + i: Integer; + btn: TVpNavBtnItem; begin -{$IFNDEF LCL} - if (lbItems.ItemIndex <> -1) then begin - lbImages.ItemIndex := - TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]).IconIndex; - - {$IFDEF VERSION5} - {$IFDEF VERSION6} - SelList := TDesignerSelections.Create; - {$ELSE} - SelList := TDesignerSelectionList.Create; - {$ENDIF} - {$ELSE} - SelList := TComponentList.Create; - {$ENDIF} - for i := 0 to pred(lbItems.Items.Count) do - if lbItems.Selected[i] then begin - {$IFDEF VERSION6} - TProtectedSelList(SelList).Add(TComponent(lbItems.Items.Objects[i])); - {$ELSE} - SelList.Add(TComponent(lbItems.Items.Objects[i])); - {$ENDIF} + if (lbItems.ItemIndex <> -1) and (Bar.ActiveFolder <> 1) then + begin + btn := TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]); + FSelImgIndex := btn.IconIndex; + pnlImageView.Invalidate; + 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])); Bar.Folders[Bar.ActiveFolder].ItemCollection.DoOnItemSelected(I); end; if not Bar.Folders[Bar.ActiveFolder].ItemCollection.ReadOnly then begin - {$IFDEF VERSION6} - btnItemUp.Enabled := TProtectedSelList(SelList).Count = 1; - {$ELSE} - btnItemUp.Enabled := SelList.Count = 1; - {$ENDIF} + btnItemUp.Enabled := SelList.Count = 1; btnItemDown.Enabled := btnItemUp.Enabled; btnItemDelete.Enabled := btnItemUp.Enabled; end; - {$IFDEF VERSION6} - if TProtectedSelList(SelList).Count > 0 then - {$ELSE} if SelList.Count > 0 then - {$ENDIF} SelectList(SelList); end; -{$ENDIF} end; -{=====} +{$ELSE} +var +{$IFDEF VERSION5} + {$IFDEF VERSION6} + SelList : TDesignerSelections; + {$ELSE} + SelList : TDesignerSelectionList; + {$ENDIF} +{$ELSE} + SelList : TComponentList; +{$ENDIF} + i : Integer; +begin + if (lbItems.ItemIndex <> -1) then begin + lbImages.ItemIndex := + TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]).IconIndex; + {$IFDEF VERSION5} + {$IFDEF VERSION6} + SelList := TDesignerSelections.Create; + {$ELSE} + SelList := TDesignerSelectionList.Create; + {$ENDIF} + {$ELSE} + SelList := TComponentList.Create; + {$ENDIF} + + for i := 0 to pred(lbItems.Items.Count) do + if lbItems.Selected[i] then begin + {$IFDEF VERSION6} + TProtectedSelList(SelList).Add(TComponent(lbItems.Items.Objects[i])); + {$ELSE} + SelList.Add(TComponent(lbItems.Items.Objects[i])); + {$ENDIF} + Bar.Folders[Bar.ActiveFolder].ItemCollection.DoOnItemSelected(I); + end; + if not Bar.Folders[Bar.ActiveFolder].ItemCollection.ReadOnly + then begin + {$IFDEF VERSION6} + btnItemUp.Enabled := TProtectedSelList(SelList).Count = 1; + {$ELSE} + btnItemUp.Enabled := SelList.Count = 1; + {$ENDIF} + btnItemDown.Enabled := btnItemUp.Enabled; + btnItemDelete.Enabled := btnItemUp.Enabled; + end; + {$IFDEF VERSION6} + if TProtectedSelList(SelList).Count > 0 then + SelectList(SelList); + {$ELSE} + if SelList.Count > 0 then + SelectList(SelList); + {$ENDIF} + end; +end; +{$ENDIF} +{=====} + (* procedure TfrmNavBarEd.lbImagesClick(Sender: TObject); begin if (lbImages.ItemIndex <> -1) and (lbItems.ItemIndex <> -1) then begin @@ -450,7 +709,8 @@ begin if assigned(Designer) then Designer.Modified; end; -end; +end; *) + {=====} procedure TfrmNavBarEd.btnItemUpClick(Sender: TObject); @@ -461,12 +721,14 @@ begin if (lbItems.ItemIndex > 0) then begin SaveItemIndex := lbItems.ItemIndex; Item := TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]); - if Item.Index > 0 then - Item.Index := Item.Index - 1; + Item.Index := Item.Index - 1; - if Assigned(Designer) then + if Assigned(Designer) then begin + GlobalDesignHook.SelectOnlyThis(nil); + GlobalDesignHook.SelectOnlyThis(Item); Designer.Modified; + end; PopulateItemList; @@ -485,8 +747,11 @@ begin if Item.Index < Pred(lbItems.Items.Count) then Item.Index := Item.Index + 1; - if Assigned(Designer) then + if Assigned(Designer) then begin + GlobalDesignHook.SelectOnlyThis(nil); + GlobalDesignHook.SelectOnlyThis(Item); Designer.Modified; + end; PopulateItemList; @@ -507,8 +772,11 @@ begin if Folder.Index > 0 then Folder.Index := Folder.Index - 1; - if assigned(Designer) then + if Assigned(Designer) then begin + GlobalDesignHook.SelectOnlyThis(nil); + GlobalDesignHook.SelectOnlyThis(folder); Designer.Modified; + end; PopulateFolderList; @@ -527,8 +795,11 @@ begin if Folder.Index < pred(lbFolders.Items.Count) then Folder.Index := Folder.Index + 1; - if assigned(Designer) then + if Assigned(Designer) then begin + GlobalDesignHook.SelectOnlyThis(nil); + GlobalDesignHook.SelectOnlyThis(folder); Designer.Modified; + end; PopulateFolderList; @@ -542,6 +813,7 @@ begin if (lbItems.ItemIndex <> -1) then begin TVpNavBtnItem(lbItems.Items.Objects[lbItems.ItemIndex]).Free; lbItems.ItemIndex := -1; + FSelImgIndex := -1; PopulateItemList; if assigned(Designer) then Designer.Modified; @@ -586,20 +858,98 @@ begin 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; + Bar.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; + +{$IFDEF LCL} +procedure TfrmNavBarEd.Selectlist(SelList: TPersistentSelectionList); +begin + if GlobalDesignHook <> nil then + begin + GlobalDesignHook.SetSelection(SelList); + GlobalDesignHook.LookupRoot := GetLookupRootForComponent(Bar); + end; + SelList.Free; +end; +{$ELSE} {$IFDEF VERSION5} - {$IFDEF VERSION6} - {$IFNDEF LCL} - procedure TfrmNavBarEd.SelectList(SelList : TDesignerSelections); - {$ENDIF} - {$ELSE} - procedure TfrmNavBarEd.SelectList(SelList : TDesignerSelectionList); - {$ENDIF} + {$IFDEF VERSION6} + procedure TfrmNavBarEd.SelectList(SelList : TDesignerSelections); + {$ELSE} + procedure TfrmNavBarEd.SelectList(SelList : TDesignerSelectionList); + {$ENDIF} {$ELSE} procedure TfrmNavBarEd.SelectList(SelList : TComponentList); {$ENDIF} begin -{$IFNDEF LCL} - {$IFNDEF Ver80} + {$IFNDEF Ver80} {$IFDEF VERSION4} if Designer <> nil then {$IFDEF VERSION6} @@ -612,9 +962,9 @@ begin (Designer as TFormDesigner).SetSelections(SelList); {$ENDIF} SelList.Free; - {$ELSE} + {$ELSE} CompLib.SetSelection(Designer, Designer.Form, SelList); - {$ENDIF} + {$ENDIF} end; {$ENDIF} {=====} diff --git a/components/tvplanit/source/design/vpreg.pas b/components/tvplanit/source/design/vpreg.pas index 1fdf28898..f97b08988 100644 --- a/components/tvplanit/source/design/vpreg.pas +++ b/components/tvplanit/source/design/vpreg.pas @@ -36,21 +36,17 @@ unit VpReg; interface uses - {$IFDEF LCL} + {$IFDEF LCL} LCLProc, LCLType, LCLIntf, LazFileUtils, - {$ELSE} - Windows, - {$ENDIF} - - {$IFDEF VERSION6} - {$IFNDEF LCL} - DesignIntf, DesignEditors, VCLEditors, - {$ELSE} PropEdits, LazarusPackageIntf, FieldsEditor, ComponentEditors, - {$ENDIF} + {$ELSE} + Windows, + {$IFDEF VERSION6} + DesignIntf, DesignEditors, VCLEditors, {$ELSE} DsgnIntf, {$ENDIF} + {$ENDIF} Dialogs, Classes, Controls, TypInfo, Forms, SysUtils, VpDatePropEdit; @@ -202,9 +198,7 @@ uses VpContactButtons, { - New contact grid button bar component } { Designtime Interfaces (Property and Component Editors) } VpAbout, { About form for the About property editor } - {$IFDEF DELPHI} - VpNabEd, { component editor for the VpNavBar } // crashes in Lazarus - {$ENDIF} + VpNabEd, { component editor for the VpNavBar } VpFlxDSEd1; { Field mapper component editor for the FlexDS } @@ -557,9 +551,7 @@ begin {----------------------------------------------------------------------------} { register component editors } {----------------------------------------------------------------------------} - {$IFDEF DELPHI} RegisterComponentEditor(TVpNavBar, TVpNavBarEditor); - {$ENDIF} RegisterComponentEditor(TVpControlLink, TVpPrtFmtPropertyEditor); RegisterComponentEditor(TVpFlexDataStore, TVpFlexDSEditor); diff --git a/components/tvplanit/source/vpmisc.pas b/components/tvplanit/source/vpmisc.pas index 172109acc..5f789bbf7 100644 --- a/components/tvplanit/source/vpmisc.pas +++ b/components/tvplanit/source/vpmisc.pas @@ -182,6 +182,9 @@ procedure LoadGlyphFromRCDATA(AGlyph: TBitmap; ABaseResName: String; procedure LoadImageFromRCDATA(AImage: TImage; ABaseResName: String; ALowRes, AMedRes, AHighRes: Integer; AdjustSize: Boolean = true); +function GetScrollbarHeight: Integer; +function GetScrollbarWidth: Integer; + procedure Unused(const A1); overload; procedure Unused(const A1, A2); overload; procedure Unused(const A1, A2, A3); overload; @@ -1023,6 +1026,17 @@ begin end; end; +function GetScrollbarHeight: Integer; +begin + Result := GetSystemMetrics(SM_CYHSCROLL); +end; + +function GetScrollbarWidth: Integer; +begin + Result := GetSystemMetrics(SM_CXVSCROLL); +end; + + {$PUSH}{$HINTS OFF} procedure Unused(const A1); begin diff --git a/components/tvplanit/source/vpnavbar.pas b/components/tvplanit/source/vpnavbar.pas index 65c8fbe5b..8dc813e9f 100644 --- a/components/tvplanit/source/vpnavbar.pas +++ b/components/tvplanit/source/vpnavbar.pas @@ -328,7 +328,7 @@ type property ActiveFolder: Integer read FActiveFolder write SetActiveFolder; property AllowInplaceEdit: Boolean read FAllowInplaceEdit write FAllowInplaceEdit default false; property AllowRearrange: Boolean read FAllowRearrange write FAllowRearrange; - property BackgroundColor: TColor read FBackgroundColor write SetBackgroundColor; + property BackgroundColor: TColor read FBackgroundColor write SetBackgroundColor default clWindow; property BackgroundImage: TBitmap read FBackgroundImage write SetBackgroundImage; property BackgroundMethod: TVpBackgroundMethod read FBackgroundMethod write SetBackgroundMethod; property ButtonHeight: Integer read FButtonHeight write SetButtonHeight; @@ -1005,7 +1005,7 @@ begin FItemFont := TFont.Create; FItemFont.Name := Font.Name; FItemFont.OnChange := nabFontChanged; - FItemFont.Color := clWhite; + FItemFont.Color := clWindowText; FItemSpacing := abs(FItemFont.Height) + 3; FSelectedItemFont := TFont.Create; @@ -1061,7 +1061,7 @@ begin ParentColor := False; FAllowRearrange := True; - FBackgroundColor := clInactiveCaption; + FBackgroundColor := clWindow; FBackgroundImage := TBitmap.Create; FBackgroundMethod := bmNormal; // FBorderStyle := bsSingle; diff --git a/components/tvplanit/source/vpnavbarpainter.pas b/components/tvplanit/source/vpnavbarpainter.pas index 45960c762..5b8dcb7cc 100644 --- a/components/tvplanit/source/vpnavbarpainter.pas +++ b/components/tvplanit/source/vpnavbarpainter.pas @@ -214,7 +214,7 @@ var rowStart: Integer; lLeft, lHeight, lWidth: Integer; begin - if FBackgroundImage.Empty or (FBackgroundMethod = bmNone) then + if FBackgroundImage.Empty or (FBackgroundMethod = bmNone) or (FNavBar.FolderCount = 0) then begin Canvas.Brush.Color := FBackgroundColor; Canvas.FillRect(R.Left, R.Top, R.Right, R.Bottom); @@ -861,6 +861,7 @@ begin try DrawBmp.Width := FClientWidth; DrawBmp.Height := FClientHeight; + DrawBmp.Transparent := false; DrawBmp.Canvas.Font := FNavBar.Font; DrawBmp.Canvas.Pen.Color := FBackgroundColor; @@ -878,6 +879,8 @@ begin if FNavBar.FolderCount = 0 then begin nabScrollUpBtn.Visible := False; nabScrollDownBtn.Visible := False; + FNavBar.Canvas.CopyMode := cmSrcCopy; + FNavBar.Canvas.CopyRect(MyRect, DrawBmp.Canvas, Rect(0, 0, DrawBmp.Width,DrawBmp.Height)); Exit; end;