]> git.lyx.org Git - features.git/blobdiff - src/frontends/xforms/lyx_gui.C
change "support/std_sstream.h" to <sstream>
[features.git] / src / frontends / xforms / lyx_gui.C
index aff77003535e53a18f9a05f3b6f86268f84ff8d6..14ff26790e3380ee43e7732efb45541873f8b56d 100644 (file)
 
 #include <boost/bind.hpp>
 
-#include "support/std_sstream.h"
-#include <iomanip>
 #include <fcntl.h>
 
+#include <sstream>
+#include <iomanip>
+
 using lyx::support::AddName;
 using lyx::support::user_lyxdir;
 
+using lyx::frontend::fontloader;
+using lyx::frontend::getRGBColor;
+using lyx::frontend::lyxColorHandler;
+using lyx::frontend::LyXColorHandler;
+using lyx::frontend::XformsColor;
+using lyx::frontend::XFormsView;
+
 namespace os = lyx::support::os;
 
 #ifndef CXX_GLOBAL_CSTD
@@ -284,27 +292,26 @@ void start(string const & batch, vector<string> const & files)
        lyxerr[Debug::GUI] << "Creating view: " << width << 'x' << height
                           << '+' << xpos << '+' << ypos << endl;
 
-       boost::shared_ptr<XFormsView> view_ptr(new XFormsView(width, height));
-       LyX::ref().addLyXView(view_ptr);
+       boost::shared_ptr<XFormsView> view(new XFormsView(width, height));
+       LyX::ref().addLyXView(view);
 
-       XFormsView & view = *view_ptr.get();
-       view.show(xpos, ypos, "LyX");
-       view.init();
+       view->show(xpos, ypos, "LyX");
+       view->init();
 
        // FIXME: some code below needs moving
 
-       lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
-       lyxsocket = new LyXServerSocket(&view.getLyXFunc(),
+       lyxserver = new LyXServer(&view->getLyXFunc(), lyxrc.lyxpipes);
+       lyxsocket = new LyXServerSocket(&view->getLyXFunc(),
                          os::slashify_path(os::getTmpDir() + "/lyxsocket"));
 
        vector<string>::const_iterator cit = files.begin();
        vector<string>::const_iterator end = files.end();
        for (; cit != end; ++cit)
-               view.view()->loadLyXFile(*cit, true);
+               view->view()->loadLyXFile(*cit, true);
 
        // handle the batch commands the user asked for
        if (!batch.empty())
-               view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
+               view->getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
 
        // enter the event loop
        while (!finished) {
@@ -366,6 +373,7 @@ string const hexname(LColor_color col)
 
 void update_color(LColor_color col)
 {
+       lyxColorHandler->getGCForeground(col);
        lyxColorHandler->updateColor(col);
 }
 
@@ -381,60 +389,34 @@ bool font_available(LyXFont const & font)
        return fontloader.available(font);
 }
 
+
 namespace {
 
-extern "C"
-void C_read_callback(int, void * data)
-{
-       LyXComm * comm = static_cast<LyXComm *>(data);
-       comm->read_ready();
-}
+std::map<int, boost::function<void()> > socket_callbacks;
 
 extern "C"
-void C_datasocket_callback(int, void * data)
+void C_socket_callback(int fd, void *)
 {
-       LyXDataSocket * client = static_cast<LyXDataSocket *>(data);
-       client->server()->dataCallback(client);
+       socket_callbacks[fd]();
 }
 
-extern "C"
-void C_serversocket_callback(int, void * data)
-{
-       LyXServerSocket * server = static_cast<LyXServerSocket *>(data);
-       server->serverCallback();
-}
 
-}
+} // NS anon
 
-void set_read_callback(int fd, LyXComm * comm)
-{
-       fl_add_io_callback(fd, FL_READ, C_read_callback, comm);
-}
-
-void remove_read_callback(int fd)
-{
-       fl_remove_io_callback(fd, FL_READ, C_read_callback);
-}
 
-void set_datasocket_callback(LyXDataSocket * p)
+void register_socket_callback(int fd, boost::function<void()> func)
 {
-       fl_add_io_callback(p->fd(), FL_READ, C_datasocket_callback, p);
+       socket_callbacks[fd] = func;
+       fl_add_io_callback(fd, FL_READ, C_socket_callback, 0);
 }
 
-void remove_datasocket_callback(LyXDataSocket * p)
-{
-       fl_remove_io_callback(p->fd(), FL_READ, C_datasocket_callback);
-}
 
-void set_serversocket_callback(LyXServerSocket * p)
+void unregister_socket_callback(int fd)
 {
-       fl_add_io_callback(p->fd(), FL_READ, C_serversocket_callback, p);
+       fl_remove_io_callback(fd, FL_READ, C_socket_callback);
+       socket_callbacks.erase(fd);
 }
 
-void remove_serversocket_callback(LyXServerSocket * p)
-{
-       fl_remove_io_callback(p->fd(), FL_READ, C_serversocket_callback);
-}
 
 string const roman_font_name()
 {