From 44feb026ceee21c046e717ed6ec65309b9c01a71 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 8 Nov 2002 13:16:54 +0000 Subject: [PATCH] Forestall any complaints from our German neighbours... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5609 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/xforms/ChangeLog | 25 ++++++++ src/frontends/xforms/xforms_resize.C | 86 +++++++++++++++++++++++----- 2 files changed, 98 insertions(+), 13 deletions(-) diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 230493cd22..8708e452fe 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,28 @@ +2002-11-08 Angus Leeming + + * xforms_resize.[Ch]: sigh. Hack the "get scaling" part of + fl_adjust_form_size out of the xforms source and put it in here as + get_scaling_factor. Resizing and then unresizing to get this info + produces really nasty results... + + I've put a request into the xforms list. + +2002-11-08 Angus Leeming + + * xforms_resize.[Ch]: replace scale_to_fit_tabs and scale_form with + get_scale_to_fit and scale_form_horizontally, respectively. The + functions are a total re-write, making use of the xforms library's + fl_adjust_form_size routine. We therefore get enormously simplified + code and consideration of /all/ button objects, not just those + tabs in tabfolders. + + * FormBase.C (prepare_to_show): + * FormBaseDeprecated.C (prepare_to_show): use the renamed resize + functions to scale the dialog so that labels fit within buttons. + + * FormBase.C (prepare_to_show): remove bc().refresh() call, as this + is done by the controller. + 2002-11-07 Angus Leeming * forms/fdfixh.sed: generate the d-tors in a clean way. diff --git a/src/frontends/xforms/xforms_resize.C b/src/frontends/xforms/xforms_resize.C index 0bc115733f..8b4e57c213 100644 --- a/src/frontends/xforms/xforms_resize.C +++ b/src/frontends/xforms/xforms_resize.C @@ -21,6 +21,79 @@ namespace { +/* This is hacked straight out of the xforms source. + It is fl_adjust_form_size without the last few lines that do the + adjusting. + */ +double get_scaling_factor(FL_FORM * form) +{ + FL_OBJECT *ob; + float xfactor, yfactor, max_factor, factor; + int sw, sh, osize; + float xm = 0.5f, ym = 0.5f; + int bw; + +// if (fl_no_connection) +// return 1.0f; + + max_factor = factor = 1.0f; + for (ob = form->first; ob; ob = ob->next) + { + if ((ob->align == FL_ALIGN_CENTER || (ob->align & FL_ALIGN_INSIDE) || + ob->objclass == FL_INPUT) && + !ob->is_child && *(ob->label) && ob->label[0] != '@' && + ob->boxtype != FL_NO_BOX && + (ob->boxtype != FL_FLAT_BOX || ob->objclass == FL_MENU)) + { + fl_get_string_dimension(ob->lstyle, ob->lsize, ob->label, + strlen(ob->label), &sw, &sh); + + bw = (ob->boxtype == FL_UP_BOX || ob->boxtype == FL_DOWN_BOX) ? + FL_abs(ob->bw) : 1; + + if (ob->objclass == FL_BUTTON && + (ob->type == FL_RETURN_BUTTON || ob->type == FL_MENU_BUTTON)) + sw += FL_min(0.6f * ob->h, 0.6f * ob->w) - 1; + + if (ob->objclass == FL_BUTTON && ob->type == FL_LIGHTBUTTON) + sw += FL_LIGHTBUTTON_MINSIZE + 1; + + if (sw <= (ob->w - 2 * (bw + xm)) && sh <= (ob->h - 2 * (bw + ym))) + continue; + + if ((osize = ob->w - 2 * (bw + xm)) <= 0) + osize = 1; + xfactor = (float) sw / (float)osize; + + if ((osize = ob->h - 2 * (bw + ym)) <= 0) + osize = 1; + yfactor = (float) sh / osize; + + if (ob->objclass == FL_INPUT) + { + xfactor = 1.0f; + yfactor = (sh + 1.6f) / osize; + } + + if ((factor = FL_max(xfactor, yfactor)) > max_factor) + { + max_factor = factor; + } + } + } + + if (max_factor <= 1.0f) + return 1.0f; + + max_factor = 0.01f * (int) (max_factor * 100.0f); + + if (max_factor > 1.25f) + max_factor = 1.25f; + + return max_factor; +} + + // A nasty hack for older xforms versions int get_tabfolder_numfolders(FL_OBJECT * folder) { @@ -55,19 +128,6 @@ int get_tabfolder_numfolders(FL_OBJECT * folder) } -double get_scaling_factor(FL_FORM * form) -{ - // fl_adjust_form_size gives us the info we desire but also resizes - // the form, which we don't want :-( - double factor = fl_adjust_form_size(form); - if (factor > 1.001) { - double const inv = 1.0 / factor; - fl_scale_form(form, inv, inv); - } - return factor; -} - - double get_tabfolder_scale_to_fit(FL_OBJECT * folder) { lyx::Assert(folder && folder->objclass == FL_TABFOLDER); -- 2.39.5