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