void tcontrol::layout_wrap(const unsigned maximum_width) { // Inherited. twidget::layout_wrap(maximum_width); assert(config_); if(label_.empty()) { // FIXME see what to do on an empty label later. return; } else { tpoint size = get_best_text_size( tpoint(0,0), tpoint(maximum_width - config_->text_extra_width, 0)); size.x += config_->text_extra_width; size.y += config_->text_extra_height; set_layout_size(size); DBG_G_L << "tcontrol(" + get_control_type() + ") " + __func__ + ":" << " maximum_width " << maximum_width << " result " << size << ".\n"; } }
tpoint tcontrol::calculate_best_size() const { assert(config_); if(label_.empty()) { DBG_GUI_L << LOG_HEADER << " empty label return default.\n"; return get_config_default_size(); } const tpoint minimum = get_config_default_size(); tpoint maximum = get_config_maximum_size(); if (!maximum.x) { maximum.x = settings::screen_width; } if (!maximum.y) { maximum.y = settings::screen_height; } maximum.x -= config_->text_extra_width; if (text_maximum_width_ && maximum.x > text_maximum_width_) { maximum.x = text_maximum_width_; } /** * @todo The value send should subtract the border size * and read it after calculation to get the proper result. */ tpoint result = get_best_text_size(minimum, maximum); DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_) << "' result " << result << ".\n"; return result; }
void tcontrol::request_reduce_width(const unsigned maximum_width) { assert(config_); if(!label_.empty() && can_wrap()) { tpoint size = get_best_text_size( tpoint(0,0), tpoint(maximum_width - config_->text_extra_width, 0)); size.x += config_->text_extra_width; size.y += config_->text_extra_height; set_layout_size(size); DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_) << "' maximum_width " << maximum_width << " result " << size << ".\n"; } else { DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_) << "' failed; either no label or wrapping not allowed.\n"; } }
void styled_widget::request_reduce_width(const unsigned maximum_width) { assert(config_); if(!label_.empty() && can_wrap()) { point size = get_best_text_size( point(), point(maximum_width - config_->text_extra_width, 0)); size.x += config_->text_extra_width; size.y += config_->text_extra_height; set_layout_size(size); DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_) << "' maximum_width " << maximum_width << " result " << size << ".\n"; } else if(label_.empty()) { point size = get_best_size(); point min_size = get_config_minimum_size(); size.x = std::min(size.x, std::max<int>(maximum_width, min_size.x)); set_layout_size(size); DBG_GUI_L << LOG_HEADER << " styled_widget " << id() << " maximum_width " << maximum_width << " result " << size << ".\n"; } else { DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_) << "' failed; either no label or wrapping not allowed.\n"; } }
tpoint tcontrol::calculate_best_size() const { assert(config_); tpoint result(config_->default_width, config_->default_height); if(! label_.empty()) { // If no label text set we use the predefined value. /** * @todo The value send should subtract the border size * and readd it after calculation to get the proper result. */ result = get_best_text_size(result); } DBG_G_L << "tcontrol(" + get_control_type() + ") " + __func__ + ":" << " empty label " << label_.empty() << " result " << result << ".\n"; return result; }
tpoint tcontrol::calculate_best_size() const { assert(config_); if(label_.empty()) { DBG_GUI_L << LOG_HEADER << " empty label return default.\n"; return get_config_default_size(); } const tpoint minimum = get_config_default_size(); const tpoint maximum = get_config_maximum_size(); /** * @todo The value send should subtract the border size * and read it after calculation to get the proper result. */ tpoint result = get_best_text_size(minimum, maximum); DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_) << "' result " << result << ".\n"; return result; }
tpoint tcontrol::calculate_best_size() const { assert(config_); tpoint result(config_->default_width, config_->default_height); if(! label_.empty()) { // If no label text set we use the predefined value. /** * @todo The value send should subtract the border size * and readd it after calculation to get the proper result. */ result = get_best_text_size(result); } DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_) << "' result " << result << ".\n"; return result; }