You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
koffice/lib/kotext/tests/kobordertest.cpp

114 lines
3.7 KiB

#include <KoBorder.h>
#include <KoZoomHandler.h>
#include <kapplication.h>
#include <kcmdlineargs.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, Qt::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();
}