tdemdichildfrm.h
00001 //---------------------------------------------------------------------------- 00002 // filename : tdemdichildfrm.h 00003 //---------------------------------------------------------------------------- 00004 // Project : KDE MDI extension 00005 // 00006 // begin : 07/1999 by Szymon Stefanek as part of kvirc 00007 // (an IRC application) 00008 // changes : 09/1999 by Falk Brettschneider to create an 00009 // - 06/2000 stand-alone Qt extension set of 00010 // classes and a Qt-based library 00011 // 2000-2003 maintained by the KDevelop project 00012 // patches : */2000 Lars Beikirch (Lars.Beikirch@gmx.net) 00013 // 00014 // copyright : (C) 1999-2003 by Falk Brettschneider 00015 // and 00016 // Szymon Stefanek (stefanek@tin.it) 00017 // email : falkbr@kdevelop.org (Falk Brettschneider) 00018 //---------------------------------------------------------------------------- 00019 // 00020 //---------------------------------------------------------------------------- 00021 // 00022 // This program is free software; you can redistribute it and/or modify 00023 // it under the terms of the GNU Library General Public License as 00024 // published by the Free Software Foundation; either version 2 of the 00025 // License, or (at your option) any later version. 00026 // 00027 //------------------------------------------------------------------------------ 00028 #ifndef _TDEMDI_CHILD_FRM_H_ 00029 #define _TDEMDI_CHILD_FRM_H_ 00030 00031 #include <tqptrlist.h> 00032 #include <tqpixmap.h> 00033 #include <tqpushbutton.h> 00034 #include <tqlabel.h> 00035 #include <tqdatetime.h> 00036 #include <tqlayout.h> 00037 00038 #include <tqdict.h> 00039 00040 #include "tdemdichildfrmcaption.h" 00041 00042 class KMdiChildArea; 00043 class KMdiChildView; 00044 class TQPopupMenu; 00045 class TQToolButton; 00046 00047 //============================================================================== 00052 class KMDI_EXPORT KMdiWin32IconButton : public TQLabel 00053 { 00054 Q_OBJECT 00055 public: 00056 KMdiWin32IconButton( TQWidget* parent, const char* name = 0 ); 00057 virtual void mousePressEvent( TQMouseEvent* ); 00058 00059 signals: 00060 void pressed(); 00061 }; 00062 00063 //============================================================================== 00064 /* some special events, see tdemdidefines.h 00065 */ 00066 //------------------------------------------------------------------------------ 00071 class KMDI_EXPORT KMdiChildFrmMoveEvent : public TQCustomEvent 00072 { 00073 public: 00074 KMdiChildFrmMoveEvent( TQMoveEvent *e ) : TQCustomEvent( TQEvent::Type( TQEvent::User + int( KMdi::EV_Move ) ), e ) {} 00075 00076 }; 00077 00078 //------------------------------------------------------------------------------ 00083 class KMDI_EXPORT KMdiChildFrmDragBeginEvent : public TQCustomEvent 00084 { 00085 public: 00086 KMdiChildFrmDragBeginEvent( TQMouseEvent *e ) : TQCustomEvent( TQEvent::Type( TQEvent::User + int( KMdi::EV_DragBegin ) ), e ) {} 00087 }; 00088 00089 //------------------------------------------------------------------------------ 00094 class KMDI_EXPORT KMdiChildFrmDragEndEvent : public TQCustomEvent 00095 { 00096 public: 00097 KMdiChildFrmDragEndEvent( TQMouseEvent *e ) : TQCustomEvent( TQEvent::Type( TQEvent::User + int( KMdi::EV_DragEnd ) ), e ) {} 00098 }; 00099 00100 //------------------------------------------------------------------------------ 00105 class KMDI_EXPORT KMdiChildFrmResizeBeginEvent : public TQCustomEvent 00106 { 00107 public: 00108 KMdiChildFrmResizeBeginEvent( TQMouseEvent *e ) : TQCustomEvent( TQEvent::Type( TQEvent::User + int( KMdi::EV_ResizeBegin ) ), e ) {} 00109 }; 00110 00111 //------------------------------------------------------------------------------ 00116 class KMDI_EXPORT KMdiChildFrmResizeEndEvent : public TQCustomEvent 00117 { 00118 public: 00119 KMdiChildFrmResizeEndEvent( TQMouseEvent *e ) : TQCustomEvent( TQEvent::Type( TQEvent::User + int( KMdi::EV_ResizeEnd ) ), e ) {} 00120 }; 00121 00122 00123 class KMdiChildFrmPrivate; 00124 //============================================================================== 00129 //------------------------------------------------------------------------------ 00130 class KMDI_EXPORT KMdiChildFrm : public TQFrame 00131 { 00132 friend class KMdiChildArea; 00133 friend class KMdiChildFrmCaption; 00134 00135 Q_OBJECT 00136 00137 // attributes 00138 public: 00139 enum MdiWindowState { Normal, Maximized, Minimized }; 00140 //positions same in h and cpp for fast order check 00141 KMdiChildView* m_pClient; 00142 00143 protected: 00144 KMdiChildArea* m_pManager; 00145 KMdiChildFrmCaption* m_pCaption; 00146 KMdiWin32IconButton* m_pWinIcon; 00147 TQToolButton* m_pUnixIcon; 00148 TQToolButton* m_pMinimize; 00149 TQToolButton* m_pMaximize; 00150 TQToolButton* m_pClose; 00151 TQToolButton* m_pUndock; 00152 MdiWindowState m_state; 00153 TQRect m_restoredRect; 00154 int m_iResizeCorner; 00155 int m_iLastCursorCorner; 00156 bool m_bResizing; 00157 bool m_bDragging; 00158 TQPixmap* m_pIconButtonPixmap; 00159 TQPixmap* m_pMinButtonPixmap; 00160 TQPixmap* m_pMaxButtonPixmap; 00161 TQPixmap* m_pRestoreButtonPixmap; 00162 TQPixmap* m_pCloseButtonPixmap; 00163 TQPixmap* m_pUndockButtonPixmap; 00164 00168 int m_windowMenuID; 00169 00173 TQPopupMenu* m_pSystemMenu; 00174 00175 TQSize m_oldClientMinSize; 00176 TQSize m_oldClientMaxSize; 00177 TQLayout::ResizeMode m_oldLayoutResizeMode; 00178 TQTime m_timeMeasure; 00179 00180 // methods 00181 public: 00182 00186 KMdiChildFrm( KMdiChildArea *parent ); 00187 00192 ~KMdiChildFrm(); 00193 00199 void setClient( KMdiChildView *w, bool bAutomaticResize = false ); 00200 00205 void unsetClient( TQPoint positionOffset = TQPoint( 0, 0 ) ); 00206 00210 void setIcon( const TQPixmap &pxm ); 00211 00215 TQPixmap* icon() const; 00216 00220 void enableClose( bool bEnable ); 00221 00225 void setCaption( const TQString& text ); 00226 00230 const TQString& caption() { return m_pCaption->m_szCaption; } 00231 00235 void setState( MdiWindowState state, bool bAnimate = true ); 00236 00240 inline MdiWindowState state() const { return m_state; } 00241 00245 TQRect mdiAreaContentsRect() const; 00246 00250 TQRect restoreGeometry() const; 00251 00255 void setRestoreGeometry( const TQRect& newRestGeo ); 00256 00261 void updateRects() { resizeEvent( 0 ); } 00262 00266 TQPopupMenu* systemMenu() const; 00267 00271 inline int captionHeight() const { return m_pCaption->height(); } 00272 00276 void redecorateButtons(); 00277 00281 bool isInDrag() const { return m_bDragging; } 00282 00286 bool isInResize() const { return m_bResizing; } 00287 00292 void raiseAndActivate(); 00293 00299 virtual void setMinimumSize ( int minw, int minh ); 00300 00301 public slots: 00302 00303 void slot_resizeViaSystemMenu(); 00304 00305 protected: 00306 00312 virtual void resizeEvent( TQResizeEvent * ); 00313 00319 virtual void mouseMoveEvent( TQMouseEvent *e ); 00320 00326 virtual void mousePressEvent( TQMouseEvent *e ); 00327 00332 virtual void mouseReleaseEvent( TQMouseEvent * ); 00333 00339 virtual void moveEvent( TQMoveEvent* me ); 00340 00344 virtual void leaveEvent( TQEvent * ); 00345 00352 virtual bool eventFilter( TQObject*, TQEvent* ); 00353 00358 void resizeWindow( int resizeCorner, int x, int y ); 00359 00363 void setResizeCursor( int resizeCorner ); 00364 00368 void unsetResizeCursor(); 00369 00374 virtual void switchToMinimizeLayout(); 00375 00379 void doResize(); 00380 00385 void doResize( bool captionOnly ); 00386 00387 protected slots: 00388 00392 void maximizePressed(); 00393 00397 void restorePressed(); 00398 00402 void minimizePressed(); 00403 00407 void closePressed(); 00408 00412 void undockPressed(); 00413 00417 void showSystemMenu(); 00418 00419 protected: 00420 00425 void linkChildren( TQDict<TQ_FocusPolicy>* pFocPolDict ); 00426 00431 TQDict<TQ_FocusPolicy>* unlinkChildren(); 00432 00438 int getResizeCorner( int ax, int ay ); 00439 00440 private: 00441 KMdiChildFrmPrivate *d; 00442 }; 00443 00444 #endif //_TDEMDI_CHILDFRM_H_ 00445 00446 // kate: space-indent off; replace-tabs off; tab-width 4; indent-mode csands;