kwin Library API Documentation

geometrytip.cpp

00001 /*****************************************************************
00002  KWin - the KDE window manager
00003  This file is part of the KDE project.
00004 
00005 Copyright (c) 2003, Karol Szwed <kszwed@kde.org>
00006 
00007 You can Freely distribute this program under the GNU General Public
00008 License. See the file "COPYING" for the exact licensing terms.
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; // use saveunder if possible to avoid weird effects in transparent mode
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     // PBaseSize is only for aspect ratios, see Client::getWMNormalHints()
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 ); // in case of isShade() and PBaseSize
00070     QString pos;
00071     pos.sprintf( "%+d,%+d<br>(<b>%d&nbsp;x&nbsp;%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 } // namespace
00080 
00081 #include "geometrytip.moc"
KDE Logo
This file is part of the documentation for kwin Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Sep 8 02:43:19 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003