toolbar3.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6768 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-04-10 14:08:06 +00:00
parent 1ae72935c7
commit 31f6d268e2
16 changed files with 125 additions and 19 deletions

View File

@ -1,3 +1,13 @@
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

View File

@ -391,7 +391,13 @@ Menuset
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
@ -411,7 +417,7 @@ End
#
# This is the default toolbar:
Toolbar "Standard"
Toolbar "Standard" "on"
Layouts
Item "Open document" "file-open"
Item "Save document" "buffer-write"

View File

@ -937,7 +937,9 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & ev_in)
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

View File

@ -65,6 +65,21 @@ void ToolbarBackend::read(LyXLex & lex)
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);

View File

@ -23,7 +23,7 @@ class LyXLex;
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
@ -38,12 +38,22 @@ public:
/// 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;

View File

@ -1,3 +1,10 @@
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

View File

@ -31,6 +31,7 @@
#include "Timeout.h"
#include "Menubar.h"
#include "controllers/ControlCommandBuffer.h"
#include "mathed/math_cursor.h"
#include "support/filetools.h" // OnlyFilename()
@ -96,7 +97,10 @@ void LyXView::setLayout(string const & layout)
void LyXView::updateToolbar()
{
toolbar_->update();
bool const math = mathcursor;
bool const table =
!getLyXFunc().getStatus(LFUN_LAYOUT_TABULAR).disabled();
toolbar_->update(math, table);
}

View File

@ -19,14 +19,14 @@
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);
@ -39,9 +39,27 @@ Toolbar::~Toolbar()
}
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;
}
}
}

View File

@ -16,22 +16,23 @@
#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);

View File

@ -1,3 +1,11 @@
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:

View File

@ -64,7 +64,7 @@ QtView::QtView(unsigned int width, unsigned int height)
::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);

View File

@ -58,6 +58,17 @@ Toolbar::Pimpl::~Pimpl()
}
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();
@ -201,7 +212,9 @@ void Toolbar::Pimpl::add(ToolbarBackend::Toolbar const & tb)
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);
}

View File

@ -44,6 +44,9 @@ public:
/// 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();
@ -64,7 +67,7 @@ private:
boost::scoped_ptr<ToolbarProxy> proxy_;
std::vector<QToolBar *> toolbars_;
std::map<string, QToolBar *> toolbars_;
QLComboBox * combo_;

View File

@ -1,3 +1,9 @@
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:

View File

@ -38,6 +38,9 @@ public:
/// 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();

View File

@ -142,7 +142,7 @@ void XFormsView::create_form_form_main(int width, int height)
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);