From b217903c070e5a0de9162250108ea8f0e9ba5ad9 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Thu, 27 Nov 2008 16:24:15 +0000 Subject: [PATCH] Remove old wrapping code's obsolete remains. --- src/gui/widgets/container.hpp | 13 -- src/gui/widgets/control.cpp | 27 ----- src/gui/widgets/control.hpp | 6 - src/gui/widgets/grid.cpp | 113 ------------------ src/gui/widgets/grid.hpp | 7 -- src/gui/widgets/scroll_label.cpp | 21 ---- src/gui/widgets/scroll_label.hpp | 9 -- .../widgets/vertical_scrollbar_container.cpp | 21 ---- .../widgets/vertical_scrollbar_container.hpp | 24 ---- src/gui/widgets/widget.hpp | 18 --- 10 files changed, 259 deletions(-) diff --git a/src/gui/widgets/container.hpp b/src/gui/widgets/container.hpp index 4c58897ef31..ab31a96b583 100644 --- a/src/gui/widgets/container.hpp +++ b/src/gui/widgets/container.hpp @@ -78,19 +78,6 @@ public: /** Inherited from twidget. */ void set_size(const tpoint& origin, const tpoint& size); -// REMOVE when wrapping is reimplemented. -#if 0 - /** - * Inherited from twidget. - * - * @todo Adjust for our border. - */ - bool set_width_constrain(const unsigned width) { return grid_.set_width_constrain(width); } - - /** Inherited from twidget. */ - void clear_width_constrain() { grid_.clear_width_constrain(); } -#endif - /***** ***** ***** ***** Inherited ***** ***** ***** *****/ /** Inherited from twidget.*/ diff --git a/src/gui/widgets/control.cpp b/src/gui/widgets/control.cpp index ee24dbbf0cf..401a707ed93 100644 --- a/src/gui/widgets/control.cpp +++ b/src/gui/widgets/control.cpp @@ -219,34 +219,7 @@ void tcontrol::load_config() load_config_extra(); } } -#if 0 -bool tcontrol::set_width_constrain(const unsigned width) -{ - assert(can_wrap()); - assert(text_maximum_width_ == 0); - bool result = false; - if(label_.empty()) { - // Return true on empty label but don't set the value. - result = true; - } else if(get_best_text_size(tpoint(width, 0)).y <= static_cast(width)) { - // Test whether we can achieve the wanted size. - text_maximum_width_ = width; - result = true; - } - - DBG_G_L << "tcontrol(" + get_control_type() + ") " + __func__ + ":" - << " empty label " << label_.empty() - << " result " << result - << ".\n"; - return result; -} - -void tcontrol::clear_width_constrain() -{ - text_maximum_width_ = 0; -} -#endif void tcontrol::draw(surface& surface, const bool force, const bool invalidate_background) { diff --git a/src/gui/widgets/control.hpp b/src/gui/widgets/control.hpp index f71491f85cb..39263ef40e4 100644 --- a/src/gui/widgets/control.hpp +++ b/src/gui/widgets/control.hpp @@ -162,13 +162,7 @@ public: * classes which call this routine should also define get_control_type(). */ void load_config(); -#if 0 - /** Inherited from twidget. */ - bool set_width_constrain(const unsigned width); - /** Inherited from twidget. */ - void clear_width_constrain(); -#endif /** Inherited from twidget. */ void draw(surface& surface, const bool force = false, const bool invalidate_background = false); diff --git a/src/gui/widgets/grid.cpp b/src/gui/widgets/grid.cpp index 9546917f38c..73ca49ea3ed 100644 --- a/src/gui/widgets/grid.cpp +++ b/src/gui/widgets/grid.cpp @@ -527,119 +527,6 @@ void tgrid::set_size(const tpoint& origin, const tpoint& size) assert(false); } -// REMOVE when wrapping is reimplemented. -#if 0 -bool tgrid::set_width_constrain(const unsigned maximum_width) -{ - - /* - * 1. Test the width of (every) row. - * 2. Row wider as wanted? - * - No goto 3 - * - Yes - * 2.1 Test every column in the row. - * 2.2 Can be resized? - * - No goto 2.1. - * - Yes can be sized small enough? - * - No FAILURE. - * - Yes goto 3. - * 2.3 Last column? - * - No goto 2.1 - * - Yes FAILURE. - * 3. Last row? - * - No goto 1. - * - Yes SUCCESS. - */ - - log_scope2(gui_layout, std::string("tgrid ") + __func__); - DBG_G_L << "tgrid: maximum_width " << maximum_width << ".\n"; - - std::vector widths(cols_); - for(unsigned row = 0; row < rows_; ++row) { - - for(unsigned col = 0; col < cols_; ++col) { - - widths[col] = (child(row, col)./**widget()->**/get_best_size()).x; - } - - if(std::accumulate(widths.begin(), widths.end(), 0) > - static_cast(maximum_width)) { - - DBG_G_L << "tgrid: row " << row << " out of bounds needs " - << std::accumulate(widths.begin(), widths.end(), 0) - << " available " << maximum_width - << ", try to resize.\n"; - log_scope2(gui_layout, "tgrid: testing all columns"); - - int width = 0; - for(unsigned col = 0; col < cols_; ++col) { - - log_scope2(gui_layout, "tgrid: column " - + lexical_cast(col)); - - tchild& chld = child(row, col); - - if(!chld.can_wrap()) { - DBG_G_L << "tgrid: column can't wrap, skip.\n"; - continue; - } - - if(widths[col] == 0) { - DBG_G_L << "tgrid: column has zero width, skip.\n"; - } - - width = widths[col]; - widths[col] = 0; - - const int widget_width = maximum_width - - std::accumulate(widths.begin(), widths.end(), 0); - - if(widget_width <=0) { - - DBG_G_L << "tgrid: column is too small to resize, skip.\n"; - widths[col] = width; - width = 0; - continue; - } - - if(chld.get_best_size(tpoint(widget_width, 0)).x <= widget_width - && chld.set_width_constrain(widget_width)) { - - DBG_G_L << "tgrid: column resize succeeded.\n"; - break; - } - - DBG_G_L << "tgrid: column resize failed.\n"; - widths[col] = width; - width = 0; - } - - if(width == 0) { - DBG_G_L << "tgrid: no solution found.\n"; - return false; - } - } else { - DBG_G_L << "tgrid: row " << row << " in bounds.\n"; - } - } - - DBG_G_L << "tgrid: found solution.\n"; - return true; -} - -void tgrid::clear_width_constrain() -{ - foreach(tchild& cell, children_) { - - if(cell.widget() && cell.widget()->can_wrap()) { - cell.widget()->clear_width_constrain(); - } - } - - // Inherit - twidget::clear_width_constrain(); -} -#endif void tgrid::draw(surface& surface, const bool force, const bool invalidate_background) { diff --git a/src/gui/widgets/grid.hpp b/src/gui/widgets/grid.hpp index d512fd2206f..cc8d8a7da09 100644 --- a/src/gui/widgets/grid.hpp +++ b/src/gui/widgets/grid.hpp @@ -204,14 +204,7 @@ public: void set_size(const tpoint& origin, const tpoint& size); /***** ***** ***** ***** Inherited ***** ***** ***** *****/ -// REMOVE when wrapping is reimplemented. -#if 0 - /** Inherited from twidget. */ - bool set_width_constrain(const unsigned width); - /** Inherited from twidget. */ - void clear_width_constrain(); -#endif /** Inherited from twidget. */ void draw(surface& surface, const bool force = false, const bool invalidate_background = false); diff --git a/src/gui/widgets/scroll_label.cpp b/src/gui/widgets/scroll_label.cpp index a2d35782bc4..ff663fd02d2 100644 --- a/src/gui/widgets/scroll_label.cpp +++ b/src/gui/widgets/scroll_label.cpp @@ -86,27 +86,6 @@ void tscroll_label::finalize() label_->set_can_wrap(true); } -// REMOVE when wrapping is reimplemented. -#if 0 -bool tscroll_label::content_set_width_constrain(const unsigned width) -{ - bool result = !label_ ? true : label_->set_width_constrain(width); - - DBG_G_L << "tscroll_label " << __func__ << ":" - << " no label " << !label_ - << " result " << result - << ".\n"; - return result; -} - -void tscroll_label::content_clear_width_constrain() -{ - if(label_) { - label_->clear_width_constrain(); - } -} - -#endif tpoint tscroll_label::content_calculate_best_size() const { assert(label_); diff --git a/src/gui/widgets/scroll_label.hpp b/src/gui/widgets/scroll_label.hpp index 302af799ea6..f8ac958bc6c 100644 --- a/src/gui/widgets/scroll_label.hpp +++ b/src/gui/widgets/scroll_label.hpp @@ -112,15 +112,6 @@ private: /** Inherited from tvertical_scrollbar_container_. */ void content_set_size(const SDL_Rect& rect); -// REMOVE when wrapping is reimplemented. -#if 0 - /** Inherited from tvertical_scrollbar_container_. */ - bool content_set_width_constrain(const unsigned width); - - /** Inherited from tvertical_scrollbar_container_. */ - void content_clear_width_constrain(); - -#endif /***** ***** ***** inherited ****** *****/ /** Inherited from tcontrol. */ diff --git a/src/gui/widgets/vertical_scrollbar_container.cpp b/src/gui/widgets/vertical_scrollbar_container.cpp index bf92a40c838..916ddaa47d7 100644 --- a/src/gui/widgets/vertical_scrollbar_container.cpp +++ b/src/gui/widgets/vertical_scrollbar_container.cpp @@ -270,27 +270,6 @@ void tvertical_scrollbar_container_::key_press(tevent_handler& /*event*/, } } -// REMOVE when wrapping is reimplemented. -#if 0 -bool tvertical_scrollbar_container_::set_width_constrain(const unsigned width) -{ - log_scope2(gui_layout, - std::string("tvertical_scrollbar_container_ ") + __func__); - - const unsigned scrollbar_width = scrollbar_mode_ == HIDE - ? 0 : find_scrollbar_grid()->get_best_size().x; - - const bool result = content_set_width_constrain(width - scrollbar_width); - - DBG_G_L << "tvertical_scrollbar_container_ " - << " width " << width - << " scrollbar_width " << scrollbar_width - << " result " << result - << ".\n"; - return result; -} -#endif - void tvertical_scrollbar_container_::draw( surface& surface, const bool force, const bool invalidate_background) { diff --git a/src/gui/widgets/vertical_scrollbar_container.hpp b/src/gui/widgets/vertical_scrollbar_container.hpp index aaba3e89979..d9586e1e5e2 100644 --- a/src/gui/widgets/vertical_scrollbar_container.hpp +++ b/src/gui/widgets/vertical_scrollbar_container.hpp @@ -103,12 +103,6 @@ public: void key_press(tevent_handler& event, bool& handled, SDLKey key, SDLMod modifier, Uint16 unicode); -// REMOVE when wrapping is reimplemented. -#if 0 - /** Inherited from twidget. */ - void clear_width_constrain() { content_clear_width_constrain(); } -#endif - /** Inherited from tcontainer. */ void draw(surface& surface, const bool force = false, const bool invalidate_background = false); @@ -240,24 +234,6 @@ private: /***** ***** (pure) virtuals for the subclasses ****** *****/ -// REMOVE when wrapping is reimplemented. -#if 0 - /** - * Sets the content width constrain. - * - * See set_width_contrain() for more info. - */ - virtual bool content_set_width_constrain(const unsigned /*width*/) - {return false; } - - /** - * Clears the content width constrain. - * - * See clear_width_constrain() for more info. - */ - virtual void content_clear_width_constrain() {} -#endif - /** * Draws the content part of the widget. * diff --git a/src/gui/widgets/widget.hpp b/src/gui/widgets/widget.hpp index e277ee2d8fe..8c3c3721c26 100644 --- a/src/gui/widgets/widget.hpp +++ b/src/gui/widgets/widget.hpp @@ -430,24 +430,6 @@ public: */ virtual void set_size(const tpoint& origin, const tpoint& size); -// REMOVE when wrapping is reimplemented. -#if 0 - /** - * Limits the maximum width for a widget. - * - * This function should only be called on widgets that can wrap. - * - * @param width The maximum width for the widget. - * - * @returns True if the widget can wrap in the wanted - * width, false otherwise. - */ - virtual bool set_width_constrain(const unsigned /*width*/) { return false; } - - /** Clears the width constrains set. */ - virtual void clear_width_constrain() {} -#endif - /***** ***** ***** ***** drawing ***** ***** ***** *****/ /**