summaryrefslogtreecommitdiffstats
path: root/kbackgammon/kbg.h
blob: b60e55beef186eab904345349bbfbfea43a4eb99 (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
/*
  Copyright (C) 1999-2001 Jens Hoefkens
  hoefkens@pilot.msu.edu

  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 __KBG_H
#define __KBG_H

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

#include <tdemainwindow.h>

class TQSplitter;
class TQCheckBox;
class TQPopupMenu;
class TQLabel;
class TDEAction;
class TDESelectAction;
class KLineEdit;
class KDialogBase;
class KDoubleNumInput;

class KBgEngine;
class KBgTextView;
class KBgBoardSetup;


class KBg : public TDEMainWindow
{
	TQ_OBJECT
  

public:

	/**
	 * Constructor creates the full main window
	 */
	KBg();

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

	/**
	 * Read various settings from the configuration files or
	 * set some reasonable defaults
	 */
	void readConfig();

public slots:

         /**
	 * Set the caption to KFIBS_NAME + string + pipcount (if requested by
	 * the user)
	 */
	void updateCaption(const TQString &s);

	/**
	 * Slot to be called by the engine - it enables/disables buttons
	 * in the button bar
	 */
	void allowCommand(int cmd, bool f);

	/**
	 * Sets the backgammon engine to type
	 */
	void setupEngine();

	void startKCM(const TQString &);

signals:

	/**
	 * Tell all listeners to write their settings to disk
	 */
	void saveSettings();

	/**
	 * Tell all listeners to restore their settings or use reasonable
	 * defaults
	 */
	void readSettings();

protected:

	/*
	 * Windows are to be hidden
	 */
	virtual void hideEvent(TQHideEvent *);

	/*
	 * Redisplay the windows
	 */
	virtual void showEvent(TQShowEvent *);

	/*
	 * Called before the window is closed. Check with the engine
	 * if that is okay.
	 */
	virtual bool queryClose();

protected slots:

        /**
	 * Show the button bar - or not - depending on the corresponding action
	 */
    void toggleMenubar();

	void configureToolbars();
	void newToolbarConfig();

	/**
	 * Starts the print dialog and asks the board to print itself
	 */
	void print();

	void openNew();

	/**
	 * Takes text from the commandline and hands it over to the
	 * current engine
	 */
	void handleCmd(const TQString &);

	/**
	 * Saves the user settings to disk
	 */
	void saveConfig();

	/**
	 * Slots for the respective actions - called by the button bar
	 * and some global key shortcuts
	 */
	void undo();
	void redo();
	void roll();
	void cube();
	void load();
	void done();

	/**
	 * Opens and displays the respective home pages
	 */
	void showWWW(int t);

	void wwwFIBS();
	void wwwRule();

	/**
	 * Show the big setup dialog
	 */
	void setupDlg();

	/**
	 * Save the settings
	 */
	void setupOk();

	/**
	 * Delete the setup dialog
	 */
	void setupDone();

	/**
	 * Load default values for user settings
	 */
	void setupDefault();

	/**
	 * Undo the settings
	 */
	void setupCancel();

private:
    TDEAction *newAction, *undoAction, *redoAction, *rollAction, *cubeAction, *endAction, *loadAction;

	/*
	 * Each engine has its own identifier.
	 */
	enum Engines {None = -1, Offline, FIBS, GNUbg, NextGen, MaxEngine};
	TQString engineString[MaxEngine];
	KBgEngine *engine[MaxEngine];
	int currEngine;

	TQPopupMenu *dummyPopup;
	enum HelpTopics {FIBSHome, RuleHome, MaxHelpTopic};
	TQString helpTopic[MaxHelpTopic][2];
	TDESelectAction *engineSet;

	/**
	 * Notebook for the setup
	 */
	KDialogBase *nb;
	KDoubleNumInput *sbt;
	TQCheckBox *cbt, *cbs, *cbm;

	/*
	 * UI elements
	 */
	TQSplitter     *panner;
	KBgBoardSetup *board;
	KBgTextView   *status;
	KLineEdit     *cmdLine;
	TQLabel        *cmdLabel;
	TQString       baseCaption; // for user friendly printing, we keep it around
};

#endif // __KBG_H