+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
# 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
#
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
+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
#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;
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 }
}
-void ToolbarBackend::add(int action)
+void ToolbarBackend::add(int action, string const & tooltip)
{
- items.push_back(action);
+ items.push_back(make_pair(action, tooltip));
}
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;
}
-void ToolbarBackend::add(string const & func)
+void ToolbarBackend::add(string const & func, string const & tooltip)
{
int const tf = lyxaction.LookupFunc(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");
+}
#define TOOLBAR_BACKEND_H
#include <vector>
+#include <algorithm>
#include "LString.h"
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();
}
///
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;
};
+2003-04-08 John Levon <levon@movementarian.org>
+
+ * Toolbar.C: handle tooltip
+
2003-04-07 John Levon <levon@movementarian.org>
* LyXView.h: add clearMessage()
// 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);
}
}
+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"
#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:
}
-void Toolbar::Pimpl::add(int action)
+void Toolbar::Pimpl::add(int action, string const & tooltip)
{
if (!toolbars_.size()) {
toolbars_.push_back(new QToolBar(owner_));
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;
~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();
+2003-04-08 John Levon <levon@movementarian.org>
+
+ * Toolbar_pimpl.C: handle tooltip
+
2003-04-03 Angus Leeming <leeming@lyx.org>
* combox.[ch]:
} // namespace anon
-void Toolbar::Pimpl::add(int action)
+void Toolbar::Pimpl::add(int action, string const & tooltip)
{
toolbarItem item;
item.action = 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_;
~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();