• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KWin

geometrytip.cpp

Go to the documentation of this file.
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 This program is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 This program is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 *********************************************************************/
00020 
00021 #include "geometrytip.h"
00022 #include <QX11Info>
00023 
00024 namespace KWin
00025 {
00026 
00027 GeometryTip::GeometryTip( const XSizeHints* xSizeHints, bool save_under ):
00028     QLabel( 0 )
00029     {
00030     setObjectName( "kwingeometry" );
00031     setMargin(1);
00032     setIndent(0);
00033     setLineWidth(1);
00034     setFrameStyle( QFrame::Raised | QFrame::StyledPanel );
00035     setAlignment( Qt::AlignCenter | Qt::AlignTop );
00036     sizeHints = xSizeHints;
00037     if( save_under )
00038         {
00039         XSetWindowAttributes attr;
00040         attr.save_under = True; // use saveunder if possible to avoid weird effects in transparent mode
00041         XChangeWindowAttributes( display(), winId(), CWSaveUnder, &attr );
00042         }
00043     }
00044 
00045 GeometryTip::~GeometryTip()
00046     {
00047     }
00048 
00049 void GeometryTip::setGeometry( const QRect& geom )
00050     {
00051     int w = geom.width();
00052     int h = geom.height();
00053 
00054     if (sizeHints) 
00055         {
00056         if (sizeHints->flags & PResizeInc) 
00057             {
00058             w = ( w - sizeHints->base_width ) / sizeHints->width_inc;
00059             h = ( h - sizeHints->base_height ) / sizeHints->height_inc; 
00060             }
00061         }
00062 
00063     h = qMax( h, 0 ); // in case of isShade() and PBaseSize
00064     QString pos;
00065     pos.sprintf( "%+d,%+d<br>(<b>%d&nbsp;x&nbsp;%d</b>)",
00066                      geom.x(), geom.y(), w, h );
00067     setText( pos );
00068     adjustSize();
00069     move( geom.x() + ((geom.width()  - width())  / 2),
00070           geom.y() + ((geom.height() - height()) / 2) );
00071     }
00072 
00073 } // namespace
00074 
00075 #include "geometrytip.moc"

KWin

Skip menu "KWin"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal