2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #include "../../idlib/precompiled.h"
32 // TearoffContainerWindow.cpp : implementation file
36 #include "TearoffContainerWindow.h"
39 // CTearoffContainerWindow
41 IMPLEMENT_DYNAMIC(CTearoffContainerWindow, CWnd)
42 CTearoffContainerWindow::CTearoffContainerWindow()
44 m_DragPreviewActive = false;
45 m_ContainedDialog = NULL;
49 CTearoffContainerWindow::~CTearoffContainerWindow()
54 BEGIN_MESSAGE_MAP(CTearoffContainerWindow, CWnd)
55 ON_WM_NCLBUTTONDBLCLK()
62 // CTearoffContainerWindow message handlers
65 void CTearoffContainerWindow::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
67 if ( nHitTest == HTCAPTION )
69 m_DockManager->DockWindow ( m_DialogID , true );
72 CWnd::OnNcLButtonDblClk(nHitTest, point);
76 void CTearoffContainerWindow::SetDialog ( CWnd* dlg , int ID )
79 m_ContainedDialog = dlg;
82 CPoint point (-10 , -10);
83 m_ContainedDialog->GetWindowRect ( rect );
85 rect.OffsetRect(point); //move the window slightly so you can tell it's been popped up
87 //stupid hack to get the window resize itself properly
88 rect.DeflateRect(0,0,0,1);
90 rect.InflateRect(0,0,0,1);
94 void CTearoffContainerWindow::SetDockManager ( CTabsDlg* dlg )
98 void CTearoffContainerWindow::OnClose()
102 //send it back to the docking window (for now at least)
103 m_DockManager->DockWindow ( m_DialogID , true );
108 BOOL CTearoffContainerWindow:: PreTranslateMessage( MSG* pMsg )
110 if ( pMsg->message == WM_NCLBUTTONUP )
113 GetWindowRect ( rect );
115 rect.DeflateRect( 0,0,0,rect.Height() - GetSystemMetrics(SM_CYSMSIZE));
116 if ( m_DockManager->RectWithinDockManager ( rect ))
118 m_DockManager->DockDialog ( m_DialogID , true );
123 return CWnd::PreTranslateMessage(pMsg);
125 void CTearoffContainerWindow::OnSize(UINT nType, int cx, int cy)
127 if ( m_ContainedDialog )
129 m_ContainedDialog->MoveWindow ( 0,0,cx,cy);
132 CWnd::OnSize(nType, cx, cy);
135 void CTearoffContainerWindow::OnDestroy()
139 // TODO: Add your message handler code here
142 void CTearoffContainerWindow::OnSetFocus(CWnd* pOldWnd)
144 CWnd::OnSetFocus(pOldWnd);
145 if ( m_ContainedDialog )
147 m_ContainedDialog->SetFocus();
149 // TODO: Add your message handler code here