📄 jvqpanel.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: JvPanel.pas, released on 2001-02-28.
The Initial Developer of the Original Code is S閎astien Buysse [sbuysse att buypin dott com]
Portions created by S閎astien Buysse are Copyright (C) 2001 S閎astien 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]
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: JvQPanel.pas,v 1.26 2005/02/06 14:06:16 asnepvangers Exp $
unit JvQPanel;
{$I jvcl.inc}
interface
uses
QWindows, QMessages,
SysUtils, Classes, QGraphics, QControls, QForms, QExtCtrls,
Qt,
JvQThemes, JvQComponent, JvQExControls, JvQJCLUtils;
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);
TJvPanel = class;
TJvArrangeSettings = class(TPersistent)
private
FPanel: TJvPanel;
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);
procedure Rearrange;
public
constructor Create(APanel: TJvPanel);
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;
TJvPanelMoveEvent = procedure(Sender: TObject; X, Y: Integer; var Allow: Boolean) of object;
TJvPanel = class(TJvCustomPanel, IJvDenySubClassing)
private
FTransparent: Boolean;
FFlatBorder: Boolean;
FFlatBorderColor: TColor;
FMultiLine: Boolean;
FOldColor: TColor;
FHotColor: TColor;
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;
FMoving: Boolean;
FGripBmp: TBitmap;
procedure CreateSizeGrip;
function GetFrameWidth: Integer;
function IsInsideGrip(X, Y: Integer): Boolean;
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 DrawCaption;
procedure DrawCaptionTo(ACanvas: TCanvas ; DrawingMask: Boolean = False );
procedure DrawBorders;
procedure SetMultiLine(const Value: Boolean);
procedure SetHotColor(const Value: TColor);
procedure SetSizeable(const Value: Boolean);
protected
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 DoPaintBackground(Canvas: TCanvas; Param: Integer): Boolean; override;
function DoBeforeMove(X, Y: Integer): Boolean; dynamic;
procedure DoAfterMove; dynamic;
procedure DrawMask(ACanvas: TCanvas); override;
procedure Loaded; override;
procedure Resize; override;
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;
property Canvas;
published
property Movable: Boolean read FMovable write FMovable default False;
property Sizeable: Boolean read FSizeable write SetSizeable default False;
property HintColor;
property HotColor: TColor read FHotColor write SetHotColor default clBtnFace;
property Transparent: Boolean read FTransparent write SetTransparent default False;
property MultiLine: Boolean read FMultiLine write SetMultiLine;
property FlatBorder: Boolean read FFlatBorder write SetFlatBorder default False;
property FlatBorderColor: TColor read FFlatBorderColor write SetFlatBorderColor default clBtnShadow;
property OnMouseEnter;
property OnMouseLeave;
property OnBeforeMove: TJvPanelMoveEvent read FOnBeforeMove write FOnBeforeMove;
property OnAfterMove: TNotifyEvent Read FOnAfterMove write FOnAfterMove;
property OnParentColorChange;
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;
property Align;
property Alignment;
property Anchors;
property BevelInner;
property BevelOuter;
property BevelWidth;
property BorderWidth;
property BorderStyle;
property Caption;
property Color;
property Constraints;
property DragMode;
property Enabled;
property Font;
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;
implementation
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
Types,
JvQMouseTimer;
const
BkModeTransparent = TRANSPARENT;
function IsThemed: Boolean;
begin
Result := False;
end;
//=== { TJvArrangeSettings } =================================================
constructor TJvArrangeSettings.Create(APanel: TJvPanel);
begin
inherited Create;
FPanel := APanel;
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
FWrapControls := Value;
Rearrange;
end;
end;
procedure TJvArrangeSettings.SetAutoArrange(Value: Boolean);
begin
if Value <> FAutoArrange then
begin
FAutoArrange := Value;
if Value then
Rearrange;
end;
end;
procedure TJvArrangeSettings.SetAutoSize(Value: TJvAutoSizePanel);
begin
if Value <> FAutoSize then
begin
FAutoSize := Value;
if AutoSize <> asNone then
Rearrange;
end;
end;
procedure TJvArrangeSettings.SetBorderLeft(Value: Integer);
begin
if Value <> FBorderLeft then
begin
FBorderLeft := Value;
Rearrange;
end;
end;
procedure TJvArrangeSettings.SetBorderTop(Value: Integer);
begin
if Value <> FBorderTop then
begin
FBorderTop := Value;
Rearrange;
end;
end;
procedure TJvArrangeSettings.SetDistanceVertical(Value: Integer);
begin
if Value <> FDistanceVertical then
begin
FDistanceVertical := Value;
Rearrange;
end;
end;
procedure TJvArrangeSettings.SetDistanceHorizontal(Value: Integer);
begin
if Value <> FDistanceHorizontal then
begin
FDistanceHorizontal := Value;
Rearrange;
end;
end;
procedure TJvArrangeSettings.SetMaxWidth(Value: Integer);
begin
if Value <> FMaxWidth then
begin
FMaxWidth := Value;
Rearrange;
end;
end;
procedure TJvArrangeSettings.Assign(Source: TPersistent);
var
A: TJvArrangeSettings;
begin
if Source is TJvArrangeSettings then
begin
A := TJvArrangeSettings(Source);
FAutoArrange := A.AutoArrange;
FAutoSize := A.AutoSize;
FWrapControls := A.WrapControls;
FBorderLeft := A.BorderLeft;
FBorderTop := A.BorderTop;
FDistanceVertical := A.DistanceVertical;
FDistanceHorizontal := A.DistanceHorizontal;
FShowNotVisibleAtDesignTime := A.ShowNotVisibleAtDesignTime;
FMaxWidth := A.MaxWidth;
Rearrange;
end
else
inherited Assign(Source);
end;
procedure TJvArrangeSettings.Rearrange;
begin
if (FPanel <> nil) and AutoArrange and
not (csLoading in FPanel.ComponentState) then
FPanel.ArrangeControls;
end;
//=== { TJvPanel } ===========================================================
constructor TJvPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FTransparent := False;
FFlatBorder := False;
FFlatBorderColor := clBtnShadow;
FHotColor := clBtnFace;
FArrangeSettings := TJvArrangeSettings.Create(Self);
end;
destructor TJvPanel.Destroy;
begin
FArrangeSettings.Free;
FreeAndNil(FGripBmp);
inherited Destroy;
end;
function TJvPanel.DoBeforeMove(X,Y: Integer): Boolean;
begin
Result := True;
if Assigned(FOnBeforeMove) then
FOnBeforeMove(Self, X, Y, Result);
end;
procedure TJvPanel.DoAfterMove;
begin
if Assigned(FOnAfterMove) then
FOnAfterMove(Self);
end;
function TJvPanel.GetFrameWidth: Integer;
begin
if FFlatBorder then
Result := 1
else
begin
Result := BorderWidth ; //Total Width of BevelInner and Outer;
if BevelOuter <> bvNone then
Inc(Result, BevelWidth);
if BevelInner <> bvNone then
Inc(Result, BevelWidth);
end;
end;
function TJvPanel.IsInsideGrip(X, Y: Integer): Boolean;
var
R: TRect;
I: Integer;
begin
I := GetFrameWidth;
R := Bounds(Width - 12 - I, Height - 12 - I, 12, 12);
Result := QWindows.PtInRect(R, X, Y);
end;
procedure TJvPanel.DrawMask(ACanvas: TCanvas);
var
R: TRect;
I, J, X, Y: Integer;
begin
inherited DrawMask(ACanvas);
ACanvas.Brush.Style := bsClear;
ACanvas.Pen.Color := clDontMask;
R := Bounds(0, 0, Width, Height);
I := GetFrameWidth;
for J := 0 to I do
begin
ACanvas.Rectangle(R);
InflateRect(R, -1, -1)
end;
DrawCaptionTo(ACanvas, True);
if Sizeable then
begin
X := ClientWidth - FGripBmp.Width - I;
Y := ClientHeight - FGripBmp.Height - I;
for I := 0 to 2 do
for J := 0 to 2 do
begin
ACanvas.MoveTo(X + 4 * I + J, Y + FGripBmp.Height);
ACanvas.LineTo(X + FGripBmp.Width, Y + 4 * I + J);
end
end;
end;
procedure TJvPanel.Paint;
var
X, Y: Integer;
I: Integer;
begin
if Assigned(FOnPaint) then
begin
FOnPaint(Self);
Exit;
end;
Canvas.Brush.Color := Color;
if not Transparent or IsThemed then
DrawThemedBackground(Self, Canvas, ClientRect)
else
Canvas.Brush.Style := bsClear;
if FFlatBorder then
begin
Canvas.Brush.Color := FFlatBorderColor;
FrameRect(Canvas, ClientRect);
Canvas.Brush.Color := Color;
end
else
DrawBorders;
Self.DrawCaption;
if Sizeable then
with Canvas do
begin
I := GetFrameWidth;
X := ClientWidth - FGripBmp.Width - I;
Y := ClientHeight - FGripBmp.Height - I;
Draw(X, Y, FGripBmp);
end;
end;
procedure TJvPanel.DrawBorders;
var
Rect: TRect;
TopColor, BottomColor: TColor;
procedure AdjustColors(Bevel: TPanelBevel);
begin
TopColor := clBtnHighlight;
if Bevel = bvLowered then
TopColor := clBtnShadow;
BottomColor := clBtnShadow;
if Bevel = bvLowered then
BottomColor := clBtnHighlight;
end;
begin
Rect := ClientRect;
if BevelOuter <> bvNone then
begin
AdjustColors(BevelOuter);
Frame3D(Canvas, Rect, TopColor, BottomColor, BevelWidth);
end;
Frame3D(Canvas, Rect, Color, Color, BorderWidth);
if BevelInner <> bvNone then
begin
AdjustColors(BevelInner);
Frame3D(Canvas, Rect, TopColor, BottomColor, BevelWidth);
end;
end;
procedure TJvPanel.DrawCaption;
begin
DrawCaptionTo(Self.Canvas);
end;
procedure TJvPanel.DrawCaptionTo(ACanvas: TCanvas ; DrawingMask: Boolean = False );
const
Alignments: array [TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER);
WordWrap: array [Boolean] of Longint = (DT_SINGLELINE, DT_WORDBREAK);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -