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

Unified Diff: xfa/fwl/core/ifwl_listbox.cpp

Issue 2432423002: Merge the CFWL_*Imp classes into the IFWL_* classes. (Closed)
Patch Set: Review feedback Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « xfa/fwl/core/ifwl_listbox.h ('k') | xfa/fwl/core/ifwl_monthcalendar.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fwl/core/ifwl_listbox.cpp
diff --git a/xfa/fwl/basewidget/fwl_listboximp.cpp b/xfa/fwl/core/ifwl_listbox.cpp
similarity index 77%
rename from xfa/fwl/basewidget/fwl_listboximp.cpp
rename to xfa/fwl/core/ifwl_listbox.cpp
index 33a0a8d1ee70baeaa47f62befb1360d9eff80bf8..a0a9eacd27ce497210e02d30e3aac3791e9e2503 100644
--- a/xfa/fwl/basewidget/fwl_listboximp.cpp
+++ b/xfa/fwl/core/ifwl_listbox.cpp
@@ -4,16 +4,13 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fwl/basewidget/fwl_listboximp.h"
+#include "xfa/fwl/core/ifwl_listbox.h"
#include "xfa/fde/tto/fde_textout.h"
-#include "xfa/fwl/basewidget/fwl_comboboximp.h"
-#include "xfa/fwl/basewidget/fwl_scrollbarimp.h"
#include "xfa/fwl/core/cfwl_message.h"
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/cfwl_themetext.h"
-#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_app.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
@@ -26,46 +23,12 @@ const int kItemTextMargin = 2;
// static
IFWL_ListBox* IFWL_ListBox::Create(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter) {
- IFWL_ListBox* pListBox = new IFWL_ListBox;
- CFWL_ListBoxImp* pListBoxImpl = new CFWL_ListBoxImp(properties, pOuter);
- pListBox->SetImpl(pListBoxImpl);
- pListBoxImpl->SetInterface(pListBox);
- return pListBox;
-}
-// static
-IFWL_ListBox* IFWL_ListBox::CreateComboList(
- const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter) {
- IFWL_ListBox* pListBox = new IFWL_ListBox;
- CFWL_ListBoxImp* pComboListImpl = new CFWL_ComboListImp(properties, pOuter);
- pListBox->SetImpl(pComboListImpl);
- pComboListImpl->SetInterface(pListBox);
- return pListBox;
-}
-IFWL_ListBox::IFWL_ListBox() {}
-int32_t IFWL_ListBox::CountSelItems() {
- return static_cast<CFWL_ListBoxImp*>(GetImpl())->CountSelItems();
-}
-IFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) {
- return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelItem(nIndexSel);
-}
-int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) {
- return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelIndex(nIndex);
-}
-FWL_Error IFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) {
- return static_cast<CFWL_ListBoxImp*>(GetImpl())->SetSelItem(pItem, bSelect);
-}
-FWL_Error IFWL_ListBox::GetItemText(IFWL_ListItem* pItem,
- CFX_WideString& wsText) {
- return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetItemText(pItem, wsText);
-}
-FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
- return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetScrollPos(fPos, bVert);
+ return new IFWL_ListBox(properties, pOuter);
}
-CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_WidgetImp(properties, pOuter),
+IFWL_ListBox::IFWL_ListBox(const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : IFWL_Widget(properties, pOuter),
m_dwTTOStyles(0),
m_iTTOAligns(0),
m_hAnchor(nullptr),
@@ -77,26 +40,26 @@ CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties,
m_rtStatic.Reset();
}
-CFWL_ListBoxImp::~CFWL_ListBoxImp() {}
+IFWL_ListBox::~IFWL_ListBox() {}
-FWL_Error CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const {
+FWL_Error IFWL_ListBox::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_ListBox;
return FWL_Error::Succeeded;
}
-FWL_Type CFWL_ListBoxImp::GetClassID() const {
+FWL_Type IFWL_ListBox::GetClassID() const {
return FWL_Type::ListBox;
}
-FWL_Error CFWL_ListBoxImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded)
+FWL_Error IFWL_ListBox::Initialize() {
+ if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
return FWL_Error::Indefinite;
m_pDelegate = new CFWL_ListBoxImpDelegate(this);
return FWL_Error::Succeeded;
}
-FWL_Error CFWL_ListBoxImp::Finalize() {
+FWL_Error IFWL_ListBox::Finalize() {
if (m_pVertScrollBar) {
m_pVertScrollBar->Finalize();
}
@@ -105,9 +68,10 @@ FWL_Error CFWL_ListBoxImp::Finalize() {
}
delete m_pDelegate;
m_pDelegate = nullptr;
- return CFWL_WidgetImp::Finalize();
+ return IFWL_Widget::Finalize();
}
-FWL_Error CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
+
+FWL_Error IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
if (!m_pProperties->m_pThemeProvider) {
@@ -115,13 +79,14 @@ FWL_Error CFWL_ListBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
}
CFX_SizeF fs = CalcSize(TRUE);
rect.Set(0, 0, fs.x, fs.y);
- CFWL_WidgetImp::GetWidgetRect(rect, TRUE);
+ IFWL_Widget::GetWidgetRect(rect, TRUE);
} else {
rect = m_pProperties->m_rtWidget;
}
return FWL_Error::Succeeded;
}
-FWL_Error CFWL_ListBoxImp::Update() {
+
+FWL_Error IFWL_ListBox::Update() {
if (IsLocked()) {
return FWL_Error::Indefinite;
}
@@ -149,7 +114,8 @@ FWL_Error CFWL_ListBoxImp::Update() {
CalcSize();
return FWL_Error::Succeeded;
}
-FWL_WidgetHit CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+
+FWL_WidgetHit IFWL_ListBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
if (IsShowScrollBar(FALSE)) {
CFX_RectF rect;
m_pHorzScrollBar->GetWidgetRect(rect);
@@ -166,8 +132,9 @@ FWL_WidgetHit CFWL_ListBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
return FWL_WidgetHit::Client;
return FWL_WidgetHit::Unknown;
}
-FWL_Error CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
+
+FWL_Error IFWL_ListBox::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
return FWL_Error::Indefinite;
if (!m_pProperties->m_pThemeProvider)
@@ -198,45 +165,46 @@ FWL_Error CFWL_ListBoxImp::DrawWidget(CFX_Graphics* pGraphics,
pGraphics->RestoreGraphState();
return FWL_Error::Succeeded;
}
-FWL_Error CFWL_ListBoxImp::SetThemeProvider(
- IFWL_ThemeProvider* pThemeProvider) {
+
+FWL_Error IFWL_ListBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
if (!pThemeProvider)
return FWL_Error::Indefinite;
m_pProperties->m_pThemeProvider = pThemeProvider;
return FWL_Error::Succeeded;
}
-int32_t CFWL_ListBoxImp::CountSelItems() {
+int32_t IFWL_ListBox::CountSelItems() {
if (!m_pProperties->m_pDataProvider)
return 0;
int32_t iRet = 0;
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
for (int32_t i = 0; i < iCount; i++) {
- IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i);
+ IFWL_ListItem* pItem = pData->GetItem(this, i);
if (!pItem) {
continue;
}
- uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem);
+ uint32_t dwStyle = pData->GetItemStyles(this, pItem);
if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
iRet++;
}
}
return iRet;
}
-IFWL_ListItem* CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel) {
+
+IFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) {
if (!m_pProperties->m_pDataProvider)
return nullptr;
int32_t index = 0;
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
for (int32_t i = 0; i < iCount; i++) {
- IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i);
+ IFWL_ListItem* pItem = pData->GetItem(this, i);
if (!pItem) {
return nullptr;
}
- uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem);
+ uint32_t dwStyle = pData->GetItemStyles(this, pItem);
if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
if (index == nIndexSel) {
return pItem;
@@ -247,19 +215,20 @@ IFWL_ListItem* CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel) {
}
return nullptr;
}
-int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex) {
+
+int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) {
if (!m_pProperties->m_pDataProvider)
return -1;
int32_t index = 0;
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
for (int32_t i = 0; i < iCount; i++) {
- IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i);
+ IFWL_ListItem* pItem = pData->GetItem(this, i);
if (!pItem) {
return -1;
}
- uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem);
+ uint32_t dwStyle = pData->GetItemStyles(this, pItem);
if (dwStyle & FWL_ITEMSTATE_LTB_Selected) {
if (index == nIndex) {
return i;
@@ -270,7 +239,8 @@ int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex) {
}
return -1;
}
-FWL_Error CFWL_ListBoxImp::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) {
+
+FWL_Error IFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) {
if (!m_pProperties->m_pDataProvider)
return FWL_Error::Indefinite;
if (!pItem) {
@@ -289,19 +259,20 @@ FWL_Error CFWL_ListBoxImp::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) {
}
return FWL_Error::Succeeded;
}
-FWL_Error CFWL_ListBoxImp::GetItemText(IFWL_ListItem* pItem,
- CFX_WideString& wsText) {
+
+FWL_Error IFWL_ListBox::GetItemText(IFWL_ListItem* pItem,
+ CFX_WideString& wsText) {
if (!m_pProperties->m_pDataProvider)
return FWL_Error::Indefinite;
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
if (!pItem)
return FWL_Error::Indefinite;
- pData->GetItemText(m_pInterface, pItem, wsText);
+ pData->GetItemText(this, pItem, wsText);
return FWL_Error::Succeeded;
}
-FWL_Error CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
+FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) {
IFWL_ScrollBar* pScrollBar =
bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get();
@@ -311,8 +282,7 @@ FWL_Error CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
return FWL_Error::Indefinite;
}
-IFWL_ListItem* CFWL_ListBoxImp::GetItem(IFWL_ListItem* pItem,
- uint32_t dwKeyCode) {
+IFWL_ListItem* IFWL_ListBox::GetItem(IFWL_ListItem* pItem, uint32_t dwKeyCode) {
IFWL_ListItem* hRet = nullptr;
switch (dwKeyCode) {
case FWL_VKEY_Up:
@@ -326,69 +296,72 @@ IFWL_ListItem* CFWL_ListBoxImp::GetItem(IFWL_ListItem* pItem,
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
int32_t iDstItem = -1;
if (bUp || bDown) {
- int32_t index = pData->GetItemIndex(m_pInterface, pItem);
+ int32_t index = pData->GetItemIndex(this, pItem);
iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1;
} else if (bHome) {
iDstItem = 0;
} else {
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
iDstItem = iCount - 1;
}
- hRet = pData->GetItem(m_pInterface, iDstItem);
+ hRet = pData->GetItem(this, iDstItem);
break;
}
default: {}
}
return hRet;
}
-void CFWL_ListBoxImp::SetSelection(IFWL_ListItem* hStart,
- IFWL_ListItem* hEnd,
- FX_BOOL bSelected) {
+
+void IFWL_ListBox::SetSelection(IFWL_ListItem* hStart,
+ IFWL_ListItem* hEnd,
+ FX_BOOL bSelected) {
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t iStart = pData->GetItemIndex(m_pInterface, hStart);
- int32_t iEnd = pData->GetItemIndex(m_pInterface, hEnd);
+ int32_t iStart = pData->GetItemIndex(this, hStart);
+ int32_t iEnd = pData->GetItemIndex(this, hEnd);
if (iStart > iEnd) {
int32_t iTemp = iStart;
iStart = iEnd;
iEnd = iTemp;
}
if (bSelected) {
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
for (int32_t i = 0; i < iCount; i++) {
- IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i);
+ IFWL_ListItem* pItem = pData->GetItem(this, i);
SetSelectionDirect(pItem, FALSE);
}
}
for (; iStart <= iEnd; iStart++) {
- IFWL_ListItem* pItem = pData->GetItem(m_pInterface, iStart);
+ IFWL_ListItem* pItem = pData->GetItem(this, iStart);
SetSelectionDirect(pItem, bSelected);
}
}
-void CFWL_ListBoxImp::SetSelectionDirect(IFWL_ListItem* pItem,
- FX_BOOL bSelect) {
+
+void IFWL_ListBox::SetSelectionDirect(IFWL_ListItem* pItem, FX_BOOL bSelect) {
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- uint32_t dwOldStyle = pData->GetItemStyles(m_pInterface, pItem);
+ uint32_t dwOldStyle = pData->GetItemStyles(this, pItem);
bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected
: dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected;
- pData->SetItemStyles(m_pInterface, pItem, dwOldStyle);
+ pData->SetItemStyles(this, pItem, dwOldStyle);
}
-FX_BOOL CFWL_ListBoxImp::IsItemSelected(IFWL_ListItem* pItem) {
+
+FX_BOOL IFWL_ListBox::IsItemSelected(IFWL_ListItem* pItem) {
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- uint32_t dwState = pData->GetItemStyles(m_pInterface, pItem);
+ uint32_t dwState = pData->GetItemStyles(this, pItem);
return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0;
}
-void CFWL_ListBoxImp::ClearSelection() {
+
+void IFWL_ListBox::ClearSelection() {
FX_BOOL bMulti =
m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection;
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
for (int32_t i = 0; i < iCount; i++) {
- IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i);
- uint32_t dwState = pData->GetItemStyles(m_pInterface, pItem);
+ IFWL_ListItem* pItem = pData->GetItem(this, i);
+ uint32_t dwState = pData->GetItemStyles(this, pItem);
if (!(dwState & FWL_ITEMSTATE_LTB_Selected))
continue;
SetSelectionDirect(pItem, FALSE);
@@ -396,7 +369,8 @@ void CFWL_ListBoxImp::ClearSelection() {
return;
}
}
-void CFWL_ListBoxImp::SelectAll() {
+
+void IFWL_ListBox::SelectAll() {
FX_BOOL bMulti =
m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection;
if (!bMulti) {
@@ -404,45 +378,48 @@ void CFWL_ListBoxImp::SelectAll() {
}
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
if (iCount > 0) {
- IFWL_ListItem* pItemStart = pData->GetItem(m_pInterface, 0);
- IFWL_ListItem* pItemEnd = pData->GetItem(m_pInterface, iCount - 1);
+ IFWL_ListItem* pItemStart = pData->GetItem(this, 0);
+ IFWL_ListItem* pItemEnd = pData->GetItem(this, iCount - 1);
SetSelection(pItemStart, pItemEnd, FALSE);
}
}
-IFWL_ListItem* CFWL_ListBoxImp::GetFocusedItem() {
+
+IFWL_ListItem* IFWL_ListBox::GetFocusedItem() {
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
for (int32_t i = 0; i < iCount; i++) {
- IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i);
+ IFWL_ListItem* pItem = pData->GetItem(this, i);
if (!pItem)
return nullptr;
- if (pData->GetItemStyles(m_pInterface, pItem) & FWL_ITEMSTATE_LTB_Focused) {
+ if (pData->GetItemStyles(this, pItem) & FWL_ITEMSTATE_LTB_Focused) {
return pItem;
}
}
return nullptr;
}
-void CFWL_ListBoxImp::SetFocusItem(IFWL_ListItem* pItem) {
+
+void IFWL_ListBox::SetFocusItem(IFWL_ListItem* pItem) {
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
IFWL_ListItem* hFocus = GetFocusedItem();
if (pItem != hFocus) {
if (hFocus) {
- uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hFocus);
+ uint32_t dwStyle = pData->GetItemStyles(this, hFocus);
dwStyle &= ~FWL_ITEMSTATE_LTB_Focused;
- pData->SetItemStyles(m_pInterface, hFocus, dwStyle);
+ pData->SetItemStyles(this, hFocus, dwStyle);
}
if (pItem) {
- uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem);
+ uint32_t dwStyle = pData->GetItemStyles(this, pItem);
dwStyle |= FWL_ITEMSTATE_LTB_Focused;
- pData->SetItemStyles(m_pInterface, pItem, dwStyle);
+ pData->SetItemStyles(this, pItem, dwStyle);
}
}
}
-IFWL_ListItem* CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
+
+IFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
fx -= m_rtConent.left, fy -= m_rtConent.top;
FX_FLOAT fPosX = 0.0f;
if (m_pHorzScrollBar) {
@@ -454,14 +431,14 @@ IFWL_ListItem* CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
}
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t nCount = pData->CountItems(m_pInterface);
+ int32_t nCount = pData->CountItems(this);
for (int32_t i = 0; i < nCount; i++) {
- IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i);
+ IFWL_ListItem* pItem = pData->GetItem(this, i);
if (!pItem) {
continue;
}
CFX_RectF rtItem;
- pData->GetItemRect(m_pInterface, pItem, rtItem);
+ pData->GetItemRect(this, pItem, rtItem);
rtItem.Offset(-fPosX, -fPosY);
if (rtItem.Contains(fx, fy)) {
return pItem;
@@ -469,8 +446,9 @@ IFWL_ListItem* CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
}
return nullptr;
}
-FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(IFWL_ListItem* pItem,
- CFX_RectF& rtCheck) {
+
+FX_BOOL IFWL_ListBox::GetItemCheckRect(IFWL_ListItem* pItem,
+ CFX_RectF& rtCheck) {
if (!m_pProperties->m_pDataProvider)
return FALSE;
if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
@@ -478,10 +456,11 @@ FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(IFWL_ListItem* pItem,
}
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- pData->GetItemCheckRect(m_pInterface, pItem, rtCheck);
+ pData->GetItemCheckRect(this, pItem, rtCheck);
return TRUE;
}
-FX_BOOL CFWL_ListBoxImp::GetItemChecked(IFWL_ListItem* pItem) {
+
+FX_BOOL IFWL_ListBox::GetItemChecked(IFWL_ListItem* pItem) {
if (!m_pProperties->m_pDataProvider)
return FALSE;
if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
@@ -489,11 +468,10 @@ FX_BOOL CFWL_ListBoxImp::GetItemChecked(IFWL_ListItem* pItem) {
}
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- return (pData->GetItemCheckState(m_pInterface, pItem) &
- FWL_ITEMSTATE_LTB_Checked);
+ return (pData->GetItemCheckState(this, pItem) & FWL_ITEMSTATE_LTB_Checked);
}
-FX_BOOL CFWL_ListBoxImp::SetItemChecked(IFWL_ListItem* pItem,
- FX_BOOL bChecked) {
+
+FX_BOOL IFWL_ListBox::SetItemChecked(IFWL_ListItem* pItem, FX_BOOL bChecked) {
if (!m_pProperties->m_pDataProvider)
return FALSE;
if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) {
@@ -501,17 +479,18 @@ FX_BOOL CFWL_ListBoxImp::SetItemChecked(IFWL_ListItem* pItem,
}
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- pData->SetItemCheckState(m_pInterface, pItem,
+ pData->SetItemCheckState(this, pItem,
bChecked ? FWL_ITEMSTATE_LTB_Checked : 0);
return TRUE;
}
-FX_BOOL CFWL_ListBoxImp::ScrollToVisible(IFWL_ListItem* pItem) {
+
+FX_BOOL IFWL_ListBox::ScrollToVisible(IFWL_ListItem* pItem) {
if (!m_pVertScrollBar)
return FALSE;
CFX_RectF rtItem;
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- pData->GetItemRect(m_pInterface, pItem, rtItem);
+ pData->GetItemRect(this, pItem, rtItem);
FX_BOOL bScroll = FALSE;
FX_FLOAT fPosY = m_pVertScrollBar->GetPos();
rtItem.Offset(0, -fPosY + m_rtConent.top);
@@ -530,15 +509,16 @@ FX_BOOL CFWL_ListBoxImp::ScrollToVisible(IFWL_ListItem* pItem) {
Repaint(&m_rtClient);
return TRUE;
}
-void CFWL_ListBoxImp::DrawBkground(CFX_Graphics* pGraphics,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix) {
+
+void IFWL_ListBox::DrawBkground(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
if (!pGraphics)
return;
if (!pTheme)
return;
CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
+ param.m_pWidget = this;
param.m_iPart = CFWL_Part::Background;
param.m_dwStates = 0;
param.m_pGraphics = pGraphics;
@@ -552,9 +532,10 @@ void CFWL_ListBoxImp::DrawBkground(CFX_Graphics* pGraphics,
}
pTheme->DrawBackground(&param);
}
-void CFWL_ListBoxImp::DrawItems(CFX_Graphics* pGraphics,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix) {
+
+void IFWL_ListBox::DrawItems(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ const CFX_Matrix* pMatrix) {
FX_FLOAT fPosX = 0.0f;
if (m_pHorzScrollBar) {
fPosX = m_pHorzScrollBar->GetPos();
@@ -574,14 +555,14 @@ void CFWL_ListBoxImp::DrawItems(CFX_Graphics* pGraphics,
m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn;
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
for (int32_t i = 0; i < iCount; i++) {
- IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i);
+ IFWL_ListItem* pItem = pData->GetItem(this, i);
if (!pItem) {
continue;
}
CFX_RectF rtItem;
- pData->GetItemRect(m_pInterface, pItem, rtItem);
+ pData->GetItemRect(this, pItem, rtItem);
rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY);
if (rtItem.bottom() < m_rtConent.top) {
continue;
@@ -594,7 +575,7 @@ void CFWL_ListBoxImp::DrawItems(CFX_Graphics* pGraphics,
}
if (GetStylesEx() & FWL_STYLEEXT_LTB_OwnerDraw) {
CFWL_EvtLtbDrawItem ev;
- ev.m_pSrcTarget = m_pInterface;
+ ev.m_pSrcTarget = this;
ev.m_pGraphics = pGraphics;
ev.m_matrix = *pMatrix;
ev.m_index = i;
@@ -605,15 +586,16 @@ void CFWL_ListBoxImp::DrawItems(CFX_Graphics* pGraphics,
}
}
}
-void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
- IFWL_ThemeProvider* pTheme,
- IFWL_ListItem* pItem,
- int32_t Index,
- const CFX_RectF& rtItem,
- const CFX_Matrix* pMatrix) {
+
+void IFWL_ListBox::DrawItem(CFX_Graphics* pGraphics,
+ IFWL_ThemeProvider* pTheme,
+ IFWL_ListItem* pItem,
+ int32_t Index,
+ const CFX_RectF& rtItem,
+ const CFX_Matrix* pMatrix) {
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- uint32_t dwItemStyles = pData->GetItemStyles(m_pInterface, pItem);
+ uint32_t dwItemStyles = pData->GetItemStyles(this, pItem);
uint32_t dwPartStates = CFWL_PartState_Normal;
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
dwPartStates = CFWL_PartState_Disabled;
@@ -626,7 +608,7 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
}
{
CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
+ param.m_pWidget = this;
param.m_iPart = CFWL_Part::ListItem;
param.m_dwStates = dwPartStates;
param.m_pGraphics = pGraphics;
@@ -647,11 +629,11 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
FX_BOOL bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon;
if (bHasIcon) {
CFX_RectF rtDIB;
- CFX_DIBitmap* pDib = pData->GetItemIcon(m_pInterface, pItem);
+ CFX_DIBitmap* pDib = pData->GetItemIcon(this, pItem);
rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height);
if (pDib) {
CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
+ param.m_pWidget = this;
param.m_iPart = CFWL_Part::Icon;
param.m_pGraphics = pGraphics;
param.m_matrix.Concat(*pMatrix);
@@ -666,9 +648,9 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
CFX_RectF rtCheck;
rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height);
rtCheck.Deflate(2, 2, 2, 2);
- pData->SetItemCheckRect(m_pInterface, pItem, rtCheck);
+ pData->SetItemCheckRect(this, pItem, rtCheck);
CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
+ param.m_pWidget = this;
param.m_iPart = CFWL_Part::Check;
param.m_pGraphics = pGraphics;
if (GetItemChecked(pItem)) {
@@ -682,7 +664,7 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
pTheme->DrawBackground(&param);
}
CFX_WideString wsText;
- pData->GetItemText(m_pInterface, pItem, wsText);
+ pData->GetItemText(this, pItem, wsText);
if (wsText.GetLength() <= 0) {
return;
}
@@ -692,7 +674,7 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
rtText.Deflate(rtItem.height, 0, 0, 0);
}
CFWL_ThemeText textParam;
- textParam.m_pWidget = m_pInterface;
+ textParam.m_pWidget = this;
textParam.m_iPart = CFWL_Part::ListItem;
textParam.m_dwStates = dwPartStates;
textParam.m_pGraphics = pGraphics;
@@ -705,7 +687,8 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics,
pTheme->DrawText(&textParam);
}
}
-CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) {
+
+CFX_SizeF IFWL_ListBox::CalcSize(FX_BOOL bAutoSize) {
CFX_SizeF fs;
if (!m_pProperties->m_pThemeProvider)
return fs;
@@ -723,18 +706,18 @@ CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) {
}
}
FX_FLOAT fWidth = 0;
- if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(m_pInterface)) {
+ if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(this)) {
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
for (int32_t i = 0; i < iCount; i++) {
- IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i);
+ IFWL_ListItem* pItem = pData->GetItem(this, i);
if (!bAutoSize) {
CFX_RectF rtItem;
rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, 0, 0);
IFWL_ListBoxDP* pBox =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- pBox->SetItemRect(m_pInterface, pItem, rtItem);
+ pBox->SetItemRect(this, pItem, rtItem);
}
if (fs.x < 0) {
fs.x = 0;
@@ -759,9 +742,9 @@ CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) {
if (bHasIcon) {
fWidth += m_fItemHeight;
}
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
for (int32_t i = 0; i < iCount; i++) {
- IFWL_ListItem* htem = pData->GetItem(m_pInterface, i);
+ IFWL_ListItem* htem = pData->GetItem(this, i);
GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize);
}
}
@@ -864,11 +847,12 @@ CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) {
}
return fs;
}
-void CFWL_ListBoxImp::GetItemSize(CFX_SizeF& size,
- IFWL_ListItem* pItem,
- FX_FLOAT fWidth,
- FX_FLOAT fItemHeight,
- FX_BOOL bAutoSize) {
+
+void IFWL_ListBox::GetItemSize(CFX_SizeF& size,
+ IFWL_ListItem* pItem,
+ FX_FLOAT fWidth,
+ FX_FLOAT fItemHeight,
+ FX_BOOL bAutoSize) {
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) {
} else {
if (!bAutoSize) {
@@ -876,24 +860,25 @@ void CFWL_ListBoxImp::GetItemSize(CFX_SizeF& size,
rtItem.Set(0, size.y, fWidth, fItemHeight);
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- pData->SetItemRect(m_pInterface, pItem, rtItem);
+ pData->SetItemRect(this, pItem, rtItem);
}
size.x = fWidth;
size.y += fItemHeight;
}
}
-FX_FLOAT CFWL_ListBoxImp::GetMaxTextWidth() {
+
+FX_FLOAT IFWL_ListBox::GetMaxTextWidth() {
FX_FLOAT fRet = 0.0f;
IFWL_ListBoxDP* pData =
static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
- int32_t iCount = pData->CountItems(m_pInterface);
+ int32_t iCount = pData->CountItems(this);
for (int32_t i = 0; i < iCount; i++) {
- IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i);
+ IFWL_ListItem* pItem = pData->GetItem(this, i);
if (!pItem) {
continue;
}
CFX_WideString wsText;
- pData->GetItemText(m_pInterface, pItem, wsText);
+ pData->GetItemText(this, pItem, wsText);
CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider);
if (sz.x > fRet) {
fRet = sz.x;
@@ -901,35 +886,38 @@ FX_FLOAT CFWL_ListBoxImp::GetMaxTextWidth() {
}
return fRet;
}
-FX_FLOAT CFWL_ListBoxImp::GetScrollWidth() {
+
+FX_FLOAT IFWL_ListBox::GetScrollWidth() {
FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>(
GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
if (!pfWidth)
return 0;
return *pfWidth;
}
-FX_FLOAT CFWL_ListBoxImp::GetItemHeigt() {
+
+FX_FLOAT IFWL_ListBox::GetItemHeigt() {
FX_FLOAT* pfFont =
static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize));
if (!pfFont)
return 20;
return *pfFont + 2 * kItemTextMargin;
}
-void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) {
+
+void IFWL_ListBox::InitScrollBar(FX_BOOL bVert) {
if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) {
return;
}
CFWL_WidgetImpProperties prop;
prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
prop.m_dwStates = FWL_WGTSTATE_Invisible;
- prop.m_pParent = m_pInterface;
+ prop.m_pParent = this;
prop.m_pThemeProvider = m_pScrollBarTP;
- IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, m_pInterface);
+ IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(prop, this);
pScrollBar->Initialize();
(bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar);
}
-FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) {
+FX_BOOL IFWL_ListBox::IsShowScrollBar(FX_BOOL bVert) {
IFWL_ScrollBar* pScrollbar =
bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get();
if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) {
@@ -939,9 +927,10 @@ FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) {
FWL_STYLEEXT_LTB_ShowScrollBarFocus) ||
(m_pProperties->m_dwStates & FWL_WGTSTATE_Focused);
}
-void CFWL_ListBoxImp::ProcessSelChanged() {
+
+void IFWL_ListBox::ProcessSelChanged() {
CFWL_EvtLtbSelChanged selEvent;
- selEvent.m_pSrcTarget = m_pInterface;
+ selEvent.m_pSrcTarget = this;
CFX_Int32Array arrSels;
int32_t iCount = CountSelItems();
for (int32_t i = 0; i < iCount; i++) {
@@ -954,7 +943,7 @@ void CFWL_ListBoxImp::ProcessSelChanged() {
DispatchEvent(&selEvent);
}
-CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner)
+CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(IFWL_ListBox* pOwner)
: m_pOwner(pOwner) {}
void CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
@@ -999,9 +988,7 @@ void CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
OnKeyDown(pMsg);
break;
}
- default: {
- break;
- }
+ default: { break; }
}
CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
}
@@ -1044,6 +1031,7 @@ void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
}
m_pOwner->Repaint(&m_pOwner->m_rtClient);
}
+
void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
m_pOwner->m_bLButtonDown = TRUE;
if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
@@ -1093,6 +1081,7 @@ void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
m_pOwner->ProcessSelChanged();
m_pOwner->Repaint(&m_pOwner->m_rtClient);
}
+
void CFWL_ListBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
if (m_pOwner->m_bLButtonDown) {
m_pOwner->m_bLButtonDown = FALSE;
@@ -1100,6 +1089,7 @@ void CFWL_ListBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
DispatchSelChangedEv();
}
}
+
void CFWL_ListBoxImpDelegate::OnMouseWheel(CFWL_MsgMouseWheel* pMsg) {
if (!m_pOwner->IsShowScrollBar(TRUE)) {
return;
@@ -1108,6 +1098,7 @@ void CFWL_ListBoxImpDelegate::OnMouseWheel(CFWL_MsgMouseWheel* pMsg) {
m_pOwner->m_pVertScrollBar->SetDelegate(nullptr);
pDelegate->OnProcessMessage(pMsg);
}
+
void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
uint32_t dwKeyCode = pMsg->m_dwKeyCode;
switch (dwKeyCode) {
@@ -1125,9 +1116,11 @@ void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
m_pOwner->ProcessSelChanged();
break;
}
- default: {}
+ default:
+ break;
}
}
+
void CFWL_ListBoxImpDelegate::OnVK(IFWL_ListItem* pItem,
FX_BOOL bShift,
FX_BOOL bCtrl) {
@@ -1159,6 +1152,7 @@ void CFWL_ListBoxImpDelegate::OnVK(IFWL_ListItem* pItem,
m_pOwner->Repaint(&rtInvalidate);
}
}
+
FX_BOOL CFWL_ListBoxImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar,
uint32_t dwCode,
FX_FLOAT fPos) {
@@ -1216,8 +1210,9 @@ FX_BOOL CFWL_ListBoxImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar,
}
return TRUE;
}
+
void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() {
CFWL_EvtLtbSelChanged ev;
- ev.m_pSrcTarget = m_pOwner->m_pInterface;
+ ev.m_pSrcTarget = m_pOwner;
m_pOwner->DispatchEvent(&ev);
}
« no previous file with comments | « xfa/fwl/core/ifwl_listbox.h ('k') | xfa/fwl/core/ifwl_monthcalendar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698