]> git.lyx.org Git - features.git/commitdiff
Color patch from Angus, KDE patch from Johnm menu patch from Rob, and the usual unint...
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 10 Nov 2000 17:29:47 +0000 (17:29 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 10 Nov 2000 17:29:47 +0000 (17:29 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1211 a592a061-630c-0410-9148-cb99ea01b6c8

28 files changed:
ChangeLog
lib/Makefile.am
lib/ui/default.ui
po/POTFILES.in
src/LyXView.C
src/bufferlist.C
src/frontends/DialogBase.h
src/frontends/Dialogs.h
src/frontends/kde/Dialogs.C
src/frontends/kde/Makefile.am
src/frontends/xforms/Color.C [new file with mode: 0644]
src/frontends/xforms/Color.h [new file with mode: 0644]
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormBase.C
src/frontends/xforms/FormBase.h
src/frontends/xforms/FormDocument.C
src/frontends/xforms/FormDocument.h
src/frontends/xforms/FormParagraph.C
src/frontends/xforms/FormParagraph.h
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/FormPreferences.h
src/frontends/xforms/FormTabular.C
src/frontends/xforms/FormTabular.h
src/frontends/xforms/Makefile.am
src/frontends/xforms/form_preferences.C
src/frontends/xforms/form_preferences.h
src/frontends/xforms/forms/form_preferences.fd
src/lyx_cb.C

index d800b58e098fbcac0e95ad46047dfbb23f39848a..9dd6c6b9d9f37abf36f5c264bc2535773aa129e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,76 @@
+2000-11-10  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * src/frontends/xforms/Color.C: include <algorithm> and <cmath>
+       headers. 
+
+       * lib/Makefile.am (DOCINST): do not install everything in the
+       documentation directory.
+
+2000-11-10  John Levon  <moz@compsoc.man.ac.uk>
+
+       * src/bufferlist.C (newFile): set the filename to the constructed
+       newfileXX.lyx
+
+       * src/lyx_cb.C (MenuWriteAs): if a buffer is "unnamed", pass the
+       constructed "newfileXX.lyx" name to the dialog
+
+       * src/frontends/DialogBase.h: make update() non-abstract so
+       KDE doesn't need to implement two update methods for every form
+
+       * src/frontends/kde/Makefile.am: add missing xforms objects
+       to compile again
+
+       * src/frontends/kde/Dialogs.C: Add FormTabularCreate dialog
+
+2000-11-09  Angus Leeming <a.leeming@ic.ac.uk>
+
+       * src/frontends/xforms/Color.[Ch]: new files, defining the color
+       structs RGB and HSV. May not be the best place for these files.
+       Perhaps move them into src ?
+
+       * src/frontends/xforms/Makefile.am: added new files.
+
+       * src/frontends/xforms/forms/form_preferences.fd:
+       * src/frontends/xforms/FormPreferences.[Ch]: bowed to reality and
+       replaced all instances of "colour" with "color"!
+
+       * src/frontends/xforms/forms/form_preferences.fd: modified Colors tab
+       slightly yet again.
+
+       * src/frontends/xforms/FormPreferences.[Ch]: functioning Colors
+       tab. Can now alter the colors of the xform's GUI on the fly. With
+       the aid of a single static Signal (see below), can "Apply" these
+       changes to all currently open dialogs. (Well, to all of the NEW
+       dialogs and to LyXView. The OLD dialogs are not yet redrawn.) ALL
+       subsequently opened dialogs will, of course, also have the new
+       color scheme. Cannot yet save (or load) the choices to file, so
+       they are lost when exiting LyX.
+       
+       * src/frontends/Dialogs.h:
+       * src/frontends/xforms/Dialogs.C (redrawGUI): new static Signal.
+       Used to trigger a redraw of any dialogs connected to it because,
+       for example, the GUI colours have been re-mapped.
+
+       * src/frontends/xforms/FormBase.[Ch]:
+       * src/frontends/xforms/FormDocument.[Ch]:
+       * src/frontends/xforms/FormParagraph.[Ch]:
+       * src/frontends/xforms/FormPreferences.[Ch]:
+       * src/frontends/xforms/FormTabular.[Ch]: (redraw): new virtual
+       method, to be connected to Dialogs::redrawGUI. Method must be
+       virtual, because dialogs with tabbed folders need to redraw the
+       forms of each tab folder.
+
+       * src/LyXView.C (d-tor):
+       * src/frontends/xforms/FormBase.C (d-tor): connected
+       Dialogs::redrawGUI signal to redraw().
+
+       * src/frontends/xforms/FormBase.C (~FormBaseBI, ~FormBaseBD):
+       removed Assert, because it is identical to that in FormBase.
+
+2000-11-10  Rob Lahaye <lahaye@postech.edu>
+
+       * lib/ui/default.ui: minor polishing.
+
 2000-11-10  Juergen Vigna  <jug@sad.it>
 
        * src/insets/insettext.C (resizeLyXText): check !cache[bv]
        (form_formats): added a "Shortcut" input field. Note that we can't use
        names such as "input_shortcut" as this buggers up the sed script stuff.
 
-       * src/frontends/xforms/FormPreferences.C
-                                     
 2000-11-07  Angus Leeming <a.leeming@ic.ac.uk>
 
        * src/LaTeXLog.C:
index cc909b69272fd3895f85607850fb754a81027372..c135f55529c8fbced5b62a861a116bbab7b66b69 100644 (file)
@@ -9,7 +9,7 @@ bin_SCRIPTS = listerrors
 BIND = bind/*.bind
 CLIPART = clipart/*.eps
 DOCDIST = doc/LyXConfig.lyx*
-DOCINST = doc/*
+DOCINST = doc/*.lyx doc/*.eps doc/*.lyx.in
 EXAMPLES = examples/*.lyx
 IMAGES = images/*.xpm
 KBD = kbd/*.kmap kbd/*.cdef
index bf34d925d3b79dc60a506a710188600344787f7f..404581856702f3f1fb874422f4f1df83f422b9eb 100644 (file)
@@ -107,12 +107,13 @@ Menuset
        Separator
        Item "Find & Replace...|F" "find-replace"
        Separator
-       Submenu "Floats & Insets|I" "edit_floats"
        Submenu "Tabular|T" "edit_tabular"
+       Submenu "Floats & Insets|I" "edit_floats"
        Item "Spellchecker...|S" "spellchecker"
        Item "Check TeX|h" "buffer-chktex"
+       Item "Remove all Error boxes|E" "error-remove-all"
        Separator
-       Item "Preferences...|e" "dialog-preferences"
+       Item "Preferences...|n" "dialog-preferences"
        Item "Reconfigure|g" "reconfigure"
     End
 
@@ -124,12 +125,10 @@ Menuset
     Menu "edit_floats"
        Item "Open/Close|O" "open-stuff"
        Item "Melt|M" "melt"
-       Item "Open All Footnotes/Margin Notes|A" "floats-operate openfoot"
-       Item "Close All Footnotes/Margin Notes|C" "floats-operate closefoot"
        Item "Open All Figures/Tables|F" "floats-operate openfig"
        Item "Close All Figures/Tables|T" "floats-operate closefig"
-       Separator
-       Item "Remove all Error Boxes|R" "error-remove-all"
+       Item "Open All Footnotes/Margin Notes|A" "floats-operate openfoot"
+       Item "Close All Footnotes/Margin Notes|C" "floats-operate closefoot"
     End
 
     Menu "edit_tabular"
@@ -160,8 +159,8 @@ Menuset
 #
     Menu "insert"
        Item "Math text|M" "math-mode"
-       Item "Math Display|D" "math-display"
-       Item "Math Panel...|P" "math-panel"
+       Item "Math display|d" "math-display"
+       Item "Math panel...|p" "math-panel"
        Separator
        Submenu "Special character|S" "insert_special"
        Item "Citation reference...|C" "citation-insert"
@@ -182,8 +181,8 @@ Menuset
     End
 
     Menu "insert_special"
-       Item "Subscript|S" "math-insert _"
-       Item "Superscript|u" "math-insert ^"
+       Item "Superscript|S" "command-sequence math-insert ^;math-mode;"
+       Item "Subscript|u" "command-sequence math-insert _;math-mode;"
        Item "HFill|H" "hfill-insert"
        Item "Hyphenation point|p" "hyphenation-point-insert"
        Item "Protected blank|b" "protected-space-insert"
@@ -264,6 +263,9 @@ Menuset
        Documents
     End
 
+#
+# HELP MENU
+#
     Menu "help"
        Item "Introduction|I" "help-open Intro"
        Item "Tutorial|T" "help-open Tutorial"
index cfcf30161702ce831e6a246162c5ebeb468f4f14..34bedb079b11a47e7898dbe31e1959521149470a 100644 (file)
@@ -11,7 +11,6 @@ src/credits.C
 src/credits_form.C
 src/CutAndPaste.C
 src/exporter.C
-src/ext_l10n.h
 src/filedlg.C
 src/FontLoader.C
 src/form1.C
index 850fa02af1e21b30fe866d51a53f3f5a8aa64ddf..f99b062e505ce576521502629708124fb070fda7 100644 (file)
@@ -74,6 +74,7 @@ LyXView::LyXView(int width, int height)
                .connect(slot(&updateAllVisibleBufferRelatedDialogs));
        dialogs_->hideBufferDependent
                .connect(slot(&CloseAllBufferRelatedDialogs));
+       Dialogs::redrawGUI.connect(slot(this, &LyXView::redraw));
 }
 
 
index fe8dba7576d3b02e4482e89349db3e56d4060c7d..99fcd4dd45370d9258f30b3f90e9e55a4c989e60 100644 (file)
@@ -456,10 +456,11 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed)
                b->paragraph = new LyXParagraph;
        }
 
-       if (!lyxrc.new_ask_filename) {
-               if (!isNamed)
-                       b->setUnnamed();
+       if (!lyxrc.new_ask_filename && !isNamed) {
+               b->setUnnamed();
+               b->setFileName(name);
        }
+
        b->setReadonly(false);
        
        return b;
index 5ef76e4d1445b4550aecc47bedd5d011a9883ba0..07fa8732cd742ee810e26900fbfcc7b7fb519b5e 100644 (file)
@@ -51,7 +51,7 @@ public:
        ///
        virtual void hide() = 0;
        ///
-       virtual void update() = 0;
+       virtual void update() {};
        //@}
 };
 
index b8efb4d323c99501a07bf5bc2f05798ccf1571e9..8e7511842f901d07d0d9b729e150ecbf902f90f6 100644 (file)
@@ -60,6 +60,10 @@ public:
        ~Dialogs();
        //@}
        
+       /** Redraw all visible popups because, for example, the GUI colours
+           have been re-mapped. */
+       static Signal0<void> redrawGUI;
+
        /**@name Global Hide and Update Signals */
        //@{
        /// Hide all visible popups
@@ -145,11 +149,3 @@ private:
 };
 
 #endif
-
-
-
-
-
-
-
-
index 0aaea3fcf9f342d039ac1cbb82c9396e6e6b8f11..0892d444b5ce74ae53d0ebd16408151bc0c8c382 100644 (file)
@@ -13,6 +13,7 @@
 #include "FormPrint.h"
 #include "FormRef.h"
 #include "FormTabular.h"
+#include "FormTabularCreate.h"
 #include "FormToc.h"
 #include "FormUrl.h"
 
@@ -37,6 +38,7 @@ Dialogs::Dialogs(LyXView * lv)
        dialogs_.push_back(new FormPrint(lv, this));
        dialogs_.push_back(new FormRef(lv, this));
        dialogs_.push_back(new FormTabular(lv, this));
+       dialogs_.push_back(new FormTabularCreate(lv, this));
        dialogs_.push_back(new FormToc(lv, this));
        dialogs_.push_back(new FormUrl(lv, this));
 
index 8b9fe1639a67133e24061175e62334eecf32cda9..5b9f94e59ba1194790cbeab476eefb9c8bcb837b 100644 (file)
@@ -51,6 +51,10 @@ libkde_la_OBJADD = \
         ../xforms/form_preferences.lo \
         ../xforms/FormTabular.lo \
         ../xforms/form_tabular.lo \
+       ../xforms/FormTabularCreate.lo \
+       ../xforms/form_tabular_create.lo \
+       ../xforms/ButtonController.lo \
+       ../xforms/xform_helpers.lo \
         ../xforms/input_validators.lo \
         ../xforms/RadioButtonGroup.lo \
         ../xforms/Toolbar_pimpl.lo \
diff --git a/src/frontends/xforms/Color.C b/src/frontends/xforms/Color.C
new file mode 100644 (file)
index 0000000..e69f91f
--- /dev/null
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *      
+ *         Copyright 1995 Matthias Ettrich
+ *          Copyright 1995-2000 The LyX Team.
+ *
+ *======================================================*/
+
+#include <config.h>
+
+#ifdef __GNUG_
+#pragma implementation
+#endif
+
+#include <algorithm> // max
+#include <cmath> // floor
+#include "Color.h"
+
+using std::max;
+using std::min;
+
+static int const nohue = -1;
+
+RGB::RGB( HSV const & hsv )
+{
+       double h = hsv.h;
+       double s = hsv.s;
+       double v = hsv.v;
+       
+       double rd, gd, bd;
+       
+       if( h == nohue || s == 0.0 ) {
+               rd = gd = bd = v;
+       } else {
+               if( h == 360.0 ) h = 0.0;
+               h /= 60.0;
+
+               int j = static_cast<int>( ::floor(h) );
+               if( j < 0 ) j = 0;
+
+               double f = h - j;
+               double p = v * (1.0 - s);
+               double q = v * (1.0 - (s*f));
+               double t = v * (1.0 - (s*(1.0 - f)));
+
+               switch( j ) {
+               case 0:
+                       rd = v;
+                       gd = t;
+                       bd = p;
+                       break;
+               case 1:
+                       rd = q;
+                       gd = v;
+                       bd = p;
+                       break;
+               case 2:
+                       rd = p;
+                       gd = v;
+                       bd = t;
+                       break;
+               case 3:
+                       rd = p;
+                       gd = q;
+                       bd = v;
+                       break;
+               case 4:
+                       rd = t;
+                       gd = p;
+                       bd = v;
+                       break;
+               case 5:
+                       rd = v;
+                       gd = p;
+                       bd = q;
+                       break;
+               default:
+                       rd = v;
+                       gd = t;
+                       bd = p;
+                       break;  // should never happen.
+               }
+       }
+
+       r = static_cast<int>( ::floor((rd * 255.0) + 0.5) );
+       g = static_cast<int>( ::floor((gd * 255.0) + 0.5) );
+       b = static_cast<int>( ::floor((bd * 255.0) + 0.5) );
+}
+
+
+HSV::HSV( RGB const & rgb )
+{
+       // r, g, b lie in the range 0-1, not 0-255.
+       double r = rgb.r / 255.0;
+       double g = rgb.g / 255.0;
+       double b = rgb.b / 255.0;
+
+       double maxval = max( max( r, g ), b );
+       double minval = max( min( r, g ), b );
+
+       v = maxval;
+
+       double diff = maxval - minval;
+       if( maxval != 0.0 )
+               s = diff / maxval;
+       else
+               s = 0.0;
+
+       h = nohue;
+       if( s != 0.0 ) {
+               double rc = (maxval - r) / diff;
+               double gc = (maxval - g) / diff;
+               double bc = (maxval - b) / diff;
+
+               if( r == maxval )
+                       h = bc - gc;
+               else if( g == maxval )
+                       h = 2.0 + rc - bc;
+               else if( b == maxval )
+                       h = 4.0 + gc - rc;
+
+               h *= 60.0;
+               if ( h < 0 )
+                       h += 360;
+       }
+}
+
diff --git a/src/frontends/xforms/Color.h b/src/frontends/xforms/Color.h
new file mode 100644 (file)
index 0000000..50ca142
--- /dev/null
@@ -0,0 +1,68 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *      
+ *         Copyright 1995 Matthias Ettrich
+ *          Copyright 1995-2000 The LyX Team.
+ *
+ *======================================================*/
+
+#ifndef COLOR_H
+#define COLOR_H
+
+#include<utility> // for pair
+
+#ifdef __GNUG_
+#pragma interface
+#endif
+
+#include "LString.h"
+
+class HSV;
+class RGB;
+
+struct HSV {
+       double h;
+       double s;
+       double v;
+       HSV() : h(0.0), s(0.0), v(0.0) {}
+       HSV(double hue, double sat, double val) : h(hue), s(sat), v(val) {}
+       HSV( RGB const & );
+};
+
+struct RGB {
+       int r;
+       int g;
+       int b;
+       RGB() : r(0), g(0), b(0) {}
+       RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
+       RGB( HSV const & );
+};
+
+typedef std::pair<string, RGB> X11Color;
+
+/// struct holding xform-specific colors
+struct XFormColor {
+       string name;
+       int colorID;
+       RGB col;
+       XFormColor() : colorID(0) {}
+       string const getname() { return name; }
+};
+
+inline
+bool operator==(RGB const & c1, RGB const & c2)
+{
+       return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
+}
+
+
+inline
+bool operator!=(RGB const & c1, RGB const & c2)
+{
+       return !(c1 == c2);
+}
+
+#endif
index f7603e384423a7105f91a3801e5615ea9e0b73b5..4b272397c9fef4fc834520b782c1a3dffea13df1 100644 (file)
 extern void ShowCredits();
 
 
+// Signal enabling all visible popups to be redrawn if so desired.
+// E.g., when the GUI colours have been remapped.
+Signal0<void> Dialogs::redrawGUI;
+
+
 Dialogs::Dialogs(LyXView * lv)
 {
        dialogs_.push_back(new FormCitation(lv, this));
index 2adf40dbac5430b72139b08ed1c1f49965c26400..2df152677a5566e6343864d6c53be68c8d7f877b 100644 (file)
@@ -48,6 +48,7 @@ FormBase::FormBase(LyXView * lv, Dialogs * d, string const & t,
          minw_(0), minh_(0)
 {
        Assert(lv && d && bp);
+       Dialogs::redrawGUI.connect(slot(this, &FormBase::redraw));
 }
 
 
@@ -57,6 +58,13 @@ FormBase::~FormBase()
 }
 
 
+void FormBase::redraw()
+{
+       if( form() && form()->visible )
+               fl_redraw_form( form() );
+}
+
+
 void FormBase::connect()
 {
        fl_set_form_minsize( form(), minw_, minh_ );
@@ -166,9 +174,7 @@ FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
                       ButtonPolicy * bp,
                       char const * close, char const * cancel)
        : FormBase( lv, d, t, bp, close, cancel )
-{
-       Assert(lv && d && bp);
-}
+{}
 
 
 void FormBaseBI::connect()
@@ -189,9 +195,7 @@ FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
                       char const * close, char const * cancel)
        : FormBase( lv, d, t, bp, close, cancel ),
          u_(0)
-{
-       Assert(lv && d && bp);
-}
+{}
 
 
 void FormBaseBD::connect()
index 6819daa863518a7cf4d8c63baad0e4db9f973989..78d6e03d1c7c1b9ff8b2a624767a7587573c607c 100644 (file)
@@ -18,6 +18,7 @@
 #include FORMS_H_LOCATION
 #include "ButtonController.h"
 #include "gettext.h"
+#include <sigc++/signal_system.h> // temporary
 
 class Buffer;
 class Dialogs;
@@ -32,6 +33,7 @@ class LyXView;
     and FormBaseBD.
     @author Angus Leeming
  */
+
 class FormBase : public DialogBase, public noncopyable {
 public:
        /// Callback functions
@@ -48,14 +50,19 @@ public:
        static void RestoreCB(FL_OBJECT *, long);
 
 protected: // methods
-       /** Constructor.
-           #FormBase(lv, d, _("DialogName"), BUFFER_DEPENDENT, new ButtonPolicy)#
-        */
+       ///
        FormBase(LyXView *, Dialogs *, string const &,
                 ButtonPolicy *, char const *, char const *);
        ///
        virtual ~FormBase();
 
+       /** Redraw the form (on receipt of a Signal indicating, for example,
+           that the xform colours have been re-mapped).
+           Must be virtual because dialogs with tabbed folders will need to
+           redraw the form for each tab.
+       */
+       virtual void redraw();
+
        /// Create the dialog if necessary, update it and display it.
        void show();
        /// Hide the dialog.
index dbeb3642163db823e32ada1e1f95decd80753249..62591159cb1574d617c6c290922441c36a7f8152 100644 (file)
@@ -73,6 +73,19 @@ FormDocument::~FormDocument()
 }
 
 
+void FormDocument::redraw()
+{
+       if( form() && form()->visible )
+               fl_redraw_form( form() );
+       else
+               return;
+
+       FL_FORM * outer_form = fl_get_active_folder(dialog_->tabbed_folder);
+       if (outer_form && outer_form->visible)
+               fl_redraw_form( outer_form );
+}
+
+
 FL_FORM * FormDocument::form() const
 {
     if (dialog_) return dialog_->form;
index 2805d4cf763b0cf0dc78305241c6a6b97ca0e165..566f3acd432ea554c1b04cae4f9bf37987cac81b 100644 (file)
@@ -79,6 +79,9 @@ private:
                ///
                BULLETBMTABLE
        };
+       /** Redraw the form (on receipt of a Signal indicating, for example,
+           that the xform colours have been re-mapped). */
+       virtual void redraw();
        /// Build the dialog
        virtual void build();
        /// Filter the inputs
index 67f49a8d430474781abcab76ab418aada9e1bc4d..1c32134fd8e19448d0946d66d697a36b50f541cb 100644 (file)
@@ -49,6 +49,19 @@ FormParagraph::~FormParagraph()
 }
 
 
+void FormParagraph::redraw()
+{
+       if( form() && form()->visible )
+               fl_redraw_form( form() );
+       else
+               return;
+
+       FL_FORM * outer_form = fl_get_active_folder(dialog_->tabbed_folder);
+       if (outer_form && outer_form->visible)
+               fl_redraw_form( outer_form );
+}
+
+
 FL_FORM * FormParagraph::form() const
 {
     if (dialog_) return dialog_->form;
index 3e6d1b105d2690dee34a409b498bdde31a4ed112..c8458eb64a14d1db732945d41b0a82b742a473ba 100644 (file)
@@ -35,6 +35,9 @@ public:
        ~FormParagraph();
 
 private:
+       /** Redraw the form (on receipt of a Signal indicating, for example,
+           that the xform colours have been re-mapped). */
+       virtual void redraw();
        /// Build the popup
        virtual void build();
        /// Apply from popup
index f06e75480c58c0c019facebfd0f9d84f01f894b0..84abfb05959e59287019a53b953463ad725793dd 100644 (file)
@@ -47,8 +47,9 @@ extern string fmt(char const * fmtstr ...);
 extern string system_lyxdir;
 extern Languages languages;
 
-static string const colourFile("/usr/lib/X11/rgb.txt");
-vector<FormPreferences::X11Colour> FormPreferences::colourDB;
+static string const colorFile("/usr/lib/X11/rgb.txt");
+vector<X11Color> FormPreferences::colorDB;
+vector<XFormColor> FormPreferences::xformColorDB;
 pair<vector<string>, vector<string> > FormPreferences::dirlist;
 
 // Two functions used to help sort a vector<Command> and a vector<Format>.
@@ -73,7 +74,7 @@ FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
          dialog_(0),
          converters_tab_(0), inputs_tab_(0), look_n_feel_tab_(0),
          outputs_tab_(0),  usage_tab_(0),
-         colours_(0), converters_(0), formats_(0), inputs_misc_(0),
+         colors_(0), converters_(0), formats_(0), inputs_misc_(0),
          interface_(0), language_(0), lnf_misc_(0), outputs_misc_(0),
          paths_(0), printer_(0), screen_fonts_(0), spellchecker_(0),
          combo_default_lang(0), combo_kbmap_1(0), combo_kbmap_2(0),
@@ -92,7 +93,7 @@ FormPreferences::~FormPreferences()
        delete combo_kbmap_1;
        delete combo_kbmap_2;
 
-       delete colours_;
+       delete colors_;
        delete converters_;
        delete formats_;
        delete inputs_misc_;
@@ -115,6 +116,42 @@ FormPreferences::~FormPreferences()
 }
 
 
+void FormPreferences::redraw()
+{
+       if( form() && form()->visible )
+               fl_redraw_form( form() );
+       else
+               return;
+
+       FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
+       if (outer_form && outer_form->visible)
+               fl_redraw_form( outer_form );
+       else
+               return;
+
+       if( outer_form == converters_tab_->form )
+               outer_form =
+                       fl_get_active_folder(converters_tab_->tabfolder_outer);
+
+       else if( outer_form == look_n_feel_tab_->form )
+               outer_form =
+                       fl_get_active_folder(look_n_feel_tab_->tabfolder_outer);
+
+       else if( outer_form == inputs_tab_->form )
+               outer_form = fl_get_active_folder(inputs_tab_->tabfolder_outer);
+
+       else if( outer_form == outputs_tab_->form )
+               outer_form = 
+                       fl_get_active_folder(outputs_tab_->tabfolder_outer);
+
+       else if( outer_form == usage_tab_->form )
+               outer_form = fl_get_active_folder(usage_tab_->tabfolder_outer);
+
+       if (outer_form && outer_form->visible)
+               fl_redraw_form( outer_form );
+}
+
+
 FL_FORM * FormPreferences::form() const
 {
        if (dialog_) return dialog_->form;
@@ -166,7 +203,7 @@ void FormPreferences::build()
 
        // build actual tabfolder contents
        // these will become nested tabfolders
-       buildColours();
+       buildColors();
        buildConverters();
        buildFormats();
        buildInputsMisc();
@@ -205,8 +242,8 @@ void FormPreferences::build()
                           _("Interface"),
                           interface_->form);
        fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
-                          _("Colours"),
-                          colours_->form);
+                          _("Colors"),
+                          colors_->form);
        fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
                           _("Misc"),
                           lnf_misc_->form);
@@ -258,7 +295,7 @@ void FormPreferences::apply()
        // like update the screen fonts because that flushes the textcache
        // and other stuff which may cost us a lot on slower/high-load machines.
 
-       applyColours();
+       applyColors();
        applyConverters();
        applyFormats();
        applyInputsMisc();
@@ -279,8 +316,8 @@ void FormPreferences::feedback( FL_OBJECT * ob )
 
        string str;
 
-       if (ob->form->fdui == colours_) {
-               str = feedbackColours( ob );
+       if (ob->form->fdui == colors_) {
+               str = feedbackColors( ob );
        } else if (ob->form->fdui == converters_) {
                str = feedbackConverters( ob );
        } else if (ob->form->fdui == formats_) {
@@ -321,8 +358,8 @@ bool FormPreferences::input(FL_OBJECT * ob, long)
        // some totally ridiculous value somewhere.  Change activate to suit.
        // comments before each test describe what is _valid_
 
-       if (ob->form->fdui == colours_)
-               return inputColours(ob);
+       if (ob->form->fdui == colors_)
+               return inputColors(ob);
        else if (ob->form->fdui == converters_)
                return inputConverters(ob);
        else if (ob->form->fdui == language_)
@@ -336,7 +373,7 @@ bool FormPreferences::input(FL_OBJECT * ob, long)
        else if (ob->form->fdui == formats_)
                return inputFormats(ob);
 
-       return false;
+       return true;
 }
 
 
@@ -345,7 +382,7 @@ void FormPreferences::update()
        if (!dialog_) return;
     
        // read lyxrc entries
-       updateColours();
+       updateColors();
        updateConverters();
        updateFormats();
        updateInputsMisc();
@@ -360,100 +397,291 @@ void FormPreferences::update()
 }
 
 
-void FormPreferences::applyColours() const
+void FormPreferences::applyColors() const
 {
+       bool modifiedXForms = false;
+       bool modifiedText = false;
+       bool modifiedBackground = false;
+
+       for( vector<XFormColor>::const_iterator cit = xformColorDB.begin();
+            cit != xformColorDB.end(); ++cit ) {
+               RGB col;
+               fl_getmcolor((*cit).colorID, &col.r, &col.g, &col.b);
+               if( col != (*cit).col ) {
+                       modifiedXForms = true;
+                       if( (*cit).colorID == FL_BLACK )
+                               modifiedText = true;
+                       if( (*cit).colorID == FL_COL1 )
+                               modifiedBackground = true;
+               }
+       }
+
+       if( modifiedXForms ) {
+               vector<XFormColor>::const_iterator cit;
+               for( cit = xformColorDB.begin(); 
+                    cit != xformColorDB.end(); ++cit ) {
+                       fl_mapcolor((*cit).colorID,
+                                   (*cit).col.r, (*cit).col.g, (*cit).col.b);
+
+                       if( modifiedText && (*cit).colorID == FL_BLACK ) {
+                               ColorsAdjustVal( FL_INACTIVE, FL_BLACK, 0.5 );
+                       }
+
+                       if( modifiedBackground && (*cit).colorID == FL_COL1 ) {
+                               ColorsAdjustVal( FL_MCOL,      FL_COL1, 0.1 );
+                               ColorsAdjustVal( FL_TOP_BCOL,  FL_COL1, 0.1 );
+                               ColorsAdjustVal( FL_LEFT_BCOL, FL_COL1, 0.1 );
+
+                               ColorsAdjustVal( FL_RIGHT_BCOL,  FL_COL1, -0.5);
+                               ColorsAdjustVal( FL_BOTTOM_BCOL, FL_COL1, -0.5);
+                       }               
+               }
+               Dialogs::redrawGUI();
+       }
 }
 
 
-void FormPreferences::buildColours()
+void FormPreferences::buildColors()
 {
-       colours_ = build_colours();
+       colors_ = build_colors();
 
-       FL_OBJECT * obj = colours_->valslider_red;
+       FL_OBJECT * obj = colors_->valslider_red;
        fl_set_slider_bounds(obj, 0, 255);
        fl_set_slider_precision(obj, 0);
        fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
        
-       obj = colours_->valslider_green;
+       obj = colors_->valslider_green;
        fl_set_slider_bounds(obj, 0, 255);
        fl_set_slider_precision(obj, 0);
        fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
        
-       obj = colours_->valslider_blue;
+       obj = colors_->valslider_blue;
        fl_set_slider_bounds(obj, 0, 255);
        fl_set_slider_precision(obj, 0);
        fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
 
-       fl_set_object_color(colours_->button_colour,
+       fl_set_object_color(colors_->button_color,
                            FL_FREE_COL4, FL_FREE_COL4);
        
-       fl_set_input_return(colours_->input_name, FL_RETURN_END_CHANGED);
+       fl_set_input_return(colors_->input_name, FL_RETURN_END_CHANGED);
 
-       if (ColoursLoadBrowser(colourFile) )
-               fl_set_input(colours_->input_name, colourFile.c_str());
+       if (ColorsLoadBrowserX11(colorFile) )
+               fl_set_input(colors_->input_name, colorFile.c_str());
        else
-               fl_set_input(colours_->input_name, N_("No file found"));
+               fl_set_input(colors_->input_name, N_("No file found"));
+
+       ColorsLoadBrowserLyX();
 
        // deactivate the browse button because it isn't implemented
-       fl_deactivate_object(colours_->button_browse);
-       fl_set_object_lcol(colours_->button_browse, FL_INACTIVE);
+       fl_deactivate_object(colors_->button_browse);
+       fl_set_object_lcol(colors_->button_browse, FL_INACTIVE);
 
        // set up the feedback mechanism
-       setPreHandler( colours_->browser_x11 );
-       setPreHandler( colours_->input_name );
-       setPreHandler( colours_->button_browse );
-       setPreHandler( colours_->button_colour );
-       setPreHandler( colours_->valslider_red );
-       setPreHandler( colours_->valslider_green );
-       setPreHandler( colours_->valslider_blue );
-       setPreHandler( colours_->browser_lyx_objs );
-       setPreHandler( colours_->button_modify );
+       setPreHandler( colors_->browser_x11 );
+       setPreHandler( colors_->input_name );
+       setPreHandler( colors_->button_browse );
+       setPreHandler( colors_->button_color );
+       setPreHandler( colors_->valslider_red );
+       setPreHandler( colors_->valslider_green );
+       setPreHandler( colors_->valslider_blue );
+       setPreHandler( colors_->browser_lyx_objs );
+       setPreHandler( colors_->button_modify );
 }
 
 
 string const
-FormPreferences::feedbackColours(FL_OBJECT const * const ob) const
+FormPreferences::feedbackColors(FL_OBJECT const * const ob) const
 {
-       return string();
+       string str;
+
+       if (ob == colors_->browser_x11 ) {
+               str = N_("The colors listed in the X11 database.");
+       } else if (ob == colors_->browser_lyx_objs ) {
+               str = N_("LyX objects that can be assigned a color.");
+       } else if (ob == colors_->input_name ) {
+               str = N_("The file containing the X11 color database.");
+       } else if (ob == colors_->button_color ) {
+               str = N_("You will only be able to modify the LyX object if the sliders and X11 browser agree. Force this by clicking on the highlighted browser name.");
+       } else if (ob == colors_->valslider_red
+                  || ob == colors_->valslider_green
+                  || ob == colors_->valslider_blue ) {
+               str = N_("Find a new color. The name highlighted in the X11 database is the closest match to this.");
+       } else if (ob == colors_->button_modify ) {
+               str = N_("Modify the color of the LyX object.");
+       }
+
+       return str;
 }
 
 
-bool FormPreferences::inputColours( FL_OBJECT const * const ob )
+bool FormPreferences::inputColors( FL_OBJECT const * const ob )
 {
-       bool activate = true;
+       if (ob == colors_->browser_x11) {
+               return ColorsBrowserX11();
+
+       } else if (ob == colors_->valslider_red
+                  || ob == colors_->valslider_green
+                  || ob == colors_->valslider_blue) {
+               return ColorsRGB();
+
+       } else if (ob == colors_->input_name) {
+               return ColorsDatabase();
+
+       } else if (ob == colors_->browser_lyx_objs) {
+               return ColorsBrowserLyX();
+               
+       } else if (ob == colors_->button_modify) {
+               return ColorsModify();
+       }
        
-       if (ob == colours_->browser_x11) {
-               int i = fl_get_browser(colours_->browser_x11);
-               if (i > 0) {
-                       ColoursUpdateBrowser(i-1);
-               }
+       return true;
+}
 
-       } else if (ob == colours_->valslider_red
-                  || ob == colours_->valslider_green
-                  || ob == colours_->valslider_blue) {
-               ColoursUpdateRGB();
-
-       } else if (ob == colours_->input_name) {
-               string file = fl_get_input(colours_->input_name);
-               if (ColoursLoadBrowser(file) )
-                       fl_set_input(colours_->input_name, file.c_str());
-               else if (ColoursLoadBrowser(colourFile) )
-                       fl_set_input(colours_->input_name, colourFile.c_str());
-               else
-                       fl_set_input(colours_->input_name, N_("No file found"));
+
+void FormPreferences::ColorsAdjustVal( int colAdjust, int colParent,
+                                      double addVal ) const
+{
+       RGB rgb;
+       fl_getmcolor( colParent, &rgb.r, &rgb.g, &rgb.b);
+
+       HSV hsv = HSV( rgb );
+       hsv.v += addVal;
+       if( hsv.v > 1.0 )
+               hsv.v = 1.0;
+       else if( hsv.v < 0.0 )
+               hsv.v = 0.0;
+
+       rgb = RGB( hsv );
+       fl_mapcolor( colAdjust, rgb.r, rgb.g, rgb.b );
+}
+
+
+bool FormPreferences::ColorsBrowserLyX() const
+{
+       int i = fl_get_browser( colors_->browser_lyx_objs );
+       if (i < 1)
+               return true;
+
+       string name = fl_get_browser_line( colors_->browser_lyx_objs, i );
+
+       vector<XFormColor>::const_iterator cit =
+               find_if(xformColorDB.begin(), xformColorDB.end(),
+                       compare_memfun(&XFormColor::getname, name));
+
+       if( cit != xformColorDB.end() ) {
+               fl_freeze_form( colors_->form );
+
+               fl_set_slider_value( colors_->valslider_red,   (*cit).col.r );
+               fl_set_slider_value( colors_->valslider_green, (*cit).col.g );
+               fl_set_slider_value( colors_->valslider_blue,  (*cit).col.b );
+               ColorsRGB();
+
+               fl_unfreeze_form( colors_->form );
        }
 
-       return activate;
+       fl_deactivate_object( colors_->button_modify );
+       fl_set_object_lcol( colors_->button_modify, FL_INACTIVE );
+
+       return true;
+}
+
+
+bool FormPreferences::ColorsBrowserX11() const
+{
+       int i = fl_get_browser(colors_->browser_x11);
+       if (i < 1)
+               return true;
+
+       fl_freeze_form( colors_->form );
+
+       RGB col = colorDB[i-1].second;
+    
+       fl_mapcolor( FL_FREE_COL4 + i, col.r, col.g, col.b );
+       fl_mapcolor( FL_FREE_COL4, col.r, col.g, col.b );
+       fl_set_slider_value( colors_->valslider_red,   col.r );
+       fl_set_slider_value( colors_->valslider_green, col.g );
+       fl_set_slider_value( colors_->valslider_blue,  col.b );
+       fl_redraw_object( colors_->button_color );
+
+       // Is it valid to activate the "Modify" button?
+       int line = fl_get_browser(colors_->browser_lyx_objs);
+       bool isSelected = ( line > 0 );
+       if( isSelected )
+               if( line > fl_get_browser_maxline(colors_->browser_lyx_objs) )
+                       isSelected = false;     
+
+       if( isSelected && colorDB[i-1].second == col ) {
+               fl_activate_object( colors_->button_modify );
+               fl_set_object_lcol( colors_->button_modify, FL_BLACK );
+       }
+       
+       fl_unfreeze_form( colors_->form );
+
+       return true;
 }
 
 
-bool FormPreferences::ColoursLoadBrowser(string const & filename)
+bool FormPreferences::ColorsDatabase() const
+{
+       string file = fl_get_input(colors_->input_name);
+       if (ColorsLoadBrowserX11(file) )
+               fl_set_input(colors_->input_name, file.c_str());
+       else if (ColorsLoadBrowserX11(colorFile) )
+               fl_set_input(colors_->input_name, colorFile.c_str());
+       else
+               fl_set_input(colors_->input_name, N_("No file found"));
+       return true;
+}
+
+
+void FormPreferences::ColorsLoadBrowserLyX()
+{
+       XFormColor xcol;
+
+       xcol.name = "GUI background";
+       xcol.colorID = FL_COL1;
+       fl_getmcolor(FL_COL1, &xcol.col.r, &xcol.col.g, &xcol.col.b);
+
+       xformColorDB.push_back( xcol );
+
+       xcol.name = "GUI text";
+       xcol.colorID = FL_BLACK;
+       fl_getmcolor(FL_BLACK, &xcol.col.r, &xcol.col.g, &xcol.col.b);
+
+       xformColorDB.push_back( xcol );
+
+       xcol.name = "GUI active tab";
+       xcol.colorID = FL_LIGHTER_COL1;
+       fl_getmcolor(FL_LIGHTER_COL1, &xcol.col.r, &xcol.col.g, &xcol.col.b);
+
+       xformColorDB.push_back( xcol );
+
+       xcol.name = "GUI push button";
+       xcol.colorID = FL_YELLOW;
+       fl_getmcolor(FL_YELLOW, &xcol.col.r, &xcol.col.g, &xcol.col.b);
+
+       xformColorDB.push_back( xcol );
+
+       FL_OBJECT * colbr = colors_->browser_lyx_objs;
+       fl_clear_browser( colbr );
+       for( vector<XFormColor>::const_iterator cit = xformColorDB.begin();
+            cit != xformColorDB.end(); ++cit ) {
+               fl_addto_browser(colbr, (*cit).name.c_str() );
+       }
+
+       fl_deselect_browser(colors_->browser_lyx_objs);
+       fl_deactivate_object( colors_->button_modify );
+       fl_set_object_lcol( colors_->button_modify, FL_INACTIVE );
+}
+
+
+bool FormPreferences::ColorsLoadBrowserX11(string const & filename) const
 {
        LyXLex lex(0, 0);
        lex.setCommentChar('!');
        
        if (!lex.setFile(filename))
-               return false;
+               return true;
 
        vector<RGB> cols;
        vector<string> names;
@@ -483,8 +711,8 @@ bool FormPreferences::ColoursLoadBrowser(string const & filename)
                                name = "white";
                        else
                                name = lowercase( name );
-                       
-                       if (name == "black" || name == "white") {
+
+                       if ( col == RGB(0,0,0) || col == RGB(255,255,255) ) {
                                cols.insert(cols.begin(), col);
                                names.insert(names.begin(), name);
                        } else {
@@ -494,101 +722,125 @@ bool FormPreferences::ColoursLoadBrowser(string const & filename)
                }
        }
        
+       FL_OBJECT * colbr = colors_->browser_x11;
+       fl_freeze_form(colors_->form);
+       fl_clear_browser( colbr );
+
        vector<string>::const_iterator sit = names.begin();
        for (vector<RGB>::const_iterator iit = cols.begin();
             iit != cols.end(); ++iit, ++sit) {
-               colourDB.push_back( X11Colour(*sit, *iit) );
+               colorDB.push_back( X11Color(*sit, *iit) );
+               fl_addto_browser(colbr, (*sit).c_str());
        }
        
-       FL_OBJECT * colbr = colours_->browser_x11;
-       fl_freeze_form(colours_->form);
-       fl_clear_browser( colbr );
-
-       for (vector<X11Colour>::const_iterator cit = colourDB.begin();
-            cit != colourDB.end(); ++cit) {
-               string name = (*cit).first;
-               //RGB col     = (*cit).second;
-               //name += "  (" + tostr(col.r) + ", " + tostr(col.g) +
-               //      ", " + tostr(col.b) + ")";
-               fl_addto_browser(colbr, name.c_str());
-       }
-
        fl_set_browser_topline(colbr, 1);
        fl_select_browser_line(colbr, 1);
-       ColoursUpdateBrowser(0);
-       fl_unfreeze_form(colours_->form);
+       ColorsBrowserX11();
+       fl_unfreeze_form(colors_->form);
        
        return true;
 }
 
 
-int FormPreferences::ColoursSearchEntry(RGB const & col) const
+bool FormPreferences::ColorsModify() const
 {
-       int mindiff = 0x7fffffff;
-       vector<X11Colour>::const_iterator mincit = colourDB.begin();
+       int i = fl_get_browser( colors_->browser_lyx_objs );
+       if (i < 1)
+               return true;
 
-       for (vector<X11Colour>::const_iterator cit = colourDB.begin();
-            cit != colourDB.end(); ++cit) {
-               RGB colDB = (*cit).second;
-               RGB diff;
-               diff.r = col.r - colDB.r;
-               diff.g = col.g - colDB.g;
-               diff.b = col.b - colDB.b;
+       string name = fl_get_browser_line( colors_->browser_lyx_objs, i );
 
-               int d = (2 * (diff.r * diff.r) +
-                        3 * (diff.g * diff.g) +
-                            (diff.b * diff.b));
+       vector<XFormColor>::iterator it = // non-const; it's modified below
+               find_if(xformColorDB.begin(), xformColorDB.end(),
+                       compare_memfun(&XFormColor::getname, name));
 
-               if (mindiff > d) {
-                       mindiff = d;
-                       mincit = cit;
-               }
-       }
-       return static_cast<int>(mincit - colourDB.begin());
-}
+       if( it == xformColorDB.end() )
+               return true;
 
+       int j = fl_get_browser( colors_->browser_x11 );
+       if (j < 1)
+               return true;
 
-void FormPreferences::ColoursUpdateBrowser(int i)
-{
-       fl_freeze_form(colours_->form);
+       (*it).col.r = colorDB[j-1].second.r;
+       (*it).col.g = colorDB[j-1].second.g;
+       (*it).col.b = colorDB[j-1].second.b;
 
-       RGB col = colourDB[i].second;
-    
-       fl_mapcolor(FL_FREE_COL4 + i, col.r, col.g, col.b);
-       fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
-       fl_set_slider_value(colours_->valslider_red,   col.r);
-       fl_set_slider_value(colours_->valslider_green, col.g);
-       fl_set_slider_value(colours_->valslider_blue,  col.b);
-       fl_redraw_object(colours_->button_colour);
+       fl_deselect_browser(colors_->browser_x11);
+       fl_deselect_browser(colors_->browser_lyx_objs);
+       fl_deactivate_object( colors_->button_modify );
+       fl_set_object_lcol( colors_->button_modify, FL_INACTIVE );
 
-       fl_unfreeze_form(colours_->form);
+       return true;
 }
 
-
-void FormPreferences::ColoursUpdateRGB()
+bool FormPreferences::ColorsRGB() const
 {
-       fl_freeze_form(colours_->form);
+       fl_freeze_form(colors_->form);
 
        RGB col;
-       col.r = int(fl_get_slider_value(colours_->valslider_red));
-       col.g = int(fl_get_slider_value(colours_->valslider_green));
-       col.b = int(fl_get_slider_value(colours_->valslider_blue));
+       col.r = int(fl_get_slider_value(colors_->valslider_red));
+       col.g = int(fl_get_slider_value(colors_->valslider_green));
+       col.b = int(fl_get_slider_value(colors_->valslider_blue));
     
        fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
-       fl_redraw_object(colours_->button_colour);
+       fl_redraw_object(colors_->button_color);
 
-       int const i = ColoursSearchEntry( col );
+       int const i = ColorsSearchEntry( col );
        // change topline only if necessary
-       // int top = fl_get_browser_topline(colours_->browser_x11);
+       // int top = fl_get_browser_topline(colors_->browser_x11);
        // if (i < top || i > (top+15))
-       fl_set_browser_topline(colours_->browser_x11, i - 5);
-       fl_select_browser_line(colours_->browser_x11, i + 1);
+       fl_set_browser_topline(colors_->browser_x11, i - 5);
+       fl_select_browser_line(colors_->browser_x11, i + 1);
+
+       // Only activate the "Modify" button if the browser and slider colors
+       // are the same AND if a LyX object is selected.
+       int line = fl_get_browser(colors_->browser_lyx_objs);
+       bool isSelected = ( line > 0 );
+       if( isSelected )
+               if( line > fl_get_browser_maxline(colors_->browser_lyx_objs) )
+                       isSelected = false;     
+
+       if( isSelected && colorDB[i].second == col ) {
+               fl_activate_object( colors_->button_modify );
+               fl_set_object_lcol( colors_->button_modify, FL_BLACK );
+       } else {
+               fl_deactivate_object( colors_->button_modify );
+               fl_set_object_lcol( colors_->button_modify, FL_INACTIVE );
+       }
+
+       fl_unfreeze_form(colors_->form);
 
-       fl_unfreeze_form(colours_->form);
+       return true;
 }
 
 
-void FormPreferences::updateColours()
+int FormPreferences::ColorsSearchEntry(RGB const & col) const
+{
+       int mindiff = 0x7fffffff;
+       vector<X11Color>::const_iterator mincit = colorDB.begin();
+
+       for (vector<X11Color>::const_iterator cit = colorDB.begin();
+            cit != colorDB.end(); ++cit) {
+               RGB colDB = (*cit).second;
+               RGB diff;
+               diff.r = col.r - colDB.r;
+               diff.g = col.g - colDB.g;
+               diff.b = col.b - colDB.b;
+
+               int d = (2 * (diff.r * diff.r) +
+                        3 * (diff.g * diff.g) +
+                            (diff.b * diff.b));
+
+               if (mindiff > d) {
+                       mindiff = d;
+                       mincit = cit;
+               }
+       }
+       return static_cast<int>(mincit - colorDB.begin());
+}
+
+
+void FormPreferences::updateColors()
 {}
 
 
@@ -685,7 +937,7 @@ bool FormPreferences::inputConverters( FL_OBJECT const * const ob )
                return ConvertersDelete();
        }
 
-       return false;
+       return true;
 }
 
 
@@ -708,7 +960,7 @@ bool FormPreferences::ConvertersAdd()
        string to   = command.to->prettyname;
        pair<string, string> FromTo = pair<string, string>(from, to);
        
-       vector<Command>::iterator it = // non-const because it's modified below
+       vector<Command>::iterator it = // non-const; it's modified below
                find_if(commands_vec.begin(), commands_vec.end(),
                        compare_memfun(&Command::getFromToPrettyname, FromTo));
 
@@ -842,7 +1094,7 @@ bool FormPreferences::ConvertersDelete()
        string to   = command.to->prettyname;
        pair<string, string> FromTo = pair<string, string>(from, to);
        
-       vector<Command>::iterator it = // non-const because it's modified below
+       vector<Command>::iterator it = // non-const; it's modified below
                find_if(commands_vec.begin(), commands_vec.end(),
                        compare_memfun(&Command::getFromToPrettyname, FromTo));
 
@@ -1115,7 +1367,7 @@ bool FormPreferences::FormatsAdd()
                return false;
 
        Format format(name, extension, prettyname, shortcut, viewer);
-       vector<Format>::iterator it = // non-const because it's modified below
+       vector<Format>::iterator it = // non-const; it's modified below
                find_if(formats_vec.begin(), formats_vec.end(),
                        compare_memfun(&Format::getname, name));
 
@@ -1212,7 +1464,7 @@ void FormPreferences::FormatsClear() const
 bool FormPreferences::FormatsDelete()
 {
        string name = fl_get_input(formats_->input_format);
-       vector<Format>::iterator it = // non-const because it's modified below
+       vector<Format>::iterator it = // non-const; it's modified below
                find_if(formats_vec.begin(), formats_vec.end(),
                        compare_memfun(&Format::getname, name));
 
@@ -1621,8 +1873,9 @@ void FormPreferences::updateLanguage()
                        find( dirlist.first.begin(), dirlist.first.end(),
                              fullpath );
                if (cit != dirlist.first.end()) {
-                       vector<string>::size_type sel = cit - dirlist.first.begin();
-                       combo_kbmap_1->select_text( dirlist.second[sel] );
+                       vector<string>::size_type sel =
+                               cit - dirlist.first.begin();
+                       combo_kbmap_1->select_text(dirlist.second[sel]);
                } else
                        combo_kbmap_1->select_text("");
 
@@ -1630,10 +1883,11 @@ void FormPreferences::updateLanguage()
                cit = find( dirlist.first.begin(), dirlist.first.end(),
                           fullpath );
                if (cit != dirlist.first.end()) {
-                       vector<string>::size_type sel = cit - dirlist.first.begin();
-                       combo_kbmap_2->select_text( dirlist.second[sel] );
+                       vector<string>::size_type sel =
+                               cit - dirlist.first.begin();
+                       combo_kbmap_2->select_text(dirlist.second[sel]);
                } else
-                       combo_kbmap_1->select_text("");
+                       combo_kbmap_2->select_text("");
        } else {
                combo_kbmap_1->select_text( "" );
                combo_kbmap_2->select_text( "" );
index 80eb46027903afad7b9e41e25a5c07d5e0d2739f..5ecc138eef483270ff1ceb11356b057780037204 100644 (file)
 #ifndef FORMPREFERENCES_H
 #define FORMPREFERENCES_H
 
+#include <utility> // for pair
+
 #include "FormBase.h"
+#include "Color.h"
 
 #ifdef __GNUG_
 #pragma interface
@@ -28,7 +31,7 @@ class Command;
 class Dialogs;
 class Format;
 class LyXView;
-struct FD_form_colours;
+struct FD_form_colors;
 struct FD_form_converters;
 struct FD_form_formats;
 struct FD_form_inputs_misc;
@@ -59,21 +62,9 @@ public:
                              FL_Coord, FL_Coord, int, void *);
 
 private:
-       /// helper struct for Colours
-       struct RGB {
-               int r;
-               int g;
-               int b;
-               RGB() : r(0), g(0), b(0) {}
-               RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
-       };
-       ///
-       friend bool operator==(RGB const &, RGB const &);
-       ///
-       friend bool operator!=(RGB const &, RGB const &);
-       ///
-       typedef std::pair<string, RGB> X11Colour;
-
+       /** Redraw the form (on receipt of a Signal indicating, for example,
+           that the xform colours have been re-mapped). */
+       virtual void redraw();
        /// Update the dialog.
        virtual void update();
        ///
@@ -97,7 +88,7 @@ private:
         */
        
        ///
-       void applyColours() const;
+       void applyColors() const;
        ///
        void applyConverters() const;
        ///
@@ -125,7 +116,7 @@ private:
         */
        
        ///
-       void buildColours();
+       void buildColors();
        ///
        void buildConverters();
        ///
@@ -153,7 +144,7 @@ private:
         */
        
        ///
-       string const feedbackColours(FL_OBJECT const * const) const;
+       string const feedbackColors(FL_OBJECT const * const) const;
        ///
        string const feedbackConverters(FL_OBJECT const * const) const;
        ///
@@ -181,7 +172,7 @@ private:
         */
        
        ///
-       bool inputColours(FL_OBJECT const * const);
+       bool inputColors(FL_OBJECT const * const);
        ///
        bool inputConverters( FL_OBJECT const * const );
        ///
@@ -199,7 +190,7 @@ private:
         */
        
        ///
-       void updateColours();
+       void updateColors();
        ///
        void updateConverters();
        ///
@@ -227,13 +218,23 @@ private:
         */
        
        ///
-       bool ColoursLoadBrowser( string const & );
+       void ColorsAdjustVal( int, int, double ) const;
+       ///
+       bool ColorsBrowserLyX() const;
+       ///
+       bool ColorsBrowserX11() const;
        ///
-       int  ColoursSearchEntry(RGB const & ) const;
+       bool ColorsDatabase() const;
        ///
-       void ColoursUpdateBrowser( int );
+       void ColorsLoadBrowserLyX();
        ///
-       void ColoursUpdateRGB();
+       bool ColorsLoadBrowserX11(string const &) const;
+       ///
+       bool ColorsModify() const;
+       ///
+       bool ColorsRGB() const;
+       ///
+       int ColorsSearchEntry(RGB const &) const;
 
        ///
        bool ConvertersAdd();
@@ -279,7 +280,7 @@ private:
        ///
        FD_form_outer_tab * build_outer_tab();
        ///
-       FD_form_colours * build_colours();
+       FD_form_colors * build_colors();
        ///
        FD_form_converters * build_converters();
        ///
@@ -316,7 +317,7 @@ private:
        /// Spellchecker, language stuff, etc
        FD_form_outer_tab * usage_tab_;
        ///
-       FD_form_colours * colours_;
+       FD_form_colors * colors_;
        ///
        FD_form_converters * converters_;
        ///
@@ -350,8 +351,10 @@ private:
        std::vector<Format> formats_vec;
        /// A vector of Commands, to be manipulated in the Converter browser.
        std::vector<Command> commands_vec;
-       /// A vector of RGB colours and associated name.
-       static std::vector<X11Colour> colourDB;
+       /// A vector of RGB colors and associated name.
+       static std::vector<X11Color> colorDB;
+       /// A vector of xform RGB colors and associated name.
+       static std::vector<XFormColor> xformColorDB;
        /** A collection of kmap files.
            First entry is the file name, full path.
            Second entry is the shorthand, as appears in the fl_choice.
@@ -362,19 +365,4 @@ private:
        bool warningPosted;
 };
 
-inline
-bool operator==(FormPreferences::RGB const & c1,
-               FormPreferences::RGB const & c2)
-{
-       return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
-}
-
-
-inline
-bool operator!=(FormPreferences::RGB const & c1,
-               FormPreferences::RGB const & c2)
-{
-       return !(c1 == c2);
-}
-
 #endif
index 56d12593f54502a10b01513df926bbe35fe74edd..e8d0c2787644e03c6c719f08179bf1f05b10957c 100644 (file)
@@ -46,6 +46,19 @@ FormTabular::~FormTabular()
 }
 
 
+void FormTabular::redraw()
+{
+       if( form() && form()->visible )
+               fl_redraw_form( form() );
+       else
+               return;
+
+       FL_FORM * outer_form = fl_get_active_folder(dialog_->tabFolder);
+       if (outer_form && outer_form->visible)
+               fl_redraw_form( outer_form );
+}
+
+
 FL_FORM * FormTabular::form() const
 {
        if (dialog_ ) return dialog_->form;
index bebdf513278822e482970af0a69c6afa76478153..ae5b498a3c4659edaa6e6e9de3e7c2ffcc01a7da 100644 (file)
@@ -35,6 +35,9 @@ public:
        ~FormTabular();
 
 private:
+       /** Redraw the form (on receipt of a Signal indicating, for example,
+           that the xform colours have been re-mapped). */
+       virtual void redraw();
        /// Disconnect signals. Also perform any necessary housekeeping.
        virtual void disconnect();
 
