]> git.lyx.org Git - features.git/commitdiff
also support the geometry option on Windows + Qt/Windows
authorPeter Kümmel <syntheticpp@gmx.net>
Wed, 29 Nov 2006 16:45:38 +0000 (16:45 +0000)
committerPeter Kümmel <syntheticpp@gmx.net>
Wed, 29 Nov 2006 16:45:38 +0000 (16:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16105 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/Application.C
src/frontends/Application.h
src/frontends/LyXView.h
src/frontends/qt4/GuiView.C
src/frontends/qt4/GuiView.h
src/lyx_main.C
src/lyx_main.h

index 7d2dc985521a4b855ff8ab8e11073fad48f39818..2ed3a01beab3c796c258b11ae151c622d0e92cb9 100644 (file)
@@ -52,7 +52,8 @@ LyXView & Application::createView(unsigned int width,
                                                                  unsigned int height,
                                                                  int posx, int posy,
                                                                  bool maximize,
-                                                                 unsigned int iconSizeXY)
+                                                                 unsigned int iconSizeXY,
+                                                                 const std::string & geometryArg)
 {
        int view_id = gui().newView();
        LyXView & view = gui().view(view_id);
@@ -62,7 +63,7 @@ LyXView & Application::createView(unsigned int width,
        /*int workArea_id_ =*/ gui().newWorkArea(width, height, view_id);
 
        view.init();
-       view.setGeometry(width, height, posx, posy, maximize, iconSizeXY);
+       view.setGeometry(width, height, posx, posy, maximize, iconSizeXY, geometryArg);
 
        setCurrentView(view);
 
index 76031a4a0c6e4cc531661029a69b202d047cdcff..3bd0c226ae1739209b4d407f9b24b2d1f4ee4809 100644 (file)
@@ -172,7 +172,8 @@ public:
 
        /// Create the main window with given geometry settings.
        LyXView & createView(unsigned int width, unsigned int height,
-               int posx, int posy, bool maximize, unsigned int iconSizeXY);
+               int posx, int posy, bool maximize, unsigned int iconSizeXY,
+               const std::string & geometryArg);
        
        /// 
        LyXView const & currentView() const;
index 5a2bfadeaae83b57fb60917238c877776f370d9d..49f40ede9638c7942a12cc9737596c6fd7b3df81 100644 (file)
@@ -88,7 +88,8 @@ public:
                unsigned int height,
                int posx, int posy,
                bool maximize,
-               unsigned int iconSizeXY) = 0;
+               unsigned int iconSizeXY,
+               const std::string & geometryArg) = 0;
 
        /// save the geometry state in the session manager.
        virtual void saveGeometry() = 0;
index b6e93c5a38bc0592402478333a9ac1a16208ac33..981cb515c3f5aa5046427851aa264bfc714718b3 100644 (file)
@@ -244,7 +244,8 @@ void GuiView::setGeometry(unsigned int width,
                                                                  unsigned int height,
                                                                  int posx, int posy,
                                                                  bool maximize,
-                                                                 unsigned int iconSizeXY)
+                                                                 unsigned int iconSizeXY,
+                                                                 const std::string & geometryArg)
 {
        // use last value (not at startup)
        if (d.lastIconSize != 0)
@@ -278,6 +279,21 @@ void GuiView::setGeometry(unsigned int width,
                if (maximize)
                        setWindowState(Qt::WindowMaximized);
        }
+       else
+       {
+               // FIXME: move this code into parse_geometry() (lyx_main.C)
+#ifdef Q_WS_WIN
+               int x, y;
+               int w, h;
+               QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)([+-][0-9]*)){0,1}" );
+               re.indexIn( toqstr(geometryArg.c_str()));
+               w = re.cap( 1 ).toInt();
+               h = re.cap( 2 ).toInt();
+               x = re.cap( 3 ).toInt();
+               y = re.cap( 4 ).toInt();
+               QWidget::setGeometry( x, y, w, h );
+#endif
+       }
 
        show();
 
index 40adbb420cb8c5743fad77af55d725cf870fea64..83c8f6ba1778d0760583428aa5acca8556904cff 100644 (file)
@@ -61,7 +61,8 @@ public:
                unsigned int height,
                int posx, int posy,
                bool maximize,
-               unsigned int iconSizeXY);
+               unsigned int iconSizeXY,
+               const std::string & geometryArg);
        virtual void saveGeometry();
        virtual void busy(bool);
        Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb);
index 7d97fac6a15cb5e096b3093eefdc6f365954d048..35abe992ecc72a629b927d70db4b70e2c79b7ec2 100644 (file)
@@ -116,6 +116,8 @@ namespace {
 string cl_system_support;
 string cl_user_support;
 
+std::string geometryArg;
+
 LyX * singleton_ = 0;
 
 void showFileError(string const & error)
@@ -193,10 +195,11 @@ LyX const & LyX::cref()
 
 
 LyX::LyX()
-       : first_start(false), geometryOption_(false)
+       : first_start(false)
 {
        singleton_ = this;
        pimpl_.reset(new Singletons);
+       geometryArg.clear();
 }
 
 
@@ -603,12 +606,14 @@ LyXView * LyX::newLyXView()
                        posy = convert<int>(val);
        }
 
-       if (geometryOption_) {
+       if (!geometryArg.empty()) 
+       {
                width = 0;
                height = 0;
        }
+
        // create the main window
-       LyXView * view = &pimpl_->application_->createView(width, height, posx, posy, maximize, iconSizeXY);
+       LyXView * view = &pimpl_->application_->createView(width, height, posx, posy, maximize, iconSizeXY, geometryArg);
 
        return view;
 }
@@ -1273,6 +1278,19 @@ int parse_import(string const & type, string const & file)
        return 2;
 }
 
+int parse_geometry(string const & arg1, string const &)
+{
+       geometryArg = arg1;
+#if defined(_WIN32) || (defined(__CYGWIN__) && defined(X_DISPLAY_MISSING))
+       // remove also the arg
+       return 1;
+#else
+       // don't remove "-geometry"
+       return -1;
+#endif
+}
+
+
 } // namespace anon
 
 
@@ -1293,15 +1311,12 @@ void LyX::easyParse(int & argc, char * argv[])
        cmdmap["--export"] = parse_export;
        cmdmap["-i"] = parse_import;
        cmdmap["--import"] = parse_import;
+       cmdmap["-geometry"] = parse_geometry;
 
        for (int i = 1; i < argc; ++i) {
                std::map<string, cmd_helper>::const_iterator it
                        = cmdmap.find(argv[i]);
 
-               // check for X11 -geometry option
-               if (support::compare(argv[i], "-geometry") == 0)
-                       geometryOption_ = true;
-
                // don't complain if not found - may be parsed later
                if (it == cmdmap.end())
                        continue;
index a0b74578ace3540040035786ac6c08f2e9d94b60..9f698d82a39c9b6c00c29e8b9b89ae4f101b641d 100644 (file)
@@ -163,9 +163,6 @@ private:
        /// Use the Pimpl idiom to hide the internals.
        struct Singletons;
        boost::scoped_ptr<Singletons> pimpl_;
-
-       ///
-       bool geometryOption_;
 };
 
 } // namespace lyx