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() { if (widgetExists(mListBox)) mListBox->removeSelectionListener(this); if (mInternalScrollArea) delete mScrollArea; if (mInternalListBox) delete mListBox; setInternalFocusHandler(NULL); }
DropDown::~DropDown() { if (widgetExists(mListBox)) { mListBox->removeActionListener(this); } if (mInternalScrollArea) { delete mScrollArea; } if (mInternalListBox) { delete mListBox; } setInternalFocusHandler(NULL); }