]> git.lyx.org Git - features.git/commitdiff
toolbar changes
authorJohn Levon <levon@movementarian.org>
Tue, 8 Apr 2003 19:17:00 +0000 (19:17 +0000)
committerJohn Levon <levon@movementarian.org>
Tue, 8 Apr 2003 19:17:00 +0000 (19:17 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6738 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
lib/ChangeLog
lib/ui/default.ui
src/ChangeLog
src/ToolbarBackend.C
src/ToolbarBackend.h
src/frontends/ChangeLog
src/frontends/Toolbar.C
src/frontends/qt2/ChangeLog
src/frontends/qt2/Toolbar_pimpl.C
src/frontends/qt2/Toolbar_pimpl.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/Toolbar_pimpl.C
src/frontends/xforms/Toolbar_pimpl.h

index 701adece6462b4824edebbaa3625420e966590c7..bb14ef8005330ee906b6ab61507800030d0cb162 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-08  John Levon  <levon@movementarian.org>
+
+       * ui/default.ui: add tooltips for toolbar items,
+       s/Icon/Item
+
 2003-04-03  Tomasz Luczak <tlu@technodat.com.pl>
 
        * layouts/mwbk.layout: small fix
index 6d0bdd8053c66524312f22e73d57eadbd0d938e4..9bfaff6dc98aac7288e86082bea93d9c48bf53ce 100644 (file)
@@ -394,11 +394,11 @@ End
 # Setup your favorite Toolbar here:
 # Only three commands are allowed inside the begin_toolbar and end_toolbar
 # directives: 
-#   Icon "<action> [<parameter>]" adds an icon to the toolbar performing
+#   Item "<action> [<parameter>]" adds an icon to the toolbar performing
 #          "<action> <parameter>"
 #      Examples:
-#      Icon "font-size small"
-#      Icon set-emph
+#      Item "font-size small"
+#      Item set-emph
 #
 #   Layouts adds the layouts combo-box to the toolbar
 #
@@ -413,26 +413,26 @@ End
 
 Toolbar
     Layouts
-    Icon "file-open"
-    Icon "buffer-write"
-    Icon "buffer-print"
+    Item "Open document" "file-open"
+    Item "Save document" "buffer-write"
+    Item "Print document" "buffer-print"
     Separator
-    Icon "cut"
-    Icon "copy"
-    Icon "paste"
+    Item "Cut selection" "cut"
+    Item "Copy selection" "copy"
+    Item "Paste" "paste"
     Separator
-    Icon "font-emph"
-    Icon "font-noun"
-    Icon "font-free-apply"
+    Item "Toggle emphasis style" "font-emph"
+    Item "Toggle noun style" "font-noun"
+    Item "Toggle free style" "font-free-apply"
     Separator
-    Icon "ert-insert"
-    Icon "math-mode"
-    #Icon "math-panel"
+    Item "Insert TeX" "ert-insert"
+    Item "Insert math" "math-mode"
+    #Item "math-panel"
     Separator
-    Icon "footnote-insert"
-    Icon "marginalnote-insert"
-    Icon "depth-increment"
+    Item "Insert footnote" "footnote-insert"
+    Item "Insert margin note" "marginalnote-insert"
+    Item "Increase depth" "depth-increment"
     Separator
-    Icon "dialog-show-new-inset graphics"
-    Icon "tabular-insert"
+    Item "Insert graphics" "dialog-show-new-inset graphics"
+    Item "Insert table" "tabular-insert"
 End
index 3577220367e002eeb30c7e0a3a8957f3f2c71291..e76d403c32f6fd37b104251a60858cf7132033b5 100644 (file)
@@ -1,3 +1,9 @@
+2003-04-08  John Levon  <levon@movementarian.org>
+
+       * ToolbarBackend.h:
+       * ToolbarBackend.C: add getIcon(), handle tooltip,
+       and change from "Icon" to "Item".
+
 2003-04-08  Alfredo Braunstein  <abraunst@libero.it>
 
        * BufferView.C (lockInset): another bad getchar crunched
index 3c2a8d08b9d7f3600dee7ecd5f45e248be7a7e93..442129bf3eb3ef44204bd52979d090bca0f036e7 100644 (file)
 #include "lyxlex.h"
 #include "debug.h"
 #include "lyxlex.h"
+#include "gettext.h"
+
 #include "support/lstrings.h"
+#include "support/filetools.h"
+
+#include "frontends/controllers/ControlMath.h"
 
 using std::endl;
 
@@ -35,7 +40,7 @@ enum _tooltags {
 
 struct keyword_item toolTags[TO_LAST - 1] = {
        { "end", TO_ENDTOOLBAR },
-       { "icon", TO_ADD },
+       { "item", TO_ADD },
        { "layouts", TO_LAYOUTS },
        { "newline", TO_NEWLINE },
        { "separator", TO_SEPARATOR }
@@ -49,9 +54,9 @@ ToolbarBackend::ToolbarBackend()
 }
 
 
-void ToolbarBackend::add(int action)
+void ToolbarBackend::add(int action, string const & tooltip)
 {
-       items.push_back(action);
+       items.push_back(make_pair(action, tooltip));
 }
 
 
@@ -74,11 +79,13 @@ void ToolbarBackend::read(LyXLex & lex)
                switch (lex.lex()) {
                case TO_ADD:
                        if (lex.next(true)) {
+                               string const tooltip = _(lex.getString());
+                               lex.next(true);
                                string const func = lex.getString();
                                lyxerr[Debug::PARSER]
                                        << "ToolbarBackend::read TO_ADD func: `"
                                        << func << '\'' << endl;
-                               add(func);
+                               add(func, tooltip);
                        }
                        break;
 
@@ -107,7 +114,7 @@ void ToolbarBackend::read(LyXLex & lex)
 }
 
 
-void ToolbarBackend::add(string const & func)
+void ToolbarBackend::add(string const & func, string const & tooltip)
 {
        int const tf = lyxaction.LookupFunc(func);
 
@@ -115,6 +122,34 @@ void ToolbarBackend::add(string const & func)
                lyxerr << "ToolbarBackend::add: no LyX command called `"
                       << func << "' exists!" << endl;
        } else {
-               add(tf);
+               add(tf, tooltip);
        }
 }
+
+
+string const ToolbarBackend::getIcon(int action)
+{
+       string fullname;
+       FuncRequest f = lyxaction.retrieveActionArg(action);
+
+       if (f.action == LFUN_INSERT_MATH && !f.argument.empty()) {
+               fullname = find_xpm(f.argument.substr(1));
+       } else {
+               string const name = lyxaction.getActionName(f.action);
+               string xpm_name(name);
+
+               if (!f.argument.empty())
+                       xpm_name = subst(name + ' ' + f.argument, ' ', '_');
+
+               fullname = LibFileSearch("images", xpm_name, "xpm");
+       }
+
+
+       if (!fullname.empty()) {
+               lyxerr[Debug::GUI] << "Full icon name is `"
+                                  << fullname << '\'' << endl;
+               return fullname;
+       }
+
+       return LibFileSearch("images", "unknown", "xpm");
+}
index 7e609ac8c4ecbf941c3e990138321f6b13bc7378..0819908ee2be04c23a0bddeedae78aa9286ba2b7 100644 (file)
@@ -13,6 +13,7 @@
 #define TOOLBAR_BACKEND_H
 
 #include <vector>
+#include <algorithm>
 
 #include "LString.h"
 
@@ -31,11 +32,14 @@ public:
                NEWLINE = -1
        };
 
