| 1 |
yoffy |
1.1 |
unit ToolBarSetting; |
| 2 |
|
|
|
| 3 |
|
|
interface |
| 4 |
|
|
|
| 5 |
|
|
uses |
| 6 |
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
| 7 |
|
|
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ActnList, IniFiles, |
| 8 |
|
|
GikoSystem, ToolBarUtil; |
| 9 |
|
|
|
| 10 |
|
|
type |
| 11 |
|
|
TGikoToolType = (gttStandard, gttList, gttBrowser); |
| 12 |
|
|
|
| 13 |
|
|
TToolBarItem = class |
| 14 |
|
|
private |
| 15 |
|
|
FToolBar: TToolBar; |
| 16 |
|
|
FButtonActionList: TList; |
| 17 |
|
|
FToolType: TGikoToolType; |
| 18 |
|
|
public |
| 19 |
|
|
constructor Create; |
| 20 |
|
|
destructor Destroy; override; |
| 21 |
|
|
property ToolBar: TToolBar read FToolBar write FToolBar; |
| 22 |
|
|
property ButtonActionList: TList read FButtonActionList write FButtonActionList; |
| 23 |
|
|
property ToolType: TGikoToolType read FToolType write FToolType; |
| 24 |
|
|
end; |
| 25 |
|
|
|
| 26 |
|
|
TToolBarSettingDialog = class(TForm) |
| 27 |
|
|
Label1: TLabel; |
| 28 |
|
|
AllListView: TListView; |
| 29 |
|
|
AddButton: TButton; |
| 30 |
|
|
RemoveButton: TButton; |
| 31 |
|
|
CurrentListView: TListView; |
| 32 |
|
|
Label2: TLabel; |
| 33 |
|
|
UpButton: TButton; |
| 34 |
|
|
DownButton: TButton; |
| 35 |
|
|
OKButton: TButton; |
| 36 |
|
|
CancelButton: TButton; |
| 37 |
|
|
Bevel1: TBevel; |
| 38 |
|
|
Label3: TLabel; |
| 39 |
|
|
ToolBarComboBox: TComboBox; |
| 40 |
|
|
SeparatorAddButton: TButton; |
| 41 |
|
|
ResetButton: TButton; |
| 42 |
|
|
procedure FormCreate(Sender: TObject); |
| 43 |
|
|
procedure FormDestroy(Sender: TObject); |
| 44 |
|
|
procedure ToolBarComboBoxChange(Sender: TObject); |
| 45 |
|
|
procedure OKButtonClick(Sender: TObject); |
| 46 |
|
|
procedure CurrentListViewData(Sender: TObject; Item: TListItem); |
| 47 |
|
|
procedure AllListViewData(Sender: TObject; Item: TListItem); |
| 48 |
|
|
procedure UpButtonClick(Sender: TObject); |
| 49 |
|
|
procedure DownButtonClick(Sender: TObject); |
| 50 |
|
|
procedure ResetButtonClick(Sender: TObject); |
| 51 |
|
|
procedure CurrentListViewChange(Sender: TObject; Item: TListItem; |
| 52 |
|
|
Change: TItemChange); |
| 53 |
|
|
procedure AllListViewChange(Sender: TObject; Item: TListItem; |
| 54 |
|
|
Change: TItemChange); |
| 55 |
|
|
procedure AddButtonClick(Sender: TObject); |
| 56 |
|
|
procedure RemoveButtonClick(Sender: TObject); |
| 57 |
|
|
procedure SeparatorAddButtonClick(Sender: TObject); |
| 58 |
|
|
procedure FormShow(Sender: TObject); |
| 59 |
|
|
private |
| 60 |
|
|
{ Private 鐃緒申鐃緒申 } |
| 61 |
|
|
FActionList: TActionList; |
| 62 |
|
|
FAllList: TList; |
| 63 |
yoffy |
1.4 |
FToolBarIndex : Integer; // 鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃? |
| 64 |
yoffy |
1.1 |
procedure CreateListData(ToolBarItem: TToolBarItem); |
| 65 |
|
|
procedure MoveItem(Offset: Integer); |
| 66 |
|
|
procedure Sort; |
| 67 |
|
|
function SetDefaultItem(deflist: array of string; ToolBarItem: TToolBarItem): Integer; |
| 68 |
|
|
public |
| 69 |
|
|
{ Public 鐃緒申鐃緒申 } |
| 70 |
|
|
constructor Create(AOwner: TComponent; ActionList: TActionList); reintroduce; overload; virtual; |
| 71 |
|
|
procedure AddToolBar(ToolBar: TToolBar; ToolType: TGikoToolType); |
| 72 |
yoffy |
1.4 |
property ToolBarIndex : Integer read FToolBarIndex write FToolBarIndex; |
| 73 |
yoffy |
1.1 |
end; |
| 74 |
|
|
|
| 75 |
|
|
var |
| 76 |
|
|
ToolBarSettingDialog: TToolBarSettingDialog; |
| 77 |
|
|
|
| 78 |
|
|
function CompareCategory(Item1, Item2: Pointer): Integer; |
| 79 |
|
|
|
| 80 |
|
|
implementation |
| 81 |
|
|
|
| 82 |
h677 |
1.3 |
//const |
| 83 |
|
|
// //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 84 |
|
|
// SEPARATOR_TEXT = '- 鐃緒申鐃緒申鐃緒申 -'; |
| 85 |
yoffy |
1.1 |
|
| 86 |
|
|
{$R *.dfm} |
| 87 |
|
|
|
| 88 |
|
|
// |
| 89 |
|
|
// TToolBarItem |
| 90 |
|
|
// |
| 91 |
|
|
constructor TToolBarItem.Create; |
| 92 |
|
|
begin |
| 93 |
|
|
inherited Create; |
| 94 |
|
|
FButtonActionList := TList.Create; |
| 95 |
|
|
end; |
| 96 |
|
|
|
| 97 |
|
|
destructor TToolBarItem.Destroy; |
| 98 |
|
|
begin |
| 99 |
|
|
FButtonActionList.Free; |
| 100 |
|
|
inherited Destroy; |
| 101 |
|
|
end; |
| 102 |
|
|
|
| 103 |
|
|
// |
| 104 |
|
|
// TToolBarSettingDialog |
| 105 |
|
|
// |
| 106 |
|
|
constructor TToolBarSettingDialog.Create(AOwner: TComponent; ActionList: TActionList); |
| 107 |
|
|
begin |
| 108 |
|
|
inherited Create(AOwner); |
| 109 |
|
|
FActionList := ActionList; |
| 110 |
|
|
end; |
| 111 |
|
|
|
| 112 |
|
|
//鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申 |
| 113 |
|
|
procedure TToolBarSettingDialog.FormCreate(Sender: TObject); |
| 114 |
|
|
begin |
| 115 |
|
|
FAllList := TList.Create; |
| 116 |
|
|
end; |
| 117 |
|
|
|
| 118 |
|
|
//鐃?鐃?鐃?鐃緒申鐃?鐃緒申 |
| 119 |
|
|
procedure TToolBarSettingDialog.FormDestroy(Sender: TObject); |
| 120 |
|
|
var |
| 121 |
|
|
i: Integer; |
| 122 |
|
|
begin |
| 123 |
|
|
FAllList.Free; |
| 124 |
|
|
for i := 0 to ToolBarComboBox.Items.Count - 1 do |
| 125 |
|
|
ToolBarComboBox.Items.Objects[i].Free; |
| 126 |
|
|
end; |
| 127 |
|
|
|
| 128 |
|
|
//鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 129 |
|
|
procedure TToolBarSettingDialog.FormShow(Sender: TObject); |
| 130 |
|
|
begin |
| 131 |
yoffy |
1.5 |
ToolBarComboBox.ItemIndex := FToolBarIndex; |
| 132 |
yoffy |
1.1 |
ToolBarComboBoxChange(Self); |
| 133 |
|
|
AllListViewChange(Sender, nil, ctState); |
| 134 |
|
|
CurrentListViewChange(Sender, nil, ctState); |
| 135 |
|
|
end; |
| 136 |
|
|
|
| 137 |
|
|
//鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申 |
| 138 |
|
|
procedure TToolBarSettingDialog.AddToolBar(ToolBar: TToolBar; ToolType: TGikoToolType); |
| 139 |
|
|
var |
| 140 |
|
|
ToolBarItem: TToolBarItem; |
| 141 |
|
|
i: Integer; |
| 142 |
|
|
begin |
| 143 |
|
|
ToolBarItem := TToolBarItem.Create; |
| 144 |
|
|
ToolBarItem.ToolBar := ToolBar; |
| 145 |
|
|
ToolBarItem.ToolType := ToolType; |
| 146 |
yoffy |
1.2 |
for i := 0 to ToolBar.ControlCount - 1 do |
| 147 |
h677 |
1.7 |
if ToolBar.Controls[ i ] is TToolButton Then |
| 148 |
|
|
if not (ToolBar.Controls[ i ].Name = 'SelectComboBoxDummy') Then |
| 149 |
yoffy |
1.2 |
ToolBarITem.ButtonActionList.Add(ToolBar.Controls[i].Action); |
| 150 |
yoffy |
1.1 |
ToolBarComboBox.Items.AddObject(ToolBar.Caption, ToolBarItem); |
| 151 |
|
|
end; |
| 152 |
|
|
|
| 153 |
|
|
|
| 154 |
|
|
//鐃?鐃緒申鐃?鐃?鐃?鐃?鐃?鐃緒申鐃?鐃緒申 |
| 155 |
|
|
procedure TToolBarSettingDialog.ToolBarComboBoxChange(Sender: TObject); |
| 156 |
|
|
var |
| 157 |
|
|
ToolBarItem: TToolBarItem; |
| 158 |
|
|
begin |
| 159 |
|
|
ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]); |
| 160 |
|
|
CreateListData(ToolBarItem); |
| 161 |
|
|
AllListView.Items.Count := FAllList.Count; |
| 162 |
|
|
CurrentListView.Items.Count := ToolBarItem.ButtonActionList.Count; |
| 163 |
|
|
Sort; |
| 164 |
|
|
AllListView.Refresh; |
| 165 |
|
|
CurrentListView.Refresh; |
| 166 |
|
|
end; |
| 167 |
|
|
|
| 168 |
|
|
//OK鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 169 |
|
|
procedure TToolBarSettingDialog.OKButtonClick(Sender: TObject); |
| 170 |
|
|
var |
| 171 |
|
|
i: Integer; |
| 172 |
|
|
j: Integer; |
| 173 |
|
|
ToolButton: TToolButton; |
| 174 |
|
|
ToolBarItem: TToolBarItem; |
| 175 |
|
|
begin |
| 176 |
|
|
for i := 0 to ToolBarComboBox.Items.Count - 1 do begin |
| 177 |
|
|
ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[i]); |
| 178 |
|
|
|
| 179 |
|
|
for j := ToolBarItem.ToolBar.ButtonCount - 1 downto 0 do |
| 180 |
h677 |
1.8 |
ToolBarItem.ToolBar.Buttons[j].HostDockSite := nil; |
| 181 |
yoffy |
1.1 |
|
| 182 |
|
|
for j := 0 to ToolBarItem.ButtonActionList.Count - 1 do begin |
| 183 |
|
|
if ToolBarItem.ButtonActionList[j] = nil then begin |
| 184 |
|
|
ToolButton := TToolButton.Create(ToolBarItem.ToolBar); |
| 185 |
|
|
ToolButton.Style := tbsSeparator; |
| 186 |
|
|
ToolButton.Width := 8; |
| 187 |
|
|
ToolButton.Left := 10000; |
| 188 |
|
|
ToolBarItem.ToolBar.InsertControl(ToolButton); |
| 189 |
|
|
end else if TObject(ToolBarItem.ButtonActionList[j]) is TCustomAction then begin |
| 190 |
|
|
ToolButton := TToolButton.Create(ToolBarItem.ToolBar); |
| 191 |
|
|
ToolButton.Action := TCustomAction(ToolBarItem.ButtonActionList[j]); |
| 192 |
h677 |
1.6 |
if ToolButton.ImageIndex = -1 then |
| 193 |
|
|
ToolButton.ImageIndex := 51; |
| 194 |
|
|
|
| 195 |
yoffy |
1.1 |
ToolButton.Left := 10000; |
| 196 |
|
|
SetButtonStyle(ToolBarItem.ButtonActionList[j], ToolButton); |
| 197 |
|
|
ToolBarItem.ToolBar.InsertControl(ToolButton); |
| 198 |
|
|
end; |
| 199 |
|
|
end; |
| 200 |
|
|
end; |
| 201 |
|
|
end; |
| 202 |
|
|
|
| 203 |
|
|
//鐃?鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃?鐃緒申鐃緒申 |
| 204 |
|
|
procedure TToolBarSettingDialog.AllListViewData(Sender: TObject; Item: TListItem); |
| 205 |
|
|
var |
| 206 |
|
|
Action: TCustomAction; |
| 207 |
|
|
begin |
| 208 |
|
|
if (FAllList.Count <= 0) or (FAllList.Count <= Item.Index) then |
| 209 |
|
|
Exit; |
| 210 |
|
|
if FAllList[Item.Index] = nil then begin |
| 211 |
|
|
Item.Caption := SEPARATOR_TEXT; |
| 212 |
|
|
Item.ImageIndex := -1; |
| 213 |
|
|
Item.Data := nil; |
| 214 |
|
|
end else if TObject(FAllList[Item.Index]) is TCustomAction then begin |
| 215 |
|
|
Action := TCustomAction(FAllList[Item.Index]); |
| 216 |
|
|
Item.Caption := Action.Hint; |
| 217 |
|
|
Item.ImageIndex := Action.ImageIndex; |
| 218 |
|
|
Item.Data := Action; |
| 219 |
|
|
end; |
| 220 |
|
|
end; |
| 221 |
|
|
|
| 222 |
|
|
//鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃?鐃緒申鐃緒申 |
| 223 |
|
|
procedure TToolBarSettingDialog.CurrentListViewData(Sender: TObject; Item: TListItem); |
| 224 |
|
|
var |
| 225 |
|
|
Action: TCustomAction; |
| 226 |
|
|
ToolBarItem: TToolBarItem; |
| 227 |
|
|
begin |
| 228 |
|
|
ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]); |
| 229 |
|
|
|
| 230 |
|
|
if (ToolBarItem.ButtonActionList.Count <= 0) or (ToolBarItem.ButtonActionList.Count <= Item.Index) then |
| 231 |
|
|
Exit; |
| 232 |
|
|
if ToolBarItem.ButtonActionList[Item.Index] = nil then begin |
| 233 |
|
|
Item.Caption := SEPARATOR_TEXT; |
| 234 |
|
|
Item.ImageIndex := -1; |
| 235 |
|
|
Item.Data := nil; |
| 236 |
|
|
end else if TObject(ToolBarItem.ButtonActionList[Item.Index]) is TCustomAction then begin |
| 237 |
|
|
Action := TCustomAction(ToolBarItem.ButtonActionList[Item.Index]); |
| 238 |
|
|
Item.Caption := Action.Hint; |
| 239 |
|
|
Item.ImageIndex := Action.ImageIndex; |
| 240 |
|
|
Item.Data := Action; |
| 241 |
|
|
end; |
| 242 |
|
|
end; |
| 243 |
|
|
|
| 244 |
|
|
//鐃?鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申 |
| 245 |
|
|
procedure TToolBarSettingDialog.CreateListData(ToolBarItem: TToolBarItem); |
| 246 |
|
|
var |
| 247 |
|
|
i: Integer; |
| 248 |
|
|
Category: string; |
| 249 |
|
|
begin |
| 250 |
|
|
FAllList.Clear; |
| 251 |
|
|
for i := 0 to FActionList.ActionCount - 1 do begin |
| 252 |
|
|
if FActionList.Actions[i].Tag = -1 then |
| 253 |
|
|
Continue; |
| 254 |
|
|
Category := FActionList.Actions[i].Category; |
| 255 |
|
|
//鐃?鐃緒申鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃緒申鐃?鐃?鐃?鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申 |
| 256 |
|
|
if (ToolBarItem.ToolType = gttStandard) and ((Category = '鐃緒申') or (Category = '鐃?鐃緒申鐃?鐃?')) then |
| 257 |
|
|
Continue; |
| 258 |
|
|
//鐃緒申鐃?鐃?鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申 |
| 259 |
|
|
if (ToolBarItem.ToolType = gttList) and (Category <> '鐃緒申') then |
| 260 |
|
|
Continue; |
| 261 |
|
|
//鐃?鐃緒申鐃?鐃?鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申 |
| 262 |
|
|
if (ToolBarItem.ToolType = gttBrowser) and (Category <> '鐃?鐃緒申鐃?鐃?') then |
| 263 |
|
|
Continue; |
| 264 |
|
|
|
| 265 |
|
|
if ToolBarItem.ButtonActionList.IndexOf(FActionList.Actions[i]) = -1 then |
| 266 |
|
|
FAllList.Add(FActionList.Actions[i]); |
| 267 |
|
|
end; |
| 268 |
|
|
end; |
| 269 |
|
|
|
| 270 |
|
|
//鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 271 |
|
|
procedure TToolBarSettingDialog.UpButtonClick(Sender: TObject); |
| 272 |
|
|
begin |
| 273 |
|
|
MoveItem(-1); |
| 274 |
|
|
end; |
| 275 |
|
|
|
| 276 |
|
|
//鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 277 |
|
|
procedure TToolBarSettingDialog.DownButtonClick(Sender: TObject); |
| 278 |
|
|
begin |
| 279 |
|
|
MoveItem(1); |
| 280 |
|
|
end; |
| 281 |
|
|
|
| 282 |
|
|
//鐃緒申鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 283 |
|
|
procedure TToolBarSettingDialog.ResetButtonClick(Sender: TObject); |
| 284 |
|
|
var |
| 285 |
|
|
ToolBarItem: TToolBarItem; |
| 286 |
|
|
cnt: Integer; |
| 287 |
|
|
begin |
| 288 |
|
|
cnt := 0; |
| 289 |
|
|
ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]); |
| 290 |
|
|
AllListView.Items.Count := 0; |
| 291 |
|
|
CurrentListView.Items.Count := 0; |
| 292 |
|
|
ToolBarItem.ButtonActionList.Clear; |
| 293 |
|
|
case ToolBarComboBox.ItemIndex of |
| 294 |
|
|
0: cnt := SetDefaultItem(DEF_STANDARD, ToolBarItem); |
| 295 |
|
|
1: cnt := SetDefaultItem(DEF_LIST, ToolBarItem); |
| 296 |
|
|
2: cnt := SetDefaultItem(DEF_BROWSER, ToolBarItem); |
| 297 |
|
|
end; |
| 298 |
|
|
CreateListData(ToolBarItem); |
| 299 |
|
|
AllListView.Items.Count := FAllList.Count; |
| 300 |
|
|
CurrentListView.Items.Count := cnt; |
| 301 |
|
|
Sort; |
| 302 |
|
|
AllListView.Refresh; |
| 303 |
|
|
CurrentListView.Refresh; |
| 304 |
|
|
end; |
| 305 |
|
|
|
| 306 |
|
|
function TToolBarSettingDialog.SetDefaultItem(deflist: array of string; ToolBarItem: TToolBarItem): Integer; |
| 307 |
|
|
var |
| 308 |
|
|
i: Integer; |
| 309 |
|
|
Action: TCustomAction; |
| 310 |
|
|
begin |
| 311 |
|
|
Result := 0; |
| 312 |
|
|
for i := 0 to Length(deflist) - 1 do begin |
| 313 |
|
|
if deflist[i] = '' then begin |
| 314 |
|
|
ToolBarItem.ButtonActionList.Add(nil); |
| 315 |
|
|
Inc(Result); |
| 316 |
|
|
end else begin |
| 317 |
|
|
Action := GetActionItem(FActionList, deflist[i]); |
| 318 |
|
|
if Action <> nil then begin |
| 319 |
|
|
ToolBarItem.ButtonActionList.Add(Action); |
| 320 |
|
|
Inc(Result); |
| 321 |
|
|
end; |
| 322 |
|
|
end; |
| 323 |
|
|
end; |
| 324 |
|
|
end; |
| 325 |
|
|
|
| 326 |
|
|
//鐃緒申鐃?鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 327 |
|
|
procedure TToolBarSettingDialog.MoveItem(Offset: Integer); |
| 328 |
|
|
var |
| 329 |
|
|
Item: TListItem; |
| 330 |
|
|
ToolBarItem: TToolBarItem; |
| 331 |
|
|
begin |
| 332 |
|
|
Item := CurrentListView.Selected; |
| 333 |
|
|
if (Item = nil) or (Item.Index + Offset < 0) then |
| 334 |
|
|
Exit; |
| 335 |
|
|
|
| 336 |
|
|
ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]); |
| 337 |
|
|
if Item.Index + Offset >= ToolBarItem.ButtonActionList.Count then |
| 338 |
|
|
Exit; |
| 339 |
|
|
|
| 340 |
|
|
ToolBarItem.ButtonActionList.Move(Item.Index, Item.Index + Offset); |
| 341 |
|
|
CurrentListView.ItemIndex := Item.Index + Offset; |
| 342 |
|
|
CurrentListView.Refresh; |
| 343 |
|
|
end; |
| 344 |
|
|
|
| 345 |
|
|
//鐃?鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃緒申鐃緒申鐃?鐃緒申 |
| 346 |
|
|
procedure TToolBarSettingDialog.AllListViewChange(Sender: TObject; |
| 347 |
|
|
Item: TListItem; Change: TItemChange); |
| 348 |
|
|
begin |
| 349 |
|
|
AddButton.Enabled := not (Item = nil); |
| 350 |
|
|
end; |
| 351 |
|
|
|
| 352 |
|
|
//鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃緒申鐃緒申鐃?鐃緒申 |
| 353 |
|
|
procedure TToolBarSettingDialog.CurrentListViewChange(Sender: TObject; |
| 354 |
|
|
Item: TListItem; Change: TItemChange); |
| 355 |
|
|
begin |
| 356 |
|
|
UpButton.Enabled := not (Item = nil); |
| 357 |
|
|
DownButton.Enabled := not (Item = nil); |
| 358 |
|
|
RemoveButton.Enabled := not (Item = nil); |
| 359 |
|
|
if Item = nil then |
| 360 |
|
|
Exit; |
| 361 |
|
|
UpButton.Enabled := Item.Index > 0; |
| 362 |
|
|
DownButton.Enabled := Item.Index < CurrentListView.Items.Count - 1; |
| 363 |
|
|
end; |
| 364 |
|
|
|
| 365 |
|
|
//鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 366 |
|
|
procedure TToolBarSettingDialog.AddButtonClick(Sender: TObject); |
| 367 |
|
|
var |
| 368 |
|
|
// List: TList; |
| 369 |
|
|
ToolBarItem: TToolBarItem; |
| 370 |
|
|
Item: TListItem; |
| 371 |
|
|
Action: TCustomAction; |
| 372 |
|
|
begin |
| 373 |
|
|
Item := AllListView.Selected; |
| 374 |
|
|
if Item = nil then |
| 375 |
|
|
Exit; |
| 376 |
|
|
|
| 377 |
|
|
ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]); |
| 378 |
|
|
Action := Item.Data; |
| 379 |
|
|
FAllList.Delete(Item.Index); |
| 380 |
|
|
if Action <> nil then begin |
| 381 |
|
|
Item := CurrentListView.Selected; |
| 382 |
|
|
if Item = nil then |
| 383 |
|
|
ToolBarItem.ButtonActionList.Add(Action) |
| 384 |
|
|
else |
| 385 |
|
|
ToolBarItem.ButtonActionList.Insert(Item.Index + 1, Action); |
| 386 |
|
|
AllListView.Items.Count := AllListView.Items.Count - 1; |
| 387 |
|
|
AllListView.Refresh; |
| 388 |
|
|
CurrentListView.Items.Count := CurrentListView.Items.Count + 1; |
| 389 |
|
|
CurrentListView.Refresh; |
| 390 |
|
|
end; |
| 391 |
|
|
end; |
| 392 |
|
|
|
| 393 |
|
|
//鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 394 |
|
|
procedure TToolBarSettingDialog.RemoveButtonClick(Sender: TObject); |
| 395 |
|
|
var |
| 396 |
|
|
ToolBarItem: TToolBarItem; |
| 397 |
|
|
Item: TListItem; |
| 398 |
|
|
Action: TCustomAction; |
| 399 |
|
|
begin |
| 400 |
|
|
Item := CurrentListView.Selected; |
| 401 |
|
|
if Item = nil then |
| 402 |
|
|
Exit; |
| 403 |
|
|
|
| 404 |
|
|
ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]); |
| 405 |
|
|
Action := Item.Data; |
| 406 |
|
|
ToolBarItem.ButtonActionList.Delete(Item.Index); |
| 407 |
|
|
if Action <> nil then begin |
| 408 |
|
|
FAllList.Add(Action); |
| 409 |
|
|
AllListView.Items.Count := AllListView.Items.Count + 1; |
| 410 |
|
|
Sort; |
| 411 |
|
|
AllListView.Refresh; |
| 412 |
|
|
end; |
| 413 |
|
|
CurrentListView.Items.Count := CurrentListView.Items.Count - 1; |
| 414 |
|
|
CurrentListView.Refresh; |
| 415 |
|
|
end; |
| 416 |
|
|
|
| 417 |
|
|
//鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 418 |
|
|
procedure TToolBarSettingDialog.SeparatorAddButtonClick(Sender: TObject); |
| 419 |
|
|
var |
| 420 |
|
|
idx: Integer; |
| 421 |
|
|
ToolBarItem: TToolBarItem; |
| 422 |
|
|
begin |
| 423 |
|
|
ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]); |
| 424 |
|
|
if CurrentListView.Selected = nil then |
| 425 |
|
|
idx := CurrentListView.Items.Count - 1 |
| 426 |
|
|
else |
| 427 |
|
|
idx := CurrentListView.Selected.Index; |
| 428 |
|
|
ToolBarItem.ButtonActionList.Insert(idx + 1, nil); |
| 429 |
|
|
CurrentListView.Items.Count := CurrentListView.Items.Count + 1; |
| 430 |
|
|
CurrentListView.Refresh; |
| 431 |
|
|
end; |
| 432 |
|
|
|
| 433 |
|
|
//鐃?鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃?鐃? |
| 434 |
|
|
procedure TToolBarSettingDialog.Sort; |
| 435 |
|
|
begin |
| 436 |
|
|
FAllList.Sort(@CompareCategory); |
| 437 |
|
|
end; |
| 438 |
|
|
|
| 439 |
|
|
//鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃? |
| 440 |
|
|
function CompareCategory(Item1, Item2: Pointer): Integer; |
| 441 |
|
|
var |
| 442 |
|
|
Action1: TCustomAction; |
| 443 |
|
|
Action2: TCustomAction; |
| 444 |
|
|
begin |
| 445 |
|
|
if (Item1 = nil) and (Item2 = nil) then |
| 446 |
|
|
Result := 0 |
| 447 |
|
|
else if (Item1 = nil) and (Item2 <> nil) then |
| 448 |
|
|
Result := -1 |
| 449 |
|
|
else if (Item1 <> nil) and (Item2 = nil) then |
| 450 |
|
|
Result := 1 |
| 451 |
|
|
else begin |
| 452 |
|
|
if (TObject(Item1) is TCustomAction) and (TObject(Item1) is TCustomAction) then begin |
| 453 |
|
|
Action1 := TCustomAction(Item1); |
| 454 |
|
|
Action2 := TCustomAction(Item2); |
| 455 |
|
|
Result := AnsiCompareStr(Action1.Category + Action1.Caption, Action2.Category + Action2.Caption); |
| 456 |
|
|
end else |
| 457 |
|
|
Result := 0; |
| 458 |
|
|
end; |
| 459 |
|
|
end; |
| 460 |
|
|
|
| 461 |
|
|
end. |