toolbar2.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6746 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-04-09 19:53:10 +00:00
parent 1618929ff7
commit 4f8b5b4990
15 changed files with 130 additions and 63 deletions

View File

@ -1,3 +1,7 @@
2003-04-09 John Levon <levon@movementarian.org>
* ui/default.ui: add a name for the toolbar
2003-04-08 John Levon <levon@movementarian.org>
* ui/default.ui: add tooltips for toolbar items,

View File

@ -411,7 +411,7 @@ End
#
# This is the default toolbar:
Toolbar
Toolbar "Standard"
Layouts
Item "Open document" "file-open"
Item "Save document" "buffer-write"

View File

@ -1,3 +1,7 @@
2003-04-09 John Levon <levon@movementarian.org>
* Makefile.in.in: translate the toolbar name
2003-03-30 John Levon <levon@movementarian.org>
* Makefile.in.in: fix escaping of " for qt UI files

View File

@ -282,6 +282,13 @@ $(srcdir)/default_ui_l10n.pot: $(top_srcdir)/lib/ui/default.ui
printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
FILENAME, FNR, line); \
} \
/^[^#]*Toolbar/ { \
line=$$0; \
sub(/[^"]*"/, "", line); \
sub(/".*/, "", line); \
printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
FILENAME, FNR, line); \
} \
/^[^#]*Item/ { \
line=$$0; \
sub(/[^"]*"/, "", line); \

View File

@ -1,3 +1,8 @@
2003-04-09 John Levon <levon@movementarian.org>
* ToolbarBackend.h:
* ToolbarBackend.C: allow multiple toolbars
2003-04-09 Lars Gullik Bjønnes <larsbj@gullik.net>
* undo_funcs.C (setCursorParUndo): adjust

View File

@ -28,12 +28,11 @@ ToolbarBackend toolbarbackend;
namespace {
enum _tooltags {
enum tooltags {
TO_ADD = 1,
TO_ENDTOOLBAR,
TO_SEPARATOR,
TO_LAYOUTS,
TO_NEWLINE,
TO_LAST
};
@ -42,7 +41,6 @@ struct keyword_item toolTags[TO_LAST - 1] = {
{ "end", TO_ENDTOOLBAR },
{ "item", TO_ADD },
{ "layouts", TO_LAYOUTS },
{ "newline", TO_NEWLINE },
{ "separator", TO_SEPARATOR }
};
@ -54,12 +52,6 @@ ToolbarBackend::ToolbarBackend()
}
void ToolbarBackend::add(int action, string const & tooltip)
{
items.push_back(make_pair(action, tooltip));
}
void ToolbarBackend::read(LyXLex & lex)
{
//consistency check
@ -68,6 +60,11 @@ void ToolbarBackend::read(LyXLex & lex)
<< lex.getString() << '\'' << endl;
}
lex.next(true);
Toolbar tb;
tb.name = lex.getString();
bool quit = false;
lex.pushTable(toolTags, TO_LAST - 1);
@ -85,20 +82,16 @@ void ToolbarBackend::read(LyXLex & lex)
lyxerr[Debug::PARSER]
<< "ToolbarBackend::read TO_ADD func: `"
<< func << '\'' << endl;
add(func, tooltip);
add(tb, func, tooltip);
}
break;
case TO_SEPARATOR:
add(SEPARATOR);
add(tb, SEPARATOR);
break;
case TO_LAYOUTS:
add(LAYOUTS);
break;
case TO_NEWLINE:
add(NEWLINE);
add(tb, LAYOUTS);
break;
case TO_ENDTOOLBAR:
@ -110,11 +103,20 @@ void ToolbarBackend::read(LyXLex & lex)
break;
}
}
toolbars.push_back(tb);
lex.popTable();
}
void ToolbarBackend::add(string const & func, string const & tooltip)
void ToolbarBackend::add(Toolbar & tb, int action, string const & tooltip)
{
tb.items.push_back(make_pair(action, tooltip));
}
void ToolbarBackend::add(Toolbar & tb, string const & func, string const & tooltip)
{
int const tf = lyxaction.LookupFunc(func);
@ -122,7 +124,7 @@ void ToolbarBackend::add(string const & func, string const & tooltip)
lyxerr << "ToolbarBackend::add: no LyX command called `"
<< func << "' exists!" << endl;
} else {
add(tf, tooltip);
add(tb, tf, tooltip);
}
}

View File

