| @@ -265,15 +265,18 @@ typedef enum UIevent { | |||||
| // as they appear. | // as they appear. | ||||
| UI_APPEND = 0x0100, | UI_APPEND = 0x0100, | ||||
| // item is focused and has received a key-down event | // item is focused and has received a key-down event | ||||
| // the respective key can be queried using uiGetActiveKey() | |||||
| // the respective key can be queried using uiGetKey() and uiGetModifier() | |||||
| UI_KEY_DOWN = 0x0200, | UI_KEY_DOWN = 0x0200, | ||||
| // item is focused and has received a key-up event | // item is focused and has received a key-up event | ||||
| // the respective key can be queried using uiGetActiveKey() | |||||
| // the respective key can be queried using uiGetKey() and uiGetModifier() | |||||
| UI_KEY_UP = 0x0400, | UI_KEY_UP = 0x0400, | ||||
| // item is focused and has received a character event | // item is focused and has received a character event | ||||
| // the respective character can be queried using uiGetActiveKey() | |||||
| // the respective character can be queried using uiGetKey() | |||||
| UI_CHAR = 0x0800, | UI_CHAR = 0x0800, | ||||
| // item is requested to fill a container with additional items, | |||||
| // usually menuitems for a context menu. | |||||
| // the respective container can be queried using uiGetExtendItem() | |||||
| UI_EXTEND = 0x1000, | |||||
| } UIevent; | } UIevent; | ||||
| // handler callback; event is one of UI_EVENT_* | // handler callback; event is one of UI_EVENT_* | ||||
| @@ -511,6 +514,8 @@ int uiGetHandlerFlags(int item); | |||||
| unsigned int uiGetKey(); | unsigned int uiGetKey(); | ||||
| // when handling a KEY_DOWN/KEY_UP event: the key that triggered this event | // when handling a KEY_DOWN/KEY_UP event: the key that triggered this event | ||||
| unsigned int uiGetModifier(); | unsigned int uiGetModifier(); | ||||
| // when handling an EXTEND event; the container which to add items to | |||||
| int uiGetExtendItem(); | |||||
| // returns the number of child items a container item contains. If the item | // returns the number of child items a container item contains. If the item | ||||
| // is not a container or does not contain any items, 0 is returned. | // is not a container or does not contain any items, 0 is returned. | ||||
| @@ -693,6 +698,7 @@ struct UIcontext { | |||||
| int hot_item; | int hot_item; | ||||
| unsigned int active_key; | unsigned int active_key; | ||||
| unsigned int active_modifier; | unsigned int active_modifier; | ||||
| int extend_item; | |||||
| int count; | int count; | ||||
| int datasize; | int datasize; | ||||
| @@ -902,6 +908,11 @@ unsigned int uiGetModifier() { | |||||
| return ui_context->active_modifier; | return ui_context->active_modifier; | ||||
| } | } | ||||
| int uiGetExtendItem() { | |||||
| assert(ui_context); | |||||
| return ui_context->extend_item; | |||||
| } | |||||
| UIitem *uiItemPtr(int item) { | UIitem *uiItemPtr(int item) { | ||||
| assert(ui_context && (item >= 0) && (item < ui_context->count)); | assert(ui_context && (item >= 0) && (item < ui_context->count)); | ||||
| return ui_context->items + item; | return ui_context->items + item; | ||||
| @@ -954,6 +965,12 @@ void uiNotifyItem(int item, UIevent event) { | |||||
| } | } | ||||
| } | } | ||||
| void uiExtend(int parent, int from_item) { | |||||
| assert(ui_context); | |||||
| ui_context->extend_item = parent; | |||||
| uiNotifyItem(from_item, UI_EXTEND); | |||||
| } | |||||
| int uiAppend(int item, int child) { | int uiAppend(int item, int child) { | ||||
| assert(child > 0); | assert(child > 0); | ||||
| assert(uiParent(child) == -1); | assert(uiParent(child) == -1); | ||||