2008-02-03 12:05:55 +00:00
|
|
|
{*********************************************************}
|
|
|
|
{* VPEDFMT.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 VpEdFmt;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF LCL}
|
2016-06-22 07:59:17 +00:00
|
|
|
LCLProc, LCLType, LCLIntf,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ELSE}
|
2016-06-22 07:59:17 +00:00
|
|
|
Windows, Messages,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
2016-06-22 07:59:17 +00:00
|
|
|
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
2008-02-03 12:05:55 +00:00
|
|
|
StdCtrls, ExtCtrls, TypInfo, ComCtrls,
|
|
|
|
VpPrtFmt;
|
|
|
|
|
|
|
|
type
|
2016-07-07 18:27:26 +00:00
|
|
|
|
|
|
|
{ TfrmEditFormat }
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
TfrmEditFormat = class(TForm)
|
|
|
|
btnCancel: TButton;
|
|
|
|
btnOk: TButton;
|
|
|
|
edDescription: TEdit;
|
|
|
|
edName: TEdit;
|
2016-07-07 18:27:26 +00:00
|
|
|
LblIncrement: TLabel;
|
|
|
|
LblDescription: TLabel;
|
|
|
|
LblName: TLabel;
|
2008-02-03 12:05:55 +00:00
|
|
|
rgDayIncrement: TRadioGroup;
|
|
|
|
udIncrement: TUpDown;
|
|
|
|
edIncrement: TEdit;
|
|
|
|
procedure btnCancelClick(Sender: TObject);
|
|
|
|
procedure btnOkClick(Sender: TObject);
|
2016-07-07 18:27:26 +00:00
|
|
|
procedure FormCreate(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure FormShow(Sender: TObject);
|
2016-07-07 18:27:26 +00:00
|
|
|
private
|
|
|
|
procedure SetCaptions;
|
2008-02-03 12:05:55 +00:00
|
|
|
protected
|
|
|
|
procedure SaveData(AFormat: TVpPrintFormatItem);
|
|
|
|
procedure SetData(AFormat: TVpPrintFormatItem);
|
|
|
|
function Validate: Boolean;
|
|
|
|
public
|
|
|
|
function Execute(AFormat: TVpPrintFormatItem) : Boolean;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2016-06-07 16:34:18 +00:00
|
|
|
{$IFDEF LCL}
|
|
|
|
{$R *.lfm}
|
|
|
|
{$ELSE}
|
|
|
|
{$R *.dfm}
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
|
|
|
|
2016-07-07 18:27:26 +00:00
|
|
|
uses
|
|
|
|
Math, VpMisc, VpSR;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{ TfrmEditLayout }
|
|
|
|
|
|
|
|
procedure TfrmEditFormat.FormShow(Sender: TObject);
|
|
|
|
begin
|
|
|
|
edName.SetFocus;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
procedure TfrmEditFormat.btnCancelClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
ModalResult := mrCancel;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
procedure TfrmEditFormat.btnOkClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Validate then
|
|
|
|
ModalResult := mrOk
|
|
|
|
else begin
|
|
|
|
ShowMessage('Please supply a Format Name');
|
|
|
|
edName.SetFocus;
|
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
function TfrmEditFormat.Execute(AFormat: TVpPrintFormatItem) : Boolean;
|
|
|
|
begin
|
|
|
|
SetData(AFormat);
|
|
|
|
Result := ShowModal = mrOk;
|
|
|
|
if Result then
|
|
|
|
SaveData(AFormat);
|
|
|
|
end;
|
2016-07-07 18:27:26 +00:00
|
|
|
|
|
|
|
procedure TfrmEditFormat.FormCreate(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SetCaptions;
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{=====}
|
|
|
|
procedure TfrmEditFormat.SaveData(AFormat: TVpPrintFormatItem);
|
|
|
|
var
|
|
|
|
EnumVal : Integer;
|
|
|
|
begin
|
|
|
|
AFormat.FormatName := edName.Text;
|
|
|
|
AFormat.Description := edDescription.Text;
|
|
|
|
AFormat.DayInc := udIncrement.Position;
|
|
|
|
|
|
|
|
EnumVal := GetEnumValue(TypeInfo(TVpDayUnits), 'du' + rgDayIncrement.Items[rgDayIncrement.ItemIndex]);
|
|
|
|
if EnumVal > -1 then
|
|
|
|
AFormat.DayIncUnits := TVpDayUnits(EnumVal)
|
|
|
|
else
|
|
|
|
AFormat.DayIncUnits := duDay;
|
|
|
|
end;
|
2016-07-07 18:27:26 +00:00
|
|
|
|
|
|
|
procedure TfrmEditFormat.SetCaptions;
|
|
|
|
const
|
|
|
|
DELTA = 8;
|
|
|
|
MARGIN = 16;
|
|
|
|
var
|
|
|
|
cnv: TControlCanvas;
|
|
|
|
w: Integer;
|
|
|
|
begin
|
|
|
|
Caption := RSEditFormatCaption;
|
|
|
|
LblName.Caption := RSNameLbl;
|
|
|
|
LblDescription.Caption := RSDescriptionLbl;
|
|
|
|
LblIncrement.Caption := RsTimeIncLbl;
|
|
|
|
rgDayIncrement.Caption := RsTimeIncUnits;
|
|
|
|
rgDayIncrement.Items[0] := RSDays;
|
|
|
|
rgDayIncrement.Items[1] := RSWeeks;
|
|
|
|
rgDayIncrement.Items[2] := RSMonths;
|
|
|
|
rgDayIncrement.Items[3] := RSYears;
|
|
|
|
btnOK.Caption := RSOKBtn;
|
|
|
|
btnCancel.Caption := RSCancelBtn;
|
|
|
|
|
|
|
|
w := MaxValue([GetLabelWidth(LblName), GetLabelWidth(LblDescription), GetLabelWidth(LblIncrement)]);
|
|
|
|
edName.Left := MARGIN + w + DELTA;
|
|
|
|
edDescription.Left := edName.Left;
|
|
|
|
edDescription.Width := edName.Width;
|
|
|
|
edIncrement.Left := edName.Left;
|
|
|
|
udIncrement.Left := edIncrement.Left + edIncrement.Width;
|
|
|
|
LblName.Left := edName.Left - GetLabelWidth(LblName) - DELTA;
|
|
|
|
LblDescription.Left := edDescription.Left - GetLabelWidth(lblDescription) - DELTA;
|
|
|
|
lblIncrement.Left := edIncrement.Left - GetLabelWidth(lblIncrement) - DELTA;
|
|
|
|
|
|
|
|
ClientWidth := MARGIN + w + DELTA + edName.Width + MARGIN;
|
|
|
|
rgDayIncrement.Width := ClientWidth - 2*MARGIN;
|
|
|
|
|
|
|
|
cnv := TControlCanvas.Create;
|
|
|
|
try
|
|
|
|
cnv.Control := btnOK;
|
|
|
|
cnv.Font.Assign(btnOK.Font);
|
|
|
|
w := Max(cnv.TextWidth(RSOKBtn), cnv.TextWidth(RSCancelBtn));
|
|
|
|
finally
|
|
|
|
cnv.Free;
|
|
|
|
end;
|
|
|
|
btnOK.Width := w + 16;
|
|
|
|
btnCancel.Width := w + 16;
|
|
|
|
btnCancel.Left := ClientWidth - MARGIN - btnCancel.Width;
|
|
|
|
btnOK.Left := btnCancel.Left - 8 - btnOK.Width;
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TfrmEditFormat.SetData(AFormat: TVpPrintFormatItem);
|
|
|
|
var
|
|
|
|
IncName : string;
|
|
|
|
begin
|
|
|
|
edName.Text := AFormat.FormatName;
|
|
|
|
edDescription.Text := AFormat.Description;
|
|
|
|
udIncrement.Position := AFormat.DayInc;
|
|
|
|
|
|
|
|
IncName := GetEnumName(TypeInfo(TVpDayUnits), Ord(AFormat.DayIncUnits));
|
|
|
|
if IncName <> '' then begin
|
|
|
|
rgDayIncrement.ItemIndex := rgDayIncrement.Items.IndexOf(Copy(IncName, 3, Length(IncName) - 2));
|
|
|
|
end
|
|
|
|
else
|
|
|
|
rgDayIncrement.ItemIndex := 0;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
function TfrmEditFormat.Validate : Boolean;
|
|
|
|
begin
|
|
|
|
Result := edName.Text <> '';
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end.
|
|
|
|
|