⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Wt
All Projects
Wt
Overview
Activity
Roadmap
Issues
Wiki
Forums
Download (1012 Bytes)
Bug #1803
» png-drawRect.cpp
Koen Deforche
, 04/01/2013 10:14 PM
#include
<Wt/WGlobal>
#include
<Wt/WApplication>
#include
<Wt/WPaintedWidget>
#include
<Wt/WPainter>
using
namespace
Wt
;
class
SomePaintedWidget
:
public
WPaintedWidget
{
public:
SomePaintedWidget
(
WContainerWidget
*
p
=
0
)
:
WPaintedWidget
(
p
)
{
resize
(
600
,
600
);
setPreferredMethod
(
WPaintedWidget
::
PngImage
);
}
protected:
void
paintEvent
(
Wt
::
WPaintDevice
*
device
)
{
WPainter
painter
(
device
);
/* Solution 1: enable anti-aliasing */
painter
.
setRenderHint
(
WPainter
::
Antialiasing
);
/* Solution 2: position line in the middle of a pixel */
painter
.
drawRect
(
10.5
,
10.5
,
400
,
200
);
}
};
class
MyApp
:
public
WApplication
{
public:
MyApp
(
const
WEnvironment
&
env
)
:
WApplication
(
env
)
{
SomePaintedWidget
*
spw
=
new
SomePaintedWidget
(
root
());
}
};
WApplication
*
createApplication
(
const
WEnvironment
&
env
)
{
return
new
MyApp
(
env
);
}
int
main
(
int
argc
,
char
**
argv
)
{
return
WRun
(
argc
,
argv
,
&
createApplication
);
}
« Previous
1
2
Next »
(2-2/2)
Loading...