]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/zwindow.cpp
error check and bail if permission denied during gamepack install
[xonotic/netradiant.git] / radiant / zwindow.cpp
1 /*
2    Copyright (C) 1999-2007 id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 //
23 // Z Window
24 //
25 // Leonardo Zide (leo@lokigames.com)
26 //
27
28 #include "stdafx.h"
29 #include "zwindow.h"
30
31 // =============================================================================
32 // ZWnd class
33
34 ZWnd::ZWnd ()
35         : GLWindow( FALSE ){
36 }
37
38 ZWnd::~ZWnd(){
39 }
40
41 void ZWnd::OnCreate(){
42         g_qeglobals_gui.d_z = m_pWidget;
43
44         if ( !MakeCurrent() ) {
45                 Error( "wglMakeCurrent in CZWnd::OnCreate failed" );
46         }
47 }
48
49 void ZWnd::OnLButtonDown( guint32 nFlags, int pointx, int pointy ){
50         SetFocus();
51         SetCapture();
52         Z_MouseDown( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
53 }
54
55 void ZWnd::OnMButtonDown( guint32 nFlags, int pointx, int pointy ){
56         SetFocus();
57         SetCapture();
58         Z_MouseDown( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
59 }
60
61 void ZWnd::OnRButtonDown( guint32 nFlags, int pointx, int pointy ){
62         SetFocus();
63         SetCapture();
64         Z_MouseDown( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
65 }
66
67 void ZWnd::OnLButtonUp( guint32 nFlags, int pointx, int pointy ){
68         Z_MouseUp( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
69         ReleaseCapture();
70 }
71
72 void ZWnd::OnMButtonUp( guint32 nFlags, int pointx, int pointy ){
73         Z_MouseUp( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
74         ReleaseCapture();
75 }
76
77 void ZWnd::OnRButtonUp( guint32 nFlags, int pointx, int pointy ){
78         Z_MouseUp( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
79         ReleaseCapture();
80 }
81
82 void ZWnd::OnMouseMove( guint32 nFlags, int pointx, int pointy ){
83         float fz = z.origin[2] + ( ( m_pWidget->allocation.height - 1 - pointy ) - ( z.height / 2 ) ) / z.scale;
84         fz = floor( fz / g_qeglobals.d_gridsize + 0.5 ) * g_qeglobals.d_gridsize;
85         CString strStatus;
86         strStatus.Format( "Z:: %.1f", fz );
87         g_pParentWnd->SetStatusText( 1, strStatus );
88         Z_MouseMoved( pointx, m_pWidget->allocation.height - 1 - pointy, nFlags );
89 }
90
91 void ZWnd::OnExpose(){
92         if ( !MakeCurrent() ) {
93                 Sys_Printf( "ERROR: wglMakeCurrent failed..\n " );
94                 Sys_Printf( "Please restart Radiant if the Z view is not working\n" );
95         }
96         else
97         {
98                 QE_CheckOpenGLForErrors();
99                 Z_Draw();
100                 QE_CheckOpenGLForErrors();
101                 SwapBuffers();
102         }
103 }
104
105 void ZWnd::OnSize( int cx, int cy ){
106         z.width = cx;
107         z.height = cy;
108         if ( z.width < 10 ) {
109                 z.width = 10;
110         }
111         if ( z.height < 10 ) {
112                 z.height = 10;
113         }
114         RedrawWindow();
115 }