summaryrefslogtreecommitdiffstats
path: root/lib/compatibility/tdemdi/qextmdi/tdemdichildview.cpp
blob: 11056c57d4f238e08606d85408d5db01c6dc4111 (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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
//----------------------------------------------------------------------------
//    filename             : tdemdichildview.cpp
//----------------------------------------------------------------------------
//    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 a
//                           -06/2000      stand-alone TQt extension set of
//                                         classes and a TQt-based library
//                           2000-2003     maintained by the KDevelop project
//    patches              : 02/2000       by Massimo Morin (mmorin@schedsys.com)
//                           */2000        by Lars Beikirch (Lars.Beikirch@gmx.net)
//                           02/2001       by Eva Brucherseifer (eva@rt.e-technik.tu-darmstadt.de)
//                           01/2003       by Jens Zurheide (jens.zurheide@gmx.de)
//
//    copyright            : (C) 1999-2003 by Szymon Stefanek (stefanek@tin.it)
//                                         and
//                                         Falk Brettschneider
//    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.
//
//----------------------------------------------------------------------------

#include "tdemdichildview.h"
#include "tdemdichildview.moc"

#include <tqdatetime.h>
#include <tqobjectlist.h>

#include "tdemdimainfrm.h"
#include "tdemdichildfrm.h"
#include "tdemdidefines.h"
#include <kdebug.h>
#include <tdelocale.h>
#include <tqiconset.h>

//============ KMdiChildView ============//

KMdiChildView::KMdiChildView( const TQString& caption, TQWidget* parentWidget, const char* name, WFlags f )
	: TQWidget( parentWidget, name, f )
	, m_focusedChildWidget( 0L )
	, m_firstFocusableChildWidget( 0L )
	, m_lastFocusableChildWidget( 0L )
	, m_stateChanged( true )
	, m_bToolView( false )
	, m_bInterruptActivation( false )
	, m_bMainframesActivateViewIsPending( false )
	, m_bFocusInEventIsPending( false )
	, m_trackChanges( 0 )
{
	setGeometry( 0, 0, 0, 0 );  // reset
	if ( caption != 0L )
		m_szCaption = caption;
	else
		m_szCaption = i18n( "Unnamed" );
	
	m_sTabCaption = m_szCaption;
	setFocusPolicy( TQWidget::ClickFocus );
	installEventFilter( this );
	
	// store the current time
	updateTimeStamp();
}


//============ KMdiChildView ============//

KMdiChildView::KMdiChildView( TQWidget* parentWidget, const char* name, WFlags f )
	: TQWidget( parentWidget, name, f )
	, m_focusedChildWidget( 0L )
	, m_firstFocusableChildWidget( 0L )
	, m_lastFocusableChildWidget( 0L )
	, m_stateChanged( true )
	, m_bToolView( false )
	, m_bInterruptActivation( false )
	, m_bMainframesActivateViewIsPending( false )
	, m_bFocusInEventIsPending( false )
{
	setGeometry( 0, 0, 0, 0 );  // reset
	m_szCaption = i18n( "Unnamed" );
	m_sTabCaption = m_szCaption;
	setFocusPolicy( TQWidget::ClickFocus );
	installEventFilter( this );

	// store the current time
	updateTimeStamp();
}

//============ ~KMdiChildView ============//

KMdiChildView::~KMdiChildView()
{
	kdDebug( 760 ) << k_funcinfo << endl;
}

void KMdiChildView::trackIconAndCaptionChanges( TQWidget *view )
{
	m_trackChanges = view;
}


//============== internal geometry ==============//

TQRect KMdiChildView::internalGeometry() const
{
	if ( mdiParent() )
	{ // is attached
		// get the client area coordinates inside the MDI child frame
		TQRect posInFrame = geometry();
		// map these values to the parent of the MDI child frame
		// (this usually is the MDI child area) and return
		TQPoint ptTopLeft = mdiParent() ->mapToParent( posInFrame.topLeft() );
		TQSize sz = size();
		return TQRect( ptTopLeft, sz );
	}
	else
	{
		TQRect geo = geometry();
		TQRect frameGeo = externalGeometry();
		return TQRect( frameGeo.x(), frameGeo.y(), geo.width(), geo.height() );
		//      return geometry();
	}
}

//============== set internal geometry ==============//

void KMdiChildView::setInternalGeometry( const TQRect& newGeometry )
{
	if ( mdiParent() )
	{ // is attached
		// retrieve the frame size
		TQRect geo = internalGeometry();
		TQRect frameGeo = externalGeometry();
		int nFrameSizeTop = geo.y() - frameGeo.y();
		int nFrameSizeLeft = geo.x() - frameGeo.x();

		// create the new geometry that is accepted by the TQWidget::setGeometry() method
		TQRect newGeoTQt;
		newGeoTQt.setX( newGeometry.x() - nFrameSizeLeft );
		newGeoTQt.setY( newGeometry.y() - nFrameSizeTop );

		newGeoTQt.setWidth( newGeometry.width() + nFrameSizeLeft + KMDI_CHILDFRM_DOUBLE_BORDER / 2 );
		newGeoTQt.setHeight( newGeometry.height() + nFrameSizeTop + KMDI_CHILDFRM_DOUBLE_BORDER / 2 );
		//      newGeoTQt.setWidth(newGeometry.width()+KMDI_MDI_CHILDFRM_DOUBLE_BORDER);
		//      newGeoTQt.setHeight(newGeometry.height()+mdiParent()->captionHeight()+KMDI_MDI_CHILDFRM_DOUBLE_BORDER);

		// set the geometry
		mdiParent()->setGeometry( newGeoTQt );
	}
	else
	{
		// retrieve the frame size
		TQRect geo = internalGeometry();
		TQRect frameGeo = externalGeometry();
		int nFrameSizeTop = geo.y() - frameGeo.y();
		int nFrameSizeLeft = geo.x() - frameGeo.x();

		// create the new geometry that is accepted by the TQWidget::setGeometry() method
		TQRect newGeoTQt;

		newGeoTQt.setX( newGeometry.x() - nFrameSizeLeft );
		newGeoTQt.setY( newGeometry.y() - nFrameSizeTop );

		newGeoTQt.setWidth( newGeometry.width() );
		newGeoTQt.setHeight( newGeometry.height() );

		// set the geometry
		setGeometry( newGeoTQt );
	}
}

//============== external geometry ==============//

TQRect KMdiChildView::externalGeometry() const
{
	return mdiParent() ? mdiParent()->frameGeometry() : frameGeometry();
}

//============== set external geometry ==============//

void KMdiChildView::setExternalGeometry( const TQRect& newGeometry )
{
	if ( mdiParent() )
	{ // is attached
		mdiParent() ->setGeometry( newGeometry );
	}
	else
	{
		// retrieve the frame size
		TQRect geo = internalGeometry();
		TQRect frameGeo = externalGeometry();
		int nTotalFrameWidth = frameGeo.width() - geo.width();
		int nTotalFrameHeight = frameGeo.height() - geo.height();
		int nFrameSizeTop = geo.y() - frameGeo.y();
		int nFrameSizeLeft = geo.x() - frameGeo.x();

		// create the new geometry that is accepted by the TQWidget::setGeometry() method
		// not attached => the window system makes the frame
		TQRect newGeoTQt;
		newGeoTQt.setX( newGeometry.x() + nFrameSizeLeft );
		newGeoTQt.setY( newGeometry.y() + nFrameSizeTop );
		newGeoTQt.setWidth( newGeometry.width() - nTotalFrameWidth );
		newGeoTQt.setHeight( newGeometry.height() - nTotalFrameHeight );

		// set the geometry
		setGeometry( newGeoTQt );
	}
}

//============== minimize ==============//

void KMdiChildView::minimize( bool bAnimate )
{
	if ( mdiParent() )
	{
		if ( !isMinimized() )
		{
			mdiParent() ->setState( KMdiChildFrm::Minimized, bAnimate );
		}
	}
	else
		showMinimized();
}

void KMdiChildView::showMinimized()
{
	emit isMinimizedNow();
	TQWidget::showMinimized();
}

//slot:
void KMdiChildView::minimize()
{
	minimize( true );
}

//============= maximize ==============//

void KMdiChildView::maximize( bool bAnimate )
{
	if ( mdiParent() )
	{
		if ( !isMaximized() )
		{
			mdiParent() ->setState( KMdiChildFrm::Maximized, bAnimate );
			emit mdiParentNowMaximized( true );
		}
	}
	else
		showMaximized();
}

void KMdiChildView::showMaximized()
{
	emit isMaximizedNow();
	TQWidget::showMaximized();
}

//slot:
void KMdiChildView::maximize()
{
	maximize( true );
}

//============== restoreGeometry ================//

TQRect KMdiChildView::restoreGeometry()
{
	if ( mdiParent() )
		return mdiParent() ->restoreGeometry();
	else //FIXME not really supported, may be we must use Windows or X11 funtions
		return geometry();
}

//============== setRestoreGeometry ================//

void KMdiChildView::setRestoreGeometry( const TQRect& newRestGeo )
{
	if ( mdiParent() )
		mdiParent()->setRestoreGeometry( newRestGeo );
}

//============== attach ================//

void KMdiChildView::attach()
{
	emit attachWindow( this, true );
}

//============== detach =================//

void KMdiChildView::detach()
{
	emit detachWindow( this, true );
}

//=============== isMinimized ? =================//

bool KMdiChildView::isMinimized() const
{
	if ( mdiParent() )
		return ( mdiParent()->state() == KMdiChildFrm::Minimized );
	else
		return TQWidget::isMinimized();
}

//============== isMaximized ? ==================//

bool KMdiChildView::isMaximized() const
{
	if ( mdiParent() )
		return ( mdiParent()->state() == KMdiChildFrm::Maximized );
	else
		return TQWidget::isMaximized();
}

//============== restore ================//

void KMdiChildView::restore()
{
	if ( mdiParent() )
	{
		if ( isMaximized() )
			emit mdiParentNowMaximized( false );
		
		if ( isMinimized() || isMaximized() )
			mdiParent()->setState( KMdiChildFrm::Normal );
	}
	else
		showNormal();
}

void KMdiChildView::showNormal()
{
	emit isRestoredNow();
	TQWidget::showNormal();
}

//=============== youAreAttached ============//

void KMdiChildView::youAreAttached( KMdiChildFrm *lpC )
{
	lpC->setCaption( m_szCaption );
	emit isAttachedNow();
}

//================ youAreDetached =============//

void KMdiChildView::youAreDetached()
{
	setCaption( m_szCaption );

	setTabCaption( m_sTabCaption );
	if ( myIconPtr() )
		setIcon( *( myIconPtr() ) );
	
	setFocusPolicy( TQWidget::StrongFocus );

	emit isDetachedNow();
}

//================ setCaption ================//
// this set the caption of only the window
void KMdiChildView::setCaption( const TQString& szCaption )
{
	// this will work only for window
	m_szCaption = szCaption;
	if ( mdiParent() )
		mdiParent() ->setCaption( m_szCaption );
	else //have to call the parent one
		TQWidget::setCaption( m_szCaption );

	emit windowCaptionChanged( m_szCaption );
}

//============== closeEvent ================//

void KMdiChildView::closeEvent( TQCloseEvent *e )
{
	e->ignore(); //we ignore the event , and then close later if needed.
	emit childWindowCloseRequest( this );
}

//================ myIconPtr =================//

TQPixmap* KMdiChildView::myIconPtr()
{
	return 0;
}

//============= focusInEvent ===============//

void KMdiChildView::focusInEvent( TQFocusEvent *e )
{
	TQWidget::focusInEvent( e );

	// every widget get a focusInEvent when a popup menu is opened!?! -> maybe bug of QT
	if ( e && ( ( e->reason() ) == TQFocusEvent::Popup ) )
		return ;


	m_bFocusInEventIsPending = true;
	activate();
	m_bFocusInEventIsPending = false;

	emit gotFocus( this );
}

//============= activate ===============//

void KMdiChildView::activate()
{
	// avoid circularity
	static bool s_bActivateIsPending = false;
	if ( s_bActivateIsPending )
		return ;
	
	s_bActivateIsPending = true;

	// raise the view and push the taskbar button
	if ( !m_bMainframesActivateViewIsPending )
		emit focusInEventOccurs( this );

	// if this method was called directly, check if the mainframe wants that we interrupt
	if ( m_bInterruptActivation )
		m_bInterruptActivation = false;
	else
	{
		if ( !m_bFocusInEventIsPending )
			setFocus();
		
		kdDebug( 760 ) << k_funcinfo << endl;
		emit activated( this );
	}

	if ( m_focusedChildWidget != 0L )
		m_focusedChildWidget->setFocus();
	else
	{
		if ( m_firstFocusableChildWidget != 0L )
		{
			m_firstFocusableChildWidget->setFocus();
			m_focusedChildWidget = m_firstFocusableChildWidget;
		}
	}
	s_bActivateIsPending = false;
}

//============= focusOutEvent ===============//

void KMdiChildView::focusOutEvent( TQFocusEvent* e )
{
	TQWidget::focusOutEvent( e );
	emit lostFocus( this );
}

//============= resizeEvent ===============//

void KMdiChildView::resizeEvent( TQResizeEvent* e )
{
	TQWidget::resizeEvent( e );

	if ( m_stateChanged )
	{
		m_stateChanged = false;
		if ( isMaximized() )
		{ //maximized
			emit isMaximizedNow();
		}
		else if ( isMinimized() )
		{ //minimized
			emit isMinimizedNow();
		}
		else
		{ //is restored
			emit isRestoredNow();
		}
	}
}

void KMdiChildView::slot_childDestroyed()
{
	// do what we do if a child is removed

	// if we lost a child we uninstall ourself as event filter for the lost
	// child and its children
	const TQObject * pLostChild = TQObject::sender();
	if ( pLostChild && ( pLostChild->isWidgetType() ) )
	{
		TQObjectList* list = ( ( TQObject* ) ( pLostChild ) ) ->queryList( "TQWidget" );
		list->insert( 0, pLostChild );        // add the lost child to the list too, just to save code
		TQObjectListIt it( *list );          // iterate over all lost child widgets
		TQObject* obj;
		while ( ( obj = it.current() ) != 0 )
		{ // for each found object...
			TQWidget * widg = ( TQWidget* ) obj;
			++it;
			widg->removeEventFilter( this );
			if ( m_firstFocusableChildWidget == widg )
				m_firstFocusableChildWidget = 0L;   // reset first widget
			
			if ( m_lastFocusableChildWidget == widg )
				m_lastFocusableChildWidget = 0L;    // reset last widget
			
			if ( m_focusedChildWidget == widg )
				m_focusedChildWidget = 0L;          // reset focused widget
		}
		delete list;                        // delete the list, not the objects
	}
}

//============= eventFilter ===============//
bool KMdiChildView::eventFilter( TQObject *obj, TQEvent *e )
{
	if ( e->type() == TQEvent::KeyPress && isAttached() )
	{
		TQKeyEvent* ke = ( TQKeyEvent* ) e;
		if ( ke->key() == TQt::Key_Tab )
		{
			TQWidget* w = ( TQWidget* ) obj;
			TQWidget::FocusPolicy wfp = w->focusPolicy();
			if ( wfp == TQWidget::StrongFocus || wfp == TQWidget::TabFocus || w->focusPolicy() == TQWidget::WheelFocus )
			{
				if ( m_lastFocusableChildWidget != 0 )
				{
					if ( w == m_lastFocusableChildWidget )
					{
						if ( w != m_firstFocusableChildWidget )
							m_firstFocusableChildWidget->setFocus();
					}
				}
			}
		}
	}
	else if ( e->type() == TQEvent::FocusIn )
	{
		if ( obj->isWidgetType() )
		{
			TQObjectList * list = queryList( "TQWidget" );
			if ( list->find( obj ) != -1 )
				m_focusedChildWidget = ( TQWidget* ) obj;

			delete list;   // delete the list, not the objects
		}
		if ( !isAttached() )
		{   // is toplevel, for attached views activation is done by main frame event filter
			static bool m_bActivationIsPending = false;
			if ( !m_bActivationIsPending )
			{
				m_bActivationIsPending = true;
				activate(); // sets the focus
				m_bActivationIsPending = false;
			}
		}
	}
	else if ( e->type() == TQEvent::ChildRemoved )
	{
		// if we lost a child we uninstall ourself as event filter for the lost
		// child and its children
		TQObject * pLostChild = ( ( TQChildEvent* ) e ) ->child();
		if ( ( pLostChild != 0L ) && ( pLostChild->isWidgetType() ) )
		{
			TQObjectList * list = pLostChild->queryList( "TQWidget" );
			list->insert( 0, pLostChild );        // add the lost child to the list too, just to save code
			TQObjectListIt it( *list );          // iterate over all lost child widgets
			TQObject * o;
			while ( ( o = it.current() ) != 0 )
			{ // for each found object...
				TQWidget * widg = ( TQWidget* ) o;
				++it;
				widg->removeEventFilter( this );
				TQWidget::FocusPolicy wfp = widg->focusPolicy();
				if ( wfp == TQWidget::StrongFocus || wfp == TQWidget::TabFocus || widg->focusPolicy() == TQWidget::WheelFocus )
				{
					if ( m_firstFocusableChildWidget == widg )
						m_firstFocusableChildWidget = 0L;   // reset first widget
					
					if ( m_lastFocusableChildWidget == widg )
						m_lastFocusableChildWidget = 0L;    // reset last widget
				}
			}
			delete list;                        // delete the list, not the objects
		}
	}
	else if ( e->type() == TQEvent::ChildInserted )
	{
		// if we got a new child and we are attached to the MDI system we
		// install ourself as event filter for the new child and its children
		// (as we did when we were added to the MDI system).
		TQObject * pNewChild = ( ( TQChildEvent* ) e ) ->child();
		if ( ( pNewChild != 0L ) && ( pNewChild->isWidgetType() ) )
		{
			TQWidget * pNewWidget = ( TQWidget* ) pNewChild;
			if ( pNewWidget->testWFlags( TQt::WType_Dialog | TQt::WShowModal ) )
				return false;
			TQObjectList *list = pNewWidget->queryList( "TQWidget" );
			list->insert( 0, pNewChild );         // add the new child to the list too, just to save code
			TQObjectListIt it( *list );          // iterate over all new child widgets
			TQObject * o;
			while ( ( o = it.current() ) != 0 )
			{ // for each found object...
				TQWidget * widg = ( TQWidget* ) o;
				++it;
				widg->installEventFilter( this );
				connect( widg, TQT_SIGNAL( destroyed() ), this, TQT_SLOT( slot_childDestroyed() ) );
				TQWidget::FocusPolicy wfp = widg->focusPolicy();
				if ( wfp == TQWidget::StrongFocus || wfp == TQWidget::TabFocus || widg->focusPolicy() == TQWidget::WheelFocus )
				{
					if ( m_firstFocusableChildWidget == 0 )
						m_firstFocusableChildWidget = widg;  // first widge
					
					m_lastFocusableChildWidget = widg; // last widget
				}
			}
			delete list;                        // delete the list, not the objects
		}
	}
	else
	{
		if ( e->type() == TQEvent::IconChange )
		{
			//            tqDebug("KMDiChildView:: TQEvent:IconChange intercepted\n");
			if ( obj == this )
				iconUpdated( this, icon() ? ( *icon() ) : TQPixmap() );
			else if ( obj == m_trackChanges )
				setIcon( m_trackChanges->icon() ? ( *( m_trackChanges->icon() ) ) : TQPixmap() );
		}
		if ( e->type() == TQEvent::CaptionChange )
		{
			if ( obj == this )
				captionUpdated( this, caption() );
		}
	}

	return false;                           // standard event processing
}

/** Switches interposing in event loop of all current child widgets off. */
void KMdiChildView::removeEventFilterForAllChildren()
{
	TQObjectList* list = queryList( "TQWidget" );
	TQObjectListIt it( *list );          // iterate over all child widgets
	TQObject* obj;
	while ( ( obj = it.current() ) != 0 )
	{ // for each found object...
		TQWidget* widg = ( TQWidget* ) obj;
		++it;
		widg->removeEventFilter( this );
	}
	delete list;                        // delete the list, not the objects
}

TQWidget* KMdiChildView::focusedChildWidget()
{
	return m_focusedChildWidget;
}

void KMdiChildView::setFirstFocusableChildWidget( TQWidget* firstFocusableChildWidget )
{
	m_firstFocusableChildWidget = firstFocusableChildWidget;
}

void KMdiChildView::setLastFocusableChildWidget( TQWidget* lastFocusableChildWidget )
{
	m_lastFocusableChildWidget = lastFocusableChildWidget;
}

/** Set a new value of  the task bar button caption  */
void KMdiChildView::setTabCaption ( const TQString& stbCaption )
{
	m_sTabCaption = stbCaption;
	emit tabCaptionChanged( m_sTabCaption );
}

void KMdiChildView::setMDICaption ( const TQString& caption )
{
	setCaption( caption );
	setTabCaption( caption );
}

/** sets an ID  */
void KMdiChildView::setWindowMenuID( int id )
{
	m_windowMenuID = id;
}

//============= slot_clickedInWindowMenu ===============//

/** called if someone click on the "Window" menu item for this child frame window */
void KMdiChildView::slot_clickedInWindowMenu()
{
	updateTimeStamp();
	emit clickedInWindowMenu( m_windowMenuID );
}

//============= slot_clickedInDockMenu ===============//

/** called if someone click on the "Dock/Undock..." menu item for this child frame window */
void KMdiChildView::slot_clickedInDockMenu()
{
	emit clickedInDockMenu( m_windowMenuID );
}

//============= setMinimumSize ===============//

void KMdiChildView::setMinimumSize( int minw, int minh )
{
	TQWidget::setMinimumSize( minw, minh );
	if ( mdiParent() && mdiParent()->state() != KMdiChildFrm::Minimized )
	{
		mdiParent() ->setMinimumSize( minw + KMDI_CHILDFRM_DOUBLE_BORDER,
		                              minh + KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR + mdiParent() ->captionHeight() );
	}
}

//============= setMaximumSize ===============//

void KMdiChildView::setMaximumSize( int maxw, int maxh )
{
	if ( mdiParent() && mdiParent()->state() == KMdiChildFrm::Normal )
	{
		int w = maxw + KMDI_CHILDFRM_DOUBLE_BORDER;
		if ( w > TQWIDGETSIZE_MAX )
			w = TQWIDGETSIZE_MAX;

		int h = maxh + KMDI_CHILDFRM_DOUBLE_BORDER + KMDI_CHILDFRM_SEPARATOR + mdiParent() ->captionHeight();
		if ( h > TQWIDGETSIZE_MAX )
			h = TQWIDGETSIZE_MAX;

		mdiParent()->setMaximumSize( w, h );
	}
	TQWidget::setMaximumSize( maxw, maxh );
}

//============= show ===============//

void KMdiChildView::show()
{
	if ( mdiParent() )
		mdiParent()->show();

	TQWidget::show();
}

//============= hide ===============//

void KMdiChildView::hide()
{
	if ( mdiParent() )
		mdiParent()->hide();
	
	TQWidget::hide();
}

//============= raise ===============//

void KMdiChildView::raise()
{
	if ( mdiParent() )  //TODO Check Z-order
		mdiParent()->raise();

	TQWidget::raise();
}