1 /** 2 * @file 3 */ 4 5 /* 6 Copyright (C) 2002-2013 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 "../../../shared/mathlib.h" 28 #include "ui_node_abstractnode.h" 29 30 /* prototype */ 31 struct uiNode_t; 32 struct uiAction_s; 33 struct uiBehaviour_t; 34 struct uiKeyBinding_s; 35 36 class uiWindowNode : public uiLocatedNode { 37 void draw(uiNode_t* node) override; 38 void doLayout(uiNode_t* node) override; 39 void onLoading(uiNode_t* node) override; 40 void onLoaded(uiNode_t* node) override; 41 void onWindowOpened(uiNode_t* node, linkedList_t* params) override; 42 void onWindowClosed(uiNode_t* node) override; 43 void onWindowActivate(uiNode_t* node) override; 44 void clone(uiNode_t const* source, uiNode_t* clone) override; 45 }; 46 47 #define INDEXEDCHILD_HASH_SIZE 32 48 49 typedef struct node_index_s { 50 uiNode_t* node; 51 struct node_index_s* hash_next; 52 struct node_index_s* next; 53 } node_index_t; 54 55 /** 56 * @brief extradata for the window node 57 */ 58 typedef struct { 59 vec2_t noticePos; /**< the position where the cl.msgText messages are rendered */ 60 bool dragButton; /**< If true, we init the window with a header to move it */ 61 bool closeButton; /**< If true, we init the window with a header button to close it */ 62 bool preventTypingEscape; /**< If true, we can't use ESC button to close the window */ 63 bool modal; /**< If true, we can't click outside the window */ 64 bool dropdown; /**< very special property force the window to close if we click outside */ 65 bool isFullScreen; /**< Internal data to allow fullscreen windows without the same size */ 66 bool fill; /**< If true, use all the screen space allowed */ 67 bool starLayout; /**< If true, do a star layout (move child into a corner according to his num) */ 68 69 uiNode_t* parent; /**< to create child window */ 70 71 struct uiKeyBinding_s* keyList; /** list of key binding */ 72 73 /** @todo think about converting it to action instead of node */ 74 struct uiAction_s* onWindowOpened; /**< Invoked when the window is added to the rendering stack */ 75 struct uiAction_s* onWindowClosed; /**< Invoked when the window is removed from the rendering stack */ 76 struct uiAction_s* onWindowActivate;/**< Called when a windows gets active again after some other window was popped from the stack */ 77 struct uiAction_s* onScriptLoaded; /**< Invoked after all UI scripts are loaded */ 78 79 node_index_t* index; 80 node_index_t* index_hash[INDEXEDCHILD_HASH_SIZE]; 81 82 /** Sprite used as a background */ 83 uiSprite_t* background; 84 } windowExtraData_t; 85 86 void UI_RegisterWindowNode(uiBehaviour_t* behaviour); 87 bool UI_WindowIsFullScreen(uiNode_t const* window); 88 bool UI_WindowIsDropDown(uiNode_t const* window); 89 bool UI_WindowIsModal(uiNode_t const* window); 90 void UI_WindowNodeRegisterKeyBinding(uiNode_t* window, struct uiKeyBinding_s* binding); 91 struct uiKeyBinding_s* UI_WindowNodeGetKeyBinding(uiNode_t const* node, unsigned int key); 92 vec_t* UI_WindowNodeGetNoticePosition(uiNode_t* node); 93 /* child index */ 94 uiNode_t* UI_WindowNodeGetIndexedChild(uiNode_t* node, const char* childName); 95 bool UI_WindowNodeAddIndexedNode(uiNode_t* node, uiNode_t* child); 96 bool UI_WindowNodeRemoveIndexedNode(uiNode_t* node, uiNode_t* child); 97