From 1bb56d90c1f3792b59ef643090094c40c5d08a13 Mon Sep 17 00:00:00 2001 From: John Levon Date: Sun, 8 Sep 2002 02:57:10 +0000 Subject: [PATCH] first cut of detachable icon menus. Buggy. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5231 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 5 ++++ src/frontends/qt2/QMathDialog.C | 47 +++++++++++++++++++-------------- src/frontends/qt2/QMathDialog.h | 6 ++++- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index f675a749b5..c915492fce 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2002-09-08 John Levon + + * QMathDialog.h: + * QMathDialog.C: detachable icon menus + 2002-09-08 John Levon * QMathDialog.C: diff --git a/src/frontends/qt2/QMathDialog.C b/src/frontends/qt2/QMathDialog.C index 97c5aff4b4..9ab38c8ba5 100644 --- a/src/frontends/qt2/QMathDialog.C +++ b/src/frontends/qt2/QMathDialog.C @@ -61,6 +61,16 @@ private: QWidget * w_; }; +namespace { + char const ** panels[] = { + latex_bop, latex_varsz, latex_brel, latex_greek, latex_arrow, + latex_dots, latex_deco, latex_misc, latex_ams_ops, + latex_ams_rel, latex_ams_nrel, latex_ams_arrows, + latex_ams_misc + }; + int const nr_panels = sizeof(panels)/sizeof(panels[0]); +} + QMathDialog::QMathDialog(QMath * form) : QMathDialogBase(0, 0, false, 0), @@ -72,37 +82,32 @@ QMathDialog::QMathDialog(QMath * form) functionsLB->insertItem(function_names[i]); } - addPanel("operators", latex_bop); - addPanel("bigoperators", latex_varsz); - addPanel("relations", latex_brel); - addPanel("greek", latex_greek); - addPanel("arrows", latex_arrow); - addPanel("dots", latex_dots); - addPanel("deco", latex_deco); - addPanel("misc", latex_misc); - addPanel("amsoperators", latex_ams_ops); - addPanel("amsrelations", latex_ams_rel); - addPanel("amsnegrelations", latex_ams_nrel); - addPanel("amsarrows", latex_ams_arrows); - addPanel("amsmisc", latex_ams_misc); + for (int i = 0; i < nr_panels; ++i) { + addPanel(panels[i]); + } symbolsWS->raiseWidget(0); symbolsWS->resize(symbolsWS->sizeHint()); } -void QMathDialog::addPanel(string const & name, char const ** entries) +IconPalette * QMathDialog::makePanel(QWidget * parent, char const ** entries) { - static int id = 0; - - QScrollViewSingle * view = new QScrollViewSingle(symbolsWS); - IconPalette * p = new IconPalette(view->viewport()); - + IconPalette * p = new IconPalette(parent); for (int i = 0; *entries[i]; ++i) { string xpm_name = LibFileSearch("images/math/", entries[i], "xpm"); p->add(QPixmap(xpm_name.c_str()), entries[i], string("\\") + entries[i]); } connect(p, SIGNAL(button_clicked(string)), this, SLOT(symbol_clicked(string))); + return p; +} + +void QMathDialog::addPanel(char const ** entries) +{ + static int id = 0; + + QScrollViewSingle * view = new QScrollViewSingle(symbolsWS); + IconPalette * p = makePanel(view->viewport(), entries); view->setChild(p); symbolsWS->addWidget(view, id++); } @@ -133,8 +138,10 @@ void QMathDialog::delimiterClicked() void QMathDialog::expandClicked() { + int const id = symbolsWS->id(symbolsWS->visibleWidget()); + IconPalette * p = makePanel(0, panels[id]); + p->show(); } - void QMathDialog::functionSelected(const QString & str) diff --git a/src/frontends/qt2/QMathDialog.h b/src/frontends/qt2/QMathDialog.h index 9b1d3fd493..ed28a88ffc 100644 --- a/src/frontends/qt2/QMathDialog.h +++ b/src/frontends/qt2/QMathDialog.h @@ -16,6 +16,7 @@ #include "ui/QMathDialogBase.h" class QMath; +class IconPalette; class QMathDialog : public QMathDialogBase { @@ -41,8 +42,11 @@ protected: //needed ? virtual void closeEvent(QCloseEvent * e); private: + /// make a symbol panel + IconPalette * makePanel(QWidget * parent, char const ** entries); + /// add a symbol panel - void addPanel(string const & name, char const ** entries); + void addPanel(char const ** entries); /// owning form QMath * form_;