summaryrefslogtreecommitdiff
path: root/fpdfsdk/fsdk_baseform.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-05-16 11:38:28 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-16 11:38:28 -0700
commit92cb5e580cecf0412b74d51e8863ed557e2bd47a (patch)
treeacdc33aa1bd876742ae62bd5901183413b2ead1b /fpdfsdk/fsdk_baseform.cpp
parent719a7a71d4cf1b714ad7f76e5f9ca28cfd5b74d3 (diff)
downloadpdfium-92cb5e580cecf0412b74d51e8863ed557e2bd47a.tar.xz
Convert border style defines to an enum class.
There were two defines, BBS_ and PBS_ for the various border styles in the system. They were the same, except PBS_ had an extra SHADOW define which was never used. This CL combines both of those into a single BorderStyle enum class and updates the code as needed. Also, removes ADDBIT, GETBIT unused defines. Updates barcode code to use the util.h defines instead of redefinition. fsdk_baseannot names starting with _ were cleaned up and some #defines moved to constants. Review-Url: https://codereview.chromium.org/1980973002
Diffstat (limited to 'fpdfsdk/fsdk_baseform.cpp')
-rw-r--r--fpdfsdk/fsdk_baseform.cpp124
1 files changed, 57 insertions, 67 deletions
diff --git a/fpdfsdk/fsdk_baseform.cpp b/fpdfsdk/fsdk_baseform.cpp
index 177e7de978..4e5c9f0065 100644
--- a/fpdfsdk/fsdk_baseform.cpp
+++ b/fpdfsdk/fsdk_baseform.cpp
@@ -880,32 +880,25 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() {
crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
CPWL_Dash dsBorder(3, 0, 0);
CPWL_Color crLeftTop, crRightBottom;
- switch (GetBorderStyle()) {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
+ BorderStyle nBorderStyle = GetBorderStyle();
+ switch (nBorderStyle) {
+ case BorderStyle::DASH:
dsBorder = CPWL_Dash(3, 3, 0);
break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
+ case BorderStyle::BEVELED:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
crRightBottom = CPWL_Utils::DevideColor(crBackground, 2);
break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
+ case BorderStyle::INSET:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75);
break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
default:
- nBorderStyle = PBS_SOLID;
break;
}
@@ -1022,15 +1015,19 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() {
}
switch (nBorderStyle) {
- case PBS_BEVELED: {
+ case BorderStyle::BEVELED: {
CPWL_Color crTemp = crLeftTop;
crLeftTop = crRightBottom;
crRightBottom = crTemp;
- } break;
- case PBS_INSET:
+ break;
+ }
+ case BorderStyle::INSET: {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
break;
+ }
+ default:
+ break;
}
font_map.SetAPType("D");
@@ -1068,32 +1065,25 @@ void CPDFSDK_Widget::ResetAppearance_CheckBox() {
crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
CPWL_Dash dsBorder(3, 0, 0);
CPWL_Color crLeftTop, crRightBottom;
- switch (GetBorderStyle()) {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
+ BorderStyle nBorderStyle = GetBorderStyle();
+ switch (nBorderStyle) {
+ case BorderStyle::DASH:
dsBorder = CPWL_Dash(3, 3, 0);
break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
+ case BorderStyle::BEVELED:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
crRightBottom = CPWL_Utils::DevideColor(crBackground, 2);
break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
+ case BorderStyle::INSET:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75);
break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
default:
- nBorderStyle = PBS_SOLID;
break;
}
@@ -1143,15 +1133,19 @@ void CPDFSDK_Widget::ResetAppearance_CheckBox() {
CFX_ByteString csAP_N_OFF = csAP_N_ON;
switch (nBorderStyle) {
- case PBS_BEVELED: {
+ case BorderStyle::BEVELED: {
CPWL_Color crTemp = crLeftTop;
crLeftTop = crRightBottom;
crRightBottom = crTemp;
- } break;
- case PBS_INSET:
+ break;
+ }
+ case BorderStyle::INSET: {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
break;
+ }
+ default:
+ break;
}
CFX_ByteString csAP_D_ON =
@@ -1194,32 +1188,25 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() {
crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
CPWL_Dash dsBorder(3, 0, 0);
CPWL_Color crLeftTop, crRightBottom;
- switch (GetBorderStyle()) {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
+ BorderStyle nBorderStyle = GetBorderStyle();
+ switch (nBorderStyle) {
+ case BorderStyle::DASH:
dsBorder = CPWL_Dash(3, 3, 0);
break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
+ case BorderStyle::BEVELED:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
crRightBottom = CPWL_Utils::DevideColor(crBackground, 2);
break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
+ case BorderStyle::INSET:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75);
break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
default:
- nBorderStyle = PBS_SOLID;
break;
}
@@ -1266,10 +1253,10 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() {
CPWL_Utils::DeflateRect(CPWL_Utils::GetCenterSquare(rcWindow), 1.0f);
if (nStyle == PCS_CIRCLE) {
- if (nBorderStyle == PBS_BEVELED) {
+ if (nBorderStyle == BorderStyle::BEVELED) {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
crRightBottom = CPWL_Utils::SubstractColor(crBackground, 0.25f);
- } else if (nBorderStyle == PBS_INSET) {
+ } else if (nBorderStyle == BorderStyle::INSET) {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5f);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75f);
}
@@ -1288,26 +1275,30 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() {
CFX_ByteString csAP_N_OFF = csAP_N_ON;
switch (nBorderStyle) {
- case PBS_BEVELED: {
+ case BorderStyle::BEVELED: {
CPWL_Color crTemp = crLeftTop;
crLeftTop = crRightBottom;
crRightBottom = crTemp;
- } break;
- case PBS_INSET:
+ break;
+ }
+ case BorderStyle::INSET: {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
break;
+ }
+ default:
+ break;
}
CFX_ByteString csAP_D_ON;
if (nStyle == PCS_CIRCLE) {
CPWL_Color crBK = CPWL_Utils::SubstractColor(crBackground, 0.25f);
- if (nBorderStyle == PBS_BEVELED) {
+ if (nBorderStyle == BorderStyle::BEVELED) {
crLeftTop = CPWL_Utils::SubstractColor(crBackground, 0.25f);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
crBK = crBackground;
- } else if (nBorderStyle == PBS_INSET) {
+ } else if (nBorderStyle == BorderStyle::INSET) {
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1);
}
@@ -1597,7 +1588,7 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) {
if (bCharArray) {
switch (GetBorderStyle()) {
- case BBS_SOLID: {
+ case BorderStyle::SOLID: {
CFX_ByteString sColor =
CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE);
if (sColor.GetLength() > 0) {
@@ -1617,8 +1608,9 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) {
sLines << "Q\n";
}
- } break;
- case BBS_DASH: {
+ break;
+ }
+ case BorderStyle::DASH: {
CFX_ByteString sColor =
CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE);
if (sColor.GetLength() > 0) {
@@ -1641,7 +1633,10 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) {
sLines << "Q\n";
}
- } break;
+ break;
+ }
+ default:
+ break;
}
}
@@ -1656,10 +1651,12 @@ CFX_FloatRect CPDFSDK_Widget::GetClientRect() const {
CFX_FloatRect rcWindow = GetRotatedRect();
FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
switch (GetBorderStyle()) {
- case BBS_BEVELED:
- case BBS_INSET:
+ case BorderStyle::BEVELED:
+ case BorderStyle::INSET:
fBorderWidth *= 2.0f;
break;
+ default:
+ break;
}
return CPWL_Utils::DeflateRect(rcWindow, fBorderWidth);
@@ -1702,31 +1699,24 @@ CFX_ByteString CPDFSDK_Widget::GetBorderAppStream() const {
CPWL_Color crLeftTop, crRightBottom;
FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- int32_t nBorderStyle = 0;
CPWL_Dash dsBorder(3, 0, 0);
- switch (GetBorderStyle()) {
- case BBS_DASH:
- nBorderStyle = PBS_DASH;
+ BorderStyle nBorderStyle = GetBorderStyle();
+ switch (nBorderStyle) {
+ case BorderStyle::DASH:
dsBorder = CPWL_Dash(3, 3, 0);
break;
- case BBS_BEVELED:
- nBorderStyle = PBS_BEVELED;
+ case BorderStyle::BEVELED:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1);
crRightBottom = CPWL_Utils::DevideColor(crBackground, 2);
break;
- case BBS_INSET:
- nBorderStyle = PBS_INSET;
+ case BorderStyle::INSET:
fBorderWidth *= 2;
crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5);
crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75);
break;
- case BBS_UNDERLINE:
- nBorderStyle = PBS_UNDERLINED;
- break;
default:
- nBorderStyle = PBS_SOLID;
break;
}