kwin Library API Documentation

buttons.h

00001 /* 00002 This is the new kwindecoration kcontrol module 00003 00004 Copyright (c) 2001 00005 Karol Szwed <gallium@kde.org> 00006 http://gallium.n3.net/ 00007 00008 Supports new kwin configuration plugins, and titlebar button position 00009 modification via dnd interface. 00010 00011 Based on original "kwintheme" (Window Borders) 00012 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 00013 00014 This program is free software; you can redistribute it and/or modify 00015 it under the terms of the GNU General Public License as published by 00016 the Free Software Foundation; either version 2 of the License, or 00017 (at your option) any later version. 00018 00019 This program is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License 00025 along with this program; if not, write to the Free Software 00026 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00027 00028 */ 00029 00030 #ifndef __BUTTONS_H_ 00031 #define __BUTTONS_H_ 00032 00033 #include <qevent.h> 00034 #include <qdragobject.h> 00035 #include <qlistbox.h> 00036 00037 00039 00040 class ButtonDrag: public QStoredDrag 00041 { 00042 public: 00043 ButtonDrag( char btn, QWidget* parent, const char* name=0 ); 00044 ~ButtonDrag() {}; 00045 00046 static bool canDecode( QDragMoveEvent* e ); 00047 static bool decode( QDropEvent* e, char& btn ); 00048 }; 00049 00050 00052 00053 class ButtonSource: public QListBox 00054 { 00055 Q_OBJECT 00056 00057 public: 00058 ButtonSource( QWidget* parent=0, const char* name=0 ); 00059 ~ButtonSource(); 00060 00061 void hideAllButtons(); 00062 void showAllButtons(); 00063 00064 signals: 00065 void buttonDropped(); 00066 00067 public slots: 00068 void hideButton( char btn ); 00069 void showButton( char btn ); 00070 00071 protected: 00072 void dragEnterEvent( QDragEnterEvent* e ); 00073 void dragMoveEvent( QDragMoveEvent* e ); 00074 void dragLeaveEvent( QDragLeaveEvent* e ); 00075 void dropEvent( QDropEvent* e ); 00076 void mousePressEvent( QMouseEvent* e ); 00077 00078 private: 00079 char convertToChar( QString s ); 00080 QString convertToString( char btn ); 00081 00082 int spacerCount; 00083 }; 00084 00085 00087 00088 class ButtonDropSite: public QFrame 00089 { 00090 Q_OBJECT 00091 00092 public: 00093 ButtonDropSite( QWidget* parent=0, const char* name=0 ); 00094 ~ButtonDropSite(); 00095 00096 // Allow external classes access our buttons - ensure buttons are 00097 // not duplicated however. 00098 QString buttonsLeft; 00099 QString buttonsRight; 00100 00101 signals: 00102 void buttonAdded( char c ); 00103 void buttonRemoved( char c ); 00104 void changed(); 00105 00106 public slots: 00107 void removeClickedButton(); 00108 00109 protected: 00110 void dragEnterEvent( QDragEnterEvent* e ); 00111 void dragMoveEvent( QDragMoveEvent* e ); 00112 void dragLeaveEvent( QDragLeaveEvent* e ); 00113 void dropEvent( QDropEvent* e ); 00114 void mousePressEvent( QMouseEvent* e ); 00115 00116 void drawContents( QPainter* p ); 00117 int buttonWidth( char btn ); 00118 int calcButtonStringWidth( const QString& s ); 00119 char removeButtonAtPoint( QPoint p ); 00120 void buttonInsertedAtPoint( QPoint p, bool& isleft, int& strPos ); 00121 void drawButtonString( QPainter* p, QString& s, int offset ); 00122 00123 QPoint mouseClickPoint; 00124 }; 00125 00126 00127 #endif 00128 // vim: ts=4
KDE Logo
This file is part of the documentation for kwin Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 13 21:47:04 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003