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

libplasma

fliplayout.h

Go to the documentation of this file.
00001 /*
00002  *   Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Lesser General Public License version 2,
00006  *   or (at your option) any later version, as published by the Free
00007  *   Software Foundation
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU Lesser General Public License for more details
00013  *
00014  *   You should have received a copy of the GNU Lesser General Public
00015  *   License along with this program; if not, write to the
00016  *   Free Software Foundation, Inc.,
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 
00020 #ifndef PLASMA_FLIPLAYOUT_H_
00021 #define PLASMA_FLIPLAYOUT_H_
00022 
00023 #include <plasma/plasma.h>
00024 #include <plasma/layouts/layout.h>
00025 #include <plasma/widgets/widget.h>
00026 
00027 namespace Plasma
00028 {
00029 
00030 template <typename SuperLayout>
00031 class FlipLayout : public SuperLayout { //Plasma::Layout
00032 public:
00033     void setFlip(Flip flip)
00034     {
00035         m_flip = flip;
00036     }
00037 
00038     Flip flip()
00039     {
00040         return m_flip;
00041     }
00042 
00043 private:
00044     Flip m_flip;
00045 
00046 protected:
00047     void relayout()
00048     {
00049         SuperLayout::relayout();
00050         QRectF rect = SuperLayout::geometry();
00051 
00052         int count = SuperLayout::count();
00053 
00054         if (m_flip == NoFlip) {
00055             return;
00056         }
00057 
00058         QRectF childGeometry;
00059         for (int i = 0; i < count; i++) {
00060             Plasma::LayoutItem * item = SuperLayout::itemAt(i);
00061 
00062             if (!item) continue;
00063 
00064             childGeometry = item->geometry();
00065             if (m_flip & HorizontalFlip) {
00066                 // 2 * rect.left() - twice because we already have one
00067                 // value of rect.left() inside the childGeometry.left()
00068                 childGeometry.moveLeft(
00069                     2 * rect.left()       + rect.width()
00070                       - childGeometry.left()  - childGeometry.width()
00071                 );
00072             }
00073             if (m_flip & VerticalFlip) {
00074                 // 2 * rect.top() - same reason as aforemontioned
00075                 childGeometry.moveTop(
00076                     2 * rect.top()      + rect.height()
00077                       - childGeometry.top() - childGeometry.height()
00078                 );
00079             }
00080             item->setGeometry(childGeometry);
00081         }
00082     }
00083 
00084 };
00085 
00086 }
00087 
00088 #endif /*FlipLayout_H_*/

libplasma

Skip menu "libplasma"
  • 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
  • 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