📄 ezmiscelctrls.pas
字号:
Emax.X + TmpMarginX,
Emin.Y - TmpMarginY,
Emax.Y + TmpMarginY );
end;
with Canvas do
begin
with Boundsr do
Rgn:= CreateRectRgn(Left, Top, Right, Bottom);
SelectClipRgn(Handle, Rgn);
try
if linetype>=MAX_LINETYPES then
begin
PenStyle.Style:=1;
If dist*Repit <> 0 then
Penstyle.Scale:=Dist2d(V[0],V[1])/(dist*Repit) // the scale factor
else
Penstyle.Scale:=0;
Penstyle.Color:=clRed;//ALineColor;
Symbol.DrawVector( V,
Penstyle,
Grapher,
Canvas,
Grapher.CurrentParams.VisualWindow,
IDENTITY_MATRIX2D,
dmNormal );
end else if ( linetype >=0 ) and ( linetype <= Pred(MAX_LINETYPES) ) then
begin
for I:= 0 to V.Count-1 do
PtArr[I]:= Grapher.RealToPoint(V[I]);
Parts[0]:= V.Count;
PolyDDA( PtArr,
Parts,
1,
Canvas,
Grapher,
linetype+1,
ALineColor, 1 );
end else
begin
PenStyle.Style:=1;
Penstyle.Scale:=Grapher.PointsToDistY(PenWidth);
Penstyle.Color:=ALineColor;
V.DrawOpened( Canvas,
Grapher.CurrentParams.VisualWindow,
V.Extension,
Grapher,
PenStyle,
IDENTITY_MATRIX2D,
dmNormal );
end;
finally
SelectClipRgn(Handle, 0);
DeleteObject(Rgn);
end;
end;
finally
V.free;
end;
end;
end;
Procedure DrawPattern( Canvas: TCanvas; Index: Integer;
ForeColor, BackColor, FillColor: TColor; Rect: TRect;
ShowIndex: Boolean ; State: TOwnerDrawState; ShowHexa: Boolean;
Clear: Boolean = true; Edged: Boolean = False);
var
Poly: array[0..4] of TPoint;
Resname, sTmp: string;
BmpRes: HBitmap;
Bmp: TBitmap;
pattern: Integer;
Parts: array[0..0] of Integer;
Boundsr: TRect;
aedge:word;
begin
Pattern:= Index;
Boundsr:= Rect;
with Canvas do
begin
Brush.Color:= FillColor;
If Clear And Not ( odSelected in State ) then
FillRect( Boundsr );
InflateRect(Boundsr,-2,-2);
If Edged then
begin
InflateRect( Boundsr, -1, -1 );
aedge:= EDGE_BUMP;
DrawEdge(Canvas.Handle, Boundsr, aedge, BF_RECT OR BF_ADJUST);
InflateRect( Boundsr, -2, -2 );
end;
end;
if ShowIndex then
begin
SetBkMode(Canvas.Handle, TRANSPARENT);
//Canvas.Font:= Self.Font;
If odSelected in State then
Canvas.Font.Color:= clHighlightText
else
Canvas.Font.Color:= clBtnShadow;
if ShowHexa then
sTmp:= IntToHex( Index, 2 )
else
sTmp:= Inttostr( Index );
Canvas.TextOut(Boundsr.Left + 1, Boundsr.Top + 1, sTmp);
Boundsr.Left:= Boundsr.Left + Canvas.TextWidth('99') + 2;
end;
with Boundsr do
begin
Poly[0]:= Point(Left,Top);
Poly[1]:= Point(Left,Bottom);
Poly[2]:= Point(Right,Bottom);
Poly[3]:= Point(Right,Top);
Poly[4]:= Point(Left,Top);
end;
with Canvas do
begin
Pen.Color:= clBtnShadow;
Brush.Style:= bsClear;
case Index of
1: begin
Brush.Color := ForeColor;
Brush.Style := bsSolid;
end;
2..89:
begin
Resname:= '#'+IntToStr(98+Pattern);
BmpRes:= LoadBitmap(HInstance, PChar(Resname));
if BmpRes<>0 then
begin
Bmp:= TBitmap.Create;
try
Bmp.Handle:= Bmpres;
Parts[0]:= 5;
EzGraphics.PolygonScreenFill8X8Bitmap(
Canvas,
nil,
Poly,
Parts,
1,
Bmp,
ForeColor,
BackColor );
finally
DeleteObject(Bmp.Handle);
Bmp.free;
end;
end;
end;
end;
Polygon(Poly);
end;
end;
procedure DrawBlock(Grapher: TEzGrapher; Canvas: TCanvas;
Rect: TRect; State: TOwnerDrawState; FillColor: TColor; Block: TEzSymbol;
Clear: Boolean = true; Edged: Boolean = False );
var
Boundsr:TRect;
Rgn: HRgn;
TmpMarginX, TmpMarginY: Double;
aedge:word;
begin
if (Block.Count=0) or EqualRect2D(Block.Extension, INVALID_EXTENSION) then Exit;
Grapher.Clear;
with Canvas do
begin
Brush.Color:= FillColor;
Boundsr:= Rect;
If Clear And Not ( odSelected in State ) then FillRect( Boundsr );
If Edged then
begin
InflateRect( Boundsr, -1, -1 );
aedge:= EDGE_BUMP;
DrawEdge(Canvas.Handle, Boundsr, aedge, BF_RECT OR BF_ADJUST);
InflateRect( Boundsr, -2, -2 );
end;
with Boundsr do
Grapher.SetViewport(Left, Top, Right, Bottom);
with Block.Extension do
begin
TmpMarginX:= (Emax.X - Emin.X) / 20;
TmpMarginY:= (Emax.Y - Emin.Y) / 20;
Grapher.SetWindow(Emin.X - TmpMarginX, Emax.X + TmpMarginX,
Emin.Y - TmpMarginY, Emax.Y + TmpMarginY);
end;
with Canvas do
begin
with Boundsr do
Rgn:= CreateRectRgn(Left, Top, Right, Bottom);
SelectClipRgn(Handle, Rgn);
try
Block.Draw(Grapher, Canvas,
Grapher.CurrentParams.VisualWindow, IDENTITY_MATRIX2D, dmNormal);
finally
SelectClipRgn(Handle, 0);
DeleteObject(Rgn);
end;
end;
end;
end;
type
TCustomEditHack = class(TCustomEdit);
constructor TEzCustomDropDownForm.Create(AOwner: TComponent);
begin
inherited CreateNew(AOwner);
BorderIcons := [];
BorderStyle := bsNone;
Font := TCustomEditHack(AOwner).Font;
FEntering := True;
FLeaving := False;
FCloseOnLeave := True;
with TWinControl(AOwner) do
begin
Self.Left := ClientOrigin.X;
Self.Top := ClientOrigin.Y + Height;
end;
FPanel:= TPanel.Create(Self);
with FPanel do
begin
Parent:= Self;
Align:= alClient;
ParentFont := True;
BevelInner:= bvLowered;
BevelOuter:= bvRaised;
BevelWidth:= 1;
BorderWidth:= 2;
end;
end;
procedure TEzCustomDropDownForm.CreateParams(var AParams: TCreateParams);
begin
inherited;
AParams.Style := AParams.Style or WS_BORDER;
end;
procedure TEzCustomDropDownForm.DoClose(var AAction: TCloseAction);
begin
AAction := caFree;
inherited;
end;
procedure TEzCustomDropDownForm.DoShow;
var
lScreenRect: TRect;
begin
inherited;
if (not SystemParametersInfo(SPI_GETWORKAREA, 0, @lScreenRect, 0)) then
lScreenRect := Rect(0, 0, Screen.Width, Screen.Height);
if (Left + Width > lScreenRect.Right) then
Left := lScreenRect.Right - Width;
if (Top + Height > lScreenRect.Bottom) then
Top := Self.Edit.ClientOrigin.y - Height;
end;
function TEzCustomDropDownForm.GetEdit: TCustomControl;
begin
result := TCustomControl(Owner);
end;
function TEzCustomDropDownForm.Leaving: Boolean;
begin
result := FLeaving;
end;
procedure TEzCustomDropDownForm.LoseFocus(const AFocusControl: TWinControl);
begin
if (Assigned(OnLoseFocus)) then
OnLoseFocus(Self, AFocusControl);
if CloseOnLeave then
Close;
end;
procedure TEzCustomDropDownForm.WMKillFocus(var AMessage: TMessage);
begin
if IsChildOf(AMessage.WParam, Self.Handle) then
inherited
else
begin
FLeaving := True;
try
inherited;
LoseFocus(FindControl(AMessage.WParam));
finally
FLeaving := False;
end;
end;
end;
procedure TEzCustomDropDownForm.WMSetFocus(var AMessage: TMessage);
begin
if IsChildOf(AMessage.WParam, Self.Handle) then
inherited
else
begin
FEntering := True;
try
inherited;
GetFocus(FindControl(AMessage.WParam));
finally
FEntering := False;
end;
end;
end;
function TEzCustomDropDownForm.Entering: Boolean;
begin
result := FEntering;
end;
procedure TEzCustomDropDownForm.GetFocus(const APreviousControl: TWinControl);
begin
if (Assigned(OnGetFocus)) then
OnGetFocus(Self, APreviousControl);
end;
{ TEzLayerGridBox }
const
Images: array[TEzCheckBitmap] of PChar = ( 'VISIBLE',
'INVISIBLE',
'SELECT',
'UNSELECT',
'CURRENT',
'NOCURRENT' );
BitmapWidth = 14;
BitmapHeight = 14;
{ TEzLayerListBox }
function TEzLayerGridBox.GetAbout: TEzAbout;
begin
end;
procedure TEzLayerGridBox.SetAbout(const Value: TEzAbout);
begin
end;
constructor TEzLayerListBox.Create(AOwner: TComponent);
begin
inherited Create(Aowner);
FLockedTextColor:= clRed;
RowCount:= 2;
FixedCols:= 0;
FixedRows:= 1;
Options:= [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goColSizing,goRowSelect];
{ create default columns }
FColumns := TEzLayerBoxColumns.Create( Self, TEzLayerBoxColumn );
BeginLayout;
with FColumns.Add do
begin
ColumnData := cdCurrent;
Alignment := taCenter;
Width := 48;
BitmapEnabled.Handle:= LoadBitmap(HInstance, Images[obCurrent]);
BitmapDisabled.Handle:= LoadBitmap(HInstance, Images[obNoCurrent]);
Title.Alignment:= taCenter;
Title.Caption:= SLLBCurrent;
end;
with FColumns.Add do
begin
ColumnData := cdVisible;
Alignment := taCenter;
Width := 48;
BitmapEnabled.Handle:= LoadBitmap(HInstance, Images[obVisible]);
BitmapDisabled.Handle:= LoadBitmap(HInstance, Images[obInVisible]);
Title.Alignment:= taCenter;
Title.Caption:= SLLBVisible;
end;
with FColumns.Add do
begin
ColumnData := cdSelectable;
Alignment := taCenter;
Width := 48;
BitmapEnabled.Handle:= LoadBitmap(HInstance, Images[obSelectable]);
BitmapDisabled.Handle:= LoadBitmap(HInstance, Images[obUnSelectable]);
Title.Alignment:= taCenter;
Title.Caption:= SLLBSelectable;
end;
with FColumns.Add do
begin
ColumnData := cdLayerName;
Alignment := taLeftJustify;
Width := 128;
Title.Alignment:= taCenter;
Title.Caption:= SLLBLayerName;
end;
EndLayout;
end;
destructor TEzLayerListBox.Destroy;
begin
FColumns.Free;
inherited Destroy;
end;
procedure TEzLayerListBox.Loaded;
begin
inherited Loaded;
if not(csDesigning in ComponentState) then
LayoutChanged;
end;
procedure TEzLayerListBox.Notification(AComponent: TComponent; Operation: TOperation);
begin
Inherited Notification( AComponent, Operation );
If ( Operation = opRemove ) And ( AComponent = FGIS ) Then
begin
FGIS := Nil;
{ clear the draw grid }
RowCount:= 2;
FixedRows:= 1;
Invalidate;
end;
end;
procedure TEzLayerListBox.SetColumns(const Value: TEzLayerBoxColumns);
begin
FColumns.Assign(Value);
LayoutChanged;
end;
procedure TEzLayerListBox.SetCurrentTextColor(const Value: TColor);
begin
if FCurrentTextColor = Value then Exit;
FCurrentTextColor := Value;
Invalidate;
end;
procedure TEzLayerListBox.SetLockedTextColor(const Value: TColor);
begin
if FLockedTextColor = Value then Exit;
FLockedTextColor := Value;
Invalidate;
end;
procedure TEzLayerListBox.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
var
ACol,ARow, AIndex: Integer;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -