+2003-04-10 John Levon <levon@movementarian.org>
+
+ * ui/default.ui: Add visibility tag to toolbars
+
+ * BufferView_pimpl.C: updateToolbar on mouse click
+
+ * ToolbarBackend.h:
+ * ToolbarBackend.C: handle toolbar on/off settings
+
+
2003-04-10 John Levon <levon@movementarian.org>
* images/: new icons, mostly taken from kdeart
End
-# Setup your favorite Toolbar here:
+# A Toolbar starts like :
+#
+# Toolbar "Name" "on"
+#
+# The second parameter is the status, and can be "on", "off", "math"
+# or "table". The last two make the toolbars appear and disappear automatically.
+#
# Only three commands are allowed inside the begin_toolbar and end_toolbar
# directives:
# Item "<action> [<parameter>]" adds an icon to the toolbar performing
#
# This is the default toolbar:
-Toolbar "Standard"
+Toolbar "Standard" "on"
Layouts
Item "Open document" "file-open"
Item "Save document" "buffer-write"
bool const res = dispatch(ev_in);
+ // FIXME: we should skip these when selecting
bv_->owner()->updateLayoutChoice();
+ bv_->owner()->updateToolbar();
bv_->fitCursor();
// slight hack: this is only called currently when
Toolbar tb;
tb.name = lex.getString();
+ lex.next(true);
+ string type = lex.getString();
+ if (!compare_ascii_no_case(type, "off"))
+ tb.display_type = OFF;
+ else if (!compare_ascii_no_case(type, "on"))
+ tb.display_type = ON;
+ else if (!compare_ascii_no_case(type, "math"))
+ tb.display_type = MATH;
+ else if (!compare_ascii_no_case(type, "table"))
+ tb.display_type = TABLE;
+ else {
+ lyxerr << "ToolbarBackend::read: unrecognised token:`"
+ << type << '\'' << endl;
+ }
+
bool quit = false;
lex.pushTable(toolTags, TO_LAST - 1);
class ToolbarBackend {
public:
/// The special toolbar actions
- enum ItemType {
+ enum ItemType {
/// adds space between buttons in the toolbar
SEPARATOR = -3,
/// a special combox insead of a button
/// the toolbar items
typedef std::vector<std::pair<int, string> > Items;
+ /// possibly display types
+ enum DisplayType {
+ OFF, //< never shown
+ ON, //< always shown
+ MATH, //< shown when in math
+ TABLE //< shown when in table
+ };
+
/// a toolbar
struct Toolbar {
/// toolbar UI name
string name;
/// toolbar contents
Items items;
+ /// display type
+ DisplayType display_type;
};
typedef std::vector<Toolbar> Toolbars;
+2003-04-10 John Levon <levon@movementarian.org>
+
+ * Toolbar.h:
+ * Toolbar.C: handle on/off etc. for toolbars
+
+ * LyXView.C: update toolbar on/off etc.
+
2003-04-09 John Levon <levon@movementarian.org>
* Toolbar.C: handle multiple toolbars
#include "Timeout.h"
#include "Menubar.h"
#include "controllers/ControlCommandBuffer.h"
+#include "mathed/math_cursor.h"
#include "support/filetools.h" // OnlyFilename()
void LyXView::updateToolbar()
{
- toolbar_->update();
+ bool const math = mathcursor;
+ bool const table =
+ !getLyXFunc().getStatus(LFUN_LAYOUT_TABULAR).disabled();
+ toolbar_->update(math, table);
}
using std::endl;
-Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarBackend const & backend)
+Toolbar::Toolbar(LyXView * o, int x, int y)
: last_textclass_(-1)
{
pimpl_ = new Pimpl(o, x, y);
// extracts the toolbars from the backend
- ToolbarBackend::Toolbars::const_iterator cit = backend.begin();
- ToolbarBackend::Toolbars::const_iterator end = backend.end();
+ ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
+ ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
for (; cit != end; ++cit)
pimpl_->add(*cit);
}
-void Toolbar::update()
+void Toolbar::update(bool in_math, bool in_table)
{
pimpl_->update();
+
+ // extracts the toolbars from the backend
+ ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
+ ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
+
+ for (; cit != end; ++cit) {
+ switch (cit->display_type) {
+ case ToolbarBackend::OFF:
+ case ToolbarBackend::ON:
+ break;
+ case ToolbarBackend::MATH:
+ pimpl_->displayToolbar(*cit, in_math);
+ break;
+ case ToolbarBackend::TABLE:
+ pimpl_->displayToolbar(*cit, in_table);
+ break;
+ }
+ }
}
#include "LString.h"
class LyXView;
-class ToolbarBackend;
-/** The LyX GUI independent toolbar class
- The GUI interface is implemented in the corresponding Toolbar_pimpl class.
- */
+/**
+ * The LyX GUI independent toolbar class
+ *
+ * The GUI interface is implemented in the corresponding Toolbar_pimpl class.
+ */
class Toolbar {
public:
///
- Toolbar(LyXView * o, int x, int y, ToolbarBackend const &);
+ Toolbar(LyXView * o, int x, int y);
///
~Toolbar();
- /// update the state of the icons
- void update();
+ /// update the state of the toolbars
+ void update(bool in_math, bool in_table);
/// update the layout combox
void setLayout(string const & layout);
+2003-04-10 John Levon <levon@movementarian.org>
+
+ * QtView.C: Toolbar ctor changed
+
+ * Toolbar_pimpl.h:
+ * Toolbar_pimpl.C: store toolbars in a map
+ for show/hide as needed
+
2003-04-09 John Levon <levon@movementarian.org>
* Toolbar_pimpl.h:
::current_view = bufferview_.get();
menubar_.reset(new Menubar(this, menubackend));
- toolbar_.reset(new Toolbar(this, 0, 0, toolbarbackend));
+ toolbar_.reset(new Toolbar(this, 0, 0));
statusBar()->setSizeGripEnabled(false);
}
+void Toolbar::Pimpl::displayToolbar(ToolbarBackend::Toolbar const & tb, bool show)
+{
+ QToolBar * qtb = toolbars_[tb.name];
+ if (show) {
+ qtb->show();
+ } else {
+ qtb->hide();
+ }
+}
+
+
void Toolbar::Pimpl::update()
{
ButtonMap::const_iterator p = map_.begin();
for (; it != end; ++it)
add(qtb, it->first, it->second);
- toolbars_.push_back(qtb);
+ toolbars_[tb.name] = qtb;
+ displayToolbar(tb, tb.display_type == ToolbarBackend::ON);
+
}
/// add an item to a toolbar
void add(QToolBar * tb, int action, string const & tooltip);
+ /// show or hide a toolbar
+ void displayToolbar(ToolbarBackend::Toolbar const & tb, bool show);
+
/// update the state of the icons
void update();
boost::scoped_ptr<ToolbarProxy> proxy_;
- std::vector<QToolBar *> toolbars_;
+ std::map<string, QToolBar *> toolbars_;
QLComboBox * combo_;
+2003-04-10 John Levon <levon@movementarian.org>
+
+ * XFormsView.C:
+ * Toolbar_pimpl.h:
+ * Toolbar_pimpl.C: API change for show/hide
+
2003-04-09 Angus Leeming <leeming@lyx.org>
* FormAboutlyx.C:
/// add an item to a toolbar
void add(int action, string const & tooltip);
+ /// display toolbar, not implemented
+ void displayToolbar(ToolbarBackend::Toolbar const & tb, bool show) {}
+
/// update the state of the icons
void update();
menubar_.reset(new Menubar(this, menubackend));
- toolbar_.reset(new Toolbar(this, air, 30 + air + bw, toolbarbackend));
+ toolbar_.reset(new Toolbar(this, air, 30 + air + bw));
int const ywork = 60 + 2 * air + bw;
int const workheight = height - ywork - (25 + 2 * air);