geometrytip.cpp
00001
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, h;
00040 int bw, bh;
00041
00042 w = geom.width();
00043 h = geom.height();
00044
00045 if (sizeHints)
00046 {
00047
00048 if (!(sizeHints->flags & PMinSize))
00049 {
00050 bw = 0;
00051 bh = 0;
00052 }
00053 else
00054 {
00055 bw = sizeHints->min_width;
00056 bh = sizeHints->min_height;
00057 }
00058
00059 if (sizeHints->flags & PResizeInc)
00060 {
00061 if (sizeHints->width_inc > 0)
00062 w = (w - bw) / sizeHints->width_inc;
00063 if (sizeHints->height_inc > 0)
00064 h = (h - bh) / sizeHints->height_inc;
00065
00066 }
00067 }
00068
00069 h = QMAX( h, 0 );
00070 QString pos;
00071 pos.sprintf( "%+d,%+d<br>(<b>%d x %d</b>)",
00072 geom.x(), geom.y(), w, h );
00073 setText( pos );
00074 adjustSize();
00075 move( geom.x() + ((geom.width() - width()) / 2),
00076 geom.y() + ((geom.height() - height()) / 2) );
00077 }
00078
00079 }
00080
00081 #include "geometrytip.moc"
This file is part of the documentation for kwin Library Version 3.3.2.