3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author John Levon <moz@compsoc.man.ac.uk>
11 #include "support/filetools.h"
14 #include "QMathDialog.h"
17 #include "ControlMath.h"
18 #include "iconpalette.h"
20 #include <qwidgetstack.h>
21 #include <qcombobox.h>
24 #include <qscrollview.h>
31 class QScrollViewSingle : public QScrollView {
33 QScrollViewSingle(QWidget * p)
35 setResizePolicy(Manual);
36 setHScrollBarMode(AlwaysOff);
37 setVScrollBarMode(AlwaysOn);
38 setMinimumHeight(200);
39 setBackgroundMode(PaletteBackground);
40 viewport()->setBackgroundMode(PaletteBackground);
43 void setChild(QWidget * w) {
45 setMinimumWidth(verticalScrollBar()->width() + w_->width() + 4);
50 virtual void resizeEvent(QResizeEvent * e) {
51 QScrollView::resizeEvent(e);
55 w_->resize(viewport()->width(), w_->height());
56 resizeContents(w_->width(), w_->height());
57 setMinimumHeight(200);
65 QMathDialog::QMathDialog(QMath * form)
66 : QMathDialogBase(0, 0, false, 0),
69 connect(symbolsCO, SIGNAL(activated(int)), symbolsWS, SLOT(raiseWidget(int)));
71 for (int i = 0; *function_names[i]; ++i) {
72 functionsLB->insertItem(function_names[i]);
75 addPanel("operators", latex_bop);
76 addPanel("bigoperators", latex_varsz);
77 addPanel("relations", latex_brel);
78 addPanel("greek", latex_greek);
79 addPanel("arrows", latex_arrow);
80 addPanel("dots", latex_dots);
81 addPanel("deco", latex_deco);
82 addPanel("misc", latex_misc);
83 addPanel("amsoperators", latex_ams_ops);
84 addPanel("amsrelations", latex_ams_rel);
85 addPanel("amsnegrelations", latex_ams_nrel);
86 addPanel("amsarrows", latex_ams_arrows);
87 addPanel("amsmisc", latex_ams_misc);
88 symbolsWS->raiseWidget(0);
89 symbolsWS->resize(symbolsWS->sizeHint());
93 void QMathDialog::addPanel(string const & name, char const ** entries)
97 QScrollViewSingle * view = new QScrollViewSingle(symbolsWS);
98 IconPalette * p = new IconPalette(view->viewport());
100 for (int i = 0; *entries[i]; ++i) {
101 string xpm_name = LibFileSearch("images/math/", entries[i], "xpm");
102 p->add(QPixmap(xpm_name.c_str()), entries[i], string("\\") + entries[i]);
104 connect(p, SIGNAL(button_clicked(string)), this, SLOT(symbol_clicked(string)));
107 symbolsWS->addWidget(view, id++);
111 void QMathDialog::symbol_clicked(string str)
113 form_->insert_symbol(str);
117 void QMathDialog::fracClicked()
119 form_->insert_symbol("frac");
123 void QMathDialog::sqrtClicked()
125 form_->insert_symbol("sqrt");
129 void QMathDialog::delimiterClicked()
134 void QMathDialog::expandClicked()
140 void QMathDialog::functionSelected(const QString & str)
142 form_->insert_symbol(str.latin1());
146 void QMathDialog::matrixClicked()
151 void QMathDialog::spaceClicked()
156 void QMathDialog::styleClicked()
161 void QMathDialog::subscriptClicked()
167 void QMathDialog::superscriptClicked()
169 form_->superscript();