⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jvwizardeditorform.pas

📁 East make Tray Icon in delphi
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{-----------------------------------------------------------------------------
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/MPL-1.1.html

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.

The Original Code is: JvWizardEditorForm.PAS, released on 2002-01-29.

The Initial Developer of the Original Code is William Yu Wei.
Portions created by William Yu Wei are Copyright (C) 2002 William Yu Wei.
All Rights Reserved.

Contributor(s):
Peter Th鰎nqvist - converted to JVCL naming conventions on 2003-07-11

You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net

Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvWizardEditorForm.pas,v 1.15 2004/12/25 09:02:34 marquardt Exp $

{*****************************************************************************
  Purpose:   Jv Wizard Component Editor

  History:
  ---------------------------------------------------------------------------
  Date(mm/dd/yy)   Comments
  ---------------------------------------------------------------------------
  01/29/2002       Initial create
                   1) Move TJvWizardActivePageProperty, TJvWizardEditor
                      class from JvWizardReg to here
                   2) TJvWizardPageListProperty added
                      TJvWizardPageList dialog form added
******************************************************************************}

unit JvWizardEditorForm;

{$I jvcl.inc}

interface

uses
  SysUtils, Classes,
  Windows, Messages, Graphics, Controls, Forms, Dialogs,
  ActnList, ImgList, ComCtrls, StdCtrls, ToolWin, Menus,
  {$IFDEF COMPILER6_UP}
  DesignIntf, DesignEditors,
  DesignWindows,
  {$ELSE}
  DsgnIntf, DsgnWnds,
  {$ENDIF COMPILER6_UP}
  JvWizard;

type
  TJvWizardActivePageProperty = class(TComponentProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure GetValues(Proc: TGetStrProc); override;
  end;

  // JvWizard Component Local Menu Editor
  TJvWizardEditor = class(TComponentEditor)
  protected
    function GetWizard: TJvWizard; virtual;
    procedure AddPage(Page: TJvWizardCustomPage);
    procedure AddWelcomePage;
    procedure AddInteriorPage;
    procedure NextPage(Step: Integer);
    property Wizard: TJvWizard read GetWizard;
  public
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

  TJvWizardPageListProperty = class(TPropertyEditor)
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string; override;
    procedure Edit; override;
  end;

  TJvWizardPageListEditor = class(TDesignWindow)
    tbrWizardPages: TToolBar;
    lbxWizardPages: TListBox;
    btnAddWelcomePage: TToolButton;
    btnDeletePages: TToolButton;
    ToolButton1: TToolButton;
    imgWizardPages: TImageList;
    actWizardPages: TActionList;
    actAddWelcomePage: TAction;
    actAddInteriorPage: TAction;
    actDeletePages: TAction;
    popWizard: TPopupMenu;
    AddWelcomePage1: TMenuItem;
    AddInteriorPage1: TMenuItem;
    tbMoveUp: TToolButton;
    tbMoveDown: TToolButton;
    acMoveUp: TAction;
    acMoveDown: TAction;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure actAddWelcomePageExecute(Sender: TObject);
    procedure actAddInteriorPageExecute(Sender: TObject);
    procedure actDeletePagesExecute(Sender: TObject);
    procedure actDeletePagesUpdate(Sender: TObject);
    procedure lbxWizardPagesClick(Sender: TObject);
    procedure lbxWizardPagesMouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure lbxWizardPagesDragOver(Sender, Source: TObject; X,
      Y: Integer; State: TDragState; var Accept: Boolean);
    procedure lbxWizardPagesDragDrop(Sender, Source: TObject; X,
      Y: Integer);
    procedure actWizardPagesUpdate(Action: TBasicAction;
      var Handled: Boolean);
    procedure acMoveUpExecute(Sender: TObject);
    procedure acMoveDownExecute(Sender: TObject);
  private
    FWizard: TJvWizard;
    procedure SetWizard(const Value: TJvWizard);
    procedure UpdatePageList(const CurrItemIndex: Integer);
    procedure SelectWizardPage(const Index: Integer);
  protected
    procedure AddPage(Page: TJvWizardCustomPage);
    procedure AddWelcomePage;
    procedure AddInteriorPage;
    property Wizard: TJvWizard
      read FWizard write SetWizard;
  public
    procedure Activated; override;
    {$IFDEF COMPILER6_UP}
    procedure ItemDeleted(const ADesigner: IDesigner; Item: TPersistent); override;
    procedure DesignerClosed(const Designer: IDesigner; AGoingDormant: Boolean); override;
    procedure ItemsModified(const Designer: IDesigner); override;
    {$ELSE}
    procedure ComponentDeleted(Component: IPersistent); override;
    function UniqueName(Component: TComponent): string; override;
    procedure FormClosed(AForm: TCustomForm); override;
    procedure FormModified; override;
    {$ENDIF COMPILER6_UP}
    function GetEditState: TEditState; override;
  end;

implementation

{$IFDEF USEJVCL}
uses
  JvDsgnConsts;
{$ENDIF USEJVCL}

{$R *.dfm}

{$IFNDEF USEJVCL}
resourcestring
  RsPageListEllipsis = 'Page List...';
  RsNewWelcomePage = 'New Welcome Page';
  RsNewInteriorPage = 'New Interior Page';
  RsDeletePage = 'Delete Page';
  RsNextPage = 'Next Page';
  RsPreviousPage = 'Previous Page';
  RsNone = '(none)';
{$ENDIF !USEJVCL}

procedure ShowWizardPageListEditor(Designer: IDesigner; AWizard: TJvWizard);
var
  I: Integer;
  AWizardPageListEditor: TJvWizardPageListEditor;
begin
  // because the page list editor is not show modal, so
  // we need to find it rather than create a new instance.
  AWizardPageListEditor := nil;
  for I := 0 to Screen.FormCount - 1 do
    if Screen.Forms[I] is TJvWizardPageListEditor then
      if TJvWizardPageListEditor(Screen.Forms[I]).Wizard = AWizard then
      begin
        AWizardPageListEditor := TJvWizardPageListEditor(Screen.Forms[I]);
        Break;
      end;
  // Show the wizard editor
  if Assigned(AWizardPageListEditor) then
  begin
    AWizardPageListEditor.Show;
    if AWizardPageListEditor.WindowState = wsMinimized then
      AWizardPageListEditor.WindowState := wsNormal;
  end
  else
  begin
    AWizardPageListEditor := TJvWizardPageListEditor.Create(Application);
    try
      {$IFDEF COMPILER6_UP}
      AWizardPageListEditor.Designer := Designer;
      {$ELSE}
      AWizardPageListEditor.Designer := IFormDesigner(Designer);
      {$ENDIF COMPILER6_UP}
      AWizardPageListEditor.Wizard := AWizard;
      AWizardPageListEditor.Show;
    except
      AWizardPageListEditor.Free;
      raise;
    end;
  end;
end;

//=== { TJvWizardActivePageProperty } ========================================

function TJvWizardActivePageProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList];
end;

