6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, ExtCtrls, ActnList, Menus, ComCtrls;
10 TPopupMenuSettingDialog = class(TForm)
12 PopupMenuComboLabel: TLabel;
13 PopupMenuComboBox: TComboBox;
15 ActionListBox: TListBox;
17 AddMainButton: TButton;
18 AddSubButton: TButton;
19 AddSepButton: TButton;
20 RemoveButton: TButton;
23 MenuTreeView: TTreeView;
29 procedure PopupMenuComboBoxChange(Sender: TObject);
30 procedure FormCreate(Sender: TObject);
31 procedure FormDestroy(Sender: TObject);
32 procedure UpButtonClick(Sender: TObject);
33 procedure DownButtonClick(Sender: TObject);
34 procedure RemoveButtonClick(Sender: TObject);
35 procedure AddSepButtonClick(Sender: TObject);
36 procedure MenuTreeViewDblClick(Sender: TObject);
37 procedure MenuTreeViewEdited(Sender: TObject; Node: TTreeNode;
39 procedure MenuTreeViewEditing(Sender: TObject; Node: TTreeNode;
40 var AllowEdit: Boolean);
41 procedure AddMainButtonClick(Sender: TObject);
42 procedure AddSubButtonClick(Sender: TObject);
43 procedure LabelButtonClick(Sender: TObject);
44 procedure MenuTreeViewChange(Sender: TObject; Node: TTreeNode);
45 procedure ApplyButtonClick(Sender: TObject);
48 FActionList: TActionList;
49 FSpecialActionLists: array[0..0] of TStringList;
50 function GetMenuAction(var Item:TMenuItem; Idx:Integer): TBasicAction;
51 procedure AddMainMenu(const Caption: String; Action: TBasicAction);
52 procedure DeleteUsedActionList(Action: TBasicAction);
53 function GetIniString(Node: TTreeNode; Parent: String; Idx: Integer): String;
54 function GetIniValueString(Node: TTreeNode): String;
57 constructor Create(AOwner: TComponent; ActionList: TActionList); reintroduce; overload; virtual;
61 PopupMenuSettingDialog: TPopupMenuSettingDialog;
66 PopupMenuUtil, IniFiles, GikoSystem, ToolBarUtil, GikoUtil;
68 //!
\83R
\83\93\83X
\83g
\83\89\83N
\83^
\81i
\88ø
\90\94\92Ç
\89Á
\81j
69 constructor TPopupMenuSettingDialog.Create(AOwner: TComponent; ActionList: TActionList);
71 //
\93Á
\8eê
\83A
\83N
\83V
\83\87\83\93\96¼
72 //
\8f\84\89ñ
\83A
\83C
\83e
\83\80
73 ROUNDITEM = 'RoundItem';
74 //
\93¯
\88ê
\94Â
\83X
\83\8c\83b
\83h
\88ê
\97\97\97p
75 SAMPETHREAD='BoardThreadItem';
79 inherited Create(AOwner);
80 FActionList := ActionList;
81 FSpecialActionLists[0] := TStringList.Create();
82 //
\8ae
\83|
\83b
\83v
\83A
\83b
\83v
\82Ì
\93Á
\8eê
\83A
\83N
\83V
\83\87\83\93\82ð
\92Ç
\89Á
83 act := TCustomAction.Create(Self);
84 act.Name := ROUNDITEM;
85 act.Caption := '
\83X
\83\8c\83b
\83h
\8f\84\89ñ
\97\
\96ñ';
86 FSpecialActionLists[0].AddObject(act.Caption, act);
87 act := TCustomAction.Create(Self);
88 act.Name := SAMPETHREAD;
89 act.Caption := '
\93¯
\94Â
\82Å
\95\
\8e¦
\82µ
\82Ä
\82¢
\82é
\83X
\83\8c\83b
\83h';
90 FSpecialActionLists[0].AddObject(act.Caption, act);
93 //!
\83|
\83b
\83v
\83A
\83b
\83v
\83\81\83j
\83\85\81[
\83R
\83\93\83{
\83{
\83b
\83N
\83X
\95Ï
\8dX
\83C
\83x
\83\93\83g
94 procedure TPopupMenuSettingDialog.PopupMenuComboBoxChange(Sender: TObject);
99 mkeys, skeys : TStringList;
101 value, subValue : String;
102 item, subItem : TMenuItem;
105 ActionListBox.Items.Clear;
106 MenuTreeView.Items.Clear;
107 AddSubButton.Enabled := False;
108 case PopupMenuComboBox.ItemIndex of
110 for idx := 0 to Length(PopupMenuUtil.ACK_BROWSER) -1 do begin
111 act := PopupMenuUtil.GetActionItem(FActionList, PopupMenuUtil.ACK_BROWSER[idx]);
112 if (act <> nil) then begin
113 ActionListBox.AddItem(act.Caption, act);
120 for idx := 0 to FSpecialActionLists[PopupMenuComboBox.ItemIndex].Count - 1 do begin
121 //
\88ê
\92U
\82·
\82×
\82Ä
\92Ç
\89Á
\82·
\82é
122 act := TCustomAction(FSpecialActionLists[PopupMenuComboBox.ItemIndex].Objects[idx]);
123 if (act <> nil) then begin
124 ActionListBox.AddItem(act.Caption, act);
128 //ini
\83t
\83@
\83C
\83\8b\82Ì
\93Ç
\82Ý
\8d\9e\82Ý
129 if (FileExists(GikoSys.Setting.GetConfigDir + PopupMenuUtil.INI_FILENAME)) Then begin
130 ini := TMemIniFile.Create(GikoSys.Setting.GetConfigDir + PopupMenuUtil.INI_FILENAME);
131 mkeys := TStringList.Create;
132 mkeys.Sorted := true;
133 skeys := TStringList.Create;
134 skeys.Sorted := true;
137 idx := PopupMenuComboBox.ItemIndex;
138 ini.ReadSection(PopupMenuUtil.SECTIONS[idx], mkeys);
139 // main
\91æ
\88ê
\8aK
\91w sub
\91æ
\93ñ
\8aK
\91w
\82Ì
\95ª
\97£
140 for i := mkeys.Count - 1 downto 0 do begin
141 if (Pos('sub', mkeys[i]) = 1) then begin
146 //
\91æ
\88ê
\8aK
\91w
\82Ì
\8f\88\97\9d
147 for i := 0 to mkeys.Count - 1 do begin
148 value := ini.ReadString(PopupMenuUtil.SECTIONS[idx], mkeys[i], '-');
149 item := PopupMenuUtil.GetMenuItem(
150 PopupMenuUtil.SECTIONS[idx], nil, FActionList, value);
151 if (item <> nil) then begin
152 bact := GetMenuAction(item, PopupMenuComboBox.ItemIndex);
153 node := MenuTreeView.Items.AddObject(node, item.Caption, bact);
154 DeleteUsedActionList(bact);
155 //
\83A
\83N
\83V
\83\87\83\93\82ª
\90Ý
\92è
\82³
\82ê
\82Ä
\82¢
\82é
\82à
\82Ì
\82É
\82Í
\91æ
\93ñ
\91w
\82Í
\82Â
\82¯
\82È
\82¢
156 if (item.Action = nil) then begin
157 //
\91æ
\93ñ
\8aK
\91w
\82Ì
\8f\88\97\9d(
\82 \82ê
\82Î)
158 for j := 0 to skeys.Count - 1 do begin
159 if (Pos('sub.' + mkeys[i], skeys[j]) = 1) then begin
160 subValue := ini.ReadString(PopupMenuUtil.SECTIONS[idx], skeys[j], '-');
161 subItem := GetMenuItem(PopupMenuUtil.SECTIONS[idx], nil, FActionList, subValue);
162 if (subItem <> nil) then begin
163 bact := GetMenuAction(item, PopupMenuComboBox.ItemIndex);
164 MenuTreeView.Items.AddChildObject(
165 node, subItem.Caption, bact);
166 DeleteUsedActionList(bact);
183 //!
\83\81\83j
\83\85\81[
\83A
\83N
\83V
\83\87\83\93\8eæ
\93¾
184 function TPopupMenuSettingDialog.GetMenuAction(var Item:TMenuItem; Idx:Integer): TBasicAction;
189 if (Item.Action <> nil) then begin
190 Result := Item.Action;
191 end else if (Item.Caption = '-') then begin
192 Item.Caption := ToolBarUtil.SEPARATOR_TEXT;
194 for i := 0 to FSpecialActionLists[Idx].Count - 1 do begin
195 if Item.Name = TCustomAction(FSpecialActionLists[Idx].Objects[i]).Name then begin
196 Result := TBasicAction(FSpecialActionLists[Idx].Objects[i]);
202 //!
\83t
\83H
\81[
\83\80\90¶
\90¬
203 procedure TPopupMenuSettingDialog.FormCreate(Sender: TObject);
205 PopupMenuComboBox.OnChange(nil);
207 //!
\83t
\83H
\81[
\83\80\8dí
\8f\9c
208 procedure TPopupMenuSettingDialog.FormDestroy(Sender: TObject);
212 ActionListBox.Items.Clear;
213 //
\93Á
\8eê
\83A
\83N
\83V
\83\87\83\93\82Í
\8dí
\8f\9c\82·
\82é
214 for i := 0 to Length(FSpecialActionLists) - 1 do begin
215 if (FSpecialActionLists[i] <> nil) then begin
216 for idx := FSpecialActionLists[i].Count - 1 downto 0 do begin
217 TComponent(FSpecialActionLists[i].Objects[idx]).Free;
219 FSpecialActionLists[i].Free;
223 //! Up
\83{
\83^
\83\93\89\9f\89º
\8f\88\97\9d
224 procedure TPopupMenuSettingDialog.UpButtonClick(Sender: TObject);
226 if (MenuTreeView.Selected <> nil) then begin
227 if (MenuTreeView.Selected.GetPrevSibling <> nil) then begin
228 MenuTreeView.Selected.MoveTo(
229 MenuTreeView.Selected.GetPrevSibling,
234 //! Down
\83{
\83^
\83\93\89\9f\89º
\8f\88\97\9d
235 procedure TPopupMenuSettingDialog.DownButtonClick(Sender: TObject);
237 if (MenuTreeView.Selected <> nil) then begin
238 if (MenuTreeView.Selected.GetNextSibling <> nil) then begin
239 MenuTreeView.Selected.GetNextSibling
241 MenuTreeView.Selected,
246 //!
\8dí
\8f\9c\83{
\83^
\83\93\89\9f\89º
\8f\88\97\9d
247 procedure TPopupMenuSettingDialog.RemoveButtonClick(Sender: TObject);
252 if (MenuTreeView.Selected <> nil) then begin
253 if (TObject(MenuTreeView.Selected.Data) is TCustomAction) then begin
254 act := TCustomAction(MenuTreeView.Selected.Data);
255 //
\93Á
\8eê
\83A
\83N
\83V
\83\87\83\93\82Ì
\8fê
\8d\87\81AAction
\83\8a\83X
\83g
\82É
\95\9c\8a\88\82³
\82¹
\82é
256 for idx := 0 to FSpecialActionLists[PopupMenuComboBox.ItemIndex].Count - 1 do begin
257 if ( act = TCustomAction(FSpecialActionLists[PopupMenuComboBox.ItemIndex].Objects[idx]) )
259 ActionListBox.AddItem(act.Caption, act);
264 MenuTreeView.Items.Delete(MenuTreeView.Selected);
268 //!
\8bæ
\90Ø
\82è
\92Ç
\89Á
\83{
\83^
\83\93\83C
\83x
\83\93\83g
269 procedure TPopupMenuSettingDialog.AddSepButtonClick(Sender: TObject);
273 item := TMenuItem.Create(nil);
275 AddMainMenu( item.Caption,
276 GetMenuAction(item, PopupMenuComboBox.ItemIndex));
279 //!
\83\81\83j
\83\85\81[
\83c
\83\8a\81[
\83_
\83u
\83\8b\83N
\83\8a\83b
\83N
\8e\9e\83C
\83x
\83\93\83g
280 procedure TPopupMenuSettingDialog.MenuTreeViewDblClick(Sender: TObject);
282 if (MenuTreeView.Selected <> nil) then begin
283 //
\95Ò
\8fW
\89Â
\94\
\82È
\83\89\83x
\83\8b\82©
\82Í
\81AAction
\82ª
\90Ý
\92è
\82³
\82ê
\82Ä
\82¢
\82é
\82©
\82Å
\94»
\92è
284 if not (TObject(MenuTreeView.Selected.Data) is TBasicAction) then begin
285 MenuTreeView.ReadOnly := False;
286 MenuTreeView.Selected.EditText;
290 //!
\83\81\83j
\83\85\81[
\83c
\83\8a\81[
\95Ò
\8fW
\8a®
\97¹
\83C
\83x
\83\93\83g
291 procedure TPopupMenuSettingDialog.MenuTreeViewEdited(Sender: TObject;
292 Node: TTreeNode; var S: String);
294 //
\93Ç
\82Ý
\8eæ
\82è
\90ê
\97p
\82É
\95Ï
\8dX
295 MenuTreeView.ReadOnly := True;
297 //!
\83\81\83j
\83\85\81[
\83c
\83\8a\81[
\95Ò
\8fW
\83C
\83x
\83\93\83g
298 procedure TPopupMenuSettingDialog.MenuTreeViewEditing(Sender: TObject;
299 Node: TTreeNode; var AllowEdit: Boolean);
301 if (Node <> nil) then begin
302 AllowEdit := not (TObject(Node.Data) is TBasicAction);
305 //!
\83\81\83j
\83\85\81[
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\89º
\8f\88\97\9d
306 procedure TPopupMenuSettingDialog.AddMainButtonClick(Sender: TObject);
313 for idx := 0 to ActionListBox.Count - 1 do begin
314 if ( ActionListBox.Selected[idx] ) then begin
315 act := TCustomAction(ActionListBox.Items.Objects[idx]);
316 //
\93Á
\8eê
\83A
\83N
\83V
\83\87\83\93\82Ì
\8fê
\8d\87\81AAction
\83\8a\83X
\83g
\82©
\82ç
\8dí
\8f\9c\82·
\82é
317 for idx2 := 0 to FSpecialActionLists[PopupMenuComboBox.ItemIndex].Count - 1 do begin
318 if ( act = TCustomAction(FSpecialActionLists[PopupMenuComboBox.ItemIndex].Objects[idx2]) )
320 ActionListBox.Items.Delete(idx);
329 if ( act <> nil ) then begin
330 AddMainMenu( act.Caption, TBasicAction(act) );
333 //!
\83T
\83u
\83\81\83j
\83\85\81[
\92Ç
\89Á
\83{
\83^
\83\93\89\9f\89º
\8f\88\97\9d
334 procedure TPopupMenuSettingDialog.AddSubButtonClick(Sender: TObject);
341 node := MenuTreeView.Selected;
343 if (node <> nil) then begin
344 if not (TObject(node.Data) is TBasicAction) then begin
346 for idx := 0 to ActionListBox.Count - 1 do begin
347 if ( ActionListBox.Selected[idx] ) then begin
348 act := TCustomAction(ActionListBox.Items.Objects[idx]);
349 //
\93Á
\8eê
\83A
\83N
\83V
\83\87\83\93\82Ì
\8fê
\8d\87\81AAction
\83\8a\83X
\83g
\82©
\82ç
\8dí
\8f\9c\82·
\82é
350 for idx2 := 0 to FSpecialActionLists[PopupMenuComboBox.ItemIndex].Count - 1 do begin
351 if ( act = TCustomAction(FSpecialActionLists[PopupMenuComboBox.ItemIndex].Objects[idx2]) )
353 ActionListBox.Items.Delete(idx);
360 if ( act <> nil ) then begin
361 MenuTreeView.Items.AddChildObject(
362 node, act.Caption, act);
367 //!
\83\89\83x
\83\8b\92Ç
\89Á
\83{
\83^
\83\93\89\9f\89º
\8f\88\97\9d
368 procedure TPopupMenuSettingDialog.LabelButtonClick(Sender: TObject);
370 if (MenuTreeView.Selected <> nil) then begin
371 //
\83T
\83u
\83\81\83j
\83\85\81[
\82É
\83\89\83x
\83\8b\82Í
\92Ç
\89Á
\82Å
\82«
\82È
\82¢
372 if ( MenuTreeView.Selected.Parent <> nil) then begin
376 AddMainMenu('
\90V
\8bK
\83\89\83x
\83\8b', TBasicAction(nil));
378 //!
\83\81\83j
\83\85\81[
\83c
\83\8a\81[
\83\81\83C
\83\93\83\81\83j
\83\85\81[
\92Ç
\89Á
379 procedure TPopupMenuSettingDialog.AddMainMenu(const Caption: String; Action: TBasicAction);
385 if (MenuTreeView.Selected <> nil) then begin
386 //
\83T
\83u
\83\81\83j
\83\85\81[
387 if ( MenuTreeView.Selected.Parent <> nil) then begin
388 //
\93¯
\88ê
\8aK
\91w
\82Ì
\8e\9f\82Ì
\83A
\83C
\83e
\83\80\82ð
\8eæ
\93¾
389 if (MenuTreeView.Selected.getNextSibling <> nil) then begin
390 node := MenuTreeView.Selected.getNextSibling;
392 node := MenuTreeView.Selected;
395 node := MenuTreeView.Selected.getNextSibling;
398 // node
\82ªnil
\82È
\82ç
\96\96\94ö
\92Ç
\89Á
399 if ( node <> nil ) then begin
400 MenuTreeView.Items.InsertObject(node,
403 MenuTreeView.Items.AddObject(node,
407 //!
\8eg
\97p
\8dÏ
\82Ý
\93Á
\8eê
\83A
\83N
\83V
\83\87\83\93\82ð
\83A
\83N
\83V
\83\87\83\93\83\8a\83X
\83g
\82©
\82ç
\8dí
\8f\9c\82·
\82é
408 procedure TPopupMenuSettingDialog.DeleteUsedActionList(Action: TBasicAction);
413 if (Action is TCustomAction) then begin
414 act := TCustomAction(Action);
415 //
\93Á
\8eê
\83A
\83N
\83V
\83\87\83\93\82Ì
\8fê
\8d\87\81AAction
\83\8a\83X
\83g
\82©
\82ç
\8dí
\8f\9c\82·
\82é
416 for idx2 := 0 to FSpecialActionLists[PopupMenuComboBox.ItemIndex].Count - 1 do begin
417 if ( act = TCustomAction(FSpecialActionLists[PopupMenuComboBox.ItemIndex].Objects[idx2]) )
419 for idx := 0 to ActionListBox.Count - 1 do begin
420 if ( act = TCustomAction(ActionListBox.Items.Objects[idx]) )
422 ActionListBox.Items.Delete(idx);
432 procedure TPopupMenuSettingDialog.MenuTreeViewChange(Sender: TObject;
435 if (Node <> nil) then begin
436 if (Node.Data = nil) and (Node.Text <> ToolBarUtil.SEPARATOR_TEXT) then begin
437 AddSubButton.Enabled := True;
439 AddSubButton.Enabled := False;
442 AddSubButton.Enabled := False;
446 function TPopupMenuSettingDialog.GetIniString(Node: TTreeNode; Parent: String; Idx: Integer): String;
449 if ( Node.Parent <> nil ) then begin
450 Result := Format('sub.%s.%2.2d', [Parent, idx + 1]);
452 Result := Format('main.%2.2d', [idx + 1]);
455 function TPopupMenuSettingDialog.GetIniValueString(Node: TTreeNode): String;
458 if (Node.Data = nil) then begin
459 if (Node.Text <> ToolBarUtil.SEPARATOR_TEXT) then begin
460 Result := '"' + Node.Text;
465 Result := TBasicAction(Node.Data).Name;
468 //!
\93K
\97p
\83{
\83^
\83\93\89\9f\89º
\8f\88\97\9d
469 procedure TPopupMenuSettingDialog.ApplyButtonClick(Sender: TObject);
471 MSG = '
\90Ý
\92è
\82ð
\95Û
\91¶
\82µ
\82Ü
\82µ
\82½
\81B
\8dÄ
\8bN
\93®
\8cã
\82É
\97L
\8cø
\82É
\82È
\82è
\82Ü
\82·
\81B';
474 sec, key, subkey : String;
476 idx, mainIdx, subIdx : Integer;
478 ini := TMemIniFile.Create(GikoSys.Setting.GetConfigDir + PopupMenuUtil.INI_FILENAME);
480 sec := PopupMenuUtil.SECTIONS[PopupMenuComboBox.ItemIndex];
481 //
\83Z
\83N
\83V
\83\87\83\93\82·
\82×
\82Ä
\82ð
\8fÁ
\82·
482 ini.EraseSection(sec);
486 node := MenuTreeView.Items.GetFirstNode;
487 while node <> nil do begin
488 if (node.Parent = nil) then begin
490 key := GetIniString(node, key, mainIdx);
491 ini.WriteString(sec, key, GetIniValueString(node));
494 subkey := GetIniString(node, key, subIdx);
495 ini.WriteString(sec, subkey, GetIniValueString(node));
498 node := node.GetNext;
502 MsgBox(Self.Handle, MSG, '
\83M
\83R
\83i
\83r', MB_OK or MB_ICONINFORMATION);