| 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_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 | |
| 22 | 21 |
| 23 /* ---------------------------- CPWL_CBListBox ---------------------------- */ | 22 /* ---------------------------- CPWL_CBListBox ---------------------------- */ |
| 24 | 23 |
| 25 FX_BOOL»CPWL_CBListBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag) | 24 FX_BOOL CPWL_CBListBox::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { |
| 26 { | 25 CPWL_Wnd::OnLButtonUp(point, nFlag); |
| 27 » CPWL_Wnd::OnLButtonUp(point,nFlag); | 26 |
| 28 | 27 if (m_bMouseDown) { |
| 29 » if (m_bMouseDown) | 28 ReleaseCapture(); |
| 30 » { | 29 m_bMouseDown = FALSE; |
| 31 » » ReleaseCapture(); | 30 |
| 32 » » m_bMouseDown = FALSE;» | 31 if (this->ClientHitTest(point)) { |
| 33 | 32 if (CPWL_Wnd* pParent = GetParentWindow()) { |
| 34 » » if (this->ClientHitTest(point)) | 33 pParent->OnNotify( |
| 35 » » { | 34 this, PNM_LBUTTONUP, 0, PWL_MAKEDWORD(point.x, point.y)); |
| 36 » » » if (CPWL_Wnd * pParent = GetParentWindow()) | 35 } |
| 37 » » » { | 36 |
| 38 » » » » pParent->OnNotify(this,PNM_LBUTTONUP,0,PWL_MAKED
WORD(point.x,point.y));»» » | 37 FX_BOOL bExit = FALSE; |
| 39 » » » } | 38 OnNotifySelChanged(FALSE, bExit, nFlag); |
| 40 » » | 39 if (bExit) |
| 41 » » » FX_BOOL bExit = FALSE; | 40 return FALSE; |
| 42 » » » OnNotifySelChanged(FALSE,bExit, nFlag); | 41 } |
| 43 » » » if (bExit) return FALSE; | 42 } |
| 44 » » } | 43 |
| 45 » } | 44 return TRUE; |
| 46 | 45 } |
| 47 » return TRUE; | 46 |
| 48 } | 47 FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(FX_WORD nChar, |
| 49 | 48 FX_BOOL& bExit, |
| 50 FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWO
RD nFlag) | 49 FX_DWORD nFlag) { |
| 51 { | 50 if (!m_pList) |
| 52 » if (!m_pList) return FALSE; | 51 return FALSE; |
| 53 | 52 |
| 54 » switch (nChar) | 53 switch (nChar) { |
| 55 » { | 54 default: |
| 56 » default: | 55 return FALSE; |
| 57 » » return FALSE; | 56 case FWL_VKEY_Up: |
| 58 » case FWL_VKEY_Up: | 57 case FWL_VKEY_Down: |
| 59 » case FWL_VKEY_Down: | 58 case FWL_VKEY_Home: |
| 60 » case FWL_VKEY_Home: | 59 case FWL_VKEY_Left: |
| 61 » case FWL_VKEY_Left: | 60 case FWL_VKEY_End: |
| 62 » case FWL_VKEY_End: | 61 case FWL_VKEY_Right: |
| 63 » case FWL_VKEY_Right: | 62 break; |
| 64 » » break;» | 63 } |
| 65 » } | 64 |
| 66 | 65 switch (nChar) { |
| 67 » switch (nChar) | 66 case FWL_VKEY_Up: |
| 68 » { | 67 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 69 » case FWL_VKEY_Up: | 68 break; |
| 70 » » m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); | 69 case FWL_VKEY_Down: |
| 71 » » break; | 70 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 72 » case FWL_VKEY_Down: | 71 break; |
| 73 » » m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); | 72 case FWL_VKEY_Home: |
| 74 » » break; | 73 m_pList->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 75 » case FWL_VKEY_Home: | 74 break; |
| 76 » » m_pList->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); | 75 case FWL_VKEY_Left: |
| 77 » » break; | 76 m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 78 » case FWL_VKEY_Left: | 77 break; |
| 79 » » m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); | 78 case FWL_VKEY_End: |
| 80 » » break; | 79 m_pList->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 81 » case FWL_VKEY_End: | 80 break; |
| 82 » » m_pList->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); | 81 case FWL_VKEY_Right: |
| 83 » » break; | 82 m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 84 » case FWL_VKEY_Right: | 83 break; |
| 85 » » m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); | 84 case FWL_VKEY_Delete: |
| 86 » » break; | 85 break; |
| 87 » case FWL_VKEY_Delete: | 86 } |
| 88 » » break; | 87 |
| 89 » } | 88 OnNotifySelChanged(TRUE, bExit, nFlag); |
| 90 | 89 |
| 91 » OnNotifySelChanged(TRUE,bExit, nFlag); | 90 return TRUE; |
| 92 | 91 } |
| 93 » return TRUE; | 92 |
| 94 } | 93 FX_BOOL CPWL_CBListBox::OnCharWithExit(FX_WORD nChar, |
| 95 | 94 FX_BOOL& bExit, |
| 96 FX_BOOL»CPWL_CBListBox::OnCharWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD
nFlag) | 95 FX_DWORD nFlag) { |
| 97 { | 96 if (!m_pList) |
| 98 » if (!m_pList) return FALSE; | 97 return FALSE; |
| 99 | 98 |
| 100 » if (!m_pList->OnChar(nChar,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)))
return FALSE; | 99 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag))) |
| 101 | 100 return FALSE; |
| 102 » if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) | 101 |
| 103 » { | 102 if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) { |
| 104 » » pComboBox->SetSelectText(); | 103 pComboBox->SetSelectText(); |
| 105 » } | 104 } |
| 106 | 105 |
| 107 » OnNotifySelChanged(TRUE,bExit,nFlag); | 106 OnNotifySelChanged(TRUE, bExit, nFlag); |
| 108 | 107 |
| 109 » return TRUE; | 108 return TRUE; |
| 110 } | 109 } |
| 111 | 110 |
| 112 /* ---------------------------- CPWL_CBButton ---------------------------- */ | 111 /* ---------------------------- CPWL_CBButton ---------------------------- */ |
| 113 | 112 |
| 114 void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) | 113 void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
| 115 { | 114 CPWL_Wnd::GetThisAppearanceStream(sAppStream); |
| 116 » CPWL_Wnd::GetThisAppearanceStream(sAppStream); | 115 |
| 117 » | 116 CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect(); |
| 118 » CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect(); | 117 |
| 119 » | 118 if (IsVisible() && !rectWnd.IsEmpty()) { |
| 120 » if (IsVisible() && !rectWnd.IsEmpty()) | 119 CFX_ByteTextBuf sButton; |
| 121 » { | 120 |
| 122 » » CFX_ByteTextBuf sButton;» | 121 CPDF_Point ptCenter = this->GetCenterPoint(); |
| 123 | 122 |
| 124 » » CPDF_Point ptCenter = this->GetCenterPoint(); | 123 CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN, |
| 125 | 124 ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); |
| 126 » » CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCent
er.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); | 125 CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN, |
| 127 » » CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCent
er.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); | 126 ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); |
| 128 » » CPDF_Point pt3(ptCenter.x,ptCenter.y - PWL_CBBUTTON_TRIANGLE_HAL
FLEN * 0.5f); | 127 CPDF_Point pt3(ptCenter.x, |
| 129 | 128 ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); |
| 130 » » if (IsFloatBigger(rectWnd.right - rectWnd.left,PWL_CBBUTTON_TRIA
NGLE_HALFLEN * 2) | 129 |
| 131 » » » && | 130 if (IsFloatBigger(rectWnd.right - rectWnd.left, |
| 132 » » » IsFloatBigger(rectWnd.top - rectWnd.bottom,PWL_CBBUTTON_
TRIANGLE_HALFLEN) | 131 PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) && |
| 133 » » » ) | 132 IsFloatBigger(rectWnd.top - rectWnd.bottom, |
| 134 » » { | 133 PWL_CBBUTTON_TRIANGLE_HALFLEN)) { |
| 135 » » » sButton << "0 g\n"; | 134 sButton << "0 g\n"; |
| 136 » » » sButton << pt1.x << " " << pt1.y << " m\n"; | 135 sButton << pt1.x << " " << pt1.y << " m\n"; |
| 137 » » » sButton << pt2.x << " " << pt2.y << " l\n"; | 136 sButton << pt2.x << " " << pt2.y << " l\n"; |
| 138 » » » sButton << pt3.x << " " << pt3.y << " l\n"; | 137 sButton << pt3.x << " " << pt3.y << " l\n"; |
| 139 » » » sButton << pt1.x << " " << pt1.y << " l f\n"; | 138 sButton << pt1.x << " " << pt1.y << " l f\n"; |
| 140 | 139 |
| 141 » » » sAppStream << "q\n" << sButton << "Q\n"; | 140 sAppStream << "q\n" << sButton << "Q\n"; |
| 142 » » }» | 141 } |
| 143 » } | 142 } |
| 144 } | 143 } |
| 145 | 144 |
| 146 void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* p
User2Device) | 145 void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, |
| 147 { | 146 CPDF_Matrix* pUser2Device) { |
| 148 » CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device); | 147 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); |
| 149 | 148 |
| 150 » CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect(); | 149 CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect(); |
| 151 » | 150 |
| 152 » if (IsVisible() && !rectWnd.IsEmpty()) | 151 if (IsVisible() && !rectWnd.IsEmpty()) { |
| 153 » { | 152 CPDF_Point ptCenter = this->GetCenterPoint(); |
| 154 » » CPDF_Point ptCenter = this->GetCenterPoint(); | 153 |
| 155 | 154 CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN, |
| 156 » » CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCent
er.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); | 155 ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); |
| 157 » » CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCent
er.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); | 156 CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN, |
| 158 » » CPDF_Point pt3(ptCenter.x,ptCenter.y - PWL_CBBUTTON_TRIANGLE_HAL
FLEN * 0.5f); | 157 ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); |
| 159 | 158 CPDF_Point pt3(ptCenter.x, |
| 160 » » if (IsFloatBigger(rectWnd.right - rectWnd.left,PWL_CBBUTTON_TRIA
NGLE_HALFLEN * 2) | 159 ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f); |
| 161 » » » && | 160 |
| 162 » » » IsFloatBigger(rectWnd.top - rectWnd.bottom,PWL_CBBUTTON_
TRIANGLE_HALFLEN) | 161 if (IsFloatBigger(rectWnd.right - rectWnd.left, |
| 163 » » » ) | 162 PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) && |
| 164 » » { | 163 IsFloatBigger(rectWnd.top - rectWnd.bottom, |
| 165 » » » CFX_PathData path; | 164 PWL_CBBUTTON_TRIANGLE_HALFLEN)) { |
| 166 | 165 CFX_PathData path; |
| 167 » » » path.SetPointCount(4); | 166 |
| 168 » » » path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); | 167 path.SetPointCount(4); |
| 169 » » » path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); | 168 path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); |
| 170 » » » path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); | 169 path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); |
| 171 » » » path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); | 170 path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); |
| 172 | 171 path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); |
| 173 » » » pDevice->DrawPath(&path, pUser2Device, NULL, | 172 |
| 174 » » » » CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKC
OLOR,GetTransparency()), | 173 pDevice->DrawPath(&path, |
| 175 » » » » 0, FXFILL_ALTERNATE); | 174 pUser2Device, |
| 176 » » } | 175 NULL, |
| 177 » } | 176 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR, |
| 178 } | 177 GetTransparency()), |
| 179 | 178 0, |
| 180 FX_BOOL»CPWL_CBButton::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag) | 179 FXFILL_ALTERNATE); |
| 181 { | 180 } |
| 182 » CPWL_Wnd::OnLButtonDown(point,nFlag); | 181 } |
| 183 | 182 } |
| 184 » SetCapture(); | 183 |
| 185 | 184 FX_BOOL CPWL_CBButton::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) { |
| 186 » if (CPWL_Wnd * pParent = GetParentWindow()) | 185 CPWL_Wnd::OnLButtonDown(point, nFlag); |
| 187 » {» » | 186 |
| 188 » » pParent->OnNotify(this,PNM_LBUTTONDOWN,0,PWL_MAKEDWORD(point.x,p
oint.y)); | 187 SetCapture(); |
| 189 » } | 188 |
| 190 » | 189 if (CPWL_Wnd* pParent = GetParentWindow()) { |
| 191 » return TRUE; | 190 pParent->OnNotify( |
| 192 } | 191 this, PNM_LBUTTONDOWN, 0, PWL_MAKEDWORD(point.x, point.y)); |
| 193 | 192 } |
| 194 FX_BOOL»CPWL_CBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag) | 193 |
| 195 { | 194 return TRUE; |
| 196 » CPWL_Wnd::OnLButtonUp(point, nFlag); | 195 } |
| 197 | 196 |
| 198 » ReleaseCapture(); | 197 FX_BOOL CPWL_CBButton::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { |
| 199 | 198 CPWL_Wnd::OnLButtonUp(point, nFlag); |
| 200 » return TRUE; | 199 |
| 200 ReleaseCapture(); |
| 201 |
| 202 return TRUE; |
| 201 } | 203 } |
| 202 | 204 |
| 203 /* ---------------------------- CPWL_ComboBox ---------------------------- */ | 205 /* ---------------------------- CPWL_ComboBox ---------------------------- */ |
| 204 | 206 |
| 205 CPWL_ComboBox::CPWL_ComboBox() : m_pEdit(NULL), | 207 CPWL_ComboBox::CPWL_ComboBox() |
| 206 m_pButton(NULL), | 208 : m_pEdit(NULL), |
| 207 m_pList(NULL), | 209 m_pButton(NULL), |
| 208 m_bPopup(FALSE), | 210 m_pList(NULL), |
| 209 m_nPopupWhere(0), | 211 m_bPopup(FALSE), |
| 210 m_nSelectItem(-1), | 212 m_nPopupWhere(0), |
| 211 m_pFillerNotify(NULL) | 213 m_nSelectItem(-1), |
| 212 { | 214 m_pFillerNotify(NULL) { |
| 213 } | 215 } |
| 214 | 216 |
| 215 CFX_ByteString CPWL_ComboBox::GetClassName() const | 217 CFX_ByteString CPWL_ComboBox::GetClassName() const { |
| 216 { | 218 return "CPWL_ComboBox"; |
| 217 return "CPWL_ComboBox"; | 219 } |
| 218 } | 220 |
| 219 | 221 void CPWL_ComboBox::OnCreate(PWL_CREATEPARAM& cp) { |
| 220 void CPWL_ComboBox::OnCreate(PWL_CREATEPARAM & cp) | 222 cp.dwFlags &= ~PWS_HSCROLL; |
| 221 { | 223 cp.dwFlags &= ~PWS_VSCROLL; |
| 222 cp.dwFlags &= ~PWS_HSCROLL; | 224 } |
| 223 cp.dwFlags &= ~PWS_VSCROLL; | 225 |
| 224 } | 226 void CPWL_ComboBox::SetFocus() { |
| 225 | 227 if (m_pEdit) |
| 226 void CPWL_ComboBox::SetFocus() | 228 m_pEdit->SetFocus(); |
| 227 { | 229 } |
| 228 if (m_pEdit) | 230 |
| 229 m_pEdit->SetFocus(); | 231 void CPWL_ComboBox::KillFocus() { |
| 230 } | 232 SetPopup(FALSE); |
| 231 | 233 CPWL_Wnd::KillFocus(); |
| 232 void CPWL_ComboBox::KillFocus() | 234 } |
| 233 { | 235 |
| 234 SetPopup(FALSE); | 236 CFX_WideString CPWL_ComboBox::GetText() const { |
| 235 CPWL_Wnd::KillFocus(); | 237 if (m_pEdit) { |
| 236 } | 238 return m_pEdit->GetText(); |
| 237 | 239 } |
| 238 CFX_WideString CPWL_ComboBox::GetText() const | 240 return CFX_WideString(); |
| 239 { | 241 } |
| 240 if (m_pEdit) | 242 |
| 241 { | 243 void CPWL_ComboBox::SetText(FX_LPCWSTR text) { |
| 242 return m_pEdit->GetText(); | 244 if (m_pEdit) |
| 243 } | 245 m_pEdit->SetText(text); |
| 244 return CFX_WideString(); | 246 } |
| 245 } | 247 |
| 246 | 248 void CPWL_ComboBox::AddString(FX_LPCWSTR string) { |
| 247 void CPWL_ComboBox::SetText(FX_LPCWSTR text) | 249 if (m_pList) |
| 248 { | 250 m_pList->AddString(string); |
| 249 if (m_pEdit) | 251 } |
| 250 m_pEdit->SetText(text); | 252 |
| 251 } | 253 FX_INT32 CPWL_ComboBox::GetSelect() const { |
| 252 | 254 return m_nSelectItem; |
| 253 void CPWL_ComboBox::AddString(FX_LPCWSTR string) | 255 } |
| 254 { | 256 |
| 255 if (m_pList) | 257 void CPWL_ComboBox::SetSelect(FX_INT32 nItemIndex) { |
| 256 m_pList->AddString(string); | 258 if (m_pList) |
| 257 } | 259 m_pList->Select(nItemIndex); |
| 258 | 260 |
| 259 FX_INT32 CPWL_ComboBox::GetSelect() const | 261 m_pEdit->SetText(m_pList->GetText()); |
| 260 { | 262 |
| 261 return m_nSelectItem; | 263 m_nSelectItem = nItemIndex; |
| 262 } | 264 } |
| 263 | 265 |
| 264 void CPWL_ComboBox::SetSelect(FX_INT32 nItemIndex) | 266 void CPWL_ComboBox::SetEditSel(FX_INT32 nStartChar, FX_INT32 nEndChar) { |
| 265 { | 267 if (m_pEdit) { |
| 266 if (m_pList) | 268 m_pEdit->SetSel(nStartChar, nEndChar); |
| 267 m_pList->Select(nItemIndex); | 269 } |
| 268 | 270 } |
| 269 m_pEdit->SetText(m_pList->GetText()); | 271 |
| 270 | 272 void CPWL_ComboBox::GetEditSel(FX_INT32& nStartChar, FX_INT32& nEndChar) const { |
| 271 m_nSelectItem = nItemIndex; | 273 nStartChar = -1; |
| 272 } | 274 nEndChar = -1; |
| 273 | 275 |
| 274 void CPWL_ComboBox::SetEditSel(FX_INT32 nStartChar,FX_INT32 nEndChar) | 276 if (m_pEdit) { |
| 275 { | 277 m_pEdit->GetSel(nStartChar, nEndChar); |
| 276 if (m_pEdit) | 278 } |
| 277 { | 279 } |
| 278 m_pEdit->SetSel(nStartChar,nEndChar); | 280 |
| 279 } | 281 void CPWL_ComboBox::Clear() { |
| 280 } | 282 if (m_pEdit) { |
| 281 | 283 m_pEdit->Clear(); |
| 282 void CPWL_ComboBox::GetEditSel(FX_INT32 & nStartChar, FX_INT32 & nEndChar) const | 284 } |
| 283 { | 285 } |
| 284 nStartChar = -1; | 286 |
| 285 nEndChar = -1; | 287 void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM& cp) { |
| 286 | 288 CreateEdit(cp); |
| 287 if (m_pEdit) | 289 CreateButton(cp); |
| 288 { | 290 CreateListBox(cp); |
| 289 m_pEdit->GetSel(nStartChar,nEndChar); | 291 } |
| 290 } | 292 |
| 291 } | 293 void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM& cp) { |
| 292 | 294 if (!m_pEdit) { |
| 293 void CPWL_ComboBox::Clear() | 295 m_pEdit = new CPWL_CBEdit; |
| 294 { | 296 m_pEdit->AttachFFLData(m_pFormFiller); |
| 295 if (m_pEdit) | 297 |
| 296 { | 298 PWL_CREATEPARAM ecp = cp; |
| 297 m_pEdit->Clear(); | 299 ecp.pParentWnd = this; |
| 298 } | 300 ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PES_CENTER | |
| 299 } | 301 PES_AUTOSCROLL | PES_UNDO; |
| 300 | 302 |
| 301 void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM & cp) | 303 if (HasFlag(PWS_AUTOFONTSIZE)) |
| 302 { | 304 ecp.dwFlags |= PWS_AUTOFONTSIZE; |
| 303 CreateEdit(cp); | 305 |
| 304 CreateButton(cp); | 306 if (!HasFlag(PCBS_ALLOWCUSTOMTEXT)) |
| 305 CreateListBox(cp); | 307 ecp.dwFlags |= PWS_READONLY; |
| 306 } | 308 |
| 307 | 309 ecp.rcRectWnd = CPDF_Rect(0, 0, 0, 0); |
| 308 void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM & cp) | 310 ecp.dwBorderWidth = 0; |
| 309 { | 311 ecp.nBorderStyle = PBS_SOLID; |
| 310 if (!m_pEdit) | 312 |
| 311 { | 313 m_pEdit->Create(ecp); |
| 312 m_pEdit = new CPWL_CBEdit; | 314 } |
| 313 m_pEdit->AttachFFLData(m_pFormFiller); | 315 } |
| 314 | 316 |
| 315 PWL_CREATEPARAM ecp = cp; | 317 void CPWL_ComboBox::CreateButton(const PWL_CREATEPARAM& cp) { |
| 316 ecp.pParentWnd = this; | 318 if (!m_pButton) { |
| 317 ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PES_CENTER
| PES_AUTOSCROLL | PES_UNDO; | 319 m_pButton = new CPWL_CBButton; |
| 318 | 320 |
| 319 if (HasFlag(PWS_AUTOFONTSIZE)) | 321 PWL_CREATEPARAM bcp = cp; |
| 320 ecp.dwFlags |= PWS_AUTOFONTSIZE; | 322 bcp.pParentWnd = this; |
| 321 | 323 bcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND; |
| 322 if (!HasFlag(PCBS_ALLOWCUSTOMTEXT)) | 324 bcp.sBackgroundColor = PWL_SCROLLBAR_BKCOLOR; |
| 323 ecp.dwFlags |= PWS_READONLY; | 325 bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR; |
| 324 | 326 bcp.dwBorderWidth = 2; |
| 325 ecp.rcRectWnd = CPDF_Rect(0,0,0,0); | 327 bcp.nBorderStyle = PBS_BEVELED; |
| 326 ecp.dwBorderWidth = 0; | 328 bcp.eCursorType = FXCT_ARROW; |
| 327 ecp.nBorderStyle = PBS_SOLID; | 329 |
| 328 | 330 m_pButton->Create(bcp); |
| 329 m_pEdit->Create(ecp); | 331 } |
| 330 } | 332 } |
| 331 } | 333 |
| 332 | 334 void CPWL_ComboBox::CreateListBox(const PWL_CREATEPARAM& cp) { |
| 333 void CPWL_ComboBox::CreateButton(const PWL_CREATEPARAM & cp) | 335 if (!m_pList) { |
| 334 { | 336 m_pList = new CPWL_CBListBox; |
| 335 if (!m_pButton) | 337 m_pList->AttachFFLData(m_pFormFiller); |
| 336 { | 338 PWL_CREATEPARAM lcp = cp; |
| 337 m_pButton = new CPWL_CBButton; | 339 lcp.pParentWnd = this; |
| 338 | 340 lcp.dwFlags = |
| 339 PWL_CREATEPARAM bcp = cp; | 341 PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOVERSEL | PWS_VSCROLL; |
| 340 bcp.pParentWnd = this; | 342 lcp.nBorderStyle = PBS_SOLID; |
| 341 bcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGRO
UND; | 343 lcp.dwBorderWidth = 1; |
| 342 bcp.sBackgroundColor = PWL_SCROLLBAR_BKCOLOR; | 344 lcp.eCursorType = FXCT_ARROW; |
| 343 bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR; | 345 lcp.rcRectWnd = CPDF_Rect(0, 0, 0, 0); |
| 344 bcp.dwBorderWidth = 2; | 346 |
| 345 bcp.nBorderStyle = PBS_BEVELED; | 347 if (cp.dwFlags & PWS_AUTOFONTSIZE) |
| 346 bcp.eCursorType = FXCT_ARROW; | 348 lcp.fFontSize = PWLCB_DEFAULTFONTSIZE; |
| 347 | 349 else |
| 348 m_pButton->Create(bcp); | 350 lcp.fFontSize = cp.fFontSize; |
| 349 } | 351 |
| 350 } | 352 if (cp.sBorderColor.nColorType == COLORTYPE_TRANSPARENT) |
| 351 | 353 lcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR; |
| 352 void CPWL_ComboBox::CreateListBox(const PWL_CREATEPARAM & cp) | 354 |
| 353 { | 355 if (cp.sBackgroundColor.nColorType == COLORTYPE_TRANSPARENT) |
| 354 if (!m_pList) | 356 lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; |
| 355 { | 357 |
| 356 m_pList = new CPWL_CBListBox; | 358 m_pList->Create(lcp); |
| 357 m_pList->AttachFFLData(m_pFormFiller); | 359 } |
| 358 PWL_CREATEPARAM lcp = cp; | 360 } |
| 359 lcp.pParentWnd = this; | 361 |
| 360 lcp.dwFlags = PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOV
ERSEL | PWS_VSCROLL; | 362 void CPWL_ComboBox::RePosChildWnd() { |
| 361 lcp.nBorderStyle = PBS_SOLID; | 363 CPDF_Rect rcClient = GetClientRect(); |
| 362 lcp.dwBorderWidth = 1; | 364 |
| 363 lcp.eCursorType = FXCT_ARROW; | 365 if (m_bPopup) { |
| 364 lcp.rcRectWnd = CPDF_Rect(0,0,0,0); | 366 CPDF_Rect rclient = GetClientRect(); |
| 365 | 367 CPDF_Rect rcButton = rclient; |
| 366 if (cp.dwFlags & PWS_AUTOFONTSIZE) | 368 CPDF_Rect rcEdit = rcClient; |
| 367 lcp.fFontSize = PWLCB_DEFAULTFONTSIZE; | 369 CPDF_Rect rcList = CPWL_Wnd::GetWindowRect(); |
| 368 else | 370 |
| 369 lcp.fFontSize = cp.fFontSize; | 371 FX_FLOAT fOldWindowHeight = m_rcOldWindow.Height(); |
| 370 | 372 FX_FLOAT fOldClientHeight = fOldWindowHeight - GetBorderWidth() * 2; |
| 371 if (cp.sBorderColor.nColorType == COLORTYPE_TRANSPARENT) | 373 |
| 372 lcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR; | 374 switch (m_nPopupWhere) { |
| 373 | 375 case 0: |
| 374 if (cp.sBackgroundColor.nColorType == COLORTYPE_TRANSPARENT) | 376 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH; |
| 375 lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; | 377 |
| 376 | 378 if (rcButton.left < rclient.left) |
| 377 m_pList->Create(lcp); | 379 rcButton.left = rclient.left; |
| 378 } | 380 |
| 379 } | 381 rcButton.bottom = rcButton.top - fOldClientHeight; |
| 380 | 382 |
| 381 void CPWL_ComboBox::RePosChildWnd() | 383 rcEdit.right = rcButton.left - 1.0f; |
| 382 { | 384 |
| 383 CPDF_Rect rcClient = GetClientRect(); | 385 if (rcEdit.left < rclient.left) |
| 384 | 386 rcEdit.left = rclient.left; |
| 385 if (m_bPopup) | 387 |
| 386 { | 388 if (rcEdit.right < rcEdit.left) |
| 387 CPDF_Rect rclient = GetClientRect(); | 389 rcEdit.right = rcEdit.left; |
| 388 CPDF_Rect rcButton = rclient; | 390 |
| 389 CPDF_Rect rcEdit = rcClient; | 391 rcEdit.bottom = rcEdit.top - fOldClientHeight; |
| 390 CPDF_Rect rcList = CPWL_Wnd::GetWindowRect(); | 392 |
| 391 | 393 rcList.top -= fOldWindowHeight; |
| 392 FX_FLOAT fOldWindowHeight = m_rcOldWindow.Height(); | 394 |
| 393 FX_FLOAT fOldClientHeight = fOldWindowHeight - GetBorderWidth()
* 2; | 395 break; |
| 394 | 396 case 1: |
| 395 switch (m_nPopupWhere) | 397 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH; |
| 396 { | 398 |
| 397 case 0: | 399 if (rcButton.left < rclient.left) |
| 398 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WID
TH; | 400 rcButton.left = rclient.left; |
| 399 | 401 |
| 400 if (rcButton.left < rclient.left) | 402 rcButton.top = rcButton.bottom + fOldClientHeight; |
| 401 rcButton.left = rclient.left; | 403 |
| 402 | 404 rcEdit.right = rcButton.left - 1.0f; |
| 403 rcButton.bottom = rcButton.top - fOldClientHeight; | 405 |
| 404 | 406 if (rcEdit.left < rclient.left) |
| 405 rcEdit.right = rcButton.left - 1.0f; | 407 rcEdit.left = rclient.left; |
| 406 | 408 |
| 407 if (rcEdit.left < rclient.left) | 409 if (rcEdit.right < rcEdit.left) |
| 408 rcEdit.left = rclient.left; | 410 rcEdit.right = rcEdit.left; |
| 409 | 411 |
| 410 if (rcEdit.right < rcEdit.left) | 412 rcEdit.top = rcEdit.bottom + fOldClientHeight; |
| 411 rcEdit.right = rcEdit.left; | 413 |
| 412 | 414 rcList.bottom += fOldWindowHeight; |
| 413 rcEdit.bottom = rcEdit.top - fOldClientHeight; | 415 |
| 414 | 416 break; |
| 415 rcList.top -= fOldWindowHeight; | 417 } |
| 416 | 418 |
| 417 break; | 419 if (m_pButton) |
| 418 case 1: | 420 m_pButton->Move(rcButton, TRUE, FALSE); |
| 419 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WID
TH; | 421 |
| 420 | 422 if (m_pEdit) |
| 421 if (rcButton.left < rclient.left) | 423 m_pEdit->Move(rcEdit, TRUE, FALSE); |
| 422 rcButton.left = rclient.left; | 424 |
| 423 | 425 if (m_pList) { |
| 424 rcButton.top = rcButton.bottom + fOldClientHeight; | 426 m_pList->SetVisible(TRUE); |
| 425 | 427 m_pList->Move(rcList, TRUE, FALSE); |
| 426 rcEdit.right = rcButton.left - 1.0f; | 428 m_pList->ScrollToListItem(m_nSelectItem); |
| 427 | 429 } |
| 428 if (rcEdit.left < rclient.left) | 430 } else { |
| 429 rcEdit.left = rclient.left; | 431 CPDF_Rect rcButton = rcClient; |
| 430 | 432 |
| 431 if (rcEdit.right < rcEdit.left) | 433 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH; |
| 432 rcEdit.right = rcEdit.left; | 434 |
| 433 | 435 if (rcButton.left < rcClient.left) |
| 434 rcEdit.top = rcEdit.bottom + fOldClientHeight; | 436 rcButton.left = rcClient.left; |
| 435 | 437 |
| 436 rcList.bottom += fOldWindowHeight; | 438 if (m_pButton) |
| 437 | 439 m_pButton->Move(rcButton, TRUE, FALSE); |
| 438 break; | 440 |
| 439 } | 441 CPDF_Rect rcEdit = rcClient; |
| 440 | 442 rcEdit.right = rcButton.left - 1.0f; |
| 441 if (m_pButton) | 443 |
| 442 m_pButton->Move(rcButton,TRUE,FALSE); | 444 if (rcEdit.left < rcClient.left) |
| 443 | 445 rcEdit.left = rcClient.left; |
| 444 if (m_pEdit) | 446 |
| 445 m_pEdit->Move(rcEdit,TRUE,FALSE); | 447 if (rcEdit.right < rcEdit.left) |
| 446 | 448 rcEdit.right = rcEdit.left; |
| 447 if (m_pList) | 449 |
| 448 { | 450 if (m_pEdit) |
| 449 m_pList->SetVisible(TRUE); | 451 m_pEdit->Move(rcEdit, TRUE, FALSE); |
| 450 m_pList->Move(rcList,TRUE,FALSE); | 452 |
| 451 m_pList->ScrollToListItem(m_nSelectItem); | 453 if (m_pList) |
| 452 } | 454 m_pList->SetVisible(FALSE); |
| 453 } | 455 } |
| 454 else | 456 } |
| 455 { | 457 |
| 456 CPDF_Rect rcButton = rcClient; | 458 void CPWL_ComboBox::SelectAll() { |
| 457 | 459 if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT)) |
| 458 rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH; | 460 m_pEdit->SelectAll(); |
| 459 | 461 } |
| 460 if (rcButton.left < rcClient.left) | 462 |
| 461 rcButton.left = rcClient.left; | 463 CPDF_Rect CPWL_ComboBox::GetFocusRect() const { |
| 462 | 464 return CPDF_Rect(); |
| 463 if (m_pButton) | 465 } |
| 464 m_pButton->Move(rcButton,TRUE,FALSE); | 466 |
| 465 | 467 void CPWL_ComboBox::SetPopup(FX_BOOL bPopup) { |
| 466 CPDF_Rect rcEdit = rcClient; | 468 if (!m_pList) |
| 467 rcEdit.right = rcButton.left - 1.0f; | 469 return; |
| 468 | 470 if (bPopup == m_bPopup) |
| 469 if (rcEdit.left < rcClient.left) | 471 return; |
| 470 rcEdit.left = rcClient.left; | 472 FX_FLOAT fListHeight = m_pList->GetContentRect().Height(); |
| 471 | 473 if (!IsFloatBigger(fListHeight, 0.0f)) |
| 472 if (rcEdit.right < rcEdit.left) | 474 return; |
| 473 rcEdit.right = rcEdit.left; | 475 |
| 474 | 476 if (bPopup) { |
| 475 if (m_pEdit) | 477 if (m_pFillerNotify) { |
| 476 m_pEdit->Move(rcEdit,TRUE,FALSE); | 478 FX_INT32 nWhere = 0; |
| 477 | 479 FX_FLOAT fPopupRet = 0.0f; |
| 478 if (m_pList) | 480 FX_FLOAT fPopupMin = 0.0f; |
| 479 m_pList->SetVisible(FALSE); | 481 if (m_pList->GetCount() > 3) |
| 480 } | 482 fPopupMin = |
| 481 } | 483 m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2; |
| 482 | 484 FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWidth() * 2; |
| 483 void CPWL_ComboBox::SelectAll() | 485 m_pFillerNotify->QueryWherePopup( |
| 484 { | 486 GetAttachedData(), fPopupMin, fPopupMax, nWhere, fPopupRet); |
| 485 if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT)) | 487 |
| 486 m_pEdit->SelectAll(); | 488 if (IsFloatBigger(fPopupRet, 0.0f)) { |
| 487 } | 489 m_bPopup = bPopup; |
| 488 | 490 |
| 489 CPDF_Rect CPWL_ComboBox::GetFocusRect() const | 491 CPDF_Rect rcWindow = CPWL_Wnd::GetWindowRect(); |
| 490 { | 492 m_rcOldWindow = rcWindow; |
| 491 return CPDF_Rect(); | 493 switch (nWhere) { |
| 492 } | 494 default: |
| 493 | 495 case 0: |
| 494 void CPWL_ComboBox::SetPopup(FX_BOOL bPopup) | 496 rcWindow.bottom -= fPopupRet; |
| 495 { | 497 break; |
| 496 if (!m_pList) return; | 498 case 1: |
| 497 if (bPopup == m_bPopup) return; | 499 rcWindow.top += fPopupRet; |
| 498 FX_FLOAT fListHeight = m_pList->GetContentRect().Height(); | 500 break; |
| 499 if (!IsFloatBigger(fListHeight,0.0f)) return; | 501 } |
| 500 | 502 |
| 501 if (bPopup) | 503 m_nPopupWhere = nWhere; |
| 502 { | 504 Move(rcWindow, TRUE, TRUE); |
| 503 if (m_pFillerNotify) | 505 } |
| 504 { | 506 } |
| 505 FX_INT32 nWhere = 0; | 507 } else { |
| 506 FX_FLOAT fPopupRet = 0.0f; | 508 m_bPopup = bPopup; |
| 507 FX_FLOAT fPopupMin = 0.0f; | 509 Move(m_rcOldWindow, TRUE, TRUE); |
| 508 if (m_pList->GetCount() > 3) | 510 } |
| 509 fPopupMin = m_pList->GetFirstHeight() * 3 + m_pL
ist->GetBorderWidth() * 2; | 511 } |
| 510 FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWid
th() * 2; | 512 |
| 511 m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPop
upMin,fPopupMax,nWhere,fPopupRet); | 513 FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) { |
| 512 | 514 if (!m_pList) |
| 513 if (IsFloatBigger(fPopupRet,0.0f)) | 515 return FALSE; |
| 514 { | 516 if (!m_pEdit) |
| 515 m_bPopup = bPopup; | 517 return FALSE; |
| 516 | 518 |
| 517 CPDF_Rect rcWindow = CPWL_Wnd::GetWindowRect(); | 519 m_nSelectItem = -1; |
| 518 m_rcOldWindow = rcWindow; | 520 |
| 519 switch (nWhere) | 521 switch (nChar) { |
| 520 { | 522 case FWL_VKEY_Up: |
| 521 default: | 523 if (m_pList->GetCurSel() > 0) { |
| 522 case 0: | 524 FX_BOOL bExit = FALSE; |
| 523 rcWindow.bottom -= fPopupRet; | 525 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { |
| 524 break; | 526 if (bExit) |
| 525 case 1: | 527 return FALSE; |
| 526 rcWindow.top += fPopupRet; | 528 SetSelectText(); |
| 527 break; | 529 } |
| 528 } | 530 } |
| 529 | 531 return TRUE; |
| 530 m_nPopupWhere = nWhere; | 532 case FWL_VKEY_Down: |
| 531 Move(rcWindow, TRUE, TRUE); | 533 if (m_pList->GetCurSel() < m_pList->GetCount() - 1) { |
| 532 } | 534 FX_BOOL bExit = FALSE; |
| 533 } | 535 if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { |
| 534 } | 536 if (bExit) |
| 535 else | 537 return FALSE; |
| 536 { | 538 SetSelectText(); |
| 537 m_bPopup = bPopup; | 539 } |
| 538 Move(m_rcOldWindow, TRUE, TRUE); | 540 } |
| 539 } | 541 return TRUE; |
| 540 } | 542 } |
| 541 | 543 |
| 542 FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) | 544 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) |
| 543 { | 545 return m_pEdit->OnKeyDown(nChar, nFlag); |
| 544 if (!m_pList) return FALSE; | 546 else |
| 545 if (!m_pEdit) return FALSE; | 547 return FALSE; |
| 546 | 548 } |
| 547 m_nSelectItem = -1; | 549 |
| 548 | 550 FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) { |
| 549 switch (nChar) | 551 if (!m_pList) |
| 550 { | 552 return FALSE; |
| 551 case FWL_VKEY_Up: | 553 if (!m_pEdit) |
| 552 if (m_pList->GetCurSel() > 0) | 554 return FALSE; |
| 553 { | 555 |
| 554 FX_BOOL bExit = FALSE; | 556 m_nSelectItem = -1; |
| 555 if (m_pList->OnKeyDownWithExit(nChar,bExit,nFlag)) | 557 FX_BOOL bExit = FALSE; |
| 556 { | 558 |
| 557 if (bExit) return FALSE; | 559 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) { |
| 558 SetSelectText(); | 560 return m_pEdit->OnChar(nChar, nFlag); |
| 559 } | 561 } else { |
| 560 } | 562 if (m_pList->OnCharWithExit(nChar, bExit, nFlag)) { |
| 561 return TRUE; | 563 return bExit; |
| 562 case FWL_VKEY_Down: | 564 } else |
| 563 if (m_pList->GetCurSel() < m_pList->GetCount() - 1) | 565 return FALSE; |
| 564 { | 566 } |
| 565 FX_BOOL bExit = FALSE; | 567 } |
| 566 if (m_pList->OnKeyDownWithExit(nChar,bExit,nFlag)) | 568 |
| 567 { | 569 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, |
| 568 if (bExit) return FALSE; | 570 FX_DWORD msg, |
| 569 SetSelectText(); | 571 FX_INTPTR wParam, |
| 570 } | 572 FX_INTPTR lParam) { |
| 571 } | 573 switch (msg) { |
| 572 return TRUE; | 574 case PNM_LBUTTONDOWN: |
| 573 } | 575 if (pWnd == m_pButton) { |
| 574 | 576 SetPopup(!m_bPopup); |
| 575 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) | 577 return; |
| 576 return m_pEdit->OnKeyDown(nChar,nFlag); | 578 } |
| 577 else | 579 break; |
| 578 return FALSE; | 580 case PNM_LBUTTONUP: |
| 579 } | 581 if (m_pEdit && m_pList) { |
| 580 | 582 if (pWnd == m_pList) { |
| 581 FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) | 583 SetSelectText(); |
| 582 { | 584 SelectAll(); |
| 583 if (!m_pList) return FALSE; | 585 m_pEdit->SetFocus(); |
| 584 if (!m_pEdit) return FALSE; | 586 SetPopup(FALSE); |
| 585 | 587 return; |
| 586 m_nSelectItem = -1; | 588 } |
| 587 FX_BOOL bExit = FALSE; | 589 } |
| 588 | 590 } |
| 589 if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) | 591 |
| 590 { | 592 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); |
| 591 return m_pEdit->OnChar(nChar,nFlag); | 593 } |
| 592 } | 594 |
| 593 else | 595 FX_BOOL CPWL_ComboBox::IsPopup() const { |
| 594 { | 596 return m_bPopup; |
| 595 if (m_pList->OnCharWithExit(nChar,bExit,nFlag)) | 597 } |
| 596 { | 598 |
| 597 return bExit; | 599 void CPWL_ComboBox::SetSelectText() { |
| 598 } | 600 CFX_WideString swText = m_pList->GetText(); |
| 599 else | 601 m_pEdit->SelectAll(); |
| 600 return FALSE; | 602 m_pEdit->ReplaceSel(m_pList->GetText()); |
| 601 } | 603 m_pEdit->SelectAll(); |
| 602 } | 604 |
| 603 | 605 m_nSelectItem = m_pList->GetCurSel(); |
| 604 void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_
INTPTR lParam) | 606 } |
| 605 { | 607 |
| 606 switch (msg) | 608 FX_BOOL CPWL_ComboBox::IsModified() const { |
| 607 { | 609 return m_pEdit->IsModified(); |
| 608 case PNM_LBUTTONDOWN: | 610 } |
| 609 if (pWnd == m_pButton) | 611 |
| 610 { | 612 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { |
| 611 SetPopup(!m_bPopup); | 613 m_pFillerNotify = pNotify; |
| 612 return; | 614 |
| 613 } | 615 if (m_pEdit) |
| 614 break; | 616 m_pEdit->SetFillerNotify(pNotify); |
| 615 case PNM_LBUTTONUP: | 617 |
| 616 if (m_pEdit && m_pList) | 618 if (m_pList) |
| 617 { | 619 m_pList->SetFillerNotify(pNotify); |
| 618 if (pWnd == m_pList) | 620 } |
| 619 { | |
| 620 SetSelectText(); | |
| 621 SelectAll(); | |
| 622 m_pEdit->SetFocus(); | |
| 623 SetPopup(FALSE); | |
| 624 return; | |
| 625 } | |
| 626 } | |
| 627 } | |
| 628 | |
| 629 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); | |
| 630 } | |
| 631 | |
| 632 FX_BOOL CPWL_ComboBox::IsPopup() const | |
| 633 { | |
| 634 return m_bPopup; | |
| 635 } | |
| 636 | |
| 637 void CPWL_ComboBox::SetSelectText() | |
| 638 { | |
| 639 CFX_WideString swText = m_pList->GetText(); | |
| 640 m_pEdit->SelectAll(); | |
| 641 m_pEdit->ReplaceSel(m_pList->GetText()); | |
| 642 m_pEdit->SelectAll(); | |
| 643 | |
| 644 m_nSelectItem = m_pList->GetCurSel(); | |
| 645 } | |
| 646 | |
| 647 FX_BOOL CPWL_ComboBox::IsModified() const | |
| 648 { | |
| 649 return m_pEdit->IsModified(); | |
| 650 } | |
| 651 | |
| 652 void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) | |
| 653 { | |
| 654 m_pFillerNotify = pNotify; | |
| 655 | |
| 656 if (m_pEdit) | |
| 657 m_pEdit->SetFillerNotify(pNotify); | |
| 658 | |
| 659 if (m_pList) | |
| 660 m_pList->SetFillerNotify(pNotify); | |
| 661 } | |
| 662 | |
| OLD | NEW |