Author: mordante
Date: Thu May 21 21:12:11 2009
New Revision: 35804
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35804&view=rev
Log:
Remove the unused function twidget::layout_fit_width.
Also remove the unused flags and forwarded functions in tgrid::tchild.
Modified:
trunk/src/gui/widgets/container.cpp
trunk/src/gui/widgets/container.hpp
trunk/src/gui/widgets/control.cpp
trunk/src/gui/widgets/control.hpp
trunk/src/gui/widgets/generator.hpp
trunk/src/gui/widgets/grid.cpp
trunk/src/gui/widgets/grid.hpp
trunk/src/gui/widgets/scrollbar_container.cpp
trunk/src/gui/widgets/scrollbar_container.hpp
trunk/src/gui/widgets/widget.hpp
Modified: trunk/src/gui/widgets/container.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/container.cpp?rev=35804&r1=35803&r2=35804&view=diff
==============================================================================
--- trunk/src/gui/widgets/container.cpp (original)
+++ trunk/src/gui/widgets/container.cpp Thu May 21 21:12:11 2009
@@ -160,46 +160,6 @@
set_layout_size(size);
}
-void tcontainer_::layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags)
-{
- // Inherited.
- twidget::layout_fit_width(maximum_width, flags);
-
- log_scope2(log_gui_layout, "tcontainer(" + get_control_type() + ") " +
__func__);
- DBG_GUI_L << "tcontainer(" + get_control_type() + "):"
- << " maximum_width " << maximum_width
- << " flags " << flags
- << ".\n";
-
- // We need a copy and adjust if for the borders, no use to ask the grid
for
- // the best size if it won't fit in the end due to our borders.
- const tpoint border_size = border_space();
-
- // Calculate the best size
- grid_.layout_fit_width(maximum_width - border_space().y, flags);
- tpoint size = grid_.get_best_size();
-
- // If the best size has a value of 0 it's means no limit so don't add
the
- // border_size might set a very small best size.
- if(size.x) {
- size.x += border_size.x;
- }
-
- if(size.y) {
- size.y += border_size.y;
- }
-
- DBG_GUI_L << "tcontainer(" + get_control_type() + "):"
- << " maximum_width " << maximum_width
- << " flags " << flags
- << " border size " << border_size
- << " returning " << size
- << ".\n";
-
- set_layout_size(size);
-}
-
void tcontainer_::set_size(const tpoint& origin, const tpoint& size)
{
tcontrol::set_size(origin, size);
Modified: trunk/src/gui/widgets/container.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/container.hpp?rev=35804&r1=35803&r2=35804&view=diff
==============================================================================
--- trunk/src/gui/widgets/container.hpp (original)
+++ trunk/src/gui/widgets/container.hpp Thu May 21 21:12:11 2009
@@ -118,10 +118,6 @@
void layout_use_horizontal_scrollbar(const unsigned maximum_width);
/** Inherited from twidget. */
- void layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags);
-
- /** Inherited from twidget. */
void set_size(const tpoint& origin, const tpoint& size);
/***** ***** ***** ***** Inherited ***** ***** ***** *****/
Modified: trunk/src/gui/widgets/control.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/control.cpp?rev=35804&r1=35803&r2=35804&view=diff
==============================================================================
--- trunk/src/gui/widgets/control.cpp (original)
+++ trunk/src/gui/widgets/control.cpp Thu May 21 21:12:11 2009
@@ -199,52 +199,6 @@
set_layout_size(tpoint(maximum_width, get_best_size().y));
assert(static_cast<unsigned>(get_best_size().x) == maximum_width);
-}
-
-void tcontrol::layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags)
-{
- assert(get_visible() != twidget::INVISIBLE);
-
- log_scope2(log_gui_layout,
- "tcontrol(" + get_control_type() + ") " + __func__);
- DBG_GUI_L << "maximum_width " << maximum_width
- << " flags " << flags
- << ".\n";
-
- // Already fits.
- if(get_best_size().x <= static_cast<int>(maximum_width)) {
- DBG_GUI_L << "Already fits.\n";
- return;
- }
-
- // Wrap.
- if((flags & twidget::WRAP) && can_wrap()) {
- layout_wrap(maximum_width);
-
- if(get_best_size().x <= static_cast<int>(maximum_width)) {
- DBG_GUI_L << "Success: Wrapped.\n";
- return;
- }
- }
-
- // Horizontal scrollbar.
- if((flags & twidget::SCROLLBAR) && has_horizontal_scrollbar()) {
- layout_use_horizontal_scrollbar(maximum_width);
-
- if(get_best_size().x <= static_cast<int>(maximum_width)) {
- DBG_GUI_L << "Success: Horizontal scrollbar.\n";
- return;
- }
- }
-
- // Shrink.
- if((flags & twidget::SHRINK) && can_shrink_width()) {
- layout_shrink_width(maximum_width);
- DBG_GUI_L << "Success: Shrunken.\n";
- }
-
- DBG_GUI_L << "Failed.\n";
}
tpoint tcontrol::calculate_best_size() const
Modified: trunk/src/gui/widgets/control.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/control.hpp?rev=35804&r1=35803&r2=35804&view=diff
==============================================================================
--- trunk/src/gui/widgets/control.hpp (original)
+++ trunk/src/gui/widgets/control.hpp Thu May 21 21:12:11 2009
@@ -161,10 +161,6 @@
/** Inherited from twidget. */
void layout_shrink_width(const unsigned maximum_width);
- /** Inherited from twidget. */
- void layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags);
-
protected:
/** Inherited from twidget. */
tpoint calculate_best_size() const;
Modified: trunk/src/gui/widgets/generator.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/generator.hpp?rev=35804&r1=35803&r2=35804&view=diff
==============================================================================
--- trunk/src/gui/widgets/generator.hpp (original)
+++ trunk/src/gui/widgets/generator.hpp Thu May 21 21:12:11 2009
@@ -202,10 +202,6 @@
virtual void NEW_layout_init(const bool full_initialization) = 0;
/** Inherited from twidget. */
- virtual void layout_fit_width(const unsigned /*maximum_width */,
- const tfit_flags /*flags*/) { /* Make pure virtual? */ }
-
- /** Inherited from twidget. */
virtual tpoint calculate_best_size() const = 0;
/** Inherited from twidget. */
Modified: trunk/src/gui/widgets/grid.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.cpp?rev=35804&r1=35803&r2=35804&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.cpp (original)
+++ trunk/src/gui/widgets/grid.cpp Thu May 21 21:12:11 2009
@@ -661,110 +661,6 @@
set_layout_size(calculate_best_size());
}
-void tgrid::layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags)
-{
- log_scope2(log_gui_layout, std::string("tgrid ") + __func__);
- DBG_GUI_L << "tgrid: maximum width " << maximum_width
- << " flags " << flags
- << ".\n";
-
- // Do we already fit?
- if(get_best_size().x <= static_cast<int>(maximum_width)) {
- DBG_GUI_L << "Already fits.\n";
- return;
- }
-
- // Try to reduce our size; friendly first.
- tfit_flags current_flags =
- static_cast<tfit_flags>(flags & (WRAP | SCROLLBAR));
-
- if(current_flags) {
- impl_layout_fit_width(maximum_width, current_flags);
- if(get_best_size().x <= static_cast<int>(maximum_width)) {
- DBG_GUI_L << "Success: Friendly.\n";
- return;
- }
- }
-
- // Try to reduce our size; the aggresive way.
- current_flags = static_cast<tfit_flags>(flags & SHRINK);
- if(current_flags) {
- impl_layout_fit_width(maximum_width, current_flags);
- if(get_best_size().x <= static_cast<int>(maximum_width)) {
- DBG_GUI_L << "Success: Forced.\n";
- return;
- }
- }
-
- DBG_GUI_L << "Failed.\n";
- assert(flags != FORCE
- || static_cast<unsigned>(get_best_size().x) <=
maximum_width);
-}
-
-void tgrid::impl_layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags)
-{
- log_scope2(log_gui_layout, std::string("tgrid ") + __func__);
- DBG_GUI_L << "tgrid: maximum width " << maximum_width
- << " flags " << flags
- << ".\n";
-
- for(unsigned col = 0; col < cols_; ++col) {
-
- // Find out how much size there still has to be reduced.
- unsigned current_size = get_best_size().x;
- int too_wide = current_size - maximum_width;
-
- DBG_GUI_L << "tgrid: col " << col
- << " maximum_width " << maximum_width
- << " current_size " << current_size
- << " too_wide " << too_wide
- << ".\n";
-
- if(too_wide < 0) {
- DBG_GUI_L << "tgrid: col " << col << " fits stop
searching.\n";
- break;
- }
-
- // If the current column too small to be reduced the entire
width
- // skip it. This can be optimized later by only trying to reduce
- // it partially, especially if multiple columns can be reduced.
- if(static_cast<int>(col_width_[col]) < too_wide) {
- DBG_GUI_L << "tgrid: col " << col
- << " col_width_ " << col_width_[col]
- << " too small to be resized.\n";
- continue;
- }
-
- // Try to reduce all widgets too wide in this column. We don't
care
- // whether or not we succeeded, if we fail there might be the
- // aggressive run that finishes the task, but that means we
tried
- // nicely before.
- const unsigned wanted_width = col_width_[col] - too_wide;
-
- DBG_GUI_L << "tgrid: col " << col
- << " try to fit the rows in " << wanted_width
- << ".\n";
-
- for(unsigned row = 0; row < rows_; ++row) {
- tchild& chld = child(row, col);
- const twidget* widget = chld.widget();
- assert(widget);
-
- if(widget->get_visible() != twidget::INVISIBLE
- && widget->get_best_size().x
- > static_cast<int>(wanted_width)) {
-
- chld.layout_fit_width(wanted_width, flags);
- }
- }
- }
-
- // Update the status.
- set_layout_size(calculate_best_size());
-}
-
void tgrid::set_size(const tpoint& origin, const tpoint& size)
{
log_scope2(log_gui_layout, "tgrid: set size");
@@ -1185,28 +1081,6 @@
widget_->layout_use_horizontal_scrollbar(
maximum_width - border_space().x);
-}
-
-void tgrid::tchild::layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags)
-{
- assert(widget_);
- assert(widget_->get_visible() != twidget::INVISIBLE);
-
- log_scope2(log_gui_layout, std::string("tgrid::tchild ") + __func__);
- DBG_GUI_L << "tgrid: maximum width " << maximum_width
- << " flags " << flags
- << ".\n";
-
- widget_->layout_fit_width(maximum_width - border_space().x, flags);
- if(widget_->get_best_size().x
- + border_space().x
- <= static_cast<int>(maximum_width)) {
-
- DBG_GUI_L << "Succeeded.\n";
- } else {
- DBG_GUI_L << "Failed.\n";
- }
}
const std::string& tgrid::tchild::id() const
Modified: trunk/src/gui/widgets/grid.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.hpp?rev=35804&r1=35803&r2=35804&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.hpp (original)
+++ trunk/src/gui/widgets/grid.hpp Thu May 21 21:12:11 2009
@@ -237,13 +237,6 @@
/** Inherited from twidget. */
void layout_use_horizontal_scrollbar(const unsigned maximum_width);
- /** Inherited from twidget. */
- void layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags);
-private:
- /** Internal helper for layout_fit_width. */
- void impl_layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags);
public:
/** Inherited from twidget. */
void set_size(const tpoint& origin, const tpoint& size);
@@ -338,10 +331,6 @@
/** Forwards layout_use_horizontal_scrollbar() to the cell. */
void layout_use_horizontal_scrollbar(const unsigned
maximum_width);
- /** Forwards layout_fit_width() to the cell. */
- void layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags);
-
/** Returns the id of the widget/ */
const std::string& id() const;
Modified: trunk/src/gui/widgets/scrollbar_container.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar_container.cpp?rev=35804&r1=35803&r2=35804&view=diff
==============================================================================
--- trunk/src/gui/widgets/scrollbar_container.cpp (original)
+++ trunk/src/gui/widgets/scrollbar_container.cpp Thu May 21 21:12:11 2009
@@ -294,52 +294,6 @@
set_layout_size(size);
}
-void tscrollbar_container::layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags)
-{
- assert(get_visible() != twidget::INVISIBLE);
-
- log_scope2(log_gui_layout,
- "tscrollbar_container(" + get_control_type() + ") " +
__func__);
- DBG_GUI_L << "maximum_width " << maximum_width
- << " flags " << flags
- << ".\n";
-
- // Already fits.
- if(get_best_size().x <= static_cast<int>(maximum_width)) {
- DBG_GUI_L << "Already fits.\n";
- return;
- }
-
- // Wrap.
- if((flags & twidget::WRAP) && can_wrap()) {
- layout_wrap(maximum_width);
-
- if(get_best_size().x <= static_cast<int>(maximum_width)) {
- DBG_GUI_L << "Success: Wrapped.\n";
- return;
- }
- }
-
- // Horizontal scrollbar.
- if((flags & twidget::SCROLLBAR) && has_horizontal_scrollbar()) {
- layout_use_horizontal_scrollbar(maximum_width);
-
- if(get_best_size().x <= static_cast<int>(maximum_width)) {
- DBG_GUI_L << "Success: Horizontal scrollbar.\n";
- return;
- }
- }
-/* Can't shrink but should not be needed as well
- // Shrink.
- if((flags & twidget::TRUNCATE) && can_shrink_width()) {
- layout_shrink_width(maximum_width);
- DBG_GUI_L << "Success: Shrunken.\n";
- }
-*/
- DBG_GUI_L << "Failed.\n";
-}
-
tpoint tscrollbar_container::calculate_best_size() const
{
log_scope2(log_gui_layout,
Modified: trunk/src/gui/widgets/scrollbar_container.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar_container.hpp?rev=35804&r1=35803&r2=35804&view=diff
==============================================================================
--- trunk/src/gui/widgets/scrollbar_container.hpp (original)
+++ trunk/src/gui/widgets/scrollbar_container.hpp Thu May 21 21:12:11 2009
@@ -106,10 +106,6 @@
/** Inherited from tcontainer_. */
void layout_use_horizontal_scrollbar(const unsigned maximum_width);
- /** Inherited from tcontainer. */
- void layout_fit_width(const unsigned maximum_width,
- const tfit_flags flags);
-
private:
/** Inherited from tcontainer_. */
tpoint calculate_best_size() const;
Modified: trunk/src/gui/widgets/widget.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/widget.hpp?rev=35804&r1=35803&r2=35804&view=diff
==============================================================================
--- trunk/src/gui/widgets/widget.hpp (original)
+++ trunk/src/gui/widgets/widget.hpp Thu May 21 21:12:11 2009
@@ -297,26 +297,6 @@
virtual void layout_shrink_width(const unsigned /*maximum_width*/)
{ assert(can_shrink_width()); }
- /** Flags to decide how to try to fit the widget in the layout. */
- enum tfit_flags {
- WRAP = 1 /**< Try to wrap the widget. */
- , SCROLLBAR = 2 /**< Try to use scrollbars. */
- , SHRINK = 4 /**< Try to shrink the widget. */
- , FORCE = 7 /**< Try all of the above. */
- };
-
- /**
- * Fits the layout in the wanted width.
- *
- * @param maximum_width The maximum width of the window.
- * @param flags The flags for the fitting.
- */
- virtual void layout_fit_width(const unsigned /*maximum_width*/,
- const tfit_flags /*flags*/)
- {
- //FIXME should be pure abstract but gives linker errors.
- }
-
/**
* Does the widget have a vertical scrollbar.
*
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits