lyx_mirror/src/frontends/qt2/QLToolbar.h
Angus Leeming 0be0fcfd59 If I ever see another licence blurb again, it'll be too soon...
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7598 a592a061-630c-0410-9148-cb99ea01b6c8
2003-08-23 00:17:00 +00:00

101 lines
1.9 KiB
C++

// -*- C++ -*-
/**
* \file qt2/Toolbar_pimpl.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Lars Gullik Bjønnes
* \author John Levon
* \author Jean-Marc Lasgouttes
*
* Full author contact details are available in file CREDITS.
*/
#ifndef QLTOOLBAR__H
#define QLTOOLBAR_H
#include "frontends/Toolbar.h"
#include "qt_helpers.h"
#include <boost/scoped_ptr.hpp>
#include <map>
#include <vector>
#include <qobject.h>
#include <qtoolbutton.h>
class QtView;
class QToolBar;
class QLComboBox;
class ToolbarProxy;
class QLToolbar : public Toolbar {
public:
friend class ToolbarProxy;
QLToolbar(LyXView * o);
/// 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);
/// show or hide a toolbar
void displayToolbar(ToolbarBackend::Toolbar const & tb, bool show);
/// update the state of the icons
void update();
/// select the right layout in the combox
void setLayout(string const & layout);
/// Populate the layout combox.
void updateLayoutList();
/// Drop down the layout list
void openLayoutList();
/// Erase the layout list
void clearLayoutList();
private:
void changed_layout(string const & sel);
void button_selected(QToolButton * button);
QtView * owner_;
boost::scoped_ptr<ToolbarProxy> proxy_;
std::map<string, QToolBar *> toolbars_;
QLComboBox * combo_;
typedef std::map<QToolButton *, int> ButtonMap;
ButtonMap map_;
};
// moc is mind-numbingly stupid
class ToolbarProxy : public QObject {
Q_OBJECT
public:
ToolbarProxy(QLToolbar & owner)
: owner_(owner) {}
public slots:
void layout_selected(const QString & str) {
owner_.changed_layout(fromqstr(str));
}
void button_selected() {
owner_.button_selected(
const_cast<QToolButton *>(
static_cast<QToolButton const *>(sender()))
);
}
private:
QLToolbar & owner_;
};
#endif