C4GUI::ComboBox_FillCallback< CB > Class Template Reference

#include <C4Gui.h>

Inheritance diagram for C4GUI::ComboBox_FillCallback< CB >:
Collaboration diagram for C4GUI::ComboBox_FillCallback< CB >:

Public Types

typedef void(CB::* ComboFillFunc) (ComboBox_FillCB *pFiller)
typedef bool(CB::* ComboSelFunc) (ComboBox *pForCombo, int32_t idNewSelection)

Public Member Functions

 ComboBox_FillCallback (CB *pCBClass, ComboFillFunc FillFunc, ComboSelFunc SelFunc)
void FillDropDown (ComboBox *pComboBox, ContextMenu *pDropdownList)
void AddEntry (const char *szText, int32_t id)
bool FindEntry (const char *szText)
void ClearEntries ()
void SelectEntry (int32_t iEntry)

Protected Member Functions

void FillDropDownCB () override
bool OnComboSelChange (ComboBox *pForCombo, int32_t idNewSelection) override

Detailed Description

template<class CB>
class C4GUI::ComboBox_FillCallback< CB >

Definition at line 1942 of file C4Gui.h.

Member Typedef Documentation

◆ ComboFillFunc

template<class CB >
typedef void(CB::* C4GUI::ComboBox_FillCallback< CB >::ComboFillFunc) (ComboBox_FillCB *pFiller)

Definition at line 1945 of file C4Gui.h.

◆ ComboSelFunc

template<class CB >
typedef bool(CB::* C4GUI::ComboBox_FillCallback< CB >::ComboSelFunc) (ComboBox *pForCombo, int32_t idNewSelection)

Definition at line 1946 of file C4Gui.h.

Constructor & Destructor Documentation

◆ ComboBox_FillCallback()

template<class CB >
C4GUI::ComboBox_FillCallback< CB >::ComboBox_FillCallback ( CB *  pCBClass,
ComboFillFunc  FillFunc,
ComboSelFunc  SelFunc 

Definition at line 1959 of file C4Gui.h.

1959  :
1960  pCBClass(pCBClass), FillFunc(FillFunc), SelFunc(SelFunc) { }

Member Function Documentation

◆ AddEntry()

void C4GUI::ComboBox_FillCB::AddEntry ( const char *  szText,
int32_t  id 

Definition at line 34 of file C4GuiComboBox.cpp.

References C4GUI::ContextMenu::AddItem(), FormatString(), C4GUI::Ico_Empty, LoadResStr(), and C4GUI::ComboBox::OnCtxComboSelect().

Referenced by C4TeamList::FillTeamDistOptions(), C4StartupOptionsDlg::OnClosed(), C4FileSelDlg::OnLocationComboFill(), and C4StartupOptionsDlg::SetSubscreen().

35  {
36  if (!szText) szText = "";
38  Handler *pHandler = new Handler(pCombo, &ComboBox::OnCtxComboSelect);
39  pHandler->SetExtra(ComboBox::ComboMenuCBStruct(szText, id));
40  pDrop->AddItem(szText, FormatString(LoadResStr("IDS_MSG_SELECT"), szText).getData(), Ico_Empty, pHandler);
41  }
void AddItem(const char *szText, const char *szToolTip=nullptr, Icons icoIcon=Ico_None, MenuHandler *pMenuHandler=nullptr, ContextHandler *pSubmenuHandler=nullptr)
Definition: C4Gui.h:1873
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void OnCtxComboSelect(C4GUI::Element *pListItem, const ComboMenuCBStruct &rNewSel)
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearEntries()

void C4GUI::ComboBox_FillCB::ClearEntries ( )

Definition at line 56 of file C4GuiComboBox.cpp.

References C4GUI::Container::Clear().

Referenced by C4StartupOptionsDlg::OnClosed().

57  {
58  pDrop->Clear();
59  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FillDropDown()

void C4GUI::ComboBox_FillCB::FillDropDown ( ComboBox pComboBox,
ContextMenu pDropdownList 

Definition at line 1930 of file C4Gui.h.

Referenced by C4GUI::ComboBox::SetComboCB().

1931  { pCombo = pComboBox; pDrop = pDropdownList; FillDropDownCB(); }
virtual void FillDropDownCB()=0
Here is the caller graph for this function:

◆ FillDropDownCB()

template<class CB >
void C4GUI::ComboBox_FillCallback< CB >::FillDropDownCB ( )

Implements C4GUI::ComboBox_FillCB.

Definition at line 1953 of file C4Gui.h.

1954  { if (pCBClass && FillFunc) (pCBClass->*FillFunc)(this); }

◆ FindEntry()

bool C4GUI::ComboBox_FillCB::FindEntry ( const char *  szText)

Definition at line 43 of file C4GuiComboBox.cpp.

References C4GUI::ContextMenu::GetIndexedEntry(), C4GUI::ContextMenu::Entry::GetText(), and SEqual().

Referenced by C4StartupOptionsDlg::OnClosed().

44  {
45  // check for entry with same name
46  ContextMenu::Entry *pEntry; int32_t idx=0;
47  while ((pEntry = pDrop->GetIndexedEntry(idx++))) if (SEqual(pEntry->GetText(), szText)) return true;
48  return false;
49  }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
Entry * GetIndexedEntry(int32_t iIndex)
Definition: C4Gui.h:1879
friend class Entry
Definition: C4Gui.h:1888
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnComboSelChange()

template<class CB >
bool C4GUI::ComboBox_FillCallback< CB >::OnComboSelChange ( ComboBox pForCombo,
int32_t  idNewSelection 

Implements C4GUI::ComboBox_FillCB.

Definition at line 1955 of file C4Gui.h.

1956  { if (pCBClass && SelFunc) return (pCBClass->*SelFunc)(pForCombo, idNewSelection); else return false; }

◆ SelectEntry()

void C4GUI::ComboBox_FillCB::SelectEntry ( int32_t  iEntry)

Definition at line 51 of file C4GuiComboBox.cpp.

References C4GUI::ContextMenu::SelectItem().

52  {
53  pDrop->SelectItem(iEntry);
54  }
void SelectItem(int32_t iIndex)
Definition: C4GuiMenu.cpp:549
Here is the call graph for this function:

The documentation for this class was generated from the following file: