]> git.lyx.org Git - features.git/commitdiff
(Rob Lahaye): miscellaneous bits 'n' bobs.
authorAngus Leeming <leeming@lyx.org>
Wed, 23 Oct 2002 08:31:10 +0000 (08:31 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 23 Oct 2002 08:31:10 +0000 (08:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5477 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/FeedbackController.C
src/frontends/xforms/FormGraphics.h
src/frontends/xforms/FormPrint.C
src/frontends/xforms/RadioButtonGroup.C
src/frontends/xforms/RadioButtonGroup.h
src/frontends/xforms/xforms_helpers.C
src/frontends/xforms/xforms_helpers.h

index 654cebb9575561d5e0acba6202bd895fb0246095..f53667e729199d8c237ba167a80abf1580262e42 100644 (file)
@@ -1,3 +1,21 @@
+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
index 01dcc2bf29e083844916663ace4b0bc1942ad734..12d44a675cfc7c505699ea7ca62a7e750f437fa9 100644 (file)
@@ -39,7 +39,7 @@ void FeedbackController::setMessageWidget(FL_OBJECT * ob)
 {
        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);
 }
 
 
@@ -140,10 +140,10 @@ void FeedbackController::postMessage(string const & message)
        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)
index 3facf82c76052c2adc2f4cba734437637103d22a..5f327a207d00478b3ec9d2433bfd1ac82945eeaf 100644 (file)
@@ -18,7 +18,6 @@
 #endif
 
 #include "FormBase.h"
-#include "RadioButtonGroup.h"
 
 #include <boost/scoped_ptr.hpp>
 
index 8d095390092a33312b5a1606d5249c5bb0ceea3e..05422954b6b13d2d01052df51b6d284897ea9b22 100644 (file)
@@ -34,8 +34,7 @@ using std::make_pair;
 typedef FormCB<ControlPrint, FormDB<FD_print> > base_class;
 
 FormPrint::FormPrint()
-       : base_class(_("Print")),
-         target_(2), which_pages_(2)
+       : base_class(_("Print"))
 {}
 
 
@@ -70,10 +69,8 @@ void FormPrint::build()
        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);
        
index 19e350c5f88deb00ad8f0772c29f7ccabd64793c..0d9531e2fd70ee3d71c62b394af2716634420946 100644 (file)
@@ -6,6 +6,7 @@
  * 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));
 }
 
 
@@ -49,15 +42,19 @@ void RadioButtonGroup::set(size_type 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);
 }
 
 
@@ -72,18 +69,15 @@ struct is_set_button {
 
 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;
 }
index 0236b8fe5abc1162a4eb07f6e38c56fcd4d74c66..603e82b4307bbedaabca76ff547382f7dcb7a383 100644 (file)
@@ -6,6 +6,7 @@
  * 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:
index bf9ce980746c0140a399fbbd1ab0134215b7d790..fab98d9d8d704ed4687613ab726da3918fc93d3f 100644 (file)
@@ -29,6 +29,7 @@
 #include <algorithm>
 #include <fstream>
 #include <vector>
+
 #include FORMS_H_LOCATION
 
 using std::ofstream;
@@ -46,7 +47,7 @@ void setEnabled(FL_OBJECT * ob, bool enable)
 {
        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);
@@ -83,15 +84,17 @@ vector<string> const getVector(FL_OBJECT * ob)
 ///
 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))
@@ -99,7 +102,7 @@ string const getString(FL_OBJECT * ob, int line)
                break;
 
        case FL_CHOICE:
-               if (line == -1)
+               if (line == 0)
                        line = fl_get_choice(ob);
 
                if (line >= 1 && line <= fl_get_choice_maxitems(ob))
@@ -110,7 +113,7 @@ string const getString(FL_OBJECT * ob, int line)
                lyx::Assert(0);
        }
 
-       return (tmp) ? trim(tmp) : string();
+       return tmp ? trim(tmp) : string();
 }
 
 string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice)
@@ -123,7 +126,7 @@ 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;
 
index c413697f9e4d80defe1cfcd9a5c48316e925c7cb..cccfeb6f86255b66aad98f7688741a0025e606a0 100644 (file)
@@ -45,9 +45,10 @@ string formatted(string const &label, int w,
 /// 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);