procedure TJvWizardActivePageProperty.GetValues(Proc: TGetStrProc);
var
  I: Integer;
  Component: TComponent;
begin
  for I := 0 to Designer.GetRoot.ComponentCount - 1 do
  begin
    Component := Designer.GetRoot.Components[I];
    if (Component.Name <> '') and (Component is TJvWizardCustomPage) and
      (TJvWizardCustomPage(Component).Wizard = GetComponent(0)) then
      Proc(Component.Name);
  end;
end;

//=== { TJvWizardEditor } ====================================================

procedure TJvWizardEditor.AddPage(Page: TJvWizardCustomPage);
begin
  Page.Parent := Wizard;
  Page.Wizard := Wizard;
  Designer.SelectComponent(Page);
  Wizard.ActivePage := Page;
  Designer.Modified;
end;

procedure TJvWizardEditor.AddInteriorPage;
var
  Page: TJvWizardInteriorPage;
begin
  Page := TJvWizardInteriorPage.Create(Designer.GetRoot);
  try
    Page.Name := Designer.UniqueName(TJvWizardInteriorPage.ClassName);
    AddPage(Page);
  except
    Page.Free;
    raise;
  end;
end;

procedure TJvWizardEditor.AddWelcomePage;
var
  Page: TJvWizardWelcomePage;
begin
  Page := TJvWizardWelcomePage.Create(Designer.GetRoot);
  try
    Page.Name := Designer.UniqueName(TJvWizardWelcomePage.ClassName);
    AddPage(Page);
  except
    Page.Free;
    raise;
  end;
end;

procedure TJvWizardEditor.ExecuteVerb(Index: Integer);
begin
  case Index of
    0:
      ShowWizardPageListEditor(Designer, GetWizard);
    1:
      AddWelcomePage;
    2:
      AddInteriorPage;
    3:
      NextPage(1);
    4:
      NextPage(-1);
    5:
      if Assigned(Wizard.ActivePage) then
      begin
        Designer.SelectComponent(Wizard);
        Wizard.ActivePage.Free;
        Designer.Modified;
      end;
  end;
end;

function TJvWizardEditor.GetWizard: TJvWizard;
begin
  if Component is TJvWizard then
    Result := TJvWizard(Component)
  else
    Result := TJvWizard(TJvWizardCustomPage(Component).Wizard);
end;

function TJvWizardEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0:
      Result := RsPageListEllipsis;
    1:
      Result := RsNewWelcomePage;
    2:
      Result := RsNewInteriorPage;
    3:
      Result := RsNextPage;
    4:
      Result := RsPreviousPage;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -