]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - include/iui.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / include / iui.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 //-----------------------------------------------------------------------------\r
23 //\r
24 // DESCRIPTION:\r
25 // interface for all-purpose messaging and UI\r
26 // window class for MFC, Gtk or Q3 UI\r
27 // each version of Radiant implements the API, using the native code that it needs\r
28 \r
29 #ifndef __IUI_H_\r
30 #define __IUI_H_\r
31 \r
32 // this one can be hooked in the GL window procs for customizing GUI through plugins\r
33 // the class is implemented by the plugin module, and given to Radiant who calls into it\r
34 class IWindowListener\r
35 {\r
36 public:\r
37   // Increment the number of references to this object\r
38   virtual void IncRef () = 0;\r
39   // Decrement the reference count\r
40   virtual void DecRef () = 0;\r
41   // since Radiant is MFC we don't use a WNDPROC, we wrap the MFC handlers\r
42   // the handler is called first, if returns false Radiant continues processing\r
43   //++timo maybe add more later ? OnKeyUp and OnKeyDown for instance\r
44   //++timo TODO: add handlers everywhere\r
45   // Gef: Changed 2nd & 3rd params to gdouble's for sub-integer grid sizes\r
46   virtual bool OnLButtonDown(guint32 nFlags, gdouble x, gdouble y) = 0;\r
47   virtual bool OnMButtonDown(guint32 nFlags, gdouble x, gdouble y) = 0;\r
48   virtual bool OnRButtonDown(guint32 nFlags, gdouble x, gdouble y) = 0;\r
49   virtual bool OnLButtonUp(guint32 nFlags, gdouble x, gdouble y) = 0;\r
50   virtual bool OnMButtonUp(guint32 nFlags, gdouble x, gdouble y) = 0;\r
51   virtual bool OnRButtonUp(guint32 nFlags, gdouble x, gdouble y) = 0;\r
52   virtual bool OnMouseMove(guint32 nFlags, gdouble x, gdouble y) = 0;\r
53   virtual bool OnKeyPressed(char *s) = 0;\r
54 \r
55   // paint message, the caller makes the GL context current, calls Paint, then swaps GL buffers\r
56   // return value might be false if something failed and closure is requested .. then the buffer swap will be cancelled\r
57   virtual bool Paint() = 0;\r
58   // window is closing (nothing you can do, just telling)\r
59   virtual void Close() = 0;\r
60 };\r
61 \r
62 // IWindowListener with additional properties\r
63 // NOTE: for now it is both a window and the GL widget\r
64 //   in the case of Gtk, there are two widgets, the window widget (a container) and the GL widget\r
65 class IWindow\r
66 {\r
67 public:\r
68   // Increment the number of references to this object\r
69   virtual void IncRef () = 0;\r
70   // Decrement the reference count\r
71   virtual void DecRef () = 0;\r
72   // misc data ------------------------------------------------\r
73   // get pixel size\r
74   virtual int getHeight() = 0;\r
75   virtual int getWidth() = 0;\r
76   // initialisation stuff -------------------------------------\r
77   // set pixel size and other parameters before showing it\r
78   virtual void setSizeParm(int width, int height) = 0;\r
79   // set the IWindowListener (implemented by the plugin using this window)\r
80   virtual void setListener(IWindowListener *) = 0;\r
81   // set the window name\r
82   virtual void setName(char *) = 0;\r
83   // will actually create the GL and the window based on the parameters\r
84   virtual bool Show() = 0;\r
85   // commands -------------------------------------------------\r
86   // call this to ask for a Redraw\r
87   virtual void Redraw() = 0;\r
88 };\r
89 \r
90 // various Radiant messages --------\r
91 // this one holds the total number of supported messages (this is used to allocate structs)\r
92 #define RADIANT_MSGCOUNT 5\r
93 // they start with a 0, can be indexed in an array\r
94 // something was selected / deselected\r
95 #define RADIANT_SELECTION 0\r
96 // a brush face was selected / deselected\r
97 #define RADIANT_SFACE     1\r
98 // current texture / shader changed\r
99 #define RADIANT_TEXTURE   2\r
100 // Radiant is going to enter "sleep mode" (all GL contexts will be destroyed)\r
101 #define RADIANT_SLEEP     3\r
102 // Radiant has left "sleep mode" (GL contexts are recreated)\r
103 #define RADIANT_WAKEUP    4\r
104 \r
105 \r
106 // this one can be used to listen for Radiant-specific events, not related to a window\r
107 class IListener\r
108 {\r
109 public:\r
110   // Increment the number of references to this object\r
111   virtual void IncRef () = 0;\r
112   // Decrement the reference count\r
113   virtual void DecRef () = 0;\r
114   // message is one of the RADIANT_* consts\r
115   virtual void DispatchRadiantMsg( int Msg ) = 0;\r
116 };\r
117 \r
118 // this one is provided by Radiant, it's a wrapper for some usefull functions\r
119 class IXYWndWrapper\r
120 {\r
121 public:\r
122   virtual void SnapToGrid( int x1, int y1, vec3_t pt ) = 0;\r
123   virtual VIEWTYPE GetViewType( void ) = 0;\r
124 };\r
125 \r
126 #define UI_MAJOR "ui"\r
127 \r
128 // create an IWindow with GL context\r
129 typedef IWindow* (WINAPI* PFN_QERAPP_CREATEGLWINDOW) ();\r
130 \r
131 // will hook the given IWindowListener to the XY window and increment the ref count\r
132 //++timo TODO: add hooking in the CAM view and Z view\r
133 typedef void (WINAPI* PFN_QERAPP_HOOKWINDOW)    (IWindowListener *);\r
134 // will unhook the given IWindowListener\r
135 typedef void (WINAPI* PFN_QERAPP_UNHOOKWINDOW)  (IWindowListener *);\r
136 // to retrieve the IXYWndWrapper\r
137 typedef IXYWndWrapper* (WINAPI* PFN_QERAPP_GETXYWNDWRAPPER)     ();\r
138 \r
139 // will hook a given listener into Radiant listening for the given message and increment ref count\r
140 // call several times to listen for several messages\r
141 typedef void (WINAPI* PFN_QERAPP_HOOKLISTENER)  (IListener *, int Msg);\r
142 // will unhook the listener and return the number of messages the given listener was removed from\r
143 typedef int  (WINAPI* PFN_QERAPP_UNHOOKLISTENER)(IListener *);\r
144 \r
145 // TODO: create GL widget, destroy it\r
146 \r
147 struct _QERUITable\r
148 {\r
149   int m_nSize;\r
150   PFN_QERAPP_CREATEGLWINDOW m_pfnCreateGLWindow;\r
151   PFN_QERAPP_HOOKWINDOW         m_pfnHookWindow;\r
152   PFN_QERAPP_UNHOOKWINDOW       m_pfnUnHookWindow;\r
153   PFN_QERAPP_GETXYWNDWRAPPER    m_pfnGetXYWndWrapper;\r
154   PFN_QERAPP_HOOKLISTENER       m_pfnHookListener;\r
155   PFN_QERAPP_UNHOOKLISTENER     m_pfnUnHookListener;\r
156 };\r
157 \r
158 #endif\r