int ListPicker(SingleWindow &parent, const TCHAR *caption, unsigned num_items, unsigned initial_value, unsigned item_height, WndListFrame::PaintItemCallback_t paint_callback, bool update, ListHelpCallback_t _help_callback, ItemHelpCallback_t _itemhelp_callback) { assert(num_items <= 0x7fffffff); assert((num_items == 0 && initial_value == 0) || initial_value < num_items); assert(item_height > 0); assert(paint_callback != NULL); wf = LoadDialog(CallBackTable, parent, Layout::landscape ? _T("IDR_XML_COMBOPICKER_L") : _T("IDR_XML_COMBOPICKER")); assert(wf != NULL); if (caption != NULL) wf->SetCaption(caption); list_control = (WndListFrame *)wf->FindByName(_T("frmComboPopupList")); assert(list_control != NULL); list_control->SetItemHeight(item_height); list_control->SetLength(num_items); list_control->SetCursorIndex(initial_value); list_control->SetActivateCallback(OnComboPopupListEnter); list_control->SetPaintItemCallback(paint_callback); help_callback = _help_callback; itemhelp_callback = _itemhelp_callback; if (itemhelp_callback != NULL) { wItemHelp = (WndFrame *)wf->FindByName(_T("lblItemHelp")); assert(wItemHelp); wItemHelp->set_visible(true); const unsigned help_height = wItemHelp->get_height(); const PixelRect rc = list_control->get_position(); assert(rc.bottom - rc.top - help_height - 10 > 0); list_control->move(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top - help_height - 10); list_control->SetCursorCallback(OnPointCursorCallback); OnPointCursorCallback(initial_value); } else wItemHelp = NULL; WndButton *help_button = (WndButton *)wf->FindByName(_T("cmdHelp")); assert(help_button != NULL); if (help_callback != NULL) help_button->SetOnClickNotify(OnHelpClicked); else help_button->hide(); if (update) wf->SetTimerNotify(OnTimerNotify); int result = wf->ShowModal() == mrOK ? (int)list_control->GetCursorIndex() : -1; delete wf; return result; }
int ListPicker(SingleWindow &parent, const TCHAR *caption, unsigned num_items, unsigned initial_value, UPixelScalar item_height, ListControl::PaintItemCallback paint_callback, bool update, ListHelpCallback_t _help_callback, ItemHelpCallback_t _itemhelp_callback) { assert(num_items <= 0x7fffffff); assert((num_items == 0 && initial_value == 0) || initial_value < num_items); assert(item_height > 0); assert(paint_callback != NULL); wf = LoadDialog(CallBackTable, parent, Layout::landscape ? _T("IDR_XML_COMBOPICKER_L") : _T("IDR_XML_COMBOPICKER")); assert(wf != NULL); if (caption != NULL) wf->SetCaption(caption); list_control = (ListControl *)wf->FindByName(_T("frmComboPopupList")); assert(list_control != NULL); list_control->SetItemHeight(item_height); list_control->SetLength(num_items); list_control->SetActivateCallback(OnComboPopupListEnter); list_control->SetPaintItemCallback(paint_callback); help_callback = _help_callback; itemhelp_callback = _itemhelp_callback; if (itemhelp_callback != NULL) { wItemHelp = (WndFrame *)wf->FindByName(_T("lblItemHelp")); assert(wItemHelp); wItemHelp->Show(); const UPixelScalar help_height = wItemHelp->GetHeight(); PixelRect rc = list_control->GetPosition(); assert(rc.bottom - rc.top - help_height > 0); rc.bottom -= help_height; list_control->Move(rc); list_control->SetCursorCallback(OnPointCursorCallback); OnPointCursorCallback(initial_value); } else wItemHelp = NULL; list_control->SetCursorIndex(initial_value); WndButton *help_button = (WndButton *)wf->FindByName(_T("cmdHelp")); assert(help_button != NULL); if (help_callback == NULL) help_button->Hide(); if (num_items == 0) { WndButton *select_button = (WndButton *)wf->FindByName(_T("SelectButton")); assert(select_button != NULL); select_button->SetEnabled(false); } if (update) wf->SetTimerNotify(OnTimerNotify); int result = wf->ShowModal() == mrOK ? (int)list_control->GetCursorIndex() : -1; delete wf; return result; }