28#include "tdemdichildfrmcaption.h"
29#include "tdemdichildfrmcaption.moc"
32#include <tqapplication.h>
34#include <tqtoolbutton.h>
35#include <tqpopupmenu.h>
37#include "tdemdidefines.h"
38#include "tdemdichildfrm.h"
39#include "tdemdichildarea.h"
40#include "tdemdimainfrm.h"
47#ifndef SPI_GETGRADIENTCAPTIONS
48# define SPI_GETGRADIENTCAPTIONS 0x1008
50#ifndef COLOR_GRADIENTACTIVECAPTION
51# define COLOR_GRADIENTACTIVECAPTION 27
53#ifndef COLOR_GRADIENTINACTIVECAPTION
54# define COLOR_GRADIENTINACTIVECAPTION 28
69 : TQWidget( parent,
"tdemdi_childfrmcaption" )
74 setBackgroundMode( NoBackground );
75 setFocusPolicy( TQWidget::NoFocus );
88 if ( e->button() == TQt::LeftButton )
90 setMouseTracking(
false );
93 TQApplication::setOverrideCursor( TQt::sizeAllCursor,
true );
98 else if ( e->button() == TQt::RightButton )
100 m_pParent->systemMenu()->popup( mapToGlobal( e->pos() ) );
108 if ( e->button() == TQt::LeftButton )
111 TQApplication::restoreOverrideCursor();
122 TQApplication::sendEvent(
m_pParent->m_pClient, &ue );
141 TQApplication::sendEvent(
m_pParent->m_pClient, &ue );
146 TQPoint relMousePosInChildArea =
m_pParent->m_pManager->mapFromGlobal( e->globalPos() );
149 if ( !
m_pParent->m_pManager->rect().contains( relMousePosInChildArea ) )
151 if ( relMousePosInChildArea.x() < 0 )
152 relMousePosInChildArea.rx() = 0;
154 if ( relMousePosInChildArea.y() < 0 )
155 relMousePosInChildArea.ry() = 0;
157 if ( relMousePosInChildArea.x() >
m_pParent->m_pManager->width() )
158 relMousePosInChildArea.rx() =
m_pParent->m_pManager->width();
160 if ( relMousePosInChildArea.y() >
m_pParent->m_pManager->height() )
161 relMousePosInChildArea.ry() =
m_pParent->m_pManager->height();
163 TQPoint mousePosInChildArea = relMousePosInChildArea -
m_offset;
166 parentWidget() ->move( mousePosInChildArea );
177 m_pParent->m_pWinIcon->setBackgroundColor( bActive ?
178 m_pParent->m_pManager->m_captionActiveBackColor :
179 m_pParent->m_pManager->m_captionInactiveBackColor );
180 m_pParent->m_pUnixIcon->setBackgroundColor( bActive ?
181 m_pParent->m_pManager->m_captionActiveBackColor :
182 m_pParent->m_pManager->m_captionInactiveBackColor );
200 int hint =
m_pParent->m_pManager->m_captionFontLineSpacing + 3;
231 p.setFont(
m_pParent->m_pManager->m_captionFont );
235 p.fillRect( r,
m_pParent->m_pManager->m_captionActiveBackColor );
236 p.setPen(
m_pParent->m_pManager->m_captionActiveForeColor );
240 p.fillRect( r,
m_pParent->m_pManager->m_captionInactiveBackColor );
241 p.setPen(
m_pParent->m_pManager->m_captionInactiveForeColor );
246 r.setLeft( r.left() +
m_pParent->icon() ->width() + 3 );
248 r.setLeft( r.left() + 22 );
250 r.setLeft( r.left() +
m_pParent->icon() ->width() + 3 );
252 r.setLeft( r.left() + 30 );
254 int captionWidthForText = width() - 4 *
m_pParent->m_pClose->width() -
m_pParent->icon() ->width() - 5;
256 p.drawText( r, AlignVCenter | AlignLeft | SingleLine, text );
263 TQFontMetrics fm = fontMetrics();
264 int actualWidth = fm.width( origStr );
266 int realLetterCount = origStr.length();
269 if ( actualWidth != 0 )
270 newLetterCount = ( maxWidth * realLetterCount ) / actualWidth;
272 newLetterCount = realLetterCount;
274 int w = maxWidth + 1;
275 TQString s = origStr;
277 if ( newLetterCount <= 0 )
280 while ( ( w > maxWidth ) && ( newLetterCount >= 1 ) )
282 if ( newLetterCount < realLetterCount )
284 if ( newLetterCount > 3 )
285 s = origStr.left( newLetterCount / 2 ) +
"..." + origStr.right( newLetterCount / 2 );
288 if ( newLetterCount > 1 )
289 s = origStr.left( newLetterCount ) +
"..";
291 s = origStr.left( 1 );
294 TQFontMetrics fm = fontMetrics();
312 setMouseTracking(
true );
316 TQApplication::setOverrideCursor( TQt::sizeAllCursor,
true );
319 m_offset = mapFromGlobal( TQCursor::pos() );
virtual void mousePressEvent(TQMouseEvent *)
The same as KMdiChildFrmCaption::slot_moveViaSystemMenu.
TQString abbreviateText(TQString origStr, int maxWidth)
Computes a new abbreviated string from a given string depending on a given maximum width.
bool m_bChildInDrag
True if the child knows that it is currently being dragged.
TQString m_szCaption
the title string shown in the caption bar
TQPoint m_offset
the position offset related to its parent widget (internally used for translating mouse move position...
int heightHint()
Returns the caption bar height depending on the used font.
virtual void mouseReleaseEvent(TQMouseEvent *)
Restore the normal mouse cursor, set the state variable back to 'not moving'.
KMdiChildFrmCaption(KMdiChildFrm *parent)
Constructor.
void setCaption(const TQString &text)
Repaint with a new caption bar title.
void setActive(bool bActive)
Repaint the caption bar in active background colors.
~KMdiChildFrmCaption()
Destructor.
virtual void mouseMoveEvent(TQMouseEvent *e)
Checks if out of move range of the KMdiChildArea and calls KMdiChildFrm::move.
virtual void paintEvent(TQPaintEvent *e)
Draws the caption bar and its title using the settings.
void slot_moveViaSystemMenu()
Grabs the mouse, a move cursor, sets a move indicator variable to true and keeps the global mouse pos...
virtual void mouseDoubleClickEvent(TQMouseEvent *)
Calls maximizePressed of the parent widget ( KMdiChildFrm ).
bool m_bActive
state variable indicating whether activated or not activated
KMdiChildFrm * m_pParent
parent widget
a TQCustomEvent for begin of dragging This special event will be useful, to inform view about child f...
a TQCustomEvent for end of dragging This special event will be useful, to inform view about child fra...
static int frameDecorOfAttachedViews()