mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
(Rob Lahaye): miscellaneous bits 'n' bobs.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5477 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
357ece3f85
commit
fe66fc4644
@ -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
|
||||
|
@ -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)
|
||||
|
@ -18,7 +18,6 @@
|
||||
#endif
|
||||
|
||||
#include "FormBase.h"
|
||||
#include "RadioButtonGroup.h"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
@ -22,24 +23,16 @@
|
||||
#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;
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
@ -23,28 +24,28 @@
|
||||
#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:
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user