2008-02-03 12:05:55 +00:00
|
|
|
{*********************************************************}
|
|
|
|
{* VPDLG.PAS 1.03 *}
|
|
|
|
{*********************************************************}
|
|
|
|
|
|
|
|
{* ***** BEGIN LICENSE BLOCK ***** *}
|
|
|
|
{* Version: MPL 1.1 *}
|
|
|
|
{* *}
|
|
|
|
{* The contents of this file are subject to the Mozilla Public License *}
|
|
|
|
{* Version 1.1 (the "License"); you may not use this file except in *}
|
|
|
|
{* compliance with the License. You may obtain a copy of the License at *}
|
|
|
|
{* http://www.mozilla.org/MPL/ *}
|
|
|
|
{* *}
|
|
|
|
{* Software distributed under the License is distributed on an "AS IS" basis, *}
|
|
|
|
{* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License *}
|
|
|
|
{* for the specific language governing rights and limitations under the *}
|
|
|
|
{* License. *}
|
|
|
|
{* *}
|
|
|
|
{* The Original Code is TurboPower Visual PlanIt *}
|
|
|
|
{* *}
|
|
|
|
{* The Initial Developer of the Original Code is TurboPower Software *}
|
|
|
|
{* *}
|
|
|
|
{* Portions created by TurboPower Software Inc. are Copyright (C) 2002 *}
|
|
|
|
{* TurboPower Software Inc. All Rights Reserved. *}
|
|
|
|
{* *}
|
|
|
|
{* Contributor(s): *}
|
|
|
|
{* *}
|
|
|
|
{* ***** END LICENSE BLOCK ***** *}
|
|
|
|
|
2016-06-22 07:59:17 +00:00
|
|
|
{$I vp.inc}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
unit VpDlg;
|
|
|
|
{dialog components base classes}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF LCL}
|
|
|
|
Controls,
|
|
|
|
{$ELSE}
|
|
|
|
{$ENDIF}
|
2016-11-21 17:12:05 +00:00
|
|
|
Classes, Forms, Graphics,
|
|
|
|
VpBase, VpBaseDS, VpConst, VpSR;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
TVpDialogPosition = (mpCenter, mpCenterTop, mpCustom);
|
|
|
|
TVpDialogOption = (doSizeable);
|
|
|
|
TVpDialogOptions = set of TVpDialogOption;
|
|
|
|
|
|
|
|
TVpDialogPlacement = class(TPersistent)
|
|
|
|
protected {private}
|
|
|
|
{property variables}
|
|
|
|
FPosition : TVpDialogPosition;
|
|
|
|
FHeight : Integer;
|
|
|
|
FLeft : Integer;
|
|
|
|
FTop : Integer;
|
|
|
|
FWidth : Integer;
|
|
|
|
published
|
|
|
|
{properties}
|
|
|
|
property Position : TVpDialogPosition read FPosition write FPosition;
|
|
|
|
property Top : Integer read FTop write FTop;
|
|
|
|
property Left : Integer read FLeft write FLeft;
|
|
|
|
property Height : Integer read FHeight write FHeight;
|
|
|
|
property Width : Integer read FWidth write FWidth;
|
|
|
|
end;
|
|
|
|
|
|
|
|
TVpBaseDialog = class(TVpComponent)
|
|
|
|
protected {private}
|
|
|
|
{property variables}
|
|
|
|
FDataStore : TVpCustomDataStore;
|
|
|
|
FOptions : TVpDialogOptions;
|
|
|
|
FPlacement : TVpDialogPlacement;
|
|
|
|
FOnHelpClick : TNotifyEvent;
|
|
|
|
FControlLink : TVpControlLink;
|
|
|
|
|
|
|
|
function GetVersion: String;
|
|
|
|
procedure SetVersion(const Value: string);
|
2018-06-12 09:22:39 +00:00
|
|
|
procedure SetControlLink (const v: TVpControlLink);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure SetDataStore(Value: TVpCustomDataStore);
|
2018-06-12 09:22:39 +00:00
|
|
|
procedure DoFormPlacement(Form: TForm);
|
|
|
|
procedure SetFormCaption(Form: TForm; const Title, SubTitle: string);
|
|
|
|
property Options: TVpDialogOptions read FOptions write FOptions;
|
|
|
|
property Placement: TVpDialogPlacement read FPlacement write FPlacement;
|
2008-02-03 12:05:55 +00:00
|
|
|
public
|
2018-06-12 09:22:39 +00:00
|
|
|
constructor Create(AOwner: TComponent); override;
|
2008-02-03 12:05:55 +00:00
|
|
|
destructor Destroy; override;
|
2018-06-12 09:22:39 +00:00
|
|
|
function Execute: Boolean; virtual;
|
|
|
|
property ControlLink: TVpControlLink read FControlLink write SetControlLink;
|
2008-02-03 12:05:55 +00:00
|
|
|
published
|
|
|
|
property DataStore: TVpCustomDataStore read FDataStore write SetDataStore;
|
|
|
|
property Version: string read GetVersion write SetVersion;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2016-07-12 18:00:32 +00:00
|
|
|
uses
|
|
|
|
VpMisc;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
constructor TVpBaseDialog.Create(AOwner : TComponent);
|
|
|
|
var
|
|
|
|
I: integer;
|
|
|
|
begin
|
|
|
|
inherited Create(AOwner);
|
|
|
|
FOptions := [];
|
|
|
|
FPlacement := TVpDialogPlacement.Create;
|
|
|
|
FPlacement.Position := mpCenter;
|
|
|
|
FPlacement.Left := 10;
|
|
|
|
FPlacement.Height := 250;
|
|
|
|
FPlacement.Top := 10;
|
|
|
|
FPlacement.Width := 400;
|
|
|
|
|
|
|
|
{ connect to the first DataStore found on the parent form. }
|
|
|
|
I := 0;
|
|
|
|
if (csDesigning in ComponentState) and not (csLoading in ComponentState) then
|
|
|
|
while (I < Owner.ComponentCount) and (FDataStore = nil) do begin
|
|
|
|
if (Owner.Components[I] is TVpCustomDataStore) then
|
|
|
|
FDataStore := TVpCustomDataStore(Owner.Components[I])
|
|
|
|
else if (Owner.Components[I] is TVpControlLink) then
|
|
|
|
FControlLink := TVpControlLink (Owner.Components[I]);
|
|
|
|
Inc(I);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TVpBaseDialog.Destroy;
|
|
|
|
begin
|
|
|
|
FDataStore := nil;
|
|
|
|
FControlLink := nil;
|
|
|
|
|
|
|
|
FPlacement.Free;
|
|
|
|
FPlacement := nil;
|
|
|
|
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function TVpBaseDialog.Execute : Boolean;
|
|
|
|
begin
|
|
|
|
{ Do nothing. }
|
|
|
|
Result := False;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function TVpBaseDialog.GetVersion: string;
|
|
|
|
begin
|
|
|
|
Result := VpVersionStr;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpBaseDialog.SetFormCaption(Form : TForm; const Title, SubTitle : string);
|
|
|
|
begin
|
|
|
|
if Title = '' then
|
|
|
|
Form.Caption := RSUntitled + ' - ' + SubTitle
|
|
|
|
else
|
|
|
|
Form.Caption := Title + ' - ' + SubTitle;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpBaseDialog.SetVersion(const Value: string);
|
|
|
|
begin
|
2016-07-12 18:00:32 +00:00
|
|
|
Unused(Value);
|
2008-02-03 12:05:55 +00:00
|
|
|
// This method left intentionally blank.
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpBaseDialog.SetControlLink (const v : TVpControlLink);
|
|
|
|
begin
|
|
|
|
if FControlLink <> v then
|
|
|
|
FControlLink := v;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpBaseDialog.SetDataStore(Value: TVpCustomDataStore);
|
|
|
|
begin
|
|
|
|
if FDataStore <> Value then begin
|
|
|
|
FDataStore := Value;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpBaseDialog.DoFormPlacement(Form : TForm);
|
|
|
|
begin
|
|
|
|
{set proper style for displayed form}
|
|
|
|
if doSizeable in FOptions then
|
|
|
|
Form.BorderStyle := bsSizeable
|
|
|
|
else
|
|
|
|
Form.BorderStyle:= bsDialog;
|
|
|
|
|
2008-02-11 01:09:19 +00:00
|
|
|
if (Screen.ActiveForm <> nil)
|
|
|
|
and (Screen.ActiveForm.FormStyle = fsStayOnTop) then
|
2008-02-03 12:05:55 +00:00
|
|
|
Form.FormStyle := fsStayOnTop;
|
|
|
|
|
2008-02-11 01:09:19 +00:00
|
|
|
// Form.Height := FPlacement.Height;
|
|
|
|
// Form.Width := FPlacement.Width;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
{set position}
|
|
|
|
case FPlacement.Position of
|
|
|
|
mpCenter : begin
|
|
|
|
Form.Position := poScreenCenter;
|
|
|
|
end;
|
|
|
|
mpCenterTop : begin
|
|
|
|
Form.Top := (Screen.Height - Form.Height) div 3;
|
|
|
|
Form.Left := (Screen.Width - Form.Width) div 2;
|
|
|
|
end;
|
|
|
|
mpCustom : begin
|
|
|
|
Form.Top := FPlacement.Top;
|
|
|
|
Form.Left := FPlacement.Left;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|