1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#include <KoBorder.h>
#include <KoZoomHandler.h>
#include <tdeapplication.h>
#include <tdecmdlineargs.h>
#include <tqpainter.h>
#include <tqwidget.h>
#include <tqgrid.h>
class MyWidget : public TQWidget
{
public:
MyWidget( KoZoomHandler* _zh, TQWidget* parent )
: TQWidget( parent ), m_zh(_zh) {
setSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed );
}
TQSize sizeHint() const {
return TQSize( 150, 150 );
}
TQSize minimumSizeHint() const {
return sizeHint();
}
KoBorder m_leftBorder;
KoBorder m_rightBorder;
KoBorder m_topBorder;
KoBorder m_bottomBorder;
protected:
virtual void paintEvent( TQPaintEvent* )
{
TQPainter p( this );
TQRect rect( 10, 10, 100, 100 );
KoBorder::drawBorders( p, m_zh, rect, m_leftBorder,
m_rightBorder, m_topBorder, m_bottomBorder,
0, TQPen() );
// Show the corners of the rect - they must apppear _inside_ the borders.
p.setPen( black );
p.drawPoint( rect.topLeft() );
p.drawPoint( rect.topRight() );
p.drawPoint( rect.bottomRight() );
p.drawPoint( rect.bottomLeft() );
}
private:
KoZoomHandler* m_zh;
};
int main (int argc, char ** argv)
{
TDEApplication::disableAutoDcopRegistration();
TDECmdLineArgs::init(argc,argv,"kobordertest", 0, 0, 0, 0);
TDEApplication app;
KoZoomHandler* zh = new KoZoomHandler();
TQGrid* grid = new TQGrid(2, TQt::Horizontal, 0L); // 2 columns
{
// First square
MyWidget* w = new MyWidget(zh, grid);
w->m_leftBorder.setPenWidth( 6 );
w->m_leftBorder.color = TQt::red;
w->m_rightBorder.setPenWidth( 9 );
w->m_rightBorder.color = TQt::red;
w->m_topBorder.setPenWidth( 11 );
w->m_topBorder.color = TQt::blue;
w->m_bottomBorder.setPenWidth( 13 );
w->m_bottomBorder.color = TQt::green;
}
{
// Second square, with opposite (odd/even-wise) widths
MyWidget* w = new MyWidget(zh, grid);
w->m_leftBorder.setPenWidth( 7 );
w->m_leftBorder.color = TQt::red;
w->m_rightBorder.setPenWidth( 8 );
w->m_rightBorder.color = TQt::red;
w->m_topBorder.setPenWidth( 10 );
w->m_topBorder.color = TQt::blue;
w->m_bottomBorder.setPenWidth( 12 );
w->m_bottomBorder.color = TQt::green;
}
{
// Third square, with double borders
MyWidget* w2 = new MyWidget(zh, grid);
w2->m_leftBorder.setPenWidth( 2 );
w2->m_leftBorder.setStyle( KoBorder::DOUBLE_LINE );
w2->m_rightBorder.setPenWidth( 6 );
w2->m_rightBorder.color = TQt::red;
w2->m_rightBorder.setStyle( KoBorder::DOUBLE_LINE );
w2->m_topBorder.setPenWidth( 4 );
w2->m_topBorder.color = TQt::blue;
w2->m_topBorder.setStyle( KoBorder::DOUBLE_LINE );
w2->m_bottomBorder.setPenWidth( 6 );
w2->m_bottomBorder.color = TQt::green;
w2->m_bottomBorder.setStyle( KoBorder::DOUBLE_LINE );
}
{
// Fourth square, with double borders
MyWidget* w2 = new MyWidget(zh, grid);
w2->m_leftBorder.setPenWidth( 1 );
w2->m_leftBorder.setStyle( KoBorder::DOUBLE_LINE );
w2->m_rightBorder.setPenWidth( 5 );
w2->m_rightBorder.color = TQt::red;
w2->m_rightBorder.setStyle( KoBorder::DOUBLE_LINE );
w2->m_topBorder.setPenWidth( 3 );
w2->m_topBorder.color = TQt::blue;
w2->m_topBorder.setStyle( KoBorder::DOUBLE_LINE );
w2->m_bottomBorder.setPenWidth( 5 );
w2->m_bottomBorder.color = TQt::green;
w2->m_bottomBorder.setStyle( KoBorder::DOUBLE_LINE );
}
grid->show();
return app.exec();
}
|