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 TQListBoxText
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 TQFrame
00185 {
00186 Q_OBJECT
00187 TQ_OBJECT
00188 public:
00195 KChatBase(TQWidget* parent, bool noComboBox = false);
00196
00202 virtual ~KChatBase();
00203
00204 enum SendingIds {
00205 SendToAll = 0
00206 };
00207
00213 virtual const TQString& fromName() const = 0;
00214
00226 bool addSendingEntry(const TQString& text, int id);
00227
00239 bool insertSendingEntry(const TQString& text, int id, int index = -1);
00240
00246 void changeSendingEntry(const TQString& text, int id);
00247
00252 void setSendingEntry(int id);
00253
00260 void removeSendingEntry(int id);
00261
00269 int sendingEntry() const;
00270
00274 int findIndex(int id) const;
00275
00280 int nextId() const;
00281
00288 virtual bool acceptMessage() const;
00289
00293 void setCompletionMode(KGlobalSettings::Completion mode);
00294
00299 void setNameFont(const TQFont& font);
00300
00305 void setMessageFont(const TQFont& font);
00306
00313 void setBothFont(const TQFont& font);
00314
00319 void setSystemNameFont(const TQFont& font);
00320
00325 void setSystemMessageFont(const TQFont& font);
00326
00331 void setSystemBothFont(const TQFont& font);
00332
00340 const TQFont& nameFont() const;
00341
00349 const TQFont& messageFont() const;
00350
00355 const TQFont& systemNameFont() const;
00356
00361 const TQFont& systemMessageFont() const;
00362
00372 virtual void saveConfig(KConfig* conf = 0);
00373
00379 virtual void readConfig(KConfig* conf = 0);
00380
00388 void setMaxItems(int maxItems);
00389
00393 void clear();
00394
00399 int maxItems() const;
00400
00401
00402 public slots:
00414 virtual void addMessage(const TQString& fromName, const TQString& text);
00415
00423 virtual void addSystemMessage(const TQString& fromName, const TQString& text);
00424
00435 virtual void addItem(const TQListBoxItem* item);
00436
00437
00442 void slotClear();
00443
00448 void setAcceptMessage(bool a);
00449
00450 signals:
00455 void rightButtonClicked(TQListBoxItem*, const TQPoint&);
00456
00457 protected:
00469 virtual void returnPressed(const TQString& text) = 0;
00470
00478 virtual TQString comboBoxItem(const TQString& name) const;
00479
00486 virtual TQListBoxItem* layoutMessage(const TQString& fromName, const TQString& text);
00487
00495 virtual TQListBoxItem* layoutSystemMessage(const TQString& fromName, const TQString& text);
00496
00497 private slots:
00503 void slotReturnPressed(const TQString&);
00504
00505 private:
00506 void init(bool noComboBox);
00507
00508 KChatBasePrivate* d;
00509 };
00510
00511 #endif