geometrytip.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "geometrytip.h"
00012
00013 namespace KWinInternal
00014 {
00015
00016 GeometryTip::GeometryTip( const XSizeHints* xSizeHints, bool save_under ):
00017 QLabel(NULL, "kwingeometry" )
00018 {
00019 setMargin(1);
00020 setIndent(0);
00021 setLineWidth(1);
00022 setFrameStyle( QFrame::Raised | QFrame::StyledPanel );
00023 setAlignment( AlignCenter | AlignTop );
00024 sizeHints = xSizeHints;
00025 if( save_under )
00026 {
00027 XSetWindowAttributes attr;
00028 attr.save_under = True;
00029 XChangeWindowAttributes( qt_xdisplay(), winId(), CWSaveUnder, &attr );
00030 }
00031 }
00032
00033 GeometryTip::~GeometryTip()
00034 {
00035 }
00036
00037 void GeometryTip::setGeometry( const QRect& geom )
00038 {
00039 int w = geom.width();
00040 int h = geom.height();
00041
00042 if (sizeHints)
00043 {
00044 if (sizeHints->flags & PResizeInc)
00045 {
00046 w = ( w - sizeHints->base_width ) / sizeHints->width_inc;
00047 h = ( h - sizeHints->base_height ) / sizeHints->height_inc;
00048 }
00049 }
00050
00051 h = QMAX( h, 0 );
00052 QString pos;
00053 pos.sprintf( "%+d,%+d<br>(<b>%d x %d</b>)",
00054 geom.x(), geom.y(), w, h );
00055 setText( pos );
00056 adjustSize();
00057 move( geom.x() + ((geom.width() - width()) / 2),
00058 geom.y() + ((geom.height() - height()) / 2) );
00059 }
00060
00061 }
00062
00063 #include "geometrytip.moc"
|