Develop and Download Open Source Software

Browse CVS Repository

Contents of /gikonavigoeson/gikonavi/PopupMenuUtil.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Sat Jul 11 04:34:17 2009 UTC (14 years, 9 months ago) by h677
Branch: MAIN
CVS Tags: v1_63_0_818, v1_63_0_817, v1_63_0_816, v1_63_0_815, v1_63_1_819, v1_62_0_805, v1_62_0_804, v1_62_0_807, v1_62_0_806, v1_62_0_803, v1_62_0_802, v1_62_0_809, v1_61_0_798, v1_61_0_799, v1_62_1_813, v1_62_0_812, v1_62_0_810, v1_62_0_811, v1_61_0_800, v1_61_1_801, HEAD
Branch point for: Bb62, Bb63, Bb61
File MIME type: text/x-pascal
ポップアップメニューのカスタマイズ化への道第一歩。
ブラウザタブを設定可能にした。

1 unit PopupMenuUtil;
2
3 interface
4
5 uses
6 Windows, Messages, SysUtils, Classes, Controls,
7 StdCtrls, ExtCtrls, ComCtrls, ActnList, Menus,
8 IniFiles, GikoSystem, MojuUtils, Giko;
9
10 procedure ReadSetting(ActionList: TActionList; PopupMenu: TPopupMenu);
11 function GetActionItem(ActionList: TActionList; ActionName: string): TCustomAction;
12 function GetMenuItem(Section: string; PopupMenu: TPopupMenu; ActionList: TActionList; MenuName: string): TMenuItem;
13 function checkActionName(Section: string ; ActionName: string): Boolean;
14 const
15 //! 荐?????<?ゃ????
16 INI_FILENAME: string = 'popupmenu.ini';
17 //! ???????吟?帥???祉???激?с?喝??
18 BROWSER_TAB: string = 'BrowserTab';
19 //! ?祉???激?с?潟???荀?/span>
20 SECTIONS : array[0..0] of string =( 'BrowserTab' ) ;
21
22 //! ???????吟?帥?????????≪??????┃絎????純???<???ャ?弱??
23 ACK_BROWSER: array[0..7] of string = (
24 'ItemReloadAction',
25 'FavoriteAddAction',
26 'BrowserTabCloseAction',
27 'NotSelectTabCloseAction',
28 'LeftTabCloseAction',
29 'RightTabCloseAction',
30 'ActiveLogDeleteAction',
31 'AllTabCloseAction');
32
33 implementation
34 procedure ReadSetting(ActionList: TActionList; PopupMenu: TPopupMenu);
35 const
36 // ?号??≪???激?с?喝??
37 // 綏≦???≪?ゃ????
38 ROUNDITEM = 'RoundItem';
39 // ??筝??帥?鴻??????筝?荀х??/span>
40 SAMPETHREAD='SameBoardThreadItem';
41 var
42 ini : TMemIniFile;
43 mkeys, skeys : TStringList;
44 i, j, idx: Integer;
45 value, subValue : String;
46 item, subItem : TMenuItem;
47 begin
48 if (FileExists(GikoSys.Setting.GetConfigDir + INI_FILENAME)) Then begin
49 ini := TMemIniFile.Create(GikoSys.Setting.GetConfigDir + INI_FILENAME);
50 mkeys := TStringList.Create;
51 mkeys.Sorted := true;
52 skeys := TStringList.Create;
53 skeys.Sorted := true;
54 try
55 for idx := 0 to Length(SECTIONS) - 1 do begin
56 ini.ReadSection(SECTIONS[idx], mkeys);
57 // main膃????韻 sub膃????韻??????/span>
58 for i := mkeys.Count - 1 downto 0 do begin
59 if (Pos('sub', mkeys[i]) = 1) then begin
60 skeys.Add(mkeys[i]);
61 mkeys.Delete(i);
62 end;
63 end;
64 // 膃????韻??????
65 PopupMenu.Items.Clear;
66 for i := 0 to mkeys.Count - 1 do begin
67 value := ini.ReadString(SECTIONS[idx], mkeys[i], '-');
68 item := GetMenuItem(SECTIONS[idx], PopupMenu, ActionList, value);
69 if (item <> nil) then begin
70 PopupMenu.Items.Add(item);
71 // ?≪???激?с?潟??荐?????????????????????篋?絮ゃ???ゃ??????
72 if (item.Action = nil) then begin
73 // 膃????韻??????(??????
74 for j := 0 to skeys.Count - 1 do begin
75 if (Pos('sub.' + mkeys[i], skeys[j]) = 1) then begin
76 subValue := ini.ReadString(SECTIONS[idx], skeys[j], '-');
77 subItem := GetMenuItem(SECTIONS[idx], PopupMenu, ActionList, subValue);
78 if (subItem <> nil) then begin
79 item.Add(subItem);
80 end;
81 end;
82 end;
83 end;
84 end;
85 end;
86 // ?????祉???激?с?潟????????腟???c?????с??????/span>
87 mkeys.Clear;
88 skeys.Clear;
89 end;
90 finally
91 skeys.Free;
92 mkeys.Free;
93 ini.Free;
94 end;
95 end;
96 end;
97 //! ?<???ャ?若??菴???
98 function GetMenuItem(Section: string; PopupMenu: TPopupMenu; ActionList: TActionList; MenuName: string): TMenuItem;
99 var
100 Action: TCustomAction;
101 begin
102 Result := nil;
103 // ???????????若???у??障??????????????/span>
104 if (Pos('"', MenuName)=1) then begin
105 Result := TMenuItem.Create(PopupMenu);
106 Result.Caption := Copy(MenuName, 2, Length(MenuName));
107 end else if (MenuName = '-' ) then begin
108 // ?阪????膩?
109 Result := TMenuItem.Create(PopupMenu);
110 Result.Caption := '-';
111 end else begin
112 if (BROWSER_TAB = Section) then begin
113 // ???????吟?帥?????号?絲上?
114 if (MenuName = 'RoundItem' ) then begin
115 try
116 // 綏≦???<???ャ?主????????/span>
117 Result := TMenuItem.Create(PopupMenu);
118 Result.Name := 'RoundItem';
119 Result.Caption := GikoForm.ItemReservPMenu.Caption;
120 Result.Hint := GikoForm.ItemReservPMenu.Hint;
121 except
122 // ?≪??戎??????????????????若??????
123 Result.Free;
124 Result := nil;
125 end;
126 end else if (MenuName = 'BoardThreadItem' ) then begin
127 try
128 // ??筝??帥?鴻??????茵?ず????????/span>
129 Result := TMenuItem.Create(PopupMenu);
130 Result.Name := 'BoardThreadItem';
131 Result.Caption := '???帥?ц;腓冴?????????鴻??????';
132 except
133 // ?≪??戎??????????????????若??????
134 Result.Free;
135 Result := nil;
136 end;
137 end;
138 end;
139 // ?<???ャ?若??羆冴?障????????荐怨????????≪???激?с?喝??????Action????篏???
140 if (Result = nil) and (checkActionName(Section, MenuName)) then begin
141 Action := GetActionItem(ActionList, MenuName);
142 if Action <> nil then begin
143 Result := TMenuItem.Create(PopupMenu);
144 Result.Action := Action;
145 end;
146 end;
147 end;
148 end;
149 //ActionName??ction??菴????障??
150 function GetActionItem(ActionList: TActionList; ActionName: string): TCustomAction;
151 var
152 i: Integer;
153 begin
154 for i := 0 to ActionList.ActionCount - 1 do begin
155 if ActionList.Actions[i].Name = ActionName then begin
156 Result := TCustomAction(ActionList.Actions[i]);
157 Exit;
158 end;
159 end;
160 Result := nil;
161 end;
162
163 function checkActionName(Section: string ; ActionName: string): Boolean;
164 var
165 i : Integer;
166 begin
167 Result := False;
168 if (BROWSER_TAB = Section) then begin
169 for i :=0 to Length(ACK_BROWSER) - 1 do begin
170 if (ACK_BROWSER[i] = ActionName) then begin
171 Result := True;
172 Break;
173 end;
174 end;
175 end;
176 end;
177 end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26