You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
447 lines
13 KiB
447 lines
13 KiB
15 years ago
|
//----------------------------------------------------------------------------
|
||
12 years ago
|
// filename : tdemdichildfrm.h
|
||
15 years ago
|
//----------------------------------------------------------------------------
|
||
|
// 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
|
||
|
// patches : */2000 Lars Beikirch (Lars.Beikirch@gmx.net)
|
||
|
//
|
||
|
// copyright : (C) 1999-2003 by Falk Brettschneider
|
||
|
// and
|
||
|
// Szymon Stefanek (stefanek@tin.it)
|
||
13 years ago
|
// email : falkbr@tdevelop.org (Falk Brettschneider)
|
||
15 years ago
|
//----------------------------------------------------------------------------
|
||
|
//
|
||
|
//----------------------------------------------------------------------------
|
||
|
//
|
||
|
// 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 _KMDI_CHILD_FRM_H_
|
||
|
#define _KMDI_CHILD_FRM_H_
|
||
|
|
||
15 years ago
|
#include <tqptrlist.h>
|
||
|
#include <tqpixmap.h>
|
||
|
#include <tqpushbutton.h>
|
||
|
#include <tqlabel.h>
|
||
|
#include <tqdatetime.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
|
||
15 years ago
|
#include <tqdict.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include "tdemdichildfrmcaption.h"
|
||
15 years ago
|
|
||
|
class KMdiChildArea;
|
||
|
class KMdiChildView;
|
||
15 years ago
|
class TQPopupMenu;
|
||
|
class TQToolButton;
|
||
15 years ago
|
|
||
|
//==============================================================================
|
||
|
/**
|
||
|
* @short Internal class, only used on Win32.
|
||
|
* This class provides a label widget that can process mouse click events.
|
||
|
*/
|
||
14 years ago
|
class KMDI_EXPORT KMdiWin32IconButton : public TQLabel
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
15 years ago
|
KMdiWin32IconButton( TQWidget* parent, const char* name = 0 );
|
||
|
virtual void mousePressEvent( TQMouseEvent* );
|
||
15 years ago
|
|
||
|
signals:
|
||
|
void pressed();
|
||
|
};
|
||
|
|
||
|
//==============================================================================
|
||
12 years ago
|
/* some special events, see tdemdidefines.h
|
||
15 years ago
|
*/
|
||
|
//------------------------------------------------------------------------------
|
||
|
/**
|
||
15 years ago
|
* @short a TQCustomEvent for move
|
||
15 years ago
|
* This special event will be useful, to inform view about child frame event.
|
||
|
*/
|
||
14 years ago
|
class KMDI_EXPORT KMdiChildFrmMoveEvent : public TQCustomEvent
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
KMdiChildFrmMoveEvent( TQMoveEvent *e ) : TQCustomEvent( TQEvent::Type( TQEvent::User + int( KMdi::EV_Move ) ), e ) {}
|
||
15 years ago
|
|
||
|
};
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
/**
|
||
15 years ago
|
* @short a TQCustomEvent for begin of dragging
|
||
15 years ago
|
* This special event will be useful, to inform view about child frame event.
|
||
|
*/
|
||
14 years ago
|
class KMDI_EXPORT KMdiChildFrmDragBeginEvent : public TQCustomEvent
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
KMdiChildFrmDragBeginEvent( TQMouseEvent *e ) : TQCustomEvent( TQEvent::Type( TQEvent::User + int( KMdi::EV_DragBegin ) ), e ) {}
|
||
15 years ago
|
};
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
/**
|
||
15 years ago
|
* @short a TQCustomEvent for end of dragging
|
||
15 years ago
|
* This special event will be useful, to inform view about child frame event.
|
||
|
*/
|
||
14 years ago
|
class KMDI_EXPORT KMdiChildFrmDragEndEvent : public TQCustomEvent
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
KMdiChildFrmDragEndEvent( TQMouseEvent *e ) : TQCustomEvent( TQEvent::Type( TQEvent::User + int( KMdi::EV_DragEnd ) ), e ) {}
|
||
15 years ago
|
};
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
/**
|
||
15 years ago
|
* @short a TQCustomEvent for begin of resizing
|
||
15 years ago
|
* This special event will be useful, to inform view about child frame event.
|
||
|
*/
|
||
14 years ago
|
class KMDI_EXPORT KMdiChildFrmResizeBeginEvent : public TQCustomEvent
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
KMdiChildFrmResizeBeginEvent( TQMouseEvent *e ) : TQCustomEvent( TQEvent::Type( TQEvent::User + int( KMdi::EV_ResizeBegin ) ), e ) {}
|
||
15 years ago
|
};
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
/**
|
||
15 years ago
|
* @short a TQCustomEvent for end of resizing
|
||
15 years ago
|
* This special event will be useful, to inform view about child frame event.
|
||
|
*/
|
||
14 years ago
|
class KMDI_EXPORT KMdiChildFrmResizeEndEvent : public TQCustomEvent
|
||
15 years ago
|
{
|
||
|
public:
|
||
15 years ago
|
KMdiChildFrmResizeEndEvent( TQMouseEvent *e ) : TQCustomEvent( TQEvent::Type( TQEvent::User + int( KMdi::EV_ResizeEnd ) ), e ) {}
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
class KMdiChildFrmPrivate;
|
||
|
//==============================================================================
|
||
|
/**
|
||
|
* @short Internal class.
|
||
14 years ago
|
* It's an MDI child frame widget. It contains a view widget and a frame caption. Usually you derive from its view.
|
||
15 years ago
|
*/
|
||
|
//------------------------------------------------------------------------------
|
||
14 years ago
|
class KMDI_EXPORT KMdiChildFrm : public TQFrame
|
||
15 years ago
|
{
|
||
|
friend class KMdiChildArea;
|
||
|
friend class KMdiChildFrmCaption;
|
||
|
|
||
|
Q_OBJECT
|
||
|
|
||
|
// attributes
|
||
|
public:
|
||
|
enum MdiWindowState { Normal, Maximized, Minimized };
|
||
|
//positions same in h and cpp for fast order check
|
||
|
KMdiChildView* m_pClient;
|
||
|
|
||
|
protected:
|
||
|
KMdiChildArea* m_pManager;
|
||
|
KMdiChildFrmCaption* m_pCaption;
|
||
|
KMdiWin32IconButton* m_pWinIcon;
|
||
15 years ago
|
TQToolButton* m_pUnixIcon;
|
||
|
TQToolButton* m_pMinimize;
|
||
|
TQToolButton* m_pMaximize;
|
||
|
TQToolButton* m_pClose;
|
||
|
TQToolButton* m_pUndock;
|
||
15 years ago
|
MdiWindowState m_state;
|
||
15 years ago
|
TQRect m_restoredRect;
|
||
15 years ago
|
int m_iResizeCorner;
|
||
|
int m_iLastCursorCorner;
|
||
|
bool m_bResizing;
|
||
|
bool m_bDragging;
|
||
15 years ago
|
TQPixmap* m_pIconButtonPixmap;
|
||
|
TQPixmap* m_pMinButtonPixmap;
|
||
|
TQPixmap* m_pMaxButtonPixmap;
|
||
|
TQPixmap* m_pRestoreButtonPixmap;
|
||
|
TQPixmap* m_pCloseButtonPixmap;
|
||
|
TQPixmap* m_pUndockButtonPixmap;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Every child frame window has an temporary ID in the Window menu of the child area.
|
||
|
*/
|
||
|
int m_windowMenuID;
|
||
|
|
||
|
/**
|
||
|
* Imitates a system menu for child frame windows
|
||
|
*/
|
||
15 years ago
|
TQPopupMenu* m_pSystemMenu;
|
||
15 years ago
|
|
||
15 years ago
|
TQSize m_oldClientMinSize;
|
||
|
TQSize m_oldClientMaxSize;
|
||
|
TQLayout::ResizeMode m_oldLayoutResizeMode;
|
||
|
TQTime m_timeMeasure;
|
||
15 years ago
|
|
||
|
// methods
|
||
|
public:
|
||
|
|
||
|
/**
|
||
|
* Creates a new KMdiChildFrm class.
|
||
|
*/
|
||
|
KMdiChildFrm( KMdiChildArea *parent );
|
||
|
|
||
|
/**
|
||
|
* Destroys this KMdiChildFrm
|
||
|
* If a child is still here managed (no recreation was made) it is destroyed too.
|
||
|
*/
|
||
|
~KMdiChildFrm();
|
||
|
|
||
|
/**
|
||
|
* Reparents the widget w to this KMdiChildFrm (if this is not already done)
|
||
|
* Installs an event filter to catch focus events.
|
||
|
* Resizes this mdi child in a way that the child fits perfectly in.
|
||
|
*/
|
||
|
void setClient( KMdiChildView *w, bool bAutomaticResize = false );
|
||
|
|
||
|
/**
|
||
|
* Reparents the client widget to 0 (desktop), moves with an offset from the original position
|
||
|
* Removes the event filter.
|
||
|
*/
|
||
15 years ago
|
void unsetClient( TQPoint positionOffset = TQPoint( 0, 0 ) );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Sets the window icon pointer.
|
||
|
*/
|
||
15 years ago
|
void setIcon( const TQPixmap &pxm );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the child frame icon.
|
||
|
*/
|
||
15 years ago
|
TQPixmap* icon() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Enables or disables the close button
|
||
|
*/
|
||
|
void enableClose( bool bEnable );
|
||
|
|
||
|
/**
|
||
|
* Sets the caption of this window
|
||
|
*/
|
||
15 years ago
|
void setCaption( const TQString& text );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Gets the caption of this mdi child.
|
||
|
*/
|
||
15 years ago
|
const TQString& caption() { return m_pCaption->m_szCaption; }
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Minimizes, Maximizes, or restores the window.
|
||
|
*/
|
||
|
void setState( MdiWindowState state, bool bAnimate = true );
|
||
|
|
||
|
/**
|
||
|
* Returns the current state of the window
|
||
|
*/
|
||
|
inline MdiWindowState state() const { return m_state; }
|
||
|
|
||
|
/**
|
||
|
* Returns the inner client area of the parent of this (which is KMdiChildArea).
|
||
|
*/
|
||
15 years ago
|
TQRect mdiAreaContentsRect() const;
|
||
15 years ago
|
|
||
|
/**
|
||
14 years ago
|
* Returns the geometry that will be restored by calling restore().
|
||
15 years ago
|
*/
|
||
15 years ago
|
TQRect restoreGeometry() const;
|
||
15 years ago
|
|
||
|
/**
|
||
14 years ago
|
* Sets the geometry that will be restored by calling restore().
|
||
15 years ago
|
*/
|
||
15 years ago
|
void setRestoreGeometry( const TQRect& newRestGeo );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Forces updating the rects of the caption and so...
|
||
|
* It may be useful when setting the mdiCaptionFont of the MdiManager
|
||
|
*/
|
||
|
void updateRects() { resizeEvent( 0 ); }
|
||
|
|
||
|
/**
|
||
|
* Returns the system menu.
|
||
|
*/
|
||
15 years ago
|
TQPopupMenu* systemMenu() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the caption bar height
|
||
|
*/
|
||
|
inline int captionHeight() const { return m_pCaption->height(); }
|
||
|
|
||
|
/**
|
||
|
* sets new raise behavior and pixmaps of the buttons depending on the current decoration style
|
||
|
*/
|
||
|
void redecorateButtons();
|
||
|
|
||
|
/**
|
||
|
* returns the mouse state "In Drag"
|
||
|
*/
|
||
|
bool isInDrag() const { return m_bDragging; }
|
||
|
|
||
|
/**
|
||
|
* returns the mouse state "In Resize"
|
||
|
*/
|
||
|
bool isInResize() const { return m_bResizing; }
|
||
|
|
||
|
/**
|
||
|
* Internally called from the signal focusInEventOccurs.
|
||
|
* It raises the MDI childframe to the top of all other MDI child frames and sets the focus on it.
|
||
|
*/
|
||
|
void raiseAndActivate();
|
||
|
|
||
|
/**
|
||
|
* Sets the minimum size of the widget to w by h pixels.
|
||
|
* It extends it's base clase method in a way that the minimum size of
|
||
|
* the child area will be set additionally if the view is maximized.
|
||
|
*/
|
||
|
virtual void setMinimumSize ( int minw, int minh );
|
||
|
|
||
|
public slots:
|
||
|
|
||
|
void slot_resizeViaSystemMenu();
|
||
|
|
||
|
protected:
|
||
|
|
||
|
/**
|
||
|
* Reimplemented from the base class.
|
||
14 years ago
|
* Resizes the captionbar, relayouts the position of the system buttons,
|
||
15 years ago
|
* and calls resize for its embedded KMdiChildView with the proper size
|
||
|
*/
|
||
15 years ago
|
virtual void resizeEvent( TQResizeEvent * );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Reimplemented from the base class.
|
||
|
* Detects if the mouse is on the edge of window and what resize cursor must be set.
|
||
|
* Calls KMdiChildFrm::resizeWindow if it is in m_bResizing.
|
||
|
*/
|
||
15 years ago
|
virtual void mouseMoveEvent( TQMouseEvent *e );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Reimplemented from the base class.
|
||
|
* Colours the caption, raises the childfrm widget and
|
||
|
* turns to resize mode if it is on the edge (resize-sensitive area)
|
||
|
*/
|
||
15 years ago
|
virtual void mousePressEvent( TQMouseEvent *e );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Reimplemented from the base class.
|
||
|
* Sets a normal cursor and leaves the resize mode.
|
||
|
*/
|
||
15 years ago
|
virtual void mouseReleaseEvent( TQMouseEvent * );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Reimplemented from the base class.
|
||
|
* give its child view the chance to notify a childframe move... that's why it sends
|
||
|
* a KMdiChildMovedEvent to the embedded KMdiChildView .
|
||
|
*/
|
||
15 years ago
|
virtual void moveEvent( TQMoveEvent* me );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Reimplemented from the base class. If not in resize mode, it sets the mouse cursor to normal appearance.
|
||
|
*/
|
||
15 years ago
|
virtual void leaveEvent( TQEvent * );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Reimplemented from the base class.
|
||
|
* In addition, the following are caught
|
||
|
* -the client's mousebutton press events which raises and activates the childframe
|
||
|
* -the client's resize event which resizes this widget as well
|
||
|
*/
|
||
15 years ago
|
virtual bool eventFilter( TQObject*, TQEvent* );
|
||
15 years ago
|
|
||
|
/**
|
||
14 years ago
|
* Calculates the new geometry from the new mouse position given as parameters
|
||
15 years ago
|
* and calls KMdiChildFrm::setGeometry
|
||
|
*/
|
||
|
void resizeWindow( int resizeCorner, int x, int y );
|
||
|
|
||
|
/**
|
||
|
* Override the cursor appearance depending on the widget corner given as parameter
|
||
|
*/
|
||
|
void setResizeCursor( int resizeCorner );
|
||
|
|
||
|
/**
|
||
|
* Changes from the resize cursor to the normal (previous) cursor
|
||
|
*/
|
||
|
void unsetResizeCursor();
|
||
|
|
||
|
/**
|
||
|
* That means to show a mini window showing the childframe's caption bar, only.
|
||
|
* It cannot be resized.
|
||
|
*/
|
||
|
virtual void switchToMinimizeLayout();
|
||
|
|
||
|
/**
|
||
|
* Does the actual resize. Called from various places but from resizeEvent in general.
|
||
|
*/
|
||
|
void doResize();
|
||
|
|
||
|
/**
|
||
|
* Does the actual resize, like doResize() but skips resize of the client if \a captionOnly is true.
|
||
|
* @todo: merge with doResize()
|
||
|
*/
|
||
|
void doResize( bool captionOnly );
|
||
|
|
||
|
protected slots:
|
||
|
|
||
|
/**
|
||
|
* Handles a click on the Maximize button
|
||
|
*/
|
||
|
void maximizePressed();
|
||
|
|
||
|
/**
|
||
|
* Handles a click on the Restore (Normalize) button
|
||
|
*/
|
||
|
void restorePressed();
|
||
|
|
||
|
/**
|
||
|
* Handles a click on the Minimize button.
|
||
|
*/
|
||
|
void minimizePressed();
|
||
|
|
||
|
/**
|
||
|
* Handles a click on the Close button.
|
||
|
*/
|
||
|
void closePressed();
|
||
|
|
||
|
/**
|
||
|
* Handles a click on the Undock (Detach) button
|
||
|
*/
|
||
|
void undockPressed();
|
||
|
|
||
|
/**
|
||
|
* Shows a system menu for child frame windows.
|
||
|
*/
|
||
|
void showSystemMenu();
|
||
|
|
||
|
protected:
|
||
|
|
||
|
/**
|
||
|
* Restore the focus policies for _all_ widgets in the view using the list given as parameter.
|
||
|
* Install the event filter for all direct child widgets of this. (See KMdiChildFrm::eventFilter)
|
||
|
*/
|
||
14 years ago
|
void linkChildren( TQDict<TQ_FocusPolicy>* pFocPolDict );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Backups all focus policies of _all_ child widgets in the MDI childview since they get lost during a reparent.
|
||
|
* Remove all event filters for all direct child widgets of this. (See KMdiChildFrm::eventFilter)
|
||
|
*/
|
||
14 years ago
|
TQDict<TQ_FocusPolicy>* unlinkChildren();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Calculates the corner id for the resize cursor. The return value can be tested for:
|
||
|
* KMDI_RESIZE_LEFT, KMDI_RESIZE_RIGHT, KMDI_RESIZE_TOP, KMDI_RESIZE_BOTTOM
|
||
|
* or an OR'd variant of them for the corners.
|
||
|
*/
|
||
|
int getResizeCorner( int ax, int ay );
|
||
|
|
||
|
private:
|
||
|
KMdiChildFrmPrivate *d;
|
||
|
};
|
||
|
|
||
|
#endif //_KMDICHILDFRM_H_
|
||
|
|
||
14 years ago
|
// kate: space-indent off; replace-tabs off; tab-width 4; indent-mode csands;
|