With this I define the popup.
Code: Select all
lv_buname = new wxComboCtrlWithCustomPopupAnim();
lv_buname->SetTextCtrlStyle(wxTE_RIGHT);
lv_buname->Create(tb1);
lv_buname->UseAltPopupWindow();
lv_buname->SetId(ID_lv_buname);
llv_buname->SetInitialSize(wxSize(200, 30));
ownpanel* itest;
itest = new ownpanel(this);
wxComboCtrl::GetFeatures();
lv_buname->SetPopupControl(itest);
lv_buname->SetPopupMinWidth(150 * (hcol + 1));
lv_buname->SetPopupMaxHeight(count / (hcol + 1) * 19.5 + 7);
lv_buname->SetText(bunam[subnr[jetwin]].Upper());
tb1->AddControl(lv_buname);
Code: Select all
class ownpanel : public wxComboPopup, public wxListView,public wxPanel
{
virtual bool Create(wxWindow* parent) wxOVERRIDE
{
wxPanel *mynewpanel;
mynewpanel= new wxPanel(parent);
wxBoxSizer* msiz = new wxBoxSizer(wxVERTICAL);
wxListView* myview = new wxListView(mynewpanel, 1,
wxPoint(0, 0), wxDefaultSize,
// wxLC_LIST | wxLC_SINGLE_SEL | wxSIMPLE_BORDER
wxLC_REPORT | wxLC_SINGLE_SEL | wxSIMPLE_BORDER);
myview->SetId(9191);
myview->AppendColumn("", wxLIST_FORMAT_LEFT, 150);
wxInt16 count = 1, hcount = 0;
wxColour ncol, acol, nocol;
ncol.Set("#" + neucolor);
acol.Set("#" + apocolor);
nocol.Set("#" + notcolor);
myview->AppendColumn("", wxLIST_FORMAT_LEFT, 150);
while (bunam[count] != "")
{
if (count <= 30)
{
// myview->InsertItem(count - 1, bunam[count].Upper());
}
myview->InsertItem(count - 1, bunam[count].Upper());
if (hcount == 30)
{
//myview->AppendColumn("", wxLIST_FORMAT_LEFT,150);
hcount = 0;
}
hcount++;
if (count > 39 && count < 67)
{
if (ncol.IsOk())
{
// myview->SetItemTextColour(count - 1, ncol);
}
}
if (count > 66)
{
// myview->SetItemTextColour(count-1, acol);
}
wxSQLite3ResultSet set;
wxString bhelp;
bhelp << count;
set = h_dbi[subibi[1]].ExecuteQuery(wxS("SELECT * FROM bibel where book=" + bhelp + ";"));
set.NextRow();
if (set.Eof())
{
// myview->SetItemTextColour(count-1, nocol);
}
count++;
}
wxStaticText* hg;
msiz->Add(myview);
hg = new wxStaticText(mynewpanel, wxID_ANY, "test");
mynewpanel->wxPanel::SetSizerAndFit(msiz);
wxString help = "";
help << subnr[jetwin] - 1;
myview->Select(wxAtoi(help), true);
mynewpanel->SetSize(200, 200); //Just tried if this solves the problem
return mynewpanel;
}
virtual wxWindow* GetControl() wxOVERRIDE { return FindWindowById(9191); }
virtual wxString GetStringValue() const wxOVERRIDE
{
if (m_value >= 0)
{
return bunam[m_value + 1];
}
// return wxListView::GetItemText(m_value);
return wxEmptyString;
/* wxInt16 ma_item, m_count;
m_count = 0;
ma_item = wxListView::GetItemCount();
while (!wxListView::IsSelected(m_count))
{
m_count++;
}
return wxListView::GetItemText(m_count);*/
}
void OnMouseMove(wxMouseEvent& event)
{
// Move selection to cursor if it is inside the popup
int resFlags;
int itemHere = wxListView::HitTest(event.GetPosition(), resFlags);
if (itemHere >= 0)
{
wxListView::Select(itemHere, true);
m_itemHere = itemHere;
}
event.Skip();
}
public:
//MyFrame* my_frame;
wxAuiManager* my_mgr;
void setmgr(MyFrame* frame);
void OnActivm(wxMouseEvent& event);
ownpanel(wxWindow* parent);
void OnMouseMotion(wxMouseEvent& event);
int m_value; // current item index
protected:
int m_itemHere; // hot item in popup
private:
// wxDECLARE_EVENT_TABLE();
};