* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author Angus Leeming
+ * \author Angus Leeming
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
#include "xforms_resize.h"
-#include "support/LAssert.h"
+
+#include <boost/assert.hpp>
+
#include <algorithm> // std::max. Use FL_max in .c code...
-#include FORMS_H_LOCATION
+#include "lyx_forms.h"
+
namespace {
int bw;
// if (fl_no_connection)
-// return 1.0f;
+// return 1.0f;
max_factor = factor = 1.0f;
for (ob = form->first; ob; ob = ob->next)
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);
+ 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;
+ sw += (int)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)
+ if ((osize = ob->w - 2 * (int)(bw + xm)) <= 0)
osize = 1;
xfactor = (float) sw / (float)osize;
- if ((osize = ob->h - 2 * (bw + ym)) <= 0)
+ if ((osize = ob->h - 2 * (int)(bw + ym)) <= 0)
osize = 1;
yfactor = (float) sh / osize;
}
-// A nasty hack for older xforms versions
-int get_tabfolder_numfolders(FL_OBJECT * folder)
-{
-#if FL_VERSION > 0 || FL_REVISION > 88
- return fl_get_tabfolder_numfolders(folder);
-#else
- if (folder->objclass != FL_TABFOLDER)
- return 0;
-
- fl_freeze_form(folder->form);
- int const saved_folder_id = fl_get_folder_number(folder);
-
- int num_folders = 0;
- FL_FORM const * old_leaf = 0;
- for (;;) {
- int const id = num_folders + 1;
- fl_set_folder_bynumber(folder, id);
- FL_FORM const * const leaf = fl_get_folder(folder);
- if (!leaf || leaf == old_leaf) {
- // unable to increment succesfully.
- break;
- }
- old_leaf = leaf;
- ++num_folders;
- }
-
- fl_set_folder_bynumber(folder, saved_folder_id);
- fl_unfreeze_form(folder->form);
-
- return num_folders;
-#endif
-}
-
-
double get_tabfolder_scale_to_fit(FL_OBJECT * folder)
{
- lyx::Assert(folder && folder->objclass == FL_TABFOLDER);
+ BOOST_ASSERT(folder && folder->objclass == FL_TABFOLDER);
fl_freeze_form(folder->form);
int const saved_folder_id = fl_get_folder_number(folder);
double factor = 1.0;
- int const size = get_tabfolder_numfolders(folder);
+ int const size = fl_get_tabfolder_numfolders(folder);
for (int i = 0; i < size; ++i) {
fl_set_folder_bynumber(folder, i+1);
FL_FORM * leaf = fl_get_folder(folder);
void scale_tabfolder_horizontally(FL_OBJECT * folder, double factor)
{
- lyx::Assert(folder && folder->objclass == FL_TABFOLDER);
+ BOOST_ASSERT(folder && folder->objclass == FL_TABFOLDER);
fl_freeze_form(folder->form);
int const saved_folder_id = fl_get_folder_number(folder);
- int const size = get_tabfolder_numfolders(folder);
+ int const size = fl_get_tabfolder_numfolders(folder);
for (int i = 0; i < size; ++i) {
fl_set_folder_bynumber(folder, i+1);
FL_FORM * leaf = fl_get_folder(folder);
double get_scale_to_fit(FL_FORM * form)
{
- lyx::Assert(form);
-
+ BOOST_ASSERT(form);
+
double factor = get_scaling_factor(form);
for (FL_OBJECT * ob = form->first; ob; ob = ob->next) {
if (ob->objclass == FL_TABFOLDER)
void scale_form_horizontally(FL_FORM * form, double factor)
{
- lyx::Assert(form);
-
+ BOOST_ASSERT(form);
+
if (factor <= 1.0)
return;
fl_scale_form(form, factor, 1);
-
+
for (FL_OBJECT * ob = form->first; ob; ob = ob->next) {
if (ob->objclass == FL_TABFOLDER)
scale_tabfolder_horizontally(ob, factor);