33 , pSelectedItem(nullptr), pSelectionChangeHandler(nullptr), pSelectionDblClickHandler(nullptr), fDrawBackground(true), fDrawBorder(false), fSelectionDisabled(false)
45 keys.emplace_back(K_UP);
50 keys.emplace_back(K_DOWN);
55 keys.emplace_back(K_LEFT);
60 keys.emplace_back(K_RIGHT);
74 keys.emplace_back(K_RETURN);
75 keys.emplace_back(K_RETURN,
KEYS_Alt);
120 if (rcSelArea.
Hgt>=0)
128 while ((pCurr = pCurr->
GetNext()))
161 if (pCurr->GetBounds().Contains(iX, iY))
191 if (iExtraSpace <= 0)
return 0;
194 rcNewBounds.
Hgt -= iExtraSpace;
211 bool ListBox::KeyContext()
218 bool ListBox::KeyUp()
237 bool ListBox::KeyDown()
256 bool ListBox::KeyLeft()
275 bool ListBox::KeyRight()
294 bool ListBox::KeyPageDown()
299 if (!pNextSelectedItem)
return false;
302 pNextSelectedItem =
pNext;
308 pNextSelectedItem =
pNext;
318 if ((
pNext = pNextSelectedItem->
GetPrev())) pNextSelectedItem =
pNext;
else break;
330 bool ListBox::KeyPageUp()
335 if (!pNextSelectedItem)
return false;
338 pNextSelectedItem =
pNext;
344 pNextSelectedItem =
pNext;
354 if ((
pNext = pNextSelectedItem->
GetNext())) pNextSelectedItem =
pNext;
else break;
366 bool ListBox::KeyHome()
376 bool ListBox::KeyEnd()
386 bool ListBox::KeyActivate()
423 else iOverallHgt = 0;
425 while ((pCurr = pCurr->
GetNext()))
429 int32_t iNewY = iOverallHgt + iYSpace;
441 int32_t y=0, iLineHgt=0, col=0;
442 for (; pCurr; pCurr=pCurr->
GetNext())
445 iLineHgt = std::max<int32_t>(rcCurrBounds.
Hgt, iLineHgt);
455 iOverallHgt = y + iLineHgt;
468 rcChildBounds.
x = iIndent;
496 rcChildBounds.
x = iIndent;
509 int32_t iPrevLineHgt = 0;
511 while (cnt-- && pPrevChild)
513 iPrevLineHgt = std::max<int32_t>(iPrevLineHgt, pPrevChild->
GetBounds().
Hgt);
514 pPrevChild = pPrevChild->
GetPrev();
516 rcChildBounds.
y += iPrevLineHgt;
542 rcChildBounds.
x = iIndent;
581 if (fByUser)
GUISound(
"UI::Select");
603 if (pSel) pSel = pSel->
GetNext();
607 if (!pSel)
return false;
632 {
return (*SortFunc)(pEl1, pEl2, par)>0; }
641 if (iElemCount <= 1)
return;
647 ppElements[i++] = pEl;
649 for (i=0; i<iElemCount; ++i)
654 delete [] ppElements;
657 delete [] ppElements;
#define C4GUI_ListBoxBarColor
#define C4GUI_ListBoxInactSelColor
#define C4GUI_ListBoxSelColor
#define C4GUI_ListBoxBarIndent
const int32_t C4MC_Button_LeftDown
const int32_t C4MC_Button_LeftDouble
int32_t GamepadGuiControl
C4ConfigControls Controls
std::vector< C4KeyCodeEx > CodeList
void DrawBoxDw(C4Surface *sfcDest, int iX1, int iY1, int iX2, int iY2, DWORD dwClr)
void DrawLineDw(C4Surface *sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width=1.0f)
virtual void DoCall(class Element *pElement)=0
virtual Element * GetLastContained()
void AddElement(Element *pChild)
void RemoveElement(Element *pChild) override
virtual void ElementSizeChanged(Element *pOfElement)
int32_t GetElementCount()
void ReaddElement(Element *pChild)
void InsertElement(Element *pChild, Element *pInsertBefore)
Element * GetFirstContained() override
friend class ScrollWindow
virtual void OnGetFocus(bool fByMouse)
virtual bool CharIn(const char *)
void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) override
virtual bool GetListItemTopSpacingBar()
Element * GetPrev() const
Element * GetNext() const
void SetBounds(const C4Rect &rcNewBound)
virtual bool CheckNameHotkey(const char *)
virtual int32_t GetListItemTopSpacing()
void Draw3DFrame(C4TargetFacet &cgo, bool fUp=false, int32_t iIndent=1, BYTE byAlpha=C4GUI_BorderAlpha, bool fDrawTop=true, int32_t iTopOff=0, bool fDrawLeft=true, int32_t iLeftOff=0)
virtual void UpdateOwnPos()
Element * GetSelectedItem()
void ElementPosChanged(Element *pOfElement) override
bool InsertElement(Element *pChild, Element *pInsertBefore, int32_t iIndent=0)
int32_t ContractToElementHeight()
BaseCallbackHandler * pSelectionChangeHandler
bool AddElement(Element *pChild, int32_t iIndent=0)
bool CharIn(const char *c) override
void UpdateElementPositions()
ScrollWindow * pClientWindow
void DrawElement(C4TargetFacet &cgo) override
void ScrollItemInView(Element *pItem)
void ElementSizeChanged(Element *pOfElement) override
void SelectionChanged(bool fByUser)
void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) override
int32_t(* SortFunction)(const Element *pEl1, const Element *pEl2, void *par)
void SortElements(SortFunction SortFunc, void *par)
bool IsMultiColumn() const
int32_t GetMarginTop() override
BaseCallbackHandler * pSelectionDblClickHandler
void SelectEntry(Element *pNewSel, bool fByUser)
void UpdateElementPosition(Element *pOfElement, int32_t iIndent)
int32_t GetMarginLeft() override
int32_t iMultiColItemWidth
void RemoveElement(Element *pChild) override
void OnGetFocus(bool fByMouse) override
SortCompareElements(ListBox::SortFunction SortFunc, void *par)
int operator()(const Element *pEl1, const Element *pEl2)
void UpdateOwnPos() override
C4Rect & GetClientRect() override
bool Contains(int32_t iX, int32_t iY) const
void GUISound(const char *szSound)