📄 mmsplit.pas
字号:
{========================================================================}
{= (c) 1995-98 SwiftSoft Ronald Dittrich =}
{========================================================================}
{= All Rights Reserved =}
{========================================================================}
{= D 01099 Dresden = Tel.: +0351-8012255 =}
{= Loewenstr.7a = info@swiftsoft.de =}
{========================================================================}
{= Actual versions on http://www.swiftsoft.de/mmtools.html =}
{========================================================================}
{= This code is for reference purposes only and may not be copied or =}
{= distributed in any format electronic or otherwise except one copy =}
{= for backup purposes. =}
{= =}
{= No Delphi Component Kit or Component individually or in a collection=}
{= subclassed or otherwise from the code in this unit, or associated =}
{= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
{= without express permission from SwiftSoft. =}
{= =}
{= For more licence informations please refer to the associated =}
{= HelpFile. =}
{========================================================================}
{= $Date: 20.01.1998 - 18:00:00 $ =}
{========================================================================}
unit MMSplit;
{$I COMPILER.INC}
interface
uses
{$IFDEF WIN32}
Windows,
{$ELSE}
WinProcs,
WinTypes,
{$ENDIF}
Messages,
SysUtils,
Classes,
Controls,
Forms,
Graphics,
ExtCtrls,
Menus,
MMObj,
MMString,
MMUtils;
type
{-- TMMSplitter -------------------------------------------------------}
TMMSplitter = class(TMMCustomPanel)
private
FCursor : TCursor;
FOrigin : TPoint;
FOffset : TPoint;
FUpdate : integer;
FSolid : Boolean;
FFixed : Boolean;
FGrid : integer;
FAutoControl : Boolean;
FMinOffset : integer;
FMaxOffset : integer;
FSPlitterSize: integer;
FSizeControl : TWinControl;
FOnSplit : TMouseMoveEvent;
FOnSplitBegin: TNotifyEvent;
FOnSplitEnd : TNotifyEvent;
procedure SetSplitterSize(aValue: integer);
procedure SetGrid(aValue: integer);
procedure SetSizeControl(aValue: TWinControl);
procedure SetFixed(aValue: Boolean);
procedure UpdateCursor;
procedure BeginSizing(aRect: TRect);
procedure DrawSizeRect(var aRect: TRect);
procedure EndSizing(aRect: TRect);
procedure WMSize(var Msg); message WM_Size;
procedure WMMove(var Msg); message WM_Move;
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 Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
published
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
{$IFDEF WIN32}
property OnStartDrag;
{$ENDIF}
property Bevel;
property DragCursor;
property DragMode;
property Enabled;
property Color;
property Ctl3D;
property ParentColor;
property ParentCtl3D;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnSplit: TMouseMoveEvent read FOnSplit write FOnSplit;
property OnSplitBegin: TNotifyEvent read FOnSplitBegin write FOnSplitBegin;
property OnSplitEnd: TNotifyEvent read FOnSplitEnd write FOnSplitEnd;
property Height default 3;
property Fixed: Boolean read FFixed write SetFixed default False;
property AutoControl: Boolean read FAutoControl write FAutoControl default False;
property MinOffset: integer read FMinOffset write FMinOffset default 0;
property MaxOffset: integer read FMaxOffset write FMaxOffset default 0;
property SplitterSize: integer read FSplitterSize write SetSplitterSize default 4;
property SizeControl: TWinControl read FSizeControl write SetSizeControl;
property DrawSolid: Boolean read FSolid write FSolid default False;
property Grid: integer read FGrid write SetGrid default 0;
end;
implementation
const
SplitCanvas : TCanvas = nil;
{------------------------------------------------------------------------}
function GetClipDC(Control: TWinControl): hDC;
var
ClipRect: TRect;
ClipRgn : hRgn;
begin
ClipRect := Control.ClientRect;
MapWindowPoints(Control.Handle, 0 , ClipRect, 2);
inc(ClipRect.Right);
inc(ClipRect.Bottom);
Result := GetDC(0);
SetViewPortOrgEx(Result, ClipRect.Left, ClipRect.Top, nil);
ClipRgn := CreateRectRgnIndirect(ClipRect);
SelectClipRgn(Result, ClipRgn);
DeleteObject(ClipRgn);
end;
{------------------------------------------------------------------------}
function CreateBrushPattern: TBitmap;
var
X,Y: integer;
begin
Result := TBitmap.Create;
Result.MonoChrome := True;
Result.Width := 8;
Result.Height:= 8;
with Result.Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := clWhite;
FillRect(Rect(0, 0, 8, 8));
for Y := 0 to 7 do
for X := 0 to 7 do
if (Y mod 2) = (X mod 2) then { toggles between even/odd pixles }
Pixels[X, Y] := clBlack; { on even/odd rows }
end;
end;
{== TMMSplitter =========================================================}
constructor TMMSplitter.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle - [csSetCaption];
FUpdate := 0;
FFixed := False;
FSolid := False;
FSplitterSize := 3;
FAutoControl := False;
FMinOffset := 0;
FMaxOffset := 0;
FCursor := Cursor;
FGrid := 0;
Caption := '';
Height := 3;
Bevel.BevelOuter := bvRaised;
ErrorCode := ComponentRegistered(InitCode, Self, ClassName);
if (ErrorCode <> 0) then RegisterFailed(InitCode, Self , ClassName);
end;
{-- TMMSplitter ---------------------------------------------------------}
procedure TMMSplitter.BeginSizing(aRect: TRect);
begin
if (SplitCanvas = nil) then SplitCanvas := TCanvas.Create;
with SplitCanvas do
begin
Handle := GetClipDC(Parent);
if FSolid then
Brush.Color := clWhite
else
Brush.Bitmap:= CreateBrushPattern;
Pen.Style := psClear;
Pen.Mode := pmXor;
end;
DrawSizeRect(aRect);
end;
{-- TMMSplitter ---------------------------------------------------------}
procedure TMMSplitter.EndSizing(aRect: TRect);
begin
{ delete SizeRect }
DrawSizeRect(aRect);
{ reset cursorClipping }
ClipCursor(nil);
if (SplitCanvas.Brush.Bitmap <> nil) then
begin
SplitCanvas.Brush.Bitmap.Free;
SplitCanvas.Brush.Bitmap := Nil;
end;
ReleaseDC(0, SplitCanvas.Handle);
SplitCanvas.Handle := 0;
SplitCanvas.Free;
SplitCanvas := nil;
end;
{-- TMMSplitter ---------------------------------------------------------}
procedure TMMSplitter.DrawSizeRect(var aRect: TRect);
begin
if (SplitCanvas <> nil) then
with SplitCanvas, aRect do
case Align of
alTop,
alBottom: Rectangle(Left, Top, Right, Bottom+1);
alLeft,
alRight: Rectangle(Left,Top,Right+1,Bottom);
end;
end;
{-- TMMSplitter ---------------------------------------------------------}
procedure TMMSplitter.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
aRect: TRect;
ScreenBounds: TRect;
i: integer;
Win: TWinControl;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -