Source Code (Use browser search to find items of interest.)
Class Index
qt'QFrame (./qt-2.1.0/src/widgets/qframe.h:33)
class Q_EXPORT QFrame : public QWidget // frame class
{
Q_OBJECT
Q_ENUMS( Shape Shadow )
Q_PROPERTY( int frameWidth READ frameWidth )
Q_PROPERTY( QRect contentsRect READ contentsRect )
Q_PROPERTY( Shape frameShape READ frameShape WRITE setFrameShape )
Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow )
Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth )
Q_PROPERTY( int margin READ margin WRITE setMargin )
Q_PROPERTY( int midLineWidth READ midLineWidth WRITE setMidLineWidth )
Q_PROPERTY( QRect frameRect READ frameRect WRITE setFrameRect DESIGNABLE false )
public:
QFrame( QWidget *parent=0, const char *name=0, WFlags f=0,
bool = TRUE );
int frameStyle() const;
virtual void setFrameStyle( int );
int frameWidth() const;
QRect contentsRect() const;
#if 1 // OBSOLETE, provided for compatibility
bool lineShapesOk() const { return TRUE; }
#endif
QSize sizeHint() const;
QSizePolicy sizePolicy() const;
enum Shape { NoFrame = 0, // no frame
Box = 0x0001, // rectangular box
Panel = 0x0002, // rectangular panel
WinPanel = 0x0003, // rectangular panel (Windows)
HLine = 0x0004, // horizontal line
VLine = 0x0005, // vertical line
StyledPanel = 0x0006, // rectangular panel depending on the GUI style
PopupPanel = 0x0007, // rectangular panel depending on the GUI style
MShape = 0x000f // mask for the shape
};
enum Shadow { Plain = 0x0010, // plain line
Raised = 0x0020, // raised shadow effect
Sunken = 0x0030, // sunken shadow effect
MShadow = 0x00f0 }; // mask for the shadow
Shape frameShape() const;
void setFrameShape( Shape );
Shadow frameShadow() const;
void setFrameShadow( Shadow );
int lineWidth() const;
virtual void setLineWidth( int );
int margin() const;
virtual void setMargin( int );
int midLineWidth() const;
virtual void setMidLineWidth( int );
QRect frameRect() const;
virtual void setFrameRect( const QRect & );
protected:
void paintEvent( QPaintEvent * );
void resizeEvent( QResizeEvent * );
virtual void drawFrame( QPainter * );
virtual void drawContents( QPainter * );
virtual void frameChanged();
void updateMask();
virtual void drawFrameMask( QPainter * );
virtual void drawContentsMask( QPainter * );
private:
void updateFrameWidth();
QRect frect;
int fstyle;
short lwidth;
short mwidth;
short mlwidth;
short fwidth;
void * d;
private: // Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
QFrame( const QFrame & );
QFrame &operator=( const QFrame & );
#endif
};
inline int QFrame::frameStyle() const
{ return fstyle; }
inline QFrame::Shape QFrame::frameShape() const
{ return (Shape) ( fstyle & MShape ); }
inline QFrame::Shadow QFrame::frameShadow() const
{ return (Shadow) ( fstyle & MShadow ); }
inline void QFrame::setFrameShape( QFrame::Shape s )
{ setFrameStyle( ( fstyle & MShadow ) | s ); }
inline void QFrame::setFrameShadow( QFrame::Shadow s )
{ setFrameStyle( ( fstyle & MShape ) | s ); }
inline int QFrame::lineWidth() const
{ return lwidth; }
inline int QFrame::midLineWidth() const
{ return mlwidth; }
inline int QFrame::margin() const
{ return mwidth; }
inline int QFrame::frameWidth() const
{ return fwidth; }
qt'QFrame::frameWidth() (./qt-2.1.0/include/qframe.h:147)
inline int QFrame::frameWidth() const
{ return fwidth; }
qt'QFrame::QFrame() (./qt-2.1.0/src/widgets/qframe.cpp:159)
QFrame::QFrame( QWidget *parent, const char *name, WFlags f,
bool )
: QWidget( parent, name, f )
{
frect = QRect( 0, 0, 0, 0 );
fstyle = NoFrame;
lwidth = 1;
mwidth = 0;
mlwidth = 0;
d = 0;
updateFrameWidth();
}
qt'QFrame::setFrameStyle() (./qt-2.1.0/src/widgets/qframe.cpp:254)
void QFrame::setFrameStyle( int style )
{
#if defined(CHECK_RANGE)
bool shape = (style & MShape) != 0;
bool shadow = (style & MShadow) != 0;
if ( shape != shadow )
qWarning( "QFrame::setFrameStyle: (%s) Incomplete frame style",
name( "unnamed" ) );
#endif
fstyle = (short)style;
updateFrameWidth();
}
/*!
\fn int QFrame::lineWidth() const
Returns the line width. (Note that the \e total line width
for \c HLine and \c VLine is given by frameWidth(), not
lineWidth().)
The default value is 1.
\sa setLineWidth(), midLineWidth(), frameWidth()
*/
/*!
Sets the line width to \e w.
\sa frameWidth(), lineWidth(), setMidLineWidth()
*/
qt'QFrame::setLineWidth() (./qt-2.1.0/src/widgets/qframe.cpp:284)
void QFrame::setLineWidth( int w )
{
lwidth = (short)w;
updateFrameWidth();
}
/*!
\fn int QFrame::midLineWidth() const
Returns the width of the mid-line.
The default value is 0.
\sa setMidLineWidth(), lineWidth(), frameWidth()
*/
/*!
Sets the width of the mid-line to \e w.
\sa midLineWidth(), setLineWidth()
*/
qt'QFrame::setMidLineWidth() (./qt-2.1.0/src/widgets/qframe.cpp:304)
void QFrame::setMidLineWidth( int w )
{
mlwidth = (short)w;
updateFrameWidth();
}
/*!
\fn int QFrame::margin() const
Returns the width of the margin. The margin is the distance between the
innermost pixel of the frame and the outermost pixel of contentsRect().
It is included in frameWidth().
The margin is filled according to backgroundMode().
The default value is 0.
\sa setMargin(), lineWidth(), frameWidth()
*/
/*!
Sets the width of the margin to \e w.
\sa margin(), setLineWidth()
*/
qt'QFrame::setMargin() (./qt-2.1.0/src/widgets/qframe.cpp:330)
void QFrame::setMargin( int w )
{
mwidth = (short)w;
updateFrameWidth();
}
/*!
\internal
Updated the fwidth parameter.
*/
qt'QFrame::updateFrameWidth() (./qt-2.1.0/src/widgets/qframe.cpp:342)
void QFrame::updateFrameWidth()
{
int type = fstyle & MShape;
int style = fstyle & MShadow;
fwidth = -1;
switch ( type ) {
case NoFrame:
fwidth = 0;
break;
case Box:
switch ( style ) {
case Plain:
fwidth = lwidth;
break;
case Raised:
case Sunken:
fwidth = (short)(lwidth*2 + midLineWidth() );
break;
}
break;
case Panel:
case StyledPanel:
case PopupPanel:
switch ( style ) {
case Plain:
case Raised:
case Sunken:
fwidth = lwidth;
break;
}
break;
case WinPanel:
switch ( style ) {
case Plain:
case Raised:
case Sunken:
fwidth = wpwidth; //WinPanel does not use lwidth!
break;
}
break;
case HLine:
case VLine:
switch ( style ) {
case Plain:
fwidth = lwidth;
break;
case Raised:
case Sunken:
fwidth = (short)(lwidth*2 + midLineWidth());
break;
}
break;
}
if ( fwidth == -1 ) // invalid style
fwidth = 0;
fwidth += margin();
frameChanged();
}
/*!
\fn int QFrame::frameWidth() const
Returns the width of the frame that is drawn.
Note that the frame width depends on the \link setFrameStyle() frame
style \endlink, not only the line width and the mid line width. For
example, the style \c NoFrame always has a frame width 0, while the
style \c Panel has a frame width equivalent to the line width.
The frame width also includes the margin.
\sa lineWidth(), midLineWidth(), frameStyle(), margin()
*/
/*!
Returns the frame rectangle.
The default frame rectangle is equivalent to the \link
QWidget::rect() widget rectangle\endlink.
\sa setFrameRect()
*/
qt'QFrame::frameRect() (./qt-2.1.0/src/widgets/qframe.cpp:435)
QRect QFrame::frameRect() const
{
if ( frect.isNull() )
return rect();
else
return frect;
}
/*!
Sets the frame rectangle to \e r.
The frame rectangle is the rectangle the frame is drawn in. By
default, this is the entire widget. Calling setFrameRect() does \e
not cause a widget update.
If \e r is a null rectangle (for example
<code>QRect(0,0,0,0)</code>), then the frame rectangle is equivalent
to the \link QWidget::rect() widget rectangle\endlink.
\sa frameRect(), contentsRect()
*/
qt'QFrame::setFrameRect() (./qt-2.1.0/src/widgets/qframe.cpp:458)
void QFrame::setFrameRect( const QRect &r )
{
frect = r.isValid() ? r : rect();
}
/*!
Returns the rectangle inside the frame.
\sa frameRect(), drawContents()
*/
qt'QFrame::contentsRect() (./qt-2.1.0/src/widgets/qframe.cpp:469)
QRect QFrame::contentsRect() const
{
QRect r = frameRect();
int w = frameWidth(); // total width
r.setRect( r.x()+w, r.y()+w, r.width()-w*2, r.height()-w*2 );
return r;
}
/*!\reimp
*/
qt'QFrame::sizeHint() (./qt-2.1.0/src/widgets/qframe.cpp:479)
QSize QFrame::sizeHint() const
{
// Returns a size hint for the frame - for HLine and VLine
// shapes, this is stretchable one way and 3 pixels wide the
// other. For other shapes, QWidget::sizeHint() is used.
switch (fstyle & MShape) {
case HLine:
return QSize(-1,3);
case VLine:
return QSize(3,-1);
default:
return QWidget::sizeHint();
}
}
/*!\reimp
*/
qt'QFrame::sizePolicy() (./qt-2.1.0/src/widgets/qframe.cpp:498)
QSizePolicy QFrame::sizePolicy() const
{
// If this is a line, it may stretch in the direction of the
// line, but it is fixed in the other direction. If this is a
// normal frame, use QWidget's default behavior.
switch (fstyle & MShape) {
case HLine:
return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
case VLine:
return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum );
default:
return QWidget::sizePolicy();
}
}
/*!
Handles paint events for the frame.
Paints the frame and the contents.
Opens the painter on the frame and calls first drawFrame(), then
drawContents().
*/
qt'QFrame::paintEvent() (./qt-2.1.0/src/widgets/qframe.cpp:525)
void QFrame::paintEvent( QPaintEvent *event )
{
QPainter paint( this );
if ( !contentsRect().contains( event->rect() ) ) {
paint.save();
paint.setClipRegion( event->region().intersect(frameRect()) );
drawFrame( &paint );
paint.restore();
}
if ( event->rect().intersects( contentsRect() ) &&
(fstyle & MShape) != HLine && (fstyle & MShape) != VLine ) {
paint.setClipRegion( event->region().intersect( contentsRect() ) );
drawContents( &paint );
}
}
/*!
Handles resize events for the frame.
Adjusts the frame rectangle for the resized widget. The frame
rectangle is elastic, the surrounding area is static.
The resulting frame rectangle may be null or invalid. You can use
setMinimumSize() to avoid that possibility.
Nothing is done if the frame rectangle is a \link QRect::isNull()
null rectangle\endlink already.
*/
qt'QFrame::resizeEvent() (./qt-2.1.0/src/widgets/qframe.cpp:556)
void QFrame::resizeEvent( QResizeEvent *e )
{
if ( !frect.isNull() ) {
QRect r( frect.x(), frect.y(),
width() - (e->oldSize().width() - frect.width()),
height() - (e->oldSize().height() - frect.height()) );
setFrameRect( r );
}
if ( autoMask())
updateMask();
}
/*!
Draws the frame using the current frame attributes and color
group. The rectangle inside the frame is not affected.
This function is virtual, but in general you do not need to
reimplement it. If you do, note that the QPainter is already open
and must remain open.
\sa frameRect(), contentsRect(), drawContents(), frameStyle(), setPalette(), drawFrameMask()
*/
qt'QFrame::drawFrame() (./qt-2.1.0/src/widgets/qframe.cpp:581)
void QFrame::drawFrame( QPainter *p )
{
QPoint p1, p2;
QRect r = frameRect();
int type = fstyle & MShape;
int cstyle = fstyle & MShadow;
const QColorGroup & g = colorGroup();
switch ( type ) {
case Box:
if ( cstyle == Plain )
qDrawPlainRect( p, r, g.foreground(), lwidth );
else
qDrawShadeRect( p, r, g, cstyle == Sunken, lwidth,
midLineWidth() );
break;
case Panel:
if ( cstyle == Plain )
qDrawPlainRect( p, r, g.foreground(), lwidth );
else
qDrawShadePanel( p, r, g, cstyle == Sunken, lwidth );
break;
case StyledPanel:
if ( cstyle == Plain )
qDrawPlainRect( p, r, g.foreground(), lwidth );
else
style().drawPanel( p, r.x(), r.y(), r.width(), r.height(), g, cstyle == Sunken, lwidth );
break;
case PopupPanel:
if ( cstyle == Plain )
qDrawPlainRect( p, r, g.foreground(), lwidth );
else
style().drawPopupPanel( p, r.x(), r.y(), r.width(), r.height(), g, lwidth );
break;
case WinPanel:
if ( cstyle == Plain )
qDrawPlainRect( p, r, g.foreground(), wpwidth );
else
qDrawWinPanel( p, r, g, cstyle == Sunken );
break;
case HLine:
case VLine:
if ( type == HLine ) {
p1 = QPoint( r.x(), r.height()/2 );
p2 = QPoint( r.x()+r.width(), p1.y() );
}
else {
p1 = QPoint( r.x()+r.width()/2, 0 );
p2 = QPoint( p1.x(), r.height() );
}
if ( cstyle == Plain ) {
QPen oldPen = p->pen();
p->setPen( QPen(g.foreground(),lwidth) );
p->drawLine( p1, p2 );
p->setPen( oldPen );
}
else
qDrawShadeLine( p, p1, p2, g, cstyle == Sunken,
lwidth, midLineWidth() );
break;
}
}
/*!
Virtual function that draws the contents of the frame.
The QPainter is already open when you get it, and you must leave it
open. Painter \link QPainter::setWorldMatrix() transformations\endlink
are switched off on entry. If you transform the painter, remember to
take the frame into account and \link QPainter::resetXForm() reset
transformation\endlink before returning.
This function is reimplemented by subclasses that draw something
inside the frame. It should draw only inside contentsRect(). The
default function does nothing.
\sa contentsRect(), QPainter::setClipRect(), drawContentsMask()
*/
qt'QFrame::drawContents() (./qt-2.1.0/src/widgets/qframe.cpp:667)
void QFrame::drawContents( QPainter * )
{
}
/*!
Virtual function that is called when the frame style, line width or
mid-line width changes.
This function can be reimplemented by subclasses that need to know
when the frame attributes change.
The default implementation calls update().
*/
qt'QFrame::frameChanged() (./qt-2.1.0/src/widgets/qframe.cpp:682)
void QFrame::frameChanged()
{
update();
}
/*!
Reimplementation of QWidget::updateMask(). Draws the mask of the
frame when transparency is required.
This function calls the virtual functions drawFrameMask() and
drawContentsMask(). These are the ones you may want to reimplement
in subclasses.
\sa QWidget::setAutoMask(), drawFrameMask(), drawContentsMask()
*/
qt'QFrame::updateMask() (./qt-2.1.0/src/widgets/qframe.cpp:699)
void QFrame::updateMask()
{
QBitmap bm( size() );
bm.fill( color0 );
QPainter p( &bm, this );
p.setPen( color1 );
p.setBrush( color1 );
drawFrameMask( &p );
drawContentsMask( &p );
p.end();
setMask( bm );
}
/*!
Virtual function that draws the mask of the frame's frame.
If you reimplemented drawFrame(QPainter*) and your widget should
support transparency you probably have to re-implement this function as well.
The default implementation is empty.
\sa drawFrame(), updateMask(), QWidget::setAutoMask(), QPainter::setClipRect()
*/
qt'QFrame::drawFrameMask() (./qt-2.1.0/src/widgets/qframe.cpp:723)
void QFrame::drawFrameMask( QPainter* p )
{
QPoint p1, p2;
QRect r = frameRect();
int type = fstyle & MShape;
int style = fstyle & MShadow;
QColorGroup g(color1, color1, color1, color1, color1, color1, color1, color1, color0);
switch ( type ) {
case Box:
if ( style == Plain )
qDrawPlainRect( p, r, g.foreground(), lwidth );
else
qDrawShadeRect( p, r, g, style == Sunken, lwidth,
midLineWidth() );
break;
case Panel:
if ( style == Plain )
qDrawPlainRect( p, r, g.foreground(), lwidth );
else
qDrawShadePanel( p, r, g, style == Sunken, lwidth );
break;
case WinPanel:
if ( style == Plain )
qDrawPlainRect( p, r, g.foreground(), wpwidth );
else
qDrawWinPanel( p, r, g, style == Sunken );
break;
case HLine:
case VLine:
if ( type == HLine ) {
p1 = QPoint( r.x(), r.height()/2 );
p2 = QPoint( r.x()+r.width(), p1.y() );
}
else {
p1 = QPoint( r.x()+r.width()/2, 0 );
p2 = QPoint( p1.x(), r.height() );
}
if ( style == Plain ) {
QPen oldPen = p->pen();
p->setPen( QPen(g.foreground(),lwidth) );
p->drawLine( p1, p2 );
p->setPen( oldPen );
}
else
qDrawShadeLine( p, p1, p2, g, style == Sunken,
lwidth, midLineWidth() );
break;
}
}
/*!
Virtual function that draws the mask of the frame's contents.
If you reimplemented drawContents(QPainter*) and your widget should
support transparency you probably have to re-implement this function as well.
The default implementation is empty.
\sa drawContents(), updateMask(), QWidget::setAutoMask(), contentsRect(), QPainter::setClipRect()
*/
qt'QFrame::drawContentsMask() (./qt-2.1.0/src/widgets/qframe.cpp:789)
void QFrame::drawContentsMask( QPainter* )
{
}
qt'QFrame::frameWidth() (./qt-2.1.0/src/widgets/qframe.h:147)
inline int QFrame::frameWidth() const
{ return fwidth; }