tools/*: remove bcc and as86 as they are no longer required to compile the system...
[virtualbox.git] / src / VBox / Debugger / VBoxDbgGui.cpp
blob46941bf9ccdcf7735d5a63d3651affeed917b78a
1 /* $Id$ */
2 /** @file
3 * VBox Debugger GUI - The Manager.
4 */
6 /*
7 * Copyright (C) 2006-2010 Oracle Corporation
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 /*******************************************************************************
19 * Header Files *
20 *******************************************************************************/
21 #define LOG_GROUP LOG_GROUP_DBGG
22 #define VBOX_COM_NO_ATL
23 #include <VBox/com/defs.h>
24 #include <VBox/vmm/vm.h>
25 #include <VBox/err.h>
27 #include "VBoxDbgGui.h"
28 #include <QDesktopWidget>
29 #include <QApplication>
33 VBoxDbgGui::VBoxDbgGui() :
34 m_pDbgStats(NULL), m_pDbgConsole(NULL), m_pSession(NULL), m_pConsole(NULL),
35 m_pMachineDebugger(NULL), m_pMachine(NULL), m_pVM(NULL),
36 m_pParent(NULL), m_pMenu(NULL),
37 m_x(0), m_y(0), m_cx(0), m_cy(0), m_xDesktop(0), m_yDesktop(0), m_cxDesktop(0), m_cyDesktop(0)
43 int VBoxDbgGui::init(PVM pVM)
46 * Set the VM handle and update the desktop size.
48 m_pVM = pVM;
49 updateDesktopSize();
51 return VINF_SUCCESS;
55 int VBoxDbgGui::init(ISession *pSession)
57 int rc = VERR_GENERAL_FAILURE;
60 * Query the VirtualBox interfaces.
62 m_pSession = pSession;
63 m_pSession->AddRef();
65 HRESULT hrc = m_pSession->COMGETTER(Machine)(&m_pMachine);
66 if (SUCCEEDED(hrc))
68 hrc = m_pSession->COMGETTER(Console)(&m_pConsole);
69 if (SUCCEEDED(hrc))
71 hrc = m_pConsole->COMGETTER(Debugger)(&m_pMachineDebugger);
72 if (SUCCEEDED(hrc))
75 * Get the VM handle.
77 LONG64 llVM;
78 hrc = m_pMachineDebugger->COMGETTER(VM)(&llVM);
79 if (SUCCEEDED(hrc))
81 rc = init((PVM)(intptr_t)llVM);
82 if (RT_SUCCESS(rc))
83 return rc;
86 /* damn, failure! */
87 m_pMachineDebugger->Release();
88 m_pMachineDebugger = NULL;
90 m_pConsole->Release();
91 m_pConsole = NULL;
93 m_pMachine->Release();
94 m_pMachine = NULL;
97 return rc;
101 VBoxDbgGui::~VBoxDbgGui()
103 if (m_pDbgStats)
105 delete m_pDbgStats;
106 m_pDbgStats = NULL;
109 if (m_pDbgConsole)
111 delete m_pDbgConsole;
112 m_pDbgConsole = NULL;
115 if (m_pMachineDebugger)
117 m_pMachineDebugger->Release();
118 m_pMachineDebugger = NULL;
121 if (m_pConsole)
123 m_pConsole->Release();
124 m_pConsole = NULL;
127 if (m_pMachine)
129 m_pMachine->Release();
130 m_pMachine = NULL;
133 if (m_pSession)
135 m_pSession->Release();
136 m_pSession = NULL;
139 m_pVM = NULL;
142 void
143 VBoxDbgGui::setParent(QWidget *pParent)
145 m_pParent = pParent;
149 void
150 VBoxDbgGui::setMenu(QMenu *pMenu)
152 m_pMenu = pMenu;
157 VBoxDbgGui::showStatistics()
159 if (!m_pDbgStats)
161 m_pDbgStats = new VBoxDbgStats(this, "*", 2, m_pParent);
162 connect(m_pDbgStats, SIGNAL(destroyed(QObject *)), this, SLOT(notifyChildDestroyed(QObject *)));
163 repositionStatistics();
166 m_pDbgStats->vShow();
167 return VINF_SUCCESS;
171 void
172 VBoxDbgGui::repositionStatistics(bool fResize/* = true*/)
175 * Move it to the right side of the VBox console,
176 * and resize it to cover all the space to the left side of the desktop.
178 if (m_pDbgStats)
179 m_pDbgStats->vReposition(m_x + m_cx, m_y,
180 m_cxDesktop - m_cx - m_x + m_xDesktop, m_cyDesktop - m_y + m_yDesktop,
181 fResize);
186 VBoxDbgGui::showConsole()
188 if (!m_pDbgConsole)
190 m_pDbgConsole = new VBoxDbgConsole(this, m_pParent);
191 connect(m_pDbgConsole, SIGNAL(destroyed(QObject *)), this, SLOT(notifyChildDestroyed(QObject *)));
192 repositionConsole();
195 m_pDbgConsole->vShow();
196 return VINF_SUCCESS;
200 void
201 VBoxDbgGui::repositionConsole(bool fResize/* = true*/)
204 * Move it to the bottom of the VBox console,
205 * and resize it to cover the space down to the bottom of the desktop.
207 if (m_pDbgConsole)
208 m_pDbgConsole->vReposition(m_x, m_y + m_cy,
209 RT_MAX(m_cx, 32), m_cyDesktop - m_cy - m_y + m_yDesktop,
210 fResize);
214 void
215 VBoxDbgGui::updateDesktopSize()
217 QRect Rct(0, 0, 1600, 1200);
218 QDesktopWidget *pDesktop = QApplication::desktop();
219 if (pDesktop)
220 Rct = pDesktop->availableGeometry(QPoint(m_x, m_y));
221 m_xDesktop = Rct.x();
222 m_yDesktop = Rct.y();
223 m_cxDesktop = Rct.width();
224 m_cyDesktop = Rct.height();
228 void
229 VBoxDbgGui::adjustRelativePos(int x, int y, unsigned cx, unsigned cy)
231 /* Disregard a width less than 640 since it will mess up the console. */
232 if (cx < 640)
233 cx = m_cx;
235 const bool fResize = cx != m_cx || cy != m_cy;
236 const bool fMoved = x != m_x || y != m_y;
238 m_x = x;
239 m_y = y;
240 m_cx = cx;
241 m_cy = cy;
243 if (fMoved)
244 updateDesktopSize();
245 repositionConsole(fResize);
246 repositionStatistics(fResize);
250 void
251 VBoxDbgGui::notifyChildDestroyed(QObject *pObj)
253 if (m_pDbgStats == pObj)
254 m_pDbgStats = NULL;
255 else if (m_pDbgConsole == pObj)
256 m_pDbgConsole = NULL;