summaryrefslogtreecommitdiffstats
path: root/tdemdi/tdemdichildfrmcaption.h
blob: 9ae9f94e68249e46ac9cf4bbae8b3a1a1af4123d (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
//----------------------------------------------------------------------------
//    filename             : tdemdichildfrmcaption.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_FRM_CAPTION_H_
#define _TDEMDI_CHILD_FRM_CAPTION_H_

#include <tqwidget.h>

#include "tdemdidefines.h"

class KMdiChildFrm;


class KMdiChildFrmCaptionPrivate;

/**
* @short Internal class.
*
* It's the caption bar of a child frame widget.
*/
class KMDI_EXPORT KMdiChildFrmCaption : public TQWidget
{
	TQ_OBJECT
public:
	/**
	 * Constructor
	 */
	KMdiChildFrmCaption( KMdiChildFrm *parent );

	/**
	 * Destructor
	 */
	~KMdiChildFrmCaption();

	/**
	 * Repaint the caption bar in active background colors
	 */
	void setActive( bool bActive );

	/**
	 * Repaint with a new caption bar title
	 */
	void setCaption( const TQString& text );

	/**
	 * Returns the caption bar height depending on the used font
	 */
	int heightHint();

public slots:
	/**
	 * Grabs the mouse, a move cursor, sets a move indicator variable to true and keeps the global mouse position in mind
	 */
	void slot_moveViaSystemMenu();

protected:
	/**
	 * Draws the caption bar and its title using the settings
	 */
	virtual void paintEvent( TQPaintEvent *e );

	/**
	 * The same as KMdiChildFrmCaption::slot_moveViaSystemMenu
	 */
	virtual void mousePressEvent( TQMouseEvent * );

	/**
	 * Calls maximizePressed of the parent widget ( KMdiChildFrm )
	 */
	virtual void mouseDoubleClickEvent( TQMouseEvent * );

	/**
	 * Restore the normal mouse cursor, set the state variable back to 'not moving'
	 */
	virtual void mouseReleaseEvent( TQMouseEvent * );

	/**
	 * Checks if out of move range of the KMdiChildArea and calls KMdiChildFrm::move
	 */
	virtual void mouseMoveEvent( TQMouseEvent *e );

	/**
	 * Computes a new abbreviated string from a given string depending on a given maximum width
	 * @todo Replace with a call to a KStringHandler function instead of rolling our own
	 */
	TQString abbreviateText( TQString origStr, int maxWidth );

	// attributes
public:
	/**
	 * the title string shown in the caption bar
	 */
	TQString m_szCaption;

protected:  // Protected attributes
	/**
	 * parent widget
	 */
	KMdiChildFrm *m_pParent;

	/**
	 * state variable indicating whether activated or not activated
	 */
	bool m_bActive;

	/**
	 * the position offset related to its parent widget (internally used for translating mouse move positions
	 */
	TQPoint m_offset;

	/**
	 * True if the child knows that it is currently being dragged.
	 */
	bool m_bChildInDrag;

private:
	KMdiChildFrmCaptionPrivate *d;
};

#endif //_TDEMDI_FRM_CAPTION_H_