]> git.lyx.org Git - features.git/blobdiff - src/insets/insetgraphics.C
small stuff
[features.git] / src / insets / insetgraphics.C
index 6b66c8a0363f9ef9b79b6b1b509680008cbec4bc..6ffb2d4155ed3475b7601549e7c7813914abc524 100644 (file)
@@ -165,6 +165,17 @@ InsetGraphics::InsetGraphics()
 {}
 
 
+InsetGraphics::InsetGraphics(InsetGraphics const & ig, bool same_id)
+       : Inset(), SigC::Object()
+       , cacheHandle(ig.cacheHandle)
+       , imageLoaded(ig.imageLoaded)
+{
+       setParams(ig.getParams());
+       if (same_id)
+               id_ = ig.id_;
+}
+
+
 InsetGraphics::~InsetGraphics()
 {
        // Emits the hide signal to the dialog connected (if any)
@@ -250,16 +261,16 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
        int lwidth = width(bv, font);
 
        // Make sure x is updated upon exit from this routine
-       float old_x = x;
+       int old_x = int(x);
        x += lwidth;
 
        // This will draw the graphics. If the graphics has not been loaded yet,
        // we draw just a rectangle.
        if (imageLoaded) {
 
-               paint.image(int(old_x) + 2, baseline - lascent,
-                            lwidth - 4, lascent + ldescent,
-                                        cacheHandle->getImage());
+               paint.image(old_x + 2, baseline - lascent,
+                           lwidth - 4, lascent + ldescent,
+                           cacheHandle->getImage());
        } else {
                
                // Get the image status, default to unknown error.
@@ -276,25 +287,24 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
                        return;
                }
 
-               string const msg = statusMessage();
                
-               paint.rectangle(int(old_x) + 2, baseline - lascent,
+               paint.rectangle(old_x + 2, baseline - lascent,
                                lwidth - 4,
                                lascent + ldescent);
 
+               string const msg = statusMessage();
                if (!msg.empty()) {
                        // Print the message.
                        LyXFont msgFont(font);
                        msgFont.setFamily(LyXFont::SANS_FAMILY);
                        msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
                        string const justname = OnlyFilename (params.filename);
-                       paint.text(int(old_x) + 8, 
-                                       baseline - lyxfont::maxAscent(msgFont) - 4,
-                                   justname, msgFont);
+                       paint.text(old_x + 8, 
+                                  baseline - lyxfont::maxAscent(msgFont) - 4,
+                                  justname, msgFont);
 
                        msgFont.setSize(LyXFont::SIZE_TINY);
-                       paint.text(int(old_x) + 8, baseline - 4, 
-                                       msg, msgFont);
+                       paint.text(old_x + 8, baseline - 4, msg, msgFont);
                }
        }
 }
@@ -306,6 +316,12 @@ void InsetGraphics::edit(BufferView *bv, int, int, unsigned int)
 }
 
 
+void InsetGraphics::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
 Inset::EDITABLE InsetGraphics::editable() const
 {
        return IS_EDITABLE;
@@ -555,7 +571,8 @@ int InsetGraphics::docBook(Buffer const * buf, ostream & os) const
 {
        // Change the path to be relative to the main file.
        string const buffer_dir = OnlyPath(buf->fileName());
-       string const filename = RemoveExtension(MakeRelPath(params.filename, buffer_dir));
+       string const filename = RemoveExtension(
+                                  MakeRelPath(params.filename, buffer_dir));
 
        // In DocBook v5.0, the graphic tag will be eliminated from DocBook, will 
        // need to switch to MediaObject. However, for now this is sufficient and 
@@ -621,18 +638,7 @@ InsetGraphicsParams InsetGraphics::getParams() const
 }
 
 
-Inset * InsetGraphics::clone(Buffer const &, bool) const
+Inset * InsetGraphics::clone(Buffer const &, bool same_id) const
 {
-#ifdef WITH_WARNINGS
-#warning use the copy constructor instead. (Lgb)
-#warning and then please honor the same_id flag (Jug)
-#endif
-       InsetGraphics * newInset = new InsetGraphics;
-
-       newInset->cacheHandle = cacheHandle;
-       newInset->imageLoaded = imageLoaded;
-
-       newInset->setParams(getParams());
-
-       return newInset;
+       return new InsetGraphics(*this, same_id);
 }