index 55519e774f82bdd71397b2f97e0e2c7044ea117b..5e1f5aecdcc0e380b276f9a30dad3704fdd779a7 100644 (file)
@@ -14,6 +14,8 @@ ETAGS_ARGS = --lang=c++
 libxforms_la_SOURCES = \
        ButtonController.C \
        ButtonController.h \
+       Color.C \
+       Color.h \
        Dialogs.C \
        GUIRunTime.C \
        FormBase.C \
index a2f71e8305338f73dc4812b541f6ef2fc6a9f8a2..989d5965480ac84d3eddb5b376a2baf07b5231f8 100644 (file)
@@ -381,23 +381,23 @@ FD_form_language * FormPreferences::build_language()
 }
 /*---------------------------------------*/
 
-FD_form_colours::~FD_form_colours()
+FD_form_colors::~FD_form_colors()
 {
   if ( form->visible ) fl_hide_form( form );
   fl_free_form( form );
 }
 
 
-FD_form_colours * FormPreferences::build_colours()
+FD_form_colors * FormPreferences::build_colors()
 {
   FL_OBJECT *obj;
-  FD_form_colours *fdui = new FD_form_colours;
+  FD_form_colors *fdui = new FD_form_colors;
 
   fdui->form = fl_bgn_form(FL_NO_BOX, 450, 360);
   fdui->form->u_vdata = this;
   obj = fl_add_box(FL_FLAT_BOX, 0, 0, 450, 360, "");
-  fdui->browser_x11 = obj = fl_add_browser(FL_HOLD_BROWSER, 10, 25, 150, 235, idex(_("X11 colour names|#X")));
-    fl_set_button_shortcut(obj, scex(_("X11 colour names|#X")), 1);
+  fdui->browser_x11 = obj = fl_add_browser(FL_HOLD_BROWSER, 10, 25, 150, 235, idex(_("X11 color names|#X")));
+    fl_set_button_shortcut(obj, scex(_("X11 color names|#X")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_TOP);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
@@ -410,7 +410,7 @@ FD_form_colours * FormPreferences::build_colours()
     fl_set_button_shortcut(obj, scex(_("Browse|#B")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
-  fdui->button_colour = obj = fl_add_button(FL_NORMAL_BUTTON, 180, 230, 90, 30, "");
+  fdui->button_color = obj = fl_add_button(FL_NORMAL_BUTTON, 180, 230, 90, 30, "");
     fl_set_object_boxtype(obj, FL_BORDER_BOX);
     fl_set_object_color(obj, FL_WHITE, FL_COL1);
   fdui->valslider_red = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 180, 25, 30, 200, idex(_("R|#R")));
@@ -431,12 +431,12 @@ FD_form_colours * FormPreferences::build_colours()
     fl_set_object_lalign(obj, FL_ALIGN_TOP);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
     fl_set_slider_size(obj, 0.15);
-  fdui->browser_lyx_objs = obj = fl_add_browser(FL_HOLD_BROWSER, 290, 25, 150, 200, idex(_("LyX objects|#L")));
+  fdui->browser_lyx_objs = obj = fl_add_browser(FL_HOLD_BROWSER, 290, 25, 150, 251, idex(_("LyX objects|#L")));
     fl_set_button_shortcut(obj, scex(_("LyX objects|#L")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_TOP);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
-  fdui->button_modify = obj = fl_add_button(FL_NORMAL_BUTTON, 350, 230, 90, 30, idex(_("Modify|#M")));
+  fdui->button_modify = obj = fl_add_button(FL_NORMAL_BUTTON, 320, 285, 90, 30, idex(_("Modify|#M")));
     fl_set_button_shortcut(obj, scex(_("Modify|#M")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
index 4ab695f89a9c7b87e82905d5ce23bbd604920592..73cba39691b07bade9d89bcbc3846f685741b1f3 100644 (file)
@@ -123,14 +123,14 @@ struct FD_form_language {
        FL_OBJECT *input_command_begin;
        FL_OBJECT *input_command_end;
 };
-struct FD_form_colours {
-       ~FD_form_colours();
+struct FD_form_colors {
+       ~FD_form_colors();
 
        FL_FORM *form;
        FL_OBJECT *browser_x11;
        FL_OBJECT *input_name;
        FL_OBJECT *button_browse;
-       FL_OBJECT *button_colour;
+       FL_OBJECT *button_color;
        FL_OBJECT *valslider_red;
        FL_OBJECT *valslider_green;
        FL_OBJECT *valslider_blue;
index 3e0b9af1c6d8328fb8dca7622e63516c40b69a03..0928edb4f768c2c5c3c178fb3c4c58138ab7f394 100644 (file)
@@ -1143,7 +1143,7 @@ callback: C_FormBaseInputCB
 argument: 0
 
 =============== FORM ===============
-Name: form_colours
+Name: form_colors
 Width: 450
 Height: 360
 Number of Objects: 10
@@ -1176,7 +1176,7 @@ alignment: FL_ALIGN_TOP
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: X11 colour names|#X
+label: X11 color names|#X
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
@@ -1234,7 +1234,7 @@ label:
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: button_colour
+name: button_color
 callback: 
 argument: 
 
@@ -1298,7 +1298,7 @@ argument: 0
 --------------------
 class: FL_BROWSER
 type: HOLD_BROWSER
-box: 290 25 150 200
+box: 290 25 150 251
 boxtype: FL_DOWN_BOX
 colors: FL_COL1 FL_YELLOW
 alignment: FL_ALIGN_TOP
@@ -1316,7 +1316,7 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 350 230 90 30
+box: 320 285 90 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
index ecdf613ac1836fd5bc34dc1985d76936c551626c..a31535504570b11336175ca9f51cdcb5366cd4f2 100644 (file)
@@ -218,29 +218,23 @@ bool MenuWriteAs(Buffer * buffer)
        if (!IsLyXFilename(fname))
                fname += ".lyx";
 
-       if (buffer->isUnnamed()) {
-               fname = fileDlg.Select(_("Enter Filename to Save Document as"), 
-                                      "",
-                                      "*.lyx", 
-                                      "");
-       } else {
-               fname = fileDlg.Select(_("Enter Filename to Save Document as"), 
-                                      OnlyPath(fname),
-                                      "*.lyx", 
-                                      OnlyFilename(fname));
-       }
+       fname = fileDlg.Select(_("Enter Filename to Save Document as"), 
+                              OnlyPath(fname),
+                              "*.lyx", 
+                              OnlyFilename(fname));
+
        AllowInput(current_view);
 
-       if (fname.empty()) {
+       if (fname.empty())
                return false;
-       }
+
        // Make sure the absolute filename ends with appropriate suffix
        string s = MakeAbsPath(fname);
        if (!IsLyXFilename(s))
                s += ".lyx";
 
        // Same name as we have already?
-       if (s == oldname) {
+       if (!buffer->isUnnamed() && s == oldname) {
                if (!AskQuestion(_("Same name as document already has:"),
                                 MakeDisplayPath(s, 50),
                                 _("Save anyway?")))
@@ -248,7 +242,7 @@ bool MenuWriteAs(Buffer * buffer)
                // Falls through to name change and save
        } 
        // No, but do we have another file with this name open?
-       else if (bufferlist.exists(s)) {
+       else if (!buffer->isUnnamed() && bufferlist.exists(s)) {
                if (AskQuestion(_("Another document with same name open!"),
                                MakeDisplayPath(s, 50),
                                _("Replace with current document?")))