summaryrefslogtreecommitdiffstats
path: root/kbackgammon/engines/fibs/kbgfibschat.h
blob: b444672d48e88a91b472b4fe72477f4e1ab253bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/*
  Copyright (C) 1999-2001 Jens Hoefkens
  jens@hoefkens.com

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

  $Id$

*/

#ifndef __KBGCHAT_H
#define __KBGCHAT_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <kchat.h>

class TQString;
class TQPoint;
class TQListBox;
class TQListBoxItem;
class TQPopupMenu;

class KTabCtl;
class TDEAction;

class KBgChatPrivate;

/**
 * Class of the FIBS Chat Windows
 *
 * This class inherits from KChat and represents a widget for a chat
 * window. It has rich text entries and supports a powerful context
 * menu.
 *
 * @short An extension of the KGame chat window for the FIBS engine
 * @author Jens Hoefkens <jens@hoefkens.com>
 *
 */
class KBgChat : public KChat
{
    TQ_OBJECT
  

public:

    /**
     * Constructor
     */
    KBgChat(TQWidget *parent = 0, const char *name = 0);

    /**
     * Destructor
     */
    virtual ~KBgChat();

public slots:

    /**
     * Catch the RMB signal to display a context menu at p. The
     * menu shows entries specific to the selected item i.
     */
    void contextMenu(TQListBoxItem *i, const TQPoint &p);

    /**
     * Add chat window specific pages to the setup dialog
     */
    void getSetupPages(KTabCtl *nb, int space);

    /**
     * Save and apply the changes made in the setup dialog
     */
    void setupOk();

    /**
     * Do not save any of the changes made in the setup dialog
     */
    void setupCancel();

    /**
     * Load default values from the setup dialog
     */
  void setupDefault();

    /**
     * Player name has logges out. Remove name from the chat
     * window combo box if necessary.
     */
    void deletePlayer(const TQString &name);

    /**
     * Process and append msg to the text.
     */
    void handleData(const TQString &msg);

    /**
     * Restore previously saved setting or provides defaults
     */
    void readConfig();

    /**
     * Save current settings
     */
    void saveConfig();

    /**
     * Set the opponents name and select whisper
     */
    void startGame(const TQString &name);

    /**
     * Game is over. We won (or not) and have been playing (or not)
     */
    void endGame();

    /**
     * Start talking to name
     */
    void fibsTalk(const TQString &name);

signals:

    /**
     * Emits a string that can be sent to the server
     */
    void fibsCommand(const TQString &cmd);

    /**
     * Request an invitation of player
     */
    void fibsRequestInvitation(const TQString &player);

    /**
     * Text of a personal message
     */
    void personalMessage(const TQString &msg);

    /**
     * Dialog is visible or not
     */
    void windowVisible(bool v);

protected:

    /**
     * Catch show events, so the engine's menu can be updated.
     */
    virtual void showEvent(TQShowEvent *e);

    /**
     * Catch hide events, so the engine's menu can be updated.
     */
    virtual void hideEvent(TQHideEvent *e);

    /**
     * Create a custom ListBoxItem that contains a formated string
     * for the chat window.
     */
    virtual TQListBoxItem* layoutMessage(const TQString& fromName, const TQString& text);

protected slots:

    /**
     * Invite the selected player using the dialog
     */
    void slotInviteD();

    /**
     * Invite the selected player to resume a match
     */
    void slotInviteR();

    /**
     * Invite the selected player to an unlimited match
     */
    void slotInviteU();

    /**
     * Invite the selected player to a 1 point match
     */
    void slotInvite1();

    /**
     * Invite the selected player to a 2 point match
     */
    void slotInvite2();

    /**
     * Invite the selected player to a 3 point match
     */
    void slotInvite3();

    /**
     * Invite the selected player to a 4 point match
     */
    void slotInvite4();

    /**
     * Invite the selected player to a 5 point match
     */
    void slotInvite5();

    /**
     * Invite the selected player to a 6 point match
     */
    void slotInvite6();

    /**
     * Invite the selected player to a 7 point match
     */
    void slotInvite7();

    /**
     * Request information on the selected player
     */
    void slotInquire();

    /**
     * Copy the selected line to the clipboard
     */
    void slotCopy();

    /**
     * Talk to the selected player
     */
    void slotTalk();

    /**
     * Add the selected player to the gag list
     */
    void slotGag();

    /**
     * Remove the selected player from the gag list
     */
    void slotUngag();

    /**
     * Clear the gag list
     */
    void slotCleargag();

    /**
     * Toggle everybody silent
     */
    void slotSilent();

    /**
     * Slot for return pressed. Time to send the text to FIBS.
     */
    void handleCommand(int id, const TQString& msg);

private:

    KBgChatPrivate *d;

};

#endif // __KBGCHAT_H