// /// Respond to the virtual call to let this gadget's Window know how big this /// text gadget wants to be based on the text size. // /// If shrink-wrapping is requested, GetDesiredSize returns the size needed to /// accommodate the borders, margins, and text; otherwise, if shrink-wrapping is not /// requested, it returns the gadget's current width and height. // void TTextGadget::GetDesiredSize(TSize& size) { TGadget::GetDesiredSize(size); TFont* font = Font; if (font == 0) font = &(GetGadgetWindow()->GetFont()); if (font == 0) return; if (ShrinkWrapWidth) size.cx += font->GetTextExtent(Text).cx; else { int left, right, top, bottom; GetOuterSizes(left, right, top, bottom); int newW = font->GetMaxWidth() * NumChars; size.cx += newW + left + right - Bounds.Width(); // Old bounds already considered } if (ShrinkWrapHeight) size.cy += font->GetHeight() + 2; }