kpanelextension.h
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 #ifndef __kpanelextension_h__ 00025 #define __kpanelextension_h__ 00026 00027 class QPopupMenu; 00028 class KConfig; 00029 class KPanelExtensionPrivate; 00030 00031 #include <qframe.h> 00032 00033 #include <kdelibs_export.h> 00034 00098 class KDEUI_EXPORT KPanelExtension : public QFrame 00099 { 00100 Q_OBJECT 00101 00102 public: 00103 00105 enum Type { Normal = 0, Stretch }; 00106 // KDE4: Merge these with KPanelApplet's enums 00108 enum Action { About = 1, Help = 2, Preferences = 4, ReportBug = 8 }; 00109 enum Position { Left = 0, Right, Top, Bottom, Floating }; 00110 enum Alignment { LeftTop = 0, Center, RightBottom }; 00112 enum Size { SizeTiny = 0, SizeSmall, SizeNormal, SizeLarge, SizeCustom }; 00113 00123 KPanelExtension(const QString& configFile, Type t = Normal, 00124 int actions = 0, QWidget *parent = 0, const char *name = 0); 00125 00129 ~KPanelExtension(); 00130 00140 virtual QSize sizeHint(Position /*p*/, QSize maxsize) const { return maxsize; } 00141 00151 KConfig* config() const { return _config; } 00152 00157 Type type() const { return _type; } 00158 00163 int actions() const { return _actions; } 00164 00175 virtual void action( Action a ); 00176 00177 00184 virtual Position preferedPosition() const { return Bottom; } 00185 00189 void setPosition( Position p ); 00193 void setAlignment( Alignment a ); 00198 void setSize( Size size, int customSize ); 00199 00204 Size sizeSetting() const; 00205 00210 int customSize() const; 00211 00217 QPopupMenu* customMenu() const; 00218 00225 bool reserveStrut() const; 00226 00227 signals: 00233 void updateLayout(); 00234 00239 void maintainFocus(bool); 00240 00241 protected: 00242 00250 virtual void about() {} 00251 00259 virtual void help() {} 00260 00268 virtual void preferences() {} 00269 00278 virtual void reportBug() {} 00279 00283 Position position() const { return _position; } 00284 00288 Alignment alignment() const { return _alignment; } 00289 00293 Orientation orientation(); 00294 00299 int sizeInPixels() const; 00300 00306 virtual void positionChange( Position ) {} 00307 00313 virtual void alignmentChange( Alignment ) {} 00314 00325 void setCustomMenu(QPopupMenu*); 00326 00332 void setReserveStrut(bool shouldUseStrut); 00333 00334 private: 00335 Type _type; 00336 Position _position; 00337 Alignment _alignment; 00338 KConfig* _config; 00339 int _actions; 00340 protected: 00341 virtual void virtual_hook( int id, void* data ); 00342 private: 00343 KPanelExtensionPrivate *d; 00344 }; 00345 00346 #endif