📄 jvnavigationpane.pas
字号:
// TODO: should this be removed?
// for I := 0 to ControlCount - 1 do
// if Controls[I] is TJvNavIconButton then
// TJvNavIconButton(Controls[I]).StyleManager := Value;
end;
procedure TJvIconPanel.SetDropDownMenu(const Value: TPopupMenu);
begin
FDropButton.DropDownMenu := Value;
FDropButton.Visible := Value <> nil;
end;
procedure TJvIconPanel.DoDropDownMenu(Sender: TObject; MousePos: TPoint;
var Handled: Boolean);
begin
if Assigned(FOnDropDownMenu) then
FOnDropDownMenu(Self, MousePos, Handled);
end;
procedure TJvIconPanel.ParentStyleManagerChanged(var Msg: TMsgStyleManagerChange);
begin
if (Msg.Sender <> Self) and ParentStyleManager then
begin
StyleManager := Msg.StyleManager;
ParentStyleManager := True;
InternalStyleManagerChanged(Self, Msg.StyleManager);
end;
end;
procedure TJvIconPanel.SetParentStyleManager(const Value: Boolean);
begin
if FParentStyleManager <> Value then
begin
FParentStyleManager := Value;
if FParentStyleManager and (Parent <> nil) then
{$IFDEF VCL}
Parent.Perform(CM_PARENTSTYLEMANAGERCHANGE, 0, 0);
{$ENDIF VCL}
{$IFDEF VisualCLX}
QWindows.Perform(Parent, CM_PARENTSTYLEMANAGERCHANGE, 0, 0);
{$ENDIF VisualCLX}
end;
end;
{$IFDEF VCL}
procedure TJvIconPanel.CMControlChange(var Msg: TMessage);
begin
InternalStyleManagerChanged(Self, StyleManager);
end;
procedure TJvIconPanel.WMEraseBkgnd(var Msg: TWMEraseBkgnd);
begin
Msg.Result := 1;
end;
{$ENDIF VCL}
{$IFDEF VisualCLX}
procedure TJvIconPanel.ControlsListChanged(Control: TControl; Inserting: Boolean);
begin
inherited ControlsListChanged(Control, Inserting);
InternalStyleManagerChanged(Self, StyleManager);
end;
function TJvIconPanel.WidgetFlags: Integer;
begin
Result := inherited WidgetFlags or Integer(WidgetFlags_WRepaintNoErase);
end;
{$ENDIF VisualCLX}
procedure TJvIconPanel.ParentStyleManagerChange(var Msg: TMessage);
begin
InternalStyleManagerChanged(Self, StyleManager);
end;
//=== { TJvCustomNavigationPane } ============================================
var
GlobalNavPanelPageRegistered: Boolean = False;
constructor TJvCustomNavigationPane.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
if not GlobalNavPanelPageRegistered then
begin
GlobalNavPanelPageRegistered := True;
RegisterClasses([TJvNavPanelPage]);
end;
FBackground := TJvNavPaneBackgroundImage.Create;
FBackground.OnChange := DoColorsChange;
ControlStyle := ControlStyle - [csAcceptsControls];
FStyleLink := TJvNavStyleLink.Create;
FStyleLink.OnChange := DoStyleChange;
FButtonHeight := 28;
FButtonWidth := 22;
{$IFDEF VCL}
BorderWidth := 1;
{$ENDIF VCL}
ParentColor := False;
Color := clWindow;
ControlStyle := ControlStyle + [csOpaque];
FResizable := True;
FColors := TJvNavPanelColors.Create;
FColors.OnChange := DoColorsChange;
FIconPanel := TJvIconPanel.Create(Self);
FIconPanel.Parent := Self;
FIconPanel.Align := alBottom;
FIconPanel.OnDropDownMenu := DoDropDownMenu;
FNavPanelFont := TFont.Create;
FNavPanelHotTrackFont := TFont.Create;
{$IFDEF VCL}
FNavPanelFont.Assign(Screen.IconFont);
{$ENDIF VCL}
{$IFDEF VisualCLX}
FNavPanelFont.Assign(Application.Font);
{$ENDIF VisualCLX}
FNavPanelFont.Style := [fsBold];
FNavPanelFont.OnChange := DoNavPanelFontChange;
FNavPanelHotTrackFont.Assign(FNavPanelFont);
FNavPanelHotTrackFont.OnChange := DoNavPanelFontChange;
FNavPanelHotTrackFontOptions := DefaultTrackFontOptions;
FSplitter := TJvOutlookSplitter.Create(Self);
with FSplitter do
begin
ResizeStyle := rsNone;
MinSize := 1;
OnCanResize := DoSplitterCanResize;
Parent := Self;
end;
FParentStyleManager := True;
{$IFDEF COMPILER6_UP}
FIconPanel.SetSubComponent(True);
FSplitter.SetSubComponent(True);
{$ENDIF COMPILER6_UP}
end;
destructor TJvCustomNavigationPane.Destroy;
begin
FStyleLink.Free;
FColors.Free;
FNavPanelFont.Free;
FNavPanelHotTrackFont.Free;
FBackground.Free;
inherited Destroy;
end;
procedure TJvCustomNavigationPane.DoSplitterCanResize(Sender: TObject;
var NewSize: Integer; var Accept: Boolean);
var
ACount: Integer;
begin
ACount := MaximizedCount;
if NewSize < ButtonHeight div 2 then
MaximizedCount := ACount - 1
else
if NewSize > ButtonHeight + ButtonHeight div 2 then
MaximizedCount := ACount + 1;
NewSize := 0;
Accept := False;
end;
function TJvCustomNavigationPane.GetDropDownMenu: TPopupMenu;
begin
if FIconPanel <> nil then
Result := FIconPanel.DropDownMenu
else
Result := nil;
end;
function TJvCustomNavigationPane.GetSmallImages: TCustomImageList;
begin
Result := FSmallImages;
end;
function TJvCustomNavigationPane.GetMaximizedCount: Integer;
var
I: Integer;
begin
Result := 0;
for I := 0 to PageCount - 1 do
if not NavPages[I].Iconic then
Inc(Result);
end;
function TJvCustomNavigationPane.HidePage(Page: TJvCustomPage): TJvCustomPage;
begin
Result := inherited HidePage(Page);
if Result <> nil then
UpdatePositions;
end;
function TJvCustomNavigationPane.ShowPage(Page: TJvCustomPage; PageIndex: Integer): TJvCustomPage;
begin
Result := inherited ShowPage(Page, PageIndex);
if Result <> nil then
UpdatePositions;
end;
procedure TJvCustomNavigationPane.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if Operation = opRemove then
begin
if AComponent = LargeImages then
LargeImages := nil;
if AComponent = SmallImages then
SmallImages := nil;
if AComponent = StyleManager then
StyleManager := nil;
end;
end;
procedure TJvCustomNavigationPane.SetDropDownMenu(const Value: TPopupMenu);
begin
if FIconPanel <> nil then
FIconPanel.DropDownMenu := Value;
end;
procedure TJvCustomNavigationPane.SetLargeImages(const Value: TCustomImageList);
begin
if FLargeImages <> Value then
begin
FLargeImages := Value;
UpdatePages;
end;
end;
procedure TJvCustomNavigationPane.SetSmallImages(const Value: TCustomImageList);
begin
if FSmallImages <> Value then
begin
FSmallImages := Value;
UpdatePages;
end;
end;
procedure TJvCustomNavigationPane.HidePanel(Index: Integer);
begin
if (Index >= 0) and (Index < PageCount) then // don't hide the first panel
NavPages[Index].Iconic := True;
end;
procedure TJvCustomNavigationPane.ShowPanel(Index: Integer);
begin
if (Index >= 0) and (Index < PageCount) then
NavPages[Index].Iconic := False;
end;
procedure TJvCustomNavigationPane.SetMaximizedCount(Value: Integer);
var
I, ACount: Integer;
begin
ACount := MaximizedCount;
if Value < 0 then
Value := 0;
if Value > PageCount then
Value := PageCount;
if Value = MaximizedCount then
Exit;
while ACount > Value do
begin
HidePanel(ACount - 1);
Dec(ACount);
end;
if Value > ACount then
for I := Value downto ACount do
ShowPanel(I - 1);
UpdatePositions;
end;
procedure TJvCustomNavigationPane.UpdatePositions;
var
I, X, Y: Integer;
begin
if (csDestroying in ComponentState) or (FIconPanel = nil) then
Exit;
DisableAlign;
FIconPanel.DisableAlign;
try
Y := 0;
X := 0;
FSplitter.Top := Y;
FIconPanel.FDropButton.Left := Width;
FIconPanel.Top := Height - FIconPanel.Height;
Inc(Y, FSplitter.Height);
for I := 0 to PageCount - 1 do
begin
if (NavPages[I].NavPanel = nil) or (NavPages[I].IconButton = nil) then
Exit;
NavPages[I].IconButton.Left := X;
Inc(X, NavPages[I].IconButton.Width);
NavPages[I].NavPanel.Top := Y;
Inc(Y, NavPages[I].NavPanel.Height);
NavPages[I].Invalidate;
end;
finally
EnableAlign;
FIconPanel.EnableAlign;
end;
Invalidate;
end;
procedure TJvCustomNavigationPane.SetColors(const Value: TJvNavPanelColors);
begin
FColors.Assign(Value);
end;
procedure TJvCustomNavigationPane.DoColorsChange(Sender: TObject);
begin
if FIconPanel <> nil then
TJvIconPanel(FIconPanel).Colors := Colors;
UpdatePages;
FSplitter.ColorFrom := Colors.SplitterColorFrom;
FSplitter.ColorTo := Colors.SplitterColorTo;
Invalidate;
end;
procedure TJvCustomNavigationPane.Loaded;
begin
inherited Loaded;
UpdatePositions;
end;
procedure TJvCustomNavigationPane.SetResizable(const Value: Boolean);
begin
if FResizable <> Value then
begin
FResizable := Value;
FSplitter.Enabled := FResizable;
end;
end;
function TJvCustomNavigationPane.InternalGetPageClass: TJvCustomPageClass;
begin
Result := TJvNavPanelPage;
end;
function TJvCustomNavigation
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -