+2002-10-22 Rob Lahaye <lahaye@snu.ac.kr>
+
+ * FeedbackController.C: use the NORMAL rather than the SMALL sized font
+ to display messages in the message_widget.
+
+ * FormGraphics.h: remove un-needed #include.
+
+ * FormPrint.C (build): minimal change due to change in
+ RadioButtonGroup's semantics.
+
+ * RadioButtonGroup.[Ch]: something of a clean-up.
+ (reset): removed.
+ (set): new method, accepting an FL_OBJECT *.
+
+ * xforms_helpers.[Ch] (setEnabled): change lcol setting from
+ FL_BLACK to FL_LCOL.
+ (getString) use line=0 instead of line=-1 as default case;
+
2002-10-22 Rob Lahaye <lahaye@snu.ac.kr>
* forms/form_aboutlyx.fd: implement the text widgets as browsers
{
lyx::Assert(ob && ob->objclass == FL_TEXT);
message_widget_ = ob;
- fl_set_object_lsize(message_widget_, FL_SMALL_SIZE);
+ fl_set_object_lsize(message_widget_, FL_NORMAL_SIZE);
}
else
str = message;
- str = formatted(str, message_widget_->w-10, FL_SMALL_SIZE);
+ str = formatted(str, message_widget_->w - 10, FL_NORMAL_SIZE);
fl_set_object_label(message_widget_, str.c_str());
- FL_COLOR const label_color = warning_posted_ ? FL_TOMATO : FL_BLACK;
+ FL_COLOR const label_color = warning_posted_ ? FL_RED : FL_BLACK;
fl_set_object_lcol(message_widget_, label_color);
if (!message_widget_->visible)
#endif
#include "FormBase.h"
-#include "RadioButtonGroup.h"
#include <boost/scoped_ptr.hpp>
typedef FormCB<ControlPrint, FormDB<FD_print> > base_class;
FormPrint::FormPrint()
- : base_class(_("Print")),
- target_(2), which_pages_(2)
+ : base_class(_("Print"))
{}
bc().addReadOnly(dialog_->check_sorted_copies);
bc().addReadOnly(dialog_->check_reverse_order);
- target_.reset();
target_.init(dialog_->radio_printer, PrinterParams::PRINTER);
target_.init(dialog_->radio_file, PrinterParams::FILE);
- which_pages_.reset();
which_pages_.init(dialog_->radio_all_pages, true);
which_pages_.init(dialog_->radio_from_to, false);
* Licence details can be found in the file COPYING.
*
* \author Baruch Even
+ * \author Rob Lahaye
*
* Full author contact details are available in file CREDITS
*/
#include "debug.h" // for lyxerr
#include "support/lyxfunctional.h"
-//#include <functional>
#include <algorithm>
#include <iterator>
using std::find_if;
-//using std::bind2nd;
using std::endl;
-void RadioButtonGroup::init(FL_OBJECT *button, size_type value)
+void RadioButtonGroup::init(FL_OBJECT * ob, size_type value)
{
- map.push_back(ButtonValuePair(button, value));
-}
-
-
-void RadioButtonGroup::reset()
-{
- map.clear();
+ map.push_back(ButtonValuePair(ob, value));
}
find_if(map.begin(), map.end(),
lyx::equal_2nd_in_pair<ButtonValuePair>(value));
- // If we found nothing, report it and return
- if (it == map.end()) {
- lyxerr << "BUG: Requested value in RadioButtonGroup doesn't exists"
- << endl;
- }
- else {
- fl_set_button(it->first, 1);
+ if (it != map.end()) {
+ set(it->first);
+ } else {
+ // We found nothing: report it and do nothing.
+ lyxerr << "BUG: Requested value in RadioButtonGroup "
+ "doesn't exist" << endl;
}
+}
+
+void RadioButtonGroup::set(FL_OBJECT * ob)
+{
+ fl_set_button(ob, 1);
}
RadioButtonGroup::size_type RadioButtonGroup::get() const
{
- // Find the first button that is active
+ // Find the active button.
ButtonValueMap::const_iterator it =
find_if(map.begin(), map.end(),
is_set_button<ButtonValuePair> ());
- // If such a button was found, return its value.
- if (it != map.end()) {
+ if (it != map.end())
return it->second;
- }
-
- lyxerr << "BUG: No radio button found to be active." << endl;
- // Else return 0.
+ // We found nothing: report it and return 0
+ lyxerr << "BUG: No active radio button found." << endl;
return 0;
}
* Licence details can be found in the file COPYING.
*
* \author Baruch Even
+ * \author Rob Lahaye
*
* Full author contact details are available in file CREDITS
*/
#include <utility>
#include "forms_fwd.h"
-/** This class simplifies the work with a group of radio buttons,
- * the idea is that you register a bunch of radio buttons with the accompanying
- * value for each radio button and then you get to query or set the active
- * button in a single function call.
+/** This class simplifies interaction with a group of radio buttons:
+ * one, and only one, can be selected.
+ * The idea is that you register a bunch of radio buttons with
+ * an accompanying value. Then you can get or set the active button with a
+ * single function call.
+ * It is necessary to also group a family of radio buttons in the
+ * corresponding .fd file in order to unset the previously chosen button
+ * when a new one is selected.
*/
class RadioButtonGroup {
public:
///
typedef lyx::size_type size_type;
- /// Constructor. Allocate space for 'n' items in the group.
- RadioButtonGroup(unsigned n = 5) : map(n) {};
+ /// Register a radio button with its corresponding value.
+ void init(FL_OBJECT * ob, size_type value);
- /// Register a radio button with it's corresponding value.
- void init(FL_OBJECT * button, size_type value);
- /// Reset registrations.
- void reset();
-
- // Set the active button.
+ // Set a single active button.
void set(size_type value);
+ void set(FL_OBJECT * ob);
- // Get the active button.
+ // Get the active button's value.
size_type get() const;
private:
#include <algorithm>
#include <fstream>
#include <vector>
+
#include FORMS_H_LOCATION
using std::ofstream;
{
if (enable) {
fl_activate_object(ob);
- fl_set_object_lcol(ob, FL_BLACK);
+ fl_set_object_lcol(ob, FL_LCOL);
} else {
fl_deactivate_object(ob);
fl_set_object_lcol(ob, FL_INACTIVE);
///
string const getString(FL_OBJECT * ob, int line)
{
- char const * tmp = 0;
+ // Negative line value does not make sense.
+ lyx::Assert(line >= 0);
+ char const * tmp = 0;
switch (ob->objclass) {
case FL_INPUT:
- lyx::Assert(line == -1);
tmp = fl_get_input(ob);
break;
+
case FL_BROWSER:
- if (line == -1)
+ if (line == 0)
line = fl_get_browser(ob);
if (line >= 1 && line <= fl_get_browser_maxline(ob))
break;
case FL_CHOICE:
- if (line == -1)
+ if (line == 0)
line = fl_get_choice(ob);
if (line >= 1 && line <= fl_get_choice_maxitems(ob))
lyx::Assert(0);
}
- return (tmp) ? trim(tmp) : string();
+ return tmp ? trim(tmp) : string();
}
string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice)
if (length.empty())
return string();
- //don't return unit-from-choice if the input(field) contains a unit
+ // don't return unit-from-choice if the input(field) contains a unit
if (isValidGlueLength(length))
return length;
/// Given an fl_choice or an fl_browser, create a vector of its entries
std::vector<string> const getVector(FL_OBJECT *);
-/// Given an fl_input, an fl_choice or an fl_browser, return an entry
-/** \c num is the position for the string, where -1 means "current item" */
-string const getString(FL_OBJECT * ob, int num = -1);
+/** Given an fl_input, an fl_choice or an fl_browser, return an entry
+ \c num is the position for the string, where 0 means "current item"
+ */
+string const getString(FL_OBJECT * ob, int num = 0);
/// Given input and choice widgets, create a string such as "1cm"
string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice);