[Libreoffice-commits] core.git: vcl/workben
Chris Sherlock
chris.sherlock at collabora.com
Thu Jan 29 19:04:48 PST 2015
vcl/workben/vcldemo.cxx | 84 ++++++++++++++++++++++++++++++++++++------------
1 file changed, 64 insertions(+), 20 deletions(-)
New commits:
commit e31eb6484a149f89cd374e414633bdf95c10efad
Author: Chris Sherlock <chris.sherlock at collabora.com>
Date: Thu Jan 29 19:00:54 2015 +1100
vcldemo: more text changes
Changes:
+ Move the rotated text down the screen to show more of it.
+ Only one colour (black)
+ Only one line of text now
+ smaller font size
+ fixed issue caused by not resetting clipping area at the right time
Note that the old changes can be brought back easily by changing a hardcoded
variable in the source.
Change-Id: I5b0688af0f344f89cd252d43b1b8964b0c456bef
Reviewed-on: https://gerrit.libreoffice.org/14247
Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index d70d511..2b6021e 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -361,54 +361,98 @@ public:
OUString aText;
- int nPrintNumCopies=0;
+ // To have more text displayed one after the other (overlapping, and in different colours), then
+ // change this value
+ int nPrintNumCopies=1;
if (bArabicText)
- {
aText = aArabicText;
- nPrintNumCopies=20;
- }
else
- {
aText = aLatinText;
- nPrintNumCopies=20;
- }
+
std::vector<OUString> maFontNames;
+
sal_uInt32 nCols[] = {
COL_BLACK, COL_BLUE, COL_GREEN, COL_CYAN, COL_RED, COL_MAGENTA,
COL_BROWN, COL_GRAY, COL_LIGHTGRAY, COL_LIGHTBLUE, COL_LIGHTGREEN,
COL_LIGHTCYAN, COL_LIGHTRED, COL_LIGHTMAGENTA, COL_YELLOW, COL_WHITE
};
+
// a few fonts to start with
const char *pNames[] = {
"Times", "Liberation Sans", "Arial", "Linux Biolinum G", "Linux Libertine Display G"
};
- for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++)
+
+ size_t nNumFontNames = SAL_N_ELEMENTS(pNames);
+
+ for (size_t i = 0; i < nNumFontNames; i++)
maFontNames.push_back(OUString::createFromAscii(pNames[i]));
- if (bClip)
+ if (bClip && !bRotate)
{
- Rectangle aRect( r.TopLeft(), Size( r.GetWidth()/2, r.GetHeight()/2) );
+ // only show the first quarter of the text
+ Rectangle aRect( r.TopLeft(), Size( r.GetWidth()/2, r.GetHeight()/2 ) );
rDev.SetClipRegion( vcl::Region( aRect ) );
}
- for (int i = 0; i < nPrintNumCopies; i++)
+ for (int i = 1; i < nPrintNumCopies+1; i++)
{
- Rectangle aRect = r;
+ int nFontHeight=0, nFontIndex=0, nFontColorIndex=0;
- rDev.SetTextColor(Color(nCols[i % SAL_N_ELEMENTS(nCols)]));
- // random font size to avoid buffering
- vcl::Font aFont( maFontNames[i % maFontNames.size()], Size(0, 1 + i * (0.9 + comphelper::rng::uniform_real_distribution(0.0, std::nextafter(0.1, DBL_MAX))) * (r.Top() - r.Bottom()) / nPrintNumCopies));
+ assert(nPrintCopies);
- if (bRotate)
+ if (nPrintNumCopies == 1)
+ {
+ float nFontMagnitude = 0.25f;
+ // random font size to avoid buffering
+ nFontHeight = 1 + nFontMagnitude * (0.9 + comphelper::rng::uniform_real_distribution(0.0, std::nextafter(0.1, DBL_MAX))) * (r.Bottom() - r.Top());
+ nFontIndex=0;
+ nFontColorIndex=0;
+ }
+ else
{
- aRect.TopLeft() = r.BottomLeft();
- aFont.SetOrientation(450);
+ // random font size to avoid buffering
+ nFontHeight = 1 + i * (0.9 + comphelper::rng::uniform_real_distribution(0.0, std::nextafter(0.1, DBL_MAX))) * (r.Top() - r.Bottom()) / nPrintNumCopies;
+ nFontIndex = (i % maFontNames.size());
+ nFontColorIndex=(i % maFontNames.size());
}
- rDev.SetFont(aFont);
- rDev.DrawText(aRect, aText);
+ rDev.SetTextColor(Color(nCols[nFontColorIndex]));
+ vcl::Font aFont( maFontNames[nFontIndex], Size(0, nFontHeight ));
+
+ if (bRotate)
+ {
+ Rectangle aFontRect = r;
+
+ int nHeight = r.GetHeight();
+
+ // move the text to the bottom of the bounding rect before rotating
+ aFontRect.Top() += nHeight;
+ aFontRect.Bottom() += nHeight;
+
+ int nDegrees = 45;
+
+ aFont.SetOrientation(nDegrees * 10);
+
+ rDev.SetFont(aFont);
+ rDev.DrawText(aFontRect, aText);
+
+ if (bClip)
+ {
+ Rectangle aClipRect( Point( r.Left(), r.Top() + ( r.GetHeight()/2 ) ) , Size( r.GetWidth()/2, r.GetHeight()/2 ) );
+ rDev.SetClipRegion( vcl::Region( aClipRect ) );
+ }
+ else
+ rDev.SetClipRegion( vcl::Region(r) );
+ }
+ else
+ {
+ rDev.SetFont(aFont);
+ rDev.DrawText(r, aText);
+ }
}
+
+ rDev.SetClipRegion();
}
};
More information about the Libreoffice-commits
mailing list