home *** CD-ROM | disk | FTP | other *** search
- {*******************************************************}
- { }
- { eXpert Development Kit }
- { }
- { Copyright (c) 1996,97 Sergey Orlik }
- { - product manager of Borland Russia }
- { }
- {*******************************************************}
- unit XDKSteps;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ExtCtrls, ComCtrls;
-
- type
- TxdkSteps = class;
-
- TxdkStepTab = class(TTabSheet)
- private
- FOnBack : TNotifyEvent;
- FOnNext : TNotifyEvent;
- public
- constructor Create(AOwner: TComponent); override;
- procedure Loaded; override;
- published
- property OnBack:TNotifyEvent read FOnBack write FOnBack;
- property OnNext:TNotifyEvent read FOnNext write FOnNext;
- end;
-
- TxdkSteps = class(TCustomPanel)
- private
- FStepPages : TPageControl;
- FBtnAbout : TButton;
- FBtnBack : TButton;
- FBtnNext : TButton;
- FBtnCancel : TButton;
- FOnAbout : TNotifyEvent;
- FOnFinish : TNotifyEvent;
- FOnCancel : TNotifyEvent;
- FFormCaption : string;
- procedure ReboundChilds;
- protected
- procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
- procedure Resize; override;
- procedure DoBack(Sender: TObject); virtual;
- procedure DoNext(Sender: TObject); virtual;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure Loaded; override;
- procedure DisableNext;
- procedure EnableNext;
- property StepPages:TPageControl read FStepPages;
- published
- property BevelInner;
- property BevelOuter;
- property BevelWidth;
- property BorderWidth;
- property BorderStyle;
- property Enabled;
- property FullRepaint;
- property Color;
- property Ctl3D;
- property Font;
- property ParentColor;
- property ParentCtl3D;
- property ParentFont;
- property ParentShowHint;
- property PopupMenu;
- property ShowHint;
- property TabOrder;
- property TabStop;
- property Visible;
- property OnAbout:TNotifyEvent read FOnAbout write FOnAbout;
- property OnFinish:TNotifyEvent read FOnFinish write FOnFinish;
- property OnCancel:TNotifyEvent read FOnCancel write FOnCancel;
- end;
-
- //================================================================================
- implementation
-
- resourcestring
- sNext = 'Next >';
- sBack = '< Back';
- sFinish = 'Finish';
-
- //TxdkSteps
- constructor TxdkSteps.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
- csOpaque, csDoubleClicks, csReplicatable];
- Align:=alClient;
- BevelOuter:=bvNone;
- FullRepaint:=True;
- FStepPages:=TPageControl.Create(Self);
- FStepPages.Parent:=Self;
- FStepPages.Align:=alTop;
- FStepPages.TabPosition:=tpBottom;
- FBtnAbout:=TButton.Create(Self);
- FBtnAbout.Parent:=Self;
- FBtnAbout.Caption:='About';
- FBtnBack:=TButton.Create(Self);
- FBtnBack.Parent:=Self;
- FBtnBack.Caption:=sBack;
- FBtnNext:=TButton.Create(Self);
- FBtnNext.Parent:=Self;
- FBtnNext.Caption:=sNext;
- FBtnNext.Default:=true;
- FBtnCancel:=TButton.Create(Self);
- FBtnCancel.Parent:=Self;
- FBtnCancel.Caption:='Cancel';
- end;
-
- destructor TxdkSteps.Destroy;
- begin
- FBtnNext.Caption:=sNext;
- if not (csDesigning in ComponentState) then
- GetParentForm(Self).Caption:=FFormCaption;
- inherited Destroy;
- end;
-
- procedure TxdkSteps.GetChildren(Proc: TGetChildProc; Root: TComponent);
- var
- I: Integer;
- begin
- for I := 0 to FStepPages.PageCount - 1 do Proc(TComponent(FStepPages.Pages[I]));
- inherited GetChildren(Proc,Root);
- end;
-
- procedure TxdkSteps.Loaded;
- begin
- inherited Loaded;
- ReboundChilds;
- if not (csDesigning in ComponentState) then
- FFormCaption:=GetParentForm(Self).Caption;
- if (Assigned(FStepPages)) and (FStepPages.PageCount>0) then
- begin
- FStepPages.ActivePage:=FStepPages.Pages[0];
- if not (csDesigning in ComponentState) then
- GetParentForm(Self).Caption:=FFormCaption+Format(' : Step 1 of %d',[FStepPages.PageCount]);
- end;
- FBtnBack.Visible:=False;
- if Assigned(FOnAbout) then
- FBtnAbout.OnClick:=FOnAbout;
- if Assigned(FOnCancel) then
- FBtnCancel.OnClick:=FOnCancel;
- FBtnBack.OnClick:=DoBack;
- FBtnNext.OnClick:=DoNext;
- if not (Assigned(FStepPages) and (FStepPages.PageCount>1)) then
- begin
- FBtnNext.Caption:=sFinish;
- FBtnNext.Font.Style:=FBtnNext.Font.Style+[fsBold];
- end;
- end;
-
- procedure TxdkSteps.Resize;
- begin
- if Parent.ClientHeight<160 then
- Parent.ClientHeight:=160;
- if Parent.ClientWidth<360 then
- Parent.ClientWidth:=360;
- inherited Resize;
- ReboundChilds;
- end;
-
- procedure TxdkSteps.ReboundChilds;
- begin
- if Height<160 then
- Height:=160;
- if Width<360 then
- Width:=360;
- FStepPages.Height:=Height-33;
- FBtnAbout.Top:=Height-29;
- FBtnAbout.Left:=4;
- FBtnBack.Top:=Height-29;
- FBtnBack.Left:=Width-239;
- FBtnNext.Top:=Height-29;
- FBtnNext.Left:=Width-164;
- FBtnCancel.Top:=Height-29;
- FBtnCancel.Left:=Width-79;
- end;
-
- procedure TxdkSteps.DoBack(Sender: TObject);
- begin
- if FStepPages.ActivePage.PageIndex=0 then
- Exit;
- if Assigned(TxdkStepTab(FStepPages.ActivePage).OnBack) then
- TxdkStepTab(FStepPages.ActivePage).OnBack(Sender);
- if FStepPages.ActivePage.PageIndex=1 then
- FBtnBack.Visible:=False;
- if FStepPages.ActivePage.PageIndex=FStepPages.PageCount-1 then
- begin
- FBtnNext.Caption:=sNext;
- FBtnNext.Font.Style:=FBtnNext.Font.Style-[fsBold];
- end;
- FStepPages.ActivePage:=FStepPages.Pages[FStepPages.ActivePage.PageIndex-1];
- if not (csDesigning in ComponentState) then
- GetParentForm(Self).Caption:=FFormCaption+
- Format(' : Step %d of %d',[FStepPages.ActivePage.PageIndex+1,FStepPages.PageCount]);
- end;
-
- procedure TxdkSteps.DoNext(Sender: TObject);
- begin
- if ((FStepPages.PageCount>0)
- and (FStepPages.ActivePage.PageIndex=FStepPages.PageCount-1))
- or (FStepPages.PageCount=0)
- then
- begin
- if Assigned(Self.OnFinish) then
- OnFinish(Sender);
- Exit;
- end;
- if Assigned(TxdkStepTab(FStepPages.ActivePage).OnNext) then
- TxdkStepTab(FStepPages.ActivePage).OnNext(Sender);
- if FStepPages.ActivePage.PageIndex=0 then
- FBtnBack.Visible:=True;
- FStepPages.ActivePage:=FStepPages.Pages[FStepPages.ActivePage.PageIndex+1];
- if FStepPages.ActivePage.PageIndex=FStepPages.PageCount-1 then
- begin
- FBtnNext.Caption:=sFinish;
- FBtnNext.Font.Style:=FBtnNext.Font.Style+[fsBold];
- end;
- if not (csDesigning in ComponentState) then
- GetParentForm(Self).Caption:=FFormCaption+
- Format(' : Step %d of %d',[FStepPages.ActivePage.PageIndex+1,FStepPages.PageCount]);
- end;
-
- procedure TxdkSteps.DisableNext;
- begin
- FBtnNext.Enabled:=false;
- end;
-
- procedure TxdkSteps.EnableNext;
- begin
- FBtnNext.Enabled:=true;
- end;
-
- //================================================================================
- // TxdkStepTab
-
- constructor TxdkStepTab.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- if not (csDesigning in ComponentState) then
- TabVisible := False
- else
- TabVisible := True;
- end;
-
- procedure TxdkStepTab.Loaded;
- begin
- inherited Loaded;
- PageControl := TxdkSteps(Parent).FStepPages;//FSteps.FStepPages;
- end;
-
- //================================================================================
-
- end.
-