source: dev/ProjectEditor/rebar.cpp@ 57

Last change on this file since 57 was 24, checked in by dai_9181, 18 years ago

保存されていないドキュメントのタブに(*)をつける機能に対応。
MDITEXTEDITINFOをCMdiTextEditに変更。今後、オブジェクト指向化を進める。

File size: 9.0 KB
Line 
1#include "Common.h"
2
3
4/////////////////////////////////////////////////////////////
5// Note. レバーコントロールを新たに追加する場合は、
6// "レバー追加" で検索をかけ、適切なコードを埋め込む
7/////////////////////////////////////////////////////////////
8
9
10CDBRebarBand::CDBRebarBand(){
11 iMaxBandNum=0;
12}
13CDBRebarBand::~CDBRebarBand(){}
14
15void CDBRebarBand::add(int band_id,AddBandProc add_proc){
16 BandId[iMaxBandNum]=band_id;
17 pAddProc[iMaxBandNum]=add_proc;
18 iMaxBandNum++;
19}
20
21HWND CDBRebarBand::call_add(int band_id,int num,char *lpszText){
22 int i;
23 for(i=0;i<iMaxBandNum;i++){
24 if(BandId[i]==band_id) break;
25 }
26 if(i==iMaxBandNum) return 0;
27
28 return pAddProc[i](hRebar,num,lpszText);
29}
30
31
32HWND AddDocCombo(HWND hRebar,int num,char *lpszText);
33HWND AddStandardToolbar(HWND hRebar,int num,char *lpszText);
34HWND AddReleaseToolbar(HWND hRebar,int num,char *lpszText);
35HWND AddDebuggerToolbar(HWND hRebar,int num,char *lpszText);
36HWND AddBand_SelectCompiler(HWND hRebar,int num,char *lpszText);
37HWND AddBand_WebSearch(HWND hRebar,int num,char *lpszText);
38
39
40CMainRebar *pobj_Rebar=0;
41
42
43void CMainRebar::SetupRebar(HWND hwnd){
44 int i;
45
46 //レバーコントロールを生成
47 hRebar=CreateWindowEx(WS_EX_TOOLWINDOW,REBARCLASSNAME,NULL,
48 WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_BORDER|WS_VISIBLE|
49 CCS_ADJUSTABLE|RBS_BANDBORDERS|RBS_DBLCLKTOGGLE ,
50 0,0,0,0,hwnd,NULL,hInst,NULL);
51
52 pobj_DBRebarBand->hRebar=hRebar;
53
54 REBARINFO RebarInfo;
55 ZeroMemory(&RebarInfo,sizeof(RebarInfo));
56 RebarInfo.cbSize=sizeof(REBARINFO);
57 SendMessage(hRebar,RB_SETBARINFO,0,(long)&RebarInfo);
58
59 //バンドを挿入
60 REBARBANDINFO RebarBand;
61 ZeroMemory(&RebarBand,sizeof(REBARBANDINFO));
62 RebarBand.cbSize=sizeof(REBARBANDINFO);
63 RebarBand.fMask=RBBIM_TEXT|RBBIM_STYLE|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_SIZE|RBBIM_ID;
64 RebarBand.cxMinChild=23;
65 RebarBand.cyMinChild=22;
66 if(pobj_nv->bNoGripper) RebarBand.fStyle=RBBS_CHILDEDGE|RBBS_NOGRIPPER;
67 else RebarBand.fStyle=RBBS_CHILDEDGE;
68 for(i=0;i<MAX_REBARBANDS;i++){
69 if(pobj_nv->SaveRebar[i].RebarID==0) break;
70
71 //レバー上にのせる子ウィンドウを生成
72 char szText[255];
73 HWND hChild;
74 hChild=pobj_DBRebarBand->call_add(pobj_nv->SaveRebar[i].RebarID,i,szText);
75
76 //レバーバンドを追加
77 RebarBand.lpText=szText;
78 RebarBand.hwndChild=hChild;
79 RebarBand.cx=pobj_nv->SaveRebar[i].RebarLength;
80 RebarBand.wID=pobj_nv->SaveRebar[i].RebarID;
81 RebarBand.fStyle|=pobj_nv->SaveRebar[i].IsBandBreak;
82 SendMessage(hRebar,RB_INSERTBAND,-1,(LPARAM)&RebarBand);
83 RebarBand.fStyle^=pobj_nv->SaveRebar[i].IsBandBreak;
84 }
85}
86
87CMainRebar::CMainRebar(HWND hwnd_parent){
88 hParent=hwnd_parent;
89
90 pobj_DBRebarBand=new CDBRebarBand();
91
92 pobj_DBRebarBand->add(
93 ID_DOCCOMBO,
94 AddDocCombo);
95
96 pobj_DBRebarBand->add(
97 ID_STANDARDTOOLBAR,
98 AddStandardToolbar);
99
100 pobj_DBRebarBand->add(
101 ID_RELEASETOOLBAR,
102 AddReleaseToolbar);
103
104 pobj_DBRebarBand->add(
105 ID_DEBUGGERTOOLBAR,
106 AddDebuggerToolbar);
107
108 pobj_DBRebarBand->add(
109 ID_SELECTCOMPILERCOMBO,
110 AddBand_SelectCompiler);
111
112 pobj_DBRebarBand->add(
113 ID_WEB_SEARCH,
114 AddBand_WebSearch);
115
116 //
117 //レバーバンドを追加する場合はこの行を編集する(レバー追加)
118 //
119
120
121 SetupRebar(hParent);
122}
123CMainRebar::~CMainRebar(){
124 SaveRebarState();
125 DestroyWindow(hRebar);
126
127 delete pobj_DBRebarBand;
128 pobj_DBRebarBand=0;
129}
130
131void CMainRebar::ResetInitRebar(){
132 DestroyWindow(hRebar);
133 ResetRebarData();
134 SetupRebar(hParent);
135}
136void CMainRebar::ResetRebar(){
137 SaveRebarState();
138 DestroyWindow(hRebar);
139 SetupRebar(hParent);
140}
141
142void CMainRebar::SaveRebarState(void){
143 int i,BandNum;
144 REBARBANDINFO BandInfo;
145
146 ZeroMemory(&BandInfo,sizeof(REBARBANDINFO));
147 BandInfo.cbSize=sizeof(REBARBANDINFO);
148 BandInfo.fMask=RBBIM_TEXT|RBBIM_STYLE|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_SIZE|RBBIM_ID;
149 BandNum=SendMessage(hRebar,RB_GETBANDCOUNT,0,0);
150 for(i=0;i<BandNum;i++){
151 SendMessage(hRebar,RB_GETBANDINFO,i,(long)&BandInfo);
152 if(BandInfo.fStyle&RBBS_BREAK) pobj_nv->SaveRebar[i].IsBandBreak=RBBS_BREAK;
153 else pobj_nv->SaveRebar[i].IsBandBreak=0;
154 pobj_nv->SaveRebar[i].RebarID=BandInfo.wID;
155 pobj_nv->SaveRebar[i].RebarLength=BandInfo.cx;
156 }
157}
158
159void CMainRebar::ChangeRebarBand(int BandID){
160 int i;
161 REBARBANDINFO RebarBand;
162
163 //ツールバーが固定されている場合は解除する
164 if(pobj_nv->bNoGripper) SendMessage(hOwner,WM_COMMAND,IDM_NOGRIPPER,0);
165
166 SAVEREBAR *psr;
167 psr=pobj_nv->SaveRebar;
168
169 for(i=0;i<MAX_REBARBANDS;i++){
170 if(psr[i].RebarID==0) break;
171 if(psr[i].RebarID==BandID){
172 SendMessage(hRebar,RB_DELETEBAND,SendMessage(hRebar,RB_IDTOINDEX,BandID,0),0);
173 memcpy(&psr[i],&psr[i+1],(MAX_REBARBANDS-i-1)*sizeof(SAVEREBAR));
174 psr[MAX_REBARBANDS-1].RebarID=0;
175 if(psr[0].RebarID==0){
176 DestroyWindow(hRebar);
177 SetupRebar(hOwner);
178
179 //メニュー状態を設定
180 ResetState_DocMenu();
181
182 ResizeOwnerWnd();
183 }
184 return;
185 }
186 }
187 if(i>=MAX_REBARBANDS) return;
188 psr[i].IsBandBreak=1;
189 psr[i].RebarID=BandID;
190 psr[i].RebarLength=0;
191 ZeroMemory(&RebarBand,sizeof(REBARBANDINFO));
192 RebarBand.cbSize=sizeof(REBARBANDINFO);
193 RebarBand.fMask=RBBIM_TEXT|RBBIM_STYLE|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_SIZE|RBBIM_ID;
194 RebarBand.fStyle=RBBS_CHILDEDGE;
195 RebarBand.cxMinChild=0;
196 RebarBand.cyMinChild=22;
197
198 //レバー上にのせる子ウィンドウを生成
199 char szText[255];
200 HWND hChild;
201 hChild=pobj_DBRebarBand->call_add(pobj_nv->SaveRebar[i].RebarID,i,szText);
202
203 //レバーバンドを追加
204 RebarBand.lpText=szText;
205 RebarBand.hwndChild=hChild;
206 RebarBand.cx=pobj_nv->SaveRebar[i].RebarLength;
207 RebarBand.wID=pobj_nv->SaveRebar[i].RebarID;
208 RebarBand.fStyle|=pobj_nv->SaveRebar[i].IsBandBreak;
209 SendMessage(hRebar,RB_INSERTBAND,-1,(LPARAM)&RebarBand);
210 RebarBand.fStyle^=pobj_nv->SaveRebar[i].IsBandBreak;
211
212 //メニュー状態を設定
213 ResetState_DocMenu();
214}
215
216void CMainRebar::menu_popup(HWND hwnd,int PosX,int PosY){
217 //レバーコントロールの表示設定メニューを表示
218 int i;
219 POINT MousePos;
220 MENUITEMINFO MenuItemInfo;
221
222 //メニューのチェック項目をセット
223 extern HMENU hRebarMenu;
224 MenuItemInfo.cbSize=sizeof(MENUITEMINFO);
225 MenuItemInfo.fMask=MIIM_STATE;
226 MenuItemInfo.fState=MFS_UNCHECKED;
227 SetMenuItemInfo(hRebarMenu,IDM_DOCSELECTBAND,0,&MenuItemInfo);
228 SetMenuItemInfo(hRebarMenu,IDM_STANDARDBAND,0,&MenuItemInfo);
229 SetMenuItemInfo(hRebarMenu,IDM_BANDMENU_WEB_SEARCH,0,&MenuItemInfo);
230#ifndef THETEXT
231 //ProjectEditorのみ
232 SetMenuItemInfo(hRebarMenu,IDM_RELEASEBAND,0,&MenuItemInfo);
233 SetMenuItemInfo(hRebarMenu,IDM_DEBUGBAND,0,&MenuItemInfo);
234 SetMenuItemInfo(hRebarMenu,IDM_SELECTCOMPILERBAND,0,&MenuItemInfo);
235#endif
236
237
238 MenuItemInfo.fState=MFS_CHECKED;
239 for(i=0;i<MAX_REBARBANDS;i++){
240 if(pobj_nv->SaveRebar[i].RebarID==0) break;
241
242 if(pobj_nv->SaveRebar[i].RebarID==ID_DOCCOMBO)
243 SetMenuItemInfo(hRebarMenu,IDM_DOCSELECTBAND,0,&MenuItemInfo);
244
245 if(pobj_nv->SaveRebar[i].RebarID==ID_STANDARDTOOLBAR)
246 SetMenuItemInfo(hRebarMenu,IDM_STANDARDBAND,0,&MenuItemInfo);
247
248 if(pobj_nv->SaveRebar[i].RebarID==ID_WEB_SEARCH)
249 SetMenuItemInfo(hRebarMenu,IDM_BANDMENU_WEB_SEARCH,0,&MenuItemInfo);
250
251#ifndef THETEXT
252 //ProjectEditorのみ
253 if(pobj_nv->SaveRebar[i].RebarID==ID_RELEASETOOLBAR)
254 SetMenuItemInfo(hRebarMenu,IDM_RELEASEBAND,0,&MenuItemInfo);
255
256 if(pobj_nv->SaveRebar[i].RebarID==ID_DEBUGGERTOOLBAR)
257 SetMenuItemInfo(hRebarMenu,IDM_DEBUGBAND,0,&MenuItemInfo);
258
259 if(pobj_nv->SaveRebar[i].RebarID==ID_SELECTCOMPILERCOMBO)
260 SetMenuItemInfo(hRebarMenu,IDM_SELECTCOMPILERBAND,0,&MenuItemInfo);
261#endif
262
263 }
264 if(pobj_nv->bNoGripper) MenuItemInfo.fState=MFS_CHECKED;
265 else MenuItemInfo.fState=MFS_UNCHECKED;
266 SetMenuItemInfo(hRebarMenu,IDM_NOGRIPPER,0,&MenuItemInfo);
267
268 //ポップアップメニューを表示
269 MousePos.x=PosX;
270 MousePos.y=PosY;
271 ClientToScreen(hwnd,&MousePos);
272 TrackPopupMenu(hRebarMenu,TPM_LEFTALIGN|TPM_RIGHTBUTTON,MousePos.x,MousePos.y,0,hOwner,NULL);
273}
274
275
276
277
278
279
280WNDPROC OldDocComboProc;
281WNDPROC OldStandardToolbarProc;
282WNDPROC OldDebuggerToolbarProc;
283WNDPROC OldSelectCompilerComboProc;
284WNDPROC OldWebSearchProc,OldWebSearchEditProc;
285
286void ResetRebarData(void){
287 SAVEREBAR *psr;
288 psr=pobj_nv->SaveRebar;
289 int num=0;
290
291#ifdef THETEXT
292
293 //スタンダードツールバー
294 psr[num].RebarID=ID_STANDARDTOOLBAR;
295 psr[num].RebarLength=BMPNUM_STANDARDTOOLBAR*23+SEPNUM_STANDARDTOOLBAR*8+15;
296 psr[num].IsBandBreak=0;
297 num++;
298
299 //WebSearchコンボボックス
300 psr[num].RebarID=ID_WEB_SEARCH;
301 psr[num].RebarLength=100;
302 psr[num].IsBandBreak=0;
303 num++;
304#else
305
306 //スタンダードツールバー
307 psr[num].RebarID=ID_STANDARDTOOLBAR;
308 psr[num].RebarLength=BMPNUM_STANDARDTOOLBAR*23+SEPNUM_STANDARDTOOLBAR*8+15;
309 psr[num].IsBandBreak=0;
310 num++;
311
312 //プラットフォーム選択ツールバー
313 psr[num].RebarID=ID_SELECTCOMPILERCOMBO;
314 psr[num].RebarLength=100;
315 psr[num].IsBandBreak=0;
316 num++;
317
318 //デバッガツールバー
319 psr[num].RebarID=ID_DEBUGGERTOOLBAR;
320 psr[num].RebarLength=BMPNUM_DEBUGGERTOOLBAR*23+SEPNUM_DEBUGGERTOOLBAR*8+15;
321 psr[num].IsBandBreak=0;
322 num++;
323
324 //リリースビルドツールバー
325 psr[num].RebarID=ID_RELEASETOOLBAR;
326 psr[num].RebarLength=2*23+15;
327 psr[num].IsBandBreak=0;
328 num++;
329#endif
330
331
332 psr[num].RebarID=0;
333
334 pobj_nv->bNoGripper=1;
335}
Note: See TracBrowser for help on using the repository browser.