- Fixed TfrmToolWindow.FormDeactivate to check CanClose first

- Fixed TfrmDrawSettings and TfrmHueSettings to be shown non-modal (fixes #49)
This commit is contained in:
Andreas Schneider 2009-12-18 18:43:55 +01:00
parent e502321f35
commit 5d7c40d579
4 changed files with 357 additions and 333 deletions

View File

@ -7,13 +7,14 @@ inherited frmDrawSettings: TfrmDrawSettings
Caption = 'Draw settings' Caption = 'Draw settings'
ClientHeight = 180 ClientHeight = 180
ClientWidth = 242 ClientWidth = 242
OnCreate = FormCreate
object rbTileList: TRadioButton[0] object rbTileList: TRadioButton[0]
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner AnchorSideTop.Control = Owner
Left = 8 Left = 8
Height = 19 Height = 22
Top = 8 Top = 8
Width = 125 Width = 146
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Bottom = 4 BorderSpacing.Bottom = 4
@ -27,9 +28,9 @@ inherited frmDrawSettings: TfrmDrawSettings
AnchorSideTop.Control = rbTileList AnchorSideTop.Control = rbTileList
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 8 Left = 8
Height = 19 Height = 22
Top = 31 Top = 34
Width = 184 Width = 213
BorderSpacing.Top = 4 BorderSpacing.Top = 4
Caption = 'Use tiles from the random pool' Caption = 'Use tiles from the random pool'
TabOrder = 1 TabOrder = 1
@ -43,18 +44,18 @@ inherited frmDrawSettings: TfrmDrawSettings
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 8 Left = 8
Height = 49 Height = 49
Top = 123 Top = 132
Width = 226 Width = 226
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 8 BorderSpacing.Around = 8
Caption = 'Hue (Statics only)' Caption = 'Hue (Statics only)'
ClientHeight = 31 ClientHeight = 45
ClientWidth = 222 ClientWidth = 222
TabOrder = 2 TabOrder = 2
object pbHue: TPaintBox object pbHue: TPaintBox
Cursor = crHandPoint Cursor = crHandPoint
Left = 4 Left = 4
Height = 27 Height = 41
Top = 0 Top = 0
Width = 214 Width = 214
Align = alClient Align = alClient
@ -70,9 +71,9 @@ inherited frmDrawSettings: TfrmDrawSettings
AnchorSideTop.Control = cbForceAltitude AnchorSideTop.Control = cbForceAltitude
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 8 Left = 8
Height = 19 Height = 22
Top = 93 Top = 102
Width = 135 Width = 149
BorderSpacing.Top = 12 BorderSpacing.Top = 12
Caption = 'Add Random Altitude' Caption = 'Add Random Altitude'
TabOrder = 3 TabOrder = 3
@ -83,8 +84,8 @@ inherited frmDrawSettings: TfrmDrawSettings
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 184 Left = 184
Height = 25 Height = 21
Top = 90 Top = 103
Width = 50 Width = 50
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Right = 8 BorderSpacing.Right = 8
@ -95,9 +96,9 @@ inherited frmDrawSettings: TfrmDrawSettings
AnchorSideTop.Control = rbRandom AnchorSideTop.Control = rbRandom
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 8 Left = 8
Height = 19 Height = 22
Top = 62 Top = 68
Width = 95 Width = 111
BorderSpacing.Top = 12 BorderSpacing.Top = 12
Caption = 'Force altitude:' Caption = 'Force altitude:'
TabOrder = 5 TabOrder = 5
@ -108,8 +109,8 @@ inherited frmDrawSettings: TfrmDrawSettings
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 184 Left = 184
Height = 25 Height = 21
Top = 59 Top = 69
Width = 50 Width = 50
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Right = 8 BorderSpacing.Right = 8
@ -117,4 +118,6 @@ inherited frmDrawSettings: TfrmDrawSettings
MinValue = -128 MinValue = -128
TabOrder = 6 TabOrder = 6
end end
inherited tmClose: TTimer[7]
end
end end

View File

@ -46,12 +46,15 @@ type
rbTileList: TRadioButton; rbTileList: TRadioButton;
seForceAltitude: TSpinEdit; seForceAltitude: TSpinEdit;
seRandomHeight: TSpinEdit; seRandomHeight: TSpinEdit;
procedure FormCreate(Sender: TObject);
procedure pbHueClick(Sender: TObject); procedure pbHueClick(Sender: TObject);
procedure pbHuePaint(Sender: TObject); procedure pbHuePaint(Sender: TObject);
procedure seForceAltitudeChange(Sender: TObject); procedure seForceAltitudeChange(Sender: TObject);
procedure seRandomHeightChange(Sender: TObject); procedure seRandomHeightChange(Sender: TObject);
public private
{ public declarations } FCanClose: Boolean;
function CanClose: Boolean; override;
procedure OnHueClose(Sender: TObject; var ACloseAction: TCloseAction);
end; end;
var var
@ -65,14 +68,17 @@ uses
{ TfrmDrawSettings } { TfrmDrawSettings }
procedure TfrmDrawSettings.pbHueClick(Sender: TObject); procedure TfrmDrawSettings.pbHueClick(Sender: TObject);
var
msg: TLMessage;
begin begin
frmHueSettings.Left := Mouse.CursorPos.x - 8; frmHueSettings.Left := Mouse.CursorPos.x - 8;
frmHueSettings.Top := Mouse.CursorPos.y - 8; frmHueSettings.Top := Mouse.CursorPos.y - 8;
frmHueSettings.ShowModal; frmHueSettings.OnClose := @OnHueClose;
pbHue.Repaint; frmHueSettings.Show;
MouseLeave(msg); FCanClose := False;
end;
procedure TfrmDrawSettings.FormCreate(Sender: TObject);
begin
FCanClose := True;
end; end;
procedure TfrmDrawSettings.pbHuePaint(Sender: TObject); procedure TfrmDrawSettings.pbHuePaint(Sender: TObject);
@ -100,7 +106,21 @@ begin
cbRandomHeight.Checked := True; cbRandomHeight.Checked := True;
end; end;
//TODO : canclose ---> hue settings function TfrmDrawSettings.CanClose: Boolean;
begin
Result := FCanClose and inherited CanClose;
end;
procedure TfrmDrawSettings.OnHueClose(Sender: TObject;
var ACloseAction: TCloseAction);
var
msg: TLMessage;
begin
FCanClose := True;
frmHueSettings.OnClose := nil;
pbHue.Repaint;
MouseLeave(msg);
end;
initialization initialization
{$I UfrmDrawSettings.lrs} {$I UfrmDrawSettings.lrs}

View File

@ -59,7 +59,8 @@ implementation
procedure TfrmToolWindow.FormDeactivate(Sender: TObject); procedure TfrmToolWindow.FormDeactivate(Sender: TObject);
begin begin
Close; if CanClose then
Close;
end; end;
procedure TfrmToolWindow.FormClose(Sender: TObject; procedure TfrmToolWindow.FormClose(Sender: TObject;

View File

@ -1084,7 +1084,7 @@ begin
acDraw.Checked := True; acDraw.Checked := True;
tbDrawTile.Down := True; tbDrawTile.Down := True;
mnuDraw.Checked := True; mnuDraw.Checked := True;
frmDrawSettings.ShowModal; frmDrawSettings.Show;
ProcessToolState; ProcessToolState;
end; end;