rgheck <[EMAIL PROTECTED]> writes: > Well, if you're going to leave InsetInfo until after 1.6, we can do > this together. You can tell me what character styles you want, and > I'll produce definitions of them that you can use. I've already done > this for Customization, as you'll see if you look under Edit>Text > Styles.
What about the following instead: 1/ make InsetInfo depend on InsetCollapsable (this is only because I need this to have an insetlayout, in principle InsetText is OK). 2/ provide styles for the different types of insetinfo 3/ waste a lot of time finding all the small ingredients that makes it work :) I think this works well enough to go in trunk. JMarc
svndiff src/insets/InsetInfo.cpp src/insets/InsetInfo.h lib/layouts/stdinsets.inc Index: src/insets/InsetInfo.cpp =================================================================== --- src/insets/InsetInfo.cpp (revision 26538) +++ src/insets/InsetInfo.cpp (working copy) @@ -47,11 +47,10 @@ namespace lyx { InsetInfo::InsetInfo(Buffer const & buf, string const & name) - : InsetText(buf), type_(UNKNOWN_INFO), name_(), + : InsetCollapsable(buf, Collapsed), type_(UNKNOWN_INFO), name_(), mouse_hover_(false) { setAutoBreakRows(true); - setDrawFrame(true); setInfo(name); } @@ -63,15 +62,15 @@ Inset * InsetInfo::editXY(Cursor & cur, } -void InsetInfo::draw(PainterInfo & pi, int x, int y) const +string InsetInfo::infoType() const { - InsetText::draw(pi, x, y); + return nameTranslator().find(type_); } -string InsetInfo::infoType() const +docstring InsetInfo::name() const { - return nameTranslator().find(type_); + return from_ascii("Info:" + infoType()); } @@ -136,6 +135,7 @@ void InsetInfo::read(Lexer & lex) _("Missing \\end_inset at this point."), from_utf8(token)); } + setLayout(buffer().params()); updateInfo(); } @@ -240,20 +240,21 @@ void InsetInfo::setInfo(string const & n string type; name_ = trim(split(name, type, ' ')); type_ = nameTranslator().find(type); + setLayout(buffer().params()); updateInfo(); } void InsetInfo::error(string const & err) { - InsetText::setText(bformat(_(err), from_utf8(name_)), buffer().params().getFont(), - false); + InsetText::setText(bformat(_(err), from_utf8(name_)), + Font(inherit_font), false); } void InsetInfo::setText(docstring const & str) { - InsetText::setText(str, buffer().params().getFont(), false); + InsetText::setText(str, Font(inherit_font), false); } @@ -281,9 +282,11 @@ void InsetInfo::updateInfo() break; } if (type_ == SHORTCUT_INFO) - setText(bindings.rbegin()->print(KeySequence::Portable)); + InsetText::setText(bindings.rbegin()->print(KeySequence::Portable), + Font(getLayout().font()), false); else - setText(theTopLevelKeymap().printBindings(func)); + InsetText::setText(theTopLevelKeymap().printBindings(func), + Font(getLayout().font()), false); break; } case LYXRC_INFO: { @@ -329,7 +332,7 @@ void InsetInfo::updateInfo() info.insertInset(0, new InsetSpecialChar(InsetSpecialChar::MENU_SEPARATOR), Change(Change::UNCHANGED)); for (i = 0; i != names.back().length(); ++i) - info.insertChar(i, names.back()[i], bp.getFont(), false); + info.insertChar(i, names.back()[i], Font(getLayout().font()), false); names.pop_back(); } break; @@ -379,4 +382,5 @@ docstring InsetInfo::contextMenu(BufferV return from_ascii("context-info"); } + } // namespace lyx Index: src/insets/InsetInfo.h =================================================================== --- src/insets/InsetInfo.h (revision 26538) +++ src/insets/InsetInfo.h (working copy) @@ -12,8 +12,7 @@ #ifndef INSET_INFO_H #define INSET_INFO_H -#include "InsetText.h" -#include "RenderButton.h" +#include "InsetCollapsable.h" #include "Cursor.h" #include "support/gettext.h" @@ -78,7 +77,7 @@ namespace lyx { /** Used to insert index labels */ -class InsetInfo : public InsetText { +class InsetInfo : public InsetCollapsable { public: enum info_type { UNKNOWN_INFO, // Invalid type @@ -95,12 +94,14 @@ public: /// InsetInfo(Buffer const & buf, std::string const & info = std::string()); /// + InsetCode lyxCode() const { return INFO_CODE; } + /// + docstring name() const; + /// Inset * editXY(Cursor & cur, int x, int y); /// EDITABLE editable() const { return NOT_EDITABLE; } /// - void draw(PainterInfo & pi, int x, int y) const; - /// void read(Lexer & lex); /// void write(std::ostream & os) const; @@ -117,8 +118,6 @@ public: /// void doDispatch(Cursor & cur, FuncRequest & cmd); /// - InsetCode lyxCode() const { return INFO_CODE; } - /// void setInfo(std::string const & info); /// update info_ and text void updateInfo(); @@ -128,6 +127,8 @@ public: docstring toolTip(BufferView const & bv, int x, int y) const; /// docstring contextMenu(BufferView const &, int, int) const; + /// should paragraph indendation be ommitted in any case? + bool neverIndent() const { return true; } private: /// The translator between the information type enum and corresponding string. Index: lib/layouts/stdinsets.inc =================================================================== --- lib/layouts/stdinsets.inc (revision 26538) +++ lib/layouts/stdinsets.inc (working copy) @@ -273,3 +273,43 @@ InsetLayout OptArg EndFont MultiPar false End + +InsetLayout Info + Decoration conglomerate +End + +InsetLayout Info:menu + LatexType command + LatexName menuitem + Preamble + \providecommand{\menuitem}[1]{\textsf{#1}} + EndPreamble + Decoration conglomerate + Font + Family sans + EndFont +End + +InsetLayout Info:shortcut + LatexType command + LatexName shortcut + Preamble + \providecommand{\shortcut}[1]{\textsf{#1}} + EndPreamble + Decoration conglomerate + Font + Family sans + EndFont +End + +InsetLayout Info:shortcuts + LatexType command + LatexName shortcut + Preamble + \providecommand{\shortcut}[1]{\textsf{#1}} + EndPreamble + Decoration conglomerate + Font + Family sans + EndFont +End