OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../include/pdfwindow/PDFWindow.h" | 7 #include "../../include/pdfwindow/PDFWindow.h" |
8 #include "../../include/pdfwindow/PWL_Wnd.h" | 8 #include "../../include/pdfwindow/PWL_Wnd.h" |
9 #include "../../include/pdfwindow/PWL_Utils.h" | 9 #include "../../include/pdfwindow/PWL_Utils.h" |
10 #include "../../include/pdfwindow/PWL_ScrollBar.h" | 10 #include "../../include/pdfwindow/PWL_ScrollBar.h" |
11 | 11 |
12 /* -------------------------- CPWL_Timer -------------------------- */ | 12 /* -------------------------- CPWL_Timer -------------------------- */ |
13 | 13 |
14 static CFX_MapPtrTemplate<FX_INT32, CPWL_Timer*>» g_TimeMap; | 14 static CFX_MapPtrTemplate<FX_INT32, CPWL_Timer*> g_TimeMap; |
15 | 15 |
16 CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemH
andler) : | 16 CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, |
17 » m_nTimerID(0), | 17 IFX_SystemHandler* pSystemHandler) |
18 » m_pAttached(pAttached), | 18 : m_nTimerID(0), m_pAttached(pAttached), m_pSystemHandler(pSystemHandler) { |
19 » m_pSystemHandler(pSystemHandler) | 19 ASSERT(m_pAttached != NULL); |
20 { | 20 ASSERT(m_pSystemHandler != NULL); |
21 » ASSERT(m_pAttached != NULL); | 21 } |
22 » ASSERT(m_pSystemHandler != NULL); | 22 |
23 } | 23 CPWL_Timer::~CPWL_Timer() { |
24 | 24 KillPWLTimer(); |
25 CPWL_Timer::~CPWL_Timer() | 25 } |
26 { | 26 |
27 » KillPWLTimer(); | 27 FX_INT32 CPWL_Timer::SetPWLTimer(FX_INT32 nElapse) { |
28 } | 28 if (m_nTimerID != 0) |
29 | 29 KillPWLTimer(); |
30 FX_INT32 CPWL_Timer::SetPWLTimer(FX_INT32 nElapse) | 30 m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc); |
31 {» | 31 g_TimeMap.SetAt(m_nTimerID, this); |
32 » if (m_nTimerID != 0) KillPWLTimer(); | 32 return m_nTimerID; |
33 » m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc); | 33 } |
34 » g_TimeMap.SetAt(m_nTimerID, this); | 34 |
35 » return m_nTimerID; | 35 void CPWL_Timer::KillPWLTimer() { |
36 } | 36 if (m_nTimerID != 0) { |
37 | 37 m_pSystemHandler->KillTimer(m_nTimerID); |
38 void CPWL_Timer::KillPWLTimer() | 38 g_TimeMap.RemoveKey(m_nTimerID); |
39 { | 39 m_nTimerID = 0; |
40 » if (m_nTimerID != 0) | 40 } |
41 » { | 41 } |
42 » » m_pSystemHandler->KillTimer(m_nTimerID); | 42 |
43 » » g_TimeMap.RemoveKey(m_nTimerID); | 43 void CPWL_Timer::TimerProc(FX_INT32 idEvent) { |
44 » » m_nTimerID = 0; | 44 CPWL_Timer* pTimer = NULL; |
45 » } | 45 if (g_TimeMap.Lookup(idEvent, pTimer)) { |
46 } | 46 if (pTimer) { |
47 | 47 if (pTimer->m_pAttached) |
48 void CPWL_Timer::TimerProc(FX_INT32 idEvent) | 48 pTimer->m_pAttached->TimerProc(); |
49 { | 49 } |
50 » CPWL_Timer* pTimer = NULL; | 50 } |
51 » if (g_TimeMap.Lookup(idEvent, pTimer)) | |
52 » { | |
53 » » if (pTimer) | |
54 » » {» » » | |
55 » » » if (pTimer->m_pAttached) | |
56 » » » » pTimer->m_pAttached->TimerProc(); | |
57 » » } | |
58 » } | |
59 } | 51 } |
60 | 52 |
61 /* -------------------------- CPWL_TimerHandler -------------------------- */ | 53 /* -------------------------- CPWL_TimerHandler -------------------------- */ |
62 | 54 |
63 CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL) | 55 CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL) { |
64 { | 56 } |
65 } | 57 |
66 | 58 CPWL_TimerHandler::~CPWL_TimerHandler() { |
67 CPWL_TimerHandler::~CPWL_TimerHandler() | 59 if (m_pTimer) |
68 { | 60 delete m_pTimer; |
69 » if (m_pTimer) delete m_pTimer; | 61 } |
70 } | 62 |
71 | 63 void CPWL_TimerHandler::BeginTimer(FX_INT32 nElapse) { |
72 void CPWL_TimerHandler::BeginTimer(FX_INT32 nElapse) | 64 if (!m_pTimer) |
73 { | 65 m_pTimer = new CPWL_Timer(this, GetSystemHandler()); |
74 » if (!m_pTimer) | 66 |
75 » » m_pTimer = new CPWL_Timer(this, GetSystemHandler()); | 67 if (m_pTimer) |
76 | 68 m_pTimer->SetPWLTimer(nElapse); |
77 » if (m_pTimer) | 69 } |
78 » » m_pTimer->SetPWLTimer(nElapse); | 70 |
79 } | 71 void CPWL_TimerHandler::EndTimer() { |
80 | 72 if (m_pTimer) |
81 void CPWL_TimerHandler::EndTimer() | 73 m_pTimer->KillPWLTimer(); |
82 { | 74 } |
83 » if (m_pTimer) | 75 |
84 » » m_pTimer->KillPWLTimer(); | 76 void CPWL_TimerHandler::TimerProc() { |
85 } | |
86 | |
87 void CPWL_TimerHandler::TimerProc() | |
88 { | |
89 } | 77 } |
90 | 78 |
91 /* --------------------------- CPWL_MsgControl ---------------------------- */ | 79 /* --------------------------- CPWL_MsgControl ---------------------------- */ |
92 | 80 |
93 class CPWL_MsgControl | 81 class CPWL_MsgControl { |
94 { | 82 friend class CPWL_Wnd; |
95 » friend class CPWL_Wnd; | 83 |
96 | 84 public: |
97 public: | 85 CPWL_MsgControl(CPWL_Wnd* pWnd) { |
98 » CPWL_MsgControl(CPWL_Wnd * pWnd) | 86 //» » PWL_TRACE("new CPWL_MsgControl\n"); |
99 » { | 87 m_pCreatedWnd = pWnd; |
100 //» » PWL_TRACE("new CPWL_MsgControl\n"); | 88 Default(); |
101 » » m_pCreatedWnd = pWnd; | 89 } |
102 » » Default(); | 90 |
103 » } | 91 ~CPWL_MsgControl() { |
104 | 92 //» » PWL_TRACE("~CPWL_MsgControl\n"); |
105 » ~CPWL_MsgControl() | 93 Default(); |
106 » { | 94 } |
107 //» » PWL_TRACE("~CPWL_MsgControl\n"); | 95 |
108 » » Default(); | 96 void Default() { |
109 » } | 97 m_aMousePath.RemoveAll(); |
110 | 98 m_aKeyboardPath.RemoveAll(); |
111 » void Default() | 99 m_pMainMouseWnd = NULL; |
112 » { | 100 m_pMainKeyboardWnd = NULL; |
113 » » m_aMousePath.RemoveAll(); | 101 } |
114 » » m_aKeyboardPath.RemoveAll(); | 102 |
115 » » m_pMainMouseWnd = NULL; | 103 FX_BOOL IsWndCreated(const CPWL_Wnd* pWnd) const { |
116 » » m_pMainKeyboardWnd = NULL; | 104 return m_pCreatedWnd == pWnd; |
117 » } | 105 } |
118 | 106 |
119 » FX_BOOL IsWndCreated(const CPWL_Wnd * pWnd) const | 107 FX_BOOL IsMainCaptureMouse(const CPWL_Wnd* pWnd) const { |
120 » { | 108 return pWnd == m_pMainMouseWnd; |
121 » » return m_pCreatedWnd == pWnd; | 109 } |
122 » } | 110 |
123 | 111 FX_BOOL IsWndCaptureMouse(const CPWL_Wnd* pWnd) const { |
124 » FX_BOOL IsMainCaptureMouse(const CPWL_Wnd * pWnd) const | 112 if (pWnd) |
125 » { | 113 for (FX_INT32 i = 0, sz = m_aMousePath.GetSize(); i < sz; i++) |
126 » » return pWnd == m_pMainMouseWnd; | 114 if (m_aMousePath.GetAt(i) == pWnd) |
127 » } | 115 return TRUE; |
128 | 116 |
129 » FX_BOOL IsWndCaptureMouse(const CPWL_Wnd * pWnd) const | 117 return FALSE; |
130 » { | 118 } |
131 » » if (pWnd) | 119 |
132 » » » for( FX_INT32 i=0,sz=m_aMousePath.GetSize(); i<sz; i++) | 120 FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd* pWnd) const { |
133 » » » » if (m_aMousePath.GetAt(i) == pWnd) | 121 return pWnd == m_pMainKeyboardWnd; |
134 » » » » » return TRUE; | 122 } |
135 | 123 |
136 » » return FALSE; | 124 FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const { |
137 » } | 125 if (pWnd) |
138 | 126 for (FX_INT32 i = 0, sz = m_aKeyboardPath.GetSize(); i < sz; i++) |
139 » FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd * pWnd) const | 127 if (m_aKeyboardPath.GetAt(i) == pWnd) |
140 » { | 128 return TRUE; |
141 » » return pWnd == m_pMainKeyboardWnd; | 129 |
142 » } | 130 return FALSE; |
143 | 131 } |
144 | 132 |
145 » FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const | 133 void SetFocus(CPWL_Wnd* pWnd) { |
146 » { | 134 m_aKeyboardPath.RemoveAll(); |
147 » » if (pWnd) | 135 |
148 » » » for( FX_INT32 i=0,sz=m_aKeyboardPath.GetSize(); i<sz; i+
+) | 136 if (pWnd) { |
149 » » » » if (m_aKeyboardPath.GetAt(i) == pWnd) | 137 m_pMainKeyboardWnd = pWnd; |
150 » » » » » return TRUE; | 138 |
151 » » | 139 CPWL_Wnd* pParent = pWnd; |
152 » » return FALSE; | 140 while (pParent) { |
153 » } | 141 m_aKeyboardPath.Add(pParent); |
154 | 142 pParent = pParent->GetParentWindow(); |
155 » void SetFocus(CPWL_Wnd * pWnd) | 143 } |
156 » { | 144 |
157 » » m_aKeyboardPath.RemoveAll(); | 145 pWnd->OnSetFocus(); |
158 | 146 } |
159 » » if (pWnd) | 147 } |
160 » » { | 148 |
161 » » » m_pMainKeyboardWnd = pWnd; | 149 void KillFocus() { |
162 | 150 if (m_aKeyboardPath.GetSize() > 0) |
163 » » » CPWL_Wnd * pParent = pWnd; | 151 if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0)) |
164 » » » while (pParent) | 152 pWnd->OnKillFocus(); |
165 » » » { | 153 |
166 » » » » m_aKeyboardPath.Add(pParent); | 154 m_pMainKeyboardWnd = NULL; |
167 » » » » pParent = pParent->GetParentWindow(); | 155 m_aKeyboardPath.RemoveAll(); |
168 » » » } | 156 } |
169 | 157 |
170 » » » pWnd->OnSetFocus(); | 158 void SetCapture(CPWL_Wnd* pWnd) { |
171 » » } | 159 m_aMousePath.RemoveAll(); |
172 » } | 160 |
173 | 161 if (pWnd) { |
174 » void KillFocus() | 162 m_pMainMouseWnd = pWnd; |
175 » { | 163 |
176 » » if (m_aKeyboardPath.GetSize() > 0) | 164 CPWL_Wnd* pParent = pWnd; |
177 » » » if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0)) | 165 while (pParent) { |
178 » » » » pWnd->OnKillFocus(); | 166 m_aMousePath.Add(pParent); |
179 | 167 pParent = pParent->GetParentWindow(); |
180 » » m_pMainKeyboardWnd = NULL; | 168 } |
181 » » m_aKeyboardPath.RemoveAll(); | 169 } |
182 » } | 170 } |
183 | 171 |
184 » void SetCapture(CPWL_Wnd * pWnd) | 172 void ReleaseCapture() { |
185 » { | 173 m_pMainMouseWnd = NULL; |
186 » » m_aMousePath.RemoveAll(); | 174 m_aMousePath.RemoveAll(); |
187 | 175 } |
188 » » if (pWnd) | 176 |
189 » » { | 177 private: |
190 » » » m_pMainMouseWnd = pWnd; | 178 CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath; |
191 | 179 CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath; |
192 » » » CPWL_Wnd * pParent = pWnd; | 180 CPWL_Wnd* m_pCreatedWnd; |
193 » » » while (pParent) | 181 CPWL_Wnd* m_pMainMouseWnd; |
194 » » » { | 182 CPWL_Wnd* m_pMainKeyboardWnd; |
195 » » » » m_aMousePath.Add(pParent); | |
196 » » » » pParent = pParent->GetParentWindow(); | |
197 » » » } | |
198 » » } | |
199 » } | |
200 | |
201 » void ReleaseCapture() | |
202 » { | |
203 » » m_pMainMouseWnd = NULL; | |
204 » » m_aMousePath.RemoveAll(); | |
205 » } | |
206 | |
207 private: | |
208 » CFX_ArrayTemplate<CPWL_Wnd*>» m_aMousePath; | |
209 » CFX_ArrayTemplate<CPWL_Wnd*>» m_aKeyboardPath; | |
210 » CPWL_Wnd*» » » » » » m_pCreatedWnd; | |
211 » CPWL_Wnd*» » » » » » m_pMainMouseWnd; | |
212 » CPWL_Wnd*» » » » » » m_pMainKeyboardW
nd; | |
213 }; | 183 }; |
214 | 184 |
215 /* --------------------------- CPWL_Wnd ---------------------------- */ | 185 /* --------------------------- CPWL_Wnd ---------------------------- */ |
216 | 186 |
217 CPWL_Wnd::CPWL_Wnd() : | 187 CPWL_Wnd::CPWL_Wnd() |
218 m_pVScrollBar(NULL), | 188 : m_pVScrollBar(NULL), |
219 m_rcWindow(), | 189 m_rcWindow(), |
220 m_rcClip(), | 190 m_rcClip(), |
221 m_bCreated(FALSE), | 191 m_bCreated(FALSE), |
222 m_bVisible(FALSE), | 192 m_bVisible(FALSE), |
223 m_bNotifying(FALSE), | 193 m_bNotifying(FALSE), |
224 m_bEnabled(TRUE) | 194 m_bEnabled(TRUE) { |
225 { | 195 } |
226 } | 196 |
227 | 197 CPWL_Wnd::~CPWL_Wnd() { |
228 CPWL_Wnd::~CPWL_Wnd() | 198 ASSERT(m_bCreated == FALSE); |
229 { | 199 } |
230 ASSERT(m_bCreated == FALSE); | 200 |
231 } | 201 CFX_ByteString CPWL_Wnd::GetClassName() const { |
232 | 202 return "CPWL_Wnd"; |
233 CFX_ByteString CPWL_Wnd::GetClassName() const | 203 } |
234 { | 204 |
235 return "CPWL_Wnd"; | 205 void CPWL_Wnd::Create(const PWL_CREATEPARAM& cp) { |
236 } | 206 if (!IsValid()) { |
237 | 207 m_sPrivateParam = cp; |
238 void CPWL_Wnd::Create(const PWL_CREATEPARAM & cp) | 208 |
239 { | 209 OnCreate(m_sPrivateParam); |
240 if (!IsValid()) | 210 |
241 { | 211 m_sPrivateParam.rcRectWnd.Normalize(); |
242 m_sPrivateParam = cp; | 212 m_rcWindow = m_sPrivateParam.rcRectWnd; |
243 | 213 m_rcClip = CPWL_Utils::InflateRect(m_rcWindow, 1.0f); |
244 OnCreate(m_sPrivateParam); | 214 |
245 | 215 CreateMsgControl(); |
246 m_sPrivateParam.rcRectWnd.Normalize(); | 216 |
247 m_rcWindow = m_sPrivateParam.rcRectWnd; | 217 if (m_sPrivateParam.pParentWnd) |
248 m_rcClip = CPWL_Utils::InflateRect(m_rcWindow,1.0f); | 218 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD); |
249 | 219 |
250 CreateMsgControl(); | 220 PWL_CREATEPARAM ccp = m_sPrivateParam; |
251 | 221 |
252 if (m_sPrivateParam.pParentWnd) | 222 ccp.dwFlags &= 0xFFFF0000L; // remove sub styles |
253 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD)
; | 223 ccp.mtChild = CPDF_Matrix(1, 0, 0, 1, 0, 0); |
254 | 224 |
255 PWL_CREATEPARAM ccp = m_sPrivateParam; | 225 CreateScrollBar(ccp); |
256 | 226 CreateChildWnd(ccp); |
257 ccp.dwFlags &= 0xFFFF0000L; //remove sub styles | 227 |
258 ccp.mtChild = CPDF_Matrix(1,0,0,1,0,0); | 228 m_bVisible = HasFlag(PWS_VISIBLE); |
259 | 229 |
260 CreateScrollBar(ccp); | 230 OnCreated(); |
261 CreateChildWnd(ccp); | 231 |
262 | 232 RePosChildWnd(); |
263 m_bVisible = HasFlag(PWS_VISIBLE); | 233 m_bCreated = TRUE; |
264 | 234 } |
265 OnCreated(); | 235 } |
266 | 236 |
267 RePosChildWnd(); | 237 void CPWL_Wnd::OnCreate(PWL_CREATEPARAM& cp) { |
268 m_bCreated = TRUE; | 238 } |
269 } | 239 |
270 } | 240 void CPWL_Wnd::OnCreated() { |
271 | 241 } |
272 void CPWL_Wnd::OnCreate(PWL_CREATEPARAM & cp) | 242 |
273 { | 243 void CPWL_Wnd::OnDestroy() { |
274 } | 244 } |
275 | 245 |
276 void CPWL_Wnd::OnCreated() | 246 void CPWL_Wnd::Destroy() { |
277 { | 247 KillFocus(); |
278 } | 248 |
279 | 249 OnDestroy(); |
280 void CPWL_Wnd::OnDestroy() | 250 |
281 { | 251 if (m_bCreated) { |
282 } | 252 for (FX_INT32 i = m_aChildren.GetSize() - 1; i >= 0; i--) { |
283 | 253 if (CPWL_Wnd* pChild = m_aChildren[i]) { |
284 void CPWL_Wnd::Destroy() | 254 pChild->Destroy(); |
285 { | 255 delete pChild; |
286 KillFocus(); | 256 pChild = NULL; |
287 | 257 } |
288 OnDestroy(); | 258 } |
289 | 259 |
290 if (m_bCreated) | 260 if (m_sPrivateParam.pParentWnd) |
291 { | 261 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD); |
292 for (FX_INT32 i = m_aChildren.GetSize()-1; i >= 0; i --) | 262 m_bCreated = FALSE; |
293 { | 263 } |
294 if (CPWL_Wnd * pChild = m_aChildren[i]) | 264 |
295 { | 265 DestroyMsgControl(); |
296 pChild->Destroy(); | 266 |
297 delete pChild; | 267 FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM)); |
298 pChild = NULL; | 268 m_aChildren.RemoveAll(); |
299 } | 269 m_pVScrollBar = NULL; |
300 } | 270 } |
301 | 271 |
302 if (m_sPrivateParam.pParentWnd) | 272 void CPWL_Wnd::Move(const CPDF_Rect& rcNew, FX_BOOL bReset, FX_BOOL bRefresh) { |
303 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHI
LD); | 273 if (IsValid()) { |
304 m_bCreated = FALSE; | 274 CPDF_Rect rcOld = this->GetWindowRect(); |
305 } | 275 |
306 | 276 m_rcWindow = rcNew; |
307 DestroyMsgControl(); | 277 m_rcWindow.Normalize(); |
308 | 278 // m_rcClip = CPWL_Utils::InflateRect(m_rcWindow,1.0f); //for special caret |
309 FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM)); | 279 |
310 m_aChildren.RemoveAll(); | 280 if (rcOld.left != rcNew.left || rcOld.right != rcNew.right || |
311 m_pVScrollBar = NULL; | 281 rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom) { |
312 } | 282 if (bReset) { |
313 | 283 RePosChildWnd(); |
314 void CPWL_Wnd::Move(const CPDF_Rect & rcNew, FX_BOOL bReset,FX_BOOL bRefresh) | 284 } |
315 { | 285 } |
316 if (IsValid()) | 286 if (bRefresh) { |
317 { | 287 InvalidateRectMove(rcOld, rcNew); |
318 CPDF_Rect rcOld = this->GetWindowRect(); | 288 } |
319 | 289 |
320 m_rcWindow = rcNew; | 290 m_sPrivateParam.rcRectWnd = m_rcWindow; |
321 m_rcWindow.Normalize(); | 291 } |
322 //m_rcClip = CPWL_Utils::InflateRect(m_rcWindow,1.0f); //for spe
cial caret | 292 } |
323 | 293 |
324 if (rcOld.left != rcNew.left || rcOld.right != rcNew.right || | 294 void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect& rcOld, |
325 rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom) | 295 const CPDF_Rect& rcNew) { |
326 { | 296 CPDF_Rect rcUnion = rcOld; |
327 if (bReset) | 297 rcUnion.Union(rcNew); |
328 { | 298 |
329 RePosChildWnd(); | 299 InvalidateRect(&rcUnion); |
330 } | 300 |
331 | 301 /* |
332 } | 302 CPDF_Rect SubArray[4]; |
333 if (bRefresh) | 303 |
334 { | 304 rcOld.Substract4(rcNew,SubArray); |
335 InvalidateRectMove(rcOld,rcNew); | 305 for (FX_INT32 i=0;i<4;i++) |
336 } | 306 { |
337 | 307 if (SubArray[i].left == 0 && |
338 m_sPrivateParam.rcRectWnd = m_rcWindow; | 308 SubArray[i].right == 0 && |
339 } | 309 SubArray[i].top == 0 && |
340 } | 310 SubArray[i].bottom == 0)continue; |
341 | 311 |
342 void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect & rcOld, const CPDF_Rect & rc
New) | 312 InvalidateRect(&CPWL_Utils::InflateRect(SubArray[i],2)); |
343 { | 313 } |
344 CPDF_Rect rcUnion = rcOld; | 314 |
345 rcUnion.Union(rcNew); | 315 rcNew.Substract4(rcOld,SubArray); |
346 | 316 for (FX_INT32 j=0;j<4;j++) |
347 InvalidateRect(&rcUnion); | 317 { |
348 | 318 if (SubArray[j].left == 0 && |
349 /* | 319 SubArray[j].right == 0 && |
350 CPDF_Rect SubArray[4]; | 320 SubArray[j].top == 0 && |
351 | 321 SubArray[j].bottom == 0)continue; |
352 rcOld.Substract4(rcNew,SubArray); | 322 |
353 for (FX_INT32 i=0;i<4;i++) | 323 InvalidateRect(&CPWL_Utils::InflateRect(SubArray[j],2)); |
354 { | 324 } |
355 if (SubArray[i].left == 0 && | 325 */ |
356 SubArray[i].right == 0 && | 326 } |
357 SubArray[i].top == 0 && | 327 |
358 SubArray[i].bottom == 0)continue; | 328 void CPWL_Wnd::GetAppearanceStream(CFX_ByteString& sAppStream) { |
359 | 329 if (IsValid()) { |
360 InvalidateRect(&CPWL_Utils::InflateRect(SubArray[i],2)); | 330 CFX_ByteTextBuf sTextBuf; |
361 } | 331 GetAppearanceStream(sTextBuf); |
362 | 332 sAppStream += sTextBuf.GetByteString(); |
363 rcNew.Substract4(rcOld,SubArray); | 333 } |
364 for (FX_INT32 j=0;j<4;j++) | 334 } |
365 { | 335 |
366 if (SubArray[j].left == 0 && | 336 void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
367 SubArray[j].right == 0 && | 337 if (IsValid() && IsVisible()) { |
368 SubArray[j].top == 0 && | 338 GetThisAppearanceStream(sAppStream); |
369 SubArray[j].bottom == 0)continue; | 339 GetChildAppearanceStream(sAppStream); |
370 | 340 } |
371 InvalidateRect(&CPWL_Utils::InflateRect(SubArray[j],2)); | 341 } |
372 } | 342 |
373 */ | 343 // if don't set,Get default apperance stream |
374 } | 344 void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
375 | 345 CPDF_Rect rectWnd = GetWindowRect(); |
376 void CPWL_Wnd::GetAppearanceStream(CFX_ByteString & sAppStream) | 346 if (!rectWnd.IsEmpty()) { |
377 { | 347 CFX_ByteTextBuf sThis; |
378 if (IsValid()) | 348 |
379 { | 349 if (HasFlag(PWS_BACKGROUND)) |
380 CFX_ByteTextBuf sTextBuf; | 350 sThis << CPWL_Utils::GetRectFillAppStream(rectWnd, |
381 GetAppearanceStream(sTextBuf); | 351 this->GetBackgroundColor()); |
382 sAppStream += sTextBuf.GetByteString(); | 352 |
383 } | 353 if (HasFlag(PWS_BORDER)) |
384 } | 354 sThis << CPWL_Utils::GetBorderAppStream( |
385 | 355 rectWnd, |
386 void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf & sAppStream) | 356 (FX_FLOAT)GetBorderWidth(), |
387 { | 357 GetBorderColor(), |
388 if (IsValid() && IsVisible()) | 358 this->GetBorderLeftTopColor(this->GetBorderStyle()), |
389 { | 359 this->GetBorderRightBottomColor(this->GetBorderStyle()), |
390 GetThisAppearanceStream(sAppStream); | 360 this->GetBorderStyle(), |
391 GetChildAppearanceStream(sAppStream); | 361 this->GetBorderDash()); |
392 } | 362 |
393 } | 363 sAppStream << sThis; |
394 | 364 } |
395 //if don't set,Get default apperance stream | 365 } |
396 void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) | 366 |
397 { | 367 void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
398 CPDF_Rect rectWnd = GetWindowRect(); | 368 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
399 if (!rectWnd.IsEmpty()) | 369 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
400 { | 370 pChild->GetAppearanceStream(sAppStream); |
401 CFX_ByteTextBuf sThis; | 371 } |
402 | 372 } |
403 if (HasFlag(PWS_BACKGROUND)) | 373 } |
404 sThis << CPWL_Utils::GetRectFillAppStream(rectWnd,this->
GetBackgroundColor()); | 374 |
405 | 375 void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice, |
406 if (HasFlag(PWS_BORDER)) | 376 CPDF_Matrix* pUser2Device) { |
407 sThis << CPWL_Utils::GetBorderAppStream(rectWnd, | 377 if (IsValid() && IsVisible()) { |
408 (FX_FLOA
T)GetBorderWidth(), | 378 DrawThisAppearance(pDevice, pUser2Device); |
409 GetBorde
rColor(), | 379 DrawChildAppearance(pDevice, pUser2Device); |
410 this->Ge
tBorderLeftTopColor(this->GetBorderStyle()), | 380 } |
411 this->Ge
tBorderRightBottomColor(this->GetBorderStyle()), | 381 } |
412 this->Ge
tBorderStyle(), | 382 |
413 this->Ge
tBorderDash()); | 383 void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, |
414 | 384 CPDF_Matrix* pUser2Device) { |
415 sAppStream << sThis; | 385 CPDF_Rect rectWnd = GetWindowRect(); |
416 } | 386 if (!rectWnd.IsEmpty()) { |
417 } | 387 if (HasFlag(PWS_BACKGROUND)) { |
418 | 388 CPDF_Rect rcClient = CPWL_Utils::DeflateRect( |
419 void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf & sAppStream) | 389 rectWnd, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
420 { | 390 CPWL_Utils::DrawFillRect(pDevice, |
421 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++) | 391 pUser2Device, |
422 { | 392 rcClient, |
423 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i)) | 393 this->GetBackgroundColor(), |
424 { | 394 GetTransparency()); |
425 pChild->GetAppearanceStream(sAppStream); | 395 } |
426 } | 396 |
427 } | 397 if (HasFlag(PWS_BORDER)) |
428 } | 398 CPWL_Utils::DrawBorder( |
429 | 399 pDevice, |
430 void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Devi
ce) | 400 pUser2Device, |
431 { | 401 rectWnd, |
432 if (IsValid() && IsVisible()) | 402 (FX_FLOAT)GetBorderWidth(), |
433 { | 403 GetBorderColor(), |
434 DrawThisAppearance(pDevice,pUser2Device); | 404 this->GetBorderLeftTopColor(this->GetBorderStyle()), |
435 DrawChildAppearance(pDevice,pUser2Device); | 405 this->GetBorderRightBottomColor(this->GetBorderStyle()), |
436 } | 406 this->GetBorderStyle(), |
437 } | 407 this->GetBorderDash(), |
438 | 408 GetTransparency()); |
439 void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2
Device) | 409 } |
440 { | 410 } |
441 CPDF_Rect rectWnd = GetWindowRect(); | 411 |
442 if (!rectWnd.IsEmpty()) | 412 void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, |
443 { | 413 CPDF_Matrix* pUser2Device) { |
444 if (HasFlag(PWS_BACKGROUND)) | 414 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
445 { | 415 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
446 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rectWnd,(FX
_FLOAT)(GetBorderWidth()+GetInnerBorderWidth())); | 416 CPDF_Matrix mt = pChild->GetChildMatrix(); |
447 CPWL_Utils::DrawFillRect(pDevice,pUser2Device,rcClient,t
his->GetBackgroundColor(),GetTransparency()); | 417 if (mt.IsIdentity()) { |
448 } | 418 pChild->DrawAppearance(pDevice, pUser2Device); |
449 | 419 } else { |
450 if (HasFlag(PWS_BORDER)) | 420 mt.Concat(*pUser2Device); |
451 CPWL_Utils::DrawBorder(pDevice, | 421 pChild->DrawAppearance(pDevice, &mt); |
452 pUser2Device, | 422 } |
453 rectWnd, | 423 } |
454 (FX_FLOAT)GetBor
derWidth(), | 424 } |
455 GetBorderColor()
, | 425 } |
456 this->GetBorderL
eftTopColor(this->GetBorderStyle()), | 426 |
457 this->GetBorderR
ightBottomColor(this->GetBorderStyle()), | 427 void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect) { |
458 this->GetBorderS
tyle(), | 428 if (IsValid()) { |
459 this->GetBorderD
ash(), | 429 CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect(); |
460 GetTransparency(
)); | 430 |
461 } | 431 if (!HasFlag(PWS_NOREFRESHCLIP)) { |
462 } | 432 CPDF_Rect rcClip = GetClipRect(); |
463 | 433 if (!rcClip.IsEmpty()) { |
464 void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser
2Device) | 434 rcRefresh.Intersect(rcClip); |
465 { | 435 } |
466 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++) | 436 } |
467 { | 437 |
468 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i)) | 438 FX_RECT rcWin = PWLtoWnd(rcRefresh); |
469 { | 439 rcWin.left -= PWL_INVALIDATE_INFLATE; |
470 CPDF_Matrix mt = pChild->GetChildMatrix(); | 440 rcWin.top -= PWL_INVALIDATE_INFLATE; |
471 if (mt.IsIdentity()) | 441 rcWin.right += PWL_INVALIDATE_INFLATE; |
472 { | 442 rcWin.bottom += PWL_INVALIDATE_INFLATE; |
473 pChild->DrawAppearance(pDevice,pUser2Device); | 443 |
474 } | 444 if (IFX_SystemHandler* pSH = GetSystemHandler()) { |
475 else | 445 if (FX_HWND hWnd = GetAttachedHWnd()) { |
476 { | 446 pSH->InvalidateRect(hWnd, rcWin); |
477 mt.Concat(*pUser2Device); | 447 } |
478 pChild->DrawAppearance(pDevice,&mt); | 448 } |
479 } | 449 } |
480 } | 450 } |
481 } | 451 |
482 } | 452 #define PWL_IMPLEMENT_KEY_METHOD(key_method_name) \ |
483 | 453 FX_BOOL CPWL_Wnd::key_method_name(FX_WORD nChar, FX_DWORD nFlag) { \ |
484 void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect) | 454 if (IsValid() && IsVisible() && IsEnabled()) { \ |
485 { | 455 if (IsWndCaptureKeyboard(this)) { \ |
486 if (IsValid()) | 456 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \ |
487 { | 457 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \ |
488 CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect(); | 458 if (IsWndCaptureKeyboard(pChild)) { \ |
489 | 459 return pChild->key_method_name(nChar, nFlag); \ |
490 if (!HasFlag(PWS_NOREFRESHCLIP)) | 460 } \ |
491 { | 461 } \ |
492 CPDF_Rect rcClip = GetClipRect(); | 462 } \ |
493 if (!rcClip.IsEmpty()) | 463 } \ |
494 { | 464 } \ |
495 rcRefresh.Intersect(rcClip); | 465 return FALSE; \ |
496 } | 466 } |
497 } | 467 |
498 | 468 #define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name) \ |
499 FX_RECT rcWin = PWLtoWnd(rcRefresh); | 469 FX_BOOL CPWL_Wnd::mouse_method_name(const CPDF_Point& point, \ |
500 rcWin.left -= PWL_INVALIDATE_INFLATE; | 470 FX_DWORD nFlag) { \ |
501 rcWin.top -= PWL_INVALIDATE_INFLATE; | 471 if (IsValid() && IsVisible() && IsEnabled()) { \ |
502 rcWin.right += PWL_INVALIDATE_INFLATE; | 472 if (IsWndCaptureMouse(this)) { \ |
503 rcWin.bottom += PWL_INVALIDATE_INFLATE; | 473 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \ |
504 | 474 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \ |
505 if (IFX_SystemHandler* pSH = GetSystemHandler()) | 475 if (IsWndCaptureMouse(pChild)) { \ |
506 { | 476 return pChild->mouse_method_name(pChild->ParentToChild(point), \ |
507 if (FX_HWND hWnd = GetAttachedHWnd()) | 477 nFlag); \ |
508 { | 478 } \ |
509 pSH->InvalidateRect(hWnd, rcWin); | 479 } \ |
510 } | 480 } \ |
511 } | 481 SetCursor(); \ |
512 } | 482 } else { \ |
513 } | 483 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \ |
514 | 484 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \ |
515 #define PWL_IMPLEMENT_KEY_METHOD(key_method_name)\ | 485 if (pChild->WndHitTest(pChild->ParentToChild(point))) { \ |
516 FX_BOOL CPWL_Wnd::key_method_name(FX_WORD nChar, FX_DWORD nFlag)\ | 486 return pChild->mouse_method_name(pChild->ParentToChild(point), \ |
517 {\ | 487 nFlag); \ |
518 if (IsValid() && IsVisible() && IsEnabled())\ | 488 } \ |
519 {\ | 489 } \ |
520 if (IsWndCaptureKeyboard(this))\ | 490 } \ |
521 {\ | 491 if (this->WndHitTest(point)) \ |
522 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)\ | 492 SetCursor(); \ |
523 {\ | 493 } \ |
524 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\ | 494 } \ |
525 {\ | 495 return FALSE; \ |
526 if (IsWndCaptureKeyboard(pChild))\ | 496 } |
527 {\ | |
528 return pChild->key_method_name(n
Char,nFlag);\ | |
529 }\ | |
530 }\ | |
531 }\ | |
532 }\ | |
533 }\ | |
534 return FALSE;\ | |
535 } | |
536 | |
537 #define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name)\ | |
538 FX_BOOL CPWL_Wnd::mouse_method_name(const CPDF_Point & point, FX_DWORD nFlag)\ | |
539 {\ | |
540 if (IsValid() && IsVisible() && IsEnabled())\ | |
541 {\ | |
542 if (IsWndCaptureMouse(this))\ | |
543 {\ | |
544 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)\ | |
545 {\ | |
546 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\ | |
547 {\ | |
548 if (IsWndCaptureMouse(pChild))\ | |
549 {\ | |
550 return pChild->mouse_method_name
(pChild->ParentToChild(point),nFlag);\ | |
551 }\ | |
552 }\ | |
553 }\ | |
554 SetCursor();\ | |
555 }\ | |
556 else\ | |
557 {\ | |
558 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)\ | |
559 {\ | |
560 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\ | |
561 {\ | |
562 if (pChild->WndHitTest(pChild->ParentToC
hild(point)))\ | |
563 {\ | |
564 return pChild->mouse_method_name
(pChild->ParentToChild(point),nFlag);\ | |
565 }\ | |
566 }\ | |
567 }\ | |
568 if (this->WndHitTest(point))\ | |
569 SetCursor();\ | |
570 }\ | |
571 }\ | |
572 return FALSE;\ | |
573 } | |
574 | 497 |
575 PWL_IMPLEMENT_KEY_METHOD(OnKeyDown) | 498 PWL_IMPLEMENT_KEY_METHOD(OnKeyDown) |
576 PWL_IMPLEMENT_KEY_METHOD(OnKeyUp) | 499 PWL_IMPLEMENT_KEY_METHOD(OnKeyUp) |
577 PWL_IMPLEMENT_KEY_METHOD(OnChar) | 500 PWL_IMPLEMENT_KEY_METHOD(OnChar) |
578 | 501 |
579 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDblClk) | 502 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDblClk) |
580 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDown) | 503 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDown) |
581 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonUp) | 504 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonUp) |
582 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDblClk) | 505 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDblClk) |
583 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDown) | 506 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDown) |
584 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonUp) | 507 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonUp) |
585 PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDblClk) | 508 PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDblClk) |
586 PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDown) | 509 PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDown) |
587 PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp) | 510 PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp) |
588 PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove) | 511 PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove) |
589 | 512 |
590 FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD
nFlag) | 513 FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta, |
591 { | 514 const CPDF_Point& point, |
592 if (IsValid() && IsVisible() && IsEnabled()) | 515 FX_DWORD nFlag) { |
593 { | 516 if (IsValid() && IsVisible() && IsEnabled()) { |
594 SetCursor(); | 517 SetCursor(); |
595 if (IsWndCaptureKeyboard(this)) | 518 if (IsWndCaptureKeyboard(this)) { |
596 { | 519 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
597 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++) | 520 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
598 { | 521 if (IsWndCaptureKeyboard(pChild)) { |
599 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i)) | 522 return pChild->OnMouseWheel( |
600 { | 523 zDelta, pChild->ParentToChild(point), nFlag); |
601 if (IsWndCaptureKeyboard(pChild)) | 524 } |
602 { | 525 } |
603 return pChild->OnMouseWheel(zDel
ta,pChild->ParentToChild(point), nFlag); | 526 } |
604 } | 527 } |
605 } | 528 } |
606 } | 529 return FALSE; |
607 } | 530 } |
608 } | 531 |
609 return FALSE; | 532 void CPWL_Wnd::AddChild(CPWL_Wnd* pWnd) { |
610 } | 533 m_aChildren.Add(pWnd); |
611 | 534 } |
612 void CPWL_Wnd::AddChild(CPWL_Wnd * pWnd) | 535 |
613 { | 536 void CPWL_Wnd::RemoveChild(CPWL_Wnd* pWnd) { |
614 m_aChildren.Add(pWnd); | 537 for (FX_INT32 i = m_aChildren.GetSize() - 1; i >= 0; i--) { |
615 } | 538 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
616 | 539 if (pChild == pWnd) { |
617 void CPWL_Wnd::RemoveChild(CPWL_Wnd * pWnd) | 540 m_aChildren.RemoveAt(i); |
618 { | 541 break; |
619 for (FX_INT32 i = m_aChildren.GetSize()-1; i >= 0; i --) | 542 } |
620 { | 543 } |
621 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 544 } |
622 { | 545 } |
623 if (pChild == pWnd) | 546 |
624 { | 547 void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd, |
625 m_aChildren.RemoveAt(i); | 548 FX_DWORD msg, |
626 break; | 549 FX_INTPTR wParam, |
627 } | 550 FX_INTPTR lParam) { |
628 } | 551 switch (msg) { |
629 } | 552 case PNM_ADDCHILD: |
630 } | 553 this->AddChild(pWnd); |
631 | 554 break; |
632 void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_INTPT
R lParam) | 555 case PNM_REMOVECHILD: |
633 { | 556 this->RemoveChild(pWnd); |
634 switch (msg) | 557 break; |
635 { | 558 default: |
636 case PNM_ADDCHILD: | 559 break; |
637 this->AddChild(pWnd); | 560 } |
638 break; | 561 } |
639 case PNM_REMOVECHILD: | 562 |
640 this->RemoveChild(pWnd); | 563 FX_BOOL CPWL_Wnd::IsValid() const { |
641 break; | 564 return m_bCreated; |
642 default: | 565 } |
643 break; | 566 |
644 } | 567 PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const { |
645 } | 568 return m_sPrivateParam; |
646 | 569 } |
647 FX_BOOL CPWL_Wnd::IsValid() const | 570 |
648 { | 571 CPWL_Wnd* CPWL_Wnd::GetParentWindow() const { |
649 return m_bCreated; | 572 return m_sPrivateParam.pParentWnd; |
650 } | 573 } |
651 | 574 |
652 PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const | 575 CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const { |
653 { | 576 return m_sPrivateParam.rcRectWnd; |
654 return m_sPrivateParam; | 577 } |
655 } | 578 |
656 | 579 CPDF_Rect CPWL_Wnd::GetWindowRect() const { |
657 CPWL_Wnd* CPWL_Wnd::GetParentWindow() const | 580 return m_rcWindow; |
658 { | 581 } |
659 return m_sPrivateParam.pParentWnd; | 582 |
660 } | 583 CPDF_Rect CPWL_Wnd::GetClientRect() const { |
661 | 584 CPDF_Rect rcWindow = GetWindowRect(); |
662 CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const | 585 CPDF_Rect rcClient = CPWL_Utils::DeflateRect( |
663 { | 586 rcWindow, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
664 return m_sPrivateParam.rcRectWnd; | 587 |
665 } | 588 if (CPWL_ScrollBar* pVSB = this->GetVScrollBar()) |
666 | 589 rcClient.right -= pVSB->GetScrollBarWidth(); |
667 CPDF_Rect CPWL_Wnd::GetWindowRect() const | 590 |
668 { | 591 rcClient.Normalize(); |
669 return m_rcWindow; | 592 |
670 } | 593 if (rcWindow.Contains(rcClient)) |
671 | 594 return rcClient; |
672 CPDF_Rect CPWL_Wnd::GetClientRect() const | 595 else |
673 { | 596 return CPDF_Rect(); |
674 CPDF_Rect rcWindow = GetWindowRect(); | 597 } |
675 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,(FX_FLOAT)(GetBord
erWidth()+GetInnerBorderWidth())); | 598 |
676 | 599 CPDF_Point CPWL_Wnd::GetCenterPoint() const { |
677 if (CPWL_ScrollBar * pVSB = this->GetVScrollBar()) | 600 CPDF_Rect rcClient = GetClientRect(); |
678 rcClient.right -= pVSB->GetScrollBarWidth(); | 601 |
679 | 602 return CPDF_Point((rcClient.left + rcClient.right) * 0.5f, |
680 rcClient.Normalize(); | 603 (rcClient.top + rcClient.bottom) * 0.5f); |
681 | 604 } |
682 if (rcWindow.Contains(rcClient)) | 605 |
683 return rcClient; | 606 CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const { |
684 else | 607 return CPWL_Utils::GetCenterSquare(GetClientRect()); |
685 return CPDF_Rect(); | 608 } |
686 } | 609 |
687 | 610 CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const { |
688 CPDF_Point CPWL_Wnd::GetCenterPoint() const | 611 return CPWL_Utils::GetCenterSquare( |
689 { | 612 CPWL_Utils::DeflateRect(GetWindowRect(), 0.1f)); |
690 CPDF_Rect rcClient = GetClientRect(); | 613 } |
691 | 614 |
692 return CPDF_Point((rcClient.left + rcClient.right) * 0.5f, | 615 FX_BOOL CPWL_Wnd::HasFlag(FX_DWORD dwFlags) const { |
693 (rcClient.top + rcClient.bottom) * 0.5f); | 616 return (m_sPrivateParam.dwFlags & dwFlags) != 0; |
694 } | 617 } |
695 | 618 |
696 CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const | 619 void CPWL_Wnd::RemoveFlag(FX_DWORD dwFlags) { |
697 { | 620 m_sPrivateParam.dwFlags &= ~dwFlags; |
698 return CPWL_Utils::GetCenterSquare(GetClientRect()); | 621 } |
699 } | 622 |
700 | 623 void CPWL_Wnd::AddFlag(FX_DWORD dwFlags) { |
701 CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const | 624 m_sPrivateParam.dwFlags |= dwFlags; |
702 { | 625 } |
703 return CPWL_Utils::GetCenterSquare(CPWL_Utils::DeflateRect(GetWindowRect
(),0.1f)); | 626 |
704 } | 627 CPWL_Color CPWL_Wnd::GetBackgroundColor() const { |
705 | 628 return m_sPrivateParam.sBackgroundColor; |
706 FX_BOOL CPWL_Wnd::HasFlag(FX_DWORD dwFlags) const | 629 } |
707 { | 630 |
708 return (m_sPrivateParam.dwFlags & dwFlags) != 0; | 631 void CPWL_Wnd::SetBackgroundColor(const CPWL_Color& color) { |
709 } | 632 m_sPrivateParam.sBackgroundColor = color; |
710 | 633 } |
711 void CPWL_Wnd::RemoveFlag(FX_DWORD dwFlags) | 634 |
712 { | 635 void CPWL_Wnd::SetTextColor(const CPWL_Color& color) { |
713 m_sPrivateParam.dwFlags &= ~dwFlags; | 636 m_sPrivateParam.sTextColor = color; |
714 } | 637 } |
715 | 638 |
716 void CPWL_Wnd::AddFlag(FX_DWORD dwFlags) | 639 void CPWL_Wnd::SetTextStrokeColor(const CPWL_Color& color) { |
717 { | 640 m_sPrivateParam.sTextStrokeColor = color; |
718 m_sPrivateParam.dwFlags |= dwFlags; | 641 } |
719 } | 642 |
720 | 643 CPWL_Color CPWL_Wnd::GetTextColor() const { |
721 CPWL_Color CPWL_Wnd::GetBackgroundColor() const | 644 return m_sPrivateParam.sTextColor; |
722 { | 645 } |
723 return m_sPrivateParam.sBackgroundColor; | 646 |
724 } | 647 CPWL_Color CPWL_Wnd::GetTextStrokeColor() const { |
725 | 648 return m_sPrivateParam.sTextStrokeColor; |
726 void CPWL_Wnd::SetBackgroundColor(const CPWL_Color & color) | 649 } |
727 { | 650 |
728 m_sPrivateParam.sBackgroundColor = color; | 651 FX_INT32 CPWL_Wnd::GetBorderStyle() const { |
729 } | 652 return m_sPrivateParam.nBorderStyle; |
730 | 653 } |
731 void CPWL_Wnd::SetTextColor(const CPWL_Color & color) | 654 |
732 { | 655 void CPWL_Wnd::SetBorderStyle(FX_INT32 nBorderStyle) { |
733 m_sPrivateParam.sTextColor = color; | 656 if (HasFlag(PWS_BORDER)) |
734 } | 657 m_sPrivateParam.nBorderStyle = nBorderStyle; |
735 | 658 } |
736 void CPWL_Wnd::SetTextStrokeColor(const CPWL_Color & color) | 659 |
737 { | 660 FX_INT32 CPWL_Wnd::GetBorderWidth() const { |
738 m_sPrivateParam.sTextStrokeColor = color; | 661 if (HasFlag(PWS_BORDER)) |
739 } | 662 return m_sPrivateParam.dwBorderWidth; |
740 | 663 |
741 CPWL_Color CPWL_Wnd::GetTextColor() const | 664 return 0; |
742 { | 665 } |
743 return m_sPrivateParam.sTextColor; | 666 |
744 } | 667 FX_INT32 CPWL_Wnd::GetInnerBorderWidth() const { |
745 | 668 /* |
746 CPWL_Color CPWL_Wnd::GetTextStrokeColor() const | 669 switch (GetBorderStyle()) |
747 { | 670 { |
748 return m_sPrivateParam.sTextStrokeColor; | 671 case PBS_BEVELED: |
749 } | 672 case PBS_INSET: |
750 | 673 return GetBorderWidth() / 2; |
751 FX_INT32 CPWL_Wnd::GetBorderStyle() const | 674 } |
752 { | 675 */ |
753 return m_sPrivateParam.nBorderStyle; | 676 return 0; |
754 } | 677 } |
755 | 678 |
756 void CPWL_Wnd::SetBorderStyle(FX_INT32 nBorderStyle) | 679 void CPWL_Wnd::SetBorderWidth(FX_INT32 nBorderWidth) { |
757 { | 680 if (HasFlag(PWS_BORDER)) |
758 if (HasFlag(PWS_BORDER)) | 681 m_sPrivateParam.dwBorderWidth = nBorderWidth; |
759 m_sPrivateParam.nBorderStyle = nBorderStyle; | 682 } |
760 } | 683 |
761 | 684 CPWL_Color CPWL_Wnd::GetBorderColor() const { |
762 FX_INT32 CPWL_Wnd::GetBorderWidth() const | 685 if (HasFlag(PWS_BORDER)) |
763 { | 686 return m_sPrivateParam.sBorderColor; |
764 if (HasFlag(PWS_BORDER)) | 687 |
765 return m_sPrivateParam.dwBorderWidth; | 688 return CPWL_Color(); |
766 | 689 } |
767 return 0; | 690 |
768 } | 691 void CPWL_Wnd::SetBorderColor(const CPWL_Color& color) { |
769 | 692 if (HasFlag(PWS_BORDER)) |
770 FX_INT32 CPWL_Wnd::GetInnerBorderWidth() const | 693 m_sPrivateParam.sBorderColor = color; |
771 { | 694 } |
772 /* | 695 |
773 switch (GetBorderStyle()) | 696 CPWL_Dash CPWL_Wnd::GetBorderDash() const { |
774 { | 697 return m_sPrivateParam.sDash; |
775 case PBS_BEVELED: | 698 } |
776 case PBS_INSET: | 699 |
777 return GetBorderWidth() / 2; | 700 void* CPWL_Wnd::GetAttachedData() const { |
778 } | 701 return m_sPrivateParam.pAttachedData; |
779 */ | 702 } |
780 return 0; | 703 |
781 } | 704 void CPWL_Wnd::SetBorderDash(const CPWL_Dash& sDash) { |
782 | 705 if (HasFlag(PWS_BORDER)) |
783 void CPWL_Wnd::SetBorderWidth(FX_INT32 nBorderWidth) | 706 m_sPrivateParam.sDash = sDash; |
784 { | 707 } |
785 if (HasFlag(PWS_BORDER)) | 708 |
786 m_sPrivateParam.dwBorderWidth = nBorderWidth; | 709 CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const { |
787 } | 710 if (HasFlag(PWS_VSCROLL)) |
788 | 711 return m_pVScrollBar; |
789 CPWL_Color CPWL_Wnd::GetBorderColor() const | 712 |
790 { | 713 return NULL; |
791 if (HasFlag(PWS_BORDER)) | 714 } |
792 return m_sPrivateParam.sBorderColor; | 715 |
793 | 716 void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM& cp) { |
794 return CPWL_Color(); | 717 CreateVScrollBar(cp); |
795 } | 718 } |
796 | 719 |
797 void CPWL_Wnd::SetBorderColor(const CPWL_Color & color) | 720 void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM& cp) { |
798 { | 721 if (!m_pVScrollBar && HasFlag(PWS_VSCROLL)) { |
799 if (HasFlag(PWS_BORDER)) | 722 PWL_CREATEPARAM scp = cp; |
800 m_sPrivateParam.sBorderColor = color; | 723 |
801 } | 724 // flags |
802 | 725 scp.dwFlags = |
803 CPWL_Dash CPWL_Wnd::GetBorderDash() const | 726 PWS_CHILD | PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NOREFRESHCLIP; |
804 { | 727 |
805 return m_sPrivateParam.sDash; | 728 scp.pParentWnd = this; |
806 } | 729 scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; |
807 | 730 scp.eCursorType = FXCT_ARROW; |
808 void* CPWL_Wnd::GetAttachedData() const | 731 scp.nTransparency = PWL_SCROLLBAR_TRANSPARANCY; |
809 { | 732 |
810 return m_sPrivateParam.pAttachedData; | 733 if ((m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL))) |
811 } | 734 m_pVScrollBar->Create(scp); |
812 | 735 } |
813 void CPWL_Wnd::SetBorderDash(const CPWL_Dash & sDash) | 736 } |
814 { | 737 |
815 if (HasFlag(PWS_BORDER)) | 738 void CPWL_Wnd::SetCapture() { |
816 m_sPrivateParam.sDash = sDash; | 739 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) |
817 } | 740 pMsgCtrl->SetCapture(this); |
818 | 741 } |
819 CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const | 742 |
820 { | 743 void CPWL_Wnd::ReleaseCapture() { |
821 if (HasFlag(PWS_VSCROLL)) | 744 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) |
822 return m_pVScrollBar; | 745 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) |
823 | 746 pChild->ReleaseCapture(); |
824 return NULL; | 747 |
825 } | 748 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) |
826 | 749 pMsgCtrl->ReleaseCapture(); |
827 void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM & cp) | 750 } |
828 { | 751 |
829 CreateVScrollBar(cp); | 752 void CPWL_Wnd::SetFocus() { |
830 } | 753 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) { |
831 | 754 if (!pMsgCtrl->IsMainCaptureKeyboard(this)) |
832 void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM & cp) | 755 pMsgCtrl->KillFocus(); |
833 { | 756 pMsgCtrl->SetFocus(this); |
834 if (!m_pVScrollBar && HasFlag(PWS_VSCROLL)) | 757 } |
835 { | 758 } |
836 PWL_CREATEPARAM scp = cp; | 759 |
837 | 760 void CPWL_Wnd::KillFocus() { |
838 //flags | 761 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) { |
839 scp.dwFlags = PWS_CHILD| PWS_BACKGROUND | PWS_AUTOTRANSPARENT |
PWS_NOREFRESHCLIP; | 762 if (pMsgCtrl->IsWndCaptureKeyboard(this)) |
840 | 763 pMsgCtrl->KillFocus(); |
841 scp.pParentWnd = this; | 764 } |
842 scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; | 765 } |
843 scp.eCursorType = FXCT_ARROW; | 766 |
844 scp.nTransparency = PWL_SCROLLBAR_TRANSPARANCY; | 767 void CPWL_Wnd::OnSetFocus() { |
845 | 768 } |
846 if ((m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL))) | 769 |
847 m_pVScrollBar->Create(scp); | 770 void CPWL_Wnd::OnKillFocus() { |
848 } | 771 } |
849 } | 772 |
850 | 773 FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point& point) const { |
851 void CPWL_Wnd::SetCapture() | 774 return IsValid() && IsVisible() && GetWindowRect().Contains(point.x, point.y); |
852 { | 775 } |
853 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl()) | 776 |
854 pMsgCtrl->SetCapture(this); | 777 FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point& point) const { |
855 } | 778 return IsValid() && IsVisible() && GetClientRect().Contains(point.x, point.y); |
856 | 779 } |
857 void CPWL_Wnd::ReleaseCapture() | 780 |
858 { | 781 const CPWL_Wnd* CPWL_Wnd::GetRootWnd() const { |
859 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++) | 782 if (m_sPrivateParam.pParentWnd) |
860 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 783 return m_sPrivateParam.pParentWnd->GetRootWnd(); |
861 pChild->ReleaseCapture(); | 784 else |
862 | 785 return this; |
863 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl()) | 786 } |
864 pMsgCtrl->ReleaseCapture(); | 787 |
865 } | 788 void CPWL_Wnd::SetVisible(FX_BOOL bVisible) { |
866 | 789 if (IsValid()) { |
867 void CPWL_Wnd::SetFocus() | 790 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
868 { | 791 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
869 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl()) | 792 pChild->SetVisible(bVisible); |
870 { | 793 } |
871 if (!pMsgCtrl->IsMainCaptureKeyboard(this)) | 794 } |
872 pMsgCtrl->KillFocus(); | 795 |
873 pMsgCtrl->SetFocus(this); | 796 if (bVisible != m_bVisible) { |
874 } | 797 m_bVisible = bVisible; |
875 } | 798 RePosChildWnd(); |
876 | 799 InvalidateRect(); |
877 void CPWL_Wnd::KillFocus() | 800 } |
878 { | 801 } |
879 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl()) | 802 } |
880 { | 803 |
881 if (pMsgCtrl->IsWndCaptureKeyboard(this)) | 804 void CPWL_Wnd::SetClipRect(const CPDF_Rect& rect) { |
882 pMsgCtrl->KillFocus(); | 805 m_rcClip = rect; |
883 } | 806 m_rcClip.Normalize(); |
884 } | 807 } |
885 | 808 |
886 void CPWL_Wnd::OnSetFocus() | 809 CPDF_Rect CPWL_Wnd::GetClipRect() const { |
887 { | 810 return m_rcClip; |
888 } | 811 } |
889 | 812 |
890 void CPWL_Wnd::OnKillFocus() | 813 FX_BOOL CPWL_Wnd::IsReadOnly() const { |
891 { | 814 return HasFlag(PWS_READONLY); |
892 } | 815 } |
893 | 816 |
894 FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point & point) const | 817 void CPWL_Wnd::RePosChildWnd() { |
895 { | 818 CPDF_Rect rcContent = CPWL_Utils::DeflateRect( |
896 return IsValid() && IsVisible() && GetWindowRect().Contains(point.x,poin
t.y); | 819 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
897 } | 820 |
898 | 821 CPWL_ScrollBar* pVSB = this->GetVScrollBar(); |
899 FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point & point) const | 822 |
900 { | 823 CPDF_Rect rcVScroll = CPDF_Rect(rcContent.right - PWL_SCROLLBAR_WIDTH, |
901 return IsValid() && IsVisible() && GetClientRect().Contains(point.x,poin
t.y); | 824 rcContent.bottom, |
902 } | 825 rcContent.right - 1.0f, |
903 | 826 rcContent.top); |
904 const CPWL_Wnd * CPWL_Wnd::GetRootWnd() const | 827 |
905 { | 828 if (pVSB) |
906 if (m_sPrivateParam.pParentWnd) | 829 pVSB->Move(rcVScroll, TRUE, FALSE); |
907 return m_sPrivateParam.pParentWnd->GetRootWnd(); | 830 } |
908 else | 831 |
909 return this; | 832 void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM& cp) { |
910 } | 833 } |
911 | 834 |
912 void CPWL_Wnd::SetVisible(FX_BOOL bVisible) | 835 void CPWL_Wnd::SetCursor() { |
913 { | 836 if (IsValid()) { |
914 if (IsValid()) | 837 if (IFX_SystemHandler* pSH = GetSystemHandler()) { |
915 { | 838 FX_INT32 nCursorType = this->GetCreationParam().eCursorType; |
916 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++) | 839 pSH->SetCursor(nCursorType); |
917 { | 840 } |
918 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 841 } |
919 { | 842 } |
920 pChild->SetVisible(bVisible); | 843 |
921 } | 844 void CPWL_Wnd::CreateMsgControl() { |
922 } | 845 if (!m_sPrivateParam.pMsgControl) |
923 | 846 m_sPrivateParam.pMsgControl = new CPWL_MsgControl(this); |
924 if (bVisible != m_bVisible) | 847 } |
925 { | 848 |
926 m_bVisible = bVisible; | 849 void CPWL_Wnd::DestroyMsgControl() { |
927 RePosChildWnd(); | 850 if (CPWL_MsgControl* pMsgControl = GetMsgControl()) |
928 InvalidateRect(); | 851 if (pMsgControl->IsWndCreated(this)) |
929 } | 852 delete pMsgControl; |
930 } | 853 } |
931 } | 854 |
932 | 855 CPWL_MsgControl* CPWL_Wnd::GetMsgControl() const { |
933 void CPWL_Wnd::SetClipRect(const CPDF_Rect & rect) | 856 return m_sPrivateParam.pMsgControl; |
934 { | 857 } |
935 m_rcClip = rect; | 858 |
936 m_rcClip.Normalize(); | 859 FX_BOOL CPWL_Wnd::IsCaptureMouse() const { |
937 } | 860 return IsWndCaptureMouse(this); |
938 | 861 } |
939 CPDF_Rect CPWL_Wnd::GetClipRect() const | 862 |
940 { | 863 FX_BOOL CPWL_Wnd::IsWndCaptureMouse(const CPWL_Wnd* pWnd) const { |
941 return m_rcClip; | 864 if (CPWL_MsgControl* pCtrl = GetMsgControl()) |
942 } | 865 return pCtrl->IsWndCaptureMouse(pWnd); |
943 | 866 |
944 FX_BOOL CPWL_Wnd::IsReadOnly() const | 867 return FALSE; |
945 { | 868 } |
946 return HasFlag(PWS_READONLY); | 869 |
947 } | 870 FX_BOOL CPWL_Wnd::IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const { |
948 | 871 if (CPWL_MsgControl* pCtrl = GetMsgControl()) |
949 void CPWL_Wnd::RePosChildWnd() | 872 return pCtrl->IsWndCaptureKeyboard(pWnd); |
950 { | 873 |
951 CPDF_Rect rcContent = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)
(GetBorderWidth()+GetInnerBorderWidth())); | 874 return FALSE; |
952 | 875 } |
953 CPWL_ScrollBar * pVSB = this->GetVScrollBar(); | 876 |
954 | 877 FX_BOOL CPWL_Wnd::IsFocused() const { |
955 CPDF_Rect rcVScroll = CPDF_Rect(rcContent.right - PWL_SCROLLBAR_WIDTH, | 878 if (CPWL_MsgControl* pCtrl = GetMsgControl()) |
956 rcContent.bottom, | 879 return pCtrl->IsMainCaptureKeyboard(this); |
957 rcContent.right-1.0f, | 880 |
958 rcContent.top); | 881 return FALSE; |
959 | 882 } |
960 if (pVSB) pVSB->Move(rcVScroll,TRUE,FALSE); | 883 |
961 } | 884 CPDF_Rect CPWL_Wnd::GetFocusRect() const { |
962 | 885 return CPWL_Utils::InflateRect(this->GetWindowRect(), 1); |
963 void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM & cp) | 886 } |
964 { | 887 |
965 } | 888 FX_FLOAT CPWL_Wnd::GetFontSize() const { |
966 | 889 return this->m_sPrivateParam.fFontSize; |
967 void CPWL_Wnd::SetCursor() | 890 } |
968 { | 891 |
969 if (IsValid()) | 892 void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize) { |
970 { | 893 this->m_sPrivateParam.fFontSize = fFontSize; |
971 if (IFX_SystemHandler* pSH = GetSystemHandler()) | 894 } |
972 { | 895 |
973 FX_INT32 nCursorType = this->GetCreationParam().eCursorT
ype; | 896 IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const { |
974 pSH->SetCursor(nCursorType); | 897 return m_sPrivateParam.pSystemHandler; |
975 } | 898 } |
976 } | 899 |
977 } | 900 IPWL_FocusHandler* CPWL_Wnd::GetFocusHandler() const { |
978 | 901 return m_sPrivateParam.pFocusHandler; |
979 void CPWL_Wnd::CreateMsgControl() | 902 } |
980 { | 903 |
981 if (!m_sPrivateParam.pMsgControl) | 904 IPWL_Provider* CPWL_Wnd::GetProvider() const { |
982 m_sPrivateParam.pMsgControl = new CPWL_MsgControl(this); | 905 return m_sPrivateParam.pProvider; |
983 } | 906 } |
984 | 907 |
985 void CPWL_Wnd::DestroyMsgControl() | 908 IFX_Edit_FontMap* CPWL_Wnd::GetFontMap() const { |
986 { | 909 return m_sPrivateParam.pFontMap; |
987 if (CPWL_MsgControl* pMsgControl = GetMsgControl()) | 910 } |
988 if (pMsgControl->IsWndCreated(this)) | 911 |
989 delete pMsgControl; | 912 CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(FX_INT32 nBorderStyle) const { |
990 } | 913 CPWL_Color color; |
991 | 914 |
992 CPWL_MsgControl* CPWL_Wnd::GetMsgControl() const | 915 switch (nBorderStyle) { |
993 { | 916 case PBS_SOLID: |
994 return m_sPrivateParam.pMsgControl; | 917 break; |
995 } | 918 case PBS_DASH: |
996 | 919 break; |
997 FX_BOOL CPWL_Wnd::IsCaptureMouse() const | 920 case PBS_BEVELED: |
998 { | 921 color = CPWL_Color(COLORTYPE_GRAY, 1); |
999 return IsWndCaptureMouse(this); | 922 break; |
1000 } | 923 case PBS_INSET: |
1001 | 924 color = CPWL_Color(COLORTYPE_GRAY, 0.5f); |
1002 FX_BOOL CPWL_Wnd::IsWndCaptureMouse(const CPWL_Wnd * pWnd) const | 925 break; |
1003 { | 926 case PBS_UNDERLINED: |
1004 if (CPWL_MsgControl * pCtrl = GetMsgControl()) | 927 break; |
1005 return pCtrl->IsWndCaptureMouse(pWnd); | 928 } |
1006 | 929 |
1007 return FALSE; | 930 return color; |
1008 } | 931 } |
1009 | 932 |
1010 FX_BOOL CPWL_Wnd::IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const | 933 CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(FX_INT32 nBorderStyle) const { |
1011 { | 934 CPWL_Color color; |
1012 if (CPWL_MsgControl * pCtrl = GetMsgControl()) | 935 |
1013 return pCtrl->IsWndCaptureKeyboard(pWnd); | 936 switch (nBorderStyle) { |
1014 | 937 case PBS_SOLID: |
1015 return FALSE; | 938 break; |
1016 } | 939 case PBS_DASH: |
1017 | 940 break; |
1018 FX_BOOL CPWL_Wnd::IsFocused() const | 941 case PBS_BEVELED: |
1019 { | 942 color = CPWL_Utils::DevideColor(GetBackgroundColor(), 2); |
1020 if (CPWL_MsgControl * pCtrl = GetMsgControl()) | 943 break; |
1021 return pCtrl->IsMainCaptureKeyboard(this); | 944 case PBS_INSET: |
1022 | 945 color = CPWL_Color(COLORTYPE_GRAY, 0.75f); |
1023 return FALSE; | 946 break; |
1024 } | 947 case PBS_UNDERLINED: |
1025 | 948 break; |
1026 CPDF_Rect CPWL_Wnd::GetFocusRect() const | 949 } |
1027 { | 950 |
1028 return CPWL_Utils::InflateRect(this->GetWindowRect(),1); | 951 return color; |
1029 } | |
1030 | |
1031 FX_FLOAT CPWL_Wnd::GetFontSize() const | |
1032 { | |
1033 return this->m_sPrivateParam.fFontSize; | |
1034 } | |
1035 | |
1036 void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize) | |
1037 { | |
1038 this->m_sPrivateParam.fFontSize = fFontSize; | |
1039 } | |
1040 | |
1041 IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const | |
1042 { | |
1043 return m_sPrivateParam.pSystemHandler; | |
1044 } | |
1045 | |
1046 IPWL_FocusHandler* CPWL_Wnd::GetFocusHandler() const | |
1047 { | |
1048 return m_sPrivateParam.pFocusHandler; | |
1049 } | |
1050 | |
1051 IPWL_Provider* CPWL_Wnd::GetProvider() const | |
1052 { | |
1053 return m_sPrivateParam.pProvider; | |
1054 } | |
1055 | |
1056 IFX_Edit_FontMap* CPWL_Wnd::GetFontMap() const | |
1057 { | |
1058 return m_sPrivateParam.pFontMap; | |
1059 } | |
1060 | |
1061 CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(FX_INT32 nBorderStyle) const | |
1062 { | |
1063 CPWL_Color color; | |
1064 | |
1065 switch (nBorderStyle) | |
1066 { | |
1067 case PBS_SOLID: | |
1068 break; | |
1069 case PBS_DASH: | |
1070 break; | |
1071 case PBS_BEVELED: | |
1072 color = CPWL_Color(COLORTYPE_GRAY,1); | |
1073 break; | |
1074 case PBS_INSET: | |
1075 color = CPWL_Color(COLORTYPE_GRAY,0.5f); | |
1076 break; | |
1077 case PBS_UNDERLINED: | |
1078 break; | |
1079 } | |
1080 | |
1081 return color; | |
1082 } | |
1083 | |
1084 CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(FX_INT32 nBorderStyle) const | |
1085 { | |
1086 CPWL_Color color; | |
1087 | |
1088 switch (nBorderStyle) | |
1089 { | |
1090 case PBS_SOLID: | |
1091 break; | |
1092 case PBS_DASH: | |
1093 break; | |
1094 case PBS_BEVELED: | |
1095 color = CPWL_Utils::DevideColor(GetBackgroundColor(),2); | |
1096 break; | |
1097 case PBS_INSET: | |
1098 color = CPWL_Color(COLORTYPE_GRAY,0.75f); | |
1099 break; | |
1100 case PBS_UNDERLINED: | |
1101 break; | |
1102 } | |
1103 | |
1104 return color; | |
1105 } | 952 } |
1106 | 953 |
1107 /* ----------------------------------------------------------------- */ | 954 /* ----------------------------------------------------------------- */ |
1108 | 955 |
1109 FX_INT32 CPWL_Wnd::GetTransparency() | 956 FX_INT32 CPWL_Wnd::GetTransparency() { |
1110 { | 957 return m_sPrivateParam.nTransparency; |
1111 » return m_sPrivateParam.nTransparency; | 958 } |
1112 } | 959 |
1113 | 960 void CPWL_Wnd::SetTransparency(FX_INT32 nTransparency) { |
1114 void CPWL_Wnd::SetTransparency(FX_INT32 nTransparency) | 961 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
1115 { | 962 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
1116 » for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++) | 963 pChild->SetTransparency(nTransparency); |
1117 » { | 964 } |
1118 » » if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 965 } |
1119 » » { | 966 |
1120 » » » pChild->SetTransparency(nTransparency); | 967 m_sPrivateParam.nTransparency = nTransparency; |
1121 » » } | 968 } |
1122 » } | 969 |
1123 | 970 CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const { |
1124 » m_sPrivateParam.nTransparency = nTransparency; | 971 CPDF_Matrix mt = this->GetChildToRoot(); |
1125 } | 972 |
1126 | 973 if (IPWL_Provider* pProvider = GetProvider()) { |
1127 CPDF_Matrix» CPWL_Wnd::GetWindowMatrix() const | 974 mt.Concat(pProvider->GetWindowMatrix(GetAttachedData())); |
1128 { | 975 return mt; |
1129 » CPDF_Matrix mt = this->GetChildToRoot(); | 976 } |
1130 | 977 |
1131 » if (IPWL_Provider* pProvider = GetProvider()) | 978 /* |
1132 » { | 979 if (CReader_App* pApp = CPWL_Module::GetReaderApp()) |
1133 » » mt.Concat(pProvider->GetWindowMatrix(GetAttachedData())); | 980 if (CReader_Document* pDocument = pApp->GetCurrentDocument()) |
1134 » » return mt; | 981 if (CReader_DocView* pDocView = |
1135 » } | 982 pDocument->GetCurrentDocView()) |
1136 | 983 { |
1137 /* | 984 CPDF_Matrix mtPageView; |
1138 » if (CReader_App* pApp = CPWL_Module::GetReaderApp()) | 985 pDocView->GetCurrentMatrix(mtPageView); |
1139 » » if (CReader_Document* pDocument = pApp->GetCurrentDocument()) | 986 mt.Concat(mtPageView); |
1140 » » » if (CReader_DocView* pDocView = pDocument->GetCurrentDoc
View()) | 987 return mt; |
1141 » » » { | 988 } |
1142 » » » » CPDF_Matrix mtPageView; | 989 |
1143 » » » » pDocView->GetCurrentMatrix(mtPageView); | 990 */ |
1144 » » » » mt.Concat(mtPageView); | 991 |
1145 » » » » return mt; | 992 return mt; |
1146 » » » }» » | 993 } |
1147 » » » | 994 |
1148 */ | 995 void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, |
1149 | 996 FX_INT32& x, |
1150 » return mt; | 997 FX_INT32& y) const { |
1151 } | 998 CPDF_Matrix mt = GetWindowMatrix(); |
1152 | 999 CPDF_Point pt = point; |
1153 void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, FX_INT32& x, FX_INT32& y) const | 1000 mt.Transform(pt.x, pt.y); |
1154 { | 1001 x = (FX_INT32)(pt.x + 0.5); |
1155 » CPDF_Matrix mt = GetWindowMatrix(); | 1002 y = (FX_INT32)(pt.y + 0.5); |
1156 » CPDF_Point pt = point; | 1003 } |
1157 » mt.Transform(pt.x,pt.y); | 1004 |
1158 » x = (FX_INT32)(pt.x+0.5); | 1005 FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect& rect) const { |
1159 » y = (FX_INT32)(pt.y+0.5); | 1006 CPDF_Rect rcTemp = rect; |
1160 } | 1007 CPDF_Matrix mt = GetWindowMatrix(); |
1161 | 1008 mt.TransformRect(rcTemp); |
1162 FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect & rect) const | 1009 return FX_RECT((FX_INT32)(rcTemp.left + 0.5), |
1163 { | 1010 (FX_INT32)(rcTemp.bottom + 0.5), |
1164 » CPDF_Rect rcTemp = rect; | 1011 (FX_INT32)(rcTemp.right + 0.5), |
1165 » CPDF_Matrix mt = GetWindowMatrix(); | 1012 (FX_INT32)(rcTemp.top + 0.5)); |
1166 » mt.TransformRect(rcTemp);» | 1013 } |
1167 » return FX_RECT((FX_INT32)(rcTemp.left+0.5), (FX_INT32)(rcTemp.bottom+0.5
), (FX_INT32)(rcTemp.right+0.5), (FX_INT32)(rcTemp.top+0.5)); | 1014 |
1168 } | 1015 FX_HWND CPWL_Wnd::GetAttachedHWnd() const { |
1169 | 1016 return m_sPrivateParam.hAttachedWnd; |
1170 FX_HWND CPWL_Wnd::GetAttachedHWnd() const | 1017 } |
1171 { | 1018 |
1172 » return m_sPrivateParam.hAttachedWnd; | 1019 CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const { |
1173 } | 1020 CPDF_Matrix mt = GetChildMatrix(); |
1174 | 1021 if (mt.IsIdentity()) |
1175 CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const | 1022 return point; |
1176 { | 1023 else { |
1177 » CPDF_Matrix mt = GetChildMatrix(); | 1024 CPDF_Point pt = point; |
1178 » if (mt.IsIdentity()) | 1025 mt.Transform(pt.x, pt.y); |
1179 » » return point; | 1026 return pt; |
1180 » else | 1027 } |
1181 » { | 1028 } |
1182 » » CPDF_Point pt = point; | 1029 |
1183 » » mt.Transform(pt.x,pt.y); | 1030 CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const { |
1184 » » return pt; | 1031 CPDF_Matrix mt = GetChildMatrix(); |
1185 » } | 1032 if (mt.IsIdentity()) |
1186 } | 1033 return rect; |
1187 | 1034 else { |
1188 CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const | 1035 CPDF_Rect rc = rect; |
1189 { | 1036 mt.TransformRect(rc); |
1190 » CPDF_Matrix mt = GetChildMatrix(); | 1037 return rc; |
1191 » if (mt.IsIdentity()) | 1038 } |
1192 » » return rect; | 1039 } |
1193 » else | 1040 |
1194 » { | 1041 CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const { |
1195 » » CPDF_Rect rc = rect; | 1042 CPDF_Matrix mt = GetChildMatrix(); |
1196 » » mt.TransformRect(rc); | 1043 if (mt.IsIdentity()) |
1197 » » return rc; | 1044 return point; |
1198 » } | 1045 else { |
1199 } | 1046 mt.SetReverse(mt); |
1200 | 1047 CPDF_Point pt = point; |
1201 CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const | 1048 mt.Transform(pt.x, pt.y); |
1202 { | 1049 return pt; |
1203 » CPDF_Matrix mt = GetChildMatrix(); | 1050 } |
1204 » if (mt.IsIdentity()) | 1051 } |
1205 » » return point; | 1052 |
1206 » else | 1053 CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const { |
1207 » { | 1054 CPDF_Matrix mt = GetChildMatrix(); |
1208 » » mt.SetReverse(mt); | 1055 if (mt.IsIdentity()) |
1209 » » CPDF_Point pt = point; | 1056 return rect; |
1210 » » mt.Transform(pt.x,pt.y); | 1057 else { |
1211 » » return pt; | 1058 mt.SetReverse(mt); |
1212 » } | 1059 CPDF_Rect rc = rect; |
1213 } | 1060 mt.TransformRect(rc); |
1214 | 1061 return rc; |
1215 CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const | 1062 } |
1216 { | 1063 } |
1217 » CPDF_Matrix mt = GetChildMatrix(); | 1064 |
1218 » if (mt.IsIdentity()) | 1065 CPDF_Matrix CPWL_Wnd::GetChildToRoot() const { |
1219 » » return rect; | 1066 CPDF_Matrix mt(1, 0, 0, 1, 0, 0); |
1220 » else | 1067 |
1221 » { | 1068 if (HasFlag(PWS_CHILD)) { |
1222 » » mt.SetReverse(mt); | 1069 const CPWL_Wnd* pParent = this; |
1223 » » CPDF_Rect rc = rect; | 1070 while (pParent) { |
1224 » » mt.TransformRect(rc); | 1071 mt.Concat(pParent->GetChildMatrix()); |
1225 » » return rc; | 1072 pParent = pParent->GetParentWindow(); |
1226 » } | 1073 } |
1227 } | 1074 } |
1228 | 1075 |
1229 CPDF_Matrix CPWL_Wnd::GetChildToRoot() const | 1076 return mt; |
1230 { | 1077 } |
1231 » CPDF_Matrix mt(1,0,0,1,0,0); | 1078 |
1232 » | 1079 CPDF_Matrix CPWL_Wnd::GetChildMatrix() const { |
1233 » if (HasFlag(PWS_CHILD)) | 1080 if (HasFlag(PWS_CHILD)) |
1234 » { | 1081 return m_sPrivateParam.mtChild; |
1235 » » const CPWL_Wnd* pParent = this; | 1082 |
1236 » » while (pParent) | 1083 return CPDF_Matrix(1, 0, 0, 1, 0, 0); |
1237 » » { | 1084 } |
1238 » » » mt.Concat(pParent->GetChildMatrix()); | 1085 |
1239 » » » pParent = pParent->GetParentWindow(); | 1086 void CPWL_Wnd::SetChildMatrix(const CPDF_Matrix& mt) { |
1240 » » } | 1087 m_sPrivateParam.mtChild = mt; |
1241 » } | 1088 } |
1242 | 1089 |
1243 » return mt; | 1090 const CPWL_Wnd* CPWL_Wnd::GetFocused() const { |
1244 } | 1091 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) { |
1245 | 1092 return pMsgCtrl->m_pMainKeyboardWnd; |
1246 CPDF_Matrix CPWL_Wnd::GetChildMatrix() const | 1093 } |
1247 { | 1094 |
1248 » if (HasFlag(PWS_CHILD)) | 1095 return NULL; |
1249 » » return m_sPrivateParam.mtChild; | 1096 } |
1250 | 1097 |
1251 » return CPDF_Matrix(1,0,0,1,0,0); | 1098 void CPWL_Wnd::EnableWindow(FX_BOOL bEnable) { |
1252 } | 1099 if (m_bEnabled != bEnable) { |
1253 | 1100 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
1254 void CPWL_Wnd::SetChildMatrix(const CPDF_Matrix& mt) | 1101 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
1255 { | 1102 pChild->EnableWindow(bEnable); |
1256 » m_sPrivateParam.mtChild = mt; | 1103 } |
1257 } | 1104 } |
1258 | 1105 |
1259 const CPWL_Wnd*»CPWL_Wnd::GetFocused() const | 1106 this->m_bEnabled = bEnable; |
1260 { | 1107 |
1261 » if (CPWL_MsgControl * pMsgCtrl = GetMsgControl()) | 1108 if (bEnable) |
1262 » { | 1109 this->OnEnabled(); |
1263 » » return pMsgCtrl->m_pMainKeyboardWnd; | 1110 else |
1264 » } | 1111 this->OnDisabled(); |
1265 | 1112 } |
1266 » return NULL; | 1113 } |
1267 } | 1114 |
1268 | 1115 FX_BOOL CPWL_Wnd::IsEnabled() { |
1269 void CPWL_Wnd::EnableWindow(FX_BOOL bEnable) | 1116 return m_bEnabled; |
1270 { | 1117 } |
1271 » if (m_bEnabled != bEnable) | 1118 |
1272 » { | 1119 void CPWL_Wnd::OnEnabled() { |
1273 » » for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++) | 1120 } |
1274 » » { | 1121 |
1275 » » » if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 1122 void CPWL_Wnd::OnDisabled() { |
1276 » » » { | 1123 } |
1277 » » » » pChild->EnableWindow(bEnable); | 1124 |
1278 » » » } | 1125 FX_BOOL CPWL_Wnd::IsCTRLpressed(FX_DWORD nFlag) const { |
1279 » » } | 1126 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { |
1280 | 1127 return pSystemHandler->IsCTRLKeyDown(nFlag); |
1281 » » this->m_bEnabled = bEnable; | 1128 } |
1282 | 1129 |
1283 » » if (bEnable) | 1130 return FALSE; |
1284 » » » this->OnEnabled(); | 1131 } |
1285 » » else | 1132 |
1286 » » » this->OnDisabled(); | 1133 FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const { |
1287 » } | 1134 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { |
1288 } | 1135 return pSystemHandler->IsSHIFTKeyDown(nFlag); |
1289 | 1136 } |
1290 FX_BOOL CPWL_Wnd::IsEnabled() | 1137 |
1291 { | 1138 return FALSE; |
1292 » return m_bEnabled; | 1139 } |
1293 } | 1140 |
1294 | 1141 FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const { |
1295 void CPWL_Wnd::OnEnabled() | 1142 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { |
1296 { | 1143 return pSystemHandler->IsALTKeyDown(nFlag); |
1297 } | 1144 } |
1298 | 1145 |
1299 void CPWL_Wnd::OnDisabled() | 1146 return FALSE; |
1300 { | 1147 } |
1301 } | 1148 |
1302 | 1149 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const { |
1303 FX_BOOL CPWL_Wnd::IsCTRLpressed(FX_DWORD nFlag) const | 1150 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { |
1304 { | 1151 return pSystemHandler->IsINSERTKeyDown(nFlag); |
1305 » if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) | 1152 } |
1306 » { | 1153 |
1307 » » return pSystemHandler->IsCTRLKeyDown(nFlag); | 1154 return FALSE; |
1308 » } | 1155 } |
1309 | |
1310 » return FALSE; | |
1311 } | |
1312 | |
1313 FX_BOOL»CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const | |
1314 { | |
1315 » if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) | |
1316 » { | |
1317 » » return pSystemHandler->IsSHIFTKeyDown(nFlag); | |
1318 » } | |
1319 | |
1320 » return FALSE; | |
1321 } | |
1322 | |
1323 FX_BOOL»CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const | |
1324 { | |
1325 » if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) | |
1326 » { | |
1327 » » return pSystemHandler->IsALTKeyDown(nFlag); | |
1328 » } | |
1329 | |
1330 » return FALSE; | |
1331 } | |
1332 | |
1333 FX_BOOL»CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const | |
1334 { | |
1335 » if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) | |
1336 » { | |
1337 » » return pSystemHandler->IsINSERTKeyDown(nFlag); | |
1338 » } | |
1339 | |
1340 » return FALSE; | |
1341 } | |
1342 | |
OLD | NEW |