void menu::set_items(const std::vector<std::string>& items, bool strip_spaces, bool keep_viewport) { const bool scrolled_to_max = (has_scrollbar() && get_position() == get_max_position()); items_.clear(); item_pos_.clear(); itemRects_.clear(); column_widths_.clear(); //undrawn_items_.clear(); max_items_ = -1; // Force recalculation of the max items. item_height_ = -1; // Force recalculation of the item height. if (!keep_viewport || selected_ >= items.size()) { selected_ = 0; } fill_items(items, strip_spaces); if(!keep_viewport) { set_position(0); } else if(scrolled_to_max) { set_position(get_max_position()); } update_scrollbar_grip_height(); if(!keep_viewport) { adjust_viewport_to_selection(); } set_dirty(); }
// ctor EDE_Browser::EDE_Browser(int X,int Y,int W,int H,const char *L) : Fl_Icon_Browser(X,Y,W,H), totalwidth_(0), column_header_(0), sort_column(0), sort_type(NO_SORT), sort_direction(false) { thegroup = new Fl_Group(X,Y,W,H); thegroup->begin(); heading = new Heading(0,0,W,buttonheight); heading->box(FL_FLAT_BOX); // draw heading background heading->align(FL_ALIGN_CLIP); heading->end(); heading->hide(); heading->parent(this); // for callback hscrollbar = new Fl_Scrollbar(1, H-Fl::scrollbar_size(), W-Fl::scrollbar_size()-3, Fl::scrollbar_size()); // take account for edges hscrollbar->type(FL_HORIZONTAL); hscrollbar->hide(); hscrollbar->parent(this); // for callback hscrollbar->callback(scroll_cb); thegroup->end(); thegroup->add(this); has_scrollbar(VERTICAL); resizable(0); thegroup->resizable(this); thegroup->align(FL_ALIGN_CLIP); // EDE_Browser is always a multiple-selection browser type(FL_MULTI_BROWSER); column_sort_types_ = new SortType[256]; // 256 columns should be enough for anyone (tm) for (int i=0; i<256; i++) column_sort_types_[i]=NO_SORT; }
void menu::wrap_words() { int total_width = max_width_ - (style_->get_cell_padding() + (2 * style_->get_thickness())); if(has_scrollbar()) { total_width -= scrollbar_width(); } if(total_width <= 0) { return; } std::vector<int> const &widths = column_widths(); for(std::vector<item>::iterator i = items_.begin(); i != items_.end(); ++i) { int space_remaining = total_width; for(size_t col = 0; col < i->fields.size() && col < widths.size(); ++col) { std::string &to_wrap = i->fields[col]; if (!to_wrap.empty()) { if(widths[col] > space_remaining && to_wrap[0] != IMAGE_PREFIX) { to_wrap = font::word_wrap_text(to_wrap, style_->get_font_size(), space_remaining); break; } space_remaining -= widths[col] + 5; } } } itemRects_.clear(); column_widths_.clear(); max_items_ = -1; // Force recalculation of the max items. item_height_ = -1; // Force recalculation of the item height. update_size(); }
void scrollarea::test_scrollbar() { if (recursive_) return; recursive_ = true; if (shown_scrollbar_ != has_scrollbar()) { bg_restore(); bg_cancel(); update_location(location()); } recursive_ = false; }
void scrollarea::update_location(const SDL_Rect& rect) { SDL_Rect r = rect; shown_scrollbar_ = has_scrollbar(); if (shown_scrollbar_) { int w = r.w - scrollbar_.width(); r.x += w; r.w -= w; scrollbar_.set_location(r); r.x -= w; r.w = w; } if (!hidden()) scrollbar_.hide(!shown_scrollbar_); set_inner_location(r); }
int CMessageBox::exec(int timeout) { neutrino_msg_t msg; neutrino_msg_data_t data; int res = menu_return::RETURN_REPAINT; CHintBoxExt::paint(0); if (m_window == NULL) { return res; /* out of memory */ } paintButtons(); if ( timeout == -1 ) timeout = g_settings.timing[SNeutrinoSettings::TIMING_EPG]; unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd( timeout ); bool loop=true; while (loop) { g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd ); if (msg == CRCInput::RC_timeout && returnDefaultOnTimeout) { // return default loop = false; } else if (((msg == CRCInput::RC_timeout) || (msg == (neutrino_msg_t)g_settings.key_channelList_cancel)) && (showbuttons & (mbCancel | mbBack))) { result = (showbuttons & mbCancel) ? mbrCancel : mbrBack; loop = false; } else if ((msg == CRCInput::RC_green) && (showbuttons & mbNo)) { result = mbrNo; loop = false; } else if ((msg == CRCInput::RC_red) && (showbuttons & mbYes)) { result = mbrYes; loop = false; } else if(msg==CRCInput::RC_right) { bool ok = false; while (!ok) { result = (CMessageBox::result_)((result + 1) & 3); ok = showbuttons & (1 << result); } paintButtons(); } else if (has_scrollbar() && ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down))) { if (msg == CRCInput::RC_up) scroll_up(); else scroll_down(); } else if(msg==CRCInput::RC_left) { bool ok = false; while (!ok) { result = (CMessageBox::result_)((result - 1) & 3); ok = showbuttons & (1 << result); } paintButtons(); } else if(msg == CRCInput::RC_ok) { loop = false; } else if((msg == CRCInput::RC_sat) || (msg == CRCInput::RC_favorites)) { } else if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) { res = menu_return::RETURN_EXIT_ALL; loop = false; } } hide(); return res; }