From 6cdf6bd6ab12d320662ae76bc332d214e11ca6b2 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sat, 9 Feb 2008 17:20:23 +0000 Subject: [PATCH] Support full screen in BufferView git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22899 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 14 +++++++++++++- src/BufferView.h | 16 ++++++++++++---- src/ParagraphMetrics.cpp | 6 +++--- src/ParagraphMetrics.h | 3 ++- src/TextMetrics.cpp | 6 +++--- src/frontends/qt4/GuiView.cpp | 2 ++ src/frontends/qt4/GuiWorkArea.cpp | 2 +- 7 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 4c3ab44f65..d05a064d22 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -257,7 +257,7 @@ struct BufferView::Private BufferView::BufferView(Buffer & buf) - : width_(0), height_(0), buffer_(buf), d(new Private(*this)) + : width_(0), height_(0), full_screen_(false), buffer_(buf), d(new Private(*this)) { d->xsel_cache_.set = false; d->intl_.initKeyMapper(lyxrc.use_kbmap); @@ -287,6 +287,18 @@ BufferView::~BufferView() } +int BufferView::rightMargin() const +{ + return full_screen_? width_ / 4 : 10; +} + + +int BufferView::leftMargin() const +{ + return full_screen_? width_ / 4 : 10; +} + + Intl & BufferView::getIntl() { return d->intl_; diff --git a/src/BufferView.h b/src/BufferView.h index 2fe0064188..fe4eaa957f 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -79,7 +79,7 @@ struct ScrollbarParameters class BufferView { public: /// - BufferView(Buffer & buffer); + explicit BufferView(Buffer & buffer); /// ~BufferView(); @@ -87,6 +87,15 @@ public: Buffer & buffer(); Buffer const & buffer() const; + /// + void setFullScreen(bool full_screen) { full_screen_ = full_screen; } + + /// right margin + int rightMargin() const; + + /// left margin + int leftMargin() const; + /// perform pending metrics updates. /** \c Update::FitCursor means first to do a FitCursor, and to * force an update if screen position changes. @@ -282,6 +291,8 @@ private: /// int height_; /// + bool full_screen_; + /// Buffer & buffer_; struct Private; @@ -294,9 +305,6 @@ inline int nestMargin() { return 15; } /// margin for changebar inline int changebarMargin() { return 12; } -/// right margin -inline int rightMargin() { return 10; } - } // namespace lyx #endif // BUFFERVIEW_H diff --git a/src/ParagraphMetrics.cpp b/src/ParagraphMetrics.cpp index 873cded4db..a53605c794 100644 --- a/src/ParagraphMetrics.cpp +++ b/src/ParagraphMetrics.cpp @@ -195,13 +195,13 @@ void ParagraphMetrics::dump() const } } -int ParagraphMetrics::rightMargin(Buffer const & buffer) const +int ParagraphMetrics::rightMargin(BufferView const & bv) const { - BufferParams const & params = buffer.params(); + BufferParams const & params = bv.buffer().params(); TextClass const & tclass = params.getTextClass(); frontend::FontMetrics const & fm = theFontMetrics(params.getFont()); int const r_margin = - lyx::rightMargin() + bv.rightMargin() + fm.signedWidth(tclass.rightmargin()) + fm.signedWidth(par_->layout()->rightmargin) * 4 / (par_->getDepth() + 4); diff --git a/src/ParagraphMetrics.h b/src/ParagraphMetrics.h index 53f5f4379a..e914522efa 100644 --- a/src/ParagraphMetrics.h +++ b/src/ParagraphMetrics.h @@ -33,6 +33,7 @@ namespace lyx { typedef std::vector RowList; class Buffer; +class BufferView; class BufferParams; class Font; class Inset; @@ -76,7 +77,7 @@ public: /// The painter and others use this RowList const & rows() const { return rows_; } /// - int rightMargin(Buffer const & buffer) const; + int rightMargin(BufferView const & bv) const; /// int singleWidth(pos_type pos, Font const & Font) const; diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 93be5ae5df..69eef18615 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -220,13 +220,13 @@ bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width) int TextMetrics::rightMargin(ParagraphMetrics const & pm) const { - return main_text_? pm.rightMargin(bv_->buffer()) : 0; + return main_text_? pm.rightMargin(*bv_) : 0; } int TextMetrics::rightMargin(pit_type const pit) const { - return main_text_? par_metrics_[pit].rightMargin(bv_->buffer()) : 0; + return main_text_? par_metrics_[pit].rightMargin(*bv_) : 0; } @@ -1697,7 +1697,7 @@ int TextMetrics::leftMargin(int max_width, int l_margin = 0; if (text_->isMainText(buffer)) - l_margin += changebarMargin(); + l_margin += bv_->leftMargin(); l_margin += theFontMetrics(buffer.params().getFont()).signedWidth( tclass.leftmargin()); diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 746f775e99..e858b95ca9 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1827,12 +1827,14 @@ bool GuiView::dispatch(FuncRequest const & cmd) setContentsMargins(0, 0, 0, 0); #endif d.current_work_area_->setFrameStyle(QFrame::NoFrame); + d.current_work_area_->bufferView().setFullScreen(false); menuBar()->show(); statusBar()->show(); } else { statusBar()->hide(); menuBar()->hide(); d.current_work_area_->setFrameStyle(QFrame::NoFrame); + d.current_work_area_->bufferView().setFullScreen(true); #if QT_VERSION >= 0x040300 setContentsMargins(-2, -2, -2, -2); #endif diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index f9fe086991..4233c7ffae 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -908,7 +908,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e) rLength = 0; } - int const right_margin = rightMargin(); + int const right_margin = buffer_view_->rightMargin(); Painter::preedit_style ps; // Most often there would be only one line: preedit_lines_ = 1; -- 2.39.5