@ -38,28 +38,30 @@ public:
/// the toolbar items
typedef std::vector<std::pair<int, string> > Items;
typedef Items::iterator iterator;
/// a toolbar
struct Toolbar {
/// toolbar UI name
string name;
/// toolbar contents
Items items;
};
typedef std::vector<Toolbar> Toolbars;
typedef Items::const_iterator item_iterator;
typedef Items::const_iterator const_iterator;
///
ToolbarBackend();
///
iterator begin() {
return items.begin();
/// iterator for all toolbars
Toolbars::const_iterator begin() const {
return toolbars.begin();
}
///
const_iterator begin() const {
return items.begin();
Toolbars::const_iterator end() const {
return toolbars.end();
}
///
iterator end() {
return items.end();
}
///
const_iterator end() const {
return items.end();
}
///
/// read a toolbar from the file
void read(LyXLex &);
/// return a full path of an XPM for the given action
@ -67,11 +69,13 @@ public:
private:
/// add the given lfun with tooltip if relevant
void add(int, string const & tooltip = string());
void add(Toolbar & tb, 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;
void add(Toolbar & tb, string const &, string const & tooltip);
/// all the toolbars
Toolbars toolbars;
};
/// The global instance

View File

@ -1,3 +1,7 @@
2003-04-09 John Levon <levon@movementarian.org>
* Toolbar.C: handle multiple toolbars
2003-04-08 John Levon <levon@movementarian.org>
* Toolbar.C: handle tooltip

View File

@ -24,11 +24,12 @@ Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarBackend const & backend)
{
pimpl_ = new Pimpl(o, x, y);
// extracts the toolbar actions from the backend
for (ToolbarBackend::const_iterator cit = backend.begin();
cit != backend.end(); ++cit) {
pimpl_->add(cit->first, cit->second);
}
// extracts the toolbars from the backend
ToolbarBackend::Toolbars::const_iterator cit = backend.begin();
ToolbarBackend::Toolbars::const_iterator end = backend.end();
for (; cit != end; ++cit)
pimpl_->add(*cit);
}

View File

@ -1,3 +1,9 @@
2003-04-09 John Levon <levon@movementarian.org>
* Toolbar_pimpl.h:
* Toolbar_pimpl.C: handle API change for multiple
toolbars
2003-04-08 John Levon <levon@movementarian.org>
* Toolbar_pimpl.C: move xpm code into ToolbarBackend,

View File

@ -12,7 +12,6 @@
#include <config.h>
#include "ToolbarBackend.h"
#include "debug.h"
#include "gettext.h"
#include "lyxfunc.h"
@ -193,21 +192,27 @@ void Toolbar::Pimpl::openLayoutList()
}
void Toolbar::Pimpl::add(int action, string const & tooltip)
void Toolbar::Pimpl::add(ToolbarBackend::Toolbar const & tb)
{
if (!toolbars_.size()) {
toolbars_.push_back(new QToolBar(owner_));
}
QToolBar * qtb = new QToolBar(qt_(tb.name), owner_);
ToolbarBackend::item_iterator it = tb.items.begin();
ToolbarBackend::item_iterator end = tb.items.end();
for (; it != end; ++it)
add(qtb, it->first, it->second);
toolbars_.push_back(qtb);
}
void Toolbar::Pimpl::add(QToolBar * tb, int action, string const & tooltip)
{
switch (action) {
case ToolbarBackend::SEPARATOR:
toolbars_.back()->addSeparator();
break;
case ToolbarBackend::NEWLINE:
toolbars_.push_back(new QToolBar(owner_));
tb->addSeparator();
break;
case ToolbarBackend::LAYOUTS: {
combo_ = new QLComboBox(toolbars_.back());
combo_ = new QLComboBox(tb);
QSizePolicy p(QSizePolicy::Minimum, QSizePolicy::Fixed);
combo_->setSizePolicy(p);
combo_->setFocusPolicy(QWidget::ClickFocus);
@ -219,11 +224,11 @@ void Toolbar::Pimpl::add(int action, string const & tooltip)
}
default: {
QPixmap p = QPixmap(toolbarbackend.getIcon(action).c_str());
QToolButton * tb =
QToolButton * button =
new QToolButton(p, toqstr(tooltip), "",
proxy_.get(), SLOT(button_selected()), toolbars_.back());
proxy_.get(), SLOT(button_selected()), tb);
map_[tb] = action;
map_[button] = action;
break;
}
}

View File

@ -14,6 +14,7 @@
#include "frontends/Toolbar.h"
#include "ToolbarBackend.h"
#include "qt_helpers.h"
@ -37,8 +38,11 @@ public:
~Pimpl();
/// add a new button to the toolbar.
void add(int action, string const & tooltip);
/// add a new toolbar
void add(ToolbarBackend::Toolbar const & tb);
/// add an item to a toolbar
void add(QToolBar * tb, int action, string const & tooltip);
/// update the state of the icons
void update();

View File

@ -1,3 +1,8 @@
2003-04-09 John Levon <levon@movementarian.org>
* Toolbar_pimpl.C:
* Toolbar_pimpl.h: ignore every toolbar after the first one
2003-04-09 Angus Leeming <leeming@lyx.org>
Enable "proper" tooltips in browser widgets if your version of

View File

@ -26,7 +26,6 @@
#include "Tooltips.h"
#include FORMS_H_LOCATION
#include "combox.h"
#include "ToolbarBackend.h"
#include "xforms_helpers.h"
#include "LyXAction.h"
@ -266,6 +265,19 @@ void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data)
} // namespace anon
void Toolbar::Pimpl::add(ToolbarBackend::Toolbar const & tb)
{
// we can only handle one toolbar
if (!toollist_.empty())
return;
ToolbarBackend::item_iterator it = tb.items.begin();
ToolbarBackend::item_iterator end = tb.items.end();
for (; it != end; ++it)
add(it->first, it->second);
}
void Toolbar::Pimpl::add(int action, string const & tooltip)
{
toolbarItem item;

View File

@ -17,6 +17,7 @@
#include "forms_fwd.h"
#include "frontends/Toolbar.h"
#include "ToolbarBackend.h"
class XFormsView;
@ -31,7 +32,10 @@ public:
~Pimpl();
/// add a new button to the toolbar.
/// add a new toolbar
void add(ToolbarBackend::Toolbar const & tb);
/// add an item to a toolbar
void add(int action, string const & tooltip);
/// update the state of the icons