mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-16 01:15:18 +00:00
Remove old wrapping code's obsolete remains.
This commit is contained in:
parent
bdac6c4fe5
commit
b217903c07
|
@ -78,19 +78,6 @@ public:
|
||||||
/** Inherited from twidget. */
|
/** Inherited from twidget. */
|
||||||
void set_size(const tpoint& origin, const tpoint& size);
|
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 ***** ***** ***** *****/
|
||||||
|
|
||||||
/** Inherited from twidget.*/
|
/** Inherited from twidget.*/
|
||||||
|
|
|
@ -219,34 +219,7 @@ void tcontrol::load_config()
|
||||||
load_config_extra();
|
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<int>(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,
|
void tcontrol::draw(surface& surface, const bool force,
|
||||||
const bool invalidate_background)
|
const bool invalidate_background)
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,13 +162,7 @@ public:
|
||||||
* classes which call this routine should also define get_control_type().
|
* classes which call this routine should also define get_control_type().
|
||||||
*/
|
*/
|
||||||
void load_config();
|
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. */
|
/** Inherited from twidget. */
|
||||||
void draw(surface& surface, const bool force = false,
|
void draw(surface& surface, const bool force = false,
|
||||||
const bool invalidate_background = false);
|
const bool invalidate_background = false);
|
||||||
|
|
|
@ -527,119 +527,6 @@ void tgrid::set_size(const tpoint& origin, const tpoint& size)
|
||||||
assert(false);
|
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<int> 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<int>(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<std::string>(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,
|
void tgrid::draw(surface& surface, const bool force,
|
||||||
const bool invalidate_background)
|
const bool invalidate_background)
|
||||||
{
|
{
|
||||||
|
|
|
@ -204,14 +204,7 @@ public:
|
||||||
void set_size(const tpoint& origin, const tpoint& size);
|
void set_size(const tpoint& origin, const tpoint& size);
|
||||||
|
|
||||||
/***** ***** ***** ***** Inherited ***** ***** ***** *****/
|
/***** ***** ***** ***** 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. */
|
/** Inherited from twidget. */
|
||||||
void draw(surface& surface, const bool force = false,
|
void draw(surface& surface, const bool force = false,
|
||||||
const bool invalidate_background = false);
|
const bool invalidate_background = false);
|
||||||
|
|
|
@ -86,27 +86,6 @@ void tscroll_label::finalize()
|
||||||
label_->set_can_wrap(true);
|
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
|
tpoint tscroll_label::content_calculate_best_size() const
|
||||||
{
|
{
|
||||||
assert(label_);
|
assert(label_);
|
||||||
|
|
|
@ -112,15 +112,6 @@ private:
|
||||||
/** Inherited from tvertical_scrollbar_container_. */
|
/** Inherited from tvertical_scrollbar_container_. */
|
||||||
void content_set_size(const SDL_Rect& rect);
|
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 ****** *****/
|
||||||
|
|
||||||
/** Inherited from tcontrol. */
|
/** Inherited from tcontrol. */
|
||||||
|
|
|
@ -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(
|
void tvertical_scrollbar_container_::draw(
|
||||||
surface& surface, const bool force, const bool invalidate_background)
|
surface& surface, const bool force, const bool invalidate_background)
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,12 +103,6 @@ public:
|
||||||
void key_press(tevent_handler& event, bool& handled,
|
void key_press(tevent_handler& event, bool& handled,
|
||||||
SDLKey key, SDLMod modifier, Uint16 unicode);
|
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. */
|
/** Inherited from tcontainer. */
|
||||||
void draw(surface& surface, const bool force = false,
|
void draw(surface& surface, const bool force = false,
|
||||||
const bool invalidate_background = false);
|
const bool invalidate_background = false);
|
||||||
|
@ -240,24 +234,6 @@ private:
|
||||||
|
|
||||||
/***** ***** (pure) virtuals for the subclasses ****** *****/
|
/***** ***** (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.
|
* Draws the content part of the widget.
|
||||||
*
|
*
|
||||||
|
|
|
@ -430,24 +430,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void set_size(const tpoint& origin, const tpoint& size);
|
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 ***** ***** ***** *****/
|
/***** ***** ***** ***** drawing ***** ***** ***** *****/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user