source: dev/ProjectEditor/TextEditor_EventProc.cpp@ 87

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

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

File size: 6.9 KB
RevLine 
[3]1#include "Common.h"
2
3
4//IME関連のイベント
5void TextEditEvent_IME_StartComposition(HWND hwnd);
6BOOL TextEditEvent_IME_Composition(HWND hwnd,LPARAM lParam);
7
8//マウス関連のイベント
9void TextEditEvent_LButtonDown(HWND hwnd,POINT *pMousePos);
10void TextEditEvent_LButtonUp(HWND hwnd,POINT *pMousePos);
11void TextEditEvent_MouseMove(HWND hwnd,POINT *pMousePos);
12void TextEditEvent_LButtonDblClk(HWND hwnd,POINT *pMousePos);
13
14//キーボード関連のイベント
15void TextEditEvent_KeyUp(HWND hwnd,int nVirtualKey);
16void TextEditEvent_Char(HWND hwnd,int nVirtualKey);
17void TextEditEvent_KeyDown(HWND hwnd,int nVirtualKey,int lKeyData);
18
19
20
21HFONT hFont_TextEdit,hFont_HyperLink_TextEdit;
22int font_width,font_height;
23
24//改行時のキャレットちらつき防止用
25int hide_caret_switch;
26
27LRESULT CALLBACK TextEditProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
28 extern HANDLE hHeap;
29 extern HWND hDocCombo;
30 extern MDIINFO MdiInfo[MAX_WNDNUM];
31 extern PROJECTINFO ProjectInfo;
32 static DWORD dwAutoScroll;
33 extern COMPLEMENT_WINDOW_INFO ComplementWndInfo;
34 int i,WndNum;
35 SCROLLINFO si;
36 RECT rect;
37 POINT pos;
38
39 switch(message){
40 case WM_MDIACTIVATE:
41 if(!lParam) return 0;
42 i=GetWndNum((HWND)lParam);
43 if(i==-1) return 0; //ウィンドウが初期状態の場合
44
45 i=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[i].title);
46 SendMessage(hDocCombo,CB_SETCURSEL,i,0);
47 SetStatusText(NULL);
48 ResetState_EditMenu();
49 return 0;
50
51
52
53 ///////////////////////
54 // IME関連のイベント
55 ///////////////////////
56
57 case WM_IME_STARTCOMPOSITION:
58 TextEditEvent_IME_StartComposition(hwnd);
59 //デフォルト処理を行う
60 break;
61 case WM_IME_CHAR:
62 //デフォルト処理を行わない(WM_CHARを呼び出さないため)
63 return 0;
64 case WM_IME_COMPOSITION:
65 if(!TextEditEvent_IME_Composition(hwnd,lParam)) return 0;
66
67 //デフォルト処理を行う
68 break;
69
70
71
72 //////////////////////////
73 // マウス関連のイベント
74 //////////////////////////
75
76 case WM_LBUTTONDOWN:
77 pos.x=LOWORD(lParam);
78 pos.y=HIWORD(lParam);
79 TextEditEvent_LButtonDown(hwnd,&pos);
80 return 0;
81 case WM_LBUTTONUP:
82 pos.x=LOWORD(lParam);
83 pos.y=HIWORD(lParam);
84 TextEditEvent_LButtonUp(hwnd,&pos);
85 return 0;
86 case WM_MOUSEMOVE:
87 pos.x=LOWORD(lParam);
88 pos.y=HIWORD(lParam);
89 TextEditEvent_MouseMove(hwnd,&pos);
90 return 0;
91 case WM_LBUTTONDBLCLK:
92 pos.x=LOWORD(lParam);
93 pos.y=HIWORD(lParam);
94 TextEditEvent_LButtonDblClk(hwnd,&pos);
95 return 0;
96 case WM_RBUTTONUP:
97 pos.x=LOWORD(lParam);
98 pos.y=HIWORD(lParam);
99 ClientToScreen(hwnd,&pos);
100
101 //ポップアップメニューを表示
102 extern HMENU hEditMenu;
103 TrackPopupMenu(hEditMenu,TPM_LEFTALIGN|TPM_RIGHTBUTTON,pos.x,pos.y,0,hOwner,NULL);
104 return 0;
105
106
107
108 //////////////////////////////
109 // キーボード関係のイベント
110 //////////////////////////////
111
112 case WM_KEYUP:
113 TextEditEvent_KeyUp(hwnd,wParam);
114 return 0;
115 case WM_CHAR:
116 TextEditEvent_Char(hwnd,wParam);
117 return 0;
118 case WM_KEYDOWN:
119 TextEditEvent_KeyDown(hwnd,wParam,lParam);
120 return 0;
121
122
123
124 case WM_PAINT:
125 PAINTSTRUCT ps;
126 HDC hdc;
127
128 WndNum=GetWndNum(GetParent(hwnd));
129 if(WndNum==-1) return 0;
130
131 hdc=BeginPaint(hwnd,&ps);
132 TextEdit_DrawBuffer(hdc,WndNum);
133 EndPaint(hwnd,&ps);
134 return 0;
135 case WM_SETFOCUS:
136 WndNum=GetWndNum(GetParent(hwnd));
137 if(WndNum==-1) return 0;
138
139 //線型キャレットを作成
140 CreateCaret(hwnd,NULL,1,font_height);
141
142 //キャレットポジションを設定
143 ResetCaretPos(WndNum);
144
145 //キャレットを表示(改行の処理中のキャレットちらつきを防止の考慮に注意)
146 if(hide_caret_switch==0) ShowCaret(hwnd);
147 return 0;
148 case WM_RESETCARETPOS:
149 WndNum=GetWndNum(GetParent(hwnd));
150 ResetCaretPos(WndNum);
151 return 0;
152 case WM_KILLFOCUS:
153 HideCaret(hwnd);
154 DestroyCaret();
155 return 0;
156 case WM_MOUSEWHEEL:
157 int zDelta;
158 zDelta= (short) HIWORD(wParam);
159
160 WndNum=GetWndNum(GetParent(hwnd));
161 si.cbSize=sizeof(SCROLLINFO);
162 si.fMask=SIF_POS|SIF_PAGE|SIF_RANGE;
163 GetScrollInfo(hwnd,SB_VERT,&si);
164
165 i=0;
166 if(zDelta>=120){
167 //上へスクロール
168 i=-3;
169 }
170 else if(zDelta<=-120){
171 //下へスクロール
172 i=3;
173 }
174
175 if(i){
176 GetClientRect(hwnd,&rect);
177 i=max(-si.nPos,min(i,si.nMax-(rect.bottom/font_height-2)-si.nPos));
178 if(i!=0){
179 si.nPos+=i;
180 SetScrollInfo(hwnd,SB_VERT,&si,1);
181
182 InvalidateRect(hwnd,NULL,0);
183 }
184 ResetCaretPos(WndNum);
185 }
186 return 0;
187 case WM_SIZE:
188 WndNum=GetWndNum(GetParent(hwnd));
189 if(WndNum==-1) return 0;
190 InvalidateRect(hwnd,NULL,0);
191 return 0;
192 case WM_VSCROLL:
193 WndNum=GetWndNum(GetParent(hwnd));
194 si.cbSize=sizeof(SCROLLINFO);
195 si.fMask=SIF_POS|SIF_PAGE|SIF_RANGE;
196 GetScrollInfo(hwnd,SB_VERT,&si);
197 if(LOWORD(wParam)==SB_LINEUP) i=-1;
198 else if(LOWORD(wParam)==SB_LINEDOWN) i=1;
199 else if(LOWORD(wParam)==SB_PAGEUP) i=-(signed int)si.nPage;
200 else if(LOWORD(wParam)==SB_PAGEDOWN) i=si.nPage;
201 else if(LOWORD(wParam)==SB_THUMBTRACK) i=HIWORD(wParam)-si.nPos;
202 else i=0;
203 GetClientRect(hwnd,&rect);
204 i=max(-si.nPos,min(i,si.nMax-(rect.bottom/font_height-2)-si.nPos));
205 if(i!=0){
206 si.nPos+=i;
207 SetScrollInfo(hwnd,SB_VERT,&si,1);
208
209 InvalidateRect(hwnd,NULL,0);
210 }
211 ResetCaretPos(WndNum);
212 return 0;
213 case WM_HSCROLL:
214 WndNum=GetWndNum(GetParent(hwnd));
215 si.cbSize=sizeof(SCROLLINFO);
216 si.fMask=SIF_POS|SIF_PAGE|SIF_RANGE;
217 GetScrollInfo(hwnd,SB_HORZ,&si);
218 if(LOWORD(wParam)==SB_LINEUP) i=-1;
219 else if(LOWORD(wParam)==SB_LINEDOWN) i=1;
220 else if(LOWORD(wParam)==SB_PAGEUP) i=-(signed int)si.nPage;
221 else if(LOWORD(wParam)==SB_PAGEDOWN) i=si.nPage;
222 else if(LOWORD(wParam)==SB_THUMBTRACK) i=HIWORD(wParam)-si.nPos;
223 else i=0;
224
225 GetClientRect(hwnd,&rect);
226
227 int iControlTabSpace;
[24]228 iControlTabSpace=MdiInfo[WndNum].pMdiTextEdit->iWidth_ControlTabSpace;
[3]229
230 i=max(-si.nPos,min(i,si.nMax-((rect.right-iControlTabSpace)/font_width)-si.nPos));
231 if(i!=0){
232 si.nPos+=i;
233 SetScrollInfo(hwnd,SB_HORZ,&si,1);
234
235 InvalidateRect(hwnd,NULL,0);
236 }
237 ResetCaretPos(WndNum);
238
239 //ルーラーを再描画
[24]240 InvalidateRect(MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->hRulerWnd,NULL,0);
241 UpdateWindow(MdiInfo[WndNum].pMdiTextEdit->pobj_Ruler->hRulerWnd);
[3]242
243 return 0;
244 case WM_CLOSE:
245 CloseDocWindow(GetWndNum(hwnd));
246 pobj_nv->bMDIZoomed=IsZoomed(hwnd);
247 i=DefMDIChildProc(hwnd,message,wParam,lParam);
248
249 //メニュー状態を設定
250 ResetState_DocMenu();
251
252 return i;
253
254
255
256 case WM_SEARCH_TAB_CREATE:
257 HWND hOneTabWnd;
258 hOneTabWnd=CreateWindowEx(0,"OneTab","OneTab",
259 WS_CHILD|WS_VISIBLE,
260 0,0,0,0,
[24]261 MdiInfo[wParam].pMdiTextEdit->pobj_WebResult->hwnd,0,hInst,0);
[3]262
263 SetWindowLong(hOneTabWnd,GWL_USERDATA,(long)lParam);
264
265 return (LRESULT)hOneTabWnd;
266 case WM_SEARCH_TAB_CLOSE:
267 DestroyWindow((HWND)lParam);
268 return 0;
269 }
270 return DefMDIChildProc(hwnd,message,wParam,lParam);
271}
Note: See TracBrowser for help on using the repository browser.