summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fde/cfde_textout.cpp78
-rw-r--r--xfa/fde/cfde_textout.h48
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp7
-rw-r--r--xfa/fwl/cfwl_checkbox.cpp11
-rw-r--r--xfa/fwl/cfwl_checkbox.h4
-rw-r--r--xfa/fwl/cfwl_combobox.cpp4
-rw-r--r--xfa/fwl/cfwl_listbox.cpp11
-rw-r--r--xfa/fwl/cfwl_listbox.h4
-rw-r--r--xfa/fwl/cfwl_monthcalendar.cpp21
-rw-r--r--xfa/fwl/cfwl_pushbutton.cpp10
-rw-r--r--xfa/fwl/cfwl_pushbutton.h2
-rw-r--r--xfa/fwl/cfwl_themetext.h4
-rw-r--r--xfa/fwl/cfwl_widget.cpp13
-rw-r--r--xfa/fwl/cfwl_widget.h5
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp6
15 files changed, 119 insertions, 109 deletions
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index 769a8c4ce5..3278a88ebb 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -17,6 +17,20 @@
#include "xfa/fde/cfde_renderdevice.h"
#include "xfa/fgas/layout/cfx_txtbreak.h"
+namespace {
+
+bool TextAlignmentVerticallyCentered(const FDE_TextAlignment align) {
+ return align == FDE_TextAlignment::kCenterLeft ||
+ align == FDE_TextAlignment::kCenter ||
+ align == FDE_TextAlignment::kCenterRight;
+}
+
+bool IsTextAlignmentTop(const FDE_TextAlignment align) {
+ return align == FDE_TextAlignment::kTopLeft;
+}
+
+} // namespace
+
FDE_TTOPIECE::FDE_TTOPIECE() = default;
FDE_TTOPIECE::FDE_TTOPIECE(const FDE_TTOPIECE& that) = default;
@@ -30,11 +44,10 @@ CFDE_TextOut::CFDE_TextOut()
m_fLineSpace(m_fFontSize),
m_fLinePos(0.0f),
m_fTolerance(0.0f),
- m_iAlignment(0),
+ m_iAlignment(FDE_TextAlignment::kTopLeft),
m_iTxtBkAlignment(0),
m_wParagraphBkChar(L'\n'),
m_TxtColor(0xFF000000),
- m_dwStyles(0),
m_dwTxtBkStyles(0),
m_ttoLines(5),
m_iCurLine(0),
@@ -63,10 +76,11 @@ void CFDE_TextOut::SetTextColor(FX_ARGB color) {
m_TxtColor = color;
}
-void CFDE_TextOut::SetStyles(uint32_t dwStyles) {
- m_dwStyles = dwStyles;
+void CFDE_TextOut::SetStyles(const FDE_TextStyle& dwStyles) {
+ m_Styles = dwStyles;
+
m_dwTxtBkStyles = 0;
- if (dwStyles & FDE_TTOSTYLE_SingleLine)
+ if (m_Styles.single_line_)
m_dwTxtBkStyles |= FX_LAYOUTSTYLE_SingleLine;
m_pTxtBreak->SetLayoutStyles(m_dwTxtBkStyles);
@@ -82,20 +96,17 @@ void CFDE_TextOut::SetParagraphBreakChar(wchar_t wch) {
m_pTxtBreak->SetParagraphBreakChar(wch);
}
-void CFDE_TextOut::SetAlignment(int32_t iAlignment) {
+void CFDE_TextOut::SetAlignment(FDE_TextAlignment iAlignment) {
m_iAlignment = iAlignment;
switch (m_iAlignment) {
- case FDE_TTOALIGNMENT_TopCenter:
- case FDE_TTOALIGNMENT_Center:
- case FDE_TTOALIGNMENT_BottomCenter:
+ case FDE_TextAlignment::kCenter:
m_iTxtBkAlignment = CFX_TxtLineAlignment_Center;
break;
- case FDE_TTOALIGNMENT_TopRight:
- case FDE_TTOALIGNMENT_CenterRight:
- case FDE_TTOALIGNMENT_BottomRight:
+ case FDE_TextAlignment::kCenterRight:
m_iTxtBkAlignment = CFX_TxtLineAlignment_Right;
break;
- default:
+ case FDE_TextAlignment::kCenterLeft:
+ case FDE_TextAlignment::kTopLeft:
m_iTxtBkAlignment = CFX_TxtLineAlignment_Left;
break;
}
@@ -197,29 +208,26 @@ void CFDE_TextOut::CalcTextSize(const wchar_t* pwsStr,
m_pTxtBreak->Reset();
float fInc = rect.Height() - fHeight;
- if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft &&
- m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) {
+ if (TextAlignmentVerticallyCentered(m_iAlignment))
fInc /= 2.0f;
- } else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) {
+ else if (IsTextAlignmentTop(m_iAlignment))
fInc = 0.0f;
- }
+
rect.left += fStartPos;
rect.top += fInc;
rect.width = std::min(fWidth, rect.Width());
rect.height = fHeight;
- if (m_dwStyles & FDE_TTOSTYLE_LastLineHeight)
+ if (m_Styles.last_line_height_)
rect.height -= m_fLineSpace - m_fFontSize;
}
void CFDE_TextOut::SetLineWidth(CFX_RectF& rect) {
- if ((m_dwStyles & FDE_TTOSTYLE_SingleLine) == 0) {
- float fLineWidth = 0.0f;
- if (rect.Width() < 1.0f)
- rect.width = m_fFontSize * 1000.0f;
+ if (m_Styles.single_line_)
+ return;
+ if (rect.Width() < 1.0f)
+ rect.width = m_fFontSize * 1000.0f;
- fLineWidth = rect.Width();
- m_pTxtBreak->SetLineWidth(fLineWidth);
- }
+ m_pTxtBreak->SetLineWidth(rect.Width());
}
bool CFDE_TextOut::RetrieveLineWidth(CFX_BreakType dwBreakStatus,
@@ -230,7 +238,6 @@ bool CFDE_TextOut::RetrieveLineWidth(CFX_BreakType dwBreakStatus,
return false;
float fLineStep = (m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize;
- bool bLineWrap = !!(m_dwStyles & FDE_TTOSTYLE_LineWrap);
float fLineWidth = 0.0f;
int32_t iCount = m_pTxtBreak->CountBreakPieces();
for (int32_t i = 0; i < iCount; i++) {
@@ -243,7 +250,7 @@ bool CFDE_TextOut::RetrieveLineWidth(CFX_BreakType dwBreakStatus,
if (dwBreakStatus == CFX_BreakType::Paragraph) {
m_pTxtBreak->Reset();
}
- if (!bLineWrap && dwBreakStatus == CFX_BreakType::Line) {
+ if (!m_Styles.line_wrap_ && dwBreakStatus == CFX_BreakType::Line) {
fWidth += fLineWidth;
} else {
fWidth = std::max(fWidth, fLineWidth);
@@ -331,7 +338,6 @@ void CFDE_TextOut::LoadText(const wchar_t* pwsStr,
if (pdfium::CollectionSize<int32_t>(m_CharWidths) < iTxtLength)
m_CharWidths.resize(iTxtLength, 0);
- bool bLineWrap = !!(m_dwStyles & FDE_TTOSTYLE_LineWrap);
float fLineStep = (m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize;
float fLineStop = rect.bottom();
m_fLinePos = rect.top;
@@ -350,7 +356,7 @@ void CFDE_TextOut::LoadText(const wchar_t* pwsStr,
bool bEndofLine =
RetrievePieces(dwBreakStatus, iStartChar, iPieceWidths, false, rect);
if (bEndofLine &&
- (bLineWrap || dwBreakStatus == CFX_BreakType::Paragraph ||
+ (m_Styles.line_wrap_ || dwBreakStatus == CFX_BreakType::Paragraph ||
dwBreakStatus == CFX_BreakType::Page)) {
iPieceWidths = 0;
m_iCurLine++;
@@ -378,8 +384,6 @@ bool CFDE_TextOut::RetrievePieces(CFX_BreakType dwBreakStatus,
int32_t& iPieceWidths,
bool bReload,
const CFX_RectF& rect) {
- bool bSingleLine = !!(m_dwStyles & FDE_TTOSTYLE_SingleLine);
- bool bLineWrap = !!(m_dwStyles & FDE_TTOSTYLE_LineWrap);
float fLineStep = (m_fLineSpace > m_fFontSize) ? m_fLineSpace : m_fFontSize;
bool bNeedReload = false;
float fLineWidth = rect.Width();
@@ -394,7 +398,7 @@ bool CFDE_TextOut::RetrievePieces(CFX_BreakType dwBreakStatus,
for (; j < iPieceChars; j++) {
const CFX_Char* pTC = pPiece->GetChar(j);
int32_t iCurCharWidth = pTC->m_iCharWidth > 0 ? pTC->m_iCharWidth : 0;
- if (bSingleLine || !bLineWrap) {
+ if (m_Styles.single_line_ || !m_Styles.line_wrap_) {
if (iLineWidth - iPieceWidths - iWidth < iCurCharWidth) {
bNeedReload = true;
break;
@@ -426,7 +430,7 @@ bool CFDE_TextOut::RetrievePieces(CFX_BreakType dwBreakStatus,
iPieceWidths += iWidth;
}
m_pTxtBreak->ClearBreakPieces();
- return bSingleLine || bLineWrap || bNeedReload ||
+ return m_Styles.single_line_ || m_Styles.line_wrap_ || bNeedReload ||
dwBreakStatus == CFX_BreakType::Paragraph;
}
@@ -507,14 +511,14 @@ void CFDE_TextOut::DoAlignment(const CFX_RectF& rect) {
float fLineStopD = pFirstPiece->rtPiece.bottom();
float fInc = fLineStopS - fLineStopD;
- if (m_iAlignment >= FDE_TTOALIGNMENT_CenterLeft &&
- m_iAlignment < FDE_TTOALIGNMENT_BottomLeft) {
+ if (TextAlignmentVerticallyCentered(m_iAlignment))
fInc /= 2.0f;
- } else if (m_iAlignment < FDE_TTOALIGNMENT_CenterLeft) {
+ else if (IsTextAlignmentTop(m_iAlignment))
fInc = 0.0f;
- }
+
if (fInc < 1.0f)
return;
+
for (auto& line : m_ttoLines) {
int32_t iPieces = line.GetSize();
for (int32_t j = 0; j < iPieces; j++) {
diff --git a/xfa/fde/cfde_textout.h b/xfa/fde/cfde_textout.h
index 7424573b6b..8d99900566 100644
--- a/xfa/fde/cfde_textout.h
+++ b/xfa/fde/cfde_textout.h
@@ -17,28 +17,34 @@
#include "core/fxge/fx_dib.h"
#include "xfa/fgas/font/cfgas_fontmgr.h"
-#define FDE_TTOSTYLE_SingleLine 0x0010
-#define FDE_TTOSTYLE_LineWrap 0x0100
-#define FDE_TTOSTYLE_LastLineHeight 0x1000
-
-#define FDE_TTOALIGNMENT_TopLeft 0
-#define FDE_TTOALIGNMENT_TopCenter 1
-#define FDE_TTOALIGNMENT_TopRight 2
-#define FDE_TTOALIGNMENT_TopAuto 3
-#define FDE_TTOALIGNMENT_CenterLeft 4
-#define FDE_TTOALIGNMENT_Center 5
-#define FDE_TTOALIGNMENT_CenterRight 6
-#define FDE_TTOALIGNMENT_CenterAuto 7
-#define FDE_TTOALIGNMENT_BottomLeft 8
-#define FDE_TTOALIGNMENT_BottomCenter 9
-#define FDE_TTOALIGNMENT_BottomRight 10
-#define FDE_TTOALIGNMENT_BottomAuto 11
-
class CFDE_RenderDevice;
class CFX_RenderDevice;
class CFX_TxtBreak;
struct FX_TXTRUN;
+enum class FDE_TextAlignment : uint8_t {
+ kTopLeft = 0,
+ kCenterLeft,
+ kCenter,
+ kCenterRight
+};
+
+struct FDE_TextStyle {
+ FDE_TextStyle()
+ : single_line_(false), line_wrap_(false), last_line_height_(false) {}
+ ~FDE_TextStyle() {}
+
+ void Reset() {
+ single_line_ = false;
+ line_wrap_ = false;
+ last_line_height_ = false;
+ }
+
+ bool single_line_;
+ bool line_wrap_;
+ bool last_line_height_;
+};
+
struct FDE_TTOPIECE {
FDE_TTOPIECE();
FDE_TTOPIECE(const FDE_TTOPIECE& that);
@@ -77,10 +83,10 @@ class CFDE_TextOut {
void SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont);
void SetFontSize(float fFontSize);
void SetTextColor(FX_ARGB color);
- void SetStyles(uint32_t dwStyles);
+ void SetStyles(const FDE_TextStyle& dwStyles);
void SetTabWidth(float fTabWidth);
void SetParagraphBreakChar(wchar_t wch);
- void SetAlignment(int32_t iAlignment);
+ void SetAlignment(FDE_TextAlignment iAlignment);
void SetLineSpace(float fLineSpace);
void SetDIBitmap(const CFX_RetainPtr<CFX_DIBitmap>& pDIB);
void SetRenderDevice(CFX_RenderDevice* pDevice);
@@ -137,12 +143,12 @@ class CFDE_TextOut {
float m_fLineSpace;
float m_fLinePos;
float m_fTolerance;
- int32_t m_iAlignment;
+ FDE_TextAlignment m_iAlignment;
+ FDE_TextStyle m_Styles;
int32_t m_iTxtBkAlignment;
std::vector<int32_t> m_CharWidths;
wchar_t m_wParagraphBkChar;
FX_ARGB m_TxtColor;
- uint32_t m_dwStyles;
uint32_t m_dwTxtBkStyles;
CFX_WideString m_wsText;
CFX_RectF m_rtClip;
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index a8445b028e..aaf0d21712 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -1321,13 +1321,14 @@ bool CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) {
pTextOut->SetLineSpace(m_Param.fLineSpace);
pTextOut->SetFont(m_Param.pFont);
pTextOut->SetFontSize(m_Param.fFontSize);
- uint32_t dwStyle = 0;
+
+ FDE_TextStyle dwStyle;
if (!(m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines))
- dwStyle |= FDE_TTOSTYLE_SingleLine;
+ dwStyle.single_line_ = true;
CFX_RectF rcText;
if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) {
- dwStyle |= FDE_TTOSTYLE_LineWrap;
+ dwStyle.line_wrap_ = true;
rcText.width = m_Param.fPlateWidth;
} else {
rcText.width = 65535;
diff --git a/xfa/fwl/cfwl_checkbox.cpp b/xfa/fwl/cfwl_checkbox.cpp
index eed201ba34..bc45e5a792 100644
--- a/xfa/fwl/cfwl_checkbox.cpp
+++ b/xfa/fwl/cfwl_checkbox.cpp
@@ -31,10 +31,10 @@ const int kCaptionMargin = 5;
CFWL_CheckBox::CFWL_CheckBox(const CFWL_App* app)
: CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr),
- m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
- m_iTTOAlign(FDE_TTOALIGNMENT_Center),
+ m_iTTOAlign(FDE_TextAlignment::kCenter),
m_bBtnDown(false),
m_fBoxHeight(16.0f) {
+ m_dwTTOStyles.single_line_ = true;
m_rtClient.Reset();
m_rtBox.Reset();
m_rtCaption.Reset();
@@ -170,9 +170,10 @@ uint32_t CFWL_CheckBox::GetPartStates() const {
}
void CFWL_CheckBox::UpdateTextOutStyles() {
- m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
- m_dwTTOStyles = 0;
- m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
+ m_iTTOAlign = FDE_TextAlignment::kTopLeft;
+
+ m_dwTTOStyles.Reset();
+ m_dwTTOStyles.single_line_ = true;
}
void CFWL_CheckBox::NextStates() {
diff --git a/xfa/fwl/cfwl_checkbox.h b/xfa/fwl/cfwl_checkbox.h
index 6fc9033dee..e90fbd1b93 100644
--- a/xfa/fwl/cfwl_checkbox.h
+++ b/xfa/fwl/cfwl_checkbox.h
@@ -66,8 +66,8 @@ class CFWL_CheckBox : public CFWL_Widget {
CFX_RectF m_rtBox;
CFX_RectF m_rtCaption;
CFX_RectF m_rtFocus;
- uint32_t m_dwTTOStyles;
- int32_t m_iTTOAlign;
+ FDE_TextStyle m_dwTTOStyles;
+ FDE_TextAlignment m_iTTOAlign;
bool m_bBtnDown;
float m_fBoxHeight;
};
diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp
index acc72b0e64..ec90a15684 100644
--- a/xfa/fwl/cfwl_combobox.cpp
+++ b/xfa/fwl/cfwl_combobox.cpp
@@ -180,8 +180,8 @@ void CFWL_ComboBox::DrawWidget(CXFA_Graphics* pGraphics,
? CFWL_PartState_Selected
: CFWL_PartState_Normal;
theme_text.m_wsText = hItem ? hItem->GetText() : L"";
- theme_text.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
- theme_text.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
+ theme_text.m_dwTTOStyles.single_line_ = true;
+ theme_text.m_iTTOAlign = FDE_TextAlignment::kCenterLeft;
pTheme->DrawText(&theme_text);
}
}
diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp
index ddad4038f5..d0455ff650 100644
--- a/xfa/fwl/cfwl_listbox.cpp
+++ b/xfa/fwl/cfwl_listbox.cpp
@@ -32,8 +32,7 @@ CFWL_ListBox::CFWL_ListBox(const CFWL_App* app,
std::unique_ptr<CFWL_WidgetProperties> properties,
CFWL_Widget* pOuter)
: CFWL_Widget(app, std::move(properties), pOuter),
- m_dwTTOStyles(0),
- m_iTTOAligns(0),
+ m_iTTOAligns(FDE_TextAlignment::kTopLeft),
m_hAnchor(nullptr),
m_fScorllBarWidth(0),
m_bLButtonDown(false),
@@ -57,20 +56,20 @@ void CFWL_ListBox::Update() {
switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) {
case FWL_STYLEEXT_LTB_LeftAlign: {
- m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft;
+ m_iTTOAligns = FDE_TextAlignment::kCenterLeft;
break;
}
case FWL_STYLEEXT_LTB_RightAlign: {
- m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight;
+ m_iTTOAligns = FDE_TextAlignment::kCenterRight;
break;
}
case FWL_STYLEEXT_LTB_CenterAlign:
default: {
- m_iTTOAligns = FDE_TTOALIGNMENT_Center;
+ m_iTTOAligns = FDE_TextAlignment::kCenter;
break;
}
}
- m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
+ m_dwTTOStyles.single_line_ = true;
m_fScorllBarWidth = GetScrollWidth();
CalcSize(false);
}
diff --git a/xfa/fwl/cfwl_listbox.h b/xfa/fwl/cfwl_listbox.h
index 4f934432d6..e98f21b464 100644
--- a/xfa/fwl/cfwl_listbox.h
+++ b/xfa/fwl/cfwl_listbox.h
@@ -122,8 +122,8 @@ class CFWL_ListBox : public CFWL_Widget {
CFX_RectF m_rtConent;
std::unique_ptr<CFWL_ScrollBar> m_pHorzScrollBar;
std::unique_ptr<CFWL_ScrollBar> m_pVertScrollBar;
- uint32_t m_dwTTOStyles;
- int32_t m_iTTOAligns;
+ FDE_TextStyle m_dwTTOStyles;
+ FDE_TextAlignment m_iTTOAligns;
CFWL_ListItem* m_hAnchor;
float m_fItemHeight;
float m_fScorllBarWidth;
diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp
index 8c770e545b..64e6977924 100644
--- a/xfa/fwl/cfwl_monthcalendar.cpp
+++ b/xfa/fwl/cfwl_monthcalendar.cpp
@@ -247,8 +247,8 @@ void CFWL_MonthCalendar::DrawCaption(CXFA_Graphics* pGraphics,
CalcTextSize(textParam.m_wsText, m_pProperties->m_pThemeProvider, false);
CalcHeadSize();
textParam.m_rtPart = m_rtHeadText;
- textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
- textParam.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ textParam.m_dwTTOStyles.single_line_ = true;
+ textParam.m_iTTOAlign = FDE_TextAlignment::kCenter;
if (pMatrix)
textParam.m_matrix.Concat(*pMatrix);
pTheme->DrawText(&textParam);
@@ -306,7 +306,9 @@ void CFWL_MonthCalendar::DrawWeek(CXFA_Graphics* pGraphics,
params.m_iPart = CFWL_Part::Week;
params.m_pGraphics = pGraphics;
params.m_dwStates = CFWL_PartState_Normal;
- params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ params.m_iTTOAlign = FDE_TextAlignment::kCenter;
+ params.m_dwTTOStyles.single_line_ = true;
+
CFX_RectF rtDayOfWeek;
if (pMatrix)
params.m_matrix.Concat(*pMatrix);
@@ -318,7 +320,6 @@ void CFWL_MonthCalendar::DrawWeek(CXFA_Graphics* pGraphics,
params.m_rtPart = rtDayOfWeek;
params.m_wsText = GetCapacityForDay(pTheme, params, i);
- params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
pTheme->DrawText(&params);
}
}
@@ -331,14 +332,15 @@ void CFWL_MonthCalendar::DrawToday(CXFA_Graphics* pGraphics,
params.m_iPart = CFWL_Part::Today;
params.m_pGraphics = pGraphics;
params.m_dwStates = CFWL_PartState_Normal;
- params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
+ params.m_iTTOAlign = FDE_TextAlignment::kCenterLeft;
params.m_wsText = L"Today" + GetTodayText(m_iYear, m_iMonth, m_iDay);
m_szToday =
CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider, false);
CalcTodaySize();
params.m_rtPart = m_rtToday;
- params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
+ params.m_dwTTOStyles.single_line_ = true;
+
if (pMatrix)
params.m_matrix.Concat(*pMatrix);
pTheme->DrawText(&params);
@@ -352,7 +354,7 @@ void CFWL_MonthCalendar::DrawDatesIn(CXFA_Graphics* pGraphics,
params.m_iPart = CFWL_Part::DatesIn;
params.m_pGraphics = pGraphics;
params.m_dwStates = CFWL_PartState_Normal;
- params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ params.m_iTTOAlign = FDE_TextAlignment::kCenter;
if (pMatrix)
params.m_matrix.Concat(*pMatrix);
@@ -364,7 +366,8 @@ void CFWL_MonthCalendar::DrawDatesIn(CXFA_Graphics* pGraphics,
params.m_dwStates = pDataInfo->dwStates;
if (j + 1 == m_iHovered)
params.m_dwStates |= CFWL_PartState_Hovered;
- params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
+
+ params.m_dwTTOStyles.single_line_ = true;
pTheme->DrawText(&params);
}
}
@@ -377,7 +380,7 @@ void CFWL_MonthCalendar::DrawDatesOut(CXFA_Graphics* pGraphics,
params.m_iPart = CFWL_Part::DatesOut;
params.m_pGraphics = pGraphics;
params.m_dwStates = CFWL_PartState_Normal;
- params.m_iTTOAlign = FDE_TTOALIGNMENT_Center;
+ params.m_iTTOAlign = FDE_TextAlignment::kCenter;
if (pMatrix)
params.m_matrix.Concat(*pMatrix);
pTheme->DrawText(&params);
diff --git a/xfa/fwl/cfwl_pushbutton.cpp b/xfa/fwl/cfwl_pushbutton.cpp
index 382748df53..1dfe2db2fd 100644
--- a/xfa/fwl/cfwl_pushbutton.cpp
+++ b/xfa/fwl/cfwl_pushbutton.cpp
@@ -22,9 +22,7 @@
CFWL_PushButton::CFWL_PushButton(const CFWL_App* app)
: CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr),
- m_bBtnDown(false),
- m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
- m_iTTOAlign(FDE_TTOALIGNMENT_Center) {}
+ m_bBtnDown(false) {}
CFWL_PushButton::~CFWL_PushButton() {}
@@ -46,7 +44,6 @@ void CFWL_PushButton::Update() {
if (!m_pProperties->m_pThemeProvider)
m_pProperties->m_pThemeProvider = GetAvailableTheme();
- UpdateTextOutStyles();
m_rtClient = GetClientRect();
m_rtCaption = m_rtClient;
}
@@ -94,11 +91,6 @@ uint32_t CFWL_PushButton::GetPartStates() {
return dwStates;
}
-void CFWL_PushButton::UpdateTextOutStyles() {
- m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
- m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
-}
-
void CFWL_PushButton::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
diff --git a/xfa/fwl/cfwl_pushbutton.h b/xfa/fwl/cfwl_pushbutton.h
index 196c53763f..84019ba181 100644
--- a/xfa/fwl/cfwl_pushbutton.h
+++ b/xfa/fwl/cfwl_pushbutton.h
@@ -49,8 +49,6 @@ class CFWL_PushButton : public CFWL_Widget {
CFX_RectF m_rtClient;
CFX_RectF m_rtCaption;
bool m_bBtnDown;
- uint32_t m_dwTTOStyles;
- int32_t m_iTTOAlign;
};
#endif // XFA_FWL_CFWL_PUSHBUTTON_H_
diff --git a/xfa/fwl/cfwl_themetext.h b/xfa/fwl/cfwl_themetext.h
index 7c8330e04e..2a42615d6f 100644
--- a/xfa/fwl/cfwl_themetext.h
+++ b/xfa/fwl/cfwl_themetext.h
@@ -16,8 +16,8 @@ class CFWL_ThemeText : public CFWL_ThemePart {
CFWL_ThemeText() : m_pGraphics(nullptr) {}
CFX_WideString m_wsText;
- uint32_t m_dwTTOStyles;
- int32_t m_iTTOAlign;
+ FDE_TextStyle m_dwTTOStyles;
+ FDE_TextAlignment m_iTTOAlign;
CXFA_Graphics* m_pGraphics;
};
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp
index a2c270c332..8b8bf5d3cd 100644
--- a/xfa/fwl/cfwl_widget.cpp
+++ b/xfa/fwl/cfwl_widget.cpp
@@ -324,9 +324,12 @@ CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText,
CFWL_ThemeText calPart;
calPart.m_pWidget = this;
calPart.m_wsText = wsText;
- calPart.m_dwTTOStyles =
- bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine;
- calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
+ if (bMultiLine)
+ calPart.m_dwTTOStyles.line_wrap_ = true;
+ else
+ calPart.m_dwTTOStyles.single_line_ = true;
+
+ calPart.m_iTTOAlign = FDE_TextAlignment::kTopLeft;
float fWidth = bMultiLine ? FWL_WGT_CalcMultiLineDefWidth : FWL_WGT_CalcWidth;
CFX_RectF rect(0, 0, fWidth, FWL_WGT_CalcHeight);
pTheme->CalcTextRect(&calPart, rect);
@@ -335,8 +338,8 @@ CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText,
void CFWL_Widget::CalcTextRect(const CFX_WideString& wsText,
IFWL_ThemeProvider* pTheme,
- uint32_t dwTTOStyles,
- int32_t iTTOAlign,
+ const FDE_TextStyle& dwTTOStyles,
+ FDE_TextAlignment iTTOAlign,
CFX_RectF& rect) {
CFWL_ThemeText calPart;
calPart.m_pWidget = this;
diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h
index 316e6f5404..11b3569dbd 100644
--- a/xfa/fwl/cfwl_widget.h
+++ b/xfa/fwl/cfwl_widget.h
@@ -12,6 +12,7 @@
#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
+#include "xfa/fde/cfde_textout.h"
#include "xfa/fwl/cfwl_event.h"
#include "xfa/fwl/cfwl_themepart.h"
#include "xfa/fwl/cfwl_widgetmgr.h"
@@ -132,8 +133,8 @@ class CFWL_Widget : public IFWL_WidgetDelegate {
bool bMultiLine);
void CalcTextRect(const CFX_WideString& wsText,
IFWL_ThemeProvider* pTheme,
- uint32_t dwTTOStyles,
- int32_t iTTOAlign,
+ const FDE_TextStyle& dwTTOStyles,
+ FDE_TextAlignment iTTOAlign,
CFX_RectF& rect);
void SetGrab(bool bSet);
void GetPopupPos(float fMinHeight,
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 0ed941f6bd..92d00e5ba9 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -841,9 +841,11 @@ void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) {
pTextOut->SetFontSize(fFontSize);
pTextOut->SetLineBreakTolerance(fFontSize * 0.2f);
pTextOut->SetLineSpace(GetLineHeight());
- uint32_t dwStyles = FDE_TTOSTYLE_LastLineHeight;
+
+ FDE_TextStyle dwStyles;
+ dwStyles.last_line_height_ = true;
if (GetUIType() == XFA_Element::TextEdit && IsMultiLine())
- dwStyles |= FDE_TTOSTYLE_LineWrap;
+ dwStyles.line_wrap_ = true;
pTextOut->SetStyles(dwStyles);
}