Lars Gullik Bjønnes wrote:
Abdelrazak Younes <[EMAIL PROTECTED]> writes:

| > | -//    workarea().setScrollbarParams(t->height(), top_y(), 
defaultRowHeight());
| > | +//    work_area_->.setScrollbarParams(t->height(), top_y(), 
defaultRowHeight());
| > |  }
| > The commented code got mangeld.
| | I plan to remove this workarea() access method so it's better to not
| leave any trace.

sure... but is 'work_area_->.' a valid construct.

?? This is a "WorkArea *" pointer so yes it is valid. In the GUI cleanup branck the Bufferview is not responsible anymore for WorkArea creation/deletion. It just ask for one new WorkArea to the Gui:

        workAreaId_ = owner_->gui().newWorkArea(width, height);
        workArea_ = & owner_->gui().workArea(workAreaId_);


The attached patched change the naming. Do you see how much I want to please you today? ;-)

Abdel.

Log:

BufferView_pimpl:
* work_area_ -> workArea_
* work_area_id_ -> workAreaId_

TheGui renamed to GuiImplementation.






Index: src/BufferView_pimpl.C
===================================================================
--- src/BufferView_pimpl.C      (revision 14148)
+++ src/BufferView_pimpl.C      (working copy)
@@ -145,13 +145,13 @@
 {
        xsel_cache_.set = false;
 
-       work_area_id_ = owner_->gui().newWorkArea(width, height);
-       work_area_ = & owner_->gui().workArea(work_area_id_);
+       workAreaId_ = owner_->gui().newWorkArea(width, height);
+       workArea_ = & owner_->gui().workArea(workAreaId_);
 
        // Setup the signals
        timecon = cursor_timeout.timeout
                .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
-        
+       
        cursor_timeout.start();
         
        saved_positions.resize(saved_positions_num);
@@ -325,7 +325,7 @@
 
 lyx::frontend::WorkArea & BufferView::Pimpl::workarea() const
 {
-       return *work_area_;
+       return *workArea_;
 }
 
 
@@ -337,7 +337,7 @@
 
 lyx::frontend::Painter & BufferView::Pimpl::painter() const
 {
-       return work_area_->getPainter();
+       return workArea_->getPainter();
 }
 
 
@@ -460,7 +460,7 @@
        if (!bv_->text()) {
                lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
                                     << " no text in updateScrollbar" << endl;
-               work_area_->setScrollbarParams(0, 0, 0);
+               workArea_->setScrollbarParams(0, 0, 0);
                return;
        }
 
@@ -482,7 +482,7 @@
 
        // estimated average paragraph height:
        if (wh_ == 0)
-               wh_ = work_area_->height() / 4;
+               wh_ = workArea_->height() / 4;
        int h = t.getPar(anchor_ref_).height();
 
        // Normalize anchor/offset (MV):
@@ -495,7 +495,7 @@
        int sumh = 0;
        int nh = 0;
        for (lyx::pit_type pit = anchor_ref_; pit <= parsize; ++pit) {
-               if (sumh > work_area_->height())
+               if (sumh > workArea_->height())
                        break;
                int const h2 = t.getPar(pit).height();
                sumh += h2;
@@ -506,7 +506,7 @@
        if (hav > wh_)
                wh_ = hav;
 
-       work_area_->setScrollbarParams((parsize + 1) * wh_,
+       workArea_->setScrollbarParams((parsize + 1) * wh_,
                anchor_ref_ * wh_ + int(offset_ref_ * wh_ / float(h)),
                int(wh_ * defaultRowHeight() / float(h)));
 }
@@ -539,7 +539,7 @@
 
        int const height = 2 * defaultRowHeight();
        int const first = height;
-       int const last = work_area_->height() - height;
+       int const last = workArea_->height() - height;
        LCursor & cur = cursor_;
 
        bv_funcs::CurStatus st = bv_funcs::status(bv_, cur);
@@ -583,7 +583,7 @@
 //     scrollDocView(new_top_y);
 //
 //     // Update the scrollbar.
-//     work_area_->.setScrollbarParams(t->height(), top_y(), 
defaultRowHeight());
+//     workArea_->.setScrollbarParams(t->height(), top_y(), 
defaultRowHeight());
 }
 
 
@@ -644,15 +644,15 @@
 
 void BufferView::Pimpl::workAreaResize()
 {
-       static int work_area_width;
-       static int work_area_height;
+       static int workArea_width;
+       static int workArea_height;
 
-       bool const widthChange = work_area_->width() != work_area_width;
-       bool const heightChange = work_area_->height() != work_area_height;
+       bool const widthChange = workArea_->width() != workArea_width;
+       bool const heightChange = workArea_->height() != workArea_height;
 
        // Update from work area
-       work_area_width = work_area_->width();
-       work_area_height = work_area_->height();
+       workArea_width = workArea_->width();
+       workArea_height = workArea_->height();
 
        if (buffer_ && widthChange) {
                // The visible LyXView need a resize
@@ -675,7 +675,7 @@
                int const asc = font_metrics::maxAscent(font);
                int const des = font_metrics::maxDescent(font);
                Point const p = bv_funcs::getPos(cursor_, cursor_.boundary());
-               if (p.y_ - asc >= 0 && p.y_ + des < work_area_->height())
+               if (p.y_ - asc >= 0 && p.y_ + des < workArea_->height())
                        return false;
        }
        center();
@@ -730,14 +730,14 @@
                }
                if (forceupdate) {
                        // Second drawing step
-                       work_area_->redraw(*bv_, vi);
+                       workArea_->redraw(*bv_, vi);
                } else {
                        // Abort updating of the coord
                        // cache - just restore the old one
                        std::swap(theCoords, backup);
                }
        } else
-               work_area_->greyOut();
+               workArea_->greyOut();
 
        // And the scrollbar
        updateScrollbar();
@@ -876,7 +876,7 @@
        Paragraph const & par = bot.text()->paragraphs()[pit];
        anchor_ref_ = pit;
        offset_ref_ = bv_funcs::coordOffset(cursor_, cursor_.boundary()).y_
-               + par.ascent() - work_area_->height() / 2;
+               + par.ascent() - workArea_->height() / 2;
 }
 
 
@@ -1013,7 +1013,7 @@
        // surrounding LyXText will handle this event.
 
        // Build temporary cursor.
-       cmd.y = min(max(cmd.y, -1), work_area_->height());
+       cmd.y = min(max(cmd.y, -1), workArea_->height());
        InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
        //lyxerr << BOOST_CURRENT_FUNCTION
        //       << " * hit inset at tip: " << inset << endl;
Index: src/BufferView_pimpl.h
===================================================================
--- src/BufferView_pimpl.h      (revision 14148)
+++ src/BufferView_pimpl.h      (working copy)
@@ -191,8 +191,8 @@
        ///
        void menuInsertLyXFile(std::string const & filen);
 
-       lyx::frontend::WorkArea * work_area_;
-       int work_area_id_;
+       lyx::frontend::WorkArea * workArea_;
+       int workAreaId_;
 
        /// this is used to handle XSelection events in the right manner
        struct {
Index: src/frontends/qt4/GuiImplementation.C
===================================================================
--- src/frontends/qt4/GuiImplementation.C       (revision 14145)
+++ src/frontends/qt4/GuiImplementation.C       (working copy)
@@ -1,16 +1,16 @@
 // -*- C++ -*-
 /**
- * \file TheGui.C
+ * \file GuiImplementation.C
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author unknown
  * \author John Levon
+ * \author Abdelrazak Younes
  *
  * Full author contact details are available in file CREDITS.
  */
 
-#include "TheGui.h"
+#include "GuiImplementation.h"
 #include "GuiWorkArea.h"
 #include "QtView.h"
 
@@ -19,18 +19,18 @@
 namespace lyx {
 namespace frontend {
 
-TheGui::TheGui(QtView & owner): owner_(owner), max_id_(0)
+GuiImplementation::GuiImplementation(QtView & owner): owner_(owner), max_id_(0)
 {
 }
 
 
-Clipboard& TheGui::clipboard()
+Clipboard& GuiImplementation::clipboard()
 {
        return clipboard_;
 }
 
 
-int TheGui::newWorkArea(int w, int h)
+int GuiImplementation::newWorkArea(int w, int h)
 {
        size_t const id = max_id_;
        ++max_id_;
@@ -38,7 +38,7 @@
        return id;
 }
 
-WorkArea& TheGui::workArea(int id)
+WorkArea& GuiImplementation::workArea(int id)
 {
        BOOST_ASSERT(work_areas_.find(id) != work_areas_.end());
 
@@ -48,7 +48,7 @@
 }
 
 
-void TheGui::destroyWorkArea(int id)
+void GuiImplementation::destroyWorkArea(int id)
 {
        work_areas_.erase(id);
 }
Index: src/frontends/qt4/GuiImplementation.h
===================================================================
--- src/frontends/qt4/GuiImplementation.h       (revision 14145)
+++ src/frontends/qt4/GuiImplementation.h       (working copy)
@@ -1,17 +1,17 @@
 // -*- C++ -*-
 /**
- * \file TheGui.h
+ * \file GuiImplementation.h
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author unknown
  * \author John Levon
+ * \author Abdelrazak Younes
  *
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef GUI_H
-#define GUI_H
+#ifndef GUI_IMPLEMENTATION_H
+#define GUI_IMPLEMENTATION_H
 
 #include "frontends/Gui.h"
 #include "GuiClipboard.h"
@@ -27,13 +27,13 @@
 class QtView;
 
 /**
- * The TheGui class is the interface to all Qt4 components.
+ * The GuiImplementation class is the interface to all Qt4 components.
  */
-class TheGui: public Gui
+class GuiImplementation: public Gui
 {
 public:
-       TheGui(QtView & owner);
-       virtual ~TheGui() {}
+       GuiImplementation(QtView & owner);
+       virtual ~GuiImplementation() {}
 
        Clipboard& clipboard();
 
@@ -55,4 +55,4 @@
 } // namespace frontend
 } // namespace lyx
 
-#endif // GUI_H
+#endif // GUI_IMPLEMENTATION_H
Index: src/frontends/qt4/QtView.h
===================================================================
--- src/frontends/qt4/QtView.h  (revision 14145)
+++ src/frontends/qt4/QtView.h  (working copy)
@@ -17,7 +17,7 @@
 // Must be here because of moc.
 #include <config.h>
 
-#include "TheGui.h"
+#include "GuiImplementation.h"
 
 #include "frontends/LyXView.h"
 #include "funcrequest.h"
@@ -111,7 +111,7 @@
        ///
        static QMainWindow* mainWidget_;
 
-       TheGui frontend_;
+       GuiImplementation frontend_;
 };
 
 } // namespace frontend
Index: src/frontends/qt4/TheGui.C
===================================================================
--- src/frontends/qt4/TheGui.C  (revision 14145)
+++ src/frontends/qt4/TheGui.C  (working copy)
@@ -1,57 +0,0 @@
-// -*- C++ -*-
-/**
- * \file TheGui.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author unknown
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include "TheGui.h"
-#include "GuiWorkArea.h"
-#include "QtView.h"
-
-using boost::shared_ptr;
-
-namespace lyx {
-namespace frontend {
-
-TheGui::TheGui(QtView & owner): owner_(owner), max_id_(0)
-{
-}
-
-
-Clipboard& TheGui::clipboard()
-{
-       return clipboard_;
-}
-
-
-int TheGui::newWorkArea(int w, int h)
-{
-       size_t const id = max_id_;
-       ++max_id_;
-       work_areas_[id].reset(new GuiWorkArea(owner_, w, h));
-       return id;
-}
-
-WorkArea& TheGui::workArea(int id)
-{
-       BOOST_ASSERT(work_areas_.find(id) != work_areas_.end());
-
-       guiCursor().connect(work_areas_[id].get());
-
-       return *work_areas_[id].get();
-}
-
-
-void TheGui::destroyWorkArea(int id)
-{
-       work_areas_.erase(id);
-}
-
-} // namespace frontend
-} // namespace lyx
Index: src/frontends/qt4/TheGui.h
===================================================================
--- src/frontends/qt4/TheGui.h  (revision 14145)
+++ src/frontends/qt4/TheGui.h  (working copy)
@@ -1,58 +0,0 @@
-// -*- C++ -*-
-/**
- * \file TheGui.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author unknown
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef GUI_H
-#define GUI_H
-
-#include "frontends/Gui.h"
-#include "GuiClipboard.h"
-
-#include <boost/shared_ptr.hpp>
-
-#include <map>
-
-namespace lyx {
-namespace frontend {
-
-class GuiWorkArea;
-class QtView;
-
-/**
- * The TheGui class is the interface to all Qt4 components.
- */
-class TheGui: public Gui
-{
-public:
-       TheGui(QtView & owner);
-       virtual ~TheGui() {}
-
-       Clipboard& clipboard();
-
-       int newWorkArea(int w, int h);
-       WorkArea& workArea(int id);
-       void destroyWorkArea(int id);
-
-private:
-       ///
-       GuiClipboard clipboard_;
-       ///
-       std::map<int, boost::shared_ptr<GuiWorkArea> > work_areas_;
-       ///
-       QtView & owner_;
-       ///
-       size_t max_id_;
-};
-
-} // namespace frontend
-} // namespace lyx
-
-#endif // GUI_H

Reply via email to