Width of labels in native look editor is adjusted based on the longest label

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@449 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-06-30 14:35:41 +00:00
parent 950bcc1cb2
commit af818e3bec
2 changed files with 22 additions and 4 deletions
+17
View File
@@ -58,6 +58,23 @@ void NativeLookEditor::resizeViewers() {
int w, h;
GetClientSize(&w, &h);
const int default_height = 17;
// Determine label width
{
label_width = 0;
wxClientDC dc(this);
dc.SetFont(*wxNORMAL_FONT);
FOR_EACH(v, viewers) {
ValueEditor* e = v->getEditor();
if (!e || e->drawLabel()) {
// width of the label string
int w;
Style& s = *v->getStyle();
String text = tr(*set->game, s.fieldP->name, capitalize_sentence(s.fieldP->name));
dc.GetTextExtent(text,&w,nullptr);
label_width = max(label_width, w + label_margin);
}
}
}
// Set editor sizes
FOR_EACH(v, viewers) {
StyleP s = v->getStyle();