📄 jvqxpbar.pas
字号:
{******************************************************************************}
{* WARNING: JEDI VCL To CLX Converter generated unit. *}
{* Manual modifications will be lost on next release. *}
{******************************************************************************}
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvXPBar.PAS, released on 2004-01-01.
The Initial Developer of the Original Code is Marc Hoffman.
Portions created by Marc Hoffman are Copyright (C) 2002 APRIORI business solutions AG.
Portions created by APRIORI business solutions AG are Copyright (C) 2002 APRIORI business solutions AG
All Rights Reserved.
Contributor(s): dejoy
//dejoy 2004-4-20
--add GroupIndex,AutoCheck,Checked property in TJvXPBarItem.
--add GetItemClass in TJvXPBarItems.
--add GetBarItemsClass in TJvXPCustomWinXPBar.
Contributor(s): dierk schmid
//dierk 2004-4-23
--add property RoundedItemFrame in TJvXPCustomWinXPBar (Integer>0 is the edge radius)
--add property ItemFrameColor in TJvXPBarColors
//dejoy 2004-4-25
-- splitt ItemFrameColor to CheckedFrameColor , FocusedFrameColor in TJvXPBarColors.
Contributors(s): matej golob
//matej 2004-5-3
--add property BorderColor in TJvXPBarColors.
--add property HeaderRounded
--add property TopSpace
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvQXPBar.pas,v 1.34 2005/02/07 07:51:17 marquardt Exp $
unit JvQXPBar;
{$I jvcl.inc}
// sorry no theming as standalone
interface
uses
QWindows, Classes, SysUtils,
QGraphics, QControls, QForms, QExtCtrls, QImgList, QActnList, QMessages,
Qt, QTypes, JvQTypes,
JvQConsts,
JvQXPCore, JvQXPCoreUtils;
type
TJvXPBarRollDirection = (rdExpand, rdCollapse);
TJvXPBarRollMode = (rmFixed, rmShrink); // rmFixed is default
TJvXPBarHitTest =
(
htNone, // mouse is inside non-supported rect
htHeader, // mouse is inside header
htRollButton // mouse is inside rollbutton
);
TJvXPBarRollDelay = 1..200;
TJvXPBarRollStep = 1..50;
const
WM_XPBARAFTERCOLLAPSE = WM_USER + 303; // Ord('J') + Ord('V') + Ord('C') + Ord('L')
WM_XPBARAFTEREXPAND = WM_XPBARAFTERCOLLAPSE + 1;
{ color constants.
}
// dxColor_CheckedColorXP := TColor($00c9b4e2);
// dxColor_CheckedColorXP := TColor($00d9c1bb);
// dxColor_CheckedColorXP := TColor($00e8ccae);
dxColor_FocusedColorXP = TColor($00D8ACB0);
dxColor_CheckedColorXP = TColor($00D9C1BB);
clHotLight = clActiveHighlight;
dxColor_FocusedFrameColorXP = clHotLight;
dxColor_CheckedFrameColorXP = clHighlight;
type
TJvXPBarItem = class;
TJvXPBarItems = class;
TJvXPCustomWinXPBar = class;
TJvXPBarOnCanChangeEvent = procedure(Sender: TObject; Item: TJvXPBarItem;
var AllowChange: Boolean) of object;
TJvXPBarOnCollapsedChangeEvent = procedure(Sender: TObject;
Collapsing: Boolean) of object;
TJvXPBarOnDrawItemEvent = procedure(Sender: TObject; ACanvas: TCanvas;
Rect: TRect; State: TJvXPDrawState; Item: TJvXPBarItem; Bitmap: TBitmap) of object;
TJvXPBarOwnerDrawEvent = procedure(Sender: TObject; ACanvas: TCanvas; var ARect: TRect) of object;
TJvXPBarOnItemClickEvent = procedure(Sender: TObject; Item: TJvXPBarItem) of object;
TJvXPBarItemActionLink = class(TActionLink)
private
FClient: TJvXPBarItem;
protected
procedure AssignClient(AClient: TObject); override;
function IsCaptionLinked: Boolean; override;
function IsCheckedLinked: Boolean; override;
function IsEnabledLinked: Boolean; override;
function IsHintLinked: Boolean; override;
function IsImageIndexLinked: Boolean; override;
function IsVisibleLinked: Boolean; override;
function IsOnExecuteLinked: Boolean; override;
procedure SetCaption(const Value: TCaption); override;
procedure SetHint(const Value: WideString); override;
function DoShowHint(var HintStr: WideString): Boolean; virtual;
procedure SetChecked(Value: Boolean); override;
procedure SetEnabled(Value: Boolean); override;
procedure SetImageIndex(Value: Integer); override;
procedure SetVisible(Value: Boolean); override;
procedure SetOnExecute(Value: TNotifyEvent); override;
property Client: TJvXPBarItem read FClient write FClient;
end;
TJvXPBarItemActionLinkClass = class of TJvXPBarItemActionLink;
TJvXPBarItemClass = class of TJvXPBarItem;
TJvXPBarItem = class(TCollectionItem)
private
FActionLink: TJvXPBarItemActionLink;
FCollection: TJvXPBarItems;
FCaption: TCaption;
FData: Pointer;
FDataObject: TObject;
FEnabled: Boolean;
FHint: string;
FImageIndex: TImageIndex;
FImageList: TCustomImageList;
FName: string;
FWinXPBar: TJvXPCustomWinXPBar;
FTag: Integer;
FVisible: Boolean;
FOnClick: TNotifyEvent;
FOnDblClick: TNotifyEvent;
FGroupIndex: Integer;
FChecked: Boolean;
function IsCaptionStored: Boolean;
function IsEnabledStored: Boolean;
function IsHintStored: Boolean;
function IsImageIndexStored: Boolean;
function IsVisibleStored: Boolean;
function IsOnClickStored: Boolean;
function IsCheckedStored: Boolean;
function GetImages: TCustomImageList;
procedure DoActionChange(Sender: TObject);
procedure SetAction(Value: TBasicAction);
procedure SetCaption(Value: TCaption);
procedure SetEnabled(Value: Boolean);
procedure SetImageIndex(Value: TImageIndex);
procedure SetImageList(Value: TCustomImageList);
procedure SetName(const Value: string);
procedure SetVisible(Value: Boolean);
procedure SetGroupIndex(const Value: Integer);
procedure SetChecked(const Value: Boolean);
procedure TurnSiblingsOff;
protected
function GetActionLinkClass: TJvXPBarItemActionLinkClass; dynamic;
function GetAction: TBasicAction; virtual;
function GetDisplayName: string; override;
procedure Notification(AComponent: TComponent); virtual;
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); dynamic;
procedure DrawItem(AWinXPBar: TJvXPCustomWinXPBar; ACanvas: TCanvas;
Rect: TRect; State: TJvXPDrawState; ShowItemFrame: Boolean; Bitmap: TBitmap); virtual;
property ActionLink: TJvXPBarItemActionLink read FActionLink write FActionLink;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
property Data: Pointer read FData write FData;
property DataObject: TObject read FDataObject write FDataObject;
property Images: TCustomImageList read GetImages;
property WinXPBar: TJvXPCustomWinXPBar read FWinXPBar;
published
property Action: TBasicAction read GetAction write SetAction;
property Caption: TCaption read FCaption write SetCaption stored IsCaptionStored;
property Checked: Boolean read FChecked write SetChecked stored IsCheckedStored default False;
property Enabled: Boolean read FEnabled write SetEnabled stored IsEnabledStored default True;
property GroupIndex: Integer read FGroupIndex write SetGroupIndex default 0;
property Hint: string read FHint write FHint stored IsHintStored;
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex stored IsImageIndexStored default -1;
property ImageList: TCustomImageList read FImageList write SetImageList;
property Name: string read FName write SetName;
property Tag: Integer read FTag write FTag default 0;
property Visible: Boolean read FVisible write SetVisible stored IsVisibleStored default True;
property OnClick: TNotifyEvent read FOnClick write FOnClick stored IsOnClickStored;
property OnDblClick: TNotifyEvent read FOnDblClick write FOnDblClick;
end;
TJvXPBarItemsClass = class of TJvXPBarItems;
TJvXPBarItems = class(TCollection)
private
FWinXPBar: TJvXPCustomWinXPBar;
function GetItem(Index: Integer): TJvXPBarItem;
procedure SetItem(Index: Integer; Value: TJvXPBarItem);
protected
procedure Update(Item: TCollectionItem); override;
function GetOwner: TPersistent; override;
class function GetItemClass: TJvXPBarItemClass; virtual;
public
constructor Create(WinXPBar: TJvXPCustomWinXPBar);
function Add: TJvXPBarItem; overload;
function Add(Action: TBasicAction): TJvXPBarItem; overload;
function Add(DataObject: TObject): TJvXPBarItem; overload;
function Insert(Index: Integer): TJvXPBarItem; overload;
function Insert(Index: Integer; Action: TBasicAction): TJvXPBarItem; overload;
function Insert(Index: Integer; DataObject: TObject): TJvXPBarItem; overload;
function Find(const AName: string): TJvXPBarItem; overload;
function Find(const Action: TBasicAction): TJvXPBarItem; overload;
function Find(const DataObject: TObject): TJvXPBarItem; overload;
property Items[Index: Integer]: TJvXPBarItem read GetItem write SetItem; default;
end;
TJvXPBarVisibleItems = class(TPersistent)
private
FItems: TList;
FWinXPBar: TJvXPCustomWinXPBar;
function Exists(Item: TJvXPBarItem): Boolean;
function GetItem(Index: Integer): TJvXPBarItem;
procedure Add(Item: TJvXPBarItem);
procedure Delete(Item: TJvXPBarItem);
public
constructor Create(WinXPBar: TJvXPCustomWinXPBar);
destructor Destroy; override;
function Count: Integer;
property Items[Index: Integer]: TJvXPBarItem read GetItem; default;
end;
TJvXPFadeThread = class(TThread)
private
FWinXPBar: TJvXPCustomWinXPBar;
FRollDirection: TJvXPBarRollDirection;
public
constructor Create(WinXPBar: TJvXPCustomWinXPBar; RollDirection: TJvXPBarRollDirection);
procedure Execute; override;
end;
TJvXPBarColors = class(TPersistent)
private
FCheckedFrameColor: TColor;
FFocusedFrameColor: TColor;
FCheckedColor: TColor;
FFocusedColor: TColor;
FBodyColor: TColor;
FGradientTo: TColor;
FGradientFrom: TColor;
FSeparatorColor: TColor;
FBorderColor: TColor;
FOnChange: TNotifyEvent;
procedure SetBorderColor(const Value: TColor);
procedure SetBodyColor(const Value: TColor);
procedure SetGradientFrom(const Value: TColor);
procedure SetGradientTo(const Value: TColor);
procedure SetSeparatorColor(const Value: TColor);
procedure SetCheckedColor(const Value: TColor);
procedure SetFocusedColor(const Value: TColor);
procedure SetCheckedFrameColor(const Value: TColor);
procedure SetFocusedFrameColor(const Value: TColor);
public
constructor Create;
procedure Assign(Source: TPersistent); override;
procedure Change;
published
property BorderColor: TColor read FBorderColor write SetBorderColor default clWhite;
property CheckedColor: TColor read FCheckedColor write SetCheckedColor default dxColor_CheckedColorXP;
property FocusedColor: TColor read FFocusedColor write SetFocusedColor default dxColor_FocusedColorXP;
property CheckedFrameColor: TColor read FCheckedFrameColor write SetCheckedFrameColor default dxColor_CheckedFrameColorXP;
property FocusedFrameColor: TColor read FFocusedFrameColor write SetFocusedFrameColor default dxColor_FocusedFrameColorXP;
property BodyColor: TColor read FBodyColor write SetBodyColor default TColor($00F7DFD6);
property GradientFrom: TColor read FGradientFrom write SetGradientFrom default clWhite;
property GradientTo: TColor read FGradientTo write SetGradientTo default TColor($00F7D7C6);
property SeparatorColor: TColor read FSeparatorColor write SetSeparatorColor default TColor($00F7D7C6);
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
TJvXPBarOptions = class(TPersistent)
end;
TJvXPCustomWinXPBar = class(TJvXPCustomControl)
private
FCollapsed: Boolean;
FFadeThread: TJvXPFadeThread;
FFont: TFont;
FFontChanging: Boolean;
FGradient: TBitmap;
FGradientWidth: Integer;
FHeaderFont: TFont;
FHeaderRounded: Boolean;
FHitTest: TJvXPBarHitTest;
FHotTrack: Boolean;
FHoverIndex: Integer;
FIcon: TIcon;
FImageList: TCustomImageList;
FItemHeight: Integer;
FItems: TJvXPBarItems;
FRollDelay: TJvXPBarRollDelay;
FRolling: Boolean;
FRollMode: TJvXPBarRollMode;
FRollOffset: Integer;
FRollStep: TJvXPBarRollStep;
FShowLinkCursor: Boolean;
FShowRollButton: Boolean;
FHotTrackColor: TColor;
FVisibleItems: TJvXPBarVisibleItems;
FAfterCollapsedChange: TJvXPBarOnCollapsedChangeEvent;
FBeforeCollapsedChange: TJvXPBarOnCollapsedChangeEvent;
FOnCollapsedChange: TJvXPBarOnCollapsedChangeEvent;
FOnCanChange: TJvXPBarOnCanChangeEvent;
FOnDrawItem: TJvXPBarOnDrawItemEvent;
FOnItemClick: TJvXPBarOnItemClickEvent;
FColors: TJvXPBarColors;
FRollImages: TCustomImageList;
FImageChangeLink: TChangeLink;
FRollChangeLink: TChangeLink;
FGrouped: Boolean;
FHeaderHeight: Integer;
FStoredHint: string;
FShowItemFrame: Boolean;
FRoundedItemFrame: Integer; // DS
FTopSpace: Integer;
FOwnerDraw: Boolean;
FOnDrawBackground: TJvXPBarOwnerDrawEvent;
FOnDrawHeader: TJvXPBarOwnerDrawEvent;
function IsFontStored: Boolean;
procedure FontChange(Sender: TObject);
procedure SetCollapsed(Value: Boolean);
procedure SetFont(Value: TFont);
procedure SetHeaderFont(Value: TFont);
procedure SetHotTrack(Value: Boolean);
procedure SetHotTrackColor(Value: TColor);
procedure SetIcon(Value: TIcon);
procedure SetImageList(Value: TCustomImageList);
procedure SetItemHeight(Value: Integer);
procedure SetItems(Value: TJvXPBarItems);
procedure SetRollOffset(const Value: Integer);
procedure SetShowRollButton(Value: Boolean);
procedure ResizeToMaxHeight;
procedure SetColors(const Value: TJvXPBarColors);
procedure SetRollImages(const Value: TCustomImageList);
procedure SetGrouped(const Value: Boolean);
procedure GroupMessage;
procedure SetHeaderHeight(const Value: Integer);
function GetRollHeight: Integer;
function GetRollWidth: Integer;
procedure SetHeaderRounded(const Value: Boolean);
procedure SetTopSpace(const Value: Integer);
procedure SetOwnerDraw(const Value: Boolean);
protected
function WantKey(Key: Integer; Shift: TShiftState;
const KeyText: WideString): Boolean; override;
class function GetBarItemsClass: TJvXPBarItemsClass; virtual;
function GetHitTestRect(const HitTest: TJvXPBarHitTest): TRect;
function GetItemRect(Index: Integer): TRect; virtual;
procedure ItemVisibilityChanged(Item: TJvXPBarItem); dynamic;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure HookMouseDown; override;
procedure HookMouseEnter; override;
procedure HookMouseLeave; override;
procedure HookMouseMove(X: Integer = 0; Y: Integer = 0); override;
procedure HookParentFontChanged; override;
procedure HookResized; override;
procedure SortVisibleItems(const Redraw: Boolean);
procedure DoColorsChange(Sender: TObject);
procedure DoDrawItem(const Index: Integer; State: TJvXPDrawState); virtual;
procedure Paint; override;
procedure EndUpdate; override;
procedure WMAfterXPBarCollapse(var Msg: TMessage); message WM_XPBARAFTERCOLLAPSE;
procedure WMAfterXPBarExpand(var Msg: TMessage); message WM_XPBARAFTEREXPAND;
property Collapsed: Boolean read FCollapsed write SetCollapsed default False;
property Colors: TJvXPBarColors read FColors write SetColors;
property RollImages: TCustomImageList read FRollImages write SetRollImages;
property Font: TFont read FFont write SetFont stored IsFontStored;
property Grouped: Boolean read FGrouped write SetGrouped default False;
property HeaderFont: TFont read FHeaderFont write SetHeaderFont stored IsFontStored;
property HeaderHeight: Integer read FHeaderHeight write SetHeaderHeight default 28;
property HeaderRounded: Boolean read FHeaderRounded write SetHeaderRounded default True;
property OwnerDraw: Boolean read FOwnerDraw write SetOwnerDraw;
property HotTrack: Boolean read FHotTrack write SetHotTrack default True;
property HotTrackColor: TColor read FHotTrackColor write SetHotTrackColor default $00FF7C35;
property Icon: TIcon read FIcon write SetIcon;
property ImageList: TCustomImageList read FImageList write SetImageList;
property ItemHeight: Integer read FItemHeight write SetItemHeight default 20;
property Items: TJvXPBarItems read FItems write SetItems;
property RollDelay: TJvXPBarRollDelay read FRollDelay write FRollDelay default 25;
property Rolling: Boolean read FRolling default False;
property RollMode: TJvXPBarRollMode read FRollMode write FRollMode default rmShrink;
property RollOffset: Integer read FRollOffset write SetRollOffset;
property RollStep: TJvXPBarRollStep read FRollStep write FRollStep default 3;
property ShowLinkCursor: Boolean read FShowLinkCursor write FShowLinkCursor default True;
property ShowRollButton: Boolean read FShowRollButton write SetShowRollButton default True;
property ShowItemFrame: Boolean read FShowItemFrame write FShowItemFrame;
property RoundedItemFrame: Integer read FRoundedItemFrame write FRoundedItemFrame default 1; //DS
property TopSpace: Integer read FTopSpace write SetTopSpace default 5;
// (rom) this name is not acceptable. Prefix with "On"
property AfterCollapsedChange: TJvXPBarOnCollapsedChangeEvent read FAfterCollapsedChange write
FAfterCollapsedChange;
property BeforeCollapsedChange: TJvXPBarOnCollapsedChangeEvent read FBeforeCollapsedChange write
FBeforeCollapsedChange;
property OnCollapsedChange: TJvXPBarOnCollapsedChangeEvent read FOnCollapsedChange write FOnCollapsedChange;
property OnCanChange: TJvXPBarOnCanChangeEvent read FOnCanChange write FOnCanChange;
property OnDrawItem: TJvXPBarOnDrawItemEvent read FOnDrawItem write FOnDrawItem;
property OnDrawBackground: TJvXPBarOwnerDrawEvent read FOnDrawBackground write FOnDrawBackground;
property OnDrawHeader: TJvXPBarOwnerDrawEvent read FOnDrawHeader write FOnDrawHeader;
property OnItemClick: TJvXPBarOnItemClickEvent read FOnItemClick write FOnItemClick;
procedure AdjustClientRect(var Rect: TRect); override;
// show hints for individual items in the list
function HintShow(var HintInfo: THintInfo): Boolean; override;
procedure DblClick; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetHitTestAt(X, Y: Integer): TJvXPBarHitTest;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -