6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, ExtCtrls, ComCtrls, ActnList, IniFiles,
8 GikoSystem, ToolBarUtil;
11 TGikoToolType = (gttStandard, gttList, gttBrowser);
16 FButtonActionList: TList;
17 FToolType: TGikoToolType;
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;
26 TToolBarSettingDialog = class(TForm)
28 AllListView: TListView;
30 RemoveButton: TButton;
31 CurrentListView: TListView;
36 CancelButton: TButton;
39 ToolBarComboBox: TComboBox;
40 SeparatorAddButton: 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;
53 procedure AllListViewChange(Sender: TObject; Item: TListItem;
55 procedure AddButtonClick(Sender: TObject);
56 procedure RemoveButtonClick(Sender: TObject);
57 procedure SeparatorAddButtonClick(Sender: TObject);
58 procedure FormShow(Sender: TObject);
61 FActionList: TActionList;
63 FToolBarIndex : Integer; //
\8f\89\8aú
\95\
\8e¦
\82·
\82é
\83c
\81[
\83\8b\83o
\81[
64 procedure CreateListData(ToolBarItem: TToolBarItem);
65 procedure MoveItem(Offset: Integer);
67 function SetDefaultItem(deflist: array of string; ToolBarItem: TToolBarItem): Integer;
70 constructor Create(AOwner: TComponent; ActionList: TActionList); reintroduce; overload; virtual;
71 procedure AddToolBar(ToolBar: TToolBar; ToolType: TGikoToolType);
72 property ToolBarIndex : Integer read FToolBarIndex write FToolBarIndex;
76 ToolBarSettingDialog: TToolBarSettingDialog;
78 function CompareCategory(Item1, Item2: Pointer): Integer;
83 // //
\8bæ
\90Ø
\82è
\95¶
\8e\9a
84 // SEPARATOR_TEXT = '-
\8bæ
\90Ø
\82è -';
91 constructor TToolBarItem.Create;
94 FButtonActionList := TList.Create;
97 destructor TToolBarItem.Destroy;
99 FButtonActionList.Free;
104 // TToolBarSettingDialog
106 constructor TToolBarSettingDialog.Create(AOwner: TComponent; ActionList: TActionList);
108 inherited Create(AOwner);
109 FActionList := ActionList;
112 //
\83t
\83H
\81[
\83\80\8dì
\90¬
113 procedure TToolBarSettingDialog.FormCreate(Sender: TObject);
115 CenterForm: TCustomForm;
117 CenterForm := TCustomForm(Owner);
118 if Assigned(CenterForm) then begin
119 Left := ((CenterForm.Width - Width) div 2) + CenterForm.Left;
120 Top := ((CenterForm.Height - Height) div 2) + CenterForm.Top;
122 Left := (Screen.Width - Width) div 2;
123 Top := (Screen.Height - Height) div 2;
126 FAllList := TList.Create;
129 //
\83t
\83H
\81[
\83\80\94j
\8aü
130 procedure TToolBarSettingDialog.FormDestroy(Sender: TObject);
135 for i := 0 to ToolBarComboBox.Items.Count - 1 do
136 ToolBarComboBox.Items.Objects[i].Free;
139 //
\95\
\8e¦
\82µ
\82½
\82Æ
\82«
140 procedure TToolBarSettingDialog.FormShow(Sender: TObject);
142 ToolBarComboBox.ItemIndex := FToolBarIndex;
143 ToolBarComboBoxChange(Self);
144 AllListViewChange(Sender, nil, ctState);
145 CurrentListViewChange(Sender, nil, ctState);
148 //
\82±
\82Ì
\83_
\83C
\83A
\83\8d\83O
\82Å
\83J
\83X
\83^
\83}
\83C
\83Y
\82·
\82é
\83c
\81[
\83\8b\83o
\81[
\82ð
\93o
\98^
\82·
\82é
149 procedure TToolBarSettingDialog.AddToolBar(ToolBar: TToolBar; ToolType: TGikoToolType);
151 ToolBarItem: TToolBarItem;
154 ToolBarItem := TToolBarItem.Create;
155 ToolBarItem.ToolBar := ToolBar;
156 ToolBarItem.ToolType := ToolType;
157 for i := 0 to ToolBar.ControlCount - 1 do
158 if ToolBar.Controls[ i ] is TToolButton Then
159 if not (ToolBar.Controls[ i ].Name = 'SelectComboBoxDummy') Then
160 ToolBarITem.ButtonActionList.Add(ToolBar.Controls[i].Action);
161 ToolBarComboBox.Items.AddObject(ToolBar.Caption, ToolBarItem);
165 //
\83R
\83\93\83{
\83{
\83b
\83N
\83X
\95Ï
\8dX
\8e\9e
166 procedure TToolBarSettingDialog.ToolBarComboBoxChange(Sender: TObject);
168 ToolBarItem: TToolBarItem;
170 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
171 CreateListData(ToolBarItem);
172 AllListView.Items.Count := FAllList.Count;
173 CurrentListView.Items.Count := ToolBarItem.ButtonActionList.Count;
176 CurrentListView.Refresh;
179 //OK
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
180 procedure TToolBarSettingDialog.OKButtonClick(Sender: TObject);
184 ToolButton: TToolButton;
185 ToolBarItem: TToolBarItem;
187 for i := 0 to ToolBarComboBox.Items.Count - 1 do begin
188 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[i]);
190 for j := ToolBarItem.ToolBar.ButtonCount - 1 downto 0 do
191 ToolBarItem.ToolBar.Buttons[j].HostDockSite := nil;
193 for j := 0 to ToolBarItem.ButtonActionList.Count - 1 do begin
194 if ToolBarItem.ButtonActionList[j] = nil then begin
195 ToolButton := TToolButton.Create(ToolBarItem.ToolBar);
196 ToolButton.Style := tbsSeparator;
197 ToolButton.Width := 8;
198 ToolButton.Left := 10000;
199 ToolBarItem.ToolBar.InsertControl(ToolButton);
200 end else if TObject(ToolBarItem.ButtonActionList[j]) is TCustomAction then begin
201 ToolButton := TToolButton.Create(ToolBarItem.ToolBar);
202 ToolButton.Action := TCustomAction(ToolBarItem.ButtonActionList[j]);
203 if ToolButton.ImageIndex = -1 then
204 ToolButton.ImageIndex := 51;
206 ToolButton.Left := 10000;
207 SetButtonStyle(ToolBarItem.ButtonActionList[j], ToolButton);
208 ToolBarItem.ToolBar.InsertControl(ToolButton);
214 //
\91S
\83c
\81[
\83\8b\83{
\83^
\83\93\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83f
\81[
\83^
\97v
\8b\81\8e\9e
215 procedure TToolBarSettingDialog.AllListViewData(Sender: TObject; Item: TListItem);
217 Action: TCustomAction;
219 if (FAllList.Count <= 0) or (FAllList.Count <= Item.Index) then
221 if FAllList[Item.Index] = nil then begin
222 Item.Caption := SEPARATOR_TEXT;
223 Item.ImageIndex := -1;
225 end else if TObject(FAllList[Item.Index]) is TCustomAction then begin
226 Action := TCustomAction(FAllList[Item.Index]);
227 Item.Caption := Action.Hint;
228 Item.ImageIndex := Action.ImageIndex;
233 //
\8c»
\8dÝ
\83c
\81[
\83\8b\83{
\83^
\83\93\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83f
\81[
\83^
\97v
\8b\81\8e\9e
234 procedure TToolBarSettingDialog.CurrentListViewData(Sender: TObject; Item: TListItem);
236 Action: TCustomAction;
237 ToolBarItem: TToolBarItem;
239 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
241 if (ToolBarItem.ButtonActionList.Count <= 0) or (ToolBarItem.ButtonActionList.Count <= Item.Index) then
243 if ToolBarItem.ButtonActionList[Item.Index] = nil then begin
244 Item.Caption := SEPARATOR_TEXT;
245 Item.ImageIndex := -1;
247 end else if TObject(ToolBarItem.ButtonActionList[Item.Index]) is TCustomAction then begin
248 Action := TCustomAction(ToolBarItem.ButtonActionList[Item.Index]);
249 Item.Caption := Action.Hint;
250 Item.ImageIndex := Action.ImageIndex;
255 //
\8eg
\97p
\82Å
\82«
\82é
\83c
\81[
\83\8b\83{
\83^
\83\93\83\8a\83X
\83g
\83r
\83\85\81[
\82É
\95\
\8e¦
\82·
\82é
\83f
\81[
\83^
\82ð
\8dì
\90¬
256 procedure TToolBarSettingDialog.CreateListData(ToolBarItem: TToolBarItem);
262 for i := 0 to FActionList.ActionCount - 1 do begin
263 if FActionList.Actions[i].Tag = -1 then
265 Category := FActionList.Actions[i].Category;
266 //
\95W
\8f\80\83c
\81[
\83\8b\83o
\81[
\82Í
\81u
\94Â
\81v
\81u
\83X
\83\8c\83b
\83h
\81v
\88È
\8aO
\82Ì
\82Ý
\91Î
\8fÛ
267 if (ToolBarItem.ToolType = gttStandard) and ((Category = '
\94Â') or (Category = '
\83X
\83\8c\83b
\83h')) then
269 //
\83\8a\83X
\83g
\83c
\81[
\83\8b\83o
\81[
\82Í
\81u
\94Â
\81v
\82Ì
\82Ý
\91Î
\8fÛ
270 if (ToolBarItem.ToolType = gttList) and (Category <> '
\94Â') then
272 //
\83u
\83\89\83E
\83U
\83c
\81[
\83\8b\83o
\81[
\82Í
\81u
\83X
\83\8c\83b
\83h
\81v
\82Ì
\82Ý
\91Î
\8fÛ
273 if (ToolBarItem.ToolType = gttBrowser) and (Category <> '
\83X
\83\8c\83b
\83h') then
276 if ToolBarItem.ButtonActionList.IndexOf(FActionList.Actions[i]) = -1 then
277 FAllList.Add(FActionList.Actions[i]);
281 //
\8fã
\82Ö
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
282 procedure TToolBarSettingDialog.UpButtonClick(Sender: TObject);
287 //
\89º
\82Ö
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
288 procedure TToolBarSettingDialog.DownButtonClick(Sender: TObject);
293 //
\83\8a\83Z
\83b
\83g
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
294 procedure TToolBarSettingDialog.ResetButtonClick(Sender: TObject);
296 ToolBarItem: TToolBarItem;
300 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
301 AllListView.Items.Count := 0;
302 CurrentListView.Items.Count := 0;
303 ToolBarItem.ButtonActionList.Clear;
304 case ToolBarComboBox.ItemIndex of
305 0: cnt := SetDefaultItem(DEF_STANDARD, ToolBarItem);
306 1: cnt := SetDefaultItem(DEF_LIST, ToolBarItem);
307 2: cnt := SetDefaultItem(DEF_BROWSER, ToolBarItem);
309 CreateListData(ToolBarItem);
310 AllListView.Items.Count := FAllList.Count;
311 CurrentListView.Items.Count := cnt;
314 CurrentListView.Refresh;
317 function TToolBarSettingDialog.SetDefaultItem(deflist: array of string; ToolBarItem: TToolBarItem): Integer;
320 Action: TCustomAction;
323 for i := 0 to Length(deflist) - 1 do begin
324 if deflist[i] = '' then begin
325 ToolBarItem.ButtonActionList.Add(nil);
328 Action := GetActionItem(FActionList, deflist[i]);
329 if Action <> nil then begin
330 ToolBarItem.ButtonActionList.Add(Action);
337 //
\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83A
\83C
\83e
\83\80\82ð
\88Ú
\93®
\82·
\82é
338 procedure TToolBarSettingDialog.MoveItem(Offset: Integer);
341 ToolBarItem: TToolBarItem;
343 Item := CurrentListView.Selected;
344 if (Item = nil) or (Item.Index + Offset < 0) then
347 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
348 if Item.Index + Offset >= ToolBarItem.ButtonActionList.Count then
351 ToolBarItem.ButtonActionList.Move(Item.Index, Item.Index + Offset);
352 CurrentListView.ItemIndex := Item.Index + Offset;
353 CurrentListView.Refresh;
356 //
\91S
\83c
\81[
\83\8b\83{
\83^
\83\93\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\91I
\91ð
\95Ï
\8dX
\8e\9e
357 procedure TToolBarSettingDialog.AllListViewChange(Sender: TObject;
358 Item: TListItem; Change: TItemChange);
360 AddButton.Enabled := not (Item = nil);
363 //
\8c»
\8dÝ
\83c
\81[
\83\8b\83{
\83^
\83\93\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\91I
\91ð
\95Ï
\8dX
\8e\9e
364 procedure TToolBarSettingDialog.CurrentListViewChange(Sender: TObject;
365 Item: TListItem; Change: TItemChange);
367 UpButton.Enabled := not (Item = nil);
368 DownButton.Enabled := not (Item = nil);
369 RemoveButton.Enabled := not (Item = nil);
372 UpButton.Enabled := Item.Index > 0;
373 DownButton.Enabled := Item.Index < CurrentListView.Items.Count - 1;
376 //
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
377 procedure TToolBarSettingDialog.AddButtonClick(Sender: TObject);
380 ToolBarItem: TToolBarItem;
382 Action: TCustomAction;
384 Item := AllListView.Selected;
388 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
390 FAllList.Delete(Item.Index);
391 if Action <> nil then begin
392 Item := CurrentListView.Selected;
394 ToolBarItem.ButtonActionList.Add(Action)
396 ToolBarItem.ButtonActionList.Insert(Item.Index + 1, Action);
397 AllListView.Items.Count := AllListView.Items.Count - 1;
399 CurrentListView.Items.Count := CurrentListView.Items.Count + 1;
400 CurrentListView.Refresh;
404 //
\8dí
\8f\9c\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
405 procedure TToolBarSettingDialog.RemoveButtonClick(Sender: TObject);
407 ToolBarItem: TToolBarItem;
409 Action: TCustomAction;
411 Item := CurrentListView.Selected;
415 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
417 ToolBarItem.ButtonActionList.Delete(Item.Index);
418 if Action <> nil then begin
419 FAllList.Add(Action);
420 AllListView.Items.Count := AllListView.Items.Count + 1;
424 CurrentListView.Items.Count := CurrentListView.Items.Count - 1;
425 CurrentListView.Refresh;
428 //
\8bæ
\90Ø
\82è
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
429 procedure TToolBarSettingDialog.SeparatorAddButtonClick(Sender: TObject);
432 ToolBarItem: TToolBarItem;
434 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
435 if CurrentListView.Selected = nil then
436 idx := CurrentListView.Items.Count - 1
438 idx := CurrentListView.Selected.Index;
439 ToolBarItem.ButtonActionList.Insert(idx + 1, nil);
440 CurrentListView.Items.Count := CurrentListView.Items.Count + 1;
441 CurrentListView.Refresh;
444 //
\91S
\83c
\81[
\83\8b\83{
\83^
\83\93\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83\
\81[
\83g
445 procedure TToolBarSettingDialog.Sort;
447 FAllList.Sort(@CompareCategory);
450 //
\83\
\81[
\83g
\82·
\82é
\82Æ
\82«
\82Ì
\94ä
\8ar
451 function CompareCategory(Item1, Item2: Pointer): Integer;
453 Action1: TCustomAction;
454 Action2: TCustomAction;
456 if (Item1 = nil) and (Item2 = nil) then
458 else if (Item1 = nil) and (Item2 <> nil) then
460 else if (Item1 <> nil) and (Item2 = nil) then
463 if (TObject(Item1) is TCustomAction) and (TObject(Item1) is TCustomAction) then begin
464 Action1 := TCustomAction(Item1);
465 Action2 := TCustomAction(Item2);
466 Result := AnsiCompareStr(Action1.Category + Action1.Caption, Action2.Category + Action2.Caption);