/* This file is part of * ====================================================== * * LyX, The Document Processor * * Copyright 2001 The LyX Team. * * ====================================================== * * \file FormFloat.C */ #include #ifdef __GNUG__ #pragma implementation #endif #include "xformsBC.h" #include "ControlFloat.h" #include "FormFloat.h" #include "form_float.h" #include "support/lstrings.h" typedef FormCB > base_class; FormFloat::FormFloat(ControlFloat & c) : base_class(c, _("Float Options")) {} // FIX: Needs to be implemented. (Lgb) // A way to set to float default is missing. // A way to set "force[!]" is missing. void FormFloat::build() { dialog_.reset(build_float()); // Manage the ok, apply and cancel/close buttons bc().setOK(dialog_->button_ok); bc().setApply(dialog_->button_apply); bc().setCancel(dialog_->button_cancel); bc().setRestore(dialog_->button_restore); bc().addReadOnly(dialog_->radio_top); bc().addReadOnly(dialog_->radio_bottom); bc().addReadOnly(dialog_->radio_page); bc().addReadOnly(dialog_->radio_here); bc().addReadOnly(dialog_->button_here_definitely); } void FormFloat::apply() { string placement; if (fl_get_button(dialog_->button_here_definitely)) { placement += "H"; } else { if (fl_get_button(dialog_->radio_top)) { placement += "t"; } if (fl_get_button(dialog_->radio_bottom)) { placement += "b"; } if (fl_get_button(dialog_->radio_page)) { placement += "p"; } if (fl_get_button(dialog_->radio_here)) { placement += "h"; } } controller().params().placement = placement; } void FormFloat::update() { bool top = false; bool bottom = false; bool page = false; bool here = false; bool here_definitely = false; string placement(controller().params().placement); if (contains(placement, "H")) { here_definitely = true; } else { if (contains(placement, "t")) { top = true; } if (contains(placement, "b")) { bottom = true; } if (contains(placement, "p")) { page = true; } if (contains(placement, "h")) { here = true; } } fl_set_button(dialog_->radio_top, top); fl_set_button(dialog_->radio_bottom, bottom); fl_set_button(dialog_->radio_page, page); fl_set_button(dialog_->radio_here, here); fl_set_button(dialog_->button_here_definitely, here_definitely); } ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long) { if (ob == dialog_->button_here_definitely) { if (fl_get_button(dialog_->button_here_definitely)) { fl_set_button(dialog_->radio_top, false); fl_set_button(dialog_->radio_bottom, false); fl_set_button(dialog_->radio_page, false); fl_set_button(dialog_->radio_here, false); } } else { if (fl_get_button(dialog_->button_here_definitely)) { fl_set_button(dialog_->button_here_definitely, false); } } return ButtonPolicy::SMI_VALID; }