- Added highlighting of the target region for copy/move operations in frmLargeScaleCommand (fixes #40)

This commit is contained in:
Andreas Schneider 2009-12-07 02:15:56 +01:00
parent 6eaf10e73e
commit 09bd74675e
2 changed files with 52 additions and 20 deletions

View File

@ -22,20 +22,20 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand
Top = 0 Top = 0
Width = 468 Width = 468
Align = alClient Align = alClient
PageIndex = 4 PageIndex = 0
ShowTabs = False ShowTabs = False
TabOrder = 0 TabOrder = 0
object pgArea: TPage object pgArea: TPage
Caption = 'pgArea' Caption = 'pgArea'
ClientWidth = 462 ClientWidth = 462
ClientHeight = 331 ClientHeight = 358
object sbArea: TScrollBox object sbArea: TScrollBox
Left = 0 Left = 0
Height = 331 Height = 358
Top = 0 Top = 0
Width = 462 Width = 462
Align = alClient Align = alClient
ClientHeight = 329 ClientHeight = 356
ClientWidth = 460 ClientWidth = 460
TabOrder = 0 TabOrder = 0
object pbArea: TPaintBox object pbArea: TPaintBox
@ -921,6 +921,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand
TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toThemeAware, toUseBlendedImages] TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toThemeAware, toUseBlendedImages]
TreeOptions.SelectionOptions = [toFullRowSelect] TreeOptions.SelectionOptions = [toFullRowSelect]
OnChange = vstActionsChange OnChange = vstActionsChange
OnChecked = vstActionsChecked
OnGetText = vstActionsGetText OnGetText = vstActionsGetText
OnPaintText = vstActionsPaintText OnPaintText = vstActionsPaintText
end end

View File

