[Libreoffice-commits] core.git: 2 commits - sc/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Thu Feb 19 06:10:04 PST 2015
sc/source/ui/cctrl/checklistmenu.cxx | 55 +++++++++++++++++++-------
sc/source/ui/cctrl/dpcontrol.cxx | 73 ++++++++++-------------------------
2 files changed, 62 insertions(+), 66 deletions(-)
New commits:
commit bdd4e1957fcdef591acac4ce3a7f6fd4f83380c4
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu Feb 19 23:05:09 2015 +0900
Simplify and HiDPI for field button shown in auto-filtered cell
Change-Id: Ib2b58b5d39f946463eaecdc51f10f11cbc35aa1f
diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx
index ec45076..e2c3457 100644
--- a/sc/source/ui/cctrl/dpcontrol.cxx
+++ b/sc/source/ui/cctrl/dpcontrol.cxx
@@ -150,12 +150,12 @@ void ScDPFieldButton::draw()
void ScDPFieldButton::getPopupBoundingBox(Point& rPos, Size& rSize) const
{
- long nW = maSize.getWidth() / 2;
- long nH = maSize.getHeight();
- if (nW > 18)
- nW = 18;
- if (nH > 18)
- nH = 18;
+ sal_Int32 nScaleFactor = mpOutDev->GetDPIScaleFactor();
+
+ long nMaxSize = 18L * nScaleFactor; // Button max size in either dimension
+
+ long nW = std::min(maSize.getWidth() / 2, nMaxSize);
+ long nH = std::min(maSize.getHeight(), nMaxSize);
// #i114944# AutoFilter button is left-aligned in RTL.
// DataPilot button is always right-aligned for now, so text output isn't affected.
@@ -163,6 +163,7 @@ void ScDPFieldButton::getPopupBoundingBox(Point& rPos, Size& rSize) const
rPos.setX(maPos.getX());
else
rPos.setX(maPos.getX() + maSize.getWidth() - nW);
+
rPos.setY(maPos.getY() + maSize.getHeight() - nH);
rSize.setWidth(nW);
rSize.setHeight(nH);
@@ -174,64 +175,34 @@ void ScDPFieldButton::drawPopupButton()
Size aSize;
getPopupBoundingBox(aPos, aSize);
+ sal_Int32 nScaleFactor = mpOutDev->GetDPIScaleFactor();
+
// Background & outer black border
mpOutDev->SetLineColor(COL_BLACK);
- mpOutDev->SetFillColor(mpStyle->GetFaceColor());
+ Color aBackgroundColor = mbPopupPressed ? mpStyle->GetShadowColor() : mpStyle->GetFaceColor();
+ mpOutDev->SetFillColor(aBackgroundColor);
mpOutDev->DrawRect(Rectangle(aPos, aSize));
- if (!mbPopupPressed)
- {
- // border lines
- mpOutDev->SetLineColor(mpStyle->GetLightColor());
- mpOutDev->DrawLine(Point(aPos.X()+1, aPos.Y()+1), Point(aPos.X()+1, aPos.Y()+aSize.Height()-2));
- mpOutDev->DrawLine(Point(aPos.X()+1, aPos.Y()+1), Point(aPos.X()+aSize.Width()-2, aPos.Y()+1));
-
- mpOutDev->SetLineColor(mpStyle->GetShadowColor());
- mpOutDev->DrawLine(Point(aPos.X()+1, aPos.Y()+aSize.Height()-2),
- Point(aPos.X()+aSize.Width()-2, aPos.Y()+aSize.Height()-2));
- mpOutDev->DrawLine(Point(aPos.X()+aSize.Width()-2, aPos.Y()+1),
- Point(aPos.X()+aSize.Width()-2, aPos.Y()+aSize.Height()-2));
- }
-
// the arrowhead
Color aArrowColor = mbHasHiddenMember ? mpStyle->GetHighlightLinkColor() : mpStyle->GetButtonTextColor();
mpOutDev->SetLineColor(aArrowColor);
mpOutDev->SetFillColor(aArrowColor);
- Point aCenter(aPos.X() + (aSize.Width() >> 1), aPos.Y() + (aSize.Height() >> 1));
- Point aPos1, aPos2;
- aPos1.X() = aCenter.X() - 4;
- aPos2.X() = aCenter.X() + 4;
- aPos1.Y() = aCenter.Y() - 3;
- aPos2.Y() = aCenter.Y() - 3;
-
- if (mbPopupPressed)
- {
- aPos1.X() += 1;
- aPos2.X() += 1;
- aPos1.Y() += 1;
- aPos2.Y() += 1;
- }
- do
- {
- ++aPos1.X();
- --aPos2.X();
- ++aPos1.Y();
- ++aPos2.Y();
- mpOutDev->DrawLine(aPos1, aPos2);
- }
- while (aPos1 != aPos2);
+ Point aCenter(aPos.X() + (aSize.Width() / 2), aPos.Y() + (aSize.Height() / 2));
+
+ Size aArrowSize(4 * nScaleFactor, 2 * nScaleFactor);
+
+ Polygon aPoly(3);
+ aPoly.SetPoint(Point(aCenter.X() - aArrowSize.Width(), aCenter.Y() - aArrowSize.Height()), 0);
+ aPoly.SetPoint(Point(aCenter.X() + aArrowSize.Width(), aCenter.Y() - aArrowSize.Height()), 1);
+ aPoly.SetPoint(Point(aCenter.X(), aCenter.Y() + aArrowSize.Height()), 2);
+ mpOutDev->DrawPolygon(aPoly);
if (mbHasHiddenMember)
{
// tiny little box to display in presence of hidden member(s).
- Point aBoxPos(aPos.X() + aSize.Width() - 5, aPos.Y() + aSize.Height() - 5);
- if (mbPopupPressed)
- {
- aBoxPos.X() += 1;
- aBoxPos.Y() += 1;
- }
- Size aBoxSize(3, 3);
+ Point aBoxPos(aPos.X() + aSize.Width() - 5 * nScaleFactor, aPos.Y() + aSize.Height() - 5 * nScaleFactor);
+ Size aBoxSize(3 * nScaleFactor, 3 * nScaleFactor);
mpOutDev->DrawRect(Rectangle(aBoxPos, aBoxSize));
}
}
commit 17f358d7d163d9412aa88ce9bc31d12799707392
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu Feb 19 23:02:12 2015 +0900
Support HiDPI in auto filter (and pivot table) pop-up menu window
Change-Id: I752a4bc01425c09e2bd3cc8cac96f3cf22f1222d
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index a9d1701..1366bf5 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -84,7 +84,8 @@ ScMenuFloatingWindow::ScMenuFloatingWindow(vcl::Window* pParent, ScDocument* pDo
SetMenuStackLevel(nMenuStackLevel);
// TODO: How do we get the right font to use here ?
- const sal_uInt16 nPopupFontHeight = 12;
+ sal_Int32 nScaleFactor = GetDPIScaleFactor();
+ const sal_uInt16 nPopupFontHeight = 12 * nScaleFactor;
const StyleSettings& rStyle = GetSettings().GetStyleSettings();
maLabelFont = rStyle.GetLabelFont();
maLabelFont.SetHeight(nPopupFontHeight);
@@ -864,9 +865,13 @@ ScCheckListMenuWindow::ScCheckListMenuWindow(vcl::Window* pParent, ScDocument* p
mpExtendedData(NULL),
mpOKAction(NULL),
mpPopupEndAction(NULL),
- maWndSize(200, 330),
+ maWndSize(),
mePrevToggleAllState(TRISTATE_INDET)
{
+ sal_Int32 nScaleFactor = GetDPIScaleFactor();
+
+ maWndSize = Size(200 * nScaleFactor, 330 * nScaleFactor);
+
maTabStopCtrls.reserve(7);
maTabStopCtrls.push_back(this);
maTabStopCtrls.push_back(&maChecks);
@@ -887,18 +892,20 @@ ScCheckListMenuWindow::~ScCheckListMenuWindow()
void ScCheckListMenuWindow::getSectionPosSize(
Point& rPos, Size& rSize, SectionType eType) const
{
+ sal_Int32 nScaleFactor = GetDPIScaleFactor();
+
// constant parameters.
- const long nListBoxMargin = 5; // horizontal distance from the side of the dialog to the listbox border.
- const long nListBoxInnerPadding = 5;
- const long nTopMargin = 5;
+ const long nListBoxMargin = 5 * nScaleFactor; // horizontal distance from the side of the dialog to the listbox border.
+ const long nListBoxInnerPadding = 5 * nScaleFactor;
+ const long nTopMargin = 5 * nScaleFactor;
const long nMenuHeight = maMenuSize.getHeight();
- const long nSingleItemBtnAreaHeight = 32; // height of the middle area below the list box where the single-action buttons are.
- const long nBottomBtnAreaHeight = 50; // height of the bottom area where the OK and Cancel buttons are.
- const long nBtnWidth = 90;
+ const long nSingleItemBtnAreaHeight = 32 * nScaleFactor; // height of the middle area below the list box where the single-action buttons are.
+ const long nBottomBtnAreaHeight = 50 * nScaleFactor; // height of the bottom area where the OK and Cancel buttons are.
+ const long nBtnWidth = 90 * nScaleFactor;
const long nLabelHeight = getLabelFont().GetHeight();
- const long nBtnHeight = nLabelHeight*2;
- const long nBottomMargin = 10;
- const long nMenuListMargin = 5;
+ const long nBtnHeight = nLabelHeight * 2;
+ const long nBottomMargin = 10 * nScaleFactor;
+ const long nMenuListMargin = 5 * nScaleFactor;
// parameters calculated from constants.
const long nListBoxWidth = maWndSize.Width() - nListBoxMargin*2;
@@ -949,7 +956,7 @@ void ScCheckListMenuWindow::getSectionPosSize(
break;
case BTN_SINGLE_SELECT:
{
- long h = 26;
+ long h = 26 * nScaleFactor;
rPos = Point(nListBoxMargin, nSingleBtnAreaY);
rPos.X() += nListBoxWidth - h - 10 - h - 10;
rPos.Y() += (nSingleItemBtnAreaHeight - h)/2;
@@ -958,7 +965,7 @@ void ScCheckListMenuWindow::getSectionPosSize(
break;
case BTN_SINGLE_UNSELECT:
{
- long h = 26;
+ long h = 26 * nScaleFactor;
rPos = Point(nListBoxMargin, nSingleBtnAreaY);
rPos.X() += nListBoxWidth - h - 10;
rPos.Y() += (nSingleItemBtnAreaHeight - h)/2;
@@ -1036,17 +1043,35 @@ void ScCheckListMenuWindow::packWindow()
maChkToggleAll.SetClickHdl( LINK(this, ScCheckListMenuWindow, TriStateHdl) );
maChkToggleAll.Show();
+ sal_Int32 nScaleFactor = GetDPIScaleFactor();
+
+ Image aSingleSelect(ScResId(RID_IMG_SELECT_CURRENT));
+ if (nScaleFactor != 1)
+ {
+ BitmapEx aBitmap = aSingleSelect.GetBitmapEx();
+ aBitmap.Scale(nScaleFactor, nScaleFactor, BMP_SCALE_FAST);
+ aSingleSelect = Image(aBitmap);
+ }
+
getSectionPosSize(aPos, aSize, BTN_SINGLE_SELECT);
maBtnSelectSingle.SetPosSizePixel(aPos, aSize);
maBtnSelectSingle.SetQuickHelpText(SC_STRLOAD(RID_POPUP_FILTER, STR_BTN_SELECT_CURRENT));
- maBtnSelectSingle.SetModeImage(Image(ScResId(RID_IMG_SELECT_CURRENT)));
+ maBtnSelectSingle.SetModeImage(aSingleSelect);
maBtnSelectSingle.SetClickHdl( LINK(this, ScCheckListMenuWindow, ButtonHdl) );
maBtnSelectSingle.Show();
+ Image aSingleUnselect(ScResId(RID_IMG_UNSELECT_CURRENT));
+ if (nScaleFactor != 1)
+ {
+ BitmapEx aBitmap = aSingleUnselect.GetBitmapEx();
+ aBitmap.Scale(nScaleFactor, nScaleFactor, BMP_SCALE_FAST);
+ aSingleUnselect = Image(aBitmap);
+ }
+
getSectionPosSize(aPos, aSize, BTN_SINGLE_UNSELECT);
maBtnUnselectSingle.SetPosSizePixel(aPos, aSize);
maBtnUnselectSingle.SetQuickHelpText(SC_STRLOAD(RID_POPUP_FILTER, STR_BTN_UNSELECT_CURRENT));
- maBtnUnselectSingle.SetModeImage(Image(ScResId(RID_IMG_UNSELECT_CURRENT)));
+ maBtnUnselectSingle.SetModeImage(aSingleUnselect);
maBtnUnselectSingle.SetClickHdl( LINK(this, ScCheckListMenuWindow, ButtonHdl) );
maBtnUnselectSingle.Show();
}
More information about the Libreoffice-commits
mailing list