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> 2003-04-08 John Levon <levon@movementarian.org>
* ui/default.ui: add tooltips for toolbar items, * ui/default.ui: add tooltips for toolbar items,

View File

@ -411,7 +411,7 @@ End
# #
# This is the default toolbar: # This is the default toolbar:
Toolbar Toolbar "Standard"
Layouts Layouts
Item "Open document" "file-open" Item "Open document" "file-open"
Item "Save document" "buffer-write" 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> 2003-03-30 John Levon <levon@movementarian.org>
* Makefile.in.in: fix escaping of " for qt UI files * 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", \ printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
FILENAME, FNR, line); \ FILENAME, FNR, line); \
} \ } \
/^[^#]*Toolbar/ { \
line=$$0; \
sub(/[^"]*"/, "", line); \
sub(/".*/, "", line); \
printf("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n\n", \
FILENAME, FNR, line); \
} \
/^[^#]*Item/ { \ /^[^#]*Item/ { \
line=$$0; \ line=$$0; \
sub(/[^"]*"/, "", line); \ 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> 2003-04-09 Lars Gullik Bjønnes <larsbj@gullik.net>
* undo_funcs.C (setCursorParUndo): adjust * undo_funcs.C (setCursorParUndo): adjust

View File

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

View File

@ -38,28 +38,30 @@ public:
/// the toolbar items /// the toolbar items
typedef std::vector<std::pair<int, string> > 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(); ToolbarBackend();
///
iterator begin() { /// iterator for all toolbars
return items.begin(); Toolbars::const_iterator begin() const {
return toolbars.begin();
} }
///
const_iterator begin() const { Toolbars::const_iterator end() const {
return items.begin(); return toolbars.end();
} }
///
iterator end() { /// read a toolbar from the file
return items.end();
}
///
const_iterator end() const {
return items.end();
}
///
void read(LyXLex &); void read(LyXLex &);
/// return a full path of an XPM for the given action /// return a full path of an XPM for the given action
@ -67,11 +69,13 @@ public:
private: private:
/// add the given lfun with tooltip if relevant /// 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 /// add the given lfun with tooltip if relevant
void add(string const &, string const & tooltip); void add(Toolbar & tb, string const &, string const & tooltip);
/// all the items
Items items; /// all the toolbars
Toolbars toolbars;
}; };
/// The global instance /// 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> 2003-04-08 John Levon <levon@movementarian.org>
* Toolbar.C: handle tooltip * 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); pimpl_ = new Pimpl(o, x, y);
// extracts the toolbar actions from the backend // extracts the toolbars from the backend
for (ToolbarBackend::const_iterator cit = backend.begin(); ToolbarBackend::Toolbars::const_iterator cit = backend.begin();
cit != backend.end(); ++cit) { ToolbarBackend::Toolbars::const_iterator end = backend.end();
pimpl_->add(cit->first, cit->second);
} 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> 2003-04-08 John Levon <levon@movementarian.org>
* Toolbar_pimpl.C: move xpm code into ToolbarBackend, * Toolbar_pimpl.C: move xpm code into ToolbarBackend,

View File

@ -12,7 +12,6 @@
#include <config.h> #include <config.h>
#include "ToolbarBackend.h"
#include "debug.h" #include "debug.h"
#include "gettext.h" #include "gettext.h"
#include "lyxfunc.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()) { QToolBar * qtb = new QToolBar(qt_(tb.name), owner_);
toolbars_.push_back(new QToolBar(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) { switch (action) {
case ToolbarBackend::SEPARATOR: case ToolbarBackend::SEPARATOR:
toolbars_.back()->addSeparator(); tb->addSeparator();
break;
case ToolbarBackend::NEWLINE:
toolbars_.push_back(new QToolBar(owner_));
break; break;
case ToolbarBackend::LAYOUTS: { case ToolbarBackend::LAYOUTS: {
combo_ = new QLComboBox(toolbars_.back()); combo_ = new QLComboBox(tb);
QSizePolicy p(QSizePolicy::Minimum, QSizePolicy::Fixed); QSizePolicy p(QSizePolicy::Minimum, QSizePolicy::Fixed);
combo_->setSizePolicy(p); combo_->setSizePolicy(p);
combo_->setFocusPolicy(QWidget::ClickFocus); combo_->setFocusPolicy(QWidget::ClickFocus);
@ -219,11 +224,11 @@ void Toolbar::Pimpl::add(int action, string const & tooltip)
} }
default: { default: {
QPixmap p = QPixmap(toolbarbackend.getIcon(action).c_str()); QPixmap p = QPixmap(toolbarbackend.getIcon(action).c_str());
QToolButton * tb = QToolButton * button =
new QToolButton(p, toqstr(tooltip), "", 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; break;
} }
} }

View File

@ -14,6 +14,7 @@
#include "frontends/Toolbar.h" #include "frontends/Toolbar.h"
#include "ToolbarBackend.h"
#include "qt_helpers.h" #include "qt_helpers.h"
@ -37,8 +38,11 @@ public:
~Pimpl(); ~Pimpl();
/// add a new button to the toolbar. /// add a new toolbar
void add(int action, string const & tooltip); 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 /// update the state of the icons
void update(); 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> 2003-04-09 Angus Leeming <leeming@lyx.org>
Enable "proper" tooltips in browser widgets if your version of Enable "proper" tooltips in browser widgets if your version of

View File

@ -26,7 +26,6 @@
#include "Tooltips.h" #include "Tooltips.h"
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
#include "combox.h" #include "combox.h"
#include "ToolbarBackend.h"
#include "xforms_helpers.h" #include "xforms_helpers.h"
#include "LyXAction.h" #include "LyXAction.h"
@ -266,6 +265,19 @@ void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data)
} // namespace anon } // 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) void Toolbar::Pimpl::add(int action, string const & tooltip)
{ {
toolbarItem item; toolbarItem item;

View File

@ -17,6 +17,7 @@
#include "forms_fwd.h" #include "forms_fwd.h"
#include "frontends/Toolbar.h" #include "frontends/Toolbar.h"
#include "ToolbarBackend.h"
class XFormsView; class XFormsView;
@ -31,7 +32,10 @@ public:
~Pimpl(); ~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); void add(int action, string const & tooltip);
/// update the state of the icons /// update the state of the icons