// SquidStaticPane.cpp: implementation of the SquidStaticPane class. // ////////////////////////////////////////////////////////////////////// #include <qframe.h> #include <qimage.h> #include <qlayout.h> #include <qlabel.h> #include <qpainter.h> #include <qscrollview.h> #include "SquidPortrait.h" #include "SquidStaticPane.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// SquidStaticPane::SquidStaticPane( QWidget* parent, QImage* img, QString n ) : QFrame( parent ), name( n ), scroll( new QScrollView( this ) ) { scroll->setVScrollBarMode( QScrollView::AlwaysOff ); scroll->setHScrollBarMode( QScrollView::AlwaysOff ); pic = new SquidPortrait( scroll, img ); scroll->addChild( pic ); QVBoxLayout* vlayout = new QVBoxLayout( this ); vlayout->addWidget( scroll ); vlayout->addSpacing( 20 ); resize( sizeHint() ); setMaximumSize( pic->width() + 4, pic->height() + 24 ); setMinimumSize( 0, 0 ); } SquidStaticPane::~SquidStaticPane() { } void SquidStaticPane::drawContents( QPainter* p ) { QFrame::drawContents( p ); QRect r = contentsRect(); p->begin( this ); p->drawText( r.x(), r.height() - 20, r.width(), 20, AlignHCenter | AlignVCenter, name ); p->end(); } void SquidStaticPane::HScroll( int pct ) { int d = scroll->contentsWidth() - scroll->visibleWidth(); if ( !d ) return; d *= pct; d /= 100; scroll->setContentsPos( d, scroll->contentsY() ); } void SquidStaticPane::VScroll( int pct ) { int d = scroll->contentsHeight() - scroll->visibleHeight(); if ( !d ) return; d *= pct; d /= 100; scroll->setContentsPos( scroll->contentsX(), d ); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 2401 | Sam Stafford |
Rename SID to SQUID - avoids conflicts with another program. Also lets me use cool squid icon. |
||
//guest/sam_stafford/sid/src/SidStaticPane.cpp | |||||
#3 | 2050 | Sam Stafford | Settings. | ||
#2 | 2030 | Sam Stafford |
Scrolling. It's not perfect, but I'm happy enough with it to move on with my life. |
||
#1 | 2016 | Sam Stafford |
Barely-functional Sid (about three hours worth of code). "Sid" = "Sam's Image Differ", for those who were curious. |