]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/glwindow.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / radiant / glwindow.h
1 /*\r
2 Copyright (c) 2001, Loki software, inc.\r
3 All rights reserved.\r
4 \r
5 Redistribution and use in source and binary forms, with or without modification, \r
6 are permitted provided that the following conditions are met:\r
7 \r
8 Redistributions of source code must retain the above copyright notice, this list \r
9 of conditions and the following disclaimer.\r
10 \r
11 Redistributions in binary form must reproduce the above copyright notice, this\r
12 list of conditions and the following disclaimer in the documentation and/or\r
13 other materials provided with the distribution.\r
14 \r
15 Neither the name of Loki software nor the names of its contributors may be used \r
16 to endorse or promote products derived from this software without specific prior \r
17 written permission. \r
18 \r
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' \r
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \r
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE \r
22 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY \r
23 DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \r
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS \r
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
29 */\r
30 \r
31 #ifndef _GLWINDOW_H_\r
32 #define _GLWINDOW_H_\r
33 \r
34 class GLWindow\r
35 {\r
36  public:\r
37   GLWindow (bool zbuffer);\r
38   virtual ~GLWindow ();\r
39 \r
40   bool MakeCurrent ();\r
41   void SwapBuffers ();\r
42   void SetTimer (guint millisec);\r
43   void KillTimer ();\r
44   bool HasTimer ()\r
45     { return m_nTimer != 0; }\r
46   void DestroyContext ();\r
47   void CreateContext ();\r
48 \r
49   virtual void OnCreate () { }\r
50   virtual void OnExpose () { }\r
51 \r
52   virtual void OnLButtonDown (guint32 flags, int x, int y) { }\r
53   virtual void OnRButtonDown (guint32 flags, int x, int y) { }\r
54   virtual void OnMButtonDown (guint32 flags, int x, int y) { }\r
55   virtual void OnLButtonUp (guint32 flags, int pointx, int pointy) { }\r
56   virtual void OnRButtonUp (guint32 flags, int pointx, int pointy) { }\r
57   virtual void OnMButtonUp (guint32 flags, int pointx, int pointy) { }\r
58   virtual void OnMouseMove (guint32 flags, int pointx, int pointy) { }\r
59 \r
60   \r
61   virtual void OnSize (int cx, int cy) { }\r
62   virtual void OnTimer () { }\r
63 \r
64   virtual void OnMouseWheel (bool bUp) { }\r
65 \r
66   void RedrawWindow ()\r
67   {\r
68     gtk_widget_queue_draw(m_pWidget);\r
69   }\r
70 \r
71   void SetFocus ()\r
72   {\r
73     /* gdk_window_raise (m_pWidget->window); */\r
74   }\r
75 \r
76   void SetCapture ()\r
77   {\r
78     m_bMouseCapture = TRUE;\r
79   }\r
80 \r
81   void ReleaseCapture ()\r
82   {\r
83     m_bMouseCapture = FALSE;\r
84   }\r
85 \r
86   bool HasCapture ()\r
87   {\r
88     return m_bMouseCapture;\r
89   }\r
90 \r
91   GtkWidget* GetWidget ()\r
92   {\r
93     return m_pWidget;\r
94   }\r
95 \r
96   // member variables\r
97  public:\r
98   GtkWidget* m_pParent; // for floating windows only\r
99 \r
100  protected:\r
101   bool       m_bMouseCapture;\r
102   GtkWidget* m_pWidget;\r
103 \r
104  private:\r
105   guint      m_nTimer; // only one timer supported\r
106 };\r
107 \r
108 #endif //_GLWINDOW_H_\r