Listbox
From IfsoGUIWiki
Contents |
Listbox
Type: ifsoGUI_Listbox
Module: ifsogui.listbox
Extends: ifsoGUI_Base
Imports: ifsogui.scrollbar
General
A listbox gadget is used to offer a list of items to the user. The listbox can be configured to allow more than one selection at a time.
Events
- ifsoGUI_EVENT_CLICK – Gadget has been clicked with the mouse. Data is which item was selected. iMouseX/Y are mouse position of the click was doen with the mouse. if the selection was made with the space bar, then iMouseX/Y are set to -1.
- ifsoGUI_EVENT_DOUBLE_CLICK – Gadget has been double clicked with the mouse. Data is the item the was double clicked. IMouseX/Y are mouse position if clicked by the mouse, or -1 if the event was generated by the Enter key.
- ifsoGUI_EVENT_RIGHT_CLICK – Gadget has been right clicked. Data is the selected index.
- ifsoGUI_EVENT_MIDDLE_CLICK – Gadget has been middle clicked. Data is the selected item.
- ifsoGUI_EVENT_MOUSE_MOVE – Mouse has been moved over the gadget. Data is 0.
- ifsoGUI_EVENT_MOUSE_ENTER – Mouse has moved over the gadget. Data is 0.
- ifsoGUI_EVENT_MOUSE_EXIT – Mouse has moved away from the gadget. Data is 0.
- ifsoGUI_EVENT_GAIN_FOCUS – Gadget has gained the focus. Data, iMouseX, and iMouseY as all 0.
- ifsoGUI_EVENT_LOST_FOCUS – Gadget has lost the focus. Data, iMouseX, and iMouseY as all 0.
Functions
Functions used by the programmer to use the gadgets.
- Create:ifsoGUI_ListBox(iX:Int, iY:Int, iW:Int, iH:Int, strName:String) - Creates and returns an instance of the gadget.
Methods/Properties
These are the methods and properties used by the programmer to use the gadgets.
- AddItem(strName:String, intData:Int, strTip:String, bSelected:Int = False) - Adds an item to the gadget.
- AddSound(iSoundEvent:Int, sndSound:TSound) - Add a sound to the event of a gadget.
- BringToFront() - Brings the gadget to the front of its parents child list.
- CanActive:Int() - Returns whether or not this gadget can be the active gadget.
- GetAbsoluteXY(iX:Int Var, iY:Int Var, caller:ifsoGUI_Base = Null) - Retrieves the gadgets Absolute x and y position.
- GetCount:Int() - Returns the number of items in the list.
- GetEnabled:Int() - Returns whether the gadget is enabled.
- GetFont:TImageFont() - Returns the font the gadget is using.
- GetGadgetAlpha:Float() - Returns the gadgets alpha value.
- GetH:Int() - Returns the gadgets height.
- GetHScrollbar:Int() - Gets whether or not the Horizontal Scrollbar will show.
- GetItem:ifsoGUI_ListItem(intIndex:Int) - Gets the item by index.
- GetItemData:Int(intIndex:Int) - Returns the data of the item.
- GetItemName:String(intIndex:Int) - Returns the name of the item.
- GetItemTip:String(intIndex:Int) - Returns the tip of the item.
- GetItemSelected:Int(intIndex:Int) - Returns whether the item is selected or not.
- GetMouseHighlight:Int() - Returns whether or not the highlight follows the mouse.
- GetMultiSelect:Int() - Returns whether or not multiple items can be selected.
- GetProperty:Object(key:String) - Returns a custom property.
- GetScrollBarWidth:Int() - Returns the width of the scrollbars.
- GetSelected:Int() - Returns the index of the selected item.
- GetSelectedItem:ifsoGUI_ListItem() - Returns the selected item.
- GetShowBorder:Int() - Returns whether or not the border is showing.
- GetShowFocus:Int() - Returns whether or not the gadget will show the focus box.
- GetTabOrder:Int() - Returns the gadgets TabOrder.
- GetTip:String() - Returns the gadgets tip text.
- GetTopItem:Int() - Returns the index of the item at the top of the visible portion of the listbox.
- GetVisible:Int() - Returns whether the gadget is visible.
- GetVisibleItems:Int() - Returns the number of items visible at a time in the listbox.
- GetVScrollbar:Int() - Gets whether or not the Vertical Scrollbar will show.
- GetW:Int() - Returns the gadgets width.
- GetWH(width:Int Var, height:Int Var) - Retrieves the gadgets width and height.
- GetXY(iX:Int Var, iY:Int Var) - Retrieves the gadgets x and y positions.
- InsertItem(intIndex:Int, strName:String, intData:Int, strTip:String, bSelected:Int = False) - Inserts an item into the gadget.
- RemoveAll() - Removes all items from the gadget.
- RemoveItem(intIndex:Int) - Removes an item from the gadget.
- SendToBack() - Sends the gadget to the back of its parent child list.
- SetBounds(iX:Int, iY:Int, iW:Int, iH:Int) - Sets the x, y, width, and height all in one call.
- SetCallBack(func(gadget:ifsoGUI_Base, id:Int, data:Int, iMouseX:Int, iMouseY:Int)) - Sets the event callback function for the gadget.
- SetEnabled(bEnabled:Int = True) - Sets the gadget enabled/disabled.
- SetFocus() - Gives the gadget the focus.
- SetFocusColor(iRed:Int, iGreen:Int, iBlue:Int) - Sets the gadgets focus box color.
- SetFont(Font:TImageFont) - Sets the font of the gadget.
- SetGadgetAlpha(fltAlpha:Float) - Sets the gadgets alpha value.
- SetGadgetColor(iRed:Int, iGreen:Int, iBlue:Int) - Sets the gadget color of the gadget.
- SetHighlightColor(iRed:Int, iGreen:Int, iBlue:Int) - Sets the highlight color.
- SetHighlightTextColor(iRed:Int, iGreen:Int, iBlue:Int) - Sets the highlight text color.
- SetHScrollbar(iHScrollbar:Int) - Sets whether or not the Horizontal Scrollbar will show.
- SetItemData(intIndex:Int, intData:Int) - Sets the data of the item.
- SetItemName(intIndex:Int, strName:String) - Sets the name of the item.
- SetItemTip(intIndex:Int, strTip:String) - Sets the tip of the item.
- SetMouseHighlight(intMouseHighlight:Int) - Sets whether or not the highlight follows the mouse.
- SetMultiSelect(bMultiSelect:Int) - Sets whether or not multiple items can be selected.
- SetProperty(key:String, value:Object) - Set a custom property.
- SetScrollBarWidth(iWidth:Int) - Sets the width of the scrollbars.
- SetSelectColor(iRed:Int, iGreen:Int, iBlue:Int) - Sets the selection color.
- SetSelected(intIndex:Int) - Sets the selected index.
- SetSelectTextColor(iRed:Int, iGreen:Int, iBlue:Int) - Sets the select text color.
- SetShowBorder(bShowBorder:Int) - Sets whether or not the border will show.
- SetShowFocus(intShowFocus:Int) - Sets whether or not to show the focus box for this gadget.
- SetTabOrder(iTabOrder:Int) - Sets the gadgets TabOrder. 0=Do not tab to this gadget -1=Last in the Tab Order
- SetTextColor(iRed:Int, iGreen:Int, iBlue:Int) - Sets the text color of the gadget.
- SetTip(strTip:String) - Sets the gadget tip text.
- SetTopItem(intTopItem:Int) - Sets the top index of the listbox.
- SetVisible(bVisible:Int) - Sets whether the gadget is visible.
- SetVScrollbar(iVScrollbar:Int) - Sets whether or not the Vertical Scrollbar will show.
- SetWH(width:Int, height:Int) - Sets the gadgets width and height.
- SetXY(iX:Int, iY:Int) - Sets the gadgets x and y position.
- SortList(bDesc:Int = False, bSortAsInt:Int = False, bData:Int = False) - Sorts the list.
Internal Functions
These function are internal to the gadget. They should only need to be called, if you are creating a gadget.
- Drawbox(images:TImage[], ws:Int[], hs:Int[], rX:Int, rY:Int, rW:Int, rH:Int, bDrawBorder:Int = True, bTileSides:Int = False, bTileCenter:Int = False) - Draws the standard ifsoGUI image based on 4 corners, 4 sides, and a center background portion.
- FastQuickSort(array:ifsoGUI_ListItem[]) - Sorts the list by the item names.
- FastQuickSortData(array:ifsoGUI_ListItem[]) - Sorts the list by the item data.
- FastQuickSortDataDesc(array:ifsoGUI_ListItem[]) - Sorts the list by the item data descending.
- FastQuickSortDesc(array:ifsoGUI_ListItem[]) - Sorts the list by item names descending.
- FastQuickSortInt(array:ifsoGUI_ListItem[]) - Sorts the list by item names, but it is treated as numbers rather than strings.
- FastQuickSortIntDesc(array:ifsoGUI_ListItem[]) - Sorts the list by item names descending, but it is treated as numbers rather than strings.
- GetDimensions:String(strName:String) - Gets the dimensions from the dimension file for the gadgets graphics.
- InsertionSort(a:ifsoGUI_ListItem[], lo0:Int, hi0:Int) - Used by the FastQuickSort routines.
- Load9Image(srcpath:String, dimensions:String[], gImage:TImage[] Var, imagew:Int[] Var, imageh:Int[] Var) - Loads the graphics for an image in 9 standard parts.
- LoadTheme() - Called when a new theme is loaded, so the gadget can load its images for drawing. The base gadget does not have a LoadTheme function, but any gadget than can be created should have one.
- QuickSort(a:ifsoGUI_ListItem[], l:Int, r:Int) - Used by the FastQuickSort functions.
- SystemEvent(id:Int, data:Int) - Called when a system level event occurs that all gadgets should know about, like loading a new theme or changing the default GUI font. The base gadget does not have a SystemEvent function, but any gadget than can be created should have one.
Internal Methods
These methods are called by the GUI itself and should only be used if you are creating your own gadget.
- Compare:Int(withObject:Object) - Compares two gadgets by TabOrder.
- Draw(parX:Int, parY:Int, parW:Int, parH:Int) - Draws the gadget and its children.
- DrawFocus(iX:Int, iY:Int, iW:Int, iH:Int) - Draws the focus box around the gadget.
- DrawTip(iMouseX:Int, iMouseY:Int) - Draws the gadgets tip.
- GadgetSystemEvent(id:Int, data:Int) - Gadget Level GUI system event occured.
- GainFocus(LostFocus:ifsoGUI_Base) - Called when the gadget becomes the active gadget.
- gMouseDown(iButton:Int, iMouseX:Int, iMouseY:Int) - Called when the mouse button is pressed on the gadget.
- gMouseUp(iButton:Int, iMouseX:Int, iMouseY:Int) - Called when the mouse button is released on the gadget.
- IsMouseOver:Int(parX:Int, parY:Int, parW:Int, parH:Int, iMouseX:Int, iMouseY:Int) - Returns whether or not the mouse is over the gadget.
- IsMyChild:Int(gadget:ifsoGUI_Base) - Is the gadget a child or slave of this gadget.
- IsMySlave:Int(gadget:ifsoGUI_Base) - Is the gadget a slave of this gadget.
- KeyPress(key:Int) - Called when a key is pressed on the active gadget.
- LostFocus(GainedFocus:ifsoGUI_Base) - Called when the gadget is no longer the Active Gadget.
- MouseOut(iMouseX:Int, iMouseY:Int, gOverGadget:ifsoGUI_Base) - Called when the mouse leaves the gadget.
- MouseOver(iMouseX:Int, iMouseY:Int, gWasOverGadget:ifsoGUI_Base) - Called when the mouse is over this gadget.
- MouseStatus:Int(iMouseX:Int, iMouseY:Int) - Called to determine the mouse status from the gadget.
- Refresh() - Refreshes the gadget.
- SendEvent(id:Int, data:Int, iMouseX:Int, iMouseY:Int) - Sends an event from the gadget.
- SlaveEvent(gadget:ifsoGUI_Base, id:Int, data:Int, iMouseX:Int, iMouseY:Int) - Called from a slave gadget.
Skinning
dimensions.txt keyword: listbox
Filename: listbox.png
This is a representation of a listbox, the sides will be stretched or tiled the height of the listbox, the top and bottom will be stretched or tiled the width of the listbox, and the center will be stretched or tiled to the length and width of the listbox. The corners will remain as is and will not be stretched or tiled at all.
ListItem
Type: ifsoGUI_ListItem
General
The items in the listbox are stored as ifsoGUI_ListItem. Each listitem has 4 fields and can be accessed either as a listitem, or individual fields can be accessed directly through the listbox.
Fields
- Name:String – The name of the item that appears in the listbox.
- Data:Int – A data value that can be used for any purpose.
- Tip:String – The tip that is displayed when the mouse is over this item.
- Selected:Int – Whether or not this listitem is currently selected or not.
