Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
2b69366b
Kaydet (Commit)
2b69366b
authored
Kas 08, 2014
tarafından
Michael Meeks
Kaydeden (comit)
Markus Mohrhard
Kas 10, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
vcldemo: re-factor to allow rendering to any outputdevice.
Change-Id: Ie3367c004d89043fb78d0b2dcd49254323353a4c
üst
4007df6c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
73 deletions
+97
-73
vcldemo.cxx
vcl/workben/vcldemo.cxx
+97
-73
No files found.
vcl/workben/vcldemo.cxx
Dosyayı görüntüle @
2b69366b
...
@@ -32,13 +32,23 @@
...
@@ -32,13 +32,23 @@
using
namespace
css
;
using
namespace
css
;
class
DemoWin
:
public
WorkWindow
class
DemoBase
:
public
WorkWindow
// hide OutputDevice if necessary
{
public
:
DemoBase
()
:
WorkWindow
(
NULL
,
WB_APP
|
WB_STDWORK
)
{
}
OutputDevice
&
getOutDev
()
{
return
*
this
;
}
};
class
DemoWin
:
public
DemoBase
{
{
Bitmap
maIntroBW
;
Bitmap
maIntroBW
;
BitmapEx
maIntro
;
BitmapEx
maIntro
;
public
:
public
:
DemoWin
()
:
WorkWindow
(
NULL
,
WB_APP
|
WB_STDWORK
)
DemoWin
()
:
DemoBase
(
)
{
{
// Needed to find images
// Needed to find images
OUString
aPath
;
OUString
aPath
;
...
@@ -60,32 +70,39 @@ public:
...
@@ -60,32 +70,39 @@ public:
maIntroBW
.
Filter
(
BMP_FILTER_EMBOSS_GREY
);
maIntroBW
.
Filter
(
BMP_FILTER_EMBOSS_GREY
);
}
}
v
irtual
void
Paint
(
const
Rectangle
&
rRect
)
SAL_OVERRIDE
;
v
oid
drawToDevice
(
OutputDevice
&
r
)
;
std
::
vector
<
Rectangle
>
partitionAndClear
(
int
nX
,
int
nY
);
virtual
void
Paint
(
const
Rectangle
&
rRect
)
SAL_OVERRIDE
{
fprintf
(
stderr
,
"DemoWin::Paint(%ld,%ld,%ld,%ld)
\n
"
,
rRect
.
getX
(),
rRect
.
getY
(),
rRect
.
getWidth
(),
rRect
.
getHeight
());
drawToDevice
(
getOutDev
());
}
void
drawBackground
()
std
::
vector
<
Rectangle
>
partitionAndClear
(
OutputDevice
&
rDev
,
int
nX
,
int
nY
);
void
drawBackground
(
OutputDevice
&
rDev
)
{
{
Rectangle
r
(
Point
(
0
,
0
),
Ge
tSizePixel
());
Rectangle
r
(
Point
(
0
,
0
),
rDev
.
GetOutpu
tSizePixel
());
Gradient
aGradient
;
Gradient
aGradient
;
aGradient
.
SetStartColor
(
COL_BLUE
);
aGradient
.
SetStartColor
(
COL_BLUE
);
aGradient
.
SetEndColor
(
COL_GREEN
);
aGradient
.
SetEndColor
(
COL_GREEN
);
aGradient
.
SetStyle
(
GradientStyle_LINEAR
);
aGradient
.
SetStyle
(
GradientStyle_LINEAR
);
// aGradient.SetBorder(r.GetSize().Width()/20);
// aGradient.SetBorder(r.GetSize().Width()/20);
DrawGradient
(
r
,
aGradient
);
rDev
.
DrawGradient
(
r
,
aGradient
);
}
}
void
drawRadialLines
(
Rectangle
r
)
void
drawRadialLines
(
OutputDevice
&
rDev
,
Rectangle
r
)
{
{
SetFillColor
(
Color
(
COL_LIGHTRED
));
rDev
.
SetFillColor
(
Color
(
COL_LIGHTRED
));
SetLineColor
(
Color
(
COL_BLACK
));
rDev
.
SetLineColor
(
Color
(
COL_BLACK
));
DrawRect
(
r
);
rDev
.
DrawRect
(
r
);
// FIXME: notice these appear reflected at the bottom not the top.
// FIXME: notice these appear reflected at the bottom not the top.
for
(
int
i
=
0
;
i
<
r
.
GetHeight
();
i
+=
15
)
for
(
int
i
=
0
;
i
<
r
.
GetHeight
();
i
+=
15
)
DrawLine
(
Point
(
r
.
Left
(),
r
.
Top
()
+
i
),
Point
(
r
.
Right
(),
r
.
Bottom
()
-
i
)
);
rDev
.
DrawLine
(
Point
(
r
.
Left
(),
r
.
Top
()
+
i
),
Point
(
r
.
Right
(),
r
.
Bottom
()
-
i
)
);
for
(
int
i
=
0
;
i
<
r
.
GetWidth
();
i
+=
15
)
for
(
int
i
=
0
;
i
<
r
.
GetWidth
();
i
+=
15
)
DrawLine
(
Point
(
r
.
Left
()
+
i
,
r
.
Bottom
()),
Point
(
r
.
Right
()
-
i
,
r
.
Top
())
);
rDev
.
DrawLine
(
Point
(
r
.
Left
()
+
i
,
r
.
Bottom
()),
Point
(
r
.
Right
()
-
i
,
r
.
Top
())
);
// Should draw a white-line across the middle
// Should draw a white-line across the middle
Color
aLastPixel
(
COL_WHITE
);
Color
aLastPixel
(
COL_WHITE
);
...
@@ -93,23 +110,25 @@ public:
...
@@ -93,23 +110,25 @@ public:
(
r
.
Top
()
+
r
.
Bottom
())
/
2
-
4
);
(
r
.
Top
()
+
r
.
Bottom
())
/
2
-
4
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
{
DrawPixel
(
aCenter
,
aLastPixel
);
rDev
.
DrawPixel
(
aCenter
,
aLastPixel
);
aLastPixel
=
GetPixel
(
aCenter
);
aLastPixel
=
rDev
.
GetPixel
(
aCenter
);
aCenter
.
Move
(
1
,
1
);
aCenter
.
Move
(
1
,
1
);
}
}
}
}
void
drawText
(
Rectangle
r
)
void
drawText
(
OutputDevice
&
rDev
,
Rectangle
r
)
{
{
SetTextColor
(
Color
(
COL_BLACK
)
);
rDev
.
SetTextColor
(
Color
(
COL_BLACK
)
);
vcl
::
Font
aFont
(
OUString
(
"Times"
),
Size
(
0
,
25
)
);
vcl
::
Font
aFont
(
OUString
(
"Times"
),
Size
(
0
,
25
)
);
SetFont
(
aFont
);
rDev
.
SetFont
(
aFont
);
DrawText
(
r
,
OUString
(
"Just a simple text"
)
);
rDev
.
DrawText
(
r
,
OUString
(
"Just a simple text"
)
);
}
}
void
drawPoly
(
Rectangle
r
)
// pretty
void
drawPoly
(
OutputDevice
&
rDev
,
Rectangle
r
)
// pretty
{
{
drawCheckered
(
r
);
drawCheckered
(
r
Dev
,
r
);
long
nDx
=
r
.
GetWidth
()
/
20
;
long
nDx
=
r
.
GetWidth
()
/
20
;
long
nDy
=
r
.
GetHeight
()
/
20
;
long
nDy
=
r
.
GetHeight
()
/
20
;
...
@@ -119,22 +138,25 @@ public:
...
@@ -119,22 +138,25 @@ public:
r
.
GetHeight
()
-
nDy
*
2
));
r
.
GetHeight
()
-
nDy
*
2
));
Polygon
aPoly
(
aShrunk
);
Polygon
aPoly
(
aShrunk
);
tools
::
PolyPolygon
aPPoly
(
aPoly
);
tools
::
PolyPolygon
aPPoly
(
aPoly
);
SetLineColor
(
Color
(
COL_RED
));
rDev
.
SetLineColor
(
Color
(
COL_RED
));
SetFillColor
(
Color
(
COL_RED
));
rDev
.
SetFillColor
(
Color
(
COL_RED
));
// This hits the optional 'drawPolyPolygon' code-path
// This hits the optional 'drawPolyPolygon' code-path
DrawTransparent
(
aPPoly
,
64
);
rDev
.
DrawTransparent
(
aPPoly
,
64
);
}
}
void
drawEllipse
(
Rectangle
r
)
void
drawEllipse
(
OutputDevice
&
rDev
,
Rectangle
r
)
{
{
SetLineColor
(
Color
(
COL_RED
));
rDev
.
SetLineColor
(
Color
(
COL_RED
));
SetFillColor
(
Color
(
COL_GREEN
));
rDev
.
SetFillColor
(
Color
(
COL_GREEN
));
DrawEllipse
(
r
);
rDev
.
DrawEllipse
(
r
);
}
}
void
drawCheckered
(
Rectangle
r
)
void
drawCheckered
(
OutputDevice
&
rDev
,
Rectangle
r
)
{
{
DrawCheckered
(
r
.
TopLeft
(),
r
.
GetSize
());
rDev
.
DrawCheckered
(
r
.
TopLeft
(),
r
.
GetSize
());
}
}
void
drawGradient
(
Rectangle
r
)
void
drawGradient
(
OutputDevice
&
rDev
,
Rectangle
r
)
{
{
Gradient
aGradient
;
Gradient
aGradient
;
aGradient
.
SetStartColor
(
COL_YELLOW
);
aGradient
.
SetStartColor
(
COL_YELLOW
);
...
@@ -142,30 +164,33 @@ public:
...
@@ -142,30 +164,33 @@ public:
// aGradient.SetAngle(45);
// aGradient.SetAngle(45);
aGradient
.
SetStyle
(
GradientStyle_RECT
);
aGradient
.
SetStyle
(
GradientStyle_RECT
);
aGradient
.
SetBorder
(
r
.
GetSize
().
Width
()
/
20
);
aGradient
.
SetBorder
(
r
.
GetSize
().
Width
()
/
20
);
DrawGradient
(
r
,
aGradient
);
rDev
.
DrawGradient
(
r
,
aGradient
);
}
}
void
drawBitmap
(
Rectangle
r
)
void
drawBitmap
(
OutputDevice
&
rDev
,
Rectangle
r
)
{
{
Bitmap
aBitmap
(
maIntroBW
);
Bitmap
aBitmap
(
maIntroBW
);
aBitmap
.
Scale
(
r
.
GetSize
(),
BMP_SCALE_BESTQUALITY
);
aBitmap
.
Scale
(
r
.
GetSize
(),
BMP_SCALE_BESTQUALITY
);
DrawBitmap
(
r
.
TopLeft
(),
aBitmap
);
rDev
.
DrawBitmap
(
r
.
TopLeft
(),
aBitmap
);
}
}
void
drawBitmapEx
(
Rectangle
r
)
void
drawBitmapEx
(
OutputDevice
&
rDev
,
Rectangle
r
)
{
{
drawCheckered
(
r
);
drawCheckered
(
r
Dev
,
r
);
BitmapEx
aBitmap
(
maIntro
);
BitmapEx
aBitmap
(
maIntro
);
aBitmap
.
Scale
(
r
.
GetSize
(),
BMP_SCALE_BESTQUALITY
);
aBitmap
.
Scale
(
r
.
GetSize
(),
BMP_SCALE_BESTQUALITY
);
#ifdef FIXME_ALPHA_WORKING
#ifdef FIXME_ALPHA_WORKING
AlphaMask
aSemiTransp
(
aBitmap
.
GetSizePixel
());
AlphaMask
aSemiTransp
(
aBitmap
.
GetSizePixel
());
aSemiTransp
.
Erase
(
64
);
aSemiTransp
.
Erase
(
64
);
DrawBitmapEx
(
r
.
TopLeft
(),
BitmapEx
(
aBitmap
.
GetBitmap
(),
rDev
.
DrawBitmapEx
(
r
.
TopLeft
(),
BitmapEx
(
aBitmap
.
GetBitmap
(),
aSemiTransp
));
aSemiTransp
));
#else
#else
DrawBitmapEx
(
r
.
TopLeft
(),
aBitmap
);
rDev
.
DrawBitmapEx
(
r
.
TopLeft
(),
aBitmap
);
#endif
#endif
}
}
void
drawPolyPolgons
(
Rectangle
r
)
void
drawPolyPolgons
(
OutputDevice
&
rDev
,
Rectangle
r
)
{
{
struct
{
struct
{
double
nX
,
nY
;
double
nX
,
nY
;
...
@@ -191,39 +216,40 @@ public:
...
@@ -191,39 +216,40 @@ public:
aSubRect
.
GetHeight
()
*
aPoints
[
v
].
nY
),
aSubRect
.
GetHeight
()
*
aPoints
[
v
].
nY
),
v
);
v
);
}
}
SetLineColor
(
Color
(
COL_YELLOW
));
rDev
.
SetLineColor
(
Color
(
COL_YELLOW
));
SetFillColor
(
Color
(
COL_BLACK
));
rDev
.
SetFillColor
(
Color
(
COL_BLACK
));
DrawPolygon
(
aPoly
);
rDev
.
DrawPolygon
(
aPoly
);
// now move and add to the polypolygon
// now move and add to the polypolygon
aPoly
.
Move
(
0
,
r
.
GetHeight
()
/
2
);
aPoly
.
Move
(
0
,
r
.
GetHeight
()
/
2
);
aPolyPoly
.
Insert
(
aPoly
);
aPolyPoly
.
Insert
(
aPoly
);
}
}
}
}
SetLineColor
(
Color
(
COL_LIGHTRED
));
rDev
.
SetLineColor
(
Color
(
COL_LIGHTRED
));
SetFillColor
(
Color
(
COL_GREEN
));
rDev
.
SetFillColor
(
Color
(
COL_GREEN
));
#ifdef FIXME_DRAW_TRANSPARENT_WORKING
#ifdef FIXME_DRAW_TRANSPARENT_WORKING
DrawTransparent
(
aPolyPoly
,
50
);
rDev
.
DrawTransparent
(
aPolyPoly
,
50
);
#else
#else
DrawPolyPolygon
(
aPolyPoly
);
rDev
.
DrawPolyPolygon
(
aPolyPoly
);
#endif
#endif
}
}
void
fetchDrawBitmap
(
Rectangle
r
)
void
fetchDrawBitmap
(
OutputDevice
&
rDev
,
Rectangle
r
)
{
{
// FIXME: should work ...
// FIXME: should work ...
Bitmap
aBitmap
(
GetBitmap
(
Point
(
0
,
0
),
Ge
tSizePixel
()));
Bitmap
aBitmap
(
GetBitmap
(
Point
(
0
,
0
),
rDev
.
GetOutpu
tSizePixel
()));
aBitmap
.
Scale
(
r
.
GetSize
(),
BMP_SCALE_BESTQUALITY
);
aBitmap
.
Scale
(
r
.
GetSize
(),
BMP_SCALE_BESTQUALITY
);
DrawBitmap
(
r
.
TopLeft
(),
aBitmap
);
rDev
.
DrawBitmap
(
r
.
TopLeft
(),
aBitmap
);
}
}
};
};
std
::
vector
<
Rectangle
>
DemoWin
::
partitionAndClear
(
int
nX
,
int
nY
)
std
::
vector
<
Rectangle
>
DemoWin
::
partitionAndClear
(
OutputDevice
&
rDev
,
int
nX
,
int
nY
)
{
{
Rectangle
r
;
Rectangle
r
;
std
::
vector
<
Rectangle
>
aRegions
;
std
::
vector
<
Rectangle
>
aRegions
;
// Make small cleared area for these guys
// Make small cleared area for these guys
Size
aSize
(
Ge
tSizePixel
());
Size
aSize
(
rDev
.
GetOutpu
tSizePixel
());
long
nBorderSize
=
aSize
.
Width
()
/
32
;
long
nBorderSize
=
aSize
.
Width
()
/
32
;
long
nBoxWidth
=
(
aSize
.
Width
()
-
nBorderSize
*
(
nX
+
1
))
/
nX
;
long
nBoxWidth
=
(
aSize
.
Width
()
-
nBorderSize
*
(
nX
+
1
))
/
nX
;
long
nBoxHeight
=
(
aSize
.
Height
()
-
nBorderSize
*
(
nY
+
1
))
/
nY
;
long
nBoxHeight
=
(
aSize
.
Height
()
-
nBorderSize
*
(
nY
+
1
))
/
nY
;
...
@@ -236,16 +262,16 @@ std::vector<Rectangle> DemoWin::partitionAndClear(int nX, int nY)
...
@@ -236,16 +262,16 @@ std::vector<Rectangle> DemoWin::partitionAndClear(int nX, int nY)
r
.
SetSize
(
Size
(
nBoxWidth
,
nBoxHeight
));
r
.
SetSize
(
Size
(
nBoxWidth
,
nBoxHeight
));
// knock up a nice little border
// knock up a nice little border
SetLineColor
(
COL_GRAY
);
rDev
.
SetLineColor
(
COL_GRAY
);
SetFillColor
(
COL_LIGHTGRAY
);
rDev
.
SetFillColor
(
COL_LIGHTGRAY
);
if
((
x
+
y
)
%
2
)
if
((
x
+
y
)
%
2
)
DrawRect
(
r
);
rDev
.
DrawRect
(
r
);
else
else
{
{
#ifdef FIXME_ROUNDED_RECT_WORKING
#ifdef FIXME_ROUNDED_RECT_WORKING
DrawRect
(
r
,
nBorderSize
,
nBorderSize
);
rDev
.
DrawRect
(
r
,
nBorderSize
,
nBorderSize
);
#else
#else
DrawRect
(
r
);
rDev
.
DrawRect
(
r
);
#endif
#endif
}
}
...
@@ -256,25 +282,23 @@ std::vector<Rectangle> DemoWin::partitionAndClear(int nX, int nY)
...
@@ -256,25 +282,23 @@ std::vector<Rectangle> DemoWin::partitionAndClear(int nX, int nY)
return
aRegions
;
return
aRegions
;
}
}
void
DemoWin
::
Paint
(
const
Rectangle
&
rRect
)
void
DemoWin
::
drawToDevice
(
OutputDevice
&
rDev
)
{
{
fprintf
(
stderr
,
"DemoWin::Paint(%ld,%ld,%ld,%ld)
\n
"
,
rRect
.
getX
(),
rRect
.
getY
(),
rRect
.
getWidth
(),
rRect
.
getHeight
());
drawBackground
(
rDev
);
drawBackground
();
std
::
vector
<
Rectangle
>
aRegions
(
partitionAndClear
(
rDev
,
4
,
3
));
std
::
vector
<
Rectangle
>
aRegions
(
partitionAndClear
(
4
,
3
));
drawRadialLines
(
rDev
,
aRegions
[
0
]);
drawText
(
rDev
,
aRegions
[
1
]);
drawRadialLines
(
aRegions
[
0
]);
drawPoly
(
rDev
,
aRegions
[
2
]);
drawText
(
aRegions
[
1
]);
drawEllipse
(
rDev
,
aRegions
[
3
]);
drawPoly
(
aRegions
[
2
]);
drawCheckered
(
rDev
,
aRegions
[
4
]);
drawEllipse
(
aRegions
[
3
]);
drawBitmapEx
(
rDev
,
aRegions
[
5
]);
drawCheckered
(
aRegions
[
4
]);
drawBitmap
(
rDev
,
aRegions
[
6
]);
drawBitmapEx
(
aRegions
[
5
]);
drawGradient
(
rDev
,
aRegions
[
7
]);
drawBitmap
(
aRegions
[
6
]);
drawPolyPolgons
(
rDev
,
aRegions
[
8
]);
drawGradient
(
aRegions
[
7
]);
drawPolyPolgons
(
aRegions
[
8
]);
// last - thumbnail all the above
// last - thumbnail all the above
fetchDrawBitmap
(
aRegions
[
9
]);
fetchDrawBitmap
(
rDev
,
aRegions
[
9
]);
}
}
class
DemoApp
:
public
Application
class
DemoApp
:
public
Application
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment