/* Copyright (c) 2021 Alex Diener This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Alex Diener alex@ludobloom.com */ #ifndef __UITextListView_H__ #define __UITextListView_H__ #ifdef __cplusplus extern "C" { #endif typedef struct UITextListView UITextListView; #define UITextListView_superclass UIListViewBase #include "uitoolkit/UIListViewBase.h" #include #define ITEM_IDENTIFIER_NONE INT_MIN #define ITEM_INDEX_NONE UINT_MAX typedef struct UITextListView_item { String text; int identifier; } UITextListView_item; #define UITextListView_ivars \ UIListViewBase_ivars \ \ unsigned int itemCount; \ struct UITextListView_item * items; #define UITextListView_vtable(self_type) \ UIListViewBase_vtable(self_type) \ \ void (* setItems)(self_type * self, unsigned int itemCount, struct UITextListView_item * items); \ void (* setSelectedItemIdentifier)(self_type * self, int identifier); \ int (* getSelectedItemIdentifier)(self_type * self); \ void (* selectItemWithIdentifier)(self_type * self, int identifier); \ void (* deselectItemWithIdentifier)(self_type * self, int identifier); \ unsigned int (* getSelectedItemIdentifiers)(self_type * self, int * outItemIdentifiers, unsigned int countMax, unsigned int offset); \ int (* getSelectedItemIdentifierAtIndex)(self_type * self, unsigned int index); stemobject_declare(UITextListView) UITextListView * UITextListView_create(unsigned int itemCount, struct UITextListView_item * items, Vector2f position, Vector2f relativeOrigin, float width, unsigned int displayedLineCount, UIListViewSelectMode selectMode, UIListViewActionCallback actionCallback, UIListViewSelectionChangedCallback selectionChangedCallback, UIListViewDeleteLineCallback deleteLineCallback, void * callbackContext, UIAppearance appearance); bool UITextListView_init(UITextListView * self, unsigned int itemCount, struct UITextListView_item * items, Vector2f position, Vector2f relativeOrigin, float width, unsigned int displayedLineCount, UIListViewSelectMode selectMode, UIListViewActionCallback actionCallback, UIListViewSelectionChangedCallback selectionChangedCallback, UIListViewDeleteLineCallback deleteLineCallback, void * callbackContext, UIAppearance appearance); void UITextListView_dispose(UITextListView * self); unsigned int UITextListView_getLineCount(UITextListView * self); void UITextListView_drawLine(UITextListView * self, unsigned int lineIndex, Rect4f lineBounds, UIDrawingInterface * drawingInterface, VertexIO * vertexIO); void UITextListView_setItems(UITextListView * self, unsigned int itemCount, struct UITextListView_item * items); void UITextListView_setSelectedItemIdentifier(UITextListView * self, int identifier); int UITextListView_getSelectedItemIdentifier(UITextListView * self); // For use with multiple selection only void UITextListView_selectItemWithIdentifier(UITextListView * self, int identifier); void UITextListView_deselectItemWithIdentifier(UITextListView * self, int identifier); // Returns the number of items written to outItemIdentifiers, which will be no more than countMax. A number of // selected items equal to the value of offset will be skipped before writing to outItemIdentifiers. If // outItemIdentifiers is NULL, this function returns the number of items that would have been written to it. // Recommended ways to call this function: // 1: With a buffer that can hold at least as many items as this UITextListView's itemCount, with countMax // set to itemCount and offset set to 0 // 2: With a buffer allocated to the number of items returned by UITextListView_getSelectedItemCount(), with // countMax set to that number and offset set to 0 // 3: In multiple chunks with a buffer of a size that may be smaller than itemCount, with countMax set to // the buffer size, and offset increasing by the number of items the buffer can hold each successive call unsigned int UITextListView_getSelectedItemIdentifiers(UITextListView * self, int * outItemIdentifiers, unsigned int countMax, unsigned int offset); int UITextListView_getSelectedItemIdentifierAtIndex(UITextListView * self, unsigned int index); #ifdef __cplusplus } #endif #endif