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 FAllList := TList.Create;
118 //
\83t
\83H
\81[
\83\80\94j
\8aü
119 procedure TToolBarSettingDialog.FormDestroy(Sender: TObject);
124 for i := 0 to ToolBarComboBox.Items.Count - 1 do
125 ToolBarComboBox.Items.Objects[i].Free;
128 //
\95\
\8e¦
\82µ
\82½
\82Æ
\82«
129 procedure TToolBarSettingDialog.FormShow(Sender: TObject);
131 ToolBarComboBox.ItemIndex := FToolBarIndex;
132 ToolBarComboBoxChange(Self);
133 AllListViewChange(Sender, nil, ctState);
134 CurrentListViewChange(Sender, nil, ctState);
137 //
\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é
138 procedure TToolBarSettingDialog.AddToolBar(ToolBar: TToolBar; ToolType: TGikoToolType);
140 ToolBarItem: TToolBarItem;
143 ToolBarItem := TToolBarItem.Create;
144 ToolBarItem.ToolBar := ToolBar;
145 ToolBarItem.ToolType := ToolType;
146 for i := 0 to ToolBar.ControlCount - 1 do
147 if ToolBar.Controls[ i ] is TToolButton Then
148 ToolBarITem.ButtonActionList.Add(ToolBar.Controls[i].Action);
149 ToolBarComboBox.Items.AddObject(ToolBar.Caption, ToolBarItem);
153 //
\83R
\83\93\83{
\83{
\83b
\83N
\83X
\95Ï
\8dX
\8e\9e
154 procedure TToolBarSettingDialog.ToolBarComboBoxChange(Sender: TObject);
156 ToolBarItem: TToolBarItem;
158 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
159 CreateListData(ToolBarItem);
160 AllListView.Items.Count := FAllList.Count;
161 CurrentListView.Items.Count := ToolBarItem.ButtonActionList.Count;
164 CurrentListView.Refresh;
167 //OK
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
168 procedure TToolBarSettingDialog.OKButtonClick(Sender: TObject);
172 ToolButton: TToolButton;
173 ToolBarItem: TToolBarItem;
175 for i := 0 to ToolBarComboBox.Items.Count - 1 do begin
176 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[i]);
178 for j := ToolBarItem.ToolBar.ButtonCount - 1 downto 0 do
179 ToolBarItem.ToolBar.RemoveControl(ToolBarItem.ToolBar.Buttons[j]);
181 for j := 0 to ToolBarItem.ButtonActionList.Count - 1 do begin
182 if ToolBarItem.ButtonActionList[j] = nil then begin
183 ToolButton := TToolButton.Create(ToolBarItem.ToolBar);
184 ToolButton.Style := tbsSeparator;
185 ToolButton.Width := 8;
186 ToolButton.Left := 10000;
187 ToolBarItem.ToolBar.InsertControl(ToolButton);
188 end else if TObject(ToolBarItem.ButtonActionList[j]) is TCustomAction then begin
189 ToolButton := TToolButton.Create(ToolBarItem.ToolBar);
190 ToolButton.Action := TCustomAction(ToolBarItem.ButtonActionList[j]);
191 ToolButton.Left := 10000;
192 SetButtonStyle(ToolBarItem.ButtonActionList[j], ToolButton);
193 ToolBarItem.ToolBar.InsertControl(ToolButton);
199 //
\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
200 procedure TToolBarSettingDialog.AllListViewData(Sender: TObject; Item: TListItem);
202 Action: TCustomAction;
204 if (FAllList.Count <= 0) or (FAllList.Count <= Item.Index) then
206 if FAllList[Item.Index] = nil then begin
207 Item.Caption := SEPARATOR_TEXT;
208 Item.ImageIndex := -1;
210 end else if TObject(FAllList[Item.Index]) is TCustomAction then begin
211 Action := TCustomAction(FAllList[Item.Index]);
212 Item.Caption := Action.Hint;
213 Item.ImageIndex := Action.ImageIndex;
218 //
\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
219 procedure TToolBarSettingDialog.CurrentListViewData(Sender: TObject; Item: TListItem);
221 Action: TCustomAction;
222 ToolBarItem: TToolBarItem;
224 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
226 if (ToolBarItem.ButtonActionList.Count <= 0) or (ToolBarItem.ButtonActionList.Count <= Item.Index) then
228 if ToolBarItem.ButtonActionList[Item.Index] = nil then begin
229 Item.Caption := SEPARATOR_TEXT;
230 Item.ImageIndex := -1;
232 end else if TObject(ToolBarItem.ButtonActionList[Item.Index]) is TCustomAction then begin
233 Action := TCustomAction(ToolBarItem.ButtonActionList[Item.Index]);
234 Item.Caption := Action.Hint;
235 Item.ImageIndex := Action.ImageIndex;
240 //
\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¬
241 procedure TToolBarSettingDialog.CreateListData(ToolBarItem: TToolBarItem);
247 for i := 0 to FActionList.ActionCount - 1 do begin
248 if FActionList.Actions[i].Tag = -1 then
250 Category := FActionList.Actions[i].Category;
251 //
\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Û
252 if (ToolBarItem.ToolType = gttStandard) and ((Category = '
\94Â') or (Category = '
\83X
\83\8c\83b
\83h')) then
254 //
\83\8a\83X
\83g
\83c
\81[
\83\8b\83o
\81[
\82Í
\81u
\94Â
\81v
\82Ì
\82Ý
\91Î
\8fÛ
255 if (ToolBarItem.ToolType = gttList) and (Category <> '
\94Â') then
257 //
\83u
\83\89\83E
\83U
\83c
\81[
\83\8b\83o
\81[
\82Í
\81u
\83X
\83\8c\83b
\83h
\81v
\82Ì
\82Ý
\91Î
\8fÛ
258 if (ToolBarItem.ToolType = gttBrowser) and (Category <> '
\83X
\83\8c\83b
\83h') then
261 if ToolBarItem.ButtonActionList.IndexOf(FActionList.Actions[i]) = -1 then
262 FAllList.Add(FActionList.Actions[i]);
266 //
\8fã
\82Ö
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
267 procedure TToolBarSettingDialog.UpButtonClick(Sender: TObject);
272 //
\89º
\82Ö
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
273 procedure TToolBarSettingDialog.DownButtonClick(Sender: TObject);
278 //
\83\8a\83Z
\83b
\83g
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
279 procedure TToolBarSettingDialog.ResetButtonClick(Sender: TObject);
281 ToolBarItem: TToolBarItem;
285 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
286 AllListView.Items.Count := 0;
287 CurrentListView.Items.Count := 0;
288 ToolBarItem.ButtonActionList.Clear;
289 case ToolBarComboBox.ItemIndex of
290 0: cnt := SetDefaultItem(DEF_STANDARD, ToolBarItem);
291 1: cnt := SetDefaultItem(DEF_LIST, ToolBarItem);
292 2: cnt := SetDefaultItem(DEF_BROWSER, ToolBarItem);
294 CreateListData(ToolBarItem);
295 AllListView.Items.Count := FAllList.Count;
296 CurrentListView.Items.Count := cnt;
299 CurrentListView.Refresh;
302 function TToolBarSettingDialog.SetDefaultItem(deflist: array of string; ToolBarItem: TToolBarItem): Integer;
305 Action: TCustomAction;
308 for i := 0 to Length(deflist) - 1 do begin
309 if deflist[i] = '' then begin
310 ToolBarItem.ButtonActionList.Add(nil);
313 Action := GetActionItem(FActionList, deflist[i]);
314 if Action <> nil then begin
315 ToolBarItem.ButtonActionList.Add(Action);
322 //
\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83A
\83C
\83e
\83\80\82ð
\88Ú
\93®
\82·
\82é
323 procedure TToolBarSettingDialog.MoveItem(Offset: Integer);
326 ToolBarItem: TToolBarItem;
328 Item := CurrentListView.Selected;
329 if (Item = nil) or (Item.Index + Offset < 0) then
332 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
333 if Item.Index + Offset >= ToolBarItem.ButtonActionList.Count then
336 ToolBarItem.ButtonActionList.Move(Item.Index, Item.Index + Offset);
337 CurrentListView.ItemIndex := Item.Index + Offset;
338 CurrentListView.Refresh;
341 //
\91S
\83c
\81[
\83\8b\83{
\83^
\83\93\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\91I
\91ð
\95Ï
\8dX
\8e\9e
342 procedure TToolBarSettingDialog.AllListViewChange(Sender: TObject;
343 Item: TListItem; Change: TItemChange);
345 AddButton.Enabled := not (Item = nil);
348 //
\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
349 procedure TToolBarSettingDialog.CurrentListViewChange(Sender: TObject;
350 Item: TListItem; Change: TItemChange);
352 UpButton.Enabled := not (Item = nil);
353 DownButton.Enabled := not (Item = nil);
354 RemoveButton.Enabled := not (Item = nil);
357 UpButton.Enabled := Item.Index > 0;
358 DownButton.Enabled := Item.Index < CurrentListView.Items.Count - 1;
361 //
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
362 procedure TToolBarSettingDialog.AddButtonClick(Sender: TObject);
365 ToolBarItem: TToolBarItem;
367 Action: TCustomAction;
369 Item := AllListView.Selected;
373 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
375 FAllList.Delete(Item.Index);
376 if Action <> nil then begin
377 Item := CurrentListView.Selected;
379 ToolBarItem.ButtonActionList.Add(Action)
381 ToolBarItem.ButtonActionList.Insert(Item.Index + 1, Action);
382 AllListView.Items.Count := AllListView.Items.Count - 1;
384 CurrentListView.Items.Count := CurrentListView.Items.Count + 1;
385 CurrentListView.Refresh;
389 //
\8dí
\8f\9c\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
390 procedure TToolBarSettingDialog.RemoveButtonClick(Sender: TObject);
392 ToolBarItem: TToolBarItem;
394 Action: TCustomAction;
396 Item := CurrentListView.Selected;
400 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
402 ToolBarItem.ButtonActionList.Delete(Item.Index);
403 if Action <> nil then begin
404 FAllList.Add(Action);
405 AllListView.Items.Count := AllListView.Items.Count + 1;
409 CurrentListView.Items.Count := CurrentListView.Items.Count - 1;
410 CurrentListView.Refresh;
413 //
\8bæ
\90Ø
\82è
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
414 procedure TToolBarSettingDialog.SeparatorAddButtonClick(Sender: TObject);
417 ToolBarItem: TToolBarItem;
419 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
420 if CurrentListView.Selected = nil then
421 idx := CurrentListView.Items.Count - 1
423 idx := CurrentListView.Selected.Index;
424 ToolBarItem.ButtonActionList.Insert(idx + 1, nil);
425 CurrentListView.Items.Count := CurrentListView.Items.Count + 1;
426 CurrentListView.Refresh;
429 //
\91S
\83c
\81[
\83\8b\83{
\83^
\83\93\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83\
\81[
\83g
430 procedure TToolBarSettingDialog.Sort;
432 FAllList.Sort(@CompareCategory);
435 //
\83\
\81[
\83g
\82·
\82é
\82Æ
\82«
\82Ì
\94ä
\8ar
436 function CompareCategory(Item1, Item2: Pointer): Integer;
438 Action1: TCustomAction;
439 Action2: TCustomAction;
441 if (Item1 = nil) and (Item2 = nil) then
443 else if (Item1 = nil) and (Item2 <> nil) then
445 else if (Item1 <> nil) and (Item2 = nil) then
448 if (TObject(Item1) is TCustomAction) and (TObject(Item1) is TCustomAction) then begin
449 Action1 := TCustomAction(Item1);
450 Action2 := TCustomAction(Item2);
451 Result := AnsiCompareStr(Action1.Category + Action1.Caption, Action2.Category + Action2.Caption);