List::List() : gcn::ListBox() { m_model = new internal::ListModel; setListModel(m_model); m_listener = new internal::SelectListener; addSelectionListener(m_listener); }
List::List(const std::vector<std::string>& values) : gcn::ListBox() { m_model = new internal::ListModel(values); setListModel(m_model); m_listener = new internal::SelectListener; addSelectionListener(m_listener); }
DropDown::DropDown() : gcn::DropDown() { m_model = new internal::ListModel; setListModel(m_model); m_listener = new internal::SelectListener(true); m_listener->setModel(m_model); addSelectionListener(m_listener); }
DropDown::DropDown(const std::vector<std::string>& values) : gcn::DropDown() { m_model = new internal::ListModel(values); setListModel(m_model); m_listener = new internal::SelectListener(true); m_listener->setModel(m_model); addSelectionListener(m_listener); }
ListBox::ListBox(ListModel *listModel) { mSelected = -1; setWidth(100); setListModel(listModel); setFocusable(true); addMouseListener(this); addKeyListener(this); }
ListBox::ListBox(ListModel *listModel) : mSelected(-1), mWrappingEnabled(false) { setWidth(100); setListModel(listModel); setFocusable(true); addMouseListener(this); addKeyListener(this); }
ListBox::ListBox(ListModel *listModel) { mSelected = -1; mWrappingKeyboardSelection = false; setWidth(100); setListModel(listModel); setFocusable(true); addMouseListener(this); addKeyListener(this); }
DropDown::DropDown(ListModel *listModel, ScrollArea *scrollArea, ListBox *listBox) { setWidth(100); setFocusable(true); mDroppedDown = false; mPushed = false; mIsDragged = false; setInternalFocusHandler(&mInternalFocusHandler); mInternalScrollArea = (scrollArea == NULL); mInternalListBox = (listBox == NULL); if (mInternalScrollArea) { mScrollArea = new ScrollArea(); } else { mScrollArea = scrollArea; } if (mInternalListBox) { mListBox = new ListBox(); } else { mListBox = listBox; } mScrollArea->setContent(mListBox); add(mScrollArea); mListBox->addActionListener(this); mListBox->addSelectionListener(this); setListModel(listModel); if (mListBox->getSelected() < 0) { mListBox->setSelected(0); } addMouseListener(this); addKeyListener(this); addFocusListener(this); adjustHeight(); setBorderSize(1); }
DropDown::DropDown(const Widget2 *const widget, ListModel *const listModel, const bool extended, const Modal modal, ActionListener *const listener, const std::string &eventId) : ActionListener(), BasicContainer(widget), KeyListener(), MouseListener(), FocusListener(), SelectionListener(), mPopup(CREATEWIDGETR(PopupList, this, listModel, extended, modal)), mShadowColor(getThemeColor(ThemeColorId::DROPDOWN_SHADOW)), mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)), mPadding(1), mImagePadding(2), mSpacing(0), mFoldedUpHeight(0), mSelectionListeners(), mExtended(extended), mDroppedDown(false), mPushed(false), mIsDragged(false) { mAllowLogic = false; mFrameSize = 2; mForegroundColor2 = getThemeColor(ThemeColorId::DROPDOWN_OUTLINE); mPopup->setHeight(100); // Initialize graphics if (instances == 0 && theme) { // Load the background skin for (int i = 0; i < 2; i ++) { Skin *const skin = theme->load(dropdownFiles[i], "dropdown.xml"); if (skin) { if (!i) mSkin = skin; const ImageRect &rect = skin->getBorder(); for (int f = 0; f < 2; f ++) { if (rect.grid[f]) { rect.grid[f]->incRef(); buttons[f][i] = rect.grid[f]; buttons[f][i]->setAlpha(mAlpha); } else { buttons[f][i] = nullptr; } } if (i) theme->unload(skin); } else { for (int f = 0; f < 2; f ++) buttons[f][i] = nullptr; } } // get the border skin theme->loadRect(skinRect, "dropdown_background.xml", ""); } instances++; setWidth(100); setFocusable(true); setListModel(listModel); if (mPopup->getSelected() < 0) mPopup->setSelected(0); addMouseListener(this); addKeyListener(this); addFocusListener(this); adjustHeight(); // mPopup->setForegroundColorAll(getThemeColor(ThemeColorId::DROPDOWN), // getThemeColor(ThemeColorId::DROPDOWN_OUTLINE)); mForegroundColor = getThemeColor(ThemeColorId::DROPDOWN); mForegroundColor2 = getThemeColor(ThemeColorId::DROPDOWN_OUTLINE); if (!eventId.empty()) setActionEventId(eventId); if (listener) addActionListener(listener); mPopup->adjustSize(); if (mSkin) { mSpacing = mSkin->getOption("spacing"); mFrameSize = CAST_U32(mSkin->getOption("frameSize")); mPadding = mSkin->getPadding(); mImagePadding = mSkin->getOption("imagePadding"); } adjustHeight(); }