]> git.lyx.org Git - lyx.git/blobdiff - src/insets/figinset.C
Various updates for insets mostly regarding fixes for text-insets.
[lyx.git] / src / insets / figinset.C
index 127963621cc9f9a6bf8264aaba5ae1f01b4a875f..58697d0dfc1fb24b008637a68b5225626e4d8f68 100644 (file)
@@ -69,9 +69,7 @@ extern BufferView * current_view;
 extern FL_OBJECT * figinset_canvas;
 
 extern char ** environ; // is this only redundtant on linux systems? Lgb.
-extern void UpdateInset(BufferView *, Inset * inset, bool mark_dirty = true);
-// better for asyncron updating:
-void PutInsetIntoInsetUpdateList(Inset * inset);
+
 extern void ProhibitInput();
 extern void AllowInput();
 
@@ -237,11 +235,10 @@ extern "C" int GhostscriptMsg(FL_OBJECT *, Window, int, int,
                                // query current colormap
                                        XColor * cmap = new XColor[gs_allcolors];
                                        for (i = 0; i < gs_allcolors; ++i) cmap[i].pixel = i;
-#if 1
-                                       XQueryColors(tmpdisp, fl_state[fl_get_vclass()].colormap, cmap, gs_allcolors);
-#else
-                                       XQueryColors(tmpdisp, color_map, cmap, gs_allcolors);
-#endif
+                                       XQueryColors(tmpdisp,
+                                                    fl_state[fl_get_vclass()]
+                                                    .colormap, cmap,
+                                                    gs_allcolors);
                                        XFlush(tmpdisp);
                                        wid1 = p->wid - 1;
                                // now we process all the image
@@ -306,7 +303,8 @@ extern "C" int GhostscriptMsg(FL_OBJECT *, Window, int, int,
 }
 
 
-static void AllocColors(int num)
+static
+void AllocColors(int num)
 // allocate color cube numxnumxnum, if possible
 {
        if (lyxerr.debugging()) {
@@ -405,11 +403,6 @@ void InitFigures()
        fl_add_canvas_handler(figinset_canvas, ClientMessage,
                              GhostscriptMsg, current_view->owner()->getMainForm());
 
-#if 0
-       // now we have to init color_map
-       if (!color_map) color_map = DefaultColormap(fl_display,
-                                                   DefaultScreen(fl_display));
-#endif
        // allocate color cube on pseudo-color display
        // first get visual
        gs_color = false;
@@ -451,15 +444,6 @@ void DoneFigures()
 
        fl_remove_canvas_handler(figinset_canvas, ClientMessage,
                                 GhostscriptMsg);
-
-#if 0
-       if (gs_color) {
-               lyxerr.debug() << "Freeing up the colors..." << endl;
-               XFreeColors(fl_display, color_map, gs_pixels,
-                           gs_num_pixels, 0);
-               /******????????????????? what's planes in this case ??????***/
-       }
-#endif
 }
 
 
@@ -474,7 +458,8 @@ int FindBmpIndex(figdata * tmpdata)
 }
 
 
-static void freefigdata(figdata * tmpdata)
+static
+void freefigdata(figdata * tmpdata)
 {
        tmpdata->ref--;
        if (tmpdata->ref) return;
@@ -500,7 +485,8 @@ static void freefigdata(figdata * tmpdata)
 }
 
 
-static void runqueue()
+static
+void runqueue()
 {
        // run queued requests for ghostscript, if any
        if (!gsrunning && gs_color && !gs_xcolor) {
@@ -716,7 +702,8 @@ static void runqueue()
 }
 
 
-static void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
+static
+void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
 {
        // recompute the stuff and put in the queue
        queue_element p;
@@ -734,7 +721,8 @@ static void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
 }
 
 
-static figdata * getfigdata(int wid, int hgh, string const & fname, 
+static
+figdata * getfigdata(int wid, int hgh, string const & fname, 
                            int psx, int psy, int pswid, int pshgh, 
                            int raw_wid, int raw_hgh, float angle, char flags)
 {
@@ -805,13 +793,15 @@ static figdata * getfigdata(int wid, int hgh, string const & fname,
 }
 
 
-static void getbitmap(figdata * p)
+static
+void getbitmap(figdata * p)
 {
        p->gspid = -1;
 }
 
 
-static void makeupdatelist(figdata * p)
+static
+void makeupdatelist(figdata * p)
 {
        for (int i = 0; i < figinsref; ++i)
                if (figures[i]->data == p) {
@@ -821,7 +811,7 @@ static void makeupdatelist(figdata * p)
                                       << endl;
                        }
                        // add inset figures[i]->inset into to_update list
-                       PutInsetIntoInsetUpdateList(figures[i]->inset);
+                       current_view->pushIntoUpdateList(figures[i]->inset);
                }
 }
 
@@ -908,7 +898,8 @@ void sigchldchecker(pid_t pid, int * status)
 }
 
 
-static void getbitmaps()
+static
+void getbitmaps()
 {
        bitmap_waiting = false;
        for (int i = 0; i < bmpinsref; ++i)
@@ -917,7 +908,8 @@ static void getbitmaps()
 }
 
 
-static void RegisterFigure(InsetFig * fi)
+static
+void RegisterFigure(InsetFig * fi)
 {
        if (figinsref == 0) InitFigures();
        fi->form = 0;
@@ -928,7 +920,7 @@ static void RegisterFigure(InsetFig * fi)
                typedef Figref * Figref_p;
                Figref ** tmp = new Figref_p[figarrsize];
                memcpy(tmp, figures,
-                      sizeof(Figref*)*(figarrsize-figallocchunk));
+                      sizeof(Figref*) * (figarrsize-figallocchunk));
                delete[] figures;
                figures = tmp;
        }
@@ -956,7 +948,8 @@ int FindFigIndex(Figref * tmpfig)
 }
 
 
-static void UnregisterFigure(InsetFig * fi)
+static
+void UnregisterFigure(InsetFig * fi)
 {
        Figref * tmpfig = fi->figure;
 
@@ -987,7 +980,8 @@ static void UnregisterFigure(InsetFig * fi)
 }
 
 
-static string NextToken(istream & is)
+static
+string NextToken(istream & is)
 {
        string token;
        char c;
@@ -1208,6 +1202,7 @@ int InsetFig::Latex(ostream & os, signed char /* fragile*/ ) const
 }
 
 
+#ifndef USE_OSTREAM_ONLY
 int InsetFig::Latex(string & file, signed char /* fragile*/ ) const
 {
        Regenerate();
@@ -1233,6 +1228,26 @@ int InsetFig::DocBook(string & file) const
        return 0;
 }
 
+#else
+
+int InsetFig::Linuxdoc(ostream &) const
+{
+       return 0;
+}
+
+
+int InsetFig::DocBook(ostream & os) const
+{
+       string figurename = fname;
+
+       if(suffixIs(figurename, ".eps"))
+               figurename.erase(fname.length() - 5);
+
+       os << "@<graphic fileref=\"" << figurename << "\"></graphic>";
+       return 0;
+}
+#endif
+
 
 void InsetFig::Validate(LaTeXFeatures & features) const
 {
@@ -1241,9 +1256,9 @@ void InsetFig::Validate(LaTeXFeatures & features) const
 }
 
 
-unsigned char InsetFig::Editable() const
+Inset::EDITABLE InsetFig::Editable() const
 {
-       return 1;
+       return IS_EDITABLE;
 }
 
 
@@ -1253,7 +1268,7 @@ bool InsetFig::Deletable() const
 }
 
 
-void InsetFig::Edit(BufferView * bv, int, int)
+void InsetFig::Edit(BufferView * bv, int, int, unsigned int)
 {
        lyxerr.debug() << "Editing InsetFig." << endl;
        Regenerate();
@@ -1891,7 +1906,7 @@ void InsetFig::CallbackFig(long arg)
                                lyxerr << "Update: ["
                                       << wid << 'x' << hgh << ']' << endl;
                        }
-                       UpdateInset(current_view, this);
+                       current_view->updateInset(this, true);
                        if (arg == 8) {
                                fl_set_focus_object(form->Figure, form->OkBtn);
                                fl_hide_form(form->Figure);
@@ -1927,7 +1942,8 @@ void InsetFig::CallbackFig(long arg)
 }
 
 
-inline void DisableFigurePanel(FD_Figure * const form)
+inline
+void DisableFigurePanel(FD_Figure * const form)
 {
         fl_deactivate_object(form->EpsFile);
        fl_deactivate_object(form->Browse);
@@ -1963,7 +1979,8 @@ inline void DisableFigurePanel(FD_Figure * const form)
 }
 
 
-inline void EnableFigurePanel(FD_Figure * const form)
+inline
+void EnableFigurePanel(FD_Figure * const form)
 {
         fl_activate_object(form->EpsFile);
        fl_activate_object(form->Browse);