📄 ezmiscelctrls.pas
字号:
begin
inherited MouseDown(Button, Shift, X, Y);
MouseToCell(X,Y,ACol,ARow);
AIndex := GIS.Layers.Count - ARow;
if (AIndex < 0) Or (ARow < 1 ) or ( AIndex > FGIS.Layers.Count - 1 ) or
(ACol < 0) or ( ACol > FColumns.Count - 1 ) then Exit;
with FColumns[ACol] do
begin
if ReadOnly then Exit;
case ColumnData of
cdCurrent:
begin
FGIS.CurrentLayerName:= FGIS.Layers[AIndex].Name;
Invalidate;
end;
cdVisible:
begin
if Not FGIS.Layers[AIndex].IsCurrent Or (FGIS.Layers.Count = 1) then
FGIS.Layers[AIndex].LayerInfo.Visible:= Not FGIS.Layers[AIndex].LayerInfo.Visible;
Invalidate;
end;
cdSelectable:
begin
FGIS.Layers[AIndex].LayerInfo.Selectable:= Not FGIS.Layers[AIndex].LayerInfo.Selectable;
Invalidate;
end;
end;
end;
end;
procedure TEzLayerListBox.DrawCell(ACol, ARow: Longint; ARect: TRect;
AState: TGridDrawState);
var
DrawMode: Word;
S: String;
AIndex: Integer;
ABitmap: TBitmap;
AX, AY: Integer;
ACellWidth, ACellHeight: Integer;
Boundsr: TRect;
begin
if ( csDesigning in ComponentState ) or (FixedRows <> 1) or
( ACol > FColumns.Count - 1 ) or ( FGIS = Nil ) then Exit;
with Canvas do
begin
Boundsr:= ARect;
if ARow = Self.Row then
begin
DrawEdge ( Handle, ARect, EDGE_BUMP, BF_RECT or BF_ADJUST );
InflateRect( Boundsr, -2, -2 );
end;
if ARow = 0 then
begin
{ The titles }
// if not (gdFixed in AState) then
begin
Brush.Style:= bsSolid;
Brush.Color := FColumns[ACol].Title.Color;
FillRect(Boundsr);
Font.Assign( FColumns[ACol].Title.Font );
end;
SetBkMode(Handle, TRANSPARENT);
case FColumns[ACol].Title.Alignment of
taLeftJustify:
DrawMode:= DT_LEFT;
taRightJustify:
DrawMode:= DT_RIGHT;
taCenter:
DrawMode:= DT_CENTER;
else
DrawMode:= DT_LEFT;
end;
DrawText(Canvas.Handle, PChar(FColumns[ACol].Title.Caption), -1, Boundsr,
DrawMode or DT_SINGLELINE or DT_VCENTER);
end else
begin
//if not (gdFixed in AState) then
begin
Brush.Style:= bsSolid;
Brush.Color := FColumns[ACol].Color;
FillRect(Boundsr);
end;
AIndex := FGIS.Layers.Count - ARow;
if AIndex < 0 then Exit;
if FColumns[ACol].ColumnData in [cdLayerName, cdLayerFullPath] then
begin
SetBkMode(Handle, TRANSPARENT);
case FColumns[ACol].Alignment of
taLeftJustify:
DrawMode:= DT_LEFT;
taRightJustify:
DrawMode:= DT_RIGHT;
taCenter:
DrawMode:= DT_CENTER;
Else
DrawMode:= DT_LEFT;
end;
if FColumns[ACol].ColumnData = cdLayerName then
S:= FGIS.Layers[AIndex].Name
else
S:= FGIS.Layers[AIndex].FileName;
Font.Assign( FColumns[ACol].Font );
if FGIS.Layers[AIndex].IsCurrent then
Font.Color:= Self.FCurrentTextColor
else if FGIS.Layers[AIndex].LayerInfo.Locked then
Font.Color:= Self.FLockedTextColor
else if FGIS.Layers[AIndex] Is TEzVirtualLayer then
Font.Color:= Self.FVirtualLayerTextColor;
DrawText(Canvas.Handle, PChar(S), -1, Boundsr,
DrawMode or DT_SINGLELINE or DT_VCENTER);
end else
begin
ABitmap:= Nil;
case FColumns[ACol].ColumnData of
cdCurrent:
if FGIS.Layers[AIndex].IsCurrent then
ABitmap := FColumns[ACol].BitmapEnabled
else
ABitmap := FColumns[ACol].BitmapDisabled;
cdVisible:
if FGIS.Layers[AIndex].LayerInfo.Visible then
ABitmap := FColumns[ACol].BitmapEnabled
else
ABitmap := FColumns[ACol].BitmapDisabled;
cdSelectable:
if FGIS.Layers[AIndex].LayerInfo.Selectable then
ABitmap := FColumns[ACol].BitmapEnabled
else
ABitmap := FColumns[ACol].BitmapDisabled;
end;
if ABitmap = Nil then Exit;
ACellWidth:= Boundsr.Right - Boundsr.Left;
ACellHeight:= Boundsr.Bottom - Boundsr.Top;
AX:= 0;
AY:= 0;
case FColumns[ACol].Alignment of
taLeftJustify:
begin
AX:= Boundsr.Left;
AY:= Boundsr.Top + (ACellHeight - ABitmap.Height) div 2;
end;
taRightJustify:
begin
AX:= Boundsr.Right - ABitmap.Width;
AY:= Boundsr.Top + (ACellHeight - ABitmap.Height) div 2;
end;
taCenter:
begin
AX:= Boundsr.Left + (ACellWidth - ABitmap.Width) div 2;
AY:= Boundsr.Top + (ACellHeight - ABitmap.Height) div 2;
end;
end;
Draw(AX, AY, ABitmap);
end;
end;
end;
//inherited DrawCell( ACol, ARow, ARect, AState );
end;
procedure TEzLayerListBox.LayoutChanged;
var
I: Integer;
begin
{ recreate the draw grid }
if FInLayout then Exit;
ColCount:= FColumns.Count;
if FGIS= nil then
begin
RowCount:= 2;
FixedRows:= 1;
Exit;
end;
If FGIS.Layers.Count=0 then
RowCount:= 2
else
RowCount:= FGIS.Layers.Count + 1;
FixedRows:= 1;
for I:= 0 to FColumns.Count-1 do
ColWidths[I] := FColumns[I].Width;
end;
procedure TEzLayerListBox.SetGis(Value: TEzBaseGis);
begin
{$IFDEF LEVEL5}
if Assigned( FGIS ) then FGIS.RemoveFreeNotification( Self );
{$ENDIF}
FGIS := Value;
if Value <> nil then
Value.FreeNotification(Self);
if (csDesigning in ComponentState) then Exit;
LayoutChanged;
end;
procedure TEzLayerListBox.BeginLayout;
begin
FInLayout:= true;
end;
procedure TEzLayerListBox.EndLayout;
begin
FInLayout:= false;
LayoutChanged;
end;
function TEzLayerListBox.Selected: string;
begin
if (FGIS = Nil) Or (Row < 1) then Exit;
Result:= FGIS.Layers[Row-1].Name;
end;
function TEzLayerListBox.SelectedLayer: TEzBaseLayer;
begin
Result:= Nil;
if (FGIS = Nil) Or (Row < 1) then Exit;
Result:= FGIS.Layers[Row-1];
end;
function TEzLayerListBox.GetAbout: TEzAbout;
begin
Result:= SEz_GisVersion;
end;
procedure TEzLayerListBox.SetAbout(const Value: TEzAbout);
begin
end;
{ TEzLayerBoxColumn }
constructor TEzLayerBoxColumn.Create(Collection: TCollection);
var
ListBox: TEzLayerListBox;
begin
ListBox := nil;
if Assigned(Collection) and (Collection is TEzLayerBoxColumns) then
ListBox := TEzLayerBoxColumns(Collection).FListBox;
if Assigned(ListBox) then ListBox.BeginLayout;
try
inherited Create(Collection);
FWidth:= 24;
FColor:= clWindow;
FFont:= TFont.Create;
FFont.Assign(ListBox.Font);
FTitle:= TEzLayerColumnTitle.Create(Self);
FTitle.Font.Assign(FFont);
FBitmapEnabled:= TBitmap.Create;
FBitmapEnabled.Transparent:= true;
FBitmapEnabled.TransparentMode:= tmAuto;
FBitmapDisabled:= TBitmap.Create;
FBitmapDisabled.Transparent:= true;
FBitmapDisabled.TransparentMode:= tmAuto;
finally
if Assigned(ListBox) then ListBox.EndLayout;
end;
end;
destructor TEzLayerBoxColumn.Destroy;
begin
FFont.Free;
FTitle.Free;
FBitmapEnabled.Free;
FBitmapDisabled.Free;
inherited destroy;
end;
procedure TEzLayerBoxColumn.Assign(Source: TPersistent);
begin
if Source is TEzLayerBoxColumn then
begin
if Assigned(Collection) then Collection.BeginUpdate;
try
ColumnData := TEzLayerBoxColumn(Source).ColumnData;
Color := TEzLayerBoxColumn(Source).Color;
ReadOnly:= TEzLayerBoxColumn(Source).ReadOnly;
Font.Assign(TEzLayerBoxColumn(Source).Font);
Title.Assign(TEzLayerBoxColumn(Source).Title);
BitmapEnabled.Assign(TEzLayerBoxColumn(Source).BitmapEnabled);
BitmapDisabled.Assign(TEzLayerBoxColumn(Source).BitmapDisabled);
finally
if Assigned(Collection) then Collection.EndUpdate;
end;
end else
inherited Assign(Source);;
end;
function TEzLayerBoxColumn.GetDisplayName: String;
begin
Result:= Inherited GetDisplayName;
end;
function TEzLayerBoxColumn.GetListBox: TEzLayerListBox;
begin
if Assigned(Collection) and (Collection is TEzLayerBoxColumns) then
Result:= TEzLayerBoxColumns(Collection).FListBox
else
Result:= Nil;
end;
procedure TEzLayerBoxColumn.RefreshLayout;
begin
if GetListBox = Nil then Exit;
with GetListBox do
begin
if csDesigning in ComponentState then Exit;
if not FInLayout then Refresh;
end;
end;
procedure TEzLayerBoxColumn.ChangeLayout;
begin
if GetListBox = Nil then Exit;
with GetListBox do
begin
if csDesigning in ComponentState then Exit;
if not FInLayout then LayoutChanged;
end;
end;
procedure TEzLayerBoxColumn.SetBitmapEnabled(const Value: TBitmap);
begin
FBitmapEnabled.Assign(Value);
RefreshLayout;
end;
procedure TEzLayerBoxColumn.SetBitmapDisabled(const Value: TBitmap);
begin
FBitmapDisabled.Assign(Value);
RefreshLayout;
end;
procedure TEzLayerBoxColumn.SetColor(const Value: TColor);
begin
if FColor = Value then Exit;
FColor := Value;
RefreshLayout;
end;
procedure TEzLayerBoxColumn.SetColumnData(const Value: TEzColumnData);
begin
FColumnData := Value;
RefreshLayout;
end;
procedure TEzLayerBoxColumn.SetFont(const Value: TFont);
begin
FFont.Assign(Value);
RefreshLayout;
end;
procedure TEzLayerBoxColumn.SetReadOnly(const Value: Boolean);
begin
FReadOnly := Value;
end;
procedure TEzLayerBoxColumn.SetTitle(const Value: TEzLayerColumnTitle);
begin
FTitle.Assign(Value);
ChangeLayout;
end;
procedure TEzLayerBoxColumn.SetAlignment(const Value: TAlignment);
begin
if FAlignment = Value then Exit;
FAlignment := Value;
RefreshLayout;
end;
procedure TEzLayerBoxColumn.SetWidth(const Value: Integer);
begin
if FWidth = Value then Exit;
FWidth := Value;
ChangeLayout;
end;
{ TEzLayerBoxColumns }
constructor TEzLayerBoxColumns.Create(ListBox: TEzLayerListBox; ColumnClass: TEzColumnClass);
begin
inherited Create(ListBox, ColumnClass);
FListBox:= ListBox;
end;
function TEzLayerBoxColumns.Add: TEzLayerBoxColumn;
begin
Result := TEzLayerBoxColumn(inherited Add);
end;
function TEzLayerBoxColumns.GetColumn(Index: Integer): TEzLayerBoxColumn;
begin
Result := TEzLayerBoxColumn(inherited Items[Index]);
end;
procedure TEzLayerBoxColumns.SetColumn(Index: Integer; Value: TEzLayerBoxColumn);
begin
Items[Index].Assign(Value);
end;
function TEzLayerBoxColumns.GetOwner: TPersistent;
begin
Result:= FListBox;
end;
procedure TEzLayerBoxColumns.Update(Item: TCollectionItem);
var
Raw: Integer;
begin
if (FListBox = nil) or (csLoading in FListBox.ComponentState) then Exit;
if Item = nil then
begin
FListBox.LayoutChanged;
end else
begin
Raw := Item.Index;
FListBox.InvalidateCol(Raw);
FListBox.ColWidths[Raw] := TEzLayerBoxColumn(Item).Width;
end;
end;
{ TEzLayerColumnTitle }
constructor TEzLayerColumnTitle.Create(Column: TEzLayerBoxColumn);
begin
inherited Create;
FColumn:= Column;
FFont:= TFont.Create;
FColor:= clBtnFace;
FAlignment:= taCenter;
end;
destructor TEzLayerColumnTitle.Destroy;
begin
FFont.Free;
inherited Destroy;
end;
procedure TEzLayerColumnTitle.SetAlignment(const Value: TAlignment);
begin
if FAlignment = Value then Exit;
FAlignment := Value;
FColumn.RefreshLayout;
end;
procedure TEzLayerColumnTitle.SetCaption(const Value: string);
begin
if FCaption = Value then Exit;
FCaption := Value;
FColumn.RefreshLayout;
end;
procedure TEzLayerColumnTitle.SetColor(const Value: TColor);
begin
if FColor = Value then Exit;
FColor := Value;
FColumn.RefreshLayout;
end;
procedure TEzLayerColumnTitle.SetFont(const Value: TFont);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -