UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_behaviour.h
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2020 UFO: Alien Invasion.
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 See the GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23 */
24 
25 #pragma once
26 
27 #include "ui_nodes.h"
29 
30 struct value_s;
31 struct uiBehaviour_t;
32 struct uiNode_t;
33 struct hashTable_s;
34 
39 struct uiBehaviour_t {
40  /* behaviour attributes */
41  const char* name;
42  const char* extends;
44  bool registration;
45  bool isVirtual;
46  bool isFunction;
47  bool isAbstract;
49  bool focusEnabled;
54  intptr_t extraDataSize;
59 #ifdef DEBUG
60  int count;
61 #endif
62 };
63 
67 typedef void (*uiNodeMethod_t)(uiNode_t* node, const struct uiCallContext_s* context);
68 
81 const struct value_s* UI_RegisterNodePropertyPosSize_(uiBehaviour_t* behaviour, const char* name, int type, size_t pos, size_t size);
82 
91 #define UI_RegisterNodeProperty(BEHAVIOUR, NAME, TYPE, OBJECTTYPE, ATTRIBUTE) UI_RegisterNodePropertyPosSize_(BEHAVIOUR, NAME, TYPE, offsetof(OBJECTTYPE, ATTRIBUTE), MEMBER_SIZEOF(OBJECTTYPE, ATTRIBUTE))
92 
99 #define UI_EXTRADATA_OFFSETOF_(TYPE, MEMBER) ((size_t) &((TYPE *)(UI_EXTRADATA_POINTER(0, TYPE)))->MEMBER)
100 
109 #define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE) UI_RegisterNodePropertyPosSize_(BEHAVIOUR, NAME, TYPE, UI_EXTRADATA_OFFSETOF_(EXTRADATATYPE, ATTRIBUTE), MEMBER_SIZEOF(EXTRADATATYPE, ATTRIBUTE))
110 
117 #define UI_RegisterOveridedNodeProperty(BEHAVIOUR, NAME) ;
118 
126 const struct value_s* UI_RegisterNodeMethod(uiBehaviour_t* behaviour, const char* name, uiNodeMethod_t function);
127 
132 const struct value_s* UI_GetPropertyFromBehaviour(const uiBehaviour_t* behaviour, const char* name) __attribute__ ((warn_unused_result));
133 
139 const value_t* UI_GetPropertyOrLuaMethod(const uiNode_t* node, const char* name, value_t *out);
140 
146 
147 void UI_AddBehaviourMethod (uiBehaviour_t* behaviour, const char* name, LUA_METHOD fcn);
148 bool UI_HasBehaviourMethod (uiBehaviour_t* behaviour, const char* name);
149 bool UI_GetBehaviourMethod (const uiBehaviour_t* behaviour, const char* name, LUA_METHOD &fcn);
150 
151 
bool UI_HasBehaviourMethod(uiBehaviour_t *behaviour, const char *name)
Returns true if a node method of given name is available on this behaviour or its super...
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
const char * name
Definition: ui_behaviour.h:41
hashTable_s * nodeMethods
Definition: ui_behaviour.h:58
const struct value_s * UI_GetPropertyFromBehaviour(const uiBehaviour_t *behaviour, const char *name) __attribute__((warn_unused_result))
Return a property from a node behaviour.
UINodePtr manager
Definition: ui_behaviour.h:43
void UI_AddBehaviourMethod(uiBehaviour_t *behaviour, const char *name, LUA_METHOD fcn)
Adds a lua based method to the list of available behaviour methods for calling.
bool UI_GetBehaviourMethod(const uiBehaviour_t *behaviour, const char *name, LUA_METHOD &fcn)
Finds the lua based method on this behaviour or its super.
#define __attribute__(x)
Definition: cxx.h:37
The hash table structure, contains an array of buckets being indexed by the hash function.
Definition: hashtable.cpp:96
void UI_InitializeNodeBehaviour(uiBehaviour_t *behaviour)
Initialize a node behaviour memory, after registration, and before using it.
GLsizei size
Definition: r_gl.h:152
const struct value_s * UI_RegisterNodePropertyPosSize_(uiBehaviour_t *behaviour, const char *name, int type, size_t pos, size_t size)
Register a property to a behaviour. It should not be used in the code.
bool isInitialized
Definition: ui_behaviour.h:48
const struct value_s * UI_RegisterNodeMethod(uiBehaviour_t *behaviour, const char *name, uiNodeMethod_t function)
Register a node method to a behaviour.
void * lua_SWIG_typeinfo
Definition: ui_behaviour.h:57
bool drawItselfChild
Definition: ui_behaviour.h:50
int LUA_METHOD
holds a reference to a lua event handler
Definition: scripts_lua.h:53
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
const value_t * UI_GetPropertyOrLuaMethod(const uiNode_t *node, const char *name, value_t *out)
Return a property or lua based method from a node, node behaviour or inherited behaviour.
const GLuint *typedef void(APIENTRY *GenRenderbuffersEXT_t)(GLsizei
Definition: r_gl.h:189
Contain the context of the calling of a function.
Definition: ui_actions.h:208
QGL_EXTERN GLuint count
Definition: r_gl.h:99
uiBehaviour_t * super
Definition: ui_behaviour.h:55
intptr_t extraDataSize
Definition: ui_behaviour.h:54
node behaviour, how a node work
Definition: ui_behaviour.h:39
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
const char * extends
Definition: ui_behaviour.h:42
const value_t ** localProperties
Definition: ui_behaviour.h:52
void(* uiNodeMethod_t)(uiNode_t *node, const struct uiCallContext_s *context)
Signature of a function to bind a node method.
Definition: ui_behaviour.h:67