2007-11-04 03:51:54 +00:00
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
|
|
|
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This file is part of GtkRadiant.
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GtkRadiant; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Z Window
|
|
|
|
//
|
|
|
|
// Leonardo Zide (leo@lokigames.com)
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "zwindow.h"
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// ZWnd class
|
|
|
|
|
|
|
|
ZWnd::ZWnd ()
|
2012-03-17 20:01:54 +00:00
|
|
|
: GLWindow( FALSE ){
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
ZWnd::~ZWnd(){
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ZWnd::OnCreate(){
|
|
|
|
g_qeglobals_gui.d_z = m_pWidget;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !MakeCurrent() ) {
|
|
|
|
Error( "wglMakeCurrent in CZWnd::OnCreate failed" );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ZWnd::OnLButtonDown( guint32 nFlags, int pointx, int pointy ){
|
|
|
|
SetFocus();
|
|
|
|
SetCapture();
|
|
|
|
Z_MouseDown( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ZWnd::OnMButtonDown( guint32 nFlags, int pointx, int pointy ){
|
|
|
|
SetFocus();
|
|
|
|
SetCapture();
|
|
|
|
Z_MouseDown( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ZWnd::OnRButtonDown( guint32 nFlags, int pointx, int pointy ){
|
|
|
|
SetFocus();
|
|
|
|
SetCapture();
|
|
|
|
Z_MouseDown( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ZWnd::OnLButtonUp( guint32 nFlags, int pointx, int pointy ){
|
|
|
|
Z_MouseUp( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
|
|
|
|
ReleaseCapture();
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ZWnd::OnMButtonUp( guint32 nFlags, int pointx, int pointy ){
|
|
|
|
Z_MouseUp( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
|
|
|
|
ReleaseCapture();
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ZWnd::OnRButtonUp( guint32 nFlags, int pointx, int pointy ){
|
|
|
|
Z_MouseUp( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
|
|
|
|
ReleaseCapture();
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ZWnd::OnMouseMove( guint32 nFlags, int pointx, int pointy ){
|
|
|
|
float fz = z.origin[2] + ( ( m_pWidget->allocation.height - 1 - pointy ) - ( z.height / 2 ) ) / z.scale;
|
|
|
|
fz = floor( fz / g_qeglobals.d_gridsize + 0.5 ) * g_qeglobals.d_gridsize;
|
|
|
|
CString strStatus;
|
|
|
|
strStatus.Format( "Z:: %.1f", fz );
|
|
|
|
g_pParentWnd->SetStatusText( 1, strStatus );
|
|
|
|
Z_MouseMoved( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ZWnd::OnExpose(){
|
|
|
|
if ( !MakeCurrent() ) {
|
2016-05-16 19:20:20 +00:00
|
|
|
Sys_FPrintf( SYS_ERR, "ERROR: wglMakeCurrent failed..\n " );
|
2012-03-17 20:01:54 +00:00
|
|
|
Sys_Printf( "Please restart Radiant if the Z view is not working\n" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QE_CheckOpenGLForErrors();
|
|
|
|
Z_Draw();
|
|
|
|
QE_CheckOpenGLForErrors();
|
|
|
|
SwapBuffers();
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ZWnd::OnSize( int cx, int cy ){
|
|
|
|
z.width = cx;
|
|
|
|
z.height = cy;
|
|
|
|
if ( z.width < 10 ) {
|
|
|
|
z.width = 10;
|
|
|
|
}
|
|
|
|
if ( z.height < 10 ) {
|
|
|
|
z.height = 10;
|
|
|
|
}
|
|
|
|
RedrawWindow();
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|