-       ///
-       typedef std::vector<int> Items;
-       ///
+       /// action, tooltip
+       typedef std::pair<int, string> Item;
+
+       /// the toolbar items
+       typedef std::vector<std::pair<int, string> > Items;
+
        typedef Items::iterator iterator;
-       ///
+
        typedef Items::const_iterator const_iterator;
        ///
        ToolbarBackend();
@@ -57,12 +61,16 @@ public:
        }
        ///
        void read(LyXLex &);
+
+       /// return a full path of an XPM for the given action
+       static string const getIcon(int action);
+
 private:
-       /// This func is just to make it easy for me...
-       void add(int);
-       ///
-       void add(string const &);
-       ///
+       /// add the given lfun with tooltip if relevant
+       void add(int, string const & tooltip = string());
+       /// add the given lfun with tooltip if relevant
+       void add(string const &, string const & tooltip);
+       /// all the items
        Items items;
 };
 
index 6631d63eec0153e88b778ccf696ffe1153f2d6d4..24d131de53ff17523d1ff3714da098ff78841464 100644 (file)
@@ -1,3 +1,7 @@
+2003-04-08  John Levon  <levon@movementarian.org>
+
+       * Toolbar.C: handle tooltip
+
 2003-04-07  John Levon  <levon@movementarian.org>
 
        * LyXView.h: add clearMessage()
index 9f4bfecc7f8ed224a3426898420260ee969f6f70..c19f215149186604532fb15cebe6f54aaf96554a 100644 (file)
@@ -27,8 +27,7 @@ Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarBackend const & backend)
        // extracts the toolbar actions from  the backend
        for (ToolbarBackend::const_iterator cit = backend.begin();
             cit != backend.end(); ++cit) {
-               pimpl_->add((*cit));
-               lyxerr[Debug::GUI] << "tool action: " << (*cit) << endl;
+               pimpl_->add(cit->first, cit->second);
        }
 }
 
index cea4694e5376cfc14cfbf8c11888bc4f11a7b73d..49bbc50d043ec7305da27c042d9665fd5fdcd205 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-08  John Levon  <levon@movementarian.org>
+
+       * Toolbar_pimpl.C: move xpm code into ToolbarBackend,
+       handle tooltip
+
 2003-04-07  John Levon  <levon@movementarian.org>
 
        * ui/QIncludeDialogBase.ui: make "Show preview"
index 534ec09eae9fee2cae23fcc68bda6e0b84576a91..fcc866c07f2efbbbd283a4276ccc408be3a43344 100644 (file)
@@ -26,8 +26,6 @@
 #include "support/filetools.h"
 #include "support/lstrings.h"
 
-#include "ControlMath.h"
-
 #include <boost/tuple/tuple.hpp>
 
 #include "QtView.h"
 
 using std::endl;
 
-namespace {
-
-QPixmap getIconPixmap(int action)
-{
-       FuncRequest f = lyxaction.retrieveActionArg(action);
-
-       string fullname;
-
-       if (f.action == LFUN_INSERT_MATH && !f.argument.empty()) {
-               fullname = find_xpm(f.argument.substr(1));
-       } else {
-               string const name = lyxaction.getActionName(f.action);
-               string xpm_name(name);
-
-               if (!f.argument.empty())
-                       xpm_name = subst(name + ' ' + f.argument, ' ','_');
-
-               fullname = LibFileSearch("images", xpm_name, "xpm");
-       }
-
-
-       if (!fullname.empty()) {
-               lyxerr[Debug::GUI] << "Full icon name is `"
-                                  << fullname << '\'' << endl;
-               return QPixmap(toqstr(fullname));
-       }
-
-       lyxerr << "Unable to find icon `" << fullname << '\'' << endl;
-       fullname = LibFileSearch("images", "unknown", "xpm");
-       if (!fullname.empty()) {
-               lyxerr[Debug::GUI] << "Using default `unknown' icon"
-                                  << endl;
-       }
-       return QPixmap(toqstr(fullname));
-}
-
-} // namespace anon
-
 
 class QLComboBox : public QComboBox {
 public:
@@ -233,7 +193,7 @@ void Toolbar::Pimpl::openLayoutList()
 }
 
 
-void Toolbar::Pimpl::add(int action)
+void Toolbar::Pimpl::add(int action, string const & tooltip)
 {
        if (!toolbars_.size()) {
                toolbars_.push_back(new QToolBar(owner_));
@@ -258,9 +218,9 @@ void Toolbar::Pimpl::add(int action)
                break;
        }
        default: {
+               QPixmap p = QPixmap(toolbarbackend.getIcon(action).c_str());
                QToolButton * tb =
-                       new QToolButton(getIconPixmap(action),
-                       qt_(lyxaction.helpText(action)), "",
+                       new QToolButton(p, toqstr(tooltip), "",
                        proxy_.get(), SLOT(button_selected()), toolbars_.back());
 
                map_[tb] = action;
index 5f40f331c96aa222af9371e8f97642e75804614a..fe8769e35dd5bc5b21a07e9869e5c9cc7119af22 100644 (file)
@@ -38,7 +38,7 @@ public:
        ~Pimpl();
 
        /// add a new button to the toolbar.
-       void add(int action);
+       void add(int action, string const & tooltip);
 
        /// update the state of the icons
        void update();
index d401586e66da64c7c4181e9c4b5529005ec4e20f..f44356e8f2c97c3a71a4fc02301834208c23fb92 100644 (file)
@@ -1,3 +1,7 @@
+2003-04-08  John Levon  <levon@movementarian.org>
+
+       * Toolbar_pimpl.C: handle tooltip
+
 2003-04-03  Angus Leeming  <leeming@lyx.org>
 
        * combox.[ch]:
index 021f56e7a7a7a9dbc75d0de8c63eeb52e8a2cffa..6126f53117eb5afb2d347fc2e37dd4754e017b30 100644 (file)
@@ -301,7 +301,7 @@ void setPixmap(FL_OBJECT * obj, int action)
 } // namespace anon
 
 
-void Toolbar::Pimpl::add(int action)
+void Toolbar::Pimpl::add(int action, string const & tooltip)
 {
        toolbarItem item;
        item.action = action;
@@ -348,9 +348,7 @@ void Toolbar::Pimpl::add(int action)
                // Remove the blue feedback rectangle
                fl_set_pixmapbutton_focus_outline(obj, 0);
 
-               // initialise the tooltip
-               string const tip = _(lyxaction.helpText(obj->argument));
-               tooltip_->init(obj, tip);
+               tooltip_->init(obj, tooltip);
 
                // The view that this object belongs to.
                obj->u_vdata = owner_;
index 26db1ca67157d6f18ce281e97b28c30d55d75ac0..73b8a0ba1dd3ddcb2bb8b1ea3e5c3b686c9dd6d9 100644 (file)
@@ -32,7 +32,7 @@ public:
        ~Pimpl();
 
        /// add a new button to the toolbar.
-       void add(int action);
+       void add(int action, string const & tooltip);
 
        /// update the state of the icons
        void update();