| 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 "xfa/fwl/basewidget/fwl_datetimepickerimp.h" | 7 #include "xfa/fwl/basewidget/fwl_datetimepickerimp.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/basewidget/fwl_editimp.h" | 9 #include "xfa/fwl/basewidget/fwl_editimp.h" |
| 10 #include "xfa/fwl/basewidget/fwl_formproxyimp.h" | 10 #include "xfa/fwl/basewidget/fwl_formproxyimp.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 int32_t IFWL_DateTimePicker::CountSelRanges() { | 76 int32_t IFWL_DateTimePicker::CountSelRanges() { |
| 77 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) | 77 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) |
| 78 ->GetDataTimeEdit() | 78 ->GetDataTimeEdit() |
| 79 ->CountSelRanges(); | 79 ->CountSelRanges(); |
| 80 } | 80 } |
| 81 int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { | 81 int32_t IFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { |
| 82 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) | 82 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) |
| 83 ->GetDataTimeEdit() | 83 ->GetDataTimeEdit() |
| 84 ->GetSelRange(nIndex, nStart); | 84 ->GetSelRange(nIndex, nStart); |
| 85 } | 85 } |
| 86 FWL_ERR IFWL_DateTimePicker::GetCurSel(int32_t& iYear, | 86 FWL_Error IFWL_DateTimePicker::GetCurSel(int32_t& iYear, |
| 87 int32_t& iMonth, | 87 int32_t& iMonth, |
| 88 int32_t& iDay) { | 88 int32_t& iDay) { |
| 89 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) | 89 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) |
| 90 ->GetCurSel(iYear, iMonth, iDay); | 90 ->GetCurSel(iYear, iMonth, iDay); |
| 91 } | 91 } |
| 92 FWL_ERR IFWL_DateTimePicker::SetCurSel(int32_t iYear, | 92 FWL_Error IFWL_DateTimePicker::SetCurSel(int32_t iYear, |
| 93 int32_t iMonth, | 93 int32_t iMonth, |
| 94 int32_t iDay) { | 94 int32_t iDay) { |
| 95 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) | 95 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) |
| 96 ->SetCurSel(iYear, iMonth, iDay); | 96 ->SetCurSel(iYear, iMonth, iDay); |
| 97 } | 97 } |
| 98 FWL_ERR IFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) { | 98 FWL_Error IFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) { |
| 99 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SetEditText(wsText); | 99 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SetEditText(wsText); |
| 100 } | 100 } |
| 101 FWL_ERR IFWL_DateTimePicker::GetEditText(CFX_WideString& wsText, | 101 FWL_Error IFWL_DateTimePicker::GetEditText(CFX_WideString& wsText, |
| 102 int32_t nStart, | 102 int32_t nStart, |
| 103 int32_t nCount) const { | 103 int32_t nCount) const { |
| 104 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) | 104 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) |
| 105 ->GetEditText(wsText, nStart, nCount); | 105 ->GetEditText(wsText, nStart, nCount); |
| 106 } | 106 } |
| 107 FX_BOOL IFWL_DateTimePicker::CanUndo() { | 107 FX_BOOL IFWL_DateTimePicker::CanUndo() { |
| 108 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanUndo(); | 108 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanUndo(); |
| 109 } | 109 } |
| 110 FX_BOOL IFWL_DateTimePicker::CanRedo() { | 110 FX_BOOL IFWL_DateTimePicker::CanRedo() { |
| 111 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanRedo(); | 111 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->CanRedo(); |
| 112 } | 112 } |
| 113 FX_BOOL IFWL_DateTimePicker::Undo() { | 113 FX_BOOL IFWL_DateTimePicker::Undo() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 136 } | 136 } |
| 137 FX_BOOL IFWL_DateTimePicker::SelectAll() { | 137 FX_BOOL IFWL_DateTimePicker::SelectAll() { |
| 138 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SelectAll(); | 138 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SelectAll(); |
| 139 } | 139 } |
| 140 FX_BOOL IFWL_DateTimePicker::Delete() { | 140 FX_BOOL IFWL_DateTimePicker::Delete() { |
| 141 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Delete(); | 141 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->Delete(); |
| 142 } | 142 } |
| 143 FX_BOOL IFWL_DateTimePicker::DeSelect() { | 143 FX_BOOL IFWL_DateTimePicker::DeSelect() { |
| 144 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->DeSelect(); | 144 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->DeSelect(); |
| 145 } | 145 } |
| 146 FWL_ERR IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { | 146 FWL_Error IFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { |
| 147 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->GetBBox(rect); | 147 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->GetBBox(rect); |
| 148 } | 148 } |
| 149 FWL_ERR IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { | 149 FWL_Error IFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { |
| 150 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SetEditLimit(nLimit); | 150 return static_cast<CFWL_DateTimePickerImp*>(GetImpl())->SetEditLimit(nLimit); |
| 151 } | 151 } |
| 152 FWL_ERR IFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, | 152 FWL_Error IFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, |
| 153 uint32_t dwStylesExRemoved) { | 153 uint32_t dwStylesExRemoved) { |
| 154 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) | 154 return static_cast<CFWL_DateTimePickerImp*>(GetImpl()) |
| 155 ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved); | 155 ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 156 } | 156 } |
| 157 CFWL_DateTimeEdit::CFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties, | 157 CFWL_DateTimeEdit::CFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties, |
| 158 IFWL_Widget* pOuter) | 158 IFWL_Widget* pOuter) |
| 159 : CFWL_EditImp(properties, pOuter) {} | 159 : CFWL_EditImp(properties, pOuter) {} |
| 160 FWL_ERR CFWL_DateTimeEdit::Initialize() { | 160 FWL_Error CFWL_DateTimeEdit::Initialize() { |
| 161 m_pDelegate = new CFWL_DateTimeEditImpDelegate(this); | 161 m_pDelegate = new CFWL_DateTimeEditImpDelegate(this); |
| 162 if (CFWL_EditImp::Initialize() != FWL_ERR_Succeeded) | 162 if (CFWL_EditImp::Initialize() != FWL_Error::Succeeded) |
| 163 return FWL_ERR_Indefinite; | 163 return FWL_Error::Indefinite; |
| 164 return FWL_ERR_Succeeded; | 164 return FWL_Error::Succeeded; |
| 165 } | 165 } |
| 166 FWL_ERR CFWL_DateTimeEdit::Finalize() { | 166 FWL_Error CFWL_DateTimeEdit::Finalize() { |
| 167 delete m_pDelegate; | 167 delete m_pDelegate; |
| 168 m_pDelegate = nullptr; | 168 m_pDelegate = nullptr; |
| 169 return CFWL_EditImp::Finalize(); | 169 return CFWL_EditImp::Finalize(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 CFWL_DateTimeEditImpDelegate::CFWL_DateTimeEditImpDelegate( | 172 CFWL_DateTimeEditImpDelegate::CFWL_DateTimeEditImpDelegate( |
| 173 CFWL_DateTimeEdit* pOwner) | 173 CFWL_DateTimeEdit* pOwner) |
| 174 : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {} | 174 : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {} |
| 175 | 175 |
| 176 int32_t CFWL_DateTimeEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 176 void CFWL_DateTimeEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
| 177 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) | 177 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { |
| 178 return DisForm_OnProcessMessage(pMessage); | 178 DisForm_OnProcessMessage(pMessage); |
| 179 return; |
| 180 } |
| 179 | 181 |
| 180 CFWL_MessageType dwHashCode = pMessage->GetClassID(); | 182 CFWL_MessageType dwHashCode = pMessage->GetClassID(); |
| 181 if (dwHashCode == CFWL_MessageType::SetFocus || | 183 if (dwHashCode == CFWL_MessageType::SetFocus || |
| 182 dwHashCode == CFWL_MessageType::KillFocus) { | 184 dwHashCode == CFWL_MessageType::KillFocus) { |
| 183 IFWL_Widget* pOuter = m_pOwner->GetOuter(); | 185 IFWL_Widget* pOuter = m_pOwner->GetOuter(); |
| 184 IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL); | 186 IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL); |
| 185 pDelegate->OnProcessMessage(pMessage); | 187 pDelegate->OnProcessMessage(pMessage); |
| 186 } | 188 } |
| 187 return 1; | |
| 188 } | 189 } |
| 189 | 190 |
| 190 int32_t CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage( | 191 void CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage( |
| 191 CFWL_Message* pMessage) { | 192 CFWL_Message* pMessage) { |
| 192 CFWL_MessageType dwHashCode = pMessage->GetClassID(); | 193 CFWL_MessageType dwHashCode = pMessage->GetClassID(); |
| 193 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { | 194 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { |
| 194 if (dwHashCode == CFWL_MessageType::Mouse) { | 195 if (dwHashCode == CFWL_MessageType::Mouse) { |
| 195 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); | 196 CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); |
| 196 if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown || | 197 if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown || |
| 197 pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) { | 198 pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) { |
| 198 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { | 199 if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { |
| 199 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; | 200 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; |
| 200 } | 201 } |
| 201 CFWL_DateTimePickerImp* pDateTime = | 202 CFWL_DateTimePickerImp* pDateTime = |
| 202 static_cast<CFWL_DateTimePickerImp*>(m_pOwner->m_pOuter->GetImpl()); | 203 static_cast<CFWL_DateTimePickerImp*>(m_pOwner->m_pOuter->GetImpl()); |
| 203 if (pDateTime->IsMonthCalendarShowed()) { | 204 if (pDateTime->IsMonthCalendarShowed()) { |
| 204 CFX_RectF rtInvalidate; | 205 CFX_RectF rtInvalidate; |
| 205 pDateTime->GetWidgetRect(rtInvalidate); | 206 pDateTime->GetWidgetRect(rtInvalidate); |
| 206 pDateTime->ShowMonthCalendar(FALSE); | 207 pDateTime->ShowMonthCalendar(FALSE); |
| 207 rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top); | 208 rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top); |
| 208 pDateTime->Repaint(&rtInvalidate); | 209 pDateTime->Repaint(&rtInvalidate); |
| 209 } | 210 } |
| 210 } | 211 } |
| 211 } else if (dwHashCode == CFWL_MessageType::Key) { | |
| 212 return CFWL_EditImpDelegate::OnProcessMessage(pMessage); | |
| 213 } | 212 } |
| 214 } | 213 } |
| 215 return CFWL_EditImpDelegate::OnProcessMessage(pMessage); | 214 CFWL_EditImpDelegate::OnProcessMessage(pMessage); |
| 216 } | 215 } |
| 217 | 216 |
| 218 CFWL_DateTimeCalendar::CFWL_DateTimeCalendar( | 217 CFWL_DateTimeCalendar::CFWL_DateTimeCalendar( |
| 219 const CFWL_WidgetImpProperties& properties, | 218 const CFWL_WidgetImpProperties& properties, |
| 220 IFWL_Widget* pOuter) | 219 IFWL_Widget* pOuter) |
| 221 : CFWL_MonthCalendarImp(properties, pOuter) {} | 220 : CFWL_MonthCalendarImp(properties, pOuter) {} |
| 222 FWL_ERR CFWL_DateTimeCalendar::Initialize() { | 221 FWL_Error CFWL_DateTimeCalendar::Initialize() { |
| 223 if (CFWL_MonthCalendarImp::Initialize() != FWL_ERR_Succeeded) | 222 if (CFWL_MonthCalendarImp::Initialize() != FWL_Error::Succeeded) |
| 224 return FWL_ERR_Indefinite; | 223 return FWL_Error::Indefinite; |
| 225 delete m_pDelegate; | 224 delete m_pDelegate; |
| 226 m_pDelegate = new CFWL_DateTimeCalendarImpDelegate(this); | 225 m_pDelegate = new CFWL_DateTimeCalendarImpDelegate(this); |
| 227 return FWL_ERR_Succeeded; | 226 return FWL_Error::Succeeded; |
| 228 } | 227 } |
| 229 FWL_ERR CFWL_DateTimeCalendar::Finalize() { | 228 FWL_Error CFWL_DateTimeCalendar::Finalize() { |
| 230 delete m_pDelegate; | 229 delete m_pDelegate; |
| 231 m_pDelegate = nullptr; | 230 m_pDelegate = nullptr; |
| 232 return CFWL_MonthCalendarImp::Finalize(); | 231 return CFWL_MonthCalendarImp::Finalize(); |
| 233 } | 232 } |
| 234 | 233 |
| 235 CFWL_DateTimeCalendarImpDelegate::CFWL_DateTimeCalendarImpDelegate( | 234 CFWL_DateTimeCalendarImpDelegate::CFWL_DateTimeCalendarImpDelegate( |
| 236 CFWL_DateTimeCalendar* pOwner) | 235 CFWL_DateTimeCalendar* pOwner) |
| 237 : CFWL_MonthCalendarImpDelegate(pOwner), m_pOwner(pOwner) { | 236 : CFWL_MonthCalendarImpDelegate(pOwner), m_pOwner(pOwner) { |
| 238 m_bFlag = FALSE; | 237 m_bFlag = FALSE; |
| 239 } | 238 } |
| 240 | 239 |
| 241 int32_t CFWL_DateTimeCalendarImpDelegate::OnProcessMessage( | 240 void CFWL_DateTimeCalendarImpDelegate::OnProcessMessage( |
| 242 CFWL_Message* pMessage) { | 241 CFWL_Message* pMessage) { |
| 243 CFWL_MessageType dwCode = pMessage->GetClassID(); | 242 CFWL_MessageType dwCode = pMessage->GetClassID(); |
| 244 if (dwCode == CFWL_MessageType::SetFocus || | 243 if (dwCode == CFWL_MessageType::SetFocus || |
| 245 dwCode == CFWL_MessageType::KillFocus) { | 244 dwCode == CFWL_MessageType::KillFocus) { |
| 246 IFWL_Widget* pOuter = m_pOwner->GetOuter(); | 245 IFWL_Widget* pOuter = m_pOwner->GetOuter(); |
| 247 IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL); | 246 IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL); |
| 248 return pDelegate->OnProcessMessage(pMessage); | 247 pDelegate->OnProcessMessage(pMessage); |
| 249 } else if (dwCode == CFWL_MessageType::Mouse) { | 248 return; |
| 249 } |
| 250 if (dwCode == CFWL_MessageType::Mouse) { |
| 250 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 251 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
| 251 if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) { | 252 if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) |
| 252 OnLButtonDownEx(pMsg); | 253 OnLButtonDownEx(pMsg); |
| 253 return 1; | 254 else if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) |
| 254 } else if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) { | |
| 255 OnLButtonUpEx(pMsg); | 255 OnLButtonUpEx(pMsg); |
| 256 return 1; | 256 return; |
| 257 } | |
| 258 } | 257 } |
| 259 return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage); | 258 CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage); |
| 260 } | 259 } |
| 261 | 260 |
| 262 void CFWL_DateTimeCalendarImpDelegate::OnLButtonDownEx(CFWL_MsgMouse* pMsg) { | 261 void CFWL_DateTimeCalendarImpDelegate::OnLButtonDownEx(CFWL_MsgMouse* pMsg) { |
| 263 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 262 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 264 m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed; | 263 m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed; |
| 265 m_pOwner->PrevMonth(); | 264 m_pOwner->PrevMonth(); |
| 266 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 265 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 267 } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 266 } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 268 m_pOwner->m_iRBtnPartStates |= CFWL_PartState_Pressed; | 267 m_pOwner->m_iRBtnPartStates |= CFWL_PartState_Pressed; |
| 269 m_pOwner->NextMonth(); | 268 m_pOwner->NextMonth(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 if (bRepaint) { | 367 if (bRepaint) { |
| 369 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); | 368 m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate); |
| 370 } | 369 } |
| 371 m_pOwner->m_iHovered = -1; | 370 m_pOwner->m_iHovered = -1; |
| 372 } | 371 } |
| 373 if (bRepaint && !rtInvalidate.IsEmpty()) { | 372 if (bRepaint && !rtInvalidate.IsEmpty()) { |
| 374 m_pOwner->Repaint(&rtInvalidate); | 373 m_pOwner->Repaint(&rtInvalidate); |
| 375 } | 374 } |
| 376 } | 375 } |
| 377 | 376 |
| 378 int32_t CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage( | 377 void CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage( |
| 379 CFWL_Message* pMessage) { | 378 CFWL_Message* pMessage) { |
| 380 if (pMessage->GetClassID() == CFWL_MessageType::Mouse) { | 379 if (pMessage->GetClassID() == CFWL_MessageType::Mouse) { |
| 381 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 380 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
| 382 if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) { | 381 if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) { |
| 383 DisForm_OnLButtonUpEx(pMsg); | 382 DisForm_OnLButtonUpEx(pMsg); |
| 384 return 1; | 383 return; |
| 385 } | 384 } |
| 386 } | 385 } |
| 387 return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage); | 386 CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage); |
| 388 } | 387 } |
| 389 | 388 |
| 390 void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx( | 389 void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx( |
| 391 CFWL_MsgMouse* pMsg) { | 390 CFWL_MsgMouse* pMsg) { |
| 392 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 391 if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 393 m_pOwner->m_iLBtnPartStates = 0; | 392 m_pOwner->m_iLBtnPartStates = 0; |
| 394 m_pOwner->Repaint(&(m_pOwner->m_rtLBtn)); | 393 m_pOwner->Repaint(&(m_pOwner->m_rtLBtn)); |
| 395 return; | 394 return; |
| 396 } | 395 } |
| 397 if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | 396 if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 m_iYear(-1), | 429 m_iYear(-1), |
| 431 m_iMonth(-1), | 430 m_iMonth(-1), |
| 432 m_iDay(-1), | 431 m_iDay(-1), |
| 433 m_bLBtnDown(FALSE), | 432 m_bLBtnDown(FALSE), |
| 434 m_pEdit(nullptr), | 433 m_pEdit(nullptr), |
| 435 m_pMonthCal(nullptr), | 434 m_pMonthCal(nullptr), |
| 436 m_pForm(nullptr) { | 435 m_pForm(nullptr) { |
| 437 m_rtBtn.Set(0, 0, 0, 0); | 436 m_rtBtn.Set(0, 0, 0, 0); |
| 438 } | 437 } |
| 439 CFWL_DateTimePickerImp::~CFWL_DateTimePickerImp() {} | 438 CFWL_DateTimePickerImp::~CFWL_DateTimePickerImp() {} |
| 440 FWL_ERR CFWL_DateTimePickerImp::GetClassName(CFX_WideString& wsClass) const { | 439 FWL_Error CFWL_DateTimePickerImp::GetClassName(CFX_WideString& wsClass) const { |
| 441 wsClass = FWL_CLASS_DateTimePicker; | 440 wsClass = FWL_CLASS_DateTimePicker; |
| 442 return FWL_ERR_Succeeded; | 441 return FWL_Error::Succeeded; |
| 443 } | 442 } |
| 444 uint32_t CFWL_DateTimePickerImp::GetClassID() const { | 443 uint32_t CFWL_DateTimePickerImp::GetClassID() const { |
| 445 return FWL_CLASSHASH_DateTimePicker; | 444 return FWL_CLASSHASH_DateTimePicker; |
| 446 } | 445 } |
| 447 FWL_ERR CFWL_DateTimePickerImp::Initialize() { | 446 FWL_Error CFWL_DateTimePickerImp::Initialize() { |
| 448 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 447 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) |
| 449 return FWL_ERR_Indefinite; | 448 return FWL_Error::Indefinite; |
| 450 m_pDelegate = new CFWL_DateTimePickerImpDelegate(this); | 449 m_pDelegate = new CFWL_DateTimePickerImpDelegate(this); |
| 451 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; | 450 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; |
| 452 CFWL_WidgetImpProperties propMonth; | 451 CFWL_WidgetImpProperties propMonth; |
| 453 propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; | 452 propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border; |
| 454 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; | 453 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; |
| 455 propMonth.m_pDataProvider = &m_MonthCalendarDP; | 454 propMonth.m_pDataProvider = &m_MonthCalendarDP; |
| 456 propMonth.m_pParent = m_pInterface; | 455 propMonth.m_pParent = m_pInterface; |
| 457 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; | 456 propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; |
| 458 m_pMonthCal.reset(IFWL_DateTimeCalender::Create(propMonth, m_pInterface)); | 457 m_pMonthCal.reset(IFWL_DateTimeCalender::Create(propMonth, m_pInterface)); |
| 459 m_pMonthCal->Initialize(); | 458 m_pMonthCal->Initialize(); |
| 460 CFX_RectF rtMonthCal; | 459 CFX_RectF rtMonthCal; |
| 461 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); | 460 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); |
| 462 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); | 461 rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); |
| 463 m_pMonthCal->SetWidgetRect(rtMonthCal); | 462 m_pMonthCal->SetWidgetRect(rtMonthCal); |
| 464 CFWL_WidgetImpProperties propEdit; | 463 CFWL_WidgetImpProperties propEdit; |
| 465 propEdit.m_pParent = m_pInterface; | 464 propEdit.m_pParent = m_pInterface; |
| 466 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; | 465 propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; |
| 467 m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, m_pInterface)); | 466 m_pEdit.reset(IFWL_DateTimeEdit::Create(propEdit, m_pInterface)); |
| 468 m_pEdit->Initialize(); | 467 m_pEdit->Initialize(); |
| 469 RegisterEventTarget(m_pMonthCal.get()); | 468 RegisterEventTarget(m_pMonthCal.get()); |
| 470 RegisterEventTarget(m_pEdit.get()); | 469 RegisterEventTarget(m_pEdit.get()); |
| 471 return FWL_ERR_Succeeded; | 470 return FWL_Error::Succeeded; |
| 472 } | 471 } |
| 473 FWL_ERR CFWL_DateTimePickerImp::Finalize() { | 472 FWL_Error CFWL_DateTimePickerImp::Finalize() { |
| 474 if (m_pEdit) { | 473 if (m_pEdit) { |
| 475 m_pEdit->Finalize(); | 474 m_pEdit->Finalize(); |
| 476 } | 475 } |
| 477 if (m_pMonthCal) { | 476 if (m_pMonthCal) { |
| 478 m_pMonthCal->Finalize(); | 477 m_pMonthCal->Finalize(); |
| 479 } | 478 } |
| 480 if (m_pForm) { | 479 if (m_pForm) { |
| 481 m_pForm->Finalize(); | 480 m_pForm->Finalize(); |
| 482 } | 481 } |
| 483 UnregisterEventTarget(); | 482 UnregisterEventTarget(); |
| 484 delete m_pDelegate; | 483 delete m_pDelegate; |
| 485 m_pDelegate = nullptr; | 484 m_pDelegate = nullptr; |
| 486 return CFWL_WidgetImp::Finalize(); | 485 return CFWL_WidgetImp::Finalize(); |
| 487 } | 486 } |
| 488 FWL_ERR CFWL_DateTimePickerImp::GetWidgetRect(CFX_RectF& rect, | 487 FWL_Error CFWL_DateTimePickerImp::GetWidgetRect(CFX_RectF& rect, |
| 489 FX_BOOL bAutoSize) { | 488 FX_BOOL bAutoSize) { |
| 490 if (m_pWidgetMgr->IsFormDisabled()) { | 489 if (m_pWidgetMgr->IsFormDisabled()) { |
| 491 return DisForm_GetWidgetRect(rect, bAutoSize); | 490 return DisForm_GetWidgetRect(rect, bAutoSize); |
| 492 } | 491 } |
| 493 if (bAutoSize) { | 492 if (bAutoSize) { |
| 494 rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight); | 493 rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight); |
| 495 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); | 494 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); |
| 496 } else { | 495 } else { |
| 497 rect = m_pProperties->m_rtWidget; | 496 rect = m_pProperties->m_rtWidget; |
| 498 } | 497 } |
| 499 return FWL_ERR_Succeeded; | 498 return FWL_Error::Succeeded; |
| 500 } | 499 } |
| 501 FWL_ERR CFWL_DateTimePickerImp::Update() { | 500 FWL_Error CFWL_DateTimePickerImp::Update() { |
| 502 if (m_pWidgetMgr->IsFormDisabled()) { | 501 if (m_pWidgetMgr->IsFormDisabled()) { |
| 503 return DisForm_Update(); | 502 return DisForm_Update(); |
| 504 } | 503 } |
| 505 if (m_iLock) { | 504 if (m_iLock) { |
| 506 return FWL_ERR_Indefinite; | 505 return FWL_Error::Indefinite; |
| 507 } | 506 } |
| 508 if (!m_pProperties->m_pThemeProvider) { | 507 if (!m_pProperties->m_pThemeProvider) { |
| 509 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 508 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 510 } | 509 } |
| 511 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider); | 510 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider); |
| 512 GetClientRect(m_rtClient); | 511 GetClientRect(m_rtClient); |
| 513 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( | 512 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( |
| 514 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 513 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| 515 if (!pFWidth) | 514 if (!pFWidth) |
| 516 return FWL_ERR_Indefinite; | 515 return FWL_Error::Indefinite; |
| 517 FX_FLOAT fBtn = *pFWidth; | 516 FX_FLOAT fBtn = *pFWidth; |
| 518 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1, | 517 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1, |
| 519 m_rtClient.height - 1); | 518 m_rtClient.height - 1); |
| 520 CFX_RectF rtEdit; | 519 CFX_RectF rtEdit; |
| 521 rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, | 520 rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, |
| 522 m_rtClient.height); | 521 m_rtClient.height); |
| 523 m_pEdit->SetWidgetRect(rtEdit); | 522 m_pEdit->SetWidgetRect(rtEdit); |
| 524 ReSetEditAlignment(); | 523 ReSetEditAlignment(); |
| 525 m_pEdit->Update(); | 524 m_pEdit->Update(); |
| 526 if (!(m_pMonthCal->GetThemeProvider())) { | 525 if (!(m_pMonthCal->GetThemeProvider())) { |
| 527 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); | 526 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); |
| 528 } | 527 } |
| 529 if (m_pProperties->m_pDataProvider) { | 528 if (m_pProperties->m_pDataProvider) { |
| 530 IFWL_DateTimePickerDP* pData = | 529 IFWL_DateTimePickerDP* pData = |
| 531 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); | 530 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); |
| 532 pData->GetToday(m_pInterface, m_MonthCalendarDP.m_iCurYear, | 531 pData->GetToday(m_pInterface, m_MonthCalendarDP.m_iCurYear, |
| 533 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); | 532 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); |
| 534 } | 533 } |
| 535 CFX_RectF rtMonthCal; | 534 CFX_RectF rtMonthCal; |
| 536 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); | 535 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); |
| 537 CFX_RectF rtPopUp; | 536 CFX_RectF rtPopUp; |
| 538 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, | 537 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, |
| 539 rtMonthCal.width, rtMonthCal.height); | 538 rtMonthCal.width, rtMonthCal.height); |
| 540 m_pMonthCal->SetWidgetRect(rtPopUp); | 539 m_pMonthCal->SetWidgetRect(rtPopUp); |
| 541 m_pMonthCal->Update(); | 540 m_pMonthCal->Update(); |
| 542 return FWL_ERR_Succeeded; | 541 return FWL_Error::Succeeded; |
| 543 } | 542 } |
| 544 FWL_WidgetHit CFWL_DateTimePickerImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 543 FWL_WidgetHit CFWL_DateTimePickerImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| 545 if (m_pWidgetMgr->IsFormDisabled()) | 544 if (m_pWidgetMgr->IsFormDisabled()) |
| 546 return DisForm_HitTest(fx, fy); | 545 return DisForm_HitTest(fx, fy); |
| 547 if (m_rtClient.Contains(fx, fy)) | 546 if (m_rtClient.Contains(fx, fy)) |
| 548 return FWL_WidgetHit::Client; | 547 return FWL_WidgetHit::Client; |
| 549 if (IsMonthCalendarShowed()) { | 548 if (IsMonthCalendarShowed()) { |
| 550 CFX_RectF rect; | 549 CFX_RectF rect; |
| 551 m_pMonthCal->GetWidgetRect(rect); | 550 m_pMonthCal->GetWidgetRect(rect); |
| 552 if (rect.Contains(fx, fy)) | 551 if (rect.Contains(fx, fy)) |
| 553 return FWL_WidgetHit::Client; | 552 return FWL_WidgetHit::Client; |
| 554 } | 553 } |
| 555 return FWL_WidgetHit::Unknown; | 554 return FWL_WidgetHit::Unknown; |
| 556 } | 555 } |
| 557 FWL_ERR CFWL_DateTimePickerImp::DrawWidget(CFX_Graphics* pGraphics, | 556 FWL_Error CFWL_DateTimePickerImp::DrawWidget(CFX_Graphics* pGraphics, |
| 558 const CFX_Matrix* pMatrix) { | 557 const CFX_Matrix* pMatrix) { |
| 559 if (!pGraphics) | 558 if (!pGraphics) |
| 560 return FWL_ERR_Indefinite; | 559 return FWL_Error::Indefinite; |
| 561 if (!m_pProperties->m_pThemeProvider) | 560 if (!m_pProperties->m_pThemeProvider) |
| 562 return FWL_ERR_Indefinite; | 561 return FWL_Error::Indefinite; |
| 563 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 562 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 564 if (HasBorder()) { | 563 if (HasBorder()) { |
| 565 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 564 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 566 } | 565 } |
| 567 if (HasEdge()) { | 566 if (HasEdge()) { |
| 568 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 567 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 569 } | 568 } |
| 570 if (!m_rtBtn.IsEmpty()) { | 569 if (!m_rtBtn.IsEmpty()) { |
| 571 DrawDropDownButton(pGraphics, pTheme, pMatrix); | 570 DrawDropDownButton(pGraphics, pTheme, pMatrix); |
| 572 } | 571 } |
| 573 if (m_pWidgetMgr->IsFormDisabled()) { | 572 if (m_pWidgetMgr->IsFormDisabled()) { |
| 574 return DisForm_DrawWidget(pGraphics, pMatrix); | 573 return DisForm_DrawWidget(pGraphics, pMatrix); |
| 575 } | 574 } |
| 576 return FWL_ERR_Succeeded; | 575 return FWL_Error::Succeeded; |
| 577 } | 576 } |
| 578 FWL_ERR CFWL_DateTimePickerImp::SetThemeProvider(IFWL_ThemeProvider* pTP) { | 577 FWL_Error CFWL_DateTimePickerImp::SetThemeProvider(IFWL_ThemeProvider* pTP) { |
| 579 m_pProperties->m_pThemeProvider = pTP; | 578 m_pProperties->m_pThemeProvider = pTP; |
| 580 m_pMonthCal->SetThemeProvider(pTP); | 579 m_pMonthCal->SetThemeProvider(pTP); |
| 581 return FWL_ERR_Succeeded; | 580 return FWL_Error::Succeeded; |
| 582 } | 581 } |
| 583 FWL_ERR CFWL_DateTimePickerImp::GetCurSel(int32_t& iYear, | 582 FWL_Error CFWL_DateTimePickerImp::GetCurSel(int32_t& iYear, |
| 584 int32_t& iMonth, | 583 int32_t& iMonth, |
| 585 int32_t& iDay) { | 584 int32_t& iDay) { |
| 586 iYear = m_iYear; | 585 iYear = m_iYear; |
| 587 iMonth = m_iMonth; | 586 iMonth = m_iMonth; |
| 588 iDay = m_iDay; | 587 iDay = m_iDay; |
| 589 return FWL_ERR_Succeeded; | 588 return FWL_Error::Succeeded; |
| 590 } | 589 } |
| 591 FWL_ERR CFWL_DateTimePickerImp::SetCurSel(int32_t iYear, | 590 FWL_Error CFWL_DateTimePickerImp::SetCurSel(int32_t iYear, |
| 592 int32_t iMonth, | 591 int32_t iMonth, |
| 593 int32_t iDay) { | 592 int32_t iDay) { |
| 594 if (iYear <= 0 || iYear >= 3000) | 593 if (iYear <= 0 || iYear >= 3000) |
| 595 return FWL_ERR_Indefinite; | 594 return FWL_Error::Indefinite; |
| 596 if (iMonth <= 0 || iMonth >= 13) | 595 if (iMonth <= 0 || iMonth >= 13) |
| 597 return FWL_ERR_Indefinite; | 596 return FWL_Error::Indefinite; |
| 598 if (iDay <= 0 || iDay >= 32) | 597 if (iDay <= 0 || iDay >= 32) |
| 599 return FWL_ERR_Indefinite; | 598 return FWL_Error::Indefinite; |
| 600 m_iYear = iYear; | 599 m_iYear = iYear; |
| 601 m_iMonth = iMonth; | 600 m_iMonth = iMonth; |
| 602 m_iDay = iDay; | 601 m_iDay = iDay; |
| 603 m_pMonthCal->SetSelect(iYear, iMonth, iDay); | 602 m_pMonthCal->SetSelect(iYear, iMonth, iDay); |
| 604 return FWL_ERR_Succeeded; | 603 return FWL_Error::Succeeded; |
| 605 } | 604 } |
| 606 FWL_ERR CFWL_DateTimePickerImp::SetEditText(const CFX_WideString& wsText) { | 605 |
| 606 FWL_Error CFWL_DateTimePickerImp::SetEditText(const CFX_WideString& wsText) { |
| 607 if (!m_pEdit) | 607 if (!m_pEdit) |
| 608 return FWL_ERR_Indefinite; | 608 return FWL_Error::Indefinite; |
| 609 int32_t iRet = m_pEdit->SetText(wsText); | 609 |
| 610 FWL_Error iRet = m_pEdit->SetText(wsText); |
| 610 Repaint(&m_rtClient); | 611 Repaint(&m_rtClient); |
| 611 CFWL_Event_DtpEditChanged ev; | 612 CFWL_Event_DtpEditChanged ev; |
| 612 ev.m_wsText = wsText; | 613 ev.m_wsText = wsText; |
| 613 DispatchEvent(&ev); | 614 DispatchEvent(&ev); |
| 614 return iRet; | 615 return iRet; |
| 615 } | 616 } |
| 616 FWL_ERR CFWL_DateTimePickerImp::GetEditText(CFX_WideString& wsText, | 617 |
| 617 int32_t nStart, | 618 FWL_Error CFWL_DateTimePickerImp::GetEditText(CFX_WideString& wsText, |
| 618 int32_t nCount) const { | 619 int32_t nStart, |
| 620 int32_t nCount) const { |
| 619 if (m_pEdit) { | 621 if (m_pEdit) { |
| 620 return m_pEdit->GetText(wsText, nStart, nCount); | 622 return m_pEdit->GetText(wsText, nStart, nCount); |
| 621 } | 623 } |
| 622 return FWL_ERR_Indefinite; | 624 return FWL_Error::Indefinite; |
| 623 } | 625 } |
| 624 FX_BOOL CFWL_DateTimePickerImp::CanUndo() { | 626 FX_BOOL CFWL_DateTimePickerImp::CanUndo() { |
| 625 return m_pEdit->CanUndo(); | 627 return m_pEdit->CanUndo(); |
| 626 } | 628 } |
| 627 FX_BOOL CFWL_DateTimePickerImp::CanRedo() { | 629 FX_BOOL CFWL_DateTimePickerImp::CanRedo() { |
| 628 return m_pEdit->CanRedo(); | 630 return m_pEdit->CanRedo(); |
| 629 } | 631 } |
| 630 FX_BOOL CFWL_DateTimePickerImp::Undo() { | 632 FX_BOOL CFWL_DateTimePickerImp::Undo() { |
| 631 return m_pEdit->Undo(); | 633 return m_pEdit->Undo(); |
| 632 } | 634 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 650 FX_BOOL CFWL_DateTimePickerImp::Copy(CFX_WideString& wsCopy) { | 652 FX_BOOL CFWL_DateTimePickerImp::Copy(CFX_WideString& wsCopy) { |
| 651 return m_pEdit->Copy(wsCopy); | 653 return m_pEdit->Copy(wsCopy); |
| 652 } | 654 } |
| 653 FX_BOOL CFWL_DateTimePickerImp::Cut(CFX_WideString& wsCut) { | 655 FX_BOOL CFWL_DateTimePickerImp::Cut(CFX_WideString& wsCut) { |
| 654 return m_pEdit->Cut(wsCut); | 656 return m_pEdit->Cut(wsCut); |
| 655 } | 657 } |
| 656 FX_BOOL CFWL_DateTimePickerImp::Paste(const CFX_WideString& wsPaste) { | 658 FX_BOOL CFWL_DateTimePickerImp::Paste(const CFX_WideString& wsPaste) { |
| 657 return m_pEdit->Paste(wsPaste); | 659 return m_pEdit->Paste(wsPaste); |
| 658 } | 660 } |
| 659 FX_BOOL CFWL_DateTimePickerImp::SelectAll() { | 661 FX_BOOL CFWL_DateTimePickerImp::SelectAll() { |
| 660 return m_pEdit->AddSelRange(0) == FWL_ERR_Succeeded; | 662 return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded; |
| 661 } | 663 } |
| 662 FX_BOOL CFWL_DateTimePickerImp::Delete() { | 664 FX_BOOL CFWL_DateTimePickerImp::Delete() { |
| 663 return m_pEdit->ClearText() == FWL_ERR_Succeeded; | 665 return m_pEdit->ClearText() == FWL_Error::Succeeded; |
| 664 } | 666 } |
| 665 FX_BOOL CFWL_DateTimePickerImp::DeSelect() { | 667 FX_BOOL CFWL_DateTimePickerImp::DeSelect() { |
| 666 return m_pEdit->ClearSelections() == FWL_ERR_Succeeded; | 668 return m_pEdit->ClearSelections() == FWL_Error::Succeeded; |
| 667 } | 669 } |
| 668 FWL_ERR CFWL_DateTimePickerImp::GetBBox(CFX_RectF& rect) { | 670 FWL_Error CFWL_DateTimePickerImp::GetBBox(CFX_RectF& rect) { |
| 669 if (m_pWidgetMgr->IsFormDisabled()) { | 671 if (m_pWidgetMgr->IsFormDisabled()) { |
| 670 return DisForm_GetBBox(rect); | 672 return DisForm_GetBBox(rect); |
| 671 } | 673 } |
| 672 rect = m_pProperties->m_rtWidget; | 674 rect = m_pProperties->m_rtWidget; |
| 673 if (IsMonthCalendarShowed()) { | 675 if (IsMonthCalendarShowed()) { |
| 674 CFX_RectF rtMonth; | 676 CFX_RectF rtMonth; |
| 675 m_pMonthCal->GetWidgetRect(rtMonth); | 677 m_pMonthCal->GetWidgetRect(rtMonth); |
| 676 rtMonth.Offset(m_pProperties->m_rtWidget.left, | 678 rtMonth.Offset(m_pProperties->m_rtWidget.left, |
| 677 m_pProperties->m_rtWidget.top); | 679 m_pProperties->m_rtWidget.top); |
| 678 rect.Union(rtMonth); | 680 rect.Union(rtMonth); |
| 679 } | 681 } |
| 680 return FWL_ERR_Succeeded; | 682 return FWL_Error::Succeeded; |
| 681 } | 683 } |
| 682 FWL_ERR CFWL_DateTimePickerImp::SetEditLimit(int32_t nLimit) { | 684 FWL_Error CFWL_DateTimePickerImp::SetEditLimit(int32_t nLimit) { |
| 683 return m_pEdit->SetLimit(nLimit); | 685 return m_pEdit->SetLimit(nLimit); |
| 684 } | 686 } |
| 685 FWL_ERR CFWL_DateTimePickerImp::ModifyEditStylesEx(uint32_t dwStylesExAdded, | 687 FWL_Error CFWL_DateTimePickerImp::ModifyEditStylesEx( |
| 686 uint32_t dwStylesExRemoved) { | 688 uint32_t dwStylesExAdded, |
| 689 uint32_t dwStylesExRemoved) { |
| 687 return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 690 return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 688 } | 691 } |
| 689 void CFWL_DateTimePickerImp::DrawDropDownButton(CFX_Graphics* pGraphics, | 692 void CFWL_DateTimePickerImp::DrawDropDownButton(CFX_Graphics* pGraphics, |
| 690 IFWL_ThemeProvider* pTheme, | 693 IFWL_ThemeProvider* pTheme, |
| 691 const CFX_Matrix* pMatrix) { | 694 const CFX_Matrix* pMatrix) { |
| 692 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) == | 695 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_Spin) == |
| 693 FWL_STYLEEXT_DTP_Spin) { | 696 FWL_STYLEEXT_DTP_Spin) { |
| 694 CFWL_WidgetImpProperties prop; | 697 CFWL_WidgetImpProperties prop; |
| 695 prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; | 698 prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; |
| 696 prop.m_pParent = m_pInterface; | 699 prop.m_pParent = m_pInterface; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; | 826 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; |
| 824 propForm.m_dwStates = FWL_WGTSTATE_Invisible; | 827 propForm.m_dwStates = FWL_WGTSTATE_Invisible; |
| 825 propForm.m_pOwner = m_pInterface; | 828 propForm.m_pOwner = m_pInterface; |
| 826 m_pForm.reset(IFWL_DateTimeForm::Create(propForm, m_pMonthCal.get())); | 829 m_pForm.reset(IFWL_DateTimeForm::Create(propForm, m_pMonthCal.get())); |
| 827 m_pForm->Initialize(); | 830 m_pForm->Initialize(); |
| 828 m_pMonthCal->SetParent(m_pForm.get()); | 831 m_pMonthCal->SetParent(m_pForm.get()); |
| 829 } | 832 } |
| 830 IFWL_DateTimeEdit* CFWL_DateTimePickerImp::GetDataTimeEdit() { | 833 IFWL_DateTimeEdit* CFWL_DateTimePickerImp::GetDataTimeEdit() { |
| 831 return m_pEdit.get(); | 834 return m_pEdit.get(); |
| 832 } | 835 } |
| 833 FWL_ERR CFWL_DateTimePickerImp::DisForm_Initialize() { | 836 FWL_Error CFWL_DateTimePickerImp::DisForm_Initialize() { |
| 834 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; | 837 m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; |
| 835 DisForm_InitDateTimeCalendar(); | 838 DisForm_InitDateTimeCalendar(); |
| 836 DisForm_InitDateTimeEdit(); | 839 DisForm_InitDateTimeEdit(); |
| 837 RegisterEventTarget(m_pMonthCal.get()); | 840 RegisterEventTarget(m_pMonthCal.get()); |
| 838 RegisterEventTarget(m_pEdit.get()); | 841 RegisterEventTarget(m_pEdit.get()); |
| 839 return FWL_ERR_Succeeded; | 842 return FWL_Error::Succeeded; |
| 840 } | 843 } |
| 841 void CFWL_DateTimePickerImp::DisForm_InitDateTimeCalendar() { | 844 void CFWL_DateTimePickerImp::DisForm_InitDateTimeCalendar() { |
| 842 if (m_pMonthCal) { | 845 if (m_pMonthCal) { |
| 843 return; | 846 return; |
| 844 } | 847 } |
| 845 CFWL_WidgetImpProperties propMonth; | 848 CFWL_WidgetImpProperties propMonth; |
| 846 propMonth.m_dwStyles = | 849 propMonth.m_dwStyles = |
| 847 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken; | 850 FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border | FWL_WGTSTYLE_EdgeSunken; |
| 848 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; | 851 propMonth.m_dwStates = FWL_WGTSTATE_Invisible; |
| 849 propMonth.m_pParent = m_pInterface; | 852 propMonth.m_pParent = m_pInterface; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 return FWL_WidgetHit::Client; | 928 return FWL_WidgetHit::Client; |
| 926 } | 929 } |
| 927 return FWL_WidgetHit::Unknown; | 930 return FWL_WidgetHit::Unknown; |
| 928 } | 931 } |
| 929 FX_BOOL CFWL_DateTimePickerImp::DisForm_IsNeedShowButton() { | 932 FX_BOOL CFWL_DateTimePickerImp::DisForm_IsNeedShowButton() { |
| 930 FX_BOOL bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused || | 933 FX_BOOL bFocus = m_pProperties->m_dwStates & FWL_WGTSTATE_Focused || |
| 931 m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused || | 934 m_pMonthCal->GetStates() & FWL_WGTSTATE_Focused || |
| 932 m_pEdit->GetStates() & FWL_WGTSTATE_Focused; | 935 m_pEdit->GetStates() & FWL_WGTSTATE_Focused; |
| 933 return bFocus; | 936 return bFocus; |
| 934 } | 937 } |
| 935 FWL_ERR CFWL_DateTimePickerImp::DisForm_Update() { | 938 |
| 936 if (m_iLock) { | 939 FWL_Error CFWL_DateTimePickerImp::DisForm_Update() { |
| 937 return FWL_ERR_Indefinite; | 940 if (m_iLock) |
| 938 } | 941 return FWL_Error::Indefinite; |
| 939 if (!m_pProperties->m_pThemeProvider) { | 942 if (!m_pProperties->m_pThemeProvider) |
| 940 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 943 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 941 } | 944 |
| 942 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider); | 945 m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider); |
| 943 GetClientRect(m_rtClient); | 946 GetClientRect(m_rtClient); |
| 944 m_pEdit->SetWidgetRect(m_rtClient); | 947 m_pEdit->SetWidgetRect(m_rtClient); |
| 945 ReSetEditAlignment(); | 948 ReSetEditAlignment(); |
| 946 m_pEdit->Update(); | 949 m_pEdit->Update(); |
| 947 if (m_pMonthCal->GetThemeProvider() == NULL) { | 950 if (!m_pMonthCal->GetThemeProvider()) |
| 948 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); | 951 m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); |
| 949 } | 952 |
| 950 if (m_pProperties->m_pDataProvider) { | 953 if (m_pProperties->m_pDataProvider) { |
| 951 IFWL_DateTimePickerDP* pData = | 954 IFWL_DateTimePickerDP* pData = |
| 952 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); | 955 static_cast<IFWL_DateTimePickerDP*>(m_pProperties->m_pDataProvider); |
| 953 pData->GetToday(m_pInterface, m_MonthCalendarDP.m_iCurYear, | 956 pData->GetToday(m_pInterface, m_MonthCalendarDP.m_iCurYear, |
| 954 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); | 957 m_MonthCalendarDP.m_iCurMonth, m_MonthCalendarDP.m_iCurDay); |
| 955 } | 958 } |
| 956 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>( | 959 FX_FLOAT* pWidth = static_cast<FX_FLOAT*>( |
| 957 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 960 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
| 958 if (!pWidth) | 961 if (!pWidth) |
| 959 return 0; | 962 return FWL_Error::Succeeded; |
| 963 |
| 960 m_fBtn = *pWidth; | 964 m_fBtn = *pWidth; |
| 961 CFX_RectF rtMonthCal; | 965 CFX_RectF rtMonthCal; |
| 962 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); | 966 m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); |
| 963 CFX_RectF rtPopUp; | 967 CFX_RectF rtPopUp; |
| 964 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, | 968 rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, |
| 965 rtMonthCal.width, rtMonthCal.height); | 969 rtMonthCal.width, rtMonthCal.height); |
| 966 m_pMonthCal->SetWidgetRect(rtPopUp); | 970 m_pMonthCal->SetWidgetRect(rtPopUp); |
| 967 m_pMonthCal->Update(); | 971 m_pMonthCal->Update(); |
| 968 return FWL_ERR_Succeeded; | 972 return FWL_Error::Succeeded; |
| 969 } | 973 } |
| 970 FWL_ERR CFWL_DateTimePickerImp::DisForm_GetWidgetRect(CFX_RectF& rect, | 974 |
| 971 FX_BOOL bAutoSize) { | 975 FWL_Error CFWL_DateTimePickerImp::DisForm_GetWidgetRect(CFX_RectF& rect, |
| 976 FX_BOOL bAutoSize) { |
| 972 rect = m_pProperties->m_rtWidget; | 977 rect = m_pProperties->m_rtWidget; |
| 973 if (DisForm_IsNeedShowButton()) { | 978 if (DisForm_IsNeedShowButton()) { |
| 974 rect.width += m_fBtn; | 979 rect.width += m_fBtn; |
| 975 } | 980 } |
| 976 return FWL_ERR_Succeeded; | 981 return FWL_Error::Succeeded; |
| 977 } | 982 } |
| 978 FWL_ERR CFWL_DateTimePickerImp::DisForm_GetBBox(CFX_RectF& rect) { | 983 FWL_Error CFWL_DateTimePickerImp::DisForm_GetBBox(CFX_RectF& rect) { |
| 979 rect = m_pProperties->m_rtWidget; | 984 rect = m_pProperties->m_rtWidget; |
| 980 if (DisForm_IsNeedShowButton()) { | 985 if (DisForm_IsNeedShowButton()) { |
| 981 rect.width += m_fBtn; | 986 rect.width += m_fBtn; |
| 982 } | 987 } |
| 983 if (IsMonthCalendarShowed()) { | 988 if (IsMonthCalendarShowed()) { |
| 984 CFX_RectF rtMonth; | 989 CFX_RectF rtMonth; |
| 985 m_pMonthCal->GetWidgetRect(rtMonth); | 990 m_pMonthCal->GetWidgetRect(rtMonth); |
| 986 rtMonth.Offset(m_pProperties->m_rtWidget.left, | 991 rtMonth.Offset(m_pProperties->m_rtWidget.left, |
| 987 m_pProperties->m_rtWidget.top); | 992 m_pProperties->m_rtWidget.top); |
| 988 rect.Union(rtMonth); | 993 rect.Union(rtMonth); |
| 989 } | 994 } |
| 990 return FWL_ERR_Succeeded; | 995 return FWL_Error::Succeeded; |
| 991 } | 996 } |
| 992 FWL_ERR CFWL_DateTimePickerImp::DisForm_DrawWidget(CFX_Graphics* pGraphics, | 997 FWL_Error CFWL_DateTimePickerImp::DisForm_DrawWidget( |
| 993 const CFX_Matrix* pMatrix) { | 998 CFX_Graphics* pGraphics, |
| 999 const CFX_Matrix* pMatrix) { |
| 994 if (!pGraphics) | 1000 if (!pGraphics) |
| 995 return FWL_ERR_Indefinite; | 1001 return FWL_Error::Indefinite; |
| 996 if (m_pEdit) { | 1002 if (m_pEdit) { |
| 997 CFX_RectF rtEdit; | 1003 CFX_RectF rtEdit; |
| 998 m_pEdit->GetWidgetRect(rtEdit); | 1004 m_pEdit->GetWidgetRect(rtEdit); |
| 999 CFX_Matrix mt; | 1005 CFX_Matrix mt; |
| 1000 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); | 1006 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); |
| 1001 if (pMatrix) { | 1007 if (pMatrix) { |
| 1002 mt.Concat(*pMatrix); | 1008 mt.Concat(*pMatrix); |
| 1003 } | 1009 } |
| 1004 m_pEdit->DrawWidget(pGraphics, &mt); | 1010 m_pEdit->DrawWidget(pGraphics, &mt); |
| 1005 } | 1011 } |
| 1006 if (IsMonthCalendarShowed()) { | 1012 if (IsMonthCalendarShowed()) { |
| 1007 CFX_RectF rtMonth; | 1013 CFX_RectF rtMonth; |
| 1008 m_pMonthCal->GetWidgetRect(rtMonth); | 1014 m_pMonthCal->GetWidgetRect(rtMonth); |
| 1009 CFX_Matrix mt; | 1015 CFX_Matrix mt; |
| 1010 mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); | 1016 mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); |
| 1011 if (pMatrix) { | 1017 if (pMatrix) { |
| 1012 mt.Concat(*pMatrix); | 1018 mt.Concat(*pMatrix); |
| 1013 } | 1019 } |
| 1014 m_pMonthCal->DrawWidget(pGraphics, &mt); | 1020 m_pMonthCal->DrawWidget(pGraphics, &mt); |
| 1015 } | 1021 } |
| 1016 return FWL_ERR_Succeeded; | 1022 return FWL_Error::Succeeded; |
| 1017 } | 1023 } |
| 1018 | 1024 |
| 1019 CFWL_DateTimePickerImpDelegate::CFWL_DateTimePickerImpDelegate( | 1025 CFWL_DateTimePickerImpDelegate::CFWL_DateTimePickerImpDelegate( |
| 1020 CFWL_DateTimePickerImp* pOwner) | 1026 CFWL_DateTimePickerImp* pOwner) |
| 1021 : m_pOwner(pOwner) {} | 1027 : m_pOwner(pOwner) {} |
| 1022 | 1028 |
| 1023 int32_t CFWL_DateTimePickerImpDelegate::OnProcessMessage( | 1029 void CFWL_DateTimePickerImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
| 1024 CFWL_Message* pMessage) { | |
| 1025 if (!pMessage) | 1030 if (!pMessage) |
| 1026 return 0; | 1031 return; |
| 1027 | 1032 |
| 1028 switch (pMessage->GetClassID()) { | 1033 switch (pMessage->GetClassID()) { |
| 1029 case CFWL_MessageType::SetFocus: { | 1034 case CFWL_MessageType::SetFocus: { |
| 1030 OnFocusChanged(pMessage, TRUE); | 1035 OnFocusChanged(pMessage, TRUE); |
| 1031 break; | 1036 break; |
| 1032 } | 1037 } |
| 1033 case CFWL_MessageType::KillFocus: { | 1038 case CFWL_MessageType::KillFocus: { |
| 1034 OnFocusChanged(pMessage, FALSE); | 1039 OnFocusChanged(pMessage, FALSE); |
| 1035 break; | 1040 break; |
| 1036 } | 1041 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1054 break; | 1059 break; |
| 1055 } | 1060 } |
| 1056 default: | 1061 default: |
| 1057 break; | 1062 break; |
| 1058 } | 1063 } |
| 1059 break; | 1064 break; |
| 1060 } | 1065 } |
| 1061 case CFWL_MessageType::Key: { | 1066 case CFWL_MessageType::Key: { |
| 1062 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { | 1067 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { |
| 1063 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); | 1068 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); |
| 1064 return pDelegate->OnProcessMessage(pMessage); | 1069 pDelegate->OnProcessMessage(pMessage); |
| 1070 return; |
| 1065 } | 1071 } |
| 1066 break; | 1072 break; |
| 1067 } | 1073 } |
| 1068 default: | 1074 default: |
| 1069 break; | 1075 break; |
| 1070 } | 1076 } |
| 1071 | 1077 |
| 1072 return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 1078 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
| 1073 } | 1079 } |
| 1074 | 1080 |
| 1075 FWL_ERR CFWL_DateTimePickerImpDelegate::OnDrawWidget( | 1081 void CFWL_DateTimePickerImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 1076 CFX_Graphics* pGraphics, | 1082 const CFX_Matrix* pMatrix) { |
| 1077 const CFX_Matrix* pMatrix) { | 1083 m_pOwner->DrawWidget(pGraphics, pMatrix); |
| 1078 return m_pOwner->DrawWidget(pGraphics, pMatrix); | |
| 1079 } | 1084 } |
| 1085 |
| 1080 void CFWL_DateTimePickerImpDelegate::OnFocusChanged(CFWL_Message* pMsg, | 1086 void CFWL_DateTimePickerImpDelegate::OnFocusChanged(CFWL_Message* pMsg, |
| 1081 FX_BOOL bSet) { | 1087 FX_BOOL bSet) { |
| 1082 if (!pMsg) | 1088 if (!pMsg) |
| 1083 return; | 1089 return; |
| 1084 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { | 1090 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { |
| 1085 return DisForm_OnFocusChanged(pMsg, bSet); | 1091 return DisForm_OnFocusChanged(pMsg, bSet); |
| 1086 } | 1092 } |
| 1087 if (bSet) { | 1093 if (bSet) { |
| 1088 m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); | 1094 m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); |
| 1089 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1095 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 } | 1174 } |
| 1169 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { | 1175 if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { |
| 1170 pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get(); | 1176 pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get(); |
| 1171 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); | 1177 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); |
| 1172 pDelegate->OnProcessMessage(pMsg); | 1178 pDelegate->OnProcessMessage(pMsg); |
| 1173 } | 1179 } |
| 1174 } | 1180 } |
| 1175 rtInvalidate.Inflate(2, 2); | 1181 rtInvalidate.Inflate(2, 2); |
| 1176 m_pOwner->Repaint(&rtInvalidate); | 1182 m_pOwner->Repaint(&rtInvalidate); |
| 1177 } | 1183 } |
| OLD | NEW |