From fd7d2e9a678c76f6f18e9dcf820546e261261421 Mon Sep 17 00:00:00 2001 From: Jeremy Henty Date: Mon, 17 Oct 2011 21:09:52 +0100 Subject: downloads DPI: make the download items resize horizontally with the main window. --- dpi/downloads.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'dpi') diff --git a/dpi/downloads.cc b/dpi/downloads.cc index 5599b6e9..d9ccb380 100644 --- a/dpi/downloads.cc +++ b/dpi/downloads.cc @@ -1086,6 +1086,29 @@ void DLWin::abort_all() mDList->get(i)->abort_dl(); } +/* + * A Scroll class that resizes its resizable widget to its width. + * see http://seriss.com/people/erco/fltk/#ScrollableWidgetBrowser + */ +class DlScroll : public Fl_Scroll +{ +public: + void resize(int x_, int y_, int w_, int h_) + { + Fl_Widget *resizable_ = resizable(); + if (resizable_) + resizable_->resize(resizable_->x(), + resizable_->y(), + w() - scrollbar_size(), + resizable_->h()); + Fl_Scroll::resize(x_, y_, w_, h_); + } + DlScroll(int x, int y, int w, int h, const char *l = 0) + : Fl_Scroll(x, y, w, h, l) + { + } +}; + /* * Create the main window and an empty list of requests. */ @@ -1097,12 +1120,13 @@ DLWin::DLWin(int ww, int wh) { // Create the empty main window mWin = new Fl_Window(ww, wh, "Downloads:"); mWin->begin(); - mScroll = new Fl_Scroll(0,0,ww,wh); + mScroll = new DlScroll(0,0,ww,wh); mScroll->begin(); mPG = new Fl_Pack(0,0,ww-18,wh); mPG->end(); mScroll->end(); mScroll->type(Fl_Scroll::VERTICAL); + mScroll->resizable(mPG); mWin->end(); mWin->resizable(mScroll); mWin->callback(dlwin_esc_cb, NULL); -- cgit v1.2.3