Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp

Issue 1239313005: Merge to XFA - else after returns. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Fix issues. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/javascript/util.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_EditCtrl.h" 9 #include "../../include/pdfwindow/PWL_EditCtrl.h"
10 #include "../../include/pdfwindow/PWL_Edit.h" 10 #include "../../include/pdfwindow/PWL_Edit.h"
11 #include "../../include/pdfwindow/PWL_ListBox.h" 11 #include "../../include/pdfwindow/PWL_ListBox.h"
12 #include "../../include/pdfwindow/PWL_ComboBox.h" 12 #include "../../include/pdfwindow/PWL_ComboBox.h"
13 #include "../../include/pdfwindow/PWL_Utils.h" 13 #include "../../include/pdfwindow/PWL_Utils.h"
14 14
15 #define PWLCB_DEFAULTFONTSIZE 12.0f 15 #define PWLCB_DEFAULTFONTSIZE 12.0f
16 16
17 #define IsFloatZero(f)» » » » » » ((f) < 0.0001 && (f) > -0.0001) 17 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
18 #define IsFloatBigger(fa,fb)» » » » ((fa) > (fb) && !IsFloat Zero((fa) - (fb))) 18 #define IsFloatBigger(fa,fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
19 #define IsFloatSmaller(fa,fb)» » » » ((fa) < (fb) && !IsFloat Zero((fa) - (fb))) 19 #define IsFloatSmaller(fa,fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
20 #define IsFloatEqual(fa,fb)» » » » » IsFloatZero((fa) -(fb)) 20 #define IsFloatEqual(fa,fb) IsFloatZero((fa)-(fb))
21 21
22 22
23 /* ---------------------------- CPWL_CBListBox ---------------------------- */ 23 /* ---------------------------- CPWL_CBListBox ---------------------------- */
24 24
25 FX_BOOL»CPWL_CBListBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag) 25 FX_BOOL CPWL_CBListBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
26 { 26 {
27 » CPWL_Wnd::OnLButtonUp(point,nFlag); 27 CPWL_Wnd::OnLButtonUp(point,nFlag);
28 28
29 » if (m_bMouseDown) 29 if (m_bMouseDown)
30 » { 30 {
31 » » ReleaseCapture(); 31 ReleaseCapture();
32 » » m_bMouseDown = FALSE; 32 m_bMouseDown = FALSE;
33 33
34 » » if (ClientHitTest(point)) 34 if (ClientHitTest(point))
35 » » { 35 {
36 » » » if (CPWL_Wnd * pParent = GetParentWindow()) 36 if (CPWL_Wnd * pParent = GetParentWindow())
37 » » » { 37 {
38 » » » » pParent->OnNotify(this,PNM_LBUTTONUP,0,PWL_MAKED WORD(point.x,point.y)); 38 pParent->OnNotify(this,PNM_LBUTTONUP,0,PWL_MAKEDWORD(point.x,poi nt.y));
39 » » » } 39 }
40 40
41 » » » FX_BOOL bExit = FALSE; 41 FX_BOOL bExit = FALSE;
42 » » » OnNotifySelChanged(FALSE,bExit, nFlag); 42 OnNotifySelChanged(FALSE,bExit, nFlag);
43 » » » if (bExit) return FALSE; 43 if (bExit) return FALSE;
44 » » } 44 }
45 » } 45 }
46 46
47 » return TRUE; 47 return TRUE;
48 } 48 }
49 49
50 FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWO RD nFlag) 50 FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWO RD nFlag)
51 { 51 {
52 » if (!m_pList) return FALSE; 52 if (!m_pList) return FALSE;
53 53
54 » switch (nChar) 54 switch (nChar)
55 » { 55 {
56 » default: 56 default:
57 » » return FALSE; 57 return FALSE;
58 » case FWL_VKEY_Up: 58 case FWL_VKEY_Up:
59 » case FWL_VKEY_Down: 59 case FWL_VKEY_Down:
60 » case FWL_VKEY_Home: 60 case FWL_VKEY_Home:
61 » case FWL_VKEY_Left: 61 case FWL_VKEY_Left:
62 » case FWL_VKEY_End: 62 case FWL_VKEY_End:
63 » case FWL_VKEY_Right: 63 case FWL_VKEY_Right:
64 » » break; 64 break;
65 » } 65 }
66 66
67 » switch (nChar) 67 switch (nChar)
68 » { 68 {
69 » case FWL_VKEY_Up: 69 case FWL_VKEY_Up:
70 » » m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 70 m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
71 » » break; 71 break;
72 » case FWL_VKEY_Down: 72 case FWL_VKEY_Down:
73 » » m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 73 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
74 » » break; 74 break;
75 » case FWL_VKEY_Home: 75 case FWL_VKEY_Home:
76 » » m_pList->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 76 m_pList->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
77 » » break; 77 break;
78 » case FWL_VKEY_Left: 78 case FWL_VKEY_Left:
79 » » m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 79 m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
80 » » break; 80 break;
81 » case FWL_VKEY_End: 81 case FWL_VKEY_End:
82 » » m_pList->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 82 m_pList->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
83 » » break; 83 break;
84 » case FWL_VKEY_Right: 84 case FWL_VKEY_Right:
85 » » m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 85 m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
86 » » break; 86 break;
87 » case FWL_VKEY_Delete: 87 case FWL_VKEY_Delete:
88 » » break; 88 break;
89 » } 89 }
90 90
91 » OnNotifySelChanged(TRUE,bExit, nFlag); 91 OnNotifySelChanged(TRUE,bExit, nFlag);
92 92
93 » return TRUE; 93 return TRUE;
94 } 94 }
95 95
96 FX_BOOL»CPWL_CBListBox::OnCharWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag) 96 FX_BOOL CPWL_CBListBox::OnCharWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag)
97 { 97 {
98 » if (!m_pList) return FALSE; 98 if (!m_pList) return FALSE;
99 99
100 » if (!m_pList->OnChar(nChar,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag))) return FALSE; 100 if (!m_pList->OnChar(nChar,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag))) retu rn FALSE;
101 101
102 » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) 102 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow())
103 » { 103 {
104 » » pComboBox->SetSelectText(); 104 pComboBox->SetSelectText();
105 » } 105 }
106 106
107 » OnNotifySelChanged(TRUE,bExit,nFlag); 107 OnNotifySelChanged(TRUE,bExit,nFlag);
108 108
109 » return TRUE; 109 return TRUE;
110 } 110 }
111 111
112 /* ---------------------------- CPWL_CBButton ---------------------------- */ 112 /* ---------------------------- CPWL_CBButton ---------------------------- */
113 113
114 void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) 114 void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
115 { 115 {
116 » CPWL_Wnd::GetThisAppearanceStream(sAppStream); 116 CPWL_Wnd::GetThisAppearanceStream(sAppStream);
117 117
118 » CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect(); 118 CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
119 119
120 » if (IsVisible() && !rectWnd.IsEmpty()) 120 if (IsVisible() && !rectWnd.IsEmpty())
121 » { 121 {
122 » » CFX_ByteTextBuf sButton; 122 CFX_ByteTextBuf sButton;
123 123
124 » » CPDF_Point ptCenter = GetCenterPoint(); 124 CPDF_Point ptCenter = GetCenterPoint();
125 125
126 » » CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCent er.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); 126 CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + P WL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
127 » » CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCent er.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); 127 CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + P WL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
128 » » CPDF_Point pt3(ptCenter.x,ptCenter.y - PWL_CBBUTTON_TRIANGLE_HAL FLEN * 0.5f); 128 CPDF_Point pt3(ptCenter.x,ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0 .5f);
129 129
130 » » if (IsFloatBigger(rectWnd.right - rectWnd.left,PWL_CBBUTTON_TRIA NGLE_HALFLEN * 2) 130 if (IsFloatBigger(rectWnd.right - rectWnd.left,PWL_CBBUTTON_TRIANGLE_HAL FLEN * 2)
131 » » » && 131 &&
132 » » » IsFloatBigger(rectWnd.top - rectWnd.bottom,PWL_CBBUTTON_ TRIANGLE_HALFLEN) 132 IsFloatBigger(rectWnd.top - rectWnd.bottom,PWL_CBBUTTON_TRIANGLE_HAL FLEN)
133 » » » ) 133 )
134 » » { 134 {
135 » » » sButton << "0 g\n"; 135 sButton << "0 g\n";
136 » » » sButton << pt1.x << " " << pt1.y << " m\n"; 136 sButton << pt1.x << " " << pt1.y << " m\n";
137 » » » sButton << pt2.x << " " << pt2.y << " l\n"; 137 sButton << pt2.x << " " << pt2.y << " l\n";
138 » » » sButton << pt3.x << " " << pt3.y << " l\n"; 138 sButton << pt3.x << " " << pt3.y << " l\n";
139 » » » sButton << pt1.x << " " << pt1.y << " l f\n"; 139 sButton << pt1.x << " " << pt1.y << " l f\n";
140 140
141 » » » sAppStream << "q\n" << sButton << "Q\n"; 141 sAppStream << "q\n" << sButton << "Q\n";
142 » » } 142 }
143 » } 143 }
144 } 144 }
145 145
146 void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* p User2Device) 146 void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* p User2Device)
147 { 147 {
148 » CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device); 148 CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
149 149
150 » CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect(); 150 CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
151 151
152 » if (IsVisible() && !rectWnd.IsEmpty()) 152 if (IsVisible() && !rectWnd.IsEmpty())
153 » { 153 {
154 » » CPDF_Point ptCenter = GetCenterPoint(); 154 CPDF_Point ptCenter = GetCenterPoint();
155 155
156 » » CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCent er.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); 156 CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + P WL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
157 » » CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCent er.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); 157 CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + P WL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
158 » » CPDF_Point pt3(ptCenter.x,ptCenter.y - PWL_CBBUTTON_TRIANGLE_HAL FLEN * 0.5f); 158 CPDF_Point pt3(ptCenter.x,ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0 .5f);
159 159
160 » » if (IsFloatBigger(rectWnd.right - rectWnd.left,PWL_CBBUTTON_TRIA NGLE_HALFLEN * 2) 160 if (IsFloatBigger(rectWnd.right - rectWnd.left,PWL_CBBUTTON_TRIANGLE_HAL FLEN * 2)
161 » » » && 161 &&
162 » » » IsFloatBigger(rectWnd.top - rectWnd.bottom,PWL_CBBUTTON_ TRIANGLE_HALFLEN) 162 IsFloatBigger(rectWnd.top - rectWnd.bottom,PWL_CBBUTTON_TRIANGLE_HAL FLEN)
163 » » » ) 163 )
164 » » { 164 {
165 » » » CFX_PathData path; 165 CFX_PathData path;
166 166
167 » » » path.SetPointCount(4); 167 path.SetPointCount(4);
168 » » » path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); 168 path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO);
169 » » » path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); 169 path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO);
170 » » » path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); 170 path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO);
171 » » » path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); 171 path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO);
172 172
173 » » » pDevice->DrawPath(&path, pUser2Device, NULL, 173 pDevice->DrawPath(&path, pUser2Device, NULL,
174 » » » » CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKC OLOR,GetTransparency()), 174 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR,GetTranspar ency()),
175 » » » » 0, FXFILL_ALTERNATE); 175 0, FXFILL_ALTERNATE);
176 » » } 176 }
177 » } 177 }
178 } 178 }
179 179
180 FX_BOOL»CPWL_CBButton::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag) 180 FX_BOOL CPWL_CBButton::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
181 { 181 {
182 » CPWL_Wnd::OnLButtonDown(point,nFlag); 182 CPWL_Wnd::OnLButtonDown(point,nFlag);
183 183
184 » SetCapture(); 184 SetCapture();
185 185
186 » if (CPWL_Wnd * pParent = GetParentWindow()) 186 if (CPWL_Wnd * pParent = GetParentWindow())
187 » { 187 {
188 » » pParent->OnNotify(this,PNM_LBUTTONDOWN,0,PWL_MAKEDWORD(point.x,p oint.y)); 188 pParent->OnNotify(this,PNM_LBUTTONDOWN,0,PWL_MAKEDWORD(point.x,point.y)) ;
189 » } 189 }
190 190
191 » return TRUE; 191 return TRUE;
192 } 192 }
193 193
194 FX_BOOL»CPWL_CBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag) 194 FX_BOOL CPWL_CBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
195 { 195 {
196 » CPWL_Wnd::OnLButtonUp(point, nFlag); 196 CPWL_Wnd::OnLButtonUp(point, nFlag);
197 197
198 » ReleaseCapture(); 198 ReleaseCapture();
199 199
200 » return TRUE; 200 return TRUE;
201 } 201 }
202 202
203 /* ---------------------------- CPWL_ComboBox ---------------------------- */ 203 /* ---------------------------- CPWL_ComboBox ---------------------------- */
204 204
205 CPWL_ComboBox::CPWL_ComboBox() : m_pEdit(NULL), 205 CPWL_ComboBox::CPWL_ComboBox() : m_pEdit(NULL),
206 » m_pButton(NULL), 206 m_pButton(NULL),
207 » m_pList(NULL), 207 m_pList(NULL),
208 » m_bPopup(FALSE), 208 m_bPopup(FALSE),
209 » m_nPopupWhere(0), 209 m_nPopupWhere(0),
210 » m_nSelectItem(-1), 210 m_nSelectItem(-1),
211 » m_pFillerNotify(NULL) 211 m_pFillerNotify(NULL)
212 { 212 {
213 } 213 }
214 214
215 CFX_ByteString CPWL_ComboBox::GetClassName() const 215 CFX_ByteString CPWL_ComboBox::GetClassName() const
216 { 216 {
217 » return "CPWL_ComboBox"; 217 return "CPWL_ComboBox";
218 } 218 }
219 219
220 void CPWL_ComboBox::OnCreate(PWL_CREATEPARAM & cp) 220 void CPWL_ComboBox::OnCreate(PWL_CREATEPARAM & cp)
221 { 221 {
222 » cp.dwFlags &= ~PWS_HSCROLL; 222 cp.dwFlags &= ~PWS_HSCROLL;
223 » cp.dwFlags &= ~PWS_VSCROLL; 223 cp.dwFlags &= ~PWS_VSCROLL;
224 } 224 }
225 225
226 void CPWL_ComboBox::SetFocus() 226 void CPWL_ComboBox::SetFocus()
227 { 227 {
228 » if (m_pEdit) 228 if (m_pEdit)
229 » » m_pEdit->SetFocus(); 229 m_pEdit->SetFocus();
230 } 230 }
231 231
232 void CPWL_ComboBox::KillFocus() 232 void CPWL_ComboBox::KillFocus()
233 { 233 {
234 » SetPopup(FALSE); 234 SetPopup(FALSE);
235 » CPWL_Wnd::KillFocus(); 235 CPWL_Wnd::KillFocus();
236 } 236 }
237 237
238 CFX_WideString CPWL_ComboBox::GetText() const 238 CFX_WideString CPWL_ComboBox::GetText() const
239 { 239 {
240 » if (m_pEdit) 240 if (m_pEdit)
241 » { 241 {
242 » » return m_pEdit->GetText(); 242 return m_pEdit->GetText();
243 » } 243 }
244 » return CFX_WideString(); 244 return CFX_WideString();
245 } 245 }
246 246
247 void CPWL_ComboBox::SetText(const FX_WCHAR* text) 247 void CPWL_ComboBox::SetText(const FX_WCHAR* text)
248 { 248 {
249 » if (m_pEdit) 249 if (m_pEdit)
250 » » m_pEdit->SetText(text); 250 m_pEdit->SetText(text);
251 } 251 }
252 252
253 void CPWL_ComboBox::AddString(const FX_WCHAR* string) 253 void CPWL_ComboBox::AddString(const FX_WCHAR* string)
254 { 254 {
255 » if (m_pList) 255 if (m_pList)
256 » » m_pList->AddString(string); 256 m_pList->AddString(string);
257 } 257 }
258 258
259 int32_t CPWL_ComboBox::GetSelect() const 259 int32_t CPWL_ComboBox::GetSelect() const
260 { 260 {
261 » return m_nSelectItem; 261 return m_nSelectItem;
262 } 262 }
263 263
264 void CPWL_ComboBox::SetSelect(int32_t nItemIndex) 264 void CPWL_ComboBox::SetSelect(int32_t nItemIndex)
265 { 265 {
266 » if (m_pList) 266 if (m_pList)
267 » » m_pList->Select(nItemIndex); 267 m_pList->Select(nItemIndex);
268 268
269 » m_pEdit->SetText(m_pList->GetText().c_str()); 269 m_pEdit->SetText(m_pList->GetText().c_str());
270 270
271 » m_nSelectItem = nItemIndex; 271 m_nSelectItem = nItemIndex;
272 } 272 }
273 273
274 void CPWL_ComboBox::SetEditSel(int32_t nStartChar,int32_t nEndChar) 274 void CPWL_ComboBox::SetEditSel(int32_t nStartChar,int32_t nEndChar)
275 { 275 {
276 » if (m_pEdit) 276 if (m_pEdit)
277 » { 277 {
278 » » m_pEdit->SetSel(nStartChar,nEndChar); 278 m_pEdit->SetSel(nStartChar,nEndChar);
279 » } 279 }
280 } 280 }
281 281
282 void CPWL_ComboBox::GetEditSel(int32_t & nStartChar, int32_t & nEndChar) const 282 void CPWL_ComboBox::GetEditSel(int32_t & nStartChar, int32_t & nEndChar) const
283 { 283 {
284 » nStartChar = -1; 284 nStartChar = -1;
285 » nEndChar = -1; 285 nEndChar = -1;
286 286
287 » if (m_pEdit) 287 if (m_pEdit)
288 » { 288 {
289 » » m_pEdit->GetSel(nStartChar,nEndChar); 289 m_pEdit->GetSel(nStartChar,nEndChar);
290 » } 290 }
291 } 291 }
292 292
293 void CPWL_ComboBox::Clear() 293 void CPWL_ComboBox::Clear()
294 { 294 {
295 » if (m_pEdit) 295 if (m_pEdit)
296 » { 296 {
297 » » m_pEdit->Clear(); 297 m_pEdit->Clear();
298 » } 298 }
299 } 299 }
300 300
301 void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM & cp) 301 void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM & cp)
302 { 302 {
303 » CreateEdit(cp); 303 CreateEdit(cp);
304 » CreateButton(cp); 304 CreateButton(cp);
305 » CreateListBox(cp); 305 CreateListBox(cp);
306 } 306 }
307 307
308 void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM & cp) 308 void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM & cp)
309 { 309 {
310 » if (!m_pEdit) 310 if (!m_pEdit)
311 » { 311 {
312 » » m_pEdit = new CPWL_CBEdit; 312 m_pEdit = new CPWL_CBEdit;
313 » » m_pEdit->AttachFFLData(m_pFormFiller); 313 m_pEdit->AttachFFLData(m_pFormFiller);
314 314
315 » » PWL_CREATEPARAM ecp = cp; 315 PWL_CREATEPARAM ecp = cp;
316 » » ecp.pParentWnd = this; 316 ecp.pParentWnd = this;
317 » » ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PES_CENTER | PES_AUTOSCROLL | PES_UNDO; 317 ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PES_CENTER | PES_A UTOSCROLL | PES_UNDO;
318 318
319 » » if (HasFlag(PWS_AUTOFONTSIZE)) 319 if (HasFlag(PWS_AUTOFONTSIZE))
320 » » » ecp.dwFlags |= PWS_AUTOFONTSIZE; 320 ecp.dwFlags |= PWS_AUTOFONTSIZE;
321 321
322 » » if (!HasFlag(PCBS_ALLOWCUSTOMTEXT)) 322 if (!HasFlag(PCBS_ALLOWCUSTOMTEXT))
323 » » » ecp.dwFlags |= PWS_READONLY; 323 ecp.dwFlags |= PWS_READONLY;
324 324
325 » » ecp.rcRectWnd = CPDF_Rect(0,0,0,0); 325 ecp.rcRectWnd = CPDF_Rect(0,0,0,0);
326 » » ecp.dwBorderWidth = 0; 326 ecp.dwBorderWidth = 0;
327 » » ecp.nBorderStyle = PBS_SOLID; 327 ecp.nBorderStyle = PBS_SOLID;
328 328
329 » » m_pEdit->Create(ecp); 329 m_pEdit->Create(ecp);
330 » } 330 }
331 } 331 }
332 332
333 void CPWL_ComboBox::CreateButton(const PWL_CREATEPARAM & cp) 333 void CPWL_ComboBox::CreateButton(const PWL_CREATEPARAM & cp)
334 { 334 {
335 » if (!m_pButton) 335 if (!m_pButton)
336 » { 336 {
337 » » m_pButton = new CPWL_CBButton; 337 m_pButton = new CPWL_CBButton;
338 338
339 » » PWL_CREATEPARAM bcp = cp; 339 PWL_CREATEPARAM bcp = cp;
340 » » bcp.pParentWnd = this; 340 bcp.pParentWnd = this;
341 » » bcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGRO UND; 341 bcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND;
342 » » bcp.sBackgroundColor = PWL_SCROLLBAR_BKCOLOR; 342 bcp.sBackgroundColor = PWL_SCROLLBAR_BKCOLOR;
343 » » bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR; 343 bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
344 » » bcp.dwBorderWidth = 2; 344 bcp.dwBorderWidth = 2;
345 » » bcp.nBorderStyle = PBS_BEVELED; 345 bcp.nBorderStyle = PBS_BEVELED;
346 » » bcp.eCursorType = FXCT_ARROW; 346 bcp.eCursorType = FXCT_ARROW;
347 347
348 » » m_pButton->Create(bcp); 348 m_pButton->Create(bcp);
349 » } 349 }
350 } 350 }
351 351
352 void CPWL_ComboBox::CreateListBox(const PWL_CREATEPARAM & cp) 352 void CPWL_ComboBox::CreateListBox(const PWL_CREATEPARAM & cp)
353 { 353 {
354 » if (!m_pList) 354 if (!m_pList)
355 » { 355 {
356 » » m_pList = new CPWL_CBListBox; 356 m_pList = new CPWL_CBListBox;
357 » » m_pList->AttachFFLData(m_pFormFiller); 357 m_pList->AttachFFLData(m_pFormFiller);
358 » » PWL_CREATEPARAM lcp = cp; 358 PWL_CREATEPARAM lcp = cp;
359 » » lcp.pParentWnd = this; 359 lcp.pParentWnd = this;
360 » » lcp.dwFlags = PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOV ERSEL | PWS_VSCROLL; 360 lcp.dwFlags = PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOVERSEL | PWS_VSCROLL;
361 » » lcp.nBorderStyle = PBS_SOLID; 361 lcp.nBorderStyle = PBS_SOLID;
362 » » lcp.dwBorderWidth = 1; 362 lcp.dwBorderWidth = 1;
363 » » lcp.eCursorType = FXCT_ARROW; 363 lcp.eCursorType = FXCT_ARROW;
364 » » lcp.rcRectWnd = CPDF_Rect(0,0,0,0); 364 lcp.rcRectWnd = CPDF_Rect(0,0,0,0);
365 365
366 » » if (cp.dwFlags & PWS_AUTOFONTSIZE) 366 if (cp.dwFlags & PWS_AUTOFONTSIZE)
367 » » » lcp.fFontSize = PWLCB_DEFAULTFONTSIZE; 367 lcp.fFontSize = PWLCB_DEFAULTFONTSIZE;
368 » » else 368 else
369 » » » lcp.fFontSize = cp.fFontSize; 369 lcp.fFontSize = cp.fFontSize;
370 370
371 » » if (cp.sBorderColor.nColorType == COLORTYPE_TRANSPARENT) 371 if (cp.sBorderColor.nColorType == COLORTYPE_TRANSPARENT)
372 » » » lcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR; 372 lcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
373 373
374 » » if (cp.sBackgroundColor.nColorType == COLORTYPE_TRANSPARENT) 374 if (cp.sBackgroundColor.nColorType == COLORTYPE_TRANSPARENT)
375 » » » lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; 375 lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
376 376
377 » » m_pList->Create(lcp); 377 m_pList->Create(lcp);
378 » } 378 }
379 } 379 }
380 380
381 void CPWL_ComboBox::RePosChildWnd() 381 void CPWL_ComboBox::RePosChildWnd()
382 { 382 {
383 » CPDF_Rect rcClient = GetClientRect(); 383 CPDF_Rect rcClient = GetClientRect();
384 384
385 » if (m_bPopup) 385 if (m_bPopup)
386 » { 386 {
387 » » CPDF_Rect rclient = GetClientRect(); 387 CPDF_Rect rclient = GetClientRect();
388 » » CPDF_Rect rcButton = rclient; 388 CPDF_Rect rcButton = rclient;
389 » » CPDF_Rect rcEdit = rcClient; 389 CPDF_Rect rcEdit = rcClient;
390 » » CPDF_Rect rcList = CPWL_Wnd::GetWindowRect(); 390 CPDF_Rect rcList = CPWL_Wnd::GetWindowRect();
391 391
392 » » FX_FLOAT fOldWindowHeight = m_rcOldWindow.Height(); 392 FX_FLOAT fOldWindowHeight = m_rcOldWindow.Height();
393 » » FX_FLOAT fOldClientHeight = fOldWindowHeight - GetBorderWidth() * 2; 393 FX_FLOAT fOldClientHeight = fOldWindowHeight - GetBorderWidth() * 2;
394 394
395 » » switch (m_nPopupWhere) 395 switch (m_nPopupWhere)
396 » » { 396 {
397 » » case 0: 397 case 0:
398 » » » rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WID TH; 398 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
399 399
400 » » » if (rcButton.left < rclient.left) 400 if (rcButton.left < rclient.left)
401 » » » » rcButton.left = rclient.left; 401 rcButton.left = rclient.left;
402 402
403 » » » rcButton.bottom = rcButton.top - fOldClientHeight; 403 rcButton.bottom = rcButton.top - fOldClientHeight;
404 404
405 » » » rcEdit.right = rcButton.left - 1.0f; 405 rcEdit.right = rcButton.left - 1.0f;
406 406
407 » » » if (rcEdit.left < rclient.left) 407 if (rcEdit.left < rclient.left)
408 » » » » rcEdit.left = rclient.left; 408 rcEdit.left = rclient.left;
409 409
410 » » » if (rcEdit.right < rcEdit.left) 410 if (rcEdit.right < rcEdit.left)
411 » » » » rcEdit.right = rcEdit.left; 411 rcEdit.right = rcEdit.left;
412 412
413 » » » rcEdit.bottom = rcEdit.top - fOldClientHeight; 413 rcEdit.bottom = rcEdit.top - fOldClientHeight;
414 414
415 » » » rcList.top -= fOldWindowHeight; 415 rcList.top -= fOldWindowHeight;
416 416
417 » » » break; 417 break;
418 » » case 1: 418 case 1:
419 » » » rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WID TH; 419 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
420 420
421 » » » if (rcButton.left < rclient.left) 421 if (rcButton.left < rclient.left)
422 » » » » rcButton.left = rclient.left; 422 rcButton.left = rclient.left;
423 423
424 » » » rcButton.top = rcButton.bottom + fOldClientHeight; 424 rcButton.top = rcButton.bottom + fOldClientHeight;
425 425
426 » » » rcEdit.right = rcButton.left - 1.0f; 426 rcEdit.right = rcButton.left - 1.0f;
427 427
428 » » » if (rcEdit.left < rclient.left) 428 if (rcEdit.left < rclient.left)
429 » » » » rcEdit.left = rclient.left; 429 rcEdit.left = rclient.left;
430 430
431 » » » if (rcEdit.right < rcEdit.left) 431 if (rcEdit.right < rcEdit.left)
432 » » » » rcEdit.right = rcEdit.left; 432 rcEdit.right = rcEdit.left;
433 433
434 » » » rcEdit.top = rcEdit.bottom + fOldClientHeight; 434 rcEdit.top = rcEdit.bottom + fOldClientHeight;
435 435
436 » » » rcList.bottom += fOldWindowHeight; 436 rcList.bottom += fOldWindowHeight;
437 437
438 » » » break; 438 break;
439 » » } 439 }
440 440
441 » » if (m_pButton) 441 if (m_pButton)
442 » » » m_pButton->Move(rcButton,TRUE,FALSE); 442 m_pButton->Move(rcButton,TRUE,FALSE);
443 443
444 » » if (m_pEdit) 444 if (m_pEdit)
445 » » » m_pEdit->Move(rcEdit,TRUE,FALSE); 445 m_pEdit->Move(rcEdit,TRUE,FALSE);
446 446
447 » » if (m_pList) 447 if (m_pList)
448 » » { 448 {
449 » » » m_pList->SetVisible(TRUE); 449 m_pList->SetVisible(TRUE);
450 » » » m_pList->Move(rcList,TRUE,FALSE); 450 m_pList->Move(rcList,TRUE,FALSE);
451 » » » m_pList->ScrollToListItem(m_nSelectItem); 451 m_pList->ScrollToListItem(m_nSelectItem);
452 » » } 452 }
453 » } 453 }
454 » else 454 else
455 » { 455 {
456 » » CPDF_Rect rcButton = rcClient; 456 CPDF_Rect rcButton = rcClient;
457 457
458 » » rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH; 458 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
459 459
460 » » if (rcButton.left < rcClient.left) 460 if (rcButton.left < rcClient.left)
461 » » » rcButton.left = rcClient.left; 461 rcButton.left = rcClient.left;
462 462
463 » » if (m_pButton) 463 if (m_pButton)
464 » » » m_pButton->Move(rcButton,TRUE,FALSE); 464 m_pButton->Move(rcButton,TRUE,FALSE);
465 465
466 » » CPDF_Rect rcEdit = rcClient; 466 CPDF_Rect rcEdit = rcClient;
467 » » rcEdit.right = rcButton.left - 1.0f; 467 rcEdit.right = rcButton.left - 1.0f;
468 468
469 » » if (rcEdit.left < rcClient.left) 469 if (rcEdit.left < rcClient.left)
470 » » » rcEdit.left = rcClient.left; 470 rcEdit.left = rcClient.left;
471 471
472 » » if (rcEdit.right < rcEdit.left) 472 if (rcEdit.right < rcEdit.left)
473 » » » rcEdit.right = rcEdit.left; 473 rcEdit.right = rcEdit.left;
474 474
475 » » if (m_pEdit) 475 if (m_pEdit)
476 » » » m_pEdit->Move(rcEdit,TRUE,FALSE); 476 m_pEdit->Move(rcEdit,TRUE,FALSE);
477 477
478 » » if (m_pList) 478 if (m_pList)
479 » » » m_pList->SetVisible(FALSE); 479 m_pList->SetVisible(FALSE);
480 » } 480 }
481 } 481 }
482 482
483 void CPWL_ComboBox::SelectAll() 483 void CPWL_ComboBox::SelectAll()
484 { 484 {
485 » if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT)) 485 if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT))
486 » » m_pEdit->SelectAll(); 486 m_pEdit->SelectAll();
487 } 487 }
488 488
489 CPDF_Rect CPWL_ComboBox::GetFocusRect() const 489 CPDF_Rect CPWL_ComboBox::GetFocusRect() const
490 { 490 {
491 » return CPDF_Rect(); 491 return CPDF_Rect();
492 } 492 }
493 493
494 void CPWL_ComboBox::SetPopup(FX_BOOL bPopup) 494 void CPWL_ComboBox::SetPopup(FX_BOOL bPopup)
495 { 495 {
496 if (!m_pList) return; 496 if (!m_pList) return;
497 if (bPopup == m_bPopup) return; 497 if (bPopup == m_bPopup) return;
498 FX_FLOAT fListHeight = m_pList->GetContentRect().Height(); 498 FX_FLOAT fListHeight = m_pList->GetContentRect().Height();
499 if (!IsFloatBigger(fListHeight,0.0f)) return; 499 if (!IsFloatBigger(fListHeight,0.0f)) return;
500 500
501 if (bPopup) 501 if (bPopup)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 { 593 {
594 if (bExit) return FALSE; 594 if (bExit) return FALSE;
595 SetSelectText(); 595 SetSelectText();
596 } 596 }
597 } 597 }
598 return TRUE; 598 return TRUE;
599 } 599 }
600 600
601 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) 601 if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
602 return m_pEdit->OnKeyDown(nChar,nFlag); 602 return m_pEdit->OnKeyDown(nChar,nFlag);
603 » else 603
604 » » return FALSE; 604 return FALSE;
605 } 605 }
606 606
607 FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) 607 FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag)
608 { 608 {
609 » if (!m_pList) return FALSE; 609 if (!m_pList)
610 » if (!m_pEdit) return FALSE; 610 return FALSE;
611 611
612 » m_nSelectItem = -1; 612 if (!m_pEdit)
613 » FX_BOOL bExit = FALSE; 613 return FALSE;
614 614
615 m_nSelectItem = -1;
615 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) 616 if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
616 {
617 return m_pEdit->OnChar(nChar,nFlag); 617 return m_pEdit->OnChar(nChar,nFlag);
618 }
619 else
620 {
621 if (m_pFillerNotify)
622 {
623 bExit = FALSE;
624 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit , nFlag);
625 if (bExit) return FALSE;
626 618
627 » » » bExit = FALSE; 619 FX_BOOL bExit = FALSE;
628 » » » m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExi t, nFlag); 620 if (m_pFillerNotify)
629 » » » if (bExit) return FALSE; 621 {
630 » » } 622 m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
631 » » if (m_pList->OnCharWithExit(nChar,bExit,nFlag)) 623 if (bExit)
632 » » { 624 return FALSE;
633 » » » return bExit; 625
634 » » } 626 m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
635 » » else 627 if (bExit)
636 » » » return FALSE; 628 return FALSE;
637 » } 629 }
630 if (m_pList->OnCharWithExit(nChar,bExit,nFlag))
631 return bExit;
632
633 return FALSE;
638 } 634 }
639 635
640 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intp tr_t lParam) 636 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intp tr_t lParam)
641 { 637 {
642 » switch (msg) 638 switch (msg)
643 » { 639 {
644 » case PNM_LBUTTONDOWN: 640 case PNM_LBUTTONDOWN:
645 » » if (pWnd == m_pButton) 641 if (pWnd == m_pButton)
646 » » { 642 {
647 » » » SetPopup(!m_bPopup); 643 SetPopup(!m_bPopup);
648 » » » return; 644 return;
649 » » } 645 }
650 » » break; 646 break;
651 » case PNM_LBUTTONUP: 647 case PNM_LBUTTONUP:
652 » » if (m_pEdit && m_pList) 648 if (m_pEdit && m_pList)
653 » » { 649 {
654 » » » if (pWnd == m_pList) 650 if (pWnd == m_pList)
655 » » » { 651 {
656 » » » » SetSelectText(); 652 SetSelectText();
657 » » » » SelectAll(); 653 SelectAll();
658 » » » » m_pEdit->SetFocus(); 654 m_pEdit->SetFocus();
659 » » » » SetPopup(FALSE); 655 SetPopup(FALSE);
660 » » » » return; 656 return;
661 » » » } 657 }
662 » » } 658 }
663 » } 659 }
664 660
665 » CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); 661 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
666 } 662 }
667 663
668 FX_BOOL CPWL_ComboBox::IsPopup() const 664 FX_BOOL CPWL_ComboBox::IsPopup() const
669 { 665 {
670 » return m_bPopup; 666 return m_bPopup;
671 } 667 }
672 668
673 void CPWL_ComboBox::SetSelectText() 669 void CPWL_ComboBox::SetSelectText()
674 { 670 {
675 » CFX_WideString swText = m_pList->GetText(); 671 CFX_WideString swText = m_pList->GetText();
676 » m_pEdit->SelectAll(); 672 m_pEdit->SelectAll();
677 » m_pEdit->ReplaceSel(m_pList->GetText().c_str()); 673 m_pEdit->ReplaceSel(m_pList->GetText().c_str());
678 » m_pEdit->SelectAll(); 674 m_pEdit->SelectAll();
679 675
680 » m_nSelectItem = m_pList->GetCurSel(); 676 m_nSelectItem = m_pList->GetCurSel();
681 } 677 }
682 678
683 FX_BOOL CPWL_ComboBox::IsModified() const 679 FX_BOOL CPWL_ComboBox::IsModified() const
684 { 680 {
685 » return m_pEdit->IsModified(); 681 return m_pEdit->IsModified();
686 } 682 }
687 683
688 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) 684 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify)
689 { 685 {
690 » m_pFillerNotify = pNotify; 686 m_pFillerNotify = pNotify;
691 687
692 » if (m_pEdit) 688 if (m_pEdit)
693 » » m_pEdit->SetFillerNotify(pNotify); 689 m_pEdit->SetFillerNotify(pNotify);
694 690
695 » if (m_pList) 691 if (m_pList)
696 » » m_pList->SetFillerNotify(pNotify); 692 m_pList->SetFillerNotify(pNotify);
697 } 693 }
698
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/util.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698