aoutlsed.pas

来自「delphi编程控件」· PAS 代码 · 共 548 行 · 第 1/2 页

PAS
548
字号
unit aoutlsed;
(*
 COPYRIGHT (c) RSD Software 1997 - 98
 All Rights Reserved.
*)

interface
{$I aclver.inc}

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, aimctrls, ExtCtrls, aoutlbar;

type
  TFAutoOutLookBarStoreEditor = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    ListBox: TListBox;
    LItemCaption: TLabel;
    EItemCaption: TEdit;
    LLImage: TLabel;
    Panel3: TPanel;
    Panel4: TPanel;
    GBGroups: TGroupBox;
    BGAdd: TButton;
    BGInsert: TButton;
    BGDelete: TButton;
    BGRename: TButton;
    BGMoveUp: TButton;
    BGMoveDown: TButton;
    Panel5: TPanel;
    GBItems: TGroupBox;
    BIAdd: TButton;
    BIDelete: TButton;
    BIClear: TButton;
    BIMoveUp: TButton;
    BIMoveDown: TButton;
    LSImage: TLabel;
    BClose: TButton;
    BHelp: TButton;
    ImageListBox: TAutoImageListBox;
    SILImage: TAutoSpinImage;
    SISImage: TAutoSpinImage;
    EItemHint: TEdit;
    LItemHint: TLabel;
    procedure BGAddClick(Sender: TObject);
    procedure BGInsertClick(Sender: TObject);
    procedure BGRenameClick(Sender: TObject);
    procedure BGDeleteClick(Sender: TObject);
    procedure ListBoxClick(Sender: TObject);
    procedure BIAddClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ImageListBoxClick(Sender: TObject);
    procedure BGMoveUpClick(Sender: TObject);
    procedure BGMoveDownClick(Sender: TObject);
    procedure EItemCaptionExit(Sender: TObject);
    procedure SIImageChange(Sender: TObject; ItemIndex: Integer);
    procedure BIDeleteClick(Sender: TObject);
    procedure BIClearClick(Sender: TObject);
    procedure BIMoveUpClick(Sender: TObject);
    procedure BIMoveDownClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ImageListBoxDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure ListBoxDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure ImageListBoxEndDrag(Sender, Target: TObject; X, Y: Integer);
    procedure SISImageChange(Sender: TObject; ItemIndex: Integer);
    procedure BCloseClick(Sender: TObject);
    procedure BHelpClick(Sender: TObject);
    procedure EItemHintExit(Sender: TObject);
  private
    Store : TAutoOutLookBarStore;
    ActiveItem : TAutoOutLookStoredItem;
    procedure WMGetMinMaxInfo(var Message: TMessage); message WM_GETMINMAXINFO;
  end;


procedure ShowAutoOutLookBarStoreEditor(AStore : TAutoOutLookBarStore);
procedure CloseAutoOutLookBarStoreEditor(AStore : TAutoOutLookBarStore);
procedure AutoOutLookBarStoreEditorUpdate(AStore : TAutoOutLookBarStore);
procedure AutoOutLookBarStoreEditorUpdateItem(AItem : TAutoOutLookStoredItem);

implementation

uses Dsgnintf, aoutlsgr, autostrs, areginf;

{$R *.DFM}

procedure ShowAutoOutLookBarStoreEditor(AStore : TAutoOutLookBarStore);
Var
  AForm : TFAutoOutLookBarStoreEditor;
begin
  if(AStore.Designer = Nil) then begin
    AStore.Designer := TFAutoOutLookBarStoreEditor.Create(Nil);
    with TFAutoOutLookBarStoreEditor(AStore.Designer) do begin
      ListBox.Items.Assign(AStore.Categories);
      if(ListBox.Items.Count > 0) then
        ListBox.ItemIndex := 0;
    end;
  end;

  AForm := TFAutoOutLookBarStoreEditor(AStore.Designer);
  AForm.Store := AStore;
  AutoOutLookBarStoreEditorUpdate(AStore);
  AForm.ListBoxClick(Nil);
  AForm.Show;
end;

procedure CloseAutoOutLookBarStoreEditor(AStore : TAutoOutLookBarStore);
begin
  if(AStore.Designer <> Nil) then
    TFAutoOutLookBarStoreEditor(AStore.Designer).Close;
end;

procedure AutoOutLookBarStoreEditorUpdate(AStore : TAutoOutLookBarStore);
Var
  AForm : TFAutoOutLookBarStoreEditor;
begin
  if(AStore.Designer <> Nil) then begin
    AForm := TFAutoOutLookBarStoreEditor(AStore.Designer);
    with AForm do begin
      Caption := LoadStr(AEC_OUTLOOKBARSTORE) + AStore.Name;
      ImageListBox.ImageList := AStore.LargeImages;
      SILImage.ImageList := AStore.LargeImages;
      SISImage.ImageList := AStore.SmallImages;      
    end;
  end;
end;

procedure AutoOutLookBarStoreEditorUpdateItem(AItem : TAutoOutLookStoredItem);
Var
  AForm : TFAutoOutLookBarStoreEditor;
begin
  if(AItem <> Nil) And (AItem.Store.Designer <> Nil) then begin
    AForm := TFAutoOutLookBarStoreEditor(AItem.Store.Designer);
    if (AForm.ListBox.ItemIndex < 0) then exit;
    if(AForm.ListBox.ItemIndex <> AItem.Category) then begin
      if(AForm.ImageListBox.Items.Count <>
      AItem.Store.GetCountByCategory(AForm.ListBox.Items[AForm.ListBox.ItemIndex])) then
        AForm.ListBoxClick(Nil);
    end else  AForm.ImageListBoxClick(Nil);
  end;
end;

procedure TFAutoOutLookBarStoreEditor.WMGetMinMaxInfo(var Message: TMessage);
var
   P : PMinMaxInfo;
begin
    P:=PMinMaxInfo(Message.lParam);
    P^.ptMinTrackSize.X:= 450;
    P^.ptMinTrackSize.Y:= 315;
end;

procedure TFAutoOutLookBarStoreEditor.BGAddClick(Sender: TObject);
Var
  St : String;
begin
  St := '';
  if AutoOLSGroupRename(St, 0) then begin
    Store.Categories.Add(St);
    ListBox.Items.Add(St);
  end;
end;

procedure TFAutoOutLookBarStoreEditor.BGInsertClick(Sender: TObject);
Var
  St : String;
begin
  St := '';
  if AutoOLSGroupRename(St, 1) then begin
    Store.Categories.Insert(ListBox.ItemIndex, St);
    ListBox.Items.Insert(ListBox.ItemIndex, St);
  end;
end;

procedure TFAutoOutLookBarStoreEditor.BGRenameClick(Sender: TObject);
Var
  St : String;
  Index : Integer;
begin
  if(ListBox.ItemIndex > -1) then begin
    Index := ListBox.ItemIndex;
    St := ListBox.Items[ListBox.ItemIndex];
    if AutoOLSGroupRename(St, 2) then begin
      Store.Categories[ListBox.ItemIndex] := St;
      ListBox.Items[ListBox.ItemIndex] := St;
    end;
    ListBox.ItemIndex := Index;
  end
end;

procedure TFAutoOutLookBarStoreEditor.BGDeleteClick(Sender: TObject);
var
  Index : Integer;
begin
  if(ListBox.ItemIndex > -1) then begin
    Index := ListBox.ItemIndex;
    Store.Categories.Delete(ListBox.ItemIndex);
    if(Store.Categories.Count <> ListBox.Items.Count) then
      ListBox.Items.Delete(ListBox.ItemIndex);
    if(Index >= ListBox.Items.Count) then
      Dec(Index);
    ListBox.ItemIndex := Index;
    ListBoxClick(Sender);
  end;
end;

procedure TFAutoOutLookBarStoreEditor.ListBoxClick(Sender: TObject);
Var
  List : TList;
  i : Integer;
  item : TAutoOutLookStoredItem;
begin
  ImageListBox.Items.Clear;
  if(ListBox.ItemIndex > -1) then begin
    List := TList.Create;
    Store.GetItemsByCategory(ListBox.Items[ListBox.ItemIndex], List);
    for i := 0 to List.Count - 1 do begin
      Item := TAutoOutLookStoredItem(List[i]);
      ImageListBox.AddItem(Item.Caption, Item.LargeImage)
    end;
    List.Free;
  end;
  if(ImageListBox.Items.Count > 0) then
    ImageListBox.ItemIndex := 0;
  ImageListBoxClick(Sender);
end;

procedure TFAutoOutLookBarStoreEditor.BIAddClick(Sender: TObject);
Var
  item : TAutoOutLookStoredItem;
  i : Integer;
  flag : Boolean;
begin
  item := TAutoOutLookStoredItem.Create(Store.Owner);
  item.Store := Store;
  item.Category := ListBox.ItemIndex;
  i := Store.Count;
  flag := True;
  while Flag do begin
    try
      item.Name := Store.Name + 'Item' + IntToStr(i);
      flag := False;
    except
      Inc(i);
    end;
  end;
  ImageListBox.AddItem(Item.Caption, -1);
  ImageListBox.ItemIndex := ImageListBox.Items.Count - 1;
  ImageListBoxClick(Sender);
end;


procedure TFAutoOutLookBarStoreEditor.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Store.Designer := Nil;
  if Not (csDestroying in Store.ComponentState)
  And  (csDesigning in Store.ComponentState) then
{$IFDEF DELPHI4}IFormDesigner{$ELSE}TFormDesigner{$ENDIF}(TForm(Store.Owner).Designer).SelectComponent(Store);
  StoreAutoFormsInformtion(self);
  Action := caFree;
end;

procedure TFAutoOutLookBarStoreEditor.ImageListBoxClick(Sender: TObject);
var
  AComponent : TComponent;
begin
  ActiveItem := Nil;
  if(ImageListBox.ItemIndex > -1) then
    ActiveItem := Store.GetItemByCategory(ListBox.Items[ListBox.ItemIndex], ImageListBox.ItemIndex);

  EItemCaption.Enabled := ActiveItem <> Nil;

⌨️ 快捷键说明

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