- // Set caption label _only_ if the cursor is in _this_ float:
- if (cur.top().text() == &text_) {
- string s;
- size_t i = cur.depth();
- while (i > 0) {
- --i;
- InsetBase * const in = &cur[i].inset();
- if (in->lyxCode() == InsetBase::FLOAT_CODE
- || in->lyxCode() == InsetBase::WRAP_CODE) {
- s = in->getInsetName();
- break;
- }
- }
- Floating const & fl = textclass_.floats().getType(s);
- s = fl.name();
- string num;
- if (s.empty())
- s = "Senseless";
- else
- num = convert<string>(textclass_.counters().value(fl.type()));
-
- // Generate the label
- label = bformat("%1$s %2$s:", _(s), num);
- }
-
- labelwidth_ = font_metrics::width(label, pi.base.font);
- pi.pain.text(x, y, label, pi.base.font);
+ setLabel(cur);
+ labelwidth_ = pi.pain.text(x, y, label, pi.base.font);