From 996de70e5694e4eeb01367abdc62d6893c1a59c5 Mon Sep 17 00:00:00 2001 From: Edwin Leuven Date: Thu, 19 Apr 2007 20:29:27 +0000 Subject: [PATCH] * Action.[Ch] add signal that provides action when triggered * ToolbarBackend.[Ch] add popupmenu and iconpallete item types * QLToolbar.[Ch] take care of popupmenu and iconpallete * stdtoolbars.inc add panels and menus (and move spellchecker to main ;-) * functions.xpm icon for function list * iconpalette.[Ch] new iconpanel that will replace old iconpalette, als subclass of qmenu that updates parent toolbutton git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17868 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/images/math/functions.xpm | 28 ++ lib/ui/default.ui | 1 + lib/ui/stdtoolbars.inc | 611 +++++++++++++++++++++++++++++++- src/ToolbarBackend.C | 22 ++ src/ToolbarBackend.h | 6 +- src/frontends/qt4/Action.C | 1 + src/frontends/qt4/Action.h | 4 + src/frontends/qt4/QLToolbar.C | 86 ++++- src/frontends/qt4/QLToolbar.h | 2 +- src/frontends/qt4/iconpalette.C | 158 +++++++++ src/frontends/qt4/iconpalette.h | 52 +++ 11 files changed, 962 insertions(+), 9 deletions(-) create mode 100644 lib/images/math/functions.xpm diff --git a/lib/images/math/functions.xpm b/lib/images/math/functions.xpm new file mode 100644 index 0000000000..058f45c051 --- /dev/null +++ b/lib/images/math/functions.xpm @@ -0,0 +1,28 @@ +/* XPM */ +static char *functions[] = { +/* columns rows colors chars-per-pixel */ +"20 20 2 1", +" c blue", +"X c None", +/* pixels */ +"XXXXXXXXXX XXXXX", +"XXXXXXXXX XXXXX", +"XXXXXXXX XXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXX XXXXXX", +"XXXXX XXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX", +"XXXXXXXX XXXXXXXXX" +}; diff --git a/lib/ui/default.ui b/lib/ui/default.ui index b65720845b..1eefc8bfdb 100644 --- a/lib/ui/default.ui +++ b/lib/ui/default.ui @@ -37,6 +37,7 @@ Toolbars "view/update" "on,right" "review" "review,top" "table" "table,bottom" + "math_panels" "off,top" "math" "math,bottom" "minibuffer" "off,bottom" End diff --git a/lib/ui/stdtoolbars.inc b/lib/ui/stdtoolbars.inc index f8cb737a97..782801527f 100644 --- a/lib/ui/stdtoolbars.inc +++ b/lib/ui/stdtoolbars.inc @@ -16,7 +16,7 @@ # # Toolbar "name" "GUI Name" # -# Only four commands are allowed inside the Toolbar and End +# Only seven commands are allowed inside the Toolbar and End # directives: # Item "The tooltip" " []" adds an icon to the toolbar performing # " " @@ -30,6 +30,17 @@ # # Minibuffer adds the command buffer (Qt only, only one may exist) # +# TableInsert adds a special widget for quick insertion of tables +# +# PopupMenu "name" "GUI Name" +# +# ... inserts a button with a popup menu derived from Toolbar "name" +# +# IconPalette "name" "GUI Name" +# +# ... inserts a button with a popup iconpalette derived from Toolbar "name" +# +# # The icons are found in the lib/images/ direcory under the name # action.xpm or action_parameter.xpm, except for math-insert, which # is e.g. lib/image/math/sum.xpm. Note that some characters are @@ -48,6 +59,8 @@ ToolbarSet Item "Save document" "buffer-write" Item "Print document" "dialog-show print" Separator + Item "Check spelling" "dialog-show spellchecker" + Separator Item "Undo" "undo" Item "Redo" "redo" Item "Cut" "cut" @@ -176,4 +189,600 @@ ToolbarSet Item "Update PostScript" "buffer-update ps" End + Toolbar "math_panels" "Math Panels" + PopupMenu "space" "Math Spacing" + PopupMenu "sqrt-square" "Roots" + PopupMenu "style" "Styles" + PopupMenu "frac-square" "Fractions" + PopupMenu "font" "Fonts" + PopupMenu "functions" "Functions" + IconPalette "latex_deco" "Frame Decorations" + IconPalette "latex_varsz" "Big Operators" + IconPalette "latex_misc" "Miscellaneous" + IconPalette "latex_greek" "Greek" + IconPalette "latex_arrow" "Arrows" + IconPalette "latex_ams_arrows" "AMS Arrows" + IconPalette "latex_bop" "Operators" + IconPalette "latex_brel" "Relations" + IconPalette "latex_ams_rel" "AMS Relations" + IconPalette "latex_ams_nrel" "AMS Negative Relations" + IconPalette "latex_dots" "Dots" + IconPalette "latex_ams_ops" "AMS Operators" + IconPalette "latex_ams_misc" "AMS Miscellaneous" + End + + Toolbar "functions" "Functions" + Item "arccos" "math-insert \arccos" + Item "arcsin" "math-insert \arcsin" + Item "arctan" "math-insert \arctan" + Item "arg" "math-insert \arg" + Item "bmod" "math-insert \bmod" + Item "cos" "math-insert \cos" + Item "cosh" "math-insert \cosh" + Item "cot" "math-insert \cot" + Item "coth" "math-insert \coth" + Item "csc" "math-insert \csc" + Item "deg" "math-insert \deg" + Item "det" "math-insert \det" + Item "dim" "math-insert \dim" + Item "exp" "math-insert \exp" + Item "gcd" "math-insert \gcd" + Item "hom" "math-insert \hom" + Item "inf" "math-insert \inf" + Item "ker" "math-insert \ker" + Item "lg" "math-insert \lg" + Item "lim" "math-insert \lim" + Item "liminf" "math-insert \liminf" + Item "limsup" "math-insert \limsup" + Item "ln" "math-insert \ln" + Item "log" "math-insert \log" + Item "max" "math-insert \max" + Item "min" "math-insert \min" + Item "sec" "math-insert \sec" + Item "sin" "math-insert \sin" + Item "sinh" "math-insert \sinh" + Item "sup" "math-insert \sup" + Item "tan" "math-insert \tan" + Item "tanh" "math-insert \tanh" + Item "Pr" "math-insert \Pr" + End + + Toolbar "space" "Spacing" + Item "Thin space \\," "math-insert \," + Item "Medium space \\:" "math-insert \:" + Item "Thick space \\;" "math-insert \;" + Item "Quadratin space \\quad" "math-insert \quad" + Item "Double quadratin space \\qquad" "math-insert \qquad" + Item "Negative space \\!" "math-insert \!" + End + + Toolbar "sqrt-square" "Roots" + Item "Square root \\sqrt" "math-insert \sqrt" + Item "Other root \\root" "math-insert \root" + End + + Toolbar "style" "Styles" + Item "Display style \\displaystyle" "math-insert \displaystyle" + Item "Normal text style \\textstyle" "math-insert \textstyle" + Item "Script (small) style \\scriptstyle" "math-insert \scriptstyle" + Item "Scriptscript (smaller) style \\scriptscriptstyle" "math-insert \scriptscriptstyle" + End + + Toolbar "frac-square" "Fractions" + Item "Standard \\frac" "math-insert \frac" + Item "No hor. line \\atop" "math-insert \atop" + Item "Nice \\nicefrac" "math-insert \nicefrac" + Item "Text frac (amsmath) \\tfrac" "math-insert \tfrac" + Item "Display frac (amsmath) \\dfrac" "math-insert \dfrac" + Item "Binomial \\choose" "math-insert \choose" + End + + Toolbar "font" "Fonts" + Item "Roman \\mathrm" "math-insert \mathrm" + Item "Bold \\mathbf" "math-insert \mathbf" + Item "Bold symbol \\boldsymbol" "math-insert \boldsymbol" + Item "Sans serif \\mathsf" "math-insert \mathsf" + Item "Italic \\mathit" "math-insert \mathit" + Item "Typewriter \\mathtt" "math-insert \mathtt" + Item "Blackboard \\mathbb" "math-insert \mathbb" + Item "Fraktur \\mathfrak" "math-insert \mathfrak" + Item "Calligraphic \\mathcal" "math-insert \mathcal" + Item "Normal text mode \\textrm" "math-insert \textrm" + End + + Toolbar "latex_dots" "Dots" + Item "ldots" "math-insert \ldots" + Item "cdots" "math-insert \cdots" + Item "vdots" "math-insert \vdots" + Item "ddots" "math-insert \ddots" + End + + Toolbar "latex_deco" "Frame Decorations" + Item "widehat" "math-insert \widehat" + Item "widetilde" "math-insert \widetilde" + Item "overbrace" "math-insert \overbrace" + Item "overleftarrow" "math-insert \overleftarrow" + Item "overrightarrow" "math-insert \overrightarrow" + Item "overline" "math-insert \overline" + Item "underbrace" "math-insert \underbrace" + Item "underline" "math-insert \underline" + Item "underleftarrow" "math-insert \underleftarrow" + Item "underrightarrow" "math-insert \underrightarrow" + Item "underleftrightarrow" "math-insert \underleftrightarrow" + Item "overleftrightarrow" "math-insert \overleftrightarrow" + Item "hat" "math-insert \hat" + Item "acute" "math-insert \acute" + Item "bar" "math-insert \bar" + Item "dot" "math-insert \dot" + Item "check" "math-insert \check" + Item "grave" "math-insert \grave" + Item "vec" "math-insert \vec" + Item "ddot" "math-insert \ddot" + Item "breve" "math-insert \breve" + Item "tilde" "math-insert \tilde" + Item "overset" "math-insert \overset" + Item "underset" "math-insert \underset" + End + + Toolbar "latex_arrow" "Arrows" + Item "leftarrow" "math-insert \leftarrow" + Item "rightarrow" "math-insert \rightarrow" + Item "downarrow" "math-insert \downarrow" + Item "uparrow" "math-insert \uparrow" + Item "updownarrow" "math-insert \updownarrow" + Item "leftrightarrow" "math-insert \leftrightarrow" + Item "Leftarrow" "math-insert \Leftarrow" + Item "Rightarrow" "math-insert \Rightarrow" + Item "Downarrow" "math-insert \Downarrow" + Item "Uparrow" "math-insert \Uparrow" + Item "Updownarrow" "math-insert \Updownarrow" + Item "Leftrightarrow" "math-insert \Leftrightarrow" + Item "Longleftrightarrow" "math-insert \Longleftrightarrow" + Item "Longleftarrow" "math-insert \Longleftarrow" + Item "Longrightarrow" "math-insert \Longrightarrow" + Item "longleftrightarrow" "math-insert \longleftrightarrow" + Item "longleftarrow" "math-insert \longleftarrow" + Item "longrightarrow" "math-insert \longrightarrow" + Item "leftharpoondown" "math-insert \leftharpoondown" + Item "rightharpoondown" "math-insert \rightharpoondown" + Item "mapsto" "math-insert \mapsto" + Item "longmapsto" "math-insert \longmapsto" + Item "nwarrow" "math-insert \nwarrow" + Item "nearrow" "math-insert \nearrow" + Item "leftharpoonup" "math-insert \leftharpoonup" + Item "rightharpoonup" "math-insert \rightharpoonup" + Item "hookleftarrow" "math-insert \hookleftarrow" + Item "hookrightarrow" "math-insert \hookrightarrow" + Item "swarrow" "math-insert \swarrow" + Item "searrow" "math-insert \searrow" + Item "rightleftharpoons" "math-insert \rightleftharpoons" + End + + Toolbar "latex_bop" "Operators" + Item "pm" "math-insert \pm" + Item "cap" "math-insert \cap" + Item "diamond" "math-insert \diamond" + Item "oplus" "math-insert \oplus" + Item "mp" "math-insert \mp" + Item "cup" "math-insert \cup" + Item "bigtriangleup" "math-insert \bigtriangleup" + Item "ominus" "math-insert \ominus" + Item "times" "math-insert \times" + Item "uplus" "math-insert \uplus" + Item "bigtriangledown" "math-insert \bigtriangledown" + Item "otimes" "math-insert \otimes" + Item "div" "math-insert \div" + Item "sqcap" "math-insert \sqcap" + Item "triangleright" "math-insert \triangleright" + Item "oslash" "math-insert \oslash" + Item "cdot" "math-insert \cdot" + Item "sqcup" "math-insert \sqcup" + Item "triangleleft" "math-insert \triangleleft" + Item "odot" "math-insert \odot" + Item "star" "math-insert \star" + Item "vee" "math-insert \vee" + Item "amalg" "math-insert \amalg" + Item "bigcirc" "math-insert \bigcirc" + Item "setminus" "math-insert \setminus" + Item "wedge" "math-insert \wedge" + Item "dagger" "math-insert \dagger" + Item "circ" "math-insert \circ" + Item "bullet" "math-insert \bullet" + Item "wr" "math-insert \wr" + Item "ddagger" "math-insert \ddagger" + End + + Toolbar "latex_brel" "Relations" + Item "leq" "math-insert \leq" + Item "geq" "math-insert \geq" + Item "equiv" "math-insert \equiv" + Item "models" "math-insert \models" + Item "prec" "math-insert \prec" + Item "succ" "math-insert \succ" + Item "sim" "math-insert \sim" + Item "perp" "math-insert \perp" + Item "preceq" "math-insert \preceq" + Item "succeq" "math-insert \succeq" + Item "simeq" "math-insert \simeq" + Item "mid" "math-insert \mid" + Item "ll" "math-insert \ll" + Item "gg" "math-insert \gg" + Item "asymp" "math-insert \asymp" + Item "parallel" "math-insert \parallel" + Item "subset" "math-insert \subset" + Item "supset" "math-insert \supset" + Item "approx" "math-insert \approx" + Item "smile" "math-insert \smile" + Item "subseteq" "math-insert \subseteq" + Item "supseteq" "math-insert \supseteq" + Item "cong" "math-insert \cong" + Item "frown" "math-insert \frown" + Item "sqsubseteq" "math-insert \sqsubseteq" + Item "sqsupseteq" "math-insert \sqsupseteq" + Item "doteq" "math-insert \doteq" + Item "neq" "math-insert \neq" + Item "in" "math-insert \in" + Item "ni" "math-insert \ni" + Item "propto" "math-insert \propto" + Item "notin" "math-insert \notin" + Item "vdash" "math-insert \vdash" + Item "dashv" "math-insert \dashv" + Item "bowtie" "math-insert \bowtie" + End + + Toolbar "latex_greek" "Greek" + Item "alpha" "math-insert \alpha" + Item "beta" "math-insert \beta" + Item "gamma" "math-insert \gamma" + Item "delta" "math-insert \delta" + Item "epsilon" "math-insert \epsilon" + Item "varepsilon" "math-insert \varepsilon" + Item "zeta" "math-insert \zeta" + Item "eta" "math-insert \eta" + Item "theta" "math-insert \theta" + Item "vartheta" "math-insert \vartheta" + Item "iota" "math-insert \iota" + Item "kappa" "math-insert \kappa" + Item "lambda" "math-insert \lambda" + Item "mu" "math-insert \mu" + Item "nu" "math-insert \nu" + Item "xi" "math-insert \xi" + Item "pi" "math-insert \pi" + Item "varpi" "math-insert \varpi" + Item "rho" "math-insert \rho" + Item "sigma" "math-insert \sigma" + Item "varsigma" "math-insert \varsigma" + Item "tau" "math-insert \tau" + Item "upsilon" "math-insert \upsilon" + Item "phi" "math-insert \phi" + Item "varphi" "math-insert \varphi" + Item "chi" "math-insert \chi" + Item "psi" "math-insert \psi" + Item "omega" "math-insert \omega" + Item "Gamma" "math-insert \Gamma" + Item "Delta" "math-insert \Delta" + Item "Theta" "math-insert \Theta" + Item "Lambda" "math-insert \Lambda" + Item "Xi" "math-insert \Xi" + Item "Pi" "math-insert \Pi" + Item "Sigma" "math-insert \Sigma" + Item "Upsilon" "math-insert \Upsilon" + Item "Phi" "math-insert \Phi" + Item "Psi" "math-insert \Psi" + Item "Omega" "math-insert \Omega" + End + + Toolbar "latex_misc" "Miscellaneous" + Item "nabla" "math-insert \nabla" + Item "partial" "math-insert \partial" + Item "infty" "math-insert \infty" + Item "prime" "math-insert \prime" + Item "ell" "math-insert \ell" + Item "emptyset" "math-insert \emptyset" + Item "exists" "math-insert \exists" + Item "forall" "math-insert \forall" + Item "imath" "math-insert \imath" + Item "jmath" "math-insert \jmath" + Item "Re" "math-insert \Re" + Item "Im" "math-insert \Im" + Item "aleph" "math-insert \aleph" + Item "wp" "math-insert \wp" + Item "hbar" "math-insert \hbar" + Item "angle" "math-insert \angle" + Item "top" "math-insert \top" + Item "bot" "math-insert \bot" + Item "Vert" "math-insert \Vert" + Item "neg" "math-insert \neg" + Item "flat" "math-insert \flat" + Item "natural" "math-insert \natural" + Item "sharp" "math-insert \sharp" + Item "surd" "math-insert \surd" + Item "triangle" "math-insert \triangle" + Item "diamondsuit" "math-insert \diamondsuit" + Item "heartsuit" "math-insert \heartsuit" + Item "clubsuit" "math-insert \clubsuit" + Item "spadesuit" "math-insert \spadesuit" + Item "textrm \\AA" "math-insert \textrm \AA" + Item "textrm \\O" "math-insert \textrm \O" + Item "mathcircumflex" "math-insert \mathcircumflex" + Item "_" "math-insert \_" + Item "mathrm T" "math-insert \mathrm T" + Item "mathbb N" "math-insert \mathbb N" + Item "mathbb Z" "math-insert \mathbb Z" + Item "mathbb Q" "math-insert \mathbb Q" + Item "mathbb R" "math-insert \mathbb R" + Item "mathbb C" "math-insert \mathbb C" + Item "mathbb H" "math-insert \mathbb H" + Item "mathcal F" "math-insert \mathcal F" + Item "mathcal L" "math-insert \mathcal L" + Item "mathcal H" "math-insert \mathcal H" + Item "mathcal O" "math-insert \mathcal O" + Item "phantom" "math-insert \phantom" + Item "vphantom" "math-insert \vphantom" + Item "hphantom" "math-insert \hphantom" + End + + Toolbar "latex_varsz" "Big Operators" + Item "sum" "math-insert \sum" + Item "int" "math-insert \int" + Item "intop" "math-insert \intop" + Item "iint" "math-insert \iint" + Item "iintop" "math-insert \iintop" + Item "iiint" "math-insert \iiint" + Item "iiintop" "math-insert \iiintop" + Item "iiiint" "math-insert \iiiint" + Item "iiiintop" "math-insert \iiiintop" + Item "dotsint" "math-insert \dotsint" + Item "dotsintop" "math-insert \dotsintop" + Item "oint" "math-insert \oint" + Item "ointop" "math-insert \ointop" + Item "oiint" "math-insert \oiint" + Item "oiintop" "math-insert \oiintop" + Item "ointctrclockwise" "math-insert \ointctrclockwise" + Item "ointctrclockwiseop" "math-insert \ointctrclockwiseop" + Item "ointclockwise" "math-insert \ointclockwise" + Item "ointclockwiseop" "math-insert \ointclockwiseop" + Item "sqint" "math-insert \sqint" + Item "sqintop" "math-insert \sqintop" + Item "sqiint" "math-insert \sqiint" + Item "sqiintop" "math-insert \sqiintop" + Item "prod" "math-insert \prod" + Item "coprod" "math-insert \coprod" + Item "bigsqcup" "math-insert \bigsqcup" + Item "bigotimes" "math-insert \bigotimes" + Item "bigodot" "math-insert \bigodot" + Item "bigoplus" "math-insert \bigoplus" + Item "bigcap" "math-insert \bigcap" + Item "bigcup" "math-insert \bigcup" + Item "biguplus" "math-insert \biguplus" + Item "bigvee" "math-insert \bigvee" + Item "bigwedge" "math-insert \bigwedge" + End + + Toolbar "latex_ams_misc" "AMS Miscellaneous" + Item "digamma" "math-insert \digamma" + Item "varkappa" "math-insert \varkappa" + Item "beth" "math-insert \beth" + Item "daleth" "math-insert \daleth" + Item "gimel" "math-insert \gimel" + Item "ulcorner" "math-insert \ulcorner" + Item "urcorner" "math-insert \urcorner" + Item "llcorner" "math-insert \llcorner" + Item "lrcorner" "math-insert \lrcorner" + Item "hbar" "math-insert \hbar" + Item "hslash" "math-insert \hslash" + Item "vartriangle" "math-insert \vartriangle" + Item "triangledown" "math-insert \triangledown" + Item "square" "math-insert \square" + Item "lozenge" "math-insert \lozenge" + Item "circledS" "math-insert \circledS" + Item "angle" "math-insert \angle" + Item "measuredangle" "math-insert \measuredangle" + Item "nexists" "math-insert \nexists" + Item "mho" "math-insert \mho" + Item "Finv" "math-insert \Finv" + Item "Game" "math-insert \Game" + Item "Bbbk" "math-insert \Bbbk" + Item "backprime" "math-insert \backprime" + Item "varnothing" "math-insert \varnothing" + Item "blacktriangle" "math-insert \blacktriangle" + Item "blacktriangledown" "math-insert \blacktriangledown" + Item "blacksquare" "math-insert \blacksquare" + Item "blacklozenge" "math-insert \blacklozenge" + Item "bigstar" "math-insert \bigstar" + Item "sphericalangle" "math-insert \sphericalangle" + Item "complement" "math-insert \complement" + Item "eth" "math-insert \eth" + Item "diagup" "math-insert \diagup" + Item "diagdown" "math-insert \diagdown" + End + + Toolbar "latex_ams_arrows" "AMS Arrows" + Item "dashleftarrow" "math-insert \dashleftarrow" + Item "dashrightarrow" "math-insert \dashrightarrow" + Item "leftleftarrows" "math-insert \leftleftarrows" + Item "leftrightarrows" "math-insert \leftrightarrows" + Item "rightrightarrows" "math-insert \rightrightarrows" + Item "rightleftarrows" "math-insert \rightleftarrows" + Item "Lleftarrow" "math-insert \Lleftarrow" + Item "Rrightarrow" "math-insert \Rrightarrow" + Item "twoheadleftarrow" "math-insert \twoheadleftarrow" + Item "twoheadrightarrow" "math-insert \twoheadrightarrow" + Item "leftarrowtail" "math-insert \leftarrowtail" + Item "rightarrowtail" "math-insert \rightarrowtail" + Item "looparrowleft" "math-insert \looparrowleft" + Item "looparrowright" "math-insert \looparrowright" + Item "curvearrowleft" "math-insert \curvearrowleft" + Item "curvearrowright" "math-insert \curvearrowright" + Item "circlearrowleft" "math-insert \circlearrowleft" + Item "circlearrowright" "math-insert \circlearrowright" + Item "Lsh" "math-insert \Lsh" + Item "Rsh" "math-insert \Rsh" + Item "upuparrows" "math-insert \upuparrows" + Item "downdownarrows" "math-insert \downdownarrows" + Item "upharpoonleft" "math-insert \upharpoonleft" + Item "upharpoonright" "math-insert \upharpoonright" + Item "downharpoonleft" "math-insert \downharpoonleft" + Item "downharpoonright" "math-insert \downharpoonright" + Item "leftrightharpoons" "math-insert \leftrightharpoons" + Item "rightleftharpoons" "math-insert \rightleftharpoons" + Item "rightsquigarrow" "math-insert \rightsquigarrow" + Item "leftrightsquigarrow" "math-insert \leftrightsquigarrow" + Item "nleftarrow" "math-insert \nleftarrow" + Item "nrightarrow" "math-insert \nrightarrow" + Item "nleftrightarrow" "math-insert \nleftrightarrow" + Item "nLeftarrow" "math-insert \nLeftarrow" + Item "nRightarrow" "math-insert \nRightarrow" + Item "nLeftrightarrow" "math-insert \nLeftrightarrow" + Item "multimap" "math-insert \multimap" + End + + Toolbar "latex_ams_rel" "AMS Relations" + Item "leqq" "math-insert \leqq" + Item "geqq" "math-insert \geqq" + Item "leqslant" "math-insert \leqslant" + Item "geqslant" "math-insert \geqslant" + Item "eqslantless" "math-insert \eqslantless" + Item "eqslantgtr" "math-insert \eqslantgtr" + Item "lesssim" "math-insert \lesssim" + Item "gtrsim" "math-insert \gtrsim" + Item "lessapprox" "math-insert \lessapprox" + Item "gtrapprox" "math-insert \gtrapprox" + Item "approxeq" "math-insert \approxeq" + Item "triangleq" "math-insert \triangleq" + Item "lessdot" "math-insert \lessdot" + Item "gtrdot" "math-insert \gtrdot" + Item "lll" "math-insert \lll" + Item "ggg" "math-insert \ggg" + Item "lessgtr" "math-insert \lessgtr" + Item "gtrless" "math-insert \gtrless" + Item "lesseqgtr" "math-insert \lesseqgtr" + Item "gtreqless" "math-insert \gtreqless" + Item "lesseqqgtr" "math-insert \lesseqqgtr" + Item "gtreqqless" "math-insert \gtreqqless" + Item "eqcirc" "math-insert \eqcirc" + Item "circeq" "math-insert \circeq" + Item "thicksim" "math-insert \thicksim" + Item "thickapprox" "math-insert \thickapprox" + Item "backsim" "math-insert \backsim" + Item "backsimeq" "math-insert \backsimeq" + Item "subseteqq" "math-insert \subseteqq" + Item "supseteqq" "math-insert \supseteqq" + Item "Subset" "math-insert \Subset" + Item "Supset" "math-insert \Supset" + Item "sqsubset" "math-insert \sqsubset" + Item "sqsupset" "math-insert \sqsupset" + Item "preccurlyeq" "math-insert \preccurlyeq" + Item "succcurlyeq" "math-insert \succcurlyeq" + Item "curlyeqprec" "math-insert \curlyeqprec" + Item "curlyeqsucc" "math-insert \curlyeqsucc" + Item "precsim" "math-insert \precsim" + Item "succsim" "math-insert \succsim" + Item "precapprox" "math-insert \precapprox" + Item "succapprox" "math-insert \succapprox" + Item "vartriangleleft" "math-insert \vartriangleleft" + Item "vartriangleright" "math-insert \vartriangleright" + Item "trianglelefteq" "math-insert \trianglelefteq" + Item "trianglerighteq" "math-insert \trianglerighteq" + Item "bumpeq" "math-insert \bumpeq" + Item "Bumpeq" "math-insert \Bumpeq" + Item "doteqdot" "math-insert \doteqdot" + Item "risingdotseq" "math-insert \risingdotseq" + Item "fallingdotseq" "math-insert \fallingdotseq" + Item "vDash" "math-insert \vDash" + Item "Vvdash" "math-insert \Vvdash" + Item "Vdash" "math-insert \Vdash" + Item "shortmid" "math-insert \shortmid" + Item "shortparallel" "math-insert \shortparallel" + Item "smallsmile" "math-insert \smallsmile" + Item "smallfrown" "math-insert \smallfrown" + Item "blacktriangleleft" "math-insert \blacktriangleleft" + Item "blacktriangleright" "math-insert \blacktriangleright" + Item "because" "math-insert \because" + Item "therefore" "math-insert \therefore" + Item "backepsilon" "math-insert \backepsilon" + Item "varpropto" "math-insert \varpropto" + Item "between" "math-insert \between" + Item "pitchfork" "math-insert \pitchfork" + End + + Toolbar "latex_ams_nrel" "AMS Negative Relations" + Item "nless" "math-insert \nless" + Item "ngtr" "math-insert \ngtr" + Item "nleq" "math-insert \nleq" + Item "ngeq" "math-insert \ngeq" + Item "nleqslant" "math-insert \nleqslant" + Item "ngeqslant" "math-insert \ngeqslant" + Item "nleqq" "math-insert \nleqq" + Item "ngeqq" "math-insert \ngeqq" + Item "lneq" "math-insert \lneq" + Item "gneq" "math-insert \gneq" + Item "lneqq" "math-insert \lneqq" + Item "gneqq" "math-insert \gneqq" + Item "lvertneqq" "math-insert \lvertneqq" + Item "gvertneqq" "math-insert \gvertneqq" + Item "lnsim" "math-insert \lnsim" + Item "gnsim" "math-insert \gnsim" + Item "lnapprox" "math-insert \lnapprox" + Item "gnapprox" "math-insert \gnapprox" + Item "nprec" "math-insert \nprec" + Item "nsucc" "math-insert \nsucc" + Item "npreceq" "math-insert \npreceq" + Item "nsucceq" "math-insert \nsucceq" + Item "precnsim" "math-insert \precnsim" + Item "succnsim" "math-insert \succnsim" + Item "precnapprox" "math-insert \precnapprox" + Item "succnapprox" "math-insert \succnapprox" + Item "subsetneq" "math-insert \subsetneq" + Item "supsetneq" "math-insert \supsetneq" + Item "subsetneqq" "math-insert \subsetneqq" + Item "supsetneqq" "math-insert \supsetneqq" + Item "nsubseteq" "math-insert \nsubseteq" + Item "nsupseteq" "math-insert \nsupseteq" + Item "nsupseteqq" "math-insert \nsupseteqq" + Item "nvdash" "math-insert \nvdash" + Item "nvDash" "math-insert \nvDash" + Item "nVDash" "math-insert \nVDash" + Item "varsubsetneq" "math-insert \varsubsetneq" + Item "varsupsetneq" "math-insert \varsupsetneq" + Item "varsubsetneqq" "math-insert \varsubsetneqq" + Item "varsupsetneqq" "math-insert \varsupsetneqq" + Item "ntriangleleft" "math-insert \ntriangleleft" + Item "ntriangleright" "math-insert \ntriangleright" + Item "ntrianglelefteq" "math-insert \ntrianglelefteq" + Item "ntrianglerighteq" "math-insert \ntrianglerighteq" + Item "ncong" "math-insert \ncong" + Item "nsim" "math-insert \nsim" + Item "nmid" "math-insert \nmid" + Item "nshortmid" "math-insert \nshortmid" + Item "nparallel" "math-insert \nparallel" + Item "nshortparallel" "math-insert \nshortparallel" + End + + Toolbar "latex_ams_ops" "AMS Operators" + Item "dotplus" "math-insert \dotplus" + Item "smallsetminus" "math-insert \smallsetminus" + Item "Cap" "math-insert \Cap" + Item "Cup" "math-insert \Cup" + Item "barwedge" "math-insert \barwedge" + Item "veebar" "math-insert \veebar" + Item "doublebarwedge" "math-insert \doublebarwedge" + Item "boxminus" "math-insert \boxminus" + Item "boxtimes" "math-insert \boxtimes" + Item "boxdot" "math-insert \boxdot" + Item "boxplus" "math-insert \boxplus" + Item "divideontimes" "math-insert \divideontimes" + Item "ltimes" "math-insert \ltimes" + Item "rtimes" "math-insert \rtimes" + Item "leftthreetimes" "math-insert \leftthreetimes" + Item "rightthreetimes" "math-insert \rightthreetimes" + Item "curlywedge" "math-insert \curlywedge" + Item "curlyvee" "math-insert \curlyvee" + Item "circleddash" "math-insert \circleddash" + Item "circledast" "math-insert \circledast" + Item "circledcirc" "math-insert \circledcirc" + Item "centerdot" "math-insert \centerdot" + Item "intercal" "math-insert \intercal" + End + End diff --git a/src/ToolbarBackend.C b/src/ToolbarBackend.C index ccb37649a9..a10832ec15 100644 --- a/src/ToolbarBackend.C +++ b/src/ToolbarBackend.C @@ -87,14 +87,18 @@ ToolbarInfo & ToolbarInfo::read(LyXLex & lex) TO_LAYOUTS, TO_MINIBUFFER, TO_TABLEINSERT, + TO_POPUPMENU, + TO_ICONPALETTE, TO_LAST }; struct keyword_item toolTags[TO_LAST - 1] = { { "end", TO_ENDTOOLBAR }, + { "iconpalette", TO_ICONPALETTE }, { "item", TO_COMMAND }, { "layouts", TO_LAYOUTS }, { "minibuffer", TO_MINIBUFFER }, + { "popupmenu", TO_POPUPMENU }, { "separator", TO_SEPARATOR }, { "tableinsert", TO_TABLEINSERT } }; @@ -152,6 +156,24 @@ ToolbarInfo & ToolbarInfo::read(LyXLex & lex) FuncRequest(kb_action(ToolbarItem::SEPARATOR)))); break; + case TO_POPUPMENU: + if (lex.next(true)) { + string const name = lex.getString(); + lex.next(true); + docstring const label = lex.getDocString(); + add(ToolbarItem(ToolbarItem::POPUPMENU, name, label)); + } + break; + + case TO_ICONPALETTE: + if (lex.next(true)) { + string const name = lex.getString(); + lex.next(true); + docstring const label = lex.getDocString(); + add(ToolbarItem(ToolbarItem::ICONPALETTE, name, label)); + } + break; + case TO_LAYOUTS: add(ToolbarItem(ToolbarItem::LAYOUTS, FuncRequest(kb_action(ToolbarItem::LAYOUTS)))); diff --git a/src/ToolbarBackend.h b/src/ToolbarBackend.h index 6149a6f99b..ec9af8fea8 100644 --- a/src/ToolbarBackend.h +++ b/src/ToolbarBackend.h @@ -35,7 +35,11 @@ public: /// a special combox insead of a button LAYOUTS, /// a special widget to insert tabulars - TABLEINSERT + TABLEINSERT, + /// + POPUPMENU, + /// + ICONPALETTE }; ToolbarItem(Type type, diff --git a/src/frontends/qt4/Action.C b/src/frontends/qt4/Action.C index 987d2b655f..b0f244742a 100644 --- a/src/frontends/qt4/Action.C +++ b/src/frontends/qt4/Action.C @@ -91,6 +91,7 @@ void Action::action() // LYXERR(Debug::ACTION) << "calling LyXFunc::dispatch: func_: " << func_ << endl; lyxView_.dispatch(func_); + triggered(this); } } // namespace frontend diff --git a/src/frontends/qt4/Action.h b/src/frontends/qt4/Action.h index 06dbf18898..03a3e0da8d 100644 --- a/src/frontends/qt4/Action.h +++ b/src/frontends/qt4/Action.h @@ -47,6 +47,10 @@ public: // void setAction(FuncRequest const & func); +Q_SIGNALS: + /// the current action is triggered + void triggered(QAction *); + private Q_SLOTS: void action(); diff --git a/src/frontends/qt4/QLToolbar.C b/src/frontends/qt4/QLToolbar.C index 9b114a7e8b..199edffa5e 100644 --- a/src/frontends/qt4/QLToolbar.C +++ b/src/frontends/qt4/QLToolbar.C @@ -21,6 +21,7 @@ #include "FuncStatus.h" #include "gettext.h" #include "lyxfunc.h" +#include "iconpalette.h" #include "GuiView.h" #include "QLToolbar.h" @@ -31,6 +32,7 @@ #include "support/filetools.h" #include "support/lstrings.h" #include "controllers/ControlMath.h" +#include "ToolbarBackend.h" #include #include @@ -38,11 +40,16 @@ #include #include -using std::endl; -using std::string; namespace lyx { +using std::string; +using std::endl; +using support::FileName; +using support::libFileSearch; +using support::subst; + + using support::libFileSearch; using support::subst; @@ -189,7 +196,7 @@ void QLToolbar::add(ToolbarItem const & item) tb->setCheckable(true); tb->setIcon(QPixmap(toqstr(getIcon(FuncRequest(LFUN_TABULAR_INSERT))))); tb->setToolTip(toqstr(item.label_)); - tb->setFocusPolicy(Qt::NoFocus); + tb->setStatusTip(toqstr(item.label_)); InsertTableWidget * iv = new InsertTableWidget(owner_, tb); connect(tb, SIGNAL(clicked(bool)), iv, SLOT(show(bool))); connect(iv, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool))); @@ -197,7 +204,69 @@ void QLToolbar::add(ToolbarItem const & item) addWidget(tb); break; } - default: { + case ToolbarItem::ICONPALETTE: { + QToolButton * tb = new QToolButton(this); + tb->setCheckable(true); + tb->setToolTip(toqstr(item.label_)); + tb->setStatusTip(toqstr(item.label_)); + tb->setText(toqstr(item.label_)); + connect(this, SIGNAL(iconSizeChanged(const QSize &)), + tb, SLOT(setIconSize(const QSize &))); + + IconPanel * panel = new IconPanel(tb); + connect(this, SIGNAL(updated()), panel, SLOT(updateParent())); + ToolbarInfo const & tbb = toolbarbackend.getToolbar(item.name_); + ToolbarInfo::item_iterator it = tbb.items.begin(); + ToolbarInfo::item_iterator const end = tbb.items.end(); + for (; it != end; ++it) + if (!lyx::getStatus(it->func_).unknown()) { + Action * action = new Action(owner_, + getIcon(it->func_), + it->label_, + it->func_, + it->label_); + panel->addButton(action); + ActionVector.push_back(action); + // use the icon of first action for the toolbar button + if (it == tbb.items.begin()) + tb->setIcon(QPixmap(getIcon(it->func_).c_str())); + } + connect(tb, SIGNAL(clicked(bool)), panel, SLOT(setVisible(bool))); + connect(panel, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool))); + addWidget(tb); + break; + } + case ToolbarItem::POPUPMENU: { + QToolButton * tb = new QToolButton; + tb->setPopupMode(QToolButton::InstantPopup); + tb->setToolTip(toqstr(item.label_)); + tb->setStatusTip(toqstr(item.label_)); + tb->setText(toqstr(item.label_)); + FileName icon_path = libFileSearch("images/math", item.name_, "xpm"); + tb->setIcon(QIcon(toqstr(icon_path.absFilename()))); + connect(this, SIGNAL(iconSizeChanged(const QSize &)), + tb, SLOT(setIconSize(const QSize &))); + + ButtonMenu * m = new ButtonMenu(toqstr(item.label_), tb); + connect(this, SIGNAL(updated()), m, SLOT(updateParent())); + ToolbarInfo const & tbb = toolbarbackend.getToolbar(item.name_); + ToolbarInfo::item_iterator it = tbb.items.begin(); + ToolbarInfo::item_iterator const end = tbb.items.end(); + for (; it != end; ++it) + if (!lyx::getStatus(it->func_).unknown()) { + Action * action = new Action(owner_, + getIcon(it->func_, false), + it->label_, + it->func_, + it->label_); + m->add(action); + ActionVector.push_back(action); + } + tb->setMenu(m); + addWidget(tb); + break; + } + case ToolbarItem::COMMAND: { if (lyx::getStatus(item.func_).unknown()) break; @@ -210,6 +279,8 @@ void QLToolbar::add(ToolbarItem const & item) ActionVector.push_back(action); break; } + default: + break; } } @@ -269,7 +340,7 @@ void QLToolbar::update() } -string const getIcon(FuncRequest const & f) +string const getIcon(FuncRequest const & f, bool unknown) { using frontend::find_xpm; @@ -308,7 +379,10 @@ string const getIcon(FuncRequest const & f) LYXERR(Debug::GUI) << "Cannot find icon for command \"" << lyxaction.getActionName(f.action) << '(' << to_utf8(f.argument()) << ")\"" << endl; - return libFileSearch("images", "unknown", "xpm").absFilename(); + if (unknown) + return libFileSearch("images", "unknown", "xpm").absFilename(); + else + return string(); } diff --git a/src/frontends/qt4/QLToolbar.h b/src/frontends/qt4/QLToolbar.h index b939c5bd7e..5da713af17 100644 --- a/src/frontends/qt4/QLToolbar.h +++ b/src/frontends/qt4/QLToolbar.h @@ -87,7 +87,7 @@ private: }; /// return a full path of an XPM for the given action -std::string const getIcon(FuncRequest const & f); +std::string const getIcon(FuncRequest const & f, bool unknown = true); } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/iconpalette.C b/src/frontends/qt4/iconpalette.C index 32b3b62cb8..d811816f17 100644 --- a/src/frontends/qt4/iconpalette.C +++ b/src/frontends/qt4/iconpalette.C @@ -17,7 +17,14 @@ #include #include #include +#include #include +#include +#include +#include +#include +#include +#include using std::make_pair; using std::string; @@ -187,6 +194,157 @@ void IconPalette::clicked() } +IconPanel::IconPanel(QWidget * parent) + : QWidget(parent, Qt::Popup) +{ + layout_ = new QGridLayout(this); + layout_->setSpacing(0); + layout_->setMargin(3); + setLayout(layout_); +} + + +void IconPanel::addButton(QAction * action) +{ + actions_.push_back(action); + QToolButton * tb = new QToolButton; + tb->setAutoRaise(true); + tb->setDefaultAction(action); + connect(tb, SIGNAL(triggered(QAction *)), + this, SLOT(clicked(QAction *))); + QToolBar * toolbar = qobject_cast(parentWidget()->parentWidget()); + connect(toolbar, SIGNAL(iconSizeChanged(const QSize &)), + tb, SLOT(setIconSize(const QSize &))); + + int const i = actions_.size(); + int const ncols = qMin(6, i); + int const row = (i - 1)/ncols + 1; + int const col = qMax(1, i - (row - 1) * 6); + layout_->addWidget(tb, row, col); +} + + +void IconPanel::clicked(QAction * action) +{ + triggered(action); + setVisible(false); +} + + +void IconPanel::showEvent(QShowEvent * event) +{ + int hoffset = - parentWidget()->pos().x(); + int voffset = - parentWidget()->pos().y(); + int const parwidth = parentWidget()->geometry().width(); + int const parheight = parentWidget()->geometry().height(); + + // vertical toolbar? + QToolBar * toolbar = qobject_cast(parentWidget()->parentWidget()); + if (toolbar && toolbar->orientation() == Qt::Vertical) { + hoffset += parwidth; + voffset -= parheight; + } + + QRect const screen = qApp->desktop()->availableGeometry(this); + QPoint const gpos = parentWidget()->mapToGlobal( + parentWidget()->geometry().bottomLeft()); + + // space to the right? + if (gpos.x() + hoffset + width() > screen.width()) { + hoffset -= width(); + if (toolbar && toolbar->orientation() == Qt::Vertical) + hoffset -= parwidth; + else + hoffset += parwidth; + } + // space at the bottom? + if (gpos.y() + voffset + height() > screen.height()) { + voffset -= height(); + if (toolbar && toolbar->orientation() == Qt::Horizontal) + voffset -= parheight; + else + voffset += parheight; + } + + move(gpos.x() + hoffset, gpos.y() + voffset); + QWidget::showEvent(event); +} + + +void IconPanel::hideEvent(QHideEvent * event ) +{ + visible(false); + QWidget::hideEvent(event); +} + + +void IconPanel::updateParent() +{ + bool enable = false; + for (int i = 0; i < actions_.size(); ++i) + if (actions_.at(i)->isEnabled()) { + enable = true; + break; + } + + parentWidget()->setEnabled(enable); +} + + +void IconPanel::paintEvent(QPaintEvent * event) +{ + // draw border + QPainter p(this); + QRegion emptyArea = QRegion(rect()); + const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); + if (fw) { + QRegion borderReg; + borderReg += QRect(0, 0, fw, height()); //left + borderReg += QRect(width()-fw, 0, fw, height()); //right + borderReg += QRect(0, 0, width(), fw); //top + borderReg += QRect(0, height()-fw, width(), fw); //bottom + p.setClipRegion(borderReg); + emptyArea -= borderReg; + QStyleOptionFrame frame; + frame.rect = rect(); + frame.palette = palette(); + frame.state = QStyle::State_None; + frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuPanelWidth); + frame.midLineWidth = 0; + style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, &p, this); + } + p.end(); + // draw the rest (buttons) + QWidget::paintEvent(event); +} + + +ButtonMenu::ButtonMenu(const QString & title, QWidget * parent) + : QMenu(title, parent) +{ +} + + +void ButtonMenu::add(QAction * action) +{ + addAction(action); + actions_.push_back(action); +} + + +void ButtonMenu::updateParent() +{ + bool enable = false; + for (int i = 0; i < actions_.size(); ++i) + if (actions_.at(i)->isEnabled()) { + enable = true; + break; + } + + parentWidget()->setEnabled(enable); +} + + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/iconpalette.h b/src/frontends/qt4/iconpalette.h index d8f3aaa21a..d91c7ae8c2 100644 --- a/src/frontends/qt4/iconpalette.h +++ b/src/frontends/qt4/iconpalette.h @@ -15,11 +15,13 @@ #include #include #include +#include #include #include #include #include +#include "Action.h" class QPushButton; @@ -69,6 +71,56 @@ private: }; +/** + * For holding an arbitrary set of icons. + * is susceptible to replace IconPalette + */ +class IconPanel : public QWidget { + Q_OBJECT +public: + IconPanel(QWidget * parent); + void addButton(QAction *); + +public Q_SLOTS: + void updateParent(); + +Q_SIGNALS: + void triggered(QAction *); + void visible(bool); + +protected: + void showEvent(QShowEvent * event); + void hideEvent(QHideEvent * event); + void paintEvent(QPaintEvent * event); + +private Q_SLOTS: + virtual void clicked(QAction *); + +private: + QGridLayout * layout_; + QList actions_; +}; + +/** + * Popup menu for a toolbutton. + * We need this to keep track whether + * it is necessary to enable/disable + * the toolbutton + */ +class ButtonMenu : public QMenu { + Q_OBJECT +public: + ButtonMenu(const QString & title, QWidget * parent = 0 ); + void add(QAction *); + +public Q_SLOTS: + void updateParent(); + +private: + QList actions_; +}; + + } // namespace frontend } // namespace lyx