You've already forked lazarus-ccr
tvplanit: Fix crash due to non-registered navbar container class. (Container still does not accept controls). Some cleanup.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4999 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -13,7 +13,7 @@ object Form1: TForm1
|
||||
Height = 370
|
||||
Top = 0
|
||||
Width = 128
|
||||
ActiveFolder = 0
|
||||
ActiveFolder = 3
|
||||
AllowInplaceEdit = True
|
||||
AllowRearrange = True
|
||||
BackgroundColor = clInactiveCaption
|
||||
@ -113,6 +113,17 @@ object Form1: TForm1
|
||||
IconSize = isLarge
|
||||
Name = 'NavFolder2'
|
||||
Tag = 0
|
||||
end
|
||||
item
|
||||
Version = 'v1.04'
|
||||
Caption = 'Container'
|
||||
Enabled = True
|
||||
FolderType = ftContainer
|
||||
ItemCollection = <>
|
||||
IconSize = isLarge
|
||||
Name = 'NavFolder3'
|
||||
Tag = 0
|
||||
ContainerIndex = 0
|
||||
end>
|
||||
Images = Images
|
||||
ItemFont.Color = clWhite
|
||||
@ -127,6 +138,16 @@ object Form1: TForm1
|
||||
OnFolderChanged = VpNavBar1FolderChanged
|
||||
Align = alLeft
|
||||
ParentColor = False
|
||||
object Container0: TVpFolderContainer
|
||||
Left = 0
|
||||
Height = 290
|
||||
Top = 80
|
||||
Width = 128
|
||||
BevelOuter = bvNone
|
||||
Color = clInactiveCaption
|
||||
ParentColor = False
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object RgDrawingStyle: TRadioGroup
|
||||
Left = 141
|
||||
|
@ -278,6 +278,7 @@ type
|
||||
function nabShowScrollUp: Boolean;
|
||||
function nabShowScrollDown: Boolean;
|
||||
procedure nabTimerEvent(Sender: TObject; Handle: Integer; Interval: Cardinal; ElapsedTime: LongInt);
|
||||
procedure nabProcessContainers;
|
||||
|
||||
{VCL message methods}
|
||||
{$IFNDEF LCL}
|
||||
@ -462,6 +463,7 @@ uses
|
||||
Themes,
|
||||
VpNavBarPainter;
|
||||
|
||||
{$IFNDEF PAINTER}
|
||||
{DrawNavTab - returns the usable text area inside the tab rect.}
|
||||
function DrawNavTab(Canvas: TCanvas; const Client: TRect; BevelWidth: Integer;
|
||||
TabColor: TColor; TabNumber: Integer; CoolTab, IsFocused, IsMouseOver: Boolean): TRect;
|
||||
@ -650,7 +652,7 @@ begin
|
||||
Result := Rect(Client.Left + 1, Client.Top + 1, Client.Right - 2, Client.Bottom - 2);
|
||||
if IsFocused then OffsetRect(Result, 1, 1);
|
||||
end;
|
||||
|
||||
{$ENDIF}
|
||||
|
||||
{===== TVpFolderContainer ===========================================}
|
||||
|
||||
@ -798,7 +800,7 @@ end;
|
||||
constructor TVpNavFolder.Create(Collection: TCollection);
|
||||
begin
|
||||
inherited Create(Collection);
|
||||
RegisterClass(TVpFolderContainer);
|
||||
// RegisterClass(TVpFolderContainer);
|
||||
FNavBar := TVpCustomNavBar(TVpCollection(Collection).GetOwner);
|
||||
FNavBar.ActiveFolder := Index;
|
||||
FItems := TVpCollection.Create(Self, TVpNavBtnItem);
|
||||
@ -1111,8 +1113,7 @@ end;
|
||||
|
||||
procedure TVpCustomNavBar.ItemChanged(FolderIndex, ItemIndex: Integer);
|
||||
begin
|
||||
Invalidate;
|
||||
// InvalidateItem(FolderIndex, ItemIndex);
|
||||
InvalidateItem(FolderIndex, ItemIndex);
|
||||
if not (csDestroying in ComponentState) then
|
||||
RecreateWnd{$IFDEF LCL}(self){$ENDIF};
|
||||
end;
|
||||
@ -2024,6 +2025,8 @@ begin
|
||||
finally
|
||||
painter.Free;
|
||||
end;
|
||||
|
||||
nabProcessContainers;
|
||||
end;
|
||||
|
||||
{$ELSE}
|
||||
@ -3033,4 +3036,47 @@ begin
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
procedure TVpCustomNavBar.nabProcessContainers;
|
||||
var
|
||||
I: Integer;
|
||||
folder: TVpNavFolder;
|
||||
TR: TRect;
|
||||
begin
|
||||
{For container style folders...}
|
||||
|
||||
{Hide the containers for all inactive folders}
|
||||
for I := 0 to FFolders.Count - 1 do begin
|
||||
if I <> FActiveFolder then begin
|
||||
if Folders[i].FolderType = ftContainer then
|
||||
with Containers[Folders[i].ContainerIndex] do begin
|
||||
Width := 0;
|
||||
Height := 0;
|
||||
Visible := false;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
Folder := Folders[FActiveFolder];
|
||||
TR := nabGetFolderArea(FActiveFolder);
|
||||
|
||||
if Folder.FolderType = ftContainer then
|
||||
with Containers[Folder.ContainerIndex] do begin
|
||||
{Position and show the folder's container}
|
||||
Height := TR.Bottom - TR.Top;
|
||||
Top := TR.Top;
|
||||
Left := TR.Left;
|
||||
Width := TR.Right - TR.Left;
|
||||
Visible := true;
|
||||
BringToFront;
|
||||
|
||||
for I := 0 to ControlCount - 1 do
|
||||
Controls[i].Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterClass(TVpFolderContainer);
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF LCL}
|
||||
LMessages, LCLProc, LCLType, LCLIntf,
|
||||
LCLProc, LCLType, LCLIntf,
|
||||
{$ELSE}
|
||||
Windows, Messages, MMSystem,
|
||||
{$ENDIF}
|
||||
@ -136,7 +136,7 @@ var
|
||||
item: TVpNavBtnItem;
|
||||
J: Integer;
|
||||
text: String;
|
||||
H, X: Integer;
|
||||
X: Integer;
|
||||
R: TRect;
|
||||
begin
|
||||
folder := FNavBar.Folders[FActiveFolder];
|
||||
@ -569,7 +569,6 @@ function TVpNavBarPainter.DrawLargeIcon(Canvas: TCanvas; AItem: TVpNavBtnItem;
|
||||
CurPos: Integer): Boolean;
|
||||
var
|
||||
W, H: Integer;
|
||||
lOffset: Integer;
|
||||
R: TRect;
|
||||
begin
|
||||
Result := false;
|
||||
@ -715,7 +714,6 @@ var
|
||||
displayTxt: String;
|
||||
TR: TRect;
|
||||
Flags: Integer;
|
||||
lOffset: Integer;
|
||||
folder: TVpNavFolder;
|
||||
savedFontstyle: TFontStyles;
|
||||
begin
|
||||
@ -854,8 +852,7 @@ var
|
||||
DrawBmp: TBitmap;
|
||||
DrawFolder: Boolean;
|
||||
TR: TRect;
|
||||
CurPos: Integer;
|
||||
I: Integer;
|
||||
CurPos: Integer = 0;
|
||||
MyRect: TRect;
|
||||
begin
|
||||
MyRect := FNavBar.ClientRect;
|
||||
|
Reference in New Issue
Block a user