@ -30,9 +30,9 @@ unit UfrmLargeScaleCommand;
interface interface
uses uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, CheckLst, Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Math,
VirtualTrees, ExtCtrls, ImagingComponents, StdCtrls, Buttons, Spin, LCLIntf, VirtualTrees, ExtCtrls, ImagingComponents, StdCtrls, Buttons, Spin, LCLIntf,
math, UPlatformTypes, UEnhancedMemoryStream; UPlatformTypes, UEnhancedMemoryStream;
type type
@ -144,6 +144,7 @@ type
procedure vdtTerrainTilesDrawNode(Sender: TBaseVirtualTree; procedure vdtTerrainTilesDrawNode(Sender: TBaseVirtualTree;
const PaintInfo: TVTPaintInfo); const PaintInfo: TVTPaintInfo);
procedure vstActionsChange(Sender: TBaseVirtualTree; Node: PVirtualNode); procedure vstActionsChange(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure vstActionsChecked(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure vstActionsGetText(Sender: TBaseVirtualTree; procedure vstActionsGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: String); var CellText: String);
@ -157,7 +158,13 @@ type
FLastX: Integer; FLastX: Integer;
FLastY: Integer; FLastY: Integer;
FAreaMove: TAreaMove; FAreaMove: TAreaMove;
procedure AddNode(AActionID: Integer; ACaption: String); FAreaNode: PVirtualNode;
FCopyMoveNode: PVirtualNode;
FAltitudeNode: PVirtualNode;
FDrawTerrainNode: PVirtualNode;
FDelStaticsNode: PVirtualNode;
FAddStaticsNode: PVirtualNode;
function AddNode(AActionID: Integer; ACaption: String): PVirtualNode;
function FindNode(AActionID: Integer): PVirtualNode; function FindNode(AActionID: Integer): PVirtualNode;
procedure SerializeTiles(ATileList: TVirtualDrawTree; procedure SerializeTiles(ATileList: TVirtualDrawTree;
AStream: TEnhancedMemoryStream); AStream: TEnhancedMemoryStream);
@ -190,12 +197,12 @@ type
procedure TfrmLargeScaleCommand.FormCreate(Sender: TObject); procedure TfrmLargeScaleCommand.FormCreate(Sender: TObject);
begin begin
vstActions.NodeDataSize := SizeOf(TNodeInfo); vstActions.NodeDataSize := SizeOf(TNodeInfo);
AddNode(-1, 'Target Area'); FAreaNode := AddNode(-1, 'Target Area');
AddNode(0, 'Copy/Move'); FCopyMoveNode := AddNode( 0, 'Copy/Move');
AddNode(1, 'Modify altitude'); FAltitudeNode := AddNode( 1, 'Modify altitude');
AddNode(2, 'Draw terrain'); FDrawTerrainNode := AddNode( 2, 'Draw terrain');
AddNode(3, 'Delete statics'); FDelStaticsNode := AddNode( 3, 'Delete statics');
AddNode(4, 'Insert statics'); FAddStaticsNode := AddNode( 4, 'Insert statics');
vstActions.Selected[vstActions.GetFirst] := True; vstActions.Selected[vstActions.GetFirst] := True;
vstArea.NodeDataSize := SizeOf(TRect); vstArea.NodeDataSize := SizeOf(TRect);
@ -270,8 +277,6 @@ end;
procedure TfrmLargeScaleCommand.pbAreaMouseMove(Sender: TObject; procedure TfrmLargeScaleCommand.pbAreaMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
var var
node: PVirtualNode;
nodeInfo: ^TRect;
offsetX, offsetY: Integer; offsetX, offsetY: Integer;
begin begin
if (ssLeft in Shift) and (vstArea.GetFirstSelected <> nil) then if (ssLeft in Shift) and (vstArea.GetFirstSelected <> nil) then
@ -448,10 +453,12 @@ end;
procedure TfrmLargeScaleCommand.pbAreaPaint(Sender: TObject); procedure TfrmLargeScaleCommand.pbAreaPaint(Sender: TObject);
var var
i: Integer;
node: PVirtualNode; node: PVirtualNode;
nodeInfo: ^TRect; nodeInfo: ^TRect;
showMoveTarget: Boolean;
begin begin
showMoveTarget := FCopyMoveNode^.CheckState = csCheckedNormal;
DisplayImage(pbArea.Canvas, 0, 0, frmRadarMap.Radar); DisplayImage(pbArea.Canvas, 0, 0, frmRadarMap.Radar);
pbArea.Canvas.Pen.Color := clRed; pbArea.Canvas.Pen.Color := clRed;
pbArea.Canvas.Brush.Color := clMaroon; pbArea.Canvas.Brush.Color := clMaroon;
@ -459,20 +466,34 @@ begin
node := vstArea.GetFirst; node := vstArea.GetFirst;
while node <> nil do while node <> nil do
begin begin
nodeInfo := vstArea.GetNodeData(node);
if vstArea.Selected[node] then if vstArea.Selected[node] then
begin begin
pbArea.Canvas.Pen.Width := 2; pbArea.Canvas.Pen.Width := 2;
pbArea.Canvas.Pen.Style := psSolid; pbArea.Canvas.Pen.Style := psSolid;
//pbArea.Canvas.Brush.Color := clRed;
end else end else
begin begin
pbArea.Canvas.Pen.Width := 1; pbArea.Canvas.Pen.Width := 1;
pbArea.Canvas.Pen.Style := psDot; pbArea.Canvas.Pen.Style := psDot;
//pbArea.Canvas.Brush.Color := clMaroon;
end; end;
nodeInfo := vstArea.GetNodeData(node);
pbArea.Canvas.Brush.Style := bsFDiagonal;
pbArea.Canvas.Pen.Color := clRed;
pbArea.Canvas.Brush.Color := clMaroon;
pbArea.Canvas.Rectangle(nodeInfo^.Left div 8, nodeInfo^.Top div 8, pbArea.Canvas.Rectangle(nodeInfo^.Left div 8, nodeInfo^.Top div 8,
nodeInfo^.Right div 8 + 1, nodeInfo^.Bottom div 8 + 1); nodeInfo^.Right div 8 + 1, nodeInfo^.Bottom div 8 + 1);
if showMoveTarget then
begin
pbArea.Canvas.Brush.Style := bsBDiagonal;
pbArea.Canvas.Pen.Color := clBlue;
pbArea.Canvas.Brush.Color := clNavy;
pbArea.Canvas.Rectangle((nodeInfo^.Left + seCMOffsetX.Value) div 8,
(nodeInfo^.Top + seCMOffsetY.Value) div 8,
(nodeInfo^.Right + seCMOffsetX.Value) div 8 + 1,
(nodeInfo^.Bottom + seCMOffsetY.Value) div 8 + 1);
end;
node := vstArea.GetNext(node); node := vstArea.GetNext(node);
end; end;
end; end;
@ -567,6 +588,13 @@ begin
end; end;
end; end;
procedure TfrmLargeScaleCommand.vstActionsChecked(Sender: TBaseVirtualTree;
Node: PVirtualNode);
begin
if Node = FCopyMoveNode then
pbArea.Repaint;
end;
procedure TfrmLargeScaleCommand.vstActionsGetText( procedure TfrmLargeScaleCommand.vstActionsGetText(
Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType; var CellText: String); TextType: TVSTTextType; var CellText: String);
@ -621,7 +649,8 @@ begin
nodeInfo^.Right, nodeInfo^.Bottom]); nodeInfo^.Right, nodeInfo^.Bottom]);
end; end;
procedure TfrmLargeScaleCommand.AddNode(AActionID: Integer; ACaption: String); function TfrmLargeScaleCommand.AddNode(AActionID: Integer;
ACaption: String): PVirtualNode;
var var
node: PVirtualNode; node: PVirtualNode;
nodeInfo: PNodeInfo; nodeInfo: PNodeInfo;
@ -632,6 +661,8 @@ begin
nodeInfo^.Caption := ACaption; nodeInfo^.Caption := ACaption;
if AActionID > -1 then if AActionID > -1 then
vstActions.CheckType[node] := ctCheckBox; vstActions.CheckType[node] := ctCheckBox;
Result := node;
end; end;
function TfrmLargeScaleCommand.FindNode(AActionID: Integer): PVirtualNode; function TfrmLargeScaleCommand.FindNode(AActionID: Integer): PVirtualNode;