libkdegames
kchatbase.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __KCHATBASE_H__
00020 #define __KCHATBASE_H__
00021
00022 #include <tqframe.h>
00023 #include <tqstring.h>
00024 #include <tqlistbox.h>
00025
00026 #include <kglobalsettings.h>
00027 #include <kdemacros.h>
00028 class TQListBoxItem;
00029
00030 class KConfig;
00031
00032
00033 class KChatBaseTextPrivate;
00034
00049 class KChatBaseText : public QListBoxText
00050 {
00051 public:
00052
00056 KChatBaseText(const TQString& player, const TQString& text);
00057
00061 KChatBaseText(const TQString& text);
00062
00066 virtual ~KChatBaseText();
00067
00075 void setName(const TQString& name);
00076
00084 void setMessage(const TQString& message);
00085
00090 const TQString& name() const;
00091
00096 const TQString& message() const;
00097
00103 TQFont nameFont() const;
00104
00110 TQFont messageFont() const;
00111
00119 void setNameFont(const TQFont* font);
00120
00128 void setMessageFont(const TQFont* font);
00129
00132 virtual int width(TQListBox* ) const;
00133
00136 virtual int height(TQListBox* ) const;
00137
00138 protected:
00141 virtual void paint(TQPainter*);
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(TQWidget* parent, bool noComboBox = false);
00195
00201 virtual ~KChatBase();
00202
00203 enum SendingIds {
00204 SendToAll = 0
00205 };
00206
00212 virtual const TQString& fromName() const = 0;
00213
00225 bool addSendingEntry(const TQString& text, int id);
00226
00238 bool insertSendingEntry(const TQString& text, int id, int index = -1);
00239
00245 void changeSendingEntry(const TQString& 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 TQFont& font);
00299
00304 void setMessageFont(const TQFont& font);
00305
00312 void setBothFont(const TQFont& font);
00313
00318 void setSystemNameFont(const TQFont& font);
00319
00324 void setSystemMessageFont(const TQFont& font);
00325
00330 void setSystemBothFont(const TQFont& font);
00331
00339 const TQFont& nameFont() const;
00340
00348 const TQFont& messageFont() const;
00349
00354 const TQFont& systemNameFont() const;
00355
00360 const TQFont& 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 TQString& fromName, const TQString& text);
00414
00422 virtual void addSystemMessage(const TQString& fromName, const TQString& text);
00423
00434 virtual void addItem(const TQListBoxItem* item);
00435
00436
00441 void slotClear();
00442
00447 void setAcceptMessage(bool a);
00448
00449 signals:
00454 void rightButtonClicked(TQListBoxItem*, const TQPoint&);
00455
00456 protected:
00468 virtual void returnPressed(const TQString& text) = 0;
00469
00477 virtual TQString comboBoxItem(const TQString& name) const;
00478
00485 virtual TQListBoxItem* layoutMessage(const TQString& fromName, const TQString& text);
00486
00494 virtual TQListBoxItem* layoutSystemMessage(const TQString& fromName, const TQString& text);
00495
00496 private slots:
00502 void slotReturnPressed(const TQString&);
00503
00504 private:
00505 void init(bool noComboBox);
00506
00507 KChatBasePrivate* d;
00508 };
00509
00510 #endif