]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettext.C
insetcharstyle drawing cosmetics
[lyx.git] / src / insets / insettext.C
index a17764b90e2deff4c9dfe1e260ba06469a071979..ba6feb7617bebfc96a5168a871c7f8b84bf349dc 100644 (file)
@@ -69,7 +69,7 @@ using std::vector;
 
 
 InsetText::InsetText(BufferParams const & bp)
-       : autoBreakRows_(false), drawFrame_(NEVER),
+       : autoBreakRows_(false), drawFrame_(false),
          frame_color_(LColor::insetframe), text_(0)
 {
        paragraphs().push_back(Paragraph());
@@ -88,6 +88,10 @@ InsetText::InsetText(InsetText const & in)
 }
 
 
+InsetText::InsetText() : text_(0)
+{}
+
+
 void InsetText::operator=(InsetText const & in)
 {
        UpdatableInset::operator=(in);
@@ -148,7 +152,9 @@ void InsetText::read(Buffer const & buf, LyXLex & lex)
 {
        clear(false);
 
+#ifdef WITH_WARNINGS
 #warning John, look here. Doesnt make much sense.
+#endif
        if (buf.params().tracking_changes)
                paragraphs().begin()->trackChanges();
 
@@ -199,7 +205,7 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
 
        text_.draw(pi, x, y + bv->top_y());
 
-       if (drawFrame_ == ALWAYS || drawFrame_ == LOCKED)
+       if (drawFrame_)
                drawFrame(pi.pain, x, y);
 }
 
@@ -243,7 +249,7 @@ void InsetText::updateLocal(LCursor & cur)
                        }
 
                        cur.clearSelection();
-                       mergeParagraph(cur.bv().buffer()->params(), paragraphs(), 0);
+                       mergeParagraph(cur.buffer().params(), paragraphs(), 0);
                }
        }
 
@@ -253,7 +259,7 @@ void InsetText::updateLocal(LCursor & cur)
        LyXView * lv = cur.bv().owner();
        lv->view_state_changed();
        lv->updateMenubar();
-       lv->updateToolbar();
+       lv->updateToolbars();
        if (old_par != cur.par()) {
                lv->setLayout(text_.getPar(cur.par()).layout()->name());
                old_par = cur.par();
@@ -267,18 +273,6 @@ string const InsetText::editMessage() const
 }
 
 
-void InsetText::sanitizeEmptyText(BufferView & bv)
-{
-       if (paragraphs().size() == 1
-           && paragraphs().begin()->empty()
-           && bv.getParentLanguage(this) != text_.current_font.language()) {
-               LyXFont font(LyXFont::ALL_IGNORE);
-               font.setLanguage(bv.getParentLanguage(this));
-               text_.setFont(bv.cursor(), font, false);
-       }
-}
-
-
 void InsetText::edit(LCursor & cur, bool left)
 {
        //lyxerr << "InsetText: edit left/right" << endl;
@@ -289,14 +283,16 @@ void InsetText::edit(LCursor & cur, bool left)
        text_.setCursor(cur.top(), par, pos);
        cur.clearSelection();
        finishUndo();
-       sanitizeEmptyText(cur.bv());
-       updateLocal(cur);
+#ifdef WITH_WARNINGS
+#warning can someone check if/when this is needed?
+#endif
+//Andre?
+//     updateLocal(cur);
 }
 
 
-InsetBase * InsetText::editXY(LCursor & cur, int x, int y)
+InsetBase * InsetText::editXY(LCursor & cur, int x, int y) const
 {
-       lyxerr << "InsetText::edit xy" << endl;
        old_par = -1;
        return text_.editXY(cur, x, y);
        //sanitizeEmptyText(cur.bv());
@@ -312,16 +308,6 @@ void InsetText::priv_dispatch(LCursor & cur, FuncRequest & cmd)
        bool was_empty = paragraphs().begin()->empty() && paragraphs().size() == 1;
        text_.dispatch(cur, cmd);
 
-       // If the action has deleted all text in the inset, we need
-       // to change the language to the language of the surronding
-       // text.
-       // Why this cleverness? (Andre')
-       if (!was_empty && paragraphs().begin()->empty() &&
-           paragraphs().size() == 1) {
-               LyXFont font(LyXFont::ALL_IGNORE);
-               font.setLanguage(cur.bv().getParentLanguage(this));
-               text_.setFont(cur, font, false);
-       }
 }
 
 
@@ -366,7 +352,7 @@ int InsetText::linuxdoc(Buffer const & buf, ostream & os,
 int InsetText::docbook(Buffer const & buf, ostream & os,
                       OutputParams const & runparams) const
 {
-       docbookParagraphs(buf, paragraphs(), os, runparams);
+       docbookParagraphs(paragraphs(), buf, os, runparams);
        return 0;
 }
 
@@ -378,10 +364,10 @@ void InsetText::validate(LaTeXFeatures & features) const
 }
 
 
-void InsetText::getCursorPos(CursorSlice const & cur, int & x, int & y) const
+void InsetText::getCursorPos(LCursor const & cur, int & x, int & y) const
 {
-       x = text_.cursorX(cur);
-       y = text_.cursorY(cur);
+       x = text_.cursorX(cur.top());
+       y = text_.cursorY(cur.top());
 }
 
 
@@ -438,9 +424,9 @@ void InsetText::setAutoBreakRows(bool flag)
 }
 
 
-void InsetText::setDrawFrame(DrawFrame how)
+void InsetText::setDrawFrame(bool flag)
 {
-       drawFrame_ = how;
+       drawFrame_ = flag;
 }
 
 
@@ -485,9 +471,11 @@ LyXText * InsetText::getText(int i) const
 
 void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist)
 {
+#ifdef WITH_WARNINGS
 #warning FIXME Check if Changes stuff needs changing here. (Lgb)
 // And it probably does. You have to take a look at this John. (Lgb)
 #warning John, have a look here. (Lgb)
+#endif
        ParagraphList::iterator pit = plist.begin();
        ParagraphList::iterator ins = paragraphs().insert(paragraphs().end(), *pit);
        ++pit;
@@ -514,7 +502,13 @@ void InsetText::addPreview(PreviewLoader & loader) const
 }
 
 
-ParagraphList & InsetText::paragraphs() const
+ParagraphList const & InsetText::paragraphs() const
+{
+       return text_.paragraphs();
+}
+
+
+ParagraphList & InsetText::paragraphs()
 {
-       return const_cast<ParagraphList &>(text_.paragraphs());
+       return text_.paragraphs();
 }