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 procedure CreateListData(ToolBarItem: TToolBarItem);
64 procedure MoveItem(Offset: Integer);
66 function SetDefaultItem(deflist: array of string; ToolBarItem: TToolBarItem): Integer;
69 constructor Create(AOwner: TComponent; ActionList: TActionList); reintroduce; overload; virtual;
70 procedure AddToolBar(ToolBar: TToolBar; ToolType: TGikoToolType);
74 ToolBarSettingDialog: TToolBarSettingDialog;
76 function CompareCategory(Item1, Item2: Pointer): Integer;
81 // //
\8bæ
\90Ø
\82è
\95¶
\8e\9a
82 // SEPARATOR_TEXT = '-
\8bæ
\90Ø
\82è -';
89 constructor TToolBarItem.Create;
92 FButtonActionList := TList.Create;
95 destructor TToolBarItem.Destroy;
97 FButtonActionList.Free;
102 // TToolBarSettingDialog
104 constructor TToolBarSettingDialog.Create(AOwner: TComponent; ActionList: TActionList);
106 inherited Create(AOwner);
107 FActionList := ActionList;
110 //
\83t
\83H
\81[
\83\80\8dì
\90¬
111 procedure TToolBarSettingDialog.FormCreate(Sender: TObject);
113 FAllList := TList.Create;
116 //
\83t
\83H
\81[
\83\80\94j
\8aü
117 procedure TToolBarSettingDialog.FormDestroy(Sender: TObject);
122 for i := 0 to ToolBarComboBox.Items.Count - 1 do
123 ToolBarComboBox.Items.Objects[i].Free;
126 //
\95\
\8e¦
\82µ
\82½
\82Æ
\82«
127 procedure TToolBarSettingDialog.FormShow(Sender: TObject);
129 ToolBarComboBox.ItemIndex := 0;
130 ToolBarComboBoxChange(Self);
131 AllListViewChange(Sender, nil, ctState);
132 CurrentListViewChange(Sender, nil, ctState);
135 //
\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é
136 procedure TToolBarSettingDialog.AddToolBar(ToolBar: TToolBar; ToolType: TGikoToolType);
138 ToolBarItem: TToolBarItem;
141 ToolBarItem := TToolBarItem.Create;
142 ToolBarItem.ToolBar := ToolBar;
143 ToolBarItem.ToolType := ToolType;
144 for i := 0 to ToolBar.ControlCount - 1 do
145 if ToolBar.Controls[ i ] is TToolButton Then
146 ToolBarITem.ButtonActionList.Add(ToolBar.Controls[i].Action);
147 ToolBarComboBox.Items.AddObject(ToolBar.Caption, ToolBarItem);
151 //
\83R
\83\93\83{
\83{
\83b
\83N
\83X
\95Ï
\8dX
\8e\9e
152 procedure TToolBarSettingDialog.ToolBarComboBoxChange(Sender: TObject);
154 ToolBarItem: TToolBarItem;
156 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
157 CreateListData(ToolBarItem);
158 AllListView.Items.Count := FAllList.Count;
159 CurrentListView.Items.Count := ToolBarItem.ButtonActionList.Count;
162 CurrentListView.Refresh;
165 //OK
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
166 procedure TToolBarSettingDialog.OKButtonClick(Sender: TObject);
170 ToolButton: TToolButton;
171 ToolBarItem: TToolBarItem;
173 for i := 0 to ToolBarComboBox.Items.Count - 1 do begin
174 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[i]);
176 for j := ToolBarItem.ToolBar.ButtonCount - 1 downto 0 do
177 ToolBarItem.ToolBar.RemoveControl(ToolBarItem.ToolBar.Buttons[j]);
179 for j := 0 to ToolBarItem.ButtonActionList.Count - 1 do begin
180 if ToolBarItem.ButtonActionList[j] = nil then begin
181 ToolButton := TToolButton.Create(ToolBarItem.ToolBar);
182 ToolButton.Style := tbsSeparator;
183 ToolButton.Width := 8;
184 ToolButton.Left := 10000;
185 ToolBarItem.ToolBar.InsertControl(ToolButton);
186 end else if TObject(ToolBarItem.ButtonActionList[j]) is TCustomAction then begin
187 ToolButton := TToolButton.Create(ToolBarItem.ToolBar);
188 ToolButton.Action := TCustomAction(ToolBarItem.ButtonActionList[j]);
189 ToolButton.Left := 10000;
190 SetButtonStyle(ToolBarItem.ButtonActionList[j], ToolButton);
191 ToolBarItem.ToolBar.InsertControl(ToolButton);
197 //
\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
198 procedure TToolBarSettingDialog.AllListViewData(Sender: TObject; Item: TListItem);
200 Action: TCustomAction;
202 if (FAllList.Count <= 0) or (FAllList.Count <= Item.Index) then
204 if FAllList[Item.Index] = nil then begin
205 Item.Caption := SEPARATOR_TEXT;
206 Item.ImageIndex := -1;
208 end else if TObject(FAllList[Item.Index]) is TCustomAction then begin
209 Action := TCustomAction(FAllList[Item.Index]);
210 Item.Caption := Action.Hint;
211 Item.ImageIndex := Action.ImageIndex;
216 //
\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
217 procedure TToolBarSettingDialog.CurrentListViewData(Sender: TObject; Item: TListItem);
219 Action: TCustomAction;
220 ToolBarItem: TToolBarItem;
222 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
224 if (ToolBarItem.ButtonActionList.Count <= 0) or (ToolBarItem.ButtonActionList.Count <= Item.Index) then
226 if ToolBarItem.ButtonActionList[Item.Index] = nil then begin
227 Item.Caption := SEPARATOR_TEXT;
228 Item.ImageIndex := -1;
230 end else if TObject(ToolBarItem.ButtonActionList[Item.Index]) is TCustomAction then begin
231 Action := TCustomAction(ToolBarItem.ButtonActionList[Item.Index]);
232 Item.Caption := Action.Hint;
233 Item.ImageIndex := Action.ImageIndex;
238 //
\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¬
239 procedure TToolBarSettingDialog.CreateListData(ToolBarItem: TToolBarItem);
245 for i := 0 to FActionList.ActionCount - 1 do begin
246 if FActionList.Actions[i].Tag = -1 then
248 Category := FActionList.Actions[i].Category;
249 //
\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Û
250 if (ToolBarItem.ToolType = gttStandard) and ((Category = '
\94Â') or (Category = '
\83X
\83\8c\83b
\83h')) then
252 //
\83\8a\83X
\83g
\83c
\81[
\83\8b\83o
\81[
\82Í
\81u
\94Â
\81v
\82Ì
\82Ý
\91Î
\8fÛ
253 if (ToolBarItem.ToolType = gttList) and (Category <> '
\94Â') then
255 //
\83u
\83\89\83E
\83U
\83c
\81[
\83\8b\83o
\81[
\82Í
\81u
\83X
\83\8c\83b
\83h
\81v
\82Ì
\82Ý
\91Î
\8fÛ
256 if (ToolBarItem.ToolType = gttBrowser) and (Category <> '
\83X
\83\8c\83b
\83h') then
259 if ToolBarItem.ButtonActionList.IndexOf(FActionList.Actions[i]) = -1 then
260 FAllList.Add(FActionList.Actions[i]);
264 //
\8fã
\82Ö
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
265 procedure TToolBarSettingDialog.UpButtonClick(Sender: TObject);
270 //
\89º
\82Ö
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
271 procedure TToolBarSettingDialog.DownButtonClick(Sender: TObject);
276 //
\83\8a\83Z
\83b
\83g
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
277 procedure TToolBarSettingDialog.ResetButtonClick(Sender: TObject);
279 ToolBarItem: TToolBarItem;
283 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
284 AllListView.Items.Count := 0;
285 CurrentListView.Items.Count := 0;
286 ToolBarItem.ButtonActionList.Clear;
287 case ToolBarComboBox.ItemIndex of
288 0: cnt := SetDefaultItem(DEF_STANDARD, ToolBarItem);
289 1: cnt := SetDefaultItem(DEF_LIST, ToolBarItem);
290 2: cnt := SetDefaultItem(DEF_BROWSER, ToolBarItem);
292 CreateListData(ToolBarItem);
293 AllListView.Items.Count := FAllList.Count;
294 CurrentListView.Items.Count := cnt;
297 CurrentListView.Refresh;
300 function TToolBarSettingDialog.SetDefaultItem(deflist: array of string; ToolBarItem: TToolBarItem): Integer;
303 Action: TCustomAction;
306 for i := 0 to Length(deflist) - 1 do begin
307 if deflist[i] = '' then begin
308 ToolBarItem.ButtonActionList.Add(nil);
311 Action := GetActionItem(FActionList, deflist[i]);
312 if Action <> nil then begin
313 ToolBarItem.ButtonActionList.Add(Action);
320 //
\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83A
\83C
\83e
\83\80\82ð
\88Ú
\93®
\82·
\82é
321 procedure TToolBarSettingDialog.MoveItem(Offset: Integer);
324 ToolBarItem: TToolBarItem;
326 Item := CurrentListView.Selected;
327 if (Item = nil) or (Item.Index + Offset < 0) then
330 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
331 if Item.Index + Offset >= ToolBarItem.ButtonActionList.Count then
334 ToolBarItem.ButtonActionList.Move(Item.Index, Item.Index + Offset);
335 CurrentListView.ItemIndex := Item.Index + Offset;
336 CurrentListView.Refresh;
339 //
\91S
\83c
\81[
\83\8b\83{
\83^
\83\93\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\91I
\91ð
\95Ï
\8dX
\8e\9e
340 procedure TToolBarSettingDialog.AllListViewChange(Sender: TObject;
341 Item: TListItem; Change: TItemChange);
343 AddButton.Enabled := not (Item = nil);
346 //
\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
347 procedure TToolBarSettingDialog.CurrentListViewChange(Sender: TObject;
348 Item: TListItem; Change: TItemChange);
350 UpButton.Enabled := not (Item = nil);
351 DownButton.Enabled := not (Item = nil);
352 RemoveButton.Enabled := not (Item = nil);
355 UpButton.Enabled := Item.Index > 0;
356 DownButton.Enabled := Item.Index < CurrentListView.Items.Count - 1;
359 //
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
360 procedure TToolBarSettingDialog.AddButtonClick(Sender: TObject);
363 ToolBarItem: TToolBarItem;
365 Action: TCustomAction;
367 Item := AllListView.Selected;
371 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
373 FAllList.Delete(Item.Index);
374 if Action <> nil then begin
375 Item := CurrentListView.Selected;
377 ToolBarItem.ButtonActionList.Add(Action)
379 ToolBarItem.ButtonActionList.Insert(Item.Index + 1, Action);
380 AllListView.Items.Count := AllListView.Items.Count - 1;
382 CurrentListView.Items.Count := CurrentListView.Items.Count + 1;
383 CurrentListView.Refresh;
387 //
\8dí
\8f\9c\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
388 procedure TToolBarSettingDialog.RemoveButtonClick(Sender: TObject);
390 ToolBarItem: TToolBarItem;
392 Action: TCustomAction;
394 Item := CurrentListView.Selected;
398 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
400 ToolBarItem.ButtonActionList.Delete(Item.Index);
401 if Action <> nil then begin
402 FAllList.Add(Action);
403 AllListView.Items.Count := AllListView.Items.Count + 1;
407 CurrentListView.Items.Count := CurrentListView.Items.Count - 1;
408 CurrentListView.Refresh;
411 //
\8bæ
\90Ø
\82è
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\82µ
\82½
\82Æ
\82«
412 procedure TToolBarSettingDialog.SeparatorAddButtonClick(Sender: TObject);
415 ToolBarItem: TToolBarItem;
417 ToolBarItem := TToolBarItem(ToolBarComboBox.Items.Objects[ToolBarComboBox.ItemIndex]);
418 if CurrentListView.Selected = nil then
419 idx := CurrentListView.Items.Count - 1
421 idx := CurrentListView.Selected.Index;
422 ToolBarItem.ButtonActionList.Insert(idx + 1, nil);
423 CurrentListView.Items.Count := CurrentListView.Items.Count + 1;
424 CurrentListView.Refresh;
427 //
\91S
\83c
\81[
\83\8b\83{
\83^
\83\93\83\8a\83X
\83g
\83r
\83\85\81[
\82Ì
\83\
\81[
\83g
428 procedure TToolBarSettingDialog.Sort;
430 FAllList.Sort(@CompareCategory);
433 //
\83\
\81[
\83g
\82·
\82é
\82Æ
\82«
\82Ì
\94ä
\8ar
434 function CompareCategory(Item1, Item2: Pointer): Integer;
436 Action1: TCustomAction;
437 Action2: TCustomAction;
439 if (Item1 = nil) and (Item2 = nil) then
441 else if (Item1 = nil) and (Item2 <> nil) then
443 else if (Item1 <> nil) and (Item2 = nil) then
446 if (TObject(Item1) is TCustomAction) and (TObject(Item1) is TCustomAction) then begin
447 Action1 := TCustomAction(Item1);
448 Action2 := TCustomAction(Item2);
449 Result := AnsiCompareStr(Action1.Category + Action1.Caption, Action2.Category + Action2.Caption);