summaryrefslogtreecommitdiffstats
path: root/tdemdi/tdemdichildarea.h
blob: a755df515bc5b0d93f81c28b193c51dec679a687 (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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
//----------------------------------------------------------------------------
//    filename             : tdemdichildarea.h
//----------------------------------------------------------------------------
//    Project              : KDE MDI extension
//
//    begin                : 07/1999       by Szymon Stefanek as part of kvirc
//                                         (an IRC application)
//    changes              : 09/1999       by Falk Brettschneider to create an
//                           - 06/2000     stand-alone Qt extension set of
//                                         classes and a Qt-based library
//                           2000-2003     maintained by the KDevelop project
//
//    copyright            : (C) 1999-2003 by Falk Brettschneider
//                                         and
//                                         Szymon Stefanek (stefanek@tin.it)
//    email                :  falkbr@kdevelop.org (Falk Brettschneider)
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU Library General Public License as
//    published by the Free Software Foundation; either version 2 of the
//    License, or (at your option) any later version.
//
//----------------------------------------------------------------------------

#ifndef _TDEMDI_CHILD_AREA_H_
#define _TDEMDI_CHILD_AREA_H_

#include <tqframe.h>
#include <tqptrlist.h>

#include "tdemdichildfrm.h"
#include "tdemdichildview.h"

class KMdiChildAreaPrivate;

/**
  * @short Internal class.
  *
  * The main frame widget KMdiMainFrm consists of 2 child widgets. One is this class.
  * It's the widget where the child frames (emulated toplevel MDI views) live in.
  * This class is the manager for the child frame widgets because it controls the
  * Z-order widget stack of KMdiChildFrm's.
  * It provides all placing and positioning algorithms for docked (attached) MDI views.
  *
  * KMdiChildArea doesn't know anything about the actual MDI views. It only knows
  * and manages the frame widgets of attached MDI views.
  * All actions and stuff concerning only to childframes are handled here.
  */
class KMDI_EXPORT KMdiChildArea : public TQFrame
{
	friend class KMdiChildFrmCaption;
	friend class KMdiChildFrm;

TQ_OBJECT

	// attributes
public:
	/**
	 * Z Order stack of KMdiChildFrm childframe windows (top=last)
	 */
	TQPtrList<KMdiChildFrm> *m_pZ; //Auto delete enabled

	/**
	 * the default size of an newly created childframe
	 */
	TQSize m_defaultChildFrmSize;
protected:
	/**
	 * The MDI childframe window caption font
	 */
	TQFont m_captionFont;

	/**
	 * The foreground color of the active MDI childframe window caption
	 */
	TQColor m_captionActiveBackColor;

	/**
	 * The background color of the active MDI childframe window captions
	 */
	TQColor m_captionActiveForeColor;

	/**
	 * The foreground color of inactive MDI childframe window captions
	 */
	TQColor m_captionInactiveBackColor;

	/**
	 * The background color of inactive MDI childframe window captions
	 */
	TQColor m_captionInactiveForeColor;

	int m_captionFontLineSpacing;

	// methods
public:

	/**
	 * Consruction. Note: This class needn't to know about KMdiMainFrm .
	 */
	KMdiChildArea( TQWidget *parent );

	/**
	 * Destructor : THERE should be no child windows anymore...
	 * Howewer it simply deletes all the child widgets :)
	 */
	~KMdiChildArea();

	/**
	 * Appends a new KMdiChildFrm to this manager.
	 * The child is shown,raised and gets focus if this window has it.
	 */
	void manageChild( KMdiChildFrm *lpC, bool bShow = true, bool bCascade = true );

	/**
	 * Destroys a managed KMdiChildFrm
	 * Also deletes the client attached to this child.
	 */
	void destroyChild( KMdiChildFrm* child, bool focusTopChild = true );

	/**
	 * Destroys a managed KMdiChildFrm
	 * Clients attached to the KMdiChildFrm are not deleted.
	 */
	void destroyChildButNotItsView( KMdiChildFrm *lpC, bool bFocusTopChild = true );

	/**
	 * Brings the child to the top of the stack
	 * The child is focused if setFocus is true. If setFocus is false, the
	 * child is just raised.
	 */
	void setTopChild( KMdiChildFrm* child, bool setFocus = false );

	/**
	 * Returns the topmost child (the active one) or 0 if there are no children.
	 * Note that the topmost child may be also hidded , if ALL the windows are minimized.
	 */
	inline KMdiChildFrm * topChild() const { return m_pZ->last(); }

	/**
	 * Returns the number of visible children
	 */
	int getVisibleChildCount() const;

	/**
	 * Calculates the cascade point for the given index. If index is -1
	 * the cascade point is calculated for the window following the last window
	 * @param indexOfWindow the index of the window in relation the z-ordered window list
	 */
	TQPoint getCascadePoint( int indexOfWindow = -1 );

	/**
	 * Sets the MDI childframe window caption font
	 * A relayout does not occur when using this function
	 */
	void setMdiCaptionFont( const TQFont &fnt );

	/**
	 * Sets the foreground color of the active MDI childframe window caption
	 * A relayout does not occur when using this function
	 */
	void setMdiCaptionActiveForeColor( const TQColor &clr );

	/**
	 * Sets the background color of the active MDI childframe window captions
	 * A relayout does not occur when using this function
	 */
	void setMdiCaptionActiveBackColor( const TQColor &clr );

	/**
	 * Sets the foreground color of inactive MDI childframe window captions
	 * A relayout does not occur when using this function
	 */
	void setMdiCaptionInactiveForeColor( const TQColor &clr );

	/**
	 * Sets the background color of inactive MDI childframe window captions
	 * A relayout does not occur when using this function
	 */
	void setMdiCaptionInactiveBackColor( const TQColor &clr );

	/**
	 * Gets all caption colors, consistent with current WM settings
	 * (or other Desktop settings e.g. system settings for win32)
	 * This method is useful not only for KMDI child windows.
	 * Colors are returned via activeBG, activeFG, inactiveBG, inactiveFG references.
	 *
	 * @deprecated Use TDEGlobalSettings::activeTitleColor(), TDEGlobalSettings::activeTextColor(),
	 * TDEGlobalSettings::inactiveTitleColor() and TDEGlobalSettings::inactiveTextColor() instead.
	 */
	static void getCaptionColors( const TQPalette &pal, TQColor &activeBG, TQColor &activeFG,
	                              TQColor &inactiveBG, TQColor &inactiveFG ) KDE_DEPRECATED;

public slots:
	/**
	 * Cascades all windows resizing them to the minimum size.
	 */
	void cascadeWindows();

	/**
	 * Cascades all windows resizing them to the maximum available size.
	 */
	void cascadeMaximized();

	/**
	 * Maximize all windows but only in vertical direction
	 */
	void expandVertical();

	/**
	 * Maximize all windows but only in horizontal direction
	 */
	void expandHorizontal();

	/**
	 * Gives focus to the topmost child if it doesn't get focus
	 * automatically or you want to wait to give it focus
	 */
	void focusTopChild();

	/**
	 * Tile Pragma
	 */
	void tilePragma();

	/**
	 * Tile Anodine
	 */
	void tileAnodine();

	/**
	 * Tile all the windows in the child area vertically
	 */
	void tileVertically();

	/**
	 * Position and layout the minimized child frames
	 */
	void layoutMinimizedChildren();

protected:

	/**
	 * Internally used for the tile algorithm
	 */
	void tileAllInternal( int maxWnds );

	/**
	 * Automatically resizes a maximized MDI view and layouts the positions of minimized MDI views.
	 */
	virtual void resizeEvent( TQResizeEvent * );

	/**
	 * Shows the 'Window' popup menu on right mouse button click
	 */
	void mousePressEvent( TQMouseEvent *e );

	/**
	 * Internally used. Actions that are necessary when an MDI view gets minimized
	 */
	void childMinimized( KMdiChildFrm *lpC, bool bWasMaximized );

signals:
	/**
	 * Signals that there aren't maximized child frames any more
	 */
	void noMaximizedChildFrmLeft( KMdiChildFrm* );

	/**
	 * Signals that the child frames are maximized now
	 */
	void nowMaximized( bool );

	/**
	 * Signals a KMdiMainFrm that the signal/slot connections of the system buttons in the
	 * menubar (only in Maximize mode) must be updated to another MDI view because the focused
	 * MDI view has changed
	 * @internal
	 */
	void sysButtonConnectionsMustChange( KMdiChildFrm*, KMdiChildFrm* );

	/**
	 * Signals a KMdiMainFrm that the 'Window' popup menu must be shown
	 * @internal
	 */
	void popupWindowMenu( TQPoint );

	/**
	 * Signals that the last attached (docked) MDI view has been closed.
	 * Note: Detached MDI views can remain.
	 */
	void lastChildFrmClosed();

private:

	KMdiChildAreaPrivate *d;
};

#endif   // _TDEMDI_CHILDAREA_H_