⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tntjvpanel.pas

📁 TntExUpdate 是 流行的 TntUnicodeControls控件的扩展包.包括很难找到的 TntJVCL 也在里面. TntSysUtils2.pas/TntSysUtilsEx.pa
💻 PAS
📖 第 1 页 / 共 3 页
字号:
{-----------------------------------------------------------------------------
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: JvPanel.pas, released on 2001-02-28.

The Initial Developer of the Original Code is Sébastien Buysse [sbuysse att buypin dott com]
Portions created by Sébastien Buysse are Copyright (C) 2001 Sébastien Buysse.
All Rights Reserved.

Contributor(s):
Michael Beck [mbeck att bigfoot dott com].
pongtawat
Peter Thornqvist [peter3 at sourceforge dot net]
Jens Fudickar [jens dott fudickar att oratool dott de]
dejoy den [dejoy att ynl dott gov dott cn]

Changes:

>> dejoy --2005-04-28
  - Change TJvArrangeSettings to inherited from TJvPersistentProperty.
  - TTntJvCustomArrangePanel implemented interface of IJvHotTrack.
  - Renamed HotColor property to HotTrackOptions.Color.

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: JvPanel.pas,v 1.63 2005/09/15 10:19:43 marquardt Exp $

unit TntJvPanel;

{$I jvcl.inc}

interface

uses
  {$IFDEF UNITVERSIONING}
  JclUnitVersioning,
  {$ENDIF UNITVERSIONING}
  Windows, TntWindows, Messages,
  SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
  {$IFDEF VisualCLX}
  Qt,
  {$ENDIF VisualCLX}
  JvPanel, JvTypes, JvThemes, JvComponent, TntJvComponent, JvExControls, TntJvExControls;

type
  (**
  TJvPanelResizeParentEvent = procedure(Sender: TObject; nLeft, nTop, nWidth, nHeight: Integer) of object;
  TJvPanelChangedSizeEvent = procedure(Sender: TObject; ChangedSize: Integer) of object;
  TJvAutoSizePanel = (asNone, asWidth, asHeight, asBoth);

  TJvArrangeSettings = class(TJvPersistentProperty)
  private
    FAutoArrange: Boolean;
    FAutoSize: TJvAutoSizePanel;
    FWrapControls: Boolean;
    FBorderLeft: Integer;
    FBorderTop: Integer;
    FDistanceVertical: Integer;
    FDistanceHorizontal: Integer;
    FShowNotVisibleAtDesignTime: Boolean;
    FMaxWidth: Integer;
    procedure SetWrapControls(Value: Boolean);
    procedure SetAutoArrange(Value: Boolean);
    procedure SetAutoSize(Value: TJvAutoSizePanel);
    procedure SetBorderLeft(Value: Integer);
    procedure SetBorderTop(Value: Integer);
    procedure SetDistanceVertical(Value: Integer);
    procedure SetDistanceHorizontal(Value: Integer);
    procedure SetMaxWidth(Value: Integer);
  public
    constructor Create; virtual;
    procedure Assign(Source: TPersistent); override;
  published
    property WrapControls: Boolean read FWrapControls write SetWrapControls default True;
    property BorderLeft: Integer read FBorderLeft write SetBorderLeft default 0;
    property BorderTop: Integer read FBorderTop write SetBorderTop default 0;
    property DistanceVertical: Integer read FDistanceVertical write SetDistanceVertical default 0;
    property DistanceHorizontal: Integer read FDistanceHorizontal write SetDistanceHorizontal default 0;
    property ShowNotVisibleAtDesignTime: Boolean read FShowNotVisibleAtDesignTime write FShowNotVisibleAtDesignTime default True;
    property AutoSize: TJvAutoSizePanel read FAutoSize write SetAutoSize default asNone;
    property AutoArrange: Boolean read FAutoArrange write SetAutoArrange default False;
    property MaxWidth: Integer read FMaxWidth write SetMaxWidth default 0;
  end;

  TJvPanelHotTrackOptions = class(TJvHotTrackOptions)
  public
    constructor Create; override;
  published
    property Color default clBtnFace;
  end;

  TJvPanelMoveEvent = procedure(Sender: TObject; X, Y: Integer; var Allow: Boolean) of object;
  ***)

  TTntJvCustomArrangePanel = class(TTntJvCustomPanel, IJvDenySubClassing, IJvHotTrack)
  private
    FTransparent: Boolean;
    FFlatBorder: Boolean;
    FFlatBorderColor: TColor;
    FMultiLine: Boolean;
    FSizeable: Boolean;
    FDragging: Boolean;
    FLastPos: TPoint;
    FArrangeSettings: TJvArrangeSettings;
    FEnableArrangeCount: Integer;
    FArrangeControlActive: Boolean;
    FArrangeWidth: Integer;
    FArrangeHeight: Integer;
    FOnResizeParent: TJvPanelResizeParentEvent;
    FOnChangedWidth: TJvPanelChangedSizeEvent;
    FOnChangedHeight: TJvPanelChangedSizeEvent;
    FOnPaint: TNotifyEvent;
    FMovable: Boolean;
    FWasMoved: Boolean;
    FOnAfterMove: TNotifyEvent;
    FOnBeforeMove: TJvPanelMoveEvent;
    FHotTrack: Boolean;
    FHotTrackFont: TFont;
    FHotTrackFontOptions: TJvTrackFontOptions;
    FHotTrackOptions: TJvHotTrackOptions;
    {$IFDEF VisualCLX}
    FMoving: Boolean;
    FGripBmp: TBitmap;
    procedure CreateSizeGrip;
    function GetFrameWidth: Integer;
    function IsInsideGrip(X, Y: Integer): Boolean;
    {$ENDIF VisualCLX}
    function GetHeight: Integer;
    procedure SetHeight(Value: Integer);
    function GetWidth: Integer;
    procedure SetWidth(Value: Integer);
    procedure SetArrangeSettings(Value: TJvArrangeSettings);
    procedure SetTransparent(const Value: Boolean);
    procedure SetFlatBorder(const Value: Boolean);
    procedure SetFlatBorderColor(const Value: TColor);
    procedure SetMultiLine(const Value: Boolean);
    procedure SetSizeable(const Value: Boolean);

    {IJvHotTrack}   //added by dejoy 2005-04-28
    function GetHotTrack: Boolean;
    function GetHotTrackFont: TFont;
    function GetHotTrackFontOptions: TJvTrackFontOptions;
    function GetHotTrackOptions: TJvHotTrackOptions;
    procedure SetHotTrack(Value: Boolean);
    procedure SetHotTrackFont(Value: TFont);
    procedure SetHotTrackFontOptions(Value: TJvTrackFontOptions);
    procedure SetHotTrackOptions(Value: TJvHotTrackOptions);
  protected
    procedure DrawCaption; dynamic;
    procedure DrawCaptionTo(ACanvas: TCanvas {$IFDEF VisualCLX}; DrawingMask: Boolean = False {$ENDIF}); dynamic;
    procedure DrawBorders; dynamic;

    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
    procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    procedure MouseEnter(Control: TControl); override;
    procedure MouseLeave(Control: TControl); override;
    procedure ParentColorChanged; override;
    procedure TextChanged; override;
    procedure Paint; override;
    function DoEraseBackground(Canvas: TCanvas; Param: Integer): Boolean; override;
    {$IFDEF VCL}
    procedure AdjustSize; override;
    procedure CreateParams(var Params: TCreateParams); override;
    procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
    procedure WMExitSizeMove(var Msg: TMessage); message WM_EXITSIZEMOVE;
    {$ENDIF VCL}
    function DoBeforeMove(X, Y: Integer): Boolean; dynamic;
    procedure DoAfterMove; dynamic;
    {$IFDEF VisualCLX}
    procedure DrawMask(ACanvas: TCanvas); override;
    {$ENDIF VisualCLX}
    procedure Loaded; override;
    procedure Resize; override;
    procedure Rearrange;
    procedure DoArrangeSettingsPropertyChanged(Sender: TObject; const PropName: string); virtual;
    procedure AlignControls(AControl: TControl; var Rect: TRect); override;
    function GetNextControlByTabOrder(ATabOrder: Integer): TWinControl;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Invalidate; override;
    procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
    procedure ArrangeControls;
    procedure EnableArrange;
    procedure DisableArrange;
    function ArrangeEnabled: Boolean;
    property ArrangeWidth: Integer read FArrangeWidth;
    property ArrangeHeight: Integer read FArrangeHeight;
    {$IFDEF VCL}
    property DockManager;
    {$ENDIF VCL}
    property Canvas;

    property HotTrack: Boolean read GetHotTrack write SetHotTrack default False;
    property HotTrackFont: TFont read GetHotTrackFont write SetHotTrackFont;
    property HotTrackFontOptions: TJvTrackFontOptions read GetHotTrackFontOptions write SetHotTrackFontOptions default
      DefaultTrackFontOptions;
    property HotTrackOptions: TJvHotTrackOptions read GetHotTrackOptions write SetHotTrackOptions;

    property Movable: Boolean read FMovable write FMovable default False;
    property Sizeable: Boolean read FSizeable write SetSizeable default False;
    property Transparent: Boolean read FTransparent write SetTransparent default False;
    property MultiLine: Boolean read FMultiLine write SetMultiLine default False;
    //FlatBorder used the BorderWidth to draw the border
    property FlatBorder: Boolean read FFlatBorder write SetFlatBorder default False;
    property FlatBorderColor: TColor read FFlatBorderColor write SetFlatBorderColor default clBtnShadow;
    property OnBeforeMove: TJvPanelMoveEvent read FOnBeforeMove write FOnBeforeMove;
    property OnAfterMove: TNotifyEvent Read FOnAfterMove write FOnAfterMove;
    property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;

    property ArrangeSettings: TJvArrangeSettings read FArrangeSettings write SetArrangeSettings;
    property Width: Integer read GetWidth write SetWidth;
    property Height: Integer read GetHeight write SetHeight;
    property OnResizeParent: TJvPanelResizeParentEvent read FOnResizeParent write FOnResizeParent;
    property OnChangedWidth: TJvPanelChangedSizeEvent read FOnChangedWidth write FOnChangedWidth;
    property OnChangedHeight: TJvPanelChangedSizeEvent read FOnChangedHeight write FOnChangedHeight;
  end;

  TTntJvPanel = class(TTntJvCustomArrangePanel)
  private
    FFilerTag: string;
    procedure ReadData(Reader: TReader);
  protected
    procedure DefineProperties(Filer: TFiler); override;
  published
    property HotTrack;
    property HotTrackFont;
    property HotTrackFontOptions;
    property HotTrackOptions;

    property Movable;
    property Sizeable;
    property HintColor;
    property Transparent;
    property MultiLine;
    property FlatBorder;
    property FlatBorderColor;
    property OnMouseEnter;
    property OnMouseLeave;
    property OnBeforeMove;
    property OnAfterMove;
    property OnParentColorChange;
    property OnPaint;

    property ArrangeSettings;
    property Width;
    property Height;
    property OnResizeParent;
    property OnChangedWidth;
    property OnChangedHeight;

    property Align;
    property Alignment;
    property Anchors;
    {$IFDEF VCL}
    property AutoSize;
    property BiDiMode;
    property UseDockManager default True;
    property DockSite;
    property DragCursor;
    property DragKind;
    property FullRepaint;
    property Locked;
    property ParentBiDiMode;
    property OnCanResize;
    property OnDockDrop;
    property OnDockOver;
    property OnEndDock;
    property OnGetSiteInfo;
    property OnStartDock;
    property OnUnDock;
    {$ENDIF VCL}
    property BevelInner;
    property BevelOuter;
    property BevelWidth;
    property BorderWidth;
    property BorderStyle;
    property Caption;
    property Color;
    property Constraints;
    property DragMode;
    property Enabled;
    property Font;
    {$IFDEF JVCLThemesEnabled}
    property ParentBackground default True;
    {$ENDIF JVCLThemesEnabled}
    property ParentColor;
    property ParentFont;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property TabOrder;
    property TabStop;
    property Visible;
    property OnClick;
    property OnConstrainedResize;
    property OnContextPopup;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnEnter;
    property OnExit;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnResize;
    property OnStartDrag;
  end;

{$IFDEF UNITVERSIONING}
const
  UnitVersioning: TUnitVersionInfo = (
    RCSfile: '$RCSfile: JvPanel.pas,v $';
    Revision: '$Revision: 1.63 $';
    Date: '$Date: 2005/09/15 10:19:43 $';
    LogPath: 'JVCL'run'
  );
{$ENDIF UNITVERSIONING}

implementation

uses
  {$IFDEF HAS_UNIT_TYPES}
  Types,
  {$ENDIF HAS_UNIT_TYPES}
  JvJCLUtils, JvJVCLUtils;

const
  BkModeTransparent = TRANSPARENT;

function IsThemed: Boolean;
begin
  {$IFDEF JVCLThemesEnabled}
  Result := ThemeServices.ThemesEnabled;
  {$ELSE}
  Result := False;
  {$ENDIF JVCLThemesEnabled}
end;

(***
//=== { TJvArrangeSettings } =================================================

constructor TJvArrangeSettings.Create();
begin
  inherited Create;
  FMaxWidth := 0;
  FBorderLeft := 0;
  FBorderTop := 0;
  FDistanceVertical := 0;
  FDistanceHorizontal := 0;
  WrapControls := True;
  ShowNotVisibleAtDesignTime := True;
  FAutoSize := asNone;
  AutoArrange := False;
end;

procedure TJvArrangeSettings.SetWrapControls(Value: Boolean);
begin
  if Value <> FWrapControls then
  begin
    Changing;
    ChangingProperty('WrapControls');
    FWrapControls := Value;
    ChangedProperty('WrapControls');
    Changed;
  end;
end;

procedure TJvArrangeSettings.SetAutoArrange(Value: Boolean);
begin
  if Value <> FAutoArrange then
  begin
    Changing;
    ChangingProperty('AutoArrange');
    FAutoArrange := Value;
    ChangedProperty('AutoArrange');
    Changed;
  end;
end;

procedure TJvArrangeSettings.SetAutoSize(Value: TJvAutoSizePanel);
begin
  if Value <> FAutoSize then
  begin
    Changing;
    ChangingProperty('AutoSize');
    FAutoSize := Value;
    ChangedProperty('AutoSize');
    Changed;
  end;
end;

procedure TJvArrangeSettings.SetBorderLeft(Value: Integer);
begin
  if Value <> FBorderLeft then
  begin
    Changing;
    ChangingProperty('BorderLeft');
    FBorderLeft := Value;
    ChangedProperty('BorderLeft');
    Changed;
  end;
end;

procedure TJvArrangeSettings.SetBorderTop(Value: Integer);
begin
  if Value <> FBorderTop then
  begin
    Changing;
    ChangingProperty('BorderTop');
    FBorderTop := Value;
    ChangedProperty('BorderTop');
    Changed;
  end;
end;

procedure TJvArrangeSettings.SetDistanceVertical(Value: Integer);
begin
  if Value <> FDistanceVertical then
  begin
    Changing;
    ChangingProperty('DistanceVertical');
    FDistanceVertical := Value;
    ChangedProperty('DistanceVertical');
    Changed;
  end;
end;

procedure TJvArrangeSettings.SetDistanceHorizontal(Value: Integer);
begin
  if Value <> FDistanceHorizontal then
  begin
    Changing;
    ChangingProperty('DistanceHorizontal');
    FDistanceHorizontal := Value;
    ChangedProperty('DistanceHorizontal');
    Changed;
  end;
end;

procedure TJvArrangeSettings.SetMaxWidth(Value: Integer);
begin
  if Value <> FMaxWidth then
  begin
    Changing;
    ChangingProperty('MaxWidth');
    FMaxWidth := Value;
    ChangedProperty('MaxWidth');
    Changed;
  end;
end;

procedure TJvArrangeSettings.Assign(Source: TPersistent);
var
  A: TJvArrangeSettings;
begin
  if Source is TJvArrangeSettings then
  begin
    BeginUpdate;
    try
      A := TJvArrangeSettings(Source);
      AutoArrange := A.AutoArrange;
      AutoSize := A.AutoSize;
      WrapControls := A.WrapControls;
      BorderLeft := A.BorderLeft;
      BorderTop := A.BorderTop;
      DistanceVertical := A.DistanceVertical;
      DistanceHorizontal := A.DistanceHorizontal;
      ShowNotVisibleAtDesignTime := A.ShowNotVisibleAtDesignTime;
      MaxWidth := A.MaxWidth;
    finally
      EndUpdate;
    end;
  end
  else
    inherited Assign(Source);
end;

//=== { TJvPanelHotTrackOptions } ===========================================================

constructor TJvPanelHotTrackOptions.Create;
begin
  inherited;
  Color := clBtnFace;
end;
***)
//=== { TTntJvCustomArrangePanel } ===========================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -