📄 jvqxpbar.pas
字号:
end;
function TJvXPBarItem.IsHintStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsHintLinked;
end;
function TJvXPBarItem.IsImageIndexStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsImageIndexLinked;
end;
function TJvXPBarItem.IsVisibleStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsVisibleLinked;
end;
function TJvXPBarItem.IsOnClickStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsOnExecuteLinked;
end;
function TJvXPBarItem.IsCheckedStored: Boolean;
begin
Result := (ActionLink = nil) or not FActionLink.IsCheckedLinked;
end;
procedure TJvXPBarItem.DoActionChange(Sender: TObject);
begin
if Sender = Action then
ActionChange(Sender, False);
end;
function TJvXPBarItem.GetAction: TBasicAction;
begin
if FActionLink <> nil then
Result := FActionLink.Action
else
Result := nil;
end;
procedure TJvXPBarItem.SetAction(Value: TBasicAction);
begin
if Value = nil then
begin
FActionLink.Free;
FActionLink := nil;
FWinXPBar.InternalRedraw; // redraw image
end
else
begin
if FActionLink = nil then
FActionLink := GetActionLinkClass.Create(Self);
FActionLink.Action := Value;
FActionLink.OnChange := DoActionChange;
ActionChange(Value, csLoading in Value.ComponentState);
Value.FreeNotification(FWinXPBar); // deligates notification to WinXPBar!
end;
end;
procedure TJvXPBarItem.SetCaption(Value: TCaption);
begin
if Value <> FCaption then
begin
FCaption := Value;
FWinXPBar.InternalRedraw;
end;
end;
procedure TJvXPBarItem.SetEnabled(Value: Boolean);
begin
if Value <> FEnabled then
begin
FEnabled := Value;
FWinXPBar.InternalRedraw;
end;
end;
procedure TJvXPBarItem.SetImageIndex(Value: TImageIndex);
begin
if Value <> FImageIndex then
begin
FImageIndex := Value;
FWinXPBar.InternalRedraw;
end;
end;
procedure TJvXPBarItem.SetImageList(Value: TCustomImageList);
begin
if Value <> FImageList then
begin
FImageList := Value;
FWinXPBar.InternalRedraw;
end;
end;
procedure TJvXPBarItem.SetName(const Value: string);
begin
if (Value <> FName) and (FCollection.Find(Value) = nil) then
FName := Value;
end;
procedure TJvXPBarItem.SetVisible(Value: Boolean);
begin
if Value <> FVisible then
begin
FVisible := Value;
FWinXPBar.ItemVisibilityChanged(Self);
FWinXPBar.ResizeToMaxHeight;
end;
end;
procedure TJvXPBarItem.SetGroupIndex(const Value: Integer);
begin
if FGroupIndex <> Value then
begin
FGroupIndex := Value;
if Checked then
TurnSiblingsOff;
end;
end;
procedure TJvXPBarItem.SetChecked(const Value: Boolean);
begin
if FChecked <> Value then
begin
FChecked := Value;
// Change(False);
if Value then
TurnSiblingsOff;
end;
end;
procedure TJvXPBarItem.TurnSiblingsOff;
var
I: Integer;
Item: TJvXPBarItem;
begin
if (GroupIndex <> 0) and Assigned(FWinXPBar) then
begin
for I := 0 to FWinXPBar.Items.Count - 1 do
begin
Item := FWinXPBar.Items[I];
if (Item <> Self) and (Item.GroupIndex = GroupIndex) then
Item.Checked := False;
end;
end;
end;
//=== { TJvXPBarItems } ======================================================
constructor TJvXPBarItems.Create(WinXPBar: TJvXPCustomWinXPBar);
begin
inherited Create(GetItemClass);
FWinXPBar := WinXPBar;
end;
function TJvXPBarItems.Add: TJvXPBarItem;
begin
Result := TJvXPBarItem(inherited Add);
end;
function TJvXPBarItems.Add(Action: TBasicAction): TJvXPBarItem;
begin
Result := Add;
Result.Action := Action;
end;
function TJvXPBarItems.Add(DataObject: TObject): TJvXPBarItem;
begin
Result := Add;
Result.DataObject := DataObject;
end;
function TJvXPBarItems.Insert(Index: Integer): TJvXPBarItem;
begin
Result := TJvXPBarItem(inherited Insert(Index));
end;
function TJvXPBarItems.Insert(Index: Integer; Action: TBasicAction): TJvXPBarItem;
begin
Result := Insert(Index);
Result.Action := Action;
end;
function TJvXPBarItems.Insert(Index: Integer; DataObject: TObject): TJvXPBarItem;
begin
Result := Insert(Index);
Result.DataObject := DataObject;
end;
function TJvXPBarItems.GetOwner: TPersistent;
begin
Result := FWinXPBar;
end;
class function TJvXPBarItems.GetItemClass: TJvXPBarItemClass;
begin
Result := TJvXPBarItem;
end;
function TJvXPBarItems.GetItem(Index: Integer): TJvXPBarItem;
begin
Result := TJvXPBarItem(inherited GetItem(Index));
end;
procedure TJvXPBarItems.SetItem(Index: Integer; Value: TJvXPBarItem);
begin
inherited SetItem(Index, Value);
end;
procedure TJvXPBarItems.Update(Item: TCollectionItem);
begin
FWinXPBar.SortVisibleItems(True);
end;
function TJvXPBarItems.Find(const AName: string): TJvXPBarItem;
var
I: Integer;
begin
Result := nil;
for I := 0 to Count - 1 do
if Items[I].Name = AName then
begin
Result := Items[I];
Break;
end;
end;
function TJvXPBarItems.Find(const Action: TBasicAction): TJvXPBarItem;
var
I: Integer;
begin
Result := nil;
for I := 0 to Count - 1 do
if Items[I].Action = Action then
begin
Result := Items[I];
Break;
end;
end;
function TJvXPBarItems.Find(const DataObject: TObject): TJvXPBarItem;
var
I: Integer;
begin
Result := nil;
for I := 0 to Count - 1 do
if Items[I].DataObject = DataObject then
begin
Result := Items[I];
Break;
end;
end;
//=== { TJvXPBarVisibleItems } ===============================================
constructor TJvXPBarVisibleItems.Create(WinXPBar: TJvXPCustomWinXPBar);
begin
inherited Create;
FItems := TList.Create;
FWinXPBar := WinXPBar;
end;
destructor TJvXPBarVisibleItems.Destroy;
begin
FItems.Free;
inherited Destroy;
end;
function TJvXPBarVisibleItems.GetItem(Index: Integer): TJvXPBarItem;
begin
Result := nil;
if Index < FItems.Count then
Result := FItems[Index];
end;
function TJvXPBarVisibleItems.Count: Integer;
begin
Result := FItems.Count;
end;
function TJvXPBarVisibleItems.Exists(Item: TJvXPBarItem): Boolean;
var
I: Integer;
begin
Result := False;
for I := 0 to Count - 1 do
if Items[I] = Item then
begin
Result := True;
Break;
end;
end;
procedure TJvXPBarVisibleItems.Add(Item: TJvXPBarItem);
begin
if not Exists(Item) then
begin
FItems.Add(Item);
FWinXPBar.SortVisibleItems(False);
end;
end;
procedure TJvXPBarVisibleItems.Delete(Item: TJvXPBarItem);
begin
if Exists(Item) then
FItems.Delete(FItems.IndexOf(Item));
end;
//=== { TJvXPFadeThread } ====================================================
constructor TJvXPFadeThread.Create(WinXPBar: TJvXPCustomWinXPBar;
RollDirection: TJvXPBarRollDirection);
begin
inherited Create(True);
FWinXPBar := WinXPBar;
FRollDirection := RollDirection;
FreeOnTerminate := True;
Suspended := False;
end;
procedure TJvXPFadeThread.Execute;
var
NewOffset: Integer;
begin
while not Terminated do
try
FWinXPBar.FRolling := True;
{ calculate new roll offset }
if FRollDirection = rdCollapse then
NewOffset := FWinXPBar.RollOffset - FWinXPBar.FRollStep
else
NewOffset := FWinXPBar.RollOffset + FWinXPBar.FRollStep;
{ validate offset ranges }
if NewOffset < 0 then
NewOffset := 0;
if NewOffset > FWinXPBar.FItemHeight then
NewOffset := FWinXPBar.FItemHeight;
FWinXPBar.RollOffset := NewOffset;
{ terminate on 'out-of-range' }
if ((FRollDirection = rdCollapse) and (NewOffset = 0)) or
((FRollDirection = rdExpand) and (NewOffset = FWinXPBar.FItemHeight)) then
Terminate;
WakeUpGUIThread;
{ idle process }
Sleep(FWinXPBar.FRollDelay);
finally
FWinXPBar.FRolling := False;
end;
{ redraw button state }
FWinXPBar.FCollapsed := FRollDirection = rdCollapse;
if FWinXPBar.FShowRollButton then
FWinXPBar.InternalRedraw;
{ update inspector }
if csDesigning in FWinXPBar.ComponentState then
TCustomForm(FWinXPBar.Owner).DesignerHook.Modified
else
PostMessage(FWinXPBar.Handle, WM_XPBARAFTERCOLLAPSE,
Ord(FRollDirection = rdCollapse), 0);
WakeUpGUIThread;
end;
//=== { TJvXPBarColors } =====================================================
constructor TJvXPBarColors.Create;
begin
inherited Create;
// (rom) needs local color constants
FBodyColor := TColor($00F7DFD6);
FBorderColor := clWhite;
FGradientFrom := clWhite;
FGradientTo := TColor($00F7D7C6);
FSeparatorColor := TColor($00F7D7C6);
FCheckedColor := dxColor_CheckedColorXP;
FFocusedColor := dxColor_FocusedColorXP;
FCheckedFrameColor := dxColor_CheckedFrameColorXP;
FFocusedFrameColor := dxColor_FocusedFrameColorXP;
end;
procedure TJvXPBarColors.Assign(Source: TPersistent);
begin
if Source is TJvXPBarColors then
with TJvXPBarColors(Source) do
begin
Self.CheckedColor := CheckedColor;
Self.FocusedColor := FocusedColor;
Self.CheckedFrameColor := CheckedFrameColor;
Self.FocusedFrameColor := FocusedFrameColor;
Self.BodyColor := BodyColor;
Self.GradientTo := GradientTo;
Self.GradientFrom := GradientFrom;
Self.SeparatorColor := SeparatorColor;
end
else
inherited Assign(Source);
end;
procedure TJvXPBarColors.Change;
begin
if Assigned(FOnChange) then
FOnChange(Self);
end;
procedure TJvXPBarColors.SetBodyColor(const Value: TColor);
begin
if FBodyColor <> Value then
begin
FBodyColor := Value;
Change;
end;
end;
procedure TJvXPBarColors.SetGradientFrom(const Value: TColor);
begin
if FGradientFrom <> Value then
begin
FGradientFrom := Value;
Change;
end;
end;
procedure TJvXPBarColors.SetGradientTo(const Value: TColor);
begin
if FGradientTo <> Value then
begin
FGradientTo := Value;
Change;
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -