Abdelrazak Younes <[EMAIL PROTECTED]> writes:
| Hello,
|
| Minus potential compilation problems with gtk and/or xforms I think I
| am ready to merge my branch with trunk. Please find attached the
| complete patch. I will wait for some green lights before applying.
|
| Abdel.
| Index: src/BufferView_pimpl.C
| ===================================================================
| --- src/BufferView_pimpl.C (revision 14120)
| +++ src/BufferView_pimpl.C (working copy)
| @@ -58,14 +58,14 @@
| #include "insets/insettext.h"
|
| #include "frontends/Alert.h"
| +#include "frontends/Clipboard.h"
| #include "frontends/Dialogs.h"
| #include "frontends/FileDialog.h"
| #include "frontends/font_metrics.h"
| #include "frontends/LyXView.h"
| -#include "frontends/LyXScreenFactory.h"
| -#include "frontends/screen.h"
| +#include "frontends/Gui.h"
| #include "frontends/WorkArea.h"
| -#include "frontends/WorkAreaFactory.h"
| +#include "frontends/Painter.h"
Can you sort the includes please?
(it is already so close so why not go all the way)
|
| #include "graphics/Previews.h"
|
| @@ -82,6 +82,10 @@
| #include <functional>
| #include <vector>
|
| +using lyx::frontend::WorkArea;
| +using lyx::frontend::Clipboard;
| +using lyx::frontend::Gui;
| +
| using lyx::pos_type;
|
| using lyx::support::addPath;
| @@ -103,7 +107,6 @@
| using std::mem_fun_ref;
| using std::vector;
|
| -
| extern BufferList bufferlist;
|
|
| @@ -142,8 +145,8 @@
| {
| xsel_cache_.set = false;
|
| - workarea_.reset(WorkAreaFactory::create(*owner_, width, height));
| - screen_.reset(LyXScreenFactory::create(workarea()));
| + work_area_id_ = owner_->gui().newWorkArea(width, height);
| + work_area_ = & owner_->gui().workArea(work_area_id_);
|
| // Setup the signals
| timecon = cursor_timeout.timeout
| @@ -314,20 +317,26 @@
| }
|
|
| -WorkArea & BufferView::Pimpl::workarea() const
| +lyx::frontend::Gui & BufferView::Pimpl::gui() const
| {
| - return *workarea_.get();
| + return owner_->gui();
| }
|
|
| -LyXScreen & BufferView::Pimpl::screen() const
| +lyx::frontend::WorkArea & BufferView::Pimpl::workarea() const
| {
| - return *screen_.get();
| + return *work_area_;
| }
|
|
| -Painter & BufferView::Pimpl::painter() const
| +lyx::frontend::Clipboard & BufferView::Pimpl::clipboard() const
| {
| + return owner_->gui().clipboard();
| +}
| +
| +
| +lyx::frontend::Painter & BufferView::Pimpl::painter() const
| +{
| return workarea().getPainter();
| }
|
| @@ -473,7 +482,7 @@
|
| // estimated average paragraph height:
| if (wh_ == 0)
| - wh_ = workarea().workHeight() / 4;
| + wh_ = workarea().height() / 4;
| int h = t.getPar(anchor_ref_).height();
|
| // Normalize anchor/offset (MV):
| @@ -486,7 +495,7 @@
| int sumh = 0;
| int nh = 0;
| for (lyx::pit_type pit = anchor_ref_; pit <= parsize; ++pit) {
| - if (sumh > workarea().workHeight())
| + if (sumh > workarea().height())
| break;
| int const h2 = t.getPar(pit).height();
| sumh += h2;
| @@ -511,7 +520,7 @@
| if (!buffer_)
| return;
|
| - screen().hideCursor();
| + owner_->gui().guiCursor().hide();
|
| LyXText & t = *bv_->text();
|
| @@ -530,7 +539,7 @@
|
| int const height = 2 * defaultRowHeight();
| int const first = height;
| - int const last = workarea().workHeight() - height;
| + int const last = workarea().height() - height;
| LCursor & cur = cursor_;
|
| bv_funcs::CurStatus st = bv_funcs::status(bv_, cur);
| @@ -591,7 +600,7 @@
| * dispatch() itself, because that's called recursively.
| */
| if (available())
| - screen().showCursor(*bv_);
| + owner_->gui().guiCursor().show(*bv_);
| }
|
|
| @@ -618,7 +627,7 @@
| xsel_cache_.set = cur.selection();
| sel = cur.selectionAsString(false);
| if (!sel.empty())
| - workarea().putClipboard(sel);
| + clipboard().put(sel);
| }
| }
|
| @@ -626,7 +635,7 @@
| void BufferView::Pimpl::selectionLost()
| {
| if (available()) {
| - screen().hideCursor();
| + owner_->gui().guiCursor().hide();
| cursor_.clearSelection();
| xsel_cache_.set = false;
| }
| @@ -638,12 +647,12 @@
| static int work_area_width;
| static int work_area_height;
|
| - bool const widthChange = workarea().workWidth() != work_area_width;
| - bool const heightChange = workarea().workHeight() != work_area_height;
| + bool const widthChange = workarea().width() != work_area_width;
| + bool const heightChange = workarea().height() != work_area_height;
|
| // Update from work area
| - work_area_width = workarea().workWidth();
| - work_area_height = workarea().workHeight();
| + work_area_width = workarea().width();
| + work_area_height = workarea().height();
Have temporary for workarea somehwere?
| @@ -666,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 < workarea().workHeight())
| + if (p.y_ - asc >= 0 && p.y_ + des < workarea().height())
| return false;
| }
| center();
| @@ -721,14 +730,14 @@
| }
| if (forceupdate) {
| // Second drawing step
| - screen().redraw(*bv_, vi);
| + workarea().redraw(*bv_, vi);
| } else {
| // Abort updating of the coord
| // cache - just restore the old one
| std::swap(theCoords, backup);
| }
| } else
| - screen().greyOut();
| + workarea().greyOut();
|
| // And the scrollbar
| updateScrollbar();
| @@ -740,7 +749,7 @@
| void BufferView::Pimpl::cursorToggle()
| {
| if (buffer_) {
| - screen().toggleCursor(*bv_);
| + owner_->gui().guiCursor().toggle(*bv_);
|
| // Use this opportunity to deal with any child processes that
| // have finished but are waiting to communicate this fact
| @@ -867,13 +876,13 @@
| Paragraph const & par = bot.text()->paragraphs()[pit];
| anchor_ref_ = pit;
| offset_ref_ = bv_funcs::coordOffset(cursor_, cursor_.boundary()).y_
| - + par.ascent() - workarea().workHeight() / 2;
| + + par.ascent() - workarea().height() / 2;
| }
|
|
| void BufferView::Pimpl::stuffClipboard(string const & content) const
| {
| - workarea().putClipboard(content);
| + clipboard().put(content);
| }
|
|
| @@ -998,13 +1007,13 @@
| if (!available())
| return false;
|
| - screen().hideCursor();
| + owner_->gui().guiCursor().hide();
|
| // Either the inset under the cursor or the
| // surrounding LyXText will handle this event.
|
| // Build temporary cursor.
| - cmd.y = min(max(cmd.y,-1), workarea().workHeight());
| + cmd.y = min(max(cmd.y,-1), workarea().height());
spacing
| InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
| //lyxerr << BOOST_CURRENT_FUNCTION
| // << " * hit inset at tip: " << inset << endl;
| @@ -1036,7 +1045,7 @@
|
| // See workAreaKeyPress
| cursor_timeout.restart();
| - screen().showCursor(*bv_);
| + owner_->gui().guiCursor().show(*bv_);
|
| // Skip these when selecting
| if (cmd.action != LFUN_MOUSE_MOTION) {
| Index: src/BufferView_pimpl.h
| ===================================================================
| --- src/BufferView_pimpl.h (revision 14120)
| +++ src/BufferView_pimpl.h (working copy)
| @@ -35,25 +35,33 @@
| #include <boost/signals/trackable.hpp>
|
|
| +
Do we need three empty lines?
| class Change;
| class LyXKeySym;
| class LyXView;
| -class WorkArea;
| -class LyXScreen;
| +
| class FuncRequest;
| class FuncStatus;
| class ViewMetricsInfo;
|
| +namespace lyx {
| +namespace frontend {
| +class Gui;
| +class WorkArea;
| +class Clipboard;
| +class Painter;
| +class GuiCursor;
| +}
| +}
|
| +
| ///
| class BufferView::Pimpl : public boost::signals::trackable {
| public:
| ///
| Pimpl(BufferView & bv, LyXView * owner, int width, int height);
| ///
| - Painter & painter() const;
| - /// return the screen for this bview
| - LyXScreen & screen() const;
| + lyx::frontend::Painter & painter() const;
| ///
| void setBuffer(Buffer * buf);
| ///
| @@ -110,6 +118,14 @@
| bool repaintAll() { return refresh_inside_; }
| ///
| void repaintAll(bool r) {refresh_inside_ = r; }
| +
| + /// the frontend
| + lyx::frontend::Gui & gui() const;
| + /// our workarea
| + lyx::frontend::WorkArea & workarea() const;
| + /// the clipboard
| + lyx::frontend::Clipboard & clipboard() const;
| +
| private:
| /// An error list (replaces the error insets)
| ErrorList errorlist_;
| @@ -148,10 +164,7 @@
| LyXView * owner_;
| ///
| Buffer * buffer_;
| - ///
| - boost::scoped_ptr<LyXScreen> screen_;
| - ///
| - boost::scoped_ptr<WorkArea> workarea_;
| +
| /// Estimated average par height for scrollbar
| int wh_;
| ///
| @@ -179,8 +192,10 @@
| std::vector<Position> saved_positions;
| ///
| void menuInsertLyXFile(std::string const & filen);
| - /// our workarea
| - WorkArea & workarea() const;
| +
| + lyx::frontend::WorkArea * work_area_;
Do we want bald pointers? Even just as cache?
| Index: src/frontends/gtk/GView.h
| ===================================================================
| --- src/frontends/gtk/GView.h (revision 14120)
| +++ src/frontends/gtk/GView.h (working copy)
| @@ -12,9 +12,12 @@
| #ifndef GVIEW_H
| #define GVIEW_H
|
| -#include "frontends/LyXView.h"
| #include "bufferview_funcs.h"
|
| +#include "frontends/LyXView.h"
| +
| +#include "TheGui.h"
This "TheGui" thing sounds/looks strange. what is it? Can it get a
more descriptive name?
| + ///
| + TheGui frontend_;
| };
|
| } // namespace frontend
| Index: src/frontends/gtk/GWorkArea.C
| ===================================================================
| --- src/frontends/gtk/GWorkArea.C (revision 14120)
| +++ src/frontends/gtk/GWorkArea.C (working copy)
| @@ -504,7 +504,7 @@
| }
|
|
| -void GWorkArea::haveSelection(bool toHave) const
| +void GWorkArea::haveSelection(bool toHave)
| {
| if (toHave) {
| Glib::RefPtr<Gtk::Clipboard> clipboard =
| @@ -533,7 +533,7 @@
|
| // ENCODING: we assume that the backend passes us ISO-8859-1 and
| // convert from that to UTF-8 before passing to GTK
| -void GWorkArea::putClipboard(string const & str) const
| +void GWorkArea::putClipboard(string const & str)
| {
Why the const removals?
| Index: src/frontends/qt4/QRef.C
| ===================================================================
| --- src/frontends/qt4/QRef.C (revision 14120)
| +++ src/frontends/qt4/QRef.C (working copy)
| @@ -4,7 +4,7 @@
| * Licence details can be found in the file COPYING.
| *
| * \author John Levon
| - * \author Jürgen Spitzmüller
| + * \author Jurgen Spitzmuller
| *
| * Full author contact details are available in file CREDITS.
| */
| Index: src/frontends/qt4/QtView.C
| ===================================================================
| --- src/frontends/qt4/QtView.C (revision 14120)
| +++ src/frontends/qt4/QtView.C (working copy)
| @@ -3,7 +3,7 @@
| * This file is part of LyX, the document processor.
| * Licence details can be found in the file COPYING.
| *
| - * \author Lars Gullik Bjønnes
| + * \author Lars Gullik Bjønnes
| * \author John Levon
| * \author Abdelrazak Younes
| *
Hmm... your compiler mangles charsets.
| Index: src/support/lstrings.C
| ===================================================================
| --- src/support/lstrings.C (revision 14120)
| +++ src/support/lstrings.C (working copy)
| @@ -546,6 +546,40 @@
| }
|
|
| +string const externalLineEnding(string const & str)
| +{
| +#ifdef Q_WS_MACX
| + // The MAC clipboard uses \r for lineendings, and we use \n
| + return subst(str, '\n', '\r');
| +#endif
| +
| + return str;
| +/*
| +#ifdef Q_WS_WIN
| + // Windows clipboard uses \r\n for lineendings, and we use \n
| + return subst(str, '\n', '\r\n');
| +#endif
| +*/
| +}
| +
| +
| +string const internalLineEnding(string const & str)
| +{
| +#ifdef Q_WS_MACX
| + // The MAC clipboard uses \r for lineendings, and we use \n
| + return subst(str, '\r', '\n');
| +#endif
| +
| + return str;
| +/*
| +#ifdef Q_WS_WIN
| + // Windows clipboard uses \r\n for lineendings, and we use \n
| + return subst(str, '\r\n', '\n');
| +#endif
| +*/
| +}
| +
| +
| #ifndef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
| #if USE_BOOST_FORMAT
Are thise releated to the gui changes? Why?
(and I donÃ't like the IFDEF implementation. Should be broken out into
an win file and a mac file.
--
Lgb