toolbar changes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6738 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-04-08 19:17:00 +00:00
parent b50525dffb
commit aa3acd6358
13 changed files with 110 additions and 86 deletions

View 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

View 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

View 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

View File

@ -15,7 +15,12 @@
#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");
}

View 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;
};

View 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()

View 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);
}
}

View 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"

View File

@ -26,8 +26,6 @@
#include "support/filetools.h"
#include "support/lstrings.h"
#include "ControlMath.h"
#include <boost/tuple/tuple.hpp>
#include "QtView.h"
@ -40,44 +38,6 @@
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;

View 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();

View 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]:

View 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_;

View 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();