kchatbase.h

Go to the documentation of this file.
00001 /*
00002     This file is part of the KDE games library
00003     Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License version 2 as published by the Free Software Foundation.
00008 
00009     This library 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 GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 #ifndef __KCHATBASE_H__
00020 #define __KCHATBASE_H__
00021 
00022 #include <qframe.h>
00023 #include <qstring.h>
00024 #include <qlistbox.h>
00025 
00026 #include <kglobalsettings.h>
00027 #include <kdemacros.h>
00028 class QListBoxItem;
00029 
00030 class KConfig;
00031 
00032 
00033 class KChatBaseTextPrivate;
00034 
00049 class KChatBaseText : public QListBoxText
00050 {
00051 public:
00052 
00056         KChatBaseText(const QString& player, const QString& text);
00057         
00061         KChatBaseText(const QString& text);
00062         
00066         virtual ~KChatBaseText();
00067 
00075         void setName(const QString& name);
00076 
00084         void setMessage(const QString& message);
00085 
00090         const QString& name() const;
00091 
00096         const QString& message() const;
00097 
00103         QFont nameFont() const;
00104 
00110         QFont messageFont() const;
00111 
00119         void setNameFont(const QFont* font);
00120 
00128         void setMessageFont(const QFont* font);
00129 
00132         virtual int width(QListBox* ) const;
00133 
00136         virtual int height(QListBox* ) const;
00137 
00138 protected:
00141         virtual void paint(QPainter*);
00142 
00143 private:
00144         void init();
00145 
00146 private:
00147         KChatBaseTextPrivate* d;
00148 };
00149 
00150 
00151 class KChatBasePrivate;
00152 
00184 class KDE_EXPORT KChatBase : public QFrame
00185 {
00186         Q_OBJECT
00187 public:
00194         KChatBase(QWidget* parent, bool noComboBox = false);
00195 
00201         virtual ~KChatBase();
00202 
00203         enum SendingIds {
00204                 SendToAll = 0
00205         };
00206 
00212         virtual const QString& fromName() const = 0;
00213 
00225         bool addSendingEntry(const QString& text, int id);
00226 
00238         bool insertSendingEntry(const QString& text, int id, int index = -1);
00239 
00245         void changeSendingEntry(const QString& text, int id);
00246 
00251         void setSendingEntry(int id);
00252 
00259         void removeSendingEntry(int id);
00260 
00268         int sendingEntry() const;
00269         
00273         int findIndex(int id) const;
00274 
00279         int nextId() const;
00280 
00287         virtual bool acceptMessage() const;
00288 
00292         void setCompletionMode(KGlobalSettings::Completion mode);
00293 
00298         void setNameFont(const QFont& font);
00299         
00304         void setMessageFont(const QFont& font);
00305 
00312         void setBothFont(const QFont& font);
00313 
00318         void setSystemNameFont(const QFont& font);
00319 
00324         void setSystemMessageFont(const QFont& font);
00325 
00330         void setSystemBothFont(const QFont& font);
00331 
00339         const QFont& nameFont() const;
00340 
00348         const QFont& messageFont() const;
00349 
00354         const QFont& systemNameFont() const;
00355 
00360         const QFont& systemMessageFont() const;
00361 
00371         virtual void saveConfig(KConfig* conf = 0);
00372 
00378         virtual void readConfig(KConfig* conf = 0);
00379 
00387         void setMaxItems(int maxItems);
00388 
00392         void clear();
00393 
00398         int maxItems() const;
00399 
00400 
00401 public slots:
00413         virtual void addMessage(const QString& fromName, const QString& text);
00414 
00422         virtual void addSystemMessage(const QString& fromName, const QString& text);
00423 
00434         virtual void addItem(const QListBoxItem* item);
00435 
00436 
00441         void slotClear();
00442 
00447         void setAcceptMessage(bool a);
00448         
00449 signals:
00454         void rightButtonClicked(QListBoxItem*, const QPoint&);
00455 
00456 protected:
00468         virtual void returnPressed(const QString& text) = 0;
00469 
00477         virtual QString comboBoxItem(const QString& name) const;
00478 
00485         virtual QListBoxItem* layoutMessage(const QString& fromName, const QString& text);
00486 
00494         virtual QListBoxItem* layoutSystemMessage(const QString& fromName, const QString& text);
00495 
00496 private slots:
00502         void slotReturnPressed(const QString&);
00503 
00504 private:
00505         void init(bool noComboBox);
00506 
00507         KChatBasePrivate* d;
00508 };
00509 
00510 #endif

Generated on Wed Aug 23 18:04:17 2006 for libkdegames by  doxygen 1.4.6