2002-06-19 03:38:44 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/**
|
2003-10-08 11:31:51 +00:00
|
|
|
|
* \file QLToolbar.h
|
2002-09-24 13:57:09 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-19 03:38:44 +00:00
|
|
|
|
*
|
2002-09-24 13:57:09 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-07-25 18:10:34 +00:00
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
2002-09-24 13:57:09 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-19 03:38:44 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2003-07-25 18:10:34 +00:00
|
|
|
|
#ifndef QLTOOLBAR__H
|
|
|
|
|
#define QLTOOLBAR_H
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
|
#include "frontends/Toolbar.h"
|
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
2003-09-07 21:25:37 +00:00
|
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
|
#include <map>
|
|
|
|
|
|
2002-11-26 01:52:51 +00:00
|
|
|
|
#include <qobject.h>
|
|
|
|
|
#include <qtoolbutton.h>
|
|
|
|
|
|
2003-09-07 21:25:37 +00:00
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
class QtView;
|
|
|
|
|
class QToolBar;
|
2002-07-21 23:08:30 +00:00
|
|
|
|
class QLComboBox;
|
2002-06-21 16:40:54 +00:00
|
|
|
|
class ToolbarProxy;
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
2003-07-25 18:10:34 +00:00
|
|
|
|
class QLToolbar : public Toolbar {
|
2002-10-20 01:48:28 +00:00
|
|
|
|
public:
|
2002-06-19 03:38:44 +00:00
|
|
|
|
friend class ToolbarProxy;
|
2002-09-24 13:57:09 +00:00
|
|
|
|
|
2003-07-25 18:10:34 +00:00
|
|
|
|
QLToolbar(LyXView * o);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
|
2003-04-09 19:53:10 +00:00
|
|
|
|
/// add a new toolbar
|
|
|
|
|
void add(ToolbarBackend::Toolbar const & tb);
|
|
|
|
|
|
|
|
|
|
/// add an item to a toolbar
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void add(QToolBar * tb, FuncRequest const &, std::string const & tooltip);
|
2002-07-22 21:43:27 +00:00
|
|
|
|
|
2003-04-10 14:08:06 +00:00
|
|
|
|
/// show or hide a toolbar
|
|
|
|
|
void displayToolbar(ToolbarBackend::Toolbar const & tb, bool show);
|
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
/// update the state of the icons
|
|
|
|
|
void update();
|
|
|
|
|
|
|
|
|
|
/// select the right layout in the combox
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void setLayout(std::string const & layout);
|
2003-07-25 18:10:34 +00:00
|
|
|
|
/// Populate the layout combox.
|
|
|
|
|
void updateLayoutList();
|
2002-06-19 03:38:44 +00:00
|
|
|
|
/// Drop down the layout list
|
|
|
|
|
void openLayoutList();
|
|
|
|
|
/// Erase the layout list
|
|
|
|
|
void clearLayoutList();
|
|
|
|
|
private:
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void changed_layout(std::string const & sel);
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
|
|
|
|
void button_selected(QToolButton * button);
|
2002-09-24 13:57:09 +00:00
|
|
|
|
|
|
|
|
|
QtView * owner_;
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
|
|
|
|
boost::scoped_ptr<ToolbarProxy> proxy_;
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::map<std::string, QToolBar *> toolbars_;
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
2002-07-21 23:08:30 +00:00
|
|
|
|
QLComboBox * combo_;
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
2003-09-21 18:57:15 +00:00
|
|
|
|
typedef std::map<QToolButton *, FuncRequest> ButtonMap;
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
|
|
|
|
ButtonMap map_;
|
|
|
|
|
};
|
|
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
// moc is mind-numbingly stupid
|
|
|
|
|
class ToolbarProxy : public QObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2003-07-25 18:10:34 +00:00
|
|
|
|
ToolbarProxy(QLToolbar & owner)
|
2002-10-20 01:48:28 +00:00
|
|
|
|
: owner_(owner) {}
|
2002-06-19 03:38:44 +00:00
|
|
|
|
public slots:
|
2002-09-24 13:57:09 +00:00
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
void layout_selected(const QString & str) {
|
2002-12-17 20:37:13 +00:00
|
|
|
|
owner_.changed_layout(fromqstr(str));
|
2002-06-19 03:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void button_selected() {
|
|
|
|
|
owner_.button_selected(
|
|
|
|
|
const_cast<QToolButton *>(
|
|
|
|
|
static_cast<QToolButton const *>(sender()))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
private:
|
2003-07-25 18:10:34 +00:00
|
|
|
|
QLToolbar & owner_;
|
2002-06-19 03:38:44 +00:00
|
|
|
|
};
|
2002-09-24 13:57:09 +00:00
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
#endif
|