kdeui Library API Documentation

kpanelapplet.cpp

00001 /*****************************************************************
00002 
00003 Copyright (c) 2000 Matthias Elter
00004 
00005 Permission is hereby granted, free of charge, to any person obtaining a copy
00006 of this software and associated documentation files (the "Software"), to deal
00007 in the Software without restriction, including without limitation the rights
00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00009 copies of the Software, and to permit persons to whom the Software is
00010 furnished to do so, subject to the following conditions:
00011 
00012 The above copyright notice and this permission notice shall be included in
00013 all copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00018 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00019 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00020 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00021 
00022 ******************************************************************/
00023 
00024 #include <kconfig.h>
00025 
00026 #include "kpanelapplet.h"
00027 #include "kpanelapplet.moc"
00028 
00029 KPanelApplet::KPanelApplet(const QString& configFile, Type type,
00030                            int actions, QWidget *parent, const char *name, WFlags f)
00031   : QFrame(parent, name, f)
00032   , _type(type)
00033   , _position( pBottom )
00034   , _alignment( LeftTop )
00035   , _config(0)
00036   , _actions(actions)
00037 {
00038   setFrameStyle(NoFrame);
00039   QPalette pal(palette());
00040   if(pal.active().mid() != pal.inactive().mid()){
00041     pal.setInactive(pal.active());
00042     setPalette(pal);
00043   }
00044 
00045   _config = new KConfig(configFile);
00046 }
00047 
00048 KPanelApplet::~KPanelApplet()
00049 {
00050   delete _config;
00051 }
00052 
00053 void KPanelApplet::setPosition( Position p )
00054 {
00055   if( _position == p ) return;
00056   _position = p;
00057   positionChange( p );
00058 }
00059 
00060 void KPanelApplet::setAlignment( Alignment a )
00061 {
00062   if( _alignment == a ) return;
00063   _alignment = a;
00064   alignmentChange( a );
00065 }
00066 
00067 // FIXME: Remove implementation for KDE 4
00068 void KPanelApplet::positionChange( Position )
00069 {
00070   orientationChange( orientation() );
00071   QResizeEvent e( size(), size() );
00072   resizeEvent( &e );
00073   popupDirectionChange( popupDirection() );
00074 }
00075 
00076 Qt::Orientation KPanelApplet::orientation() const
00077 {
00078   if( _position == pTop || _position == pBottom ) {
00079     return Horizontal;
00080   } else {
00081     return Vertical;
00082   }
00083 }
00084 
00085 // FIXME: Remove for KDE 4
00086 KPanelApplet::Direction KPanelApplet::popupDirection()
00087 {
00088     switch( _position ) {
00089     case pTop:     return Down;
00090     case pRight:   return Left;
00091     case pLeft:    return Right;
00092     default:
00093     case pBottom:  return Up;
00094     }
00095 }
00096 
00097 void KPanelApplet::action( Action a )
00098 {
00099     if ( (a & About) != 0 )
00100     about();
00101     if ( (a & Help) != 0 )
00102     help();
00103     if ( (a & Preferences) != 0 )
00104     preferences();
00105     if ( (a & ReportBug) != 0 )
00106     reportBug();
00107 }
00108 
00109 void KPanelApplet::virtual_hook( int, void* )
00110 { /*BASE::virtual_hook( id, data );*/ }
00111 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:00 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001