Ignore:
Timestamp:
Mar 8, 2011, 1:57:42 PM (14 years ago)
Author:
george
Message:
  • Added: Customization of layouts in "Customize docking" window.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCoolDockCustomize.pas

    r97 r180  
    77uses
    88  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
    9   ComCtrls, StdCtrls, Spin;
     9  ComCtrls, StdCtrls, Spin, UCoolDockLayout;
    1010
    1111type
     
    1414
    1515  TCoolDockCustomizeForm = class(TForm)
     16  published
     17    ButtonLayoutDelete: TButton;
     18    ButtonLayoutApply: TButton;
     19    ButtonLayoutRename: TButton;
     20    ButtonLayoutNew: TButton;
     21    ButtonLayoutSave: TButton;
    1622    ButtonClose: TButton;
    1723    ComboBox1: TComboBox;
     
    2733    TabSheetLayouts: TTabSheet;
    2834    procedure ButtonCloseClick(Sender: TObject);
     35    procedure ButtonLayoutApplyClick(Sender: TObject);
     36    procedure ButtonLayoutDeleteClick(Sender: TObject);
     37    procedure ButtonLayoutNewClick(Sender: TObject);
     38    procedure ButtonLayoutRenameClick(Sender: TObject);
    2939    procedure FormShow(Sender: TObject);
     40    procedure ListBox1SelectionChange(Sender: TObject; User: boolean);
    3041  private
    3142    { private declarations }
    3243  public
     44    LayoutList: TCoolDockLayoutList;
    3345  end;
    3446
    3547implementation
    3648
     49resourcestring
     50  SNewLayout = 'New Layout';
     51  SEnterNewName = 'Enter new name';
    3752
    3853{ TCoolDockCustomizeForm }
     
    4358end;
    4459
     60procedure TCoolDockCustomizeForm.ButtonLayoutApplyClick(Sender: TObject);
     61begin
     62  if ListBox1.ItemIndex <> - 1 then
     63    TCoolDockLayout(LayoutList.Items[ListBox1.ItemIndex]).Restore;
     64end;
     65
     66procedure TCoolDockCustomizeForm.ButtonLayoutDeleteClick(Sender: TObject);
     67begin
     68  if ListBox1.ItemIndex <> - 1 then begin
     69    LayoutList.Items.Delete(ListBox1.ItemIndex);
     70    LayoutList.PopulateStringList(ListBox1.Items);
     71  end;
     72end;
     73
     74procedure TCoolDockCustomizeForm.ButtonLayoutNewClick(Sender: TObject);
     75var
     76  NewLayout: TCoolDockLayout;
     77  NewName: string;
     78begin
     79  NewName := SNewLayout;
     80  if InputQuery(SNewLayout, SEnterNewName, NewName) then
     81  if not Assigned(LayoutList.FindByName(NewName)) then begin
     82    NewLayout := TCoolDockLayout.Create;
     83    NewLayout.Name := NewName;
     84    NewLayout.Store;
     85    LayoutList.Items.Add(NewLayout);
     86    LayoutList.PopulateStringList(ListBox1.Items);
     87  end;
     88end;
     89
     90procedure TCoolDockCustomizeForm.ButtonLayoutRenameClick(Sender: TObject);
     91var
     92  NewName: string;
     93begin
     94  NewName := TCoolDockLayout(LayoutList.Items[ListBox1.ItemIndex]).Name;
     95  if InputQuery(SNewLayout, SEnterNewName, NewName) then begin
     96    TCoolDockLayout(LayoutList.Items[ListBox1.ItemIndex]).Name := NewName;
     97    LayoutList.PopulateStringList(ListBox1.Items);
     98  end;
     99end;
     100
    45101procedure TCoolDockCustomizeForm.FormShow(Sender: TObject);
    46102begin
     103  if Assigned(LayoutList) then begin
     104    LayoutList.PopulateStringList(ListBox1.Items);
     105  end;
     106end;
    47107
     108procedure TCoolDockCustomizeForm.ListBox1SelectionChange(Sender: TObject;
     109  User: boolean);
     110begin
     111  ButtonLayoutRename.Enabled := ListBox1.ItemIndex <> -1;
     112  ButtonLayoutDelete.Enabled := ListBox1.ItemIndex <> -1;
     113  ButtonLayoutApply.Enabled := ListBox1.ItemIndex <> -1;
     114  ButtonLayoutSave.Enabled := ListBox1.ItemIndex <> -1;
    48115end;
    49116
Note: See TracChangeset for help on using the changeset viewer.