]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/xywindow.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / radiant / xywindow.h
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \r
7 GtkRadiant is free software; you can redistribute it and/or modify\r
8 it under the terms of the GNU General Public License as published by\r
9 the Free Software Foundation; either version 2 of the License, or\r
10 (at your option) any later version.\r
11 \r
12 GtkRadiant is distributed in the hope that it will be useful,\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 GNU General Public License for more details.\r
16 \r
17 You should have received a copy of the GNU General Public License\r
18 along with GtkRadiant; if not, write to the Free Software\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
20 */\r
21 \r
22 #ifndef _XYWINDOW_H_\r
23 #define _XYWINDOW_H_\r
24 \r
25 #include "qe3.h"\r
26 #include "camwindow.h"\r
27 #include "glwindow.h"\r
28 \r
29 const int SCALE_X = 0x01;\r
30 const int SCALE_Y = 0x02;\r
31 const int SCALE_Z = 0x04;\r
32 \r
33 typedef void (PFNPathCallback)(bool, int);\r
34 // as i didn't really encapsulate anything this\r
35 // should really be a struct..\r
36 class ClipPoint\r
37 {\r
38 public:\r
39   ClipPoint(){ Reset(); };\r
40   void Reset(){ m_ptClip[0] = m_ptClip[1] = m_ptClip[2] = 0.0; m_bSet = false; m_pVec3 = NULL;};\r
41   bool Set(){ return m_bSet; };\r
42   void Set(bool b) { m_bSet = b; };\r
43   void UpdatePointPtr() { if (m_pVec3) VectorCopy(m_ptClip, *m_pVec3); };\r
44   void SetPointPtr(vec3_t* p) { m_pVec3 = p; };\r
45   vec3_t m_ptClip;      // the 3d point\r
46   vec3_t* m_pVec3;      // optional ptr for 3rd party updates\r
47   int m_ptScreenX, m_ptScreenY;    // the onscreen xy point (for mousability)\r
48   bool m_bSet;\r
49   operator vec3_t&() {return m_ptClip;};\r
50   operator vec3_t*() {return &m_ptClip;};\r
51   \r
52   /*! Draw clip/path point with rasterized number label */\r
53   void Draw(float fScale, int num);\r
54   /*! Draw clip/path point with rasterized string label */\r
55   void Draw(float fScale, const char *label);\r
56 };\r
57 \r
58 class XYWnd : public GLWindow\r
59 {\r
60 public:\r
61   XYWnd();\r
62   virtual ~XYWnd() { }\r
63 \r
64 public:\r
65   bool AreaSelectOK();\r
66   vec3_t& RotateOrigin();\r
67   vec3_t& Rotation();\r
68   void UndoClear();\r
69   bool UndoAvailable();\r
70   void KillPathMode();\r
71   void Undo();\r
72   void UndoCopy();\r
73   void Copy();\r
74   void Paste();\r
75   void Redraw(unsigned int nBits);\r
76   void VectorCopyXY(vec3_t in, vec3_t out);\r
77   void PositionView();\r
78   void FlipClip();\r
79   void SplitClip();\r
80   void Clip();\r
81   vec3_t& GetOrigin();\r
82   void SetOrigin(vec3_t org);           // PGM\r
83   void XY_Init();\r
84   void XY_Overlay();\r
85   void XY_Draw();\r
86   void DrawZIcon();\r
87   void DrawRotateIcon();\r
88   void DrawCameraIcon();\r
89   void XY_DrawBlockGrid();\r
90   void XY_DrawGrid();\r
91   void XY_MouseMoved (int x, int y, int buttons);\r
92 // TTimo: FIXME: was experimental stuff to track possible endless loop issues\r
93 //  void XY_MouseMovedRec (int x, int y, int buttons);\r
94   void NewBrushDrag (int x, int y);\r
95   qboolean DragDelta (int x, int y, vec3_t move);\r
96   void XY_MouseUp(int x, int y, int buttons);\r
97   void XY_MouseDown (int x, int y, int buttons);\r
98   void XY_ToGridPoint (int x, int y, vec3_t point);\r
99   void XY_ToPoint (int x, int y, vec3_t point);\r
100   void SnapToPoint (int x, int y, vec3_t point);\r
101   void SetActive(bool b) {m_bActive = b;};\r
102   bool Active() {return m_bActive;};\r
103 \r
104   void DropClipPoint(guint32 nFlags, int pointx, int pointy);\r
105   bool RogueClipMode();\r
106   bool ClipMode();\r
107   void SetClipMode(bool bMode);\r
108   void RetainClipMode(bool bMode);\r
109 \r
110   bool RotateMode();\r
111   bool SetRotateMode(bool bMode);\r
112   bool ScaleMode();\r
113   void SetScaleMode(bool bMode);\r
114 \r
115   bool PathMode();\r
116   void DropPathPoint(guint32 nFlags, int pointx, int pointy);\r
117   bool PointMode();\r
118 //  void AddPointPoint(guint32 nFlags, vec3_t* pVec);\r
119   void SetPointMode(bool b);\r
120 \r
121   void SetViewType(int n);\r
122   bool m_bActive;\r
123 \r
124 protected:\r
125   int m_nUpdateBits;\r
126   int m_nWidth;\r
127   int m_nHeight;\r
128   bool m_bTiming;\r
129   float m_fScale;\r
130   float m_TopClip;\r
131   float m_BottomClip;\r
132   bool m_bDirty;\r
133   vec3_t m_vOrigin;\r
134 \r
135   int m_ptCursorX, m_ptCursorY;\r
136   bool m_bRButtonDown;\r
137 \r
138   int m_nButtonstate;\r
139   int m_nPressx;\r
140   int m_nPressy;\r
141   vec3_t m_vPressdelta;\r
142   bool m_bPress_selection;\r
143 \r
144   friend class CamWnd;\r
145 \r
146 private:\r
147   // this is unique for all views\r
148   static GtkWidget* m_mnuDrop;\r
149 \r
150   int m_nViewType;\r
151 \r
152   int m_nScrollFlags;\r
153   int m_ptDragX, m_ptDragY;\r
154   int m_ptDragAdjX, m_ptDragAdjY;\r
155   int m_ptDragTotalX, m_ptDragTotalY;\r
156 \r
157   void OriginalButtonUp(guint32 nFlags, int point, int pointy);\r
158   void OriginalButtonDown(guint32 nFlags, int point, int pointy);\r
159 //  void ProduceSplits(brush_t** pFront, brush_t** pBack);\r
160   void PlanePointsFromClipPoints(vec3_t planepts[3], brush_t *pBrush);\r
161   void ProduceSplitLists();\r
162   void HandleDrop();\r
163   void PaintSizeInfo(int nDim1, int nDim2, vec3_t vMinBounds, vec3_t vMaxBounds);\r
164 \r
165   int m_ptDownX, m_ptDownY;\r
166 \r
167 public:\r
168   void OnEntityCreate(const char* item);\r
169   int GetViewType() {return m_nViewType; }\r
170   void SetScale(float f) {m_fScale = f;}\r
171   float Scale() {return m_fScale;}\r
172   int Width() {return m_nWidth;}\r
173   int Height() {return m_nHeight;}\r
174 \r
175 protected:\r
176 \r
177   void OnCreate ();\r
178   void OnExpose ();\r
179   void OnLButtonDown(guint32 flags, int pointx, int pointy);\r
180   void OnRButtonDown(guint32 flags, int pointx, int pointy);\r
181   void OnMButtonDown(guint32 flags, int pointx, int pointy);\r
182   void OnLButtonUp(guint32 flags, int pointx, int pointy);\r
183   void OnRButtonUp(guint32 flags, int pointx, int pointy);\r
184   void OnMButtonUp(guint32 flags, int pointx, int pointy);\r
185   void OnMouseMove(guint32 nFlags, int pointx, int pointy);\r
186   void OnMouseWheel(bool bUp);\r
187   void OnSize (int cx, int cy);\r
188   void OnTimer();\r
189 \r
190 private:\r
191   XORRectangle m_XORRectangle;\r
192 };\r
193 \r
194 #endif // _XYWINDOW_H_\r