ui_nodes.h

Go to the documentation of this file.
00001 
00005 /*
00006 Copyright (C) 2002-2010 UFO: Alien Invasion.
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016 
00017 See the GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023 */
00024 
00025 #ifndef CLIENT_UI_UI_NODES_H
00026 #define CLIENT_UI_UI_NODES_H
00027 
00028 #include "../../shared/ufotypes.h"
00029 #include "../../common/scripts.h"
00030 
00031 /* prototype */
00032 struct uiIcon_s;
00033 struct value_s;
00034 struct nodeKeyBinding_s;
00035 struct uiCallContext_s;
00036 struct uiNode_s;
00037 struct uiModel_s;
00038 
00039 /* exclude rect */
00040 #define UI_MAX_EXLUDERECTS  64
00041 
00042 typedef struct uiExcludeRect_s {
00043     vec2_t pos, size;
00044 } uiExcludeRect_t;
00045 
00046 typedef void (*uiNodeMethod_t)(struct uiNode_s*node, const struct uiCallContext_s *context);
00047 
00051 typedef struct uiNode_s {
00052     /* common identification */
00053     char name[MAX_VAR];         
00054     struct uiBehaviour_s *behaviour;
00055     struct uiNode_s *super; 
00056     qboolean dynamic;           
00057     qboolean indexed;           
00059     /* common navigation */
00060     struct uiNode_s *firstChild;    
00061     struct uiNode_s *lastChild;     
00062     struct uiNode_s *next;          
00063     struct uiNode_s *parent;        
00064     struct uiNode_s *root;          
00066     /* common pos */
00067     vec2_t pos;
00068     vec2_t size;
00069 
00070     /* common attributes */
00071     const char* tooltip;        
00072     struct uiKeyBinding_s *key; 
00073     qboolean invis;             
00074     qboolean disabled;          
00075     qboolean invalidated;       
00076     qboolean ghost;             
00077     qboolean state;             
00078     int padding;                
00079     int align;                  
00080     int num;                    
00081     struct uiAction_s* visibilityCondition; 
00084     uiExcludeRect_t *excludeRect;   
00085     int excludeRectNum;         
00087     /* other attributes */
00089     int textalign;              
00090     char* text;                 
00091     const char* font;           
00092     void* image;
00093     int border;                 
00094     vec4_t bgcolor;             
00095     vec4_t bordercolor;         
00096     vec4_t color;               
00097     vec4_t selectedColor;       
00099     /* common events */
00100     struct uiAction_s *onClick;
00101     struct uiAction_s *onRightClick;
00102     struct uiAction_s *onMiddleClick;
00103     struct uiAction_s *onWheel;
00104     struct uiAction_s *onMouseEnter;
00105     struct uiAction_s *onMouseLeave;
00106     struct uiAction_s *onWheelUp;
00107     struct uiAction_s *onWheelDown;
00108     struct uiAction_s *onChange;    
00109 } uiNode_t;
00110 
00111 
00117 #define UI_EXTRADATA_POINTER(NODE, TYPE) ((TYPE*)((char*)NODE + sizeof(uiNode_t)))
00118 #define UI_EXTRADATA(NODE, TYPE) (*UI_EXTRADATA_POINTER(NODE, TYPE))
00119 #define UI_EXTRADATACONST_POINTER(NODE, TYPE) ((TYPE*)((const char*)NODE + sizeof(uiNode_t)))
00120 #define UI_EXTRADATACONST(NODE, TYPE) (*UI_EXTRADATACONST_POINTER(NODE, const TYPE))
00121 
00128 #define UI_EXTRADATA_OFFSETOF(TYPE, MEMBER) ((size_t) &((TYPE *)(UI_EXTRADATA_POINTER(0, TYPE)))->MEMBER)
00129 
00134 typedef struct uiBehaviour_s {
00135     /* behaviour attributes */
00136     const char* name;               
00137     const char* extends;            
00138     qboolean isVirtual;             
00139     qboolean isFunction;            
00140     qboolean isAbstract;            
00141     qboolean isInitialized;         
00142     qboolean focusEnabled;          
00143     qboolean drawItselfChild;       
00144     const value_t* properties;      
00145     int propertyCount;              
00146     intptr_t extraDataSize;         
00147     struct uiBehaviour_s *super;    
00148 #ifdef DEBUG
00149     int count;                      
00150 #endif
00151 
00152     /* draw callback */
00153     void (*draw)(uiNode_t *node);                           
00154     void (*drawTooltip)(uiNode_t *node, int x, int y);  
00155     void (*drawOverWindow)(uiNode_t *node);                 
00157     /* mouse events */
00158     void (*leftClick)(uiNode_t *node, int x, int y);        
00159     void (*rightClick)(uiNode_t *node, int x, int y);       
00160     void (*middleClick)(uiNode_t *node, int x, int y);  
00161     void (*mouseWheel)(uiNode_t *node, qboolean down, int x, int y);    
00162     void (*mouseMove)(uiNode_t *node, int x, int y);
00163     void (*mouseDown)(uiNode_t *node, int x, int y, int button);    
00164     void (*mouseUp)(uiNode_t *node, int x, int y, int button);  
00165     void (*capturedMouseMove)(uiNode_t *node, int x, int y);
00166     void (*capturedMouseLost)(uiNode_t *node);
00167 
00168     /* system allocation */
00169     void (*loading)(uiNode_t *node);        
00170     void (*loaded)(uiNode_t *node);     
00171     void (*clone)(const uiNode_t *source, uiNode_t *clone);         
00172     void (*new)(uiNode_t *node);            
00173     void (*delete)(uiNode_t *node);     
00175     /* system callback */
00176     void (*init)(uiNode_t *node);           
00177     void (*close)(uiNode_t *node);      
00178     void (*doLayout)(uiNode_t *node);       
00179     void (*activate)(uiNode_t *node);       
00180     void (*propertyChanged)(uiNode_t *node, const value_t *property);       
00181     void (*sizeChanged)(uiNode_t *node);        
00182     void (*getClientPosition)(uiNode_t *node, vec2_t position); 
00184     /* drag and drop callback */
00185     qboolean (*dndEnter)(uiNode_t *node);                           
00186     qboolean (*dndMove)(uiNode_t *node, int x, int y);          
00187     void (*dndLeave)(uiNode_t *node);                               
00188     qboolean (*dndDrop)(uiNode_t *node, int x, int y);          
00189     qboolean (*dndFinished)(uiNode_t *node, qboolean isDroped); 
00191     /* focus and keyboard events */
00192     void (*focusGained)(uiNode_t *node);
00193     void (*focusLost)(uiNode_t *node);
00194     qboolean (*keyPressed)(uiNode_t *node, unsigned int key, unsigned short unicode);
00195 
00196     /* Planned */
00197 #if 0
00198     /* mouse move event */
00199     void (*mouseEnter)(uiNode_t *node);
00200     void (*mouseLeave)(uiNode_t *node);
00201 #endif
00202 } uiBehaviour_t;
00203 
00204 /* module initialization */
00205 void UI_InitNodes(void);
00206 
00207 /* nodes */
00208 uiNode_t* UI_AllocNode(const char* name, const char* type, qboolean isDynamic);
00209 uiNode_t* UI_GetNodeByPath(const char* path) __attribute__ ((warn_unused_result));
00210 void UI_ReadNodePath(const char* path, const uiNode_t *relativeNode, uiNode_t** resultNode, const value_t **resultProperty);
00211 struct uiNode_s *UI_GetNodeAtPosition(int x, int y) __attribute__ ((warn_unused_result));
00212 const char* UI_GetPath(const uiNode_t* node) __attribute__ ((warn_unused_result));
00213 struct uiNode_s *UI_CloneNode(const struct uiNode_s * node, struct uiNode_s *newWindow, qboolean recursive, const char *newName, qboolean isDynamic) __attribute__ ((warn_unused_result));
00214 qboolean UI_CheckVisibility(uiNode_t *node);
00215 void UI_DeleteAllChild(uiNode_t* node);
00216 void UI_DeleteNode(uiNode_t* node);
00217 
00218 /* behaviours */
00219 uiBehaviour_t* UI_GetNodeBehaviour(const char* name) __attribute__ ((warn_unused_result));
00220 uiBehaviour_t* UI_GetNodeBehaviourByIndex(int index) __attribute__ ((warn_unused_result));
00221 int UI_GetNodeBehaviourCount(void) __attribute__ ((warn_unused_result));
00222 const struct value_s *UI_GetPropertyFromBehaviour(const uiBehaviour_t *behaviour, const char* name) __attribute__ ((warn_unused_result));
00223 
00224 #endif

Generated by  doxygen 1.6.2