25 #include <tqpainter.h>
32 #include "lineview.moc"
34 LineView::LineView( TQWidget *parent, const char *name ) :
35 TQScrollView( parent, name )
39 mLines.setAutoDelete( true );
41 resizeContents( mPixelWidth, contentsHeight() );
43 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
50 int LineView::pixelWidth()
55 void LineView::addLine( int start, int end )
57 int count = mLines.count();
59 if( start < 0 ) start = 0;
60 if( end > mPixelWidth) end = mPixelWidth;
62 kdDebug(5850) << "LineView::addLine() col: " << count << " start: " << start
63 << " end: " << end << endl;
65 mLines.append( new Line( count, start, end ) );
68 void LineView::clear()
74 void LineView::drawContents(TQPainter* p, int cx, int cy, int cw, int ch)
79 int mGridSpacingY = 20;
84 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
86 p->drawLine(x,cy,x,cy+ch);
92 int y = ((int)(cy/mGridSpacingY))*mGridSpacingY + 10;
95 p->drawLine(cx,y,cx+cw,y);
100 for( line = mLines.first(); line; line = mLines.next() ) {
101 int ctop = line->column * 20 + 10 - 5;
102 int cbottom = line->column * 20 + 10 + 5;
107 if ( ctop <= (cy+ch) && cbottom >= cy &&
108 s <= (cx+cw) && e >= cx ) {
109 if ( s < cx ) s = cx;
110 if ( e > (cx+cw) ) e = cx+cw;
111 if ( ctop < cy ) ctop = cy;
112 if ( cbottom > (cy+ch) ) cbottom = cy+ch;
115 p->fillRect( s, ctop, e - s + 1, cbottom - ctop + 1, TQBrush( "red") );
|