| 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/lightwidget/cfwl_widget.h" | 7 #include "xfa/fwl/lightwidget/cfwl_widget.h" |
| 8 | 8 |
| 9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
| 10 #include "xfa/fwl/core/cfwl_themetext.h" | 10 #include "xfa/fwl/core/cfwl_themetext.h" |
| 11 #include "xfa/fwl/core/fwl_noteimp.h" | 11 #include "xfa/fwl/core/fwl_noteimp.h" |
| 12 #include "xfa/fwl/core/fwl_noteimp.h" | 12 #include "xfa/fwl/core/fwl_noteimp.h" |
| 13 #include "xfa/fwl/core/fwl_widgetimp.h" | 13 #include "xfa/fwl/core/fwl_widgetimp.h" |
| 14 #include "xfa/fwl/core/fwl_widgetmgrimp.h" | 14 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
| 15 #include "xfa/fwl/core/ifwl_app.h" | 15 #include "xfa/fwl/core/ifwl_app.h" |
| 16 #include "xfa/fwl/core/ifwl_themeprovider.h" | 16 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 17 | 17 |
| 18 #define FWL_WGT_CalcHeight 2048 |
| 19 #define FWL_WGT_CalcWidth 2048 |
| 20 #define FWL_WGT_CalcMultiLineDefWidth 120.0f |
| 21 |
| 18 IFWL_Widget* CFWL_Widget::GetWidget() { | 22 IFWL_Widget* CFWL_Widget::GetWidget() { |
| 19 return m_pIface; | 23 return m_pIface; |
| 20 } | 24 } |
| 21 | 25 |
| 22 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { | 26 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { |
| 23 if (!m_pIface) | 27 if (!m_pIface) |
| 24 return FWL_ERR_Indefinite; | 28 return FWL_ERR_Indefinite; |
| 25 return m_pIface->GetClassName(wsClass); | 29 return m_pIface->GetClassName(wsClass); |
| 26 } | 30 } |
| 27 | 31 |
| 28 uint32_t CFWL_Widget::GetClassID() const { | 32 uint32_t CFWL_Widget::GetClassID() const { |
| 29 if (!m_pIface) | 33 if (!m_pIface) |
| 30 return 0; | 34 return 0; |
| 31 return m_pIface->GetClassID(); | 35 return m_pIface->GetClassID(); |
| 32 } | 36 } |
| 33 | 37 |
| 34 FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { | 38 FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { |
| 35 if (!m_pIface) | 39 if (!m_pIface) |
| 36 return FALSE; | 40 return FALSE; |
| 37 return m_pIface->IsInstance(wsClass); | 41 return m_pIface->IsInstance(wsClass); |
| 38 } | 42 } |
| 39 | 43 |
| 40 static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't'); | 44 static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't'); |
| 41 | 45 |
| 42 FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) { | 46 FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) { |
| 43 if (!m_pIface) | 47 if (!m_pIface) |
| 44 return FWL_ERR_Indefinite; | 48 return FWL_ERR_Indefinite; |
| 45 return m_pIface->SetPrivateData(gs_pFWLWidget, this, NULL); | 49 return m_pIface->SetPrivateData(gs_pFWLWidget, this, nullptr); |
| 46 } | 50 } |
| 47 | 51 |
| 48 FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 52 FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 49 if (!m_pIface) | 53 if (!m_pIface) |
| 50 return FWL_ERR_Indefinite; | 54 return FWL_ERR_Indefinite; |
| 51 return m_pIface->GetWidgetRect(rect, bAutoSize); | 55 return m_pIface->GetWidgetRect(rect, bAutoSize); |
| 52 } | 56 } |
| 53 | 57 |
| 54 FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) { | 58 FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) { |
| 55 if (!m_pIface) | 59 if (!m_pIface) |
| 56 return FWL_ERR_Indefinite; | 60 return FWL_ERR_Indefinite; |
| 57 return m_pIface->GetGlobalRect(rect); | 61 return m_pIface->GetGlobalRect(rect); |
| 58 } | 62 } |
| 59 | 63 |
| 60 FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { | 64 FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { |
| 61 if (!m_pIface) | 65 if (!m_pIface) |
| 62 return FWL_ERR_Indefinite; | 66 return FWL_ERR_Indefinite; |
| 63 return m_pIface->SetWidgetRect(rect); | 67 return m_pIface->SetWidgetRect(rect); |
| 64 } | 68 } |
| 65 | 69 |
| 66 FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) { | 70 FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) { |
| 67 if (!m_pIface) | 71 if (!m_pIface) |
| 68 return FWL_ERR_Indefinite; | 72 return FWL_ERR_Indefinite; |
| 69 return m_pIface->GetClientRect(rect); | 73 return m_pIface->GetClientRect(rect); |
| 70 } | 74 } |
| 71 | 75 |
| 72 CFWL_Widget* CFWL_Widget::GetParent() { | 76 CFWL_Widget* CFWL_Widget::GetParent() { |
| 73 if (!m_pIface) | 77 if (!m_pIface) |
| 74 return NULL; | 78 return nullptr; |
| 79 |
| 75 IFWL_Widget* parent = m_pIface->GetParent(); | 80 IFWL_Widget* parent = m_pIface->GetParent(); |
| 76 if (parent) { | 81 if (parent) |
| 77 return static_cast<CFWL_Widget*>(parent->GetPrivateData(gs_pFWLWidget)); | 82 return static_cast<CFWL_Widget*>(parent->GetPrivateData(gs_pFWLWidget)); |
| 78 } | 83 return nullptr; |
| 79 return NULL; | |
| 80 } | 84 } |
| 81 | 85 |
| 82 FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) { | 86 FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) { |
| 83 if (!m_pIface) | 87 if (!m_pIface) |
| 84 return FWL_ERR_Indefinite; | 88 return FWL_ERR_Indefinite; |
| 85 return m_pIface->SetParent(pParent ? pParent->GetWidget() : NULL); | 89 return m_pIface->SetParent(pParent ? pParent->GetWidget() : nullptr); |
| 86 } | 90 } |
| 87 | 91 |
| 88 CFWL_Widget* CFWL_Widget::GetOwner() { | 92 CFWL_Widget* CFWL_Widget::GetOwner() { |
| 89 if (!m_pIface) | 93 return nullptr; |
| 90 return NULL; | |
| 91 return NULL; | |
| 92 } | 94 } |
| 93 | 95 |
| 94 FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) { | 96 FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) { |
| 95 if (!m_pIface) | 97 if (!m_pIface) |
| 96 return FWL_ERR_Indefinite; | 98 return FWL_ERR_Indefinite; |
| 97 return FWL_ERR_Succeeded; | 99 return FWL_ERR_Succeeded; |
| 98 } | 100 } |
| 99 | 101 |
| 100 uint32_t CFWL_Widget::GetStyles() { | 102 uint32_t CFWL_Widget::GetStyles() { |
| 101 if (!m_pIface) | 103 if (!m_pIface) |
| 102 return 0; | 104 return 0; |
| 103 return m_pIface->GetStyles(); | 105 return m_pIface->GetStyles(); |
| 104 } | 106 } |
| 105 | 107 |
| 106 FWL_ERR CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, | 108 FWL_ERR CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, |
| 107 uint32_t dwStylesRemoved) { | 109 uint32_t dwStylesRemoved) { |
| 108 if (!m_pIface) | 110 if (!m_pIface) |
| 109 return FWL_ERR_Indefinite; | 111 return FWL_ERR_Indefinite; |
| 110 return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved); | 112 return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved); |
| 111 } | 113 } |
| 114 |
| 112 uint32_t CFWL_Widget::GetStylesEx() { | 115 uint32_t CFWL_Widget::GetStylesEx() { |
| 113 if (!m_pIface) | 116 if (!m_pIface) |
| 114 return 0; | 117 return 0; |
| 115 return m_pIface->GetStylesEx(); | 118 return m_pIface->GetStylesEx(); |
| 116 } | 119 } |
| 117 | 120 |
| 118 FWL_ERR CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, | 121 FWL_ERR CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, |
| 119 uint32_t dwStylesExRemoved) { | 122 uint32_t dwStylesExRemoved) { |
| 120 return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); | 123 return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); |
| 121 } | 124 } |
| 122 | 125 |
| 123 uint32_t CFWL_Widget::GetStates() { | 126 uint32_t CFWL_Widget::GetStates() { |
| 124 if (!m_pIface) | 127 if (!m_pIface) |
| 125 return FWL_ERR_Indefinite; | 128 return FWL_ERR_Indefinite; |
| 126 return m_pIface->GetStates(); | 129 return m_pIface->GetStates(); |
| 127 } | 130 } |
| 128 | 131 |
| 129 FWL_ERR CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { | 132 void CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
| 130 if (!m_pIface) | 133 if (m_pIface) |
| 131 return FWL_ERR_Indefinite; | 134 m_pIface->SetStates(dwStates, bSet); |
| 132 return m_pIface->SetStates(dwStates, bSet); | |
| 133 } | 135 } |
| 134 | 136 |
| 135 FWL_ERR CFWL_Widget::SetPrivateData(void* module_id, | 137 FWL_ERR CFWL_Widget::SetPrivateData(void* module_id, |
| 136 void* pData, | 138 void* pData, |
| 137 PD_CALLBACK_FREEDATA callback) { | 139 PD_CALLBACK_FREEDATA callback) { |
| 138 if (!m_pIface) | 140 if (!m_pIface) |
| 139 return FWL_ERR_Indefinite; | 141 return FWL_ERR_Indefinite; |
| 140 return m_pIface->SetPrivateData(module_id, pData, callback); | 142 return m_pIface->SetPrivateData(module_id, pData, callback); |
| 141 } | 143 } |
| 142 | 144 |
| 143 void* CFWL_Widget::GetPrivateData(void* module_id) { | 145 void* CFWL_Widget::GetPrivateData(void* module_id) { |
| 144 if (!m_pIface) | 146 if (!m_pIface) |
| 145 return NULL; | 147 return nullptr; |
| 146 return m_pIface->GetPrivateData(module_id); | 148 return m_pIface->GetPrivateData(module_id); |
| 147 } | 149 } |
| 148 | 150 |
| 149 FWL_ERR CFWL_Widget::Update() { | 151 FWL_ERR CFWL_Widget::Update() { |
| 150 if (!m_pIface) | 152 if (!m_pIface) |
| 151 return FWL_ERR_Indefinite; | 153 return FWL_ERR_Indefinite; |
| 152 return m_pIface->Update(); | 154 return m_pIface->Update(); |
| 153 } | 155 } |
| 154 | 156 |
| 155 FWL_ERR CFWL_Widget::LockUpdate() { | 157 FWL_ERR CFWL_Widget::LockUpdate() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 168 if (!m_pIface) | 170 if (!m_pIface) |
| 169 return FWL_WidgetHit::Unknown; | 171 return FWL_WidgetHit::Unknown; |
| 170 return m_pIface->HitTest(fx, fy); | 172 return m_pIface->HitTest(fx, fy); |
| 171 } | 173 } |
| 172 | 174 |
| 173 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, | 175 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, |
| 174 FX_FLOAT& fx, | 176 FX_FLOAT& fx, |
| 175 FX_FLOAT& fy) { | 177 FX_FLOAT& fy) { |
| 176 if (!m_pIface) | 178 if (!m_pIface) |
| 177 return FWL_ERR_Indefinite; | 179 return FWL_ERR_Indefinite; |
| 178 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, fx, fy); | 180 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : nullptr, fx, |
| 181 fy); |
| 179 } | 182 } |
| 180 | 183 |
| 181 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) { | 184 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) { |
| 182 if (!m_pIface) | 185 if (!m_pIface) |
| 183 return FWL_ERR_Indefinite; | 186 return FWL_ERR_Indefinite; |
| 184 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, rt); | 187 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : nullptr, rt); |
| 185 } | 188 } |
| 186 | 189 |
| 187 FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { | 190 FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { |
| 188 if (!m_pIface) | 191 if (!m_pIface) |
| 189 return FWL_ERR_Indefinite; | 192 return FWL_ERR_Indefinite; |
| 190 return m_pIface->GetMatrix(matrix, bGlobal); | 193 return m_pIface->GetMatrix(matrix, bGlobal); |
| 191 } | 194 } |
| 192 | 195 |
| 193 FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { | 196 FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { |
| 194 if (!m_pIface) | 197 if (!m_pIface) |
| 195 return FWL_ERR_Indefinite; | 198 return FWL_ERR_Indefinite; |
| 196 return m_pIface->SetMatrix(matrix); | 199 return m_pIface->SetMatrix(matrix); |
| 197 } | 200 } |
| 198 | 201 |
| 199 FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, | 202 FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, |
| 200 const CFX_Matrix* pMatrix) { | 203 const CFX_Matrix* pMatrix) { |
| 201 if (!m_pIface) | 204 if (!m_pIface) |
| 202 return FWL_ERR_Indefinite; | 205 return FWL_ERR_Indefinite; |
| 203 return m_pIface->DrawWidget(pGraphics, pMatrix); | 206 return m_pIface->DrawWidget(pGraphics, pMatrix); |
| 204 } | 207 } |
| 205 | 208 |
| 206 IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { | 209 IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { |
| 207 if (!m_pIface) | 210 if (!m_pIface) |
| 208 return NULL; | 211 return nullptr; |
| 212 |
| 209 m_pDelegate = m_pIface->SetDelegate(pDelegate); | 213 m_pDelegate = m_pIface->SetDelegate(pDelegate); |
| 210 return m_pDelegate; | 214 return m_pDelegate; |
| 211 } | 215 } |
| 212 | 216 |
| 213 CFWL_Widget::CFWL_Widget() | 217 CFWL_Widget::CFWL_Widget() |
| 214 : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) { | 218 : m_pIface(nullptr), m_pDelegate(nullptr), m_pProperties(nullptr) { |
| 215 m_pProperties = new CFWL_WidgetProperties; | 219 m_pProperties = new CFWL_WidgetProperties; |
| 216 m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 220 m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
| 217 ASSERT(m_pWidgetMgr); | 221 ASSERT(m_pWidgetMgr); |
| 218 } | 222 } |
| 219 | 223 |
| 220 CFWL_Widget::~CFWL_Widget() { | 224 CFWL_Widget::~CFWL_Widget() { |
| 221 delete m_pProperties; | 225 delete m_pProperties; |
| 222 if (m_pIface) { | 226 if (m_pIface) { |
| 223 m_pIface->Finalize(); | 227 m_pIface->Finalize(); |
| 224 delete m_pIface; | 228 delete m_pIface; |
| 225 } | 229 } |
| 226 } | 230 } |
| 227 | 231 |
| 228 FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) { | 232 FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) { |
| 229 if (!m_pIface) | 233 if (!m_pIface) |
| 230 return FWL_ERR_Indefinite; | 234 return FWL_ERR_Indefinite; |
| 235 |
| 231 CFX_RectF rect; | 236 CFX_RectF rect; |
| 232 if (pRect) { | 237 if (pRect) { |
| 233 rect = *pRect; | 238 rect = *pRect; |
| 234 } else { | 239 } else { |
| 235 m_pIface->GetWidgetRect(rect); | 240 m_pIface->GetWidgetRect(rect); |
| 236 rect.left = rect.top = 0; | 241 rect.left = rect.top = 0; |
| 237 } | 242 } |
| 238 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); | 243 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); |
| 239 } | 244 } |
| 240 | 245 |
| 241 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) { | 246 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) { |
| 242 if (!m_pIface) | 247 if (!m_pIface) |
| 243 return FWL_ERR_Indefinite; | 248 return FWL_ERR_Indefinite; |
| 244 | 249 |
| 245 IFWL_App* pApp = m_pIface->GetOwnerApp(); | 250 IFWL_App* pApp = m_pIface->GetOwnerApp(); |
| 246 if (!pApp) | 251 if (!pApp) |
| 247 return FWL_ERR_Indefinite; | 252 return FWL_ERR_Indefinite; |
| 248 | 253 |
| 249 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); | 254 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); |
| 250 if (!pDriver) | 255 if (!pDriver) |
| 251 return FWL_ERR_Indefinite; | 256 return FWL_ERR_Indefinite; |
| 252 | 257 |
| 253 if (bFocus) { | 258 if (bFocus) { |
| 254 pDriver->SetFocus(m_pIface); | 259 pDriver->SetFocus(m_pIface); |
| 255 } else { | 260 } else { |
| 256 if (pDriver->GetFocus() == m_pIface) { | 261 if (pDriver->GetFocus() == m_pIface) { |
| 257 pDriver->SetFocus(NULL); | 262 pDriver->SetFocus(nullptr); |
| 258 } | 263 } |
| 259 } | 264 } |
| 260 return FWL_ERR_Succeeded; | 265 return FWL_ERR_Succeeded; |
| 261 } | 266 } |
| 262 | 267 |
| 263 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) { | 268 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) { |
| 264 if (!m_pIface) | 269 if (!m_pIface) |
| 265 return FWL_ERR_Indefinite; | 270 return FWL_ERR_Indefinite; |
| 266 | 271 |
| 267 IFWL_App* pApp = m_pIface->GetOwnerApp(); | 272 IFWL_App* pApp = m_pIface->GetOwnerApp(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 283 | 288 |
| 284 IFWL_App* pApp = m_pIface->GetOwnerApp(); | 289 IFWL_App* pApp = m_pIface->GetOwnerApp(); |
| 285 if (!pApp) | 290 if (!pApp) |
| 286 return; | 291 return; |
| 287 | 292 |
| 288 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 293 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
| 289 if (!pNoteDriver) | 294 if (!pNoteDriver) |
| 290 return; | 295 return; |
| 291 | 296 |
| 292 IFWL_Widget* pEventSourceImp = | 297 IFWL_Widget* pEventSourceImp = |
| 293 !pEventSource ? NULL : pEventSource->GetWidget(); | 298 !pEventSource ? nullptr : pEventSource->GetWidget(); |
| 294 pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); | 299 pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); |
| 295 } | 300 } |
| 296 | 301 |
| 297 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { | 302 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { |
| 298 if (!m_pIface) | 303 if (!m_pIface) |
| 299 return; | 304 return; |
| 300 if (m_pIface->GetOuter()) { | 305 if (m_pIface->GetOuter()) |
| 301 return; | 306 return; |
| 302 } | 307 |
| 303 IFWL_App* pApp = m_pIface->GetOwnerApp(); | 308 IFWL_App* pApp = m_pIface->GetOwnerApp(); |
| 304 if (!pApp) | 309 if (!pApp) |
| 305 return; | 310 return; |
| 311 |
| 306 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 312 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
| 307 if (!pNoteDriver) | 313 if (!pNoteDriver) |
| 308 return; | 314 return; |
| 315 |
| 309 pNoteDriver->SendEvent(pEvent); | 316 pNoteDriver->SendEvent(pEvent); |
| 310 } | 317 } |
| 311 | 318 |
| 312 #define FWL_WGT_CalcHeight 2048 | |
| 313 #define FWL_WGT_CalcWidth 2048 | |
| 314 #define FWL_WGT_CalcMultiLineDefWidth 120.0f | |
| 315 | |
| 316 CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, | 319 CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, |
| 317 FX_BOOL bMultiLine, | 320 FX_BOOL bMultiLine, |
| 318 int32_t iLineWidth) { | 321 int32_t iLineWidth) { |
| 319 if (!m_pIface) | 322 if (!m_pIface) |
| 320 return CFX_SizeF(); | 323 return CFX_SizeF(); |
| 324 |
| 321 IFWL_ThemeProvider* pTheme = m_pIface->GetThemeProvider(); | 325 IFWL_ThemeProvider* pTheme = m_pIface->GetThemeProvider(); |
| 322 if (!pTheme) | 326 if (!pTheme) |
| 323 return CFX_SizeF(); | 327 return CFX_SizeF(); |
| 324 | 328 |
| 325 CFWL_ThemeText calPart; | 329 CFWL_ThemeText calPart; |
| 326 calPart.m_pWidget = m_pIface; | 330 calPart.m_pWidget = m_pIface; |
| 327 calPart.m_wsText = wsText; | 331 calPart.m_wsText = wsText; |
| 328 calPart.m_dwTTOStyles = | 332 calPart.m_dwTTOStyles = |
| 329 bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; | 333 bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; |
| 330 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; | 334 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; |
| 331 CFX_RectF rect; | 335 CFX_RectF rect; |
| 332 FX_FLOAT fWidth = bMultiLine | 336 FX_FLOAT fWidth = bMultiLine |
| 333 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth | 337 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth |
| 334 : FWL_WGT_CalcMultiLineDefWidth) | 338 : FWL_WGT_CalcMultiLineDefWidth) |
| 335 : FWL_WGT_CalcWidth; | 339 : FWL_WGT_CalcWidth; |
| 336 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); | 340 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); |
| 337 pTheme->CalcTextRect(&calPart, rect); | 341 pTheme->CalcTextRect(&calPart, rect); |
| 338 return CFX_SizeF(rect.width, rect.height); | 342 return CFX_SizeF(rect.width, rect.height); |
| 339 } | 343 } |
| OLD | NEW |