mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-14 04:21:56 +00:00
This is the merging of the GUI API cleanup branch that was developed in svn+ssh://svn.lyx.org/lyx/lyx-devel/branches/personal/younes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14152 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9ae369d22f
commit
d8ae51dbe1
@ -1983,7 +1983,7 @@ if build_qt4:
|
|||||||
QtView.C
|
QtView.C
|
||||||
QURLDialog.C
|
QURLDialog.C
|
||||||
QVSpaceDialog.C
|
QVSpaceDialog.C
|
||||||
QWorkArea.C
|
GuiWorkArea.C
|
||||||
QWrapDialog.C
|
QWrapDialog.C
|
||||||
QLToolbar.C
|
QLToolbar.C
|
||||||
socket_callback.C
|
socket_callback.C
|
||||||
|
@ -39,9 +39,10 @@
|
|||||||
#include "WordLangTuple.h"
|
#include "WordLangTuple.h"
|
||||||
|
|
||||||
#include "frontends/Alert.h"
|
#include "frontends/Alert.h"
|
||||||
|
#include "frontends/Clipboard.h"
|
||||||
#include "frontends/Dialogs.h"
|
#include "frontends/Dialogs.h"
|
||||||
#include "frontends/LyXView.h"
|
#include "frontends/LyXView.h"
|
||||||
#include "frontends/screen.h"
|
#include "frontends/Gui.h"
|
||||||
#include "frontends/WorkArea.h"
|
#include "frontends/WorkArea.h"
|
||||||
|
|
||||||
#include "insets/insetcommand.h" // ChangeRefs
|
#include "insets/insetcommand.h" // ChangeRefs
|
||||||
@ -83,19 +84,13 @@ Buffer * BufferView::buffer() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXScreen & BufferView::screen() const
|
|
||||||
{
|
|
||||||
return pimpl_->screen();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LyXView * BufferView::owner() const
|
LyXView * BufferView::owner() const
|
||||||
{
|
{
|
||||||
return pimpl_->owner_;
|
return pimpl_->owner_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Painter & BufferView::painter() const
|
lyx::frontend::Painter & BufferView::painter() const
|
||||||
{
|
{
|
||||||
return pimpl_->painter();
|
return pimpl_->painter();
|
||||||
}
|
}
|
||||||
@ -200,7 +195,7 @@ void BufferView::switchKeyMap()
|
|||||||
|
|
||||||
int BufferView::workWidth() const
|
int BufferView::workWidth() const
|
||||||
{
|
{
|
||||||
return pimpl_->workarea().workWidth();
|
return pimpl_->workarea().width();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -212,7 +207,7 @@ void BufferView::center()
|
|||||||
|
|
||||||
string const BufferView::getClipboard() const
|
string const BufferView::getClipboard() const
|
||||||
{
|
{
|
||||||
return pimpl_->workarea().getClipboard();
|
return pimpl_->clipboard().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -317,7 +312,7 @@ void BufferView::gotoLabel(string const & label)
|
|||||||
|
|
||||||
void BufferView::hideCursor()
|
void BufferView::hideCursor()
|
||||||
{
|
{
|
||||||
screen().hideCursor();
|
pimpl_->gui().guiCursor().hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
LyXText * BufferView::getLyXText()
|
LyXText * BufferView::getLyXText()
|
||||||
@ -338,13 +333,13 @@ LyXText const * BufferView::getLyXText() const
|
|||||||
|
|
||||||
void BufferView::haveSelection(bool sel)
|
void BufferView::haveSelection(bool sel)
|
||||||
{
|
{
|
||||||
pimpl_->workarea().haveSelection(sel);
|
pimpl_->clipboard().haveSelection(sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BufferView::workHeight() const
|
int BufferView::workHeight() const
|
||||||
{
|
{
|
||||||
return pimpl_->workarea().workHeight();
|
return pimpl_->workarea().height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,11 +32,14 @@ class FuncStatus;
|
|||||||
class Language;
|
class Language;
|
||||||
class LCursor;
|
class LCursor;
|
||||||
class LyXText;
|
class LyXText;
|
||||||
class LyXScreen;
|
|
||||||
class LyXView;
|
class LyXView;
|
||||||
class Painter;
|
|
||||||
class ParIterator;
|
class ParIterator;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
class Painter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace Update {
|
namespace Update {
|
||||||
enum flags {
|
enum flags {
|
||||||
@ -83,9 +86,8 @@ public:
|
|||||||
Buffer * buffer() const;
|
Buffer * buffer() const;
|
||||||
|
|
||||||
/// return the painter object for drawing onto the view
|
/// return the painter object for drawing onto the view
|
||||||
Painter & painter() const;
|
lyx::frontend::Painter & painter() const;
|
||||||
/// return the screen object for handling re-drawing
|
|
||||||
LyXScreen & screen() const;
|
|
||||||
/// return the owning main view
|
/// return the owning main view
|
||||||
LyXView * owner() const;
|
LyXView * owner() const;
|
||||||
|
|
||||||
|
@ -58,14 +58,14 @@
|
|||||||
#include "insets/insettext.h"
|
#include "insets/insettext.h"
|
||||||
|
|
||||||
#include "frontends/Alert.h"
|
#include "frontends/Alert.h"
|
||||||
|
#include "frontends/Clipboard.h"
|
||||||
#include "frontends/Dialogs.h"
|
#include "frontends/Dialogs.h"
|
||||||
#include "frontends/FileDialog.h"
|
#include "frontends/FileDialog.h"
|
||||||
#include "frontends/font_metrics.h"
|
#include "frontends/font_metrics.h"
|
||||||
|
#include "frontends/Gui.h"
|
||||||
#include "frontends/LyXView.h"
|
#include "frontends/LyXView.h"
|
||||||
#include "frontends/LyXScreenFactory.h"
|
#include "frontends/Painter.h"
|
||||||
#include "frontends/screen.h"
|
|
||||||
#include "frontends/WorkArea.h"
|
#include "frontends/WorkArea.h"
|
||||||
#include "frontends/WorkAreaFactory.h"
|
|
||||||
|
|
||||||
#include "graphics/Previews.h"
|
#include "graphics/Previews.h"
|
||||||
|
|
||||||
@ -82,6 +82,10 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
using lyx::frontend::WorkArea;
|
||||||
|
using lyx::frontend::Clipboard;
|
||||||
|
using lyx::frontend::Gui;
|
||||||
|
|
||||||
using lyx::pos_type;
|
using lyx::pos_type;
|
||||||
|
|
||||||
using lyx::support::addPath;
|
using lyx::support::addPath;
|
||||||
@ -103,7 +107,6 @@ using std::string;
|
|||||||
using std::mem_fun_ref;
|
using std::mem_fun_ref;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
extern BufferList bufferlist;
|
extern BufferList bufferlist;
|
||||||
|
|
||||||
|
|
||||||
@ -142,13 +145,13 @@ BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner,
|
|||||||
{
|
{
|
||||||
xsel_cache_.set = false;
|
xsel_cache_.set = false;
|
||||||
|
|
||||||
workarea_.reset(WorkAreaFactory::create(*owner_, width, height));
|
workAreaId_ = owner_->gui().newWorkArea(width, height);
|
||||||
screen_.reset(LyXScreenFactory::create(workarea()));
|
workArea_ = & owner_->gui().workArea(workAreaId_);
|
||||||
|
|
||||||
// Setup the signals
|
// Setup the signals
|
||||||
timecon = cursor_timeout.timeout
|
timecon = cursor_timeout.timeout
|
||||||
.connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
|
.connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
|
||||||
|
|
||||||
cursor_timeout.start();
|
cursor_timeout.start();
|
||||||
|
|
||||||
saved_positions.resize(saved_positions_num);
|
saved_positions.resize(saved_positions_num);
|
||||||
@ -314,21 +317,27 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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 *workArea_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Painter & BufferView::Pimpl::painter() const
|
lyx::frontend::Clipboard & BufferView::Pimpl::clipboard() const
|
||||||
{
|
{
|
||||||
return workarea().getPainter();
|
return owner_->gui().clipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
lyx::frontend::Painter & BufferView::Pimpl::painter() const
|
||||||
|
{
|
||||||
|
return workArea_->getPainter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -451,7 +460,7 @@ void BufferView::Pimpl::updateScrollbar()
|
|||||||
if (!bv_->text()) {
|
if (!bv_->text()) {
|
||||||
lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
|
lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
|
||||||
<< " no text in updateScrollbar" << endl;
|
<< " no text in updateScrollbar" << endl;
|
||||||
workarea().setScrollbarParams(0, 0, 0);
|
workArea_->setScrollbarParams(0, 0, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,7 +482,7 @@ void BufferView::Pimpl::updateScrollbar()
|
|||||||
|
|
||||||
// estimated average paragraph height:
|
// estimated average paragraph height:
|
||||||
if (wh_ == 0)
|
if (wh_ == 0)
|
||||||
wh_ = workarea().workHeight() / 4;
|
wh_ = workArea_->height() / 4;
|
||||||
int h = t.getPar(anchor_ref_).height();
|
int h = t.getPar(anchor_ref_).height();
|
||||||
|
|
||||||
// Normalize anchor/offset (MV):
|
// Normalize anchor/offset (MV):
|
||||||
@ -486,7 +495,7 @@ void BufferView::Pimpl::updateScrollbar()
|
|||||||
int sumh = 0;
|
int sumh = 0;
|
||||||
int nh = 0;
|
int nh = 0;
|
||||||
for (lyx::pit_type pit = anchor_ref_; pit <= parsize; ++pit) {
|
for (lyx::pit_type pit = anchor_ref_; pit <= parsize; ++pit) {
|
||||||
if (sumh > workarea().workHeight())
|
if (sumh > workArea_->height())
|
||||||
break;
|
break;
|
||||||
int const h2 = t.getPar(pit).height();
|
int const h2 = t.getPar(pit).height();
|
||||||
sumh += h2;
|
sumh += h2;
|
||||||
@ -497,7 +506,7 @@ void BufferView::Pimpl::updateScrollbar()
|
|||||||
if (hav > wh_)
|
if (hav > wh_)
|
||||||
wh_ = hav;
|
wh_ = hav;
|
||||||
|
|
||||||
workarea().setScrollbarParams((parsize + 1) * wh_,
|
workArea_->setScrollbarParams((parsize + 1) * wh_,
|
||||||
anchor_ref_ * wh_ + int(offset_ref_ * wh_ / float(h)),
|
anchor_ref_ * wh_ + int(offset_ref_ * wh_ / float(h)),
|
||||||
int(wh_ * defaultRowHeight() / float(h)));
|
int(wh_ * defaultRowHeight() / float(h)));
|
||||||
}
|
}
|
||||||
@ -511,7 +520,7 @@ void BufferView::Pimpl::scrollDocView(int value)
|
|||||||
if (!buffer_)
|
if (!buffer_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
screen().hideCursor();
|
owner_->gui().guiCursor().hide();
|
||||||
|
|
||||||
LyXText & t = *bv_->text();
|
LyXText & t = *bv_->text();
|
||||||
|
|
||||||
@ -530,7 +539,7 @@ void BufferView::Pimpl::scrollDocView(int value)
|
|||||||
|
|
||||||
int const height = 2 * defaultRowHeight();
|
int const height = 2 * defaultRowHeight();
|
||||||
int const first = height;
|
int const first = height;
|
||||||
int const last = workarea().workHeight() - height;
|
int const last = workArea_->height() - height;
|
||||||
LCursor & cur = cursor_;
|
LCursor & cur = cursor_;
|
||||||
|
|
||||||
bv_funcs::CurStatus st = bv_funcs::status(bv_, cur);
|
bv_funcs::CurStatus st = bv_funcs::status(bv_, cur);
|
||||||
@ -574,7 +583,7 @@ void BufferView::Pimpl::scroll(int /*lines*/)
|
|||||||
// scrollDocView(new_top_y);
|
// scrollDocView(new_top_y);
|
||||||
//
|
//
|
||||||
// // Update the scrollbar.
|
// // Update the scrollbar.
|
||||||
// workarea().setScrollbarParams(t->height(), top_y(), defaultRowHeight());
|
// workArea_->.setScrollbarParams(t->height(), top_y(), defaultRowHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -591,7 +600,7 @@ void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
|
|||||||
* dispatch() itself, because that's called recursively.
|
* dispatch() itself, because that's called recursively.
|
||||||
*/
|
*/
|
||||||
if (available())
|
if (available())
|
||||||
screen().showCursor(*bv_);
|
owner_->gui().guiCursor().show(*bv_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -618,7 +627,7 @@ void BufferView::Pimpl::selectionRequested()
|
|||||||
xsel_cache_.set = cur.selection();
|
xsel_cache_.set = cur.selection();
|
||||||
sel = cur.selectionAsString(false);
|
sel = cur.selectionAsString(false);
|
||||||
if (!sel.empty())
|
if (!sel.empty())
|
||||||
workarea().putClipboard(sel);
|
clipboard().put(sel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,7 +635,7 @@ void BufferView::Pimpl::selectionRequested()
|
|||||||
void BufferView::Pimpl::selectionLost()
|
void BufferView::Pimpl::selectionLost()
|
||||||
{
|
{
|
||||||
if (available()) {
|
if (available()) {
|
||||||
screen().hideCursor();
|
owner_->gui().guiCursor().hide();
|
||||||
cursor_.clearSelection();
|
cursor_.clearSelection();
|
||||||
xsel_cache_.set = false;
|
xsel_cache_.set = false;
|
||||||
}
|
}
|
||||||
@ -635,15 +644,15 @@ void BufferView::Pimpl::selectionLost()
|
|||||||
|
|
||||||
void BufferView::Pimpl::workAreaResize()
|
void BufferView::Pimpl::workAreaResize()
|
||||||
{
|
{
|
||||||
static int work_area_width;
|
static int workArea_width;
|
||||||
static int work_area_height;
|
static int workArea_height;
|
||||||
|
|
||||||
bool const widthChange = workarea().workWidth() != work_area_width;
|
bool const widthChange = workArea_->width() != workArea_width;
|
||||||
bool const heightChange = workarea().workHeight() != work_area_height;
|
bool const heightChange = workArea_->height() != workArea_height;
|
||||||
|
|
||||||
// Update from work area
|
// Update from work area
|
||||||
work_area_width = workarea().workWidth();
|
workArea_width = workArea_->width();
|
||||||
work_area_height = workarea().workHeight();
|
workArea_height = workArea_->height();
|
||||||
|
|
||||||
if (buffer_ && widthChange) {
|
if (buffer_ && widthChange) {
|
||||||
// The visible LyXView need a resize
|
// The visible LyXView need a resize
|
||||||
@ -666,7 +675,7 @@ bool BufferView::Pimpl::fitCursor()
|
|||||||
int const asc = font_metrics::maxAscent(font);
|
int const asc = font_metrics::maxAscent(font);
|
||||||
int const des = font_metrics::maxDescent(font);
|
int const des = font_metrics::maxDescent(font);
|
||||||
Point const p = bv_funcs::getPos(cursor_, cursor_.boundary());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
center();
|
center();
|
||||||
@ -721,14 +730,14 @@ void BufferView::Pimpl::update(Update::flags flags)
|
|||||||
}
|
}
|
||||||
if (forceupdate) {
|
if (forceupdate) {
|
||||||
// Second drawing step
|
// Second drawing step
|
||||||
screen().redraw(*bv_, vi);
|
workArea_->redraw(*bv_, vi);
|
||||||
} else {
|
} else {
|
||||||
// Abort updating of the coord
|
// Abort updating of the coord
|
||||||
// cache - just restore the old one
|
// cache - just restore the old one
|
||||||
std::swap(theCoords, backup);
|
std::swap(theCoords, backup);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
screen().greyOut();
|
workArea_->greyOut();
|
||||||
|
|
||||||
// And the scrollbar
|
// And the scrollbar
|
||||||
updateScrollbar();
|
updateScrollbar();
|
||||||
@ -740,7 +749,7 @@ void BufferView::Pimpl::update(Update::flags flags)
|
|||||||
void BufferView::Pimpl::cursorToggle()
|
void BufferView::Pimpl::cursorToggle()
|
||||||
{
|
{
|
||||||
if (buffer_) {
|
if (buffer_) {
|
||||||
screen().toggleCursor(*bv_);
|
owner_->gui().guiCursor().toggle(*bv_);
|
||||||
|
|
||||||
// Use this opportunity to deal with any child processes that
|
// Use this opportunity to deal with any child processes that
|
||||||
// have finished but are waiting to communicate this fact
|
// have finished but are waiting to communicate this fact
|
||||||
@ -867,13 +876,13 @@ void BufferView::Pimpl::center()
|
|||||||
Paragraph const & par = bot.text()->paragraphs()[pit];
|
Paragraph const & par = bot.text()->paragraphs()[pit];
|
||||||
anchor_ref_ = pit;
|
anchor_ref_ = pit;
|
||||||
offset_ref_ = bv_funcs::coordOffset(cursor_, cursor_.boundary()).y_
|
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
|
void BufferView::Pimpl::stuffClipboard(string const & content) const
|
||||||
{
|
{
|
||||||
workarea().putClipboard(content);
|
clipboard().put(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -998,13 +1007,13 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
|
|||||||
if (!available())
|
if (!available())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
screen().hideCursor();
|
owner_->gui().guiCursor().hide();
|
||||||
|
|
||||||
// Either the inset under the cursor or the
|
// Either the inset under the cursor or the
|
||||||
// surrounding LyXText will handle this event.
|
// surrounding LyXText will handle this event.
|
||||||
|
|
||||||
// Build temporary cursor.
|
// Build temporary cursor.
|
||||||
cmd.y = min(max(cmd.y,-1), workarea().workHeight());
|
cmd.y = min(max(cmd.y, -1), workArea_->height());
|
||||||
InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
|
InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
|
||||||
//lyxerr << BOOST_CURRENT_FUNCTION
|
//lyxerr << BOOST_CURRENT_FUNCTION
|
||||||
// << " * hit inset at tip: " << inset << endl;
|
// << " * hit inset at tip: " << inset << endl;
|
||||||
@ -1036,7 +1045,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
|
|||||||
|
|
||||||
// See workAreaKeyPress
|
// See workAreaKeyPress
|
||||||
cursor_timeout.restart();
|
cursor_timeout.restart();
|
||||||
screen().showCursor(*bv_);
|
owner_->gui().guiCursor().show(*bv_);
|
||||||
|
|
||||||
// Skip these when selecting
|
// Skip these when selecting
|
||||||
if (cmd.action != LFUN_MOUSE_MOTION) {
|
if (cmd.action != LFUN_MOUSE_MOTION) {
|
||||||
|
@ -34,16 +34,24 @@
|
|||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/signals/trackable.hpp>
|
#include <boost/signals/trackable.hpp>
|
||||||
|
|
||||||
|
|
||||||
class Change;
|
class Change;
|
||||||
class LyXKeySym;
|
class LyXKeySym;
|
||||||
class LyXView;
|
class LyXView;
|
||||||
class WorkArea;
|
|
||||||
class LyXScreen;
|
|
||||||
class FuncRequest;
|
class FuncRequest;
|
||||||
class FuncStatus;
|
class FuncStatus;
|
||||||
class ViewMetricsInfo;
|
class ViewMetricsInfo;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
class Gui;
|
||||||
|
class WorkArea;
|
||||||
|
class Clipboard;
|
||||||
|
class Painter;
|
||||||
|
class GuiCursor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
class BufferView::Pimpl : public boost::signals::trackable {
|
class BufferView::Pimpl : public boost::signals::trackable {
|
||||||
@ -51,9 +59,7 @@ public:
|
|||||||
///
|
///
|
||||||
Pimpl(BufferView & bv, LyXView * owner, int width, int height);
|
Pimpl(BufferView & bv, LyXView * owner, int width, int height);
|
||||||
///
|
///
|
||||||
Painter & painter() const;
|
lyx::frontend::Painter & painter() const;
|
||||||
/// return the screen for this bview
|
|
||||||
LyXScreen & screen() const;
|
|
||||||
///
|
///
|
||||||
void setBuffer(Buffer * buf);
|
void setBuffer(Buffer * buf);
|
||||||
///
|
///
|
||||||
@ -110,6 +116,14 @@ public:
|
|||||||
bool repaintAll() { return refresh_inside_; }
|
bool repaintAll() { return refresh_inside_; }
|
||||||
///
|
///
|
||||||
void repaintAll(bool r) {refresh_inside_ = r; }
|
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:
|
private:
|
||||||
/// An error list (replaces the error insets)
|
/// An error list (replaces the error insets)
|
||||||
ErrorList errorlist_;
|
ErrorList errorlist_;
|
||||||
@ -148,10 +162,7 @@ private:
|
|||||||
LyXView * owner_;
|
LyXView * owner_;
|
||||||
///
|
///
|
||||||
Buffer * buffer_;
|
Buffer * buffer_;
|
||||||
///
|
|
||||||
boost::scoped_ptr<LyXScreen> screen_;
|
|
||||||
///
|
|
||||||
boost::scoped_ptr<WorkArea> workarea_;
|
|
||||||
/// Estimated average par height for scrollbar
|
/// Estimated average par height for scrollbar
|
||||||
int wh_;
|
int wh_;
|
||||||
///
|
///
|
||||||
@ -179,8 +190,10 @@ private:
|
|||||||
std::vector<Position> saved_positions;
|
std::vector<Position> saved_positions;
|
||||||
///
|
///
|
||||||
void menuInsertLyXFile(std::string const & filen);
|
void menuInsertLyXFile(std::string const & filen);
|
||||||
/// our workarea
|
|
||||||
WorkArea & workarea() const;
|
lyx::frontend::WorkArea * workArea_;
|
||||||
|
int workAreaId_;
|
||||||
|
|
||||||
/// this is used to handle XSelection events in the right manner
|
/// this is used to handle XSelection events in the right manner
|
||||||
struct {
|
struct {
|
||||||
CursorSlice cursor;
|
CursorSlice cursor;
|
||||||
|
41
src/frontends/Clipboard.h
Normal file
41
src/frontends/Clipboard.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file Clipboard.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 BASE_CLIPBOARD_H
|
||||||
|
#define BASE_CLIPBOARD_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Clipboard class manages the clipboard.
|
||||||
|
*/
|
||||||
|
class Clipboard
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Clipboard() {}
|
||||||
|
|
||||||
|
/// a selection exists
|
||||||
|
virtual void haveSelection(bool) = 0;
|
||||||
|
/// get the X clipboard contents
|
||||||
|
virtual std::string const get() const = 0;
|
||||||
|
/// fill the clipboard
|
||||||
|
virtual void put(std::string const &) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // BASE_CLIPBOARD_H
|
53
src/frontends/Gui.h
Normal file
53
src/frontends/Gui.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file Gui.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 BASE_GUI_H
|
||||||
|
#define BASE_GUI_H
|
||||||
|
|
||||||
|
#include "frontends/GuiCursor.h"
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
class Clipboard;
|
||||||
|
class WorkArea;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Gui class manages the different frontend elements.
|
||||||
|
*/
|
||||||
|
class Gui
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Gui() {}
|
||||||
|
|
||||||
|
///
|
||||||
|
virtual Clipboard& clipboard() = 0;
|
||||||
|
///
|
||||||
|
virtual int newWorkArea(int w, int h) = 0;
|
||||||
|
///
|
||||||
|
virtual WorkArea& workArea(int id) = 0;
|
||||||
|
///
|
||||||
|
virtual void destroyWorkArea(int id) = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
GuiCursor & guiCursor() {return cursor_;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
GuiCursor cursor_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // BASE_GUI_H
|
149
src/frontends/GuiCursor.C
Normal file
149
src/frontends/GuiCursor.C
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/**
|
||||||
|
* \file GuiCursor.C
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author John Levon
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*
|
||||||
|
* Splash screen code added by Angus Leeming
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "frontends/GuiCursor.h"
|
||||||
|
|
||||||
|
#include "font_metrics.h"
|
||||||
|
#include "lyx_gui.h"
|
||||||
|
#include "frontends/Painter.h"
|
||||||
|
#include "frontends/WorkArea.h"
|
||||||
|
|
||||||
|
#include "BufferView.h"
|
||||||
|
#include "buffer.h"
|
||||||
|
#include "bufferparams.h"
|
||||||
|
#include "coordcache.h"
|
||||||
|
#include "cursor.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "language.h"
|
||||||
|
#include "LColor.h"
|
||||||
|
#include "lyxfont.h"
|
||||||
|
#include "lyxrc.h"
|
||||||
|
#include "lyxrow.h"
|
||||||
|
#include "lyxtext.h"
|
||||||
|
#include "metricsinfo.h"
|
||||||
|
#include "paragraph.h"
|
||||||
|
#include "rowpainter.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
#include "graphics/GraphicsImage.h"
|
||||||
|
#include "graphics/GraphicsLoader.h"
|
||||||
|
|
||||||
|
#include "support/filetools.h" // LibFileSearch
|
||||||
|
|
||||||
|
#include <boost/utility.hpp>
|
||||||
|
#include <boost/bind.hpp>
|
||||||
|
#include <boost/signals/trackable.hpp>
|
||||||
|
|
||||||
|
using lyx::support::libFileSearch;
|
||||||
|
|
||||||
|
using std::endl;
|
||||||
|
using std::min;
|
||||||
|
using std::max;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
GuiCursor::GuiCursor()
|
||||||
|
: cursor_visible_(false), work_area_(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GuiCursor::~GuiCursor()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiCursor::connect(WorkArea * work_area)
|
||||||
|
{
|
||||||
|
work_area_ = work_area;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiCursor::show(BufferView & bv)
|
||||||
|
{
|
||||||
|
if (cursor_visible_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!bv.available())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Cursor_Shape shape = BAR_SHAPE;
|
||||||
|
|
||||||
|
LyXText const & text = *bv.getLyXText();
|
||||||
|
LyXFont const & realfont = text.real_current_font;
|
||||||
|
BufferParams const & bp = bv.buffer()->params();
|
||||||
|
bool const samelang = realfont.language() == bp.language;
|
||||||
|
bool const isrtl = realfont.isVisibleRightToLeft();
|
||||||
|
|
||||||
|
if (!samelang || isrtl != bp.language->rightToLeft()) {
|
||||||
|
shape = L_SHAPE;
|
||||||
|
if (isrtl)
|
||||||
|
shape = REVERSED_L_SHAPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The ERT language hack needs fixing up
|
||||||
|
if (realfont.language() == latex_language)
|
||||||
|
shape = BAR_SHAPE;
|
||||||
|
|
||||||
|
LyXFont const font = bv.cursor().getFont();
|
||||||
|
int const asc = font_metrics::maxAscent(font);
|
||||||
|
int const des = font_metrics::maxDescent(font);
|
||||||
|
int h = asc + des;
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
bv.cursor().getPos(x, y);
|
||||||
|
y -= asc;
|
||||||
|
//lyxerr << "Cursor::show x: " << x << " y: " << y << endl;
|
||||||
|
|
||||||
|
BOOST_ASSERT(work_area_);
|
||||||
|
|
||||||
|
// if it doesn't touch the screen, don't try to show it
|
||||||
|
if (y + h < 0 || y >= work_area_->height())
|
||||||
|
return;
|
||||||
|
|
||||||
|
cursor_visible_ = true;
|
||||||
|
work_area_->showCursor(x, y, h, shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiCursor::hide()
|
||||||
|
{
|
||||||
|
if (!cursor_visible_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
cursor_visible_ = false;
|
||||||
|
BOOST_ASSERT(work_area_);
|
||||||
|
work_area_->removeCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiCursor::toggle(BufferView & bv)
|
||||||
|
{
|
||||||
|
if (cursor_visible_)
|
||||||
|
hide();
|
||||||
|
else
|
||||||
|
show(bv);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiCursor::prepare()
|
||||||
|
{
|
||||||
|
cursor_visible_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
73
src/frontends/GuiCursor.h
Normal file
73
src/frontends/GuiCursor.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file GuiCursor.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_CURSOR_H
|
||||||
|
#define GUI_CURSOR_H
|
||||||
|
|
||||||
|
|
||||||
|
class LyXText;
|
||||||
|
class CursorSlice;
|
||||||
|
class BufferView;
|
||||||
|
class ViewMetricsInfo;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
class WorkArea;
|
||||||
|
|
||||||
|
/// types of cursor in work area
|
||||||
|
enum Cursor_Shape {
|
||||||
|
/// normal I-beam
|
||||||
|
BAR_SHAPE,
|
||||||
|
/// L-shape for locked insets of a different language
|
||||||
|
L_SHAPE,
|
||||||
|
/// reverse L-shape for RTL text
|
||||||
|
REVERSED_L_SHAPE
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GuiCursor - document rendering management
|
||||||
|
*
|
||||||
|
* The blinking cursor is handled here.
|
||||||
|
*/
|
||||||
|
class GuiCursor {
|
||||||
|
public:
|
||||||
|
GuiCursor();
|
||||||
|
|
||||||
|
virtual ~GuiCursor();
|
||||||
|
|
||||||
|
void connect(WorkArea * work_area);
|
||||||
|
|
||||||
|
/// hide the visible cursor, if it is visible
|
||||||
|
void hide();
|
||||||
|
|
||||||
|
/// show the cursor if it is not visible
|
||||||
|
void show(BufferView & bv);
|
||||||
|
|
||||||
|
/// toggle the cursor's visibility
|
||||||
|
void toggle(BufferView & bv);
|
||||||
|
|
||||||
|
/// set cursor_visible_ to false in prep for re-display
|
||||||
|
void prepare();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// is the cursor currently displayed
|
||||||
|
bool cursor_visible_;
|
||||||
|
|
||||||
|
WorkArea * work_area_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // GUI_CURSOR_H
|
@ -1,26 +0,0 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
/**
|
|
||||||
* \file LyXScreenFactory.h
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author John Levon
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LYXSCREENFACTORY_H
|
|
||||||
#define LYXSCREENFACTORY_H
|
|
||||||
|
|
||||||
class WorkArea;
|
|
||||||
class LyXScreen;
|
|
||||||
|
|
||||||
namespace LyXScreenFactory {
|
|
||||||
/**
|
|
||||||
* Make a screen renderer. Used because we want to
|
|
||||||
* generate a toolkit-specific instance.
|
|
||||||
*/
|
|
||||||
LyXScreen * create(WorkArea & owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // LYXSCREEN_FACTORY_H
|
|
@ -33,9 +33,15 @@ class Timeout;
|
|||||||
class FuncRequest;
|
class FuncRequest;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
namespace frontend {
|
||||||
|
class Gui;
|
||||||
|
} // namespace frontend
|
||||||
|
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
class ControlCommandBuffer;
|
class ControlCommandBuffer;
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,6 +151,8 @@ public:
|
|||||||
// returns true if this view has the focus.
|
// returns true if this view has the focus.
|
||||||
virtual bool hasFocus() const = 0;
|
virtual bool hasFocus() const = 0;
|
||||||
|
|
||||||
|
virtual lyx::frontend::Gui & gui() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// view of a buffer. Eventually there will be several.
|
/// view of a buffer. Eventually there will be several.
|
||||||
boost::shared_ptr<BufferView> bufferview_;
|
boost::shared_ptr<BufferView> bufferview_;
|
||||||
|
@ -21,7 +21,6 @@ libfrontends_la_SOURCES = \
|
|||||||
FileDialog.h \
|
FileDialog.h \
|
||||||
LyXKeySym.h \
|
LyXKeySym.h \
|
||||||
LyXKeySymFactory.h \
|
LyXKeySymFactory.h \
|
||||||
LyXScreenFactory.h \
|
|
||||||
LyXView.C \
|
LyXView.C \
|
||||||
LyXView.h \
|
LyXView.h \
|
||||||
Menubar.h \
|
Menubar.h \
|
||||||
@ -31,8 +30,12 @@ libfrontends_la_SOURCES = \
|
|||||||
Timeout.h \
|
Timeout.h \
|
||||||
Toolbars.C \
|
Toolbars.C \
|
||||||
Toolbars.h \
|
Toolbars.h \
|
||||||
|
Clipboard.h \
|
||||||
|
Gui.h \
|
||||||
|
GuiCursor.C \
|
||||||
|
GuiCursor.h \
|
||||||
|
WorkArea.C \
|
||||||
WorkArea.h \
|
WorkArea.h \
|
||||||
WorkAreaFactory.h \
|
|
||||||
font_metrics.h \
|
font_metrics.h \
|
||||||
guiapi.h \
|
guiapi.h \
|
||||||
guiapi.C \
|
guiapi.C \
|
||||||
@ -40,6 +43,4 @@ libfrontends_la_SOURCES = \
|
|||||||
lyx_gui.h \
|
lyx_gui.h \
|
||||||
mouse_state.h \
|
mouse_state.h \
|
||||||
nullpainter.C \
|
nullpainter.C \
|
||||||
nullpainter.h \
|
nullpainter.h
|
||||||
screen.C \
|
|
||||||
screen.h
|
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include "Painter.h"
|
#include "Painter.h"
|
||||||
#include "font_metrics.h"
|
#include "font_metrics.h"
|
||||||
#include "WorkArea.h"
|
|
||||||
|
|
||||||
#include "LColor.h"
|
#include "LColor.h"
|
||||||
#include "lyxfont.h"
|
#include "lyxfont.h"
|
||||||
@ -21,6 +20,8 @@
|
|||||||
using std::max;
|
using std::max;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
void Painter::button(int x, int y, int w, int h)
|
void Painter::button(int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
@ -92,3 +93,6 @@ void Painter::underline(LyXFont const & f, int x, int y, int width)
|
|||||||
else
|
else
|
||||||
fillRectangle(x, y + below, width, below + height, f.color());
|
fillRectangle(x, y + below, width, below + height, f.color());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
@ -26,8 +26,8 @@ namespace lyx {
|
|||||||
namespace graphics {
|
namespace graphics {
|
||||||
class Image;
|
class Image;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Painter - A painter class to encapsulate all graphics parameters and operations
|
* Painter - A painter class to encapsulate all graphics parameters and operations
|
||||||
@ -182,4 +182,7 @@ protected:
|
|||||||
virtual void buttonFrame(int x, int y, int w, int h);
|
virtual void buttonFrame(int x, int y, int w, int h);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
#endif // PAINTER_H
|
#endif // PAINTER_H
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* \file screen.C
|
* \file WorkArea.C
|
||||||
* This file is part of LyX, the document processor.
|
* This file is part of LyX, the document processor.
|
||||||
* Licence details can be found in the file COPYING.
|
* Licence details can be found in the file COPYING.
|
||||||
*
|
*
|
||||||
* \author John Levon
|
* \author John Levon
|
||||||
|
* \author Abdelrazak Younes
|
||||||
*
|
*
|
||||||
* Full author contact details are available in file CREDITS.
|
* Full author contact details are available in file CREDITS.
|
||||||
*
|
*
|
||||||
@ -12,11 +13,11 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "screen.h"
|
#include "WorkArea.h"
|
||||||
|
|
||||||
#include "font_metrics.h"
|
#include "font_metrics.h"
|
||||||
#include "lyx_gui.h"
|
#include "lyx_gui.h"
|
||||||
#include "Painter.h"
|
#include "Painter.h"
|
||||||
#include "WorkArea.h"
|
|
||||||
|
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
@ -52,7 +53,8 @@ using std::max;
|
|||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
class SplashScreen : boost::noncopyable, boost::signals::trackable {
|
class SplashScreen : boost::noncopyable, boost::signals::trackable {
|
||||||
public:
|
public:
|
||||||
@ -116,126 +118,48 @@ SplashScreen::SplashScreen()
|
|||||||
loader_.reset(file);
|
loader_.reset(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace anon
|
WorkArea::WorkArea(LyXView & owner, int w, int h)
|
||||||
|
: greyed_out_(true)
|
||||||
|
|
||||||
LyXScreen::LyXScreen()
|
|
||||||
: greyed_out_(true), cursor_visible_(false)
|
|
||||||
{
|
{
|
||||||
// Start loading the pixmap as soon as possible
|
// Start loading the pixmap as soon as possible
|
||||||
if (lyxrc.show_banner) {
|
if (lyxrc.show_banner) {
|
||||||
SplashScreen const & splash = SplashScreen::get();
|
SplashScreen const & splash = SplashScreen::get();
|
||||||
splash.connect(boost::bind(&LyXScreen::checkAndGreyOut, this));
|
splash.connect(boost::bind(&WorkArea::checkAndGreyOut, this));
|
||||||
splash.startLoading();
|
splash.startLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXScreen::~LyXScreen()
|
void WorkArea::checkAndGreyOut()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LyXScreen::checkAndGreyOut()
|
|
||||||
{
|
{
|
||||||
if (greyed_out_)
|
if (greyed_out_)
|
||||||
greyOut();
|
greyOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXScreen::showCursor(BufferView & bv)
|
void WorkArea::redraw(BufferView & bv, ViewMetricsInfo const & vi)
|
||||||
{
|
|
||||||
if (cursor_visible_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!bv.available())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Cursor_Shape shape = BAR_SHAPE;
|
|
||||||
|
|
||||||
LyXText const & text = *bv.getLyXText();
|
|
||||||
LyXFont const & realfont = text.real_current_font;
|
|
||||||
BufferParams const & bp = bv.buffer()->params();
|
|
||||||
bool const samelang = realfont.language() == bp.language;
|
|
||||||
bool const isrtl = realfont.isVisibleRightToLeft();
|
|
||||||
|
|
||||||
if (!samelang || isrtl != bp.language->rightToLeft()) {
|
|
||||||
shape = L_SHAPE;
|
|
||||||
if (isrtl)
|
|
||||||
shape = REVERSED_L_SHAPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The ERT language hack needs fixing up
|
|
||||||
if (realfont.language() == latex_language)
|
|
||||||
shape = BAR_SHAPE;
|
|
||||||
|
|
||||||
LyXFont const font = bv.cursor().getFont();
|
|
||||||
int const asc = font_metrics::maxAscent(font);
|
|
||||||
int const des = font_metrics::maxDescent(font);
|
|
||||||
int h = asc + des;
|
|
||||||
int x = 0;
|
|
||||||
int y = 0;
|
|
||||||
bv.cursor().getPos(x, y);
|
|
||||||
y -= asc;
|
|
||||||
//lyxerr << "LyXScreen::showCursor x: " << x << " y: " << y << endl;
|
|
||||||
|
|
||||||
// if it doesn't touch the screen, don't try to show it
|
|
||||||
if (y + h < 0 || y >= workarea().workHeight())
|
|
||||||
return;
|
|
||||||
|
|
||||||
cursor_visible_ = true;
|
|
||||||
showCursor(x, y, h, shape);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LyXScreen::hideCursor()
|
|
||||||
{
|
|
||||||
if (!cursor_visible_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
cursor_visible_ = false;
|
|
||||||
removeCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LyXScreen::toggleCursor(BufferView & bv)
|
|
||||||
{
|
|
||||||
if (cursor_visible_)
|
|
||||||
hideCursor();
|
|
||||||
else
|
|
||||||
showCursor(bv);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LyXScreen::prepareCursor()
|
|
||||||
{
|
|
||||||
cursor_visible_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LyXScreen::redraw(BufferView & bv, ViewMetricsInfo const & vi)
|
|
||||||
{
|
{
|
||||||
greyed_out_ = false;
|
greyed_out_ = false;
|
||||||
workarea().getPainter().start();
|
getPainter().start();
|
||||||
paintText(bv, vi);
|
paintText(bv, vi);
|
||||||
lyxerr[Debug::DEBUG] << "Redraw screen" << endl;
|
lyxerr[Debug::DEBUG] << "Redraw screen" << endl;
|
||||||
int const ymin = std::max(vi.y1, 0);
|
int const ymin = std::max(vi.y1, 0);
|
||||||
int const ymax =
|
int const ymax =
|
||||||
( vi.p2 < vi.size - 1 ? vi.y2 : workarea().workHeight() );
|
( vi.p2 < vi.size - 1 ? vi.y2 : height() );
|
||||||
expose(0, ymin, workarea().workWidth(), ymax - ymin);
|
expose(0, ymin, width(), ymax - ymin);
|
||||||
workarea().getPainter().end();
|
getPainter().end();
|
||||||
theCoords.doneUpdating();
|
theCoords.doneUpdating();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXScreen::greyOut()
|
void WorkArea::greyOut()
|
||||||
{
|
{
|
||||||
greyed_out_ = true;
|
greyed_out_ = true;
|
||||||
workarea().getPainter().start();
|
getPainter().start();
|
||||||
|
|
||||||
workarea().getPainter().fillRectangle(0, 0,
|
getPainter().fillRectangle(0, 0,
|
||||||
workarea().workWidth(),
|
width(),
|
||||||
workarea().workHeight(),
|
height(),
|
||||||
LColor::bottomarea);
|
LColor::bottomarea);
|
||||||
|
|
||||||
// Add a splash screen to the centre of the work area
|
// Add a splash screen to the centre of the work area
|
||||||
@ -245,16 +169,19 @@ void LyXScreen::greyOut()
|
|||||||
int const w = splash_image->getWidth();
|
int const w = splash_image->getWidth();
|
||||||
int const h = splash_image->getHeight();
|
int const h = splash_image->getHeight();
|
||||||
|
|
||||||
int x = (workarea().workWidth() - w) / 2;
|
int x = (width() - w) / 2;
|
||||||
int y = (workarea().workHeight() - h) / 2;
|
int y = (height() - h) / 2;
|
||||||
|
|
||||||
workarea().getPainter().image(x, y, w, h, *splash_image);
|
getPainter().image(x, y, w, h, *splash_image);
|
||||||
|
|
||||||
x += 260;
|
x += 260;
|
||||||
y += 265;
|
y += 265;
|
||||||
|
|
||||||
workarea().getPainter().text(x, y, splash.text(), splash.font());
|
getPainter().text(x, y, splash.text(), splash.font());
|
||||||
}
|
}
|
||||||
expose(0, 0, workarea().workWidth(), workarea().workHeight());
|
expose(0, 0, width(), height());
|
||||||
workarea().getPainter().end();
|
getPainter().end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
@ -6,32 +6,39 @@
|
|||||||
*
|
*
|
||||||
* \author unknown
|
* \author unknown
|
||||||
* \author John Levon
|
* \author John Levon
|
||||||
|
* \author Abdelrazak Younes
|
||||||
*
|
*
|
||||||
* Full author contact details are available in file CREDITS.
|
* Full author contact details are available in file CREDITS.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WORKAREA_H
|
#ifndef BASE_WORKAREA_H
|
||||||
#define WORKAREA_H
|
#define BASE_WORKAREA_H
|
||||||
|
|
||||||
|
#include "frontends/GuiCursor.h"
|
||||||
|
|
||||||
#include "frontends/key_state.h"
|
#include "frontends/key_state.h"
|
||||||
#include "frontends/LyXKeySym.h"
|
#include "frontends/LyXKeySym.h"
|
||||||
|
|
||||||
#include <boost/signal.hpp>
|
class LyXView;
|
||||||
|
class FuncRequest;
|
||||||
|
class BufferView;
|
||||||
|
class ViewMetricsInfo;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
class Painter;
|
class Painter;
|
||||||
class FuncRequest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The work area class represents the widget that provides the
|
* The work area class represents the widget that provides the
|
||||||
* view onto a document. It is owned by the BufferView, and
|
* view onto a document. It is owned by the BufferView, and
|
||||||
* is responsible for handing events back to its owning BufferView.
|
* is responsible for handing events back to its owning BufferView.
|
||||||
* It works in concert with the LyXScreen class to update the
|
* It works in concert with the BaseScreen class to update the
|
||||||
* widget view of a document.
|
* widget view of a document.
|
||||||
*/
|
*/
|
||||||
class WorkArea {
|
class WorkArea {
|
||||||
public:
|
public:
|
||||||
WorkArea() {}
|
WorkArea(LyXView & owner, int w, int h);
|
||||||
|
|
||||||
virtual ~WorkArea() {}
|
virtual ~WorkArea() {}
|
||||||
|
|
||||||
@ -39,9 +46,10 @@ public:
|
|||||||
virtual Painter & getPainter() = 0;
|
virtual Painter & getPainter() = 0;
|
||||||
|
|
||||||
/// return the width of the work area in pixels
|
/// return the width of the work area in pixels
|
||||||
virtual int workWidth() const = 0;
|
virtual int width() const = 0;
|
||||||
|
|
||||||
/// return the height of the work area in pixels
|
/// return the height of the work area in pixels
|
||||||
virtual int workHeight() const = 0;
|
virtual int height() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the scrollbar.
|
* Update the scrollbar.
|
||||||
@ -51,13 +59,31 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
|
virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
|
||||||
|
|
||||||
// FIXME: this is an odd place to have it, but xforms needs it here ...
|
/// redraw the screen, without using existing pixmap
|
||||||
/// a selection exists
|
virtual void redraw(BufferView & bv, ViewMetricsInfo const & vi);
|
||||||
virtual void haveSelection(bool) const = 0;
|
|
||||||
/// get the X clipboard contents
|
/// grey out (no buffer)
|
||||||
virtual std::string const getClipboard() const = 0;
|
void greyOut();
|
||||||
/// fill the clipboard
|
|
||||||
virtual void putClipboard(std::string const &) const = 0;
|
/// paint the cursor and store the background
|
||||||
|
virtual void showCursor(int x, int y, int h, Cursor_Shape shape) = 0;
|
||||||
|
|
||||||
|
/// hide the cursor
|
||||||
|
virtual void removeCursor() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// cause the display of the given area of the work area
|
||||||
|
virtual void expose(int x, int y, int w, int h) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
///
|
||||||
|
void checkAndGreyOut();
|
||||||
|
|
||||||
|
///
|
||||||
|
bool greyed_out_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WORKAREA_H
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // BASE_WORKAREA_H
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
/**
|
|
||||||
* \file WorkAreaFactory.h
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author John Levon
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WORKAREAFACTORY_H
|
|
||||||
#define WORKAREAFACTORY_H
|
|
||||||
|
|
||||||
class WorkArea;
|
|
||||||
class LyXView;
|
|
||||||
|
|
||||||
namespace WorkAreaFactory {
|
|
||||||
/**
|
|
||||||
* Make a work area. Used because we want to generate
|
|
||||||
* a toolkit-specific instance.
|
|
||||||
*/
|
|
||||||
WorkArea * create(LyXView & owner, int w, int h);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // WORKAREA_FACTORY_H
|
|
@ -30,10 +30,8 @@
|
|||||||
#include "lyxtext.h"
|
#include "lyxtext.h"
|
||||||
#include "lyxrow.h"
|
#include "lyxrow.h"
|
||||||
|
|
||||||
#include "frontends/screen.h"
|
|
||||||
#include "frontends/font_metrics.h"
|
#include "frontends/font_metrics.h"
|
||||||
#include "frontends/Painter.h"
|
#include "frontends/Painter.h"
|
||||||
#include "frontends/WorkArea.h"
|
|
||||||
|
|
||||||
#include "insets/insettext.h"
|
#include "insets/insettext.h"
|
||||||
|
|
||||||
@ -43,7 +41,7 @@ namespace lyx {
|
|||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
GScreen::GScreen(GWorkArea & o)
|
GScreen::GScreen(GWorkArea & o)
|
||||||
: LyXScreen(), owner_(o)
|
: owner_(o)
|
||||||
{
|
{
|
||||||
// the cursor isnt yet visible
|
// the cursor isnt yet visible
|
||||||
cursorX_ = 0;
|
cursorX_ = 0;
|
||||||
@ -58,12 +56,6 @@ GScreen::~GScreen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WorkArea & GScreen::workarea()
|
|
||||||
{
|
|
||||||
return owner_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GScreen::setCursorColor(Glib::RefPtr<Gdk::GC> gc)
|
void GScreen::setCursorColor(Glib::RefPtr<Gdk::GC> gc)
|
||||||
{
|
{
|
||||||
Gdk::Color * clr = owner_.getColorHandler().
|
Gdk::Color * clr = owner_.getColorHandler().
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#ifndef GSCREEN_H
|
#ifndef GSCREEN_H
|
||||||
#define GSCREEN_H
|
#define GSCREEN_H
|
||||||
|
|
||||||
#include "screen.h"
|
#include "frontends/GuiCursor.h"
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ class GWorkArea;
|
|||||||
date and used to optimize drawing on the screen.
|
date and used to optimize drawing on the screen.
|
||||||
This class also handles the drawing of the cursor and partly the selection.
|
This class also handles the drawing of the cursor and partly the selection.
|
||||||
*/
|
*/
|
||||||
class GScreen : public LyXScreen {
|
class GScreen {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
GScreen(GWorkArea &);
|
GScreen(GWorkArea &);
|
||||||
@ -40,9 +40,6 @@ public:
|
|||||||
virtual void removeCursor();
|
virtual void removeCursor();
|
||||||
///
|
///
|
||||||
virtual void showCursor(int x, int y, int h, Cursor_Shape shape);
|
virtual void showCursor(int x, int y, int h, Cursor_Shape shape);
|
||||||
protected:
|
|
||||||
/// get the work area
|
|
||||||
virtual WorkArea & workarea();
|
|
||||||
|
|
||||||
/// Copies specified area of pixmap to screen
|
/// Copies specified area of pixmap to screen
|
||||||
virtual void expose(int x, int y, int w, int h);
|
virtual void expose(int x, int y, int w, int h);
|
||||||
|
@ -57,7 +57,7 @@ void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
|
|||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
GView::GView()
|
GView::GView() : frontend_(*this)
|
||||||
{
|
{
|
||||||
// The physical store for the boxes making up the layout.
|
// The physical store for the boxes making up the layout.
|
||||||
box_store_.push_back(BoxPtr(new Gtk::VBox));
|
box_store_.push_back(BoxPtr(new Gtk::VBox));
|
||||||
|
@ -12,9 +12,12 @@
|
|||||||
#ifndef GVIEW_H
|
#ifndef GVIEW_H
|
||||||
#define GVIEW_H
|
#define GVIEW_H
|
||||||
|
|
||||||
#include "frontends/LyXView.h"
|
|
||||||
#include "bufferview_funcs.h"
|
#include "bufferview_funcs.h"
|
||||||
|
|
||||||
|
#include "frontends/LyXView.h"
|
||||||
|
|
||||||
|
#include "GuiImplementation.h"
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -55,6 +58,9 @@ public:
|
|||||||
// returns true if this view has the focus.
|
// returns true if this view has the focus.
|
||||||
virtual bool hasFocus() const;
|
virtual bool hasFocus() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
Gui & gui() { return frontend_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void showViewState();
|
void showViewState();
|
||||||
bool onFocusIn(GdkEventFocus * event);
|
bool onFocusIn(GdkEventFocus * event);
|
||||||
@ -73,6 +79,8 @@ private:
|
|||||||
|
|
||||||
boost::scoped_ptr<GMiniBuffer> minibuffer_;
|
boost::scoped_ptr<GMiniBuffer> minibuffer_;
|
||||||
Gtk::Widget * workArea_;
|
Gtk::Widget * workArea_;
|
||||||
|
///
|
||||||
|
GuiImplementation frontend_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -504,7 +504,7 @@ void GWorkArea::onClipboardClear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GWorkArea::haveSelection(bool toHave) const
|
void GWorkArea::haveSelection(bool toHave)
|
||||||
{
|
{
|
||||||
if (toHave) {
|
if (toHave) {
|
||||||
Glib::RefPtr<Gtk::Clipboard> clipboard =
|
Glib::RefPtr<Gtk::Clipboard> clipboard =
|
||||||
@ -533,7 +533,7 @@ string const GWorkArea::getClipboard() const
|
|||||||
|
|
||||||
// ENCODING: we assume that the backend passes us ISO-8859-1 and
|
// ENCODING: we assume that the backend passes us ISO-8859-1 and
|
||||||
// convert from that to UTF-8 before passing to GTK
|
// convert from that to UTF-8 before passing to GTK
|
||||||
void GWorkArea::putClipboard(string const & str) const
|
void GWorkArea::putClipboard(string const & str)
|
||||||
{
|
{
|
||||||
Glib::RefPtr<Gtk::Clipboard> clipboard =
|
Glib::RefPtr<Gtk::Clipboard> clipboard =
|
||||||
Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
|
Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "GPainter.h"
|
#include "GPainter.h"
|
||||||
|
|
||||||
#include "frontends/WorkArea.h"
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
@ -55,7 +55,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class GWorkArea : public WorkArea, public sigc::trackable {
|
class GWorkArea : public sigc::trackable {
|
||||||
public:
|
public:
|
||||||
GWorkArea(LyXView & owner, int width, int height);
|
GWorkArea(LyXView & owner, int width, int height);
|
||||||
~GWorkArea();
|
~GWorkArea();
|
||||||
@ -80,11 +80,11 @@ public:
|
|||||||
|
|
||||||
virtual void setScrollbarParams(int height, int pos, int line_height);
|
virtual void setScrollbarParams(int height, int pos, int line_height);
|
||||||
/// a selection exists
|
/// a selection exists
|
||||||
virtual void haveSelection(bool) const;
|
virtual void haveSelection(bool);
|
||||||
///
|
///
|
||||||
virtual std::string const getClipboard() const;
|
virtual std::string const getClipboard() const;
|
||||||
///
|
///
|
||||||
virtual void putClipboard(std::string const &) const;
|
virtual void putClipboard(std::string const &);
|
||||||
void inputCommit(gchar * str);
|
void inputCommit(gchar * str);
|
||||||
private:
|
private:
|
||||||
bool onExpose(GdkEventExpose * event);
|
bool onExpose(GdkEventExpose * event);
|
||||||
|
63
src/frontends/gtk/GuiClipboard.h
Normal file
63
src/frontends/gtk/GuiClipboard.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file gtk/Clipboard.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CLIPBOARD_H
|
||||||
|
#define CLIPBOARD_H
|
||||||
|
|
||||||
|
#include "frontends/Clipboard.h"
|
||||||
|
|
||||||
|
#include "GWorkArea.h"
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
typedef GWorkArea FWorkArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The GTK version of the Clipboard.
|
||||||
|
*/
|
||||||
|
class GuiClipboard: public lyx::frontend::Clipboard
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiClipboard(FWorkArea * work_area)
|
||||||
|
: old_work_area_(work_area)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~GuiClipboard() {}
|
||||||
|
|
||||||
|
/** ClipBoard overloaded methods
|
||||||
|
*/
|
||||||
|
//@{
|
||||||
|
void haveSelection(bool own)
|
||||||
|
{
|
||||||
|
old_work_area_->haveSelection(own);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string const get() const
|
||||||
|
{
|
||||||
|
return old_work_area_->getClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void put(std::string const & str)
|
||||||
|
{
|
||||||
|
old_work_area_->putClipboard(str);
|
||||||
|
}
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
FWorkArea * old_work_area_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // CLIPBOARD_H
|
91
src/frontends/gtk/GuiImplementation.h
Normal file
91
src/frontends/gtk/GuiImplementation.h
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file gtk/GuiImplementation.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GUI_IMPLEMENTATION_H
|
||||||
|
#define GUI_IMPLEMENTATION_H
|
||||||
|
|
||||||
|
#include "frontends/Gui.h"
|
||||||
|
#include "frontends/LyXView.h"
|
||||||
|
|
||||||
|
#include "GScreen.h"
|
||||||
|
#include "GWorkArea.h"
|
||||||
|
|
||||||
|
#include "GuiClipboard.h"
|
||||||
|
#include "GuiWorkArea.h"
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
typedef GScreen FScreen;
|
||||||
|
typedef GWorkArea FWorkArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Gui class is the interface to all GTK components.
|
||||||
|
*/
|
||||||
|
class GuiImplementation: public lyx::frontend::Gui
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiImplementation(LyXView & owner): owner_(owner)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~GuiImplementation()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
lyx::frontend::Clipboard& clipboard()
|
||||||
|
{
|
||||||
|
return *clipboard_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newWorkArea(int w, int h)
|
||||||
|
{
|
||||||
|
old_work_area_.reset(new FWorkArea(owner_, w, h));
|
||||||
|
old_screen_.reset(new FScreen(*old_work_area_.get()));
|
||||||
|
work_area_.reset(new GuiWorkArea(owner_, w, h, old_screen_.get(), old_work_area_.get()));
|
||||||
|
clipboard_.reset(new GuiClipboard(old_work_area_.get()));
|
||||||
|
guiCursor().connect(work_area_.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
lyx::frontend::WorkArea& workArea(int id)
|
||||||
|
{
|
||||||
|
return *work_area_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroyWorkArea(int id)
|
||||||
|
{
|
||||||
|
clipboard_.reset();
|
||||||
|
work_area_.reset();
|
||||||
|
old_work_area_.reset();
|
||||||
|
old_screen_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
///
|
||||||
|
boost::shared_ptr<GuiClipboard> clipboard_;
|
||||||
|
///
|
||||||
|
boost::shared_ptr<GuiWorkArea> work_area_;
|
||||||
|
///
|
||||||
|
boost::shared_ptr<FWorkArea> old_work_area_;
|
||||||
|
///
|
||||||
|
boost::shared_ptr<FScreen> old_screen_;
|
||||||
|
///
|
||||||
|
LyXView & owner_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // GUI_IMPLEMENTATION_H
|
98
src/frontends/gtk/GuiWorkArea.h
Normal file
98
src/frontends/gtk/GuiWorkArea.h
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file gtk/WorkArea.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WORKAREA_H
|
||||||
|
#define WORKAREA_H
|
||||||
|
|
||||||
|
#include "frontends/WorkArea.h"
|
||||||
|
|
||||||
|
#include "GScreen.h"
|
||||||
|
#include "GWorkArea.h"
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
typedef GScreen FScreen;
|
||||||
|
typedef GWorkArea FWorkArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary wrapper around GWorkArea and GScreen.
|
||||||
|
* Please refer to the Qt4 implementation for a proper cleanup of the API.
|
||||||
|
*/
|
||||||
|
class GuiWorkArea: public lyx::frontend::WorkArea {
|
||||||
|
public:
|
||||||
|
GuiWorkArea(LyXView & owner, int w, int h,
|
||||||
|
FScreen * screen, FWorkArea * work_area)
|
||||||
|
: lyx::frontend::WorkArea(owner, w, h),
|
||||||
|
old_screen_(screen), old_work_area_(work_area)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~GuiWorkArea() {}
|
||||||
|
|
||||||
|
/// return the painter object for this work area
|
||||||
|
virtual lyx::frontend::Painter & getPainter()
|
||||||
|
{
|
||||||
|
return old_work_area_->getPainter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// return the width of the work area in pixels
|
||||||
|
virtual int width() const
|
||||||
|
{
|
||||||
|
return old_work_area_->workWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// return the height of the work area in pixels
|
||||||
|
virtual int height() const
|
||||||
|
{
|
||||||
|
return old_work_area_->workHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the scrollbar.
|
||||||
|
* @param height the total document height in pixels
|
||||||
|
* @param pos the current position in the document, in pixels
|
||||||
|
* @param line_height the line-scroll amount, in pixels
|
||||||
|
*/
|
||||||
|
virtual void setScrollbarParams(int height, int pos, int line_height)
|
||||||
|
{
|
||||||
|
old_work_area_->setScrollbarParams(height, pos, line_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// paint the cursor and store the background
|
||||||
|
virtual void showCursor(int x, int y, int h, Cursor_Shape shape)
|
||||||
|
{
|
||||||
|
old_screen_->showCursor(x, y, h, shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// hide the cursor
|
||||||
|
virtual void removeCursor()
|
||||||
|
{
|
||||||
|
old_screen_->removeCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// cause the display of the given area of the work area
|
||||||
|
virtual void expose(int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
old_screen_->expose(x, y, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
FScreen * old_screen_;
|
||||||
|
FWorkArea * old_work_area_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // WORKAREA_H
|
@ -1,38 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file gtk/LyXScreenFactory.C
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author Huang Ying
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
// Too hard to make concept checks work with this file
|
|
||||||
#ifdef _GLIBCXX_CONCEPT_CHECKS
|
|
||||||
#undef _GLIBCXX_CONCEPT_CHECKS
|
|
||||||
#endif
|
|
||||||
#ifdef _GLIBCPP_CONCEPT_CHECKS
|
|
||||||
#undef _GLIBCPP_CONCEPT_CHECKS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "GWorkArea.h"
|
|
||||||
#include "GScreen.h"
|
|
||||||
|
|
||||||
#include "frontends/LyXScreenFactory.h"
|
|
||||||
|
|
||||||
namespace LyXScreenFactory {
|
|
||||||
|
|
||||||
|
|
||||||
LyXScreen * create(WorkArea & owner)
|
|
||||||
{
|
|
||||||
using lyx::frontend::GScreen;
|
|
||||||
using lyx::frontend::GWorkArea;
|
|
||||||
|
|
||||||
return new GScreen(static_cast<GWorkArea &>(owner));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -111,6 +111,8 @@ libgtk_la_SOURCES = \
|
|||||||
GToolbar.h \
|
GToolbar.h \
|
||||||
GUrl.C \
|
GUrl.C \
|
||||||
GUrl.h \
|
GUrl.h \
|
||||||
|
GuiClipboard.h \
|
||||||
|
GuiWorkArea.h \
|
||||||
GView.C \
|
GView.C \
|
||||||
GView.h \
|
GView.h \
|
||||||
GViewBase.C \
|
GViewBase.C \
|
||||||
@ -133,10 +135,9 @@ libgtk_la_SOURCES = \
|
|||||||
LyXGdkImage.C \
|
LyXGdkImage.C \
|
||||||
LyXGdkImage.h \
|
LyXGdkImage.h \
|
||||||
LyXKeySymFactory.C \
|
LyXKeySymFactory.C \
|
||||||
LyXScreenFactory.C \
|
|
||||||
WorkAreaFactory.C \
|
|
||||||
ghelpers.C \
|
ghelpers.C \
|
||||||
ghelpers.h \
|
ghelpers.h \
|
||||||
|
GuiImplementation.h \
|
||||||
io_callback.C \
|
io_callback.C \
|
||||||
io_callback.h \
|
io_callback.h \
|
||||||
lyx_gui.C \
|
lyx_gui.C \
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file gtk/WorkAreaFactory.C
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author Huang Ying
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
// Too hard to make concept checks work with this file
|
|
||||||
#ifdef _GLIBCXX_CONCEPT_CHECKS
|
|
||||||
#undef _GLIBCXX_CONCEPT_CHECKS
|
|
||||||
#endif
|
|
||||||
#ifdef _GLIBCPP_CONCEPT_CHECKS
|
|
||||||
#undef _GLIBCPP_CONCEPT_CHECKS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "GWorkArea.h"
|
|
||||||
|
|
||||||
#include "frontends/WorkAreaFactory.h"
|
|
||||||
|
|
||||||
#include <gtkmm.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace WorkAreaFactory {
|
|
||||||
|
|
||||||
|
|
||||||
WorkArea * create(LyXView & owner, int w, int h)
|
|
||||||
{
|
|
||||||
return new lyx::frontend::GWorkArea(owner, w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -18,7 +18,13 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
int NullPainter::paperHeight() const
|
int NullPainter::paperHeight() const
|
||||||
{
|
{
|
||||||
return std::numeric_limits<int>::max();
|
return std::numeric_limits<int>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
#include "LColor.h"
|
#include "LColor.h"
|
||||||
#include "Painter.h"
|
#include "Painter.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
class NullPainter : public Painter {
|
class NullPainter : public Painter {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
@ -71,4 +75,7 @@ public:
|
|||||||
void buttonFrame(int, int, int, int) {}
|
void buttonFrame(int, int, int, int) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
#endif // NULLPAINTER_H
|
#endif // NULLPAINTER_H
|
||||||
|
63
src/frontends/qt3/GuiClipboard.h
Normal file
63
src/frontends/qt3/GuiClipboard.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file qt3/GuiClipboard.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CLIPBOARD_H
|
||||||
|
#define CLIPBOARD_H
|
||||||
|
|
||||||
|
#include "frontends/Clipboard.h"
|
||||||
|
|
||||||
|
#include "QWorkArea.h"
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
typedef QWorkArea FWorkArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Qt3 version of the Clipboard.
|
||||||
|
*/
|
||||||
|
class GuiClipboard: public lyx::frontend::Clipboard
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiClipboard(FWorkArea * work_area)
|
||||||
|
: old_work_area_(work_area)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~GuiClipboard() {}
|
||||||
|
|
||||||
|
/** ClipBoard overloaded methods
|
||||||
|
*/
|
||||||
|
//@{
|
||||||
|
void haveSelection(bool own)
|
||||||
|
{
|
||||||
|
old_work_area_->haveSelection(own);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string const get() const
|
||||||
|
{
|
||||||
|
return old_work_area_->getClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void put(std::string const & str)
|
||||||
|
{
|
||||||
|
old_work_area_->putClipboard(str);
|
||||||
|
}
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
FWorkArea * old_work_area_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // CLIPBOARD_H
|
89
src/frontends/qt3/GuiImplementation.h
Normal file
89
src/frontends/qt3/GuiImplementation.h
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file qt3/Gui.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GUI_IMPLEMENTATION_H
|
||||||
|
#define GUI_IMPLEMENTATION_H
|
||||||
|
|
||||||
|
#include "frontends/Gui.h"
|
||||||
|
#include "frontends/LyXView.h"
|
||||||
|
|
||||||
|
#include "qscreen.h"
|
||||||
|
#include "QWorkArea.h"
|
||||||
|
|
||||||
|
#include "GuiClipboard.h"
|
||||||
|
#include "GuiWorkArea.h"
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
typedef QScreen FScreen;
|
||||||
|
typedef QWorkArea FWorkArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Gui class is the interface to all Qt3 components.
|
||||||
|
*/
|
||||||
|
class GuiImplementation: public lyx::frontend::Gui
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiImplementation(LyXView & owner): owner_(owner)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~GuiImplementation()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
lyx::frontend::Clipboard& clipboard()
|
||||||
|
{
|
||||||
|
return *clipboard_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newWorkArea(int w, int h)
|
||||||
|
{
|
||||||
|
old_work_area_.reset(new FWorkArea(owner_, w, h));
|
||||||
|
old_screen_.reset(new FScreen(*old_work_area_.get()));
|
||||||
|
work_area_.reset(new GuiWorkArea(owner_, w, h, old_screen_.get(), old_work_area_.get()));
|
||||||
|
clipboard_.reset(new GuiClipboard(old_work_area_.get()));
|
||||||
|
guiCursor().connect(work_area_.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
lyx::frontend::WorkArea& workArea(int id)
|
||||||
|
{
|
||||||
|
return *work_area_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroyWorkArea(int id)
|
||||||
|
{
|
||||||
|
clipboard_.reset();
|
||||||
|
work_area_.reset();
|
||||||
|
old_work_area_.reset();
|
||||||
|
old_screen_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
///
|
||||||
|
boost::shared_ptr<GuiClipboard> clipboard_;
|
||||||
|
///
|
||||||
|
boost::shared_ptr<GuiWorkArea> work_area_;
|
||||||
|
///
|
||||||
|
boost::shared_ptr<FWorkArea> old_work_area_;
|
||||||
|
///
|
||||||
|
boost::shared_ptr<FScreen> old_screen_;
|
||||||
|
///
|
||||||
|
LyXView & owner_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // GUI_IMPLEMENTATION_H
|
98
src/frontends/qt3/GuiWorkArea.h
Normal file
98
src/frontends/qt3/GuiWorkArea.h
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file qt3/WorkArea.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WORKAREA_H
|
||||||
|
#define WORKAREA_H
|
||||||
|
|
||||||
|
#include "frontends/WorkArea.h"
|
||||||
|
|
||||||
|
#include "qscreen.h"
|
||||||
|
#include "QWorkArea.h"
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
typedef QScreen FScreen;
|
||||||
|
typedef QWorkArea FWorkArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary wrapper around QWorkArea and QScreen.
|
||||||
|
* Please refer to the Qt4 implementation for a proper cleanup of the API.
|
||||||
|
*/
|
||||||
|
class GuiWorkArea: public lyx::frontend::WorkArea {
|
||||||
|
public:
|
||||||
|
GuiWorkArea(LyXView & owner, int w, int h,
|
||||||
|
FScreen * screen, FWorkArea * work_area)
|
||||||
|
: lyx::frontend::WorkArea(owner, w, h),
|
||||||
|
old_screen_(screen), old_work_area_(work_area)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~GuiWorkArea() {}
|
||||||
|
|
||||||
|
/// return the painter object for this work area
|
||||||
|
virtual lyx::frontend::Painter & getPainter()
|
||||||
|
{
|
||||||
|
return old_work_area_->getPainter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// return the width of the work area in pixels
|
||||||
|
virtual int width() const
|
||||||
|
{
|
||||||
|
return old_work_area_->workWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// return the height of the work area in pixels
|
||||||
|
virtual int height() const
|
||||||
|
{
|
||||||
|
return old_work_area_->workHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the scrollbar.
|
||||||
|
* @param height the total document height in pixels
|
||||||
|
* @param pos the current position in the document, in pixels
|
||||||
|
* @param line_height the line-scroll amount, in pixels
|
||||||
|
*/
|
||||||
|
virtual void setScrollbarParams(int height, int pos, int line_height)
|
||||||
|
{
|
||||||
|
old_work_area_->setScrollbarParams(height, pos, line_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// paint the cursor and store the background
|
||||||
|
virtual void showCursor(int x, int y, int h, Cursor_Shape shape)
|
||||||
|
{
|
||||||
|
old_screen_->showCursor(x, y, h, shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// hide the cursor
|
||||||
|
virtual void removeCursor()
|
||||||
|
{
|
||||||
|
old_screen_->removeCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// cause the display of the given area of the work area
|
||||||
|
virtual void expose(int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
old_screen_->expose(x, y, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
FScreen * old_screen_;
|
||||||
|
FWorkArea * old_work_area_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // WORKAREA_H
|
@ -1,25 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file qt3/LyXScreenFactory.C
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author John Levon
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "frontends/LyXScreenFactory.h"
|
|
||||||
|
|
||||||
#include "QWorkArea.h"
|
|
||||||
#include "qscreen.h"
|
|
||||||
|
|
||||||
namespace LyXScreenFactory {
|
|
||||||
|
|
||||||
LyXScreen * create(WorkArea & owner)
|
|
||||||
{
|
|
||||||
return new QScreen(static_cast<QWorkArea &>(owner));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace LyXScreenFactory
|
|
@ -27,8 +27,10 @@ libqt3_la_SOURCES = \
|
|||||||
Alert_pimpl.C \
|
Alert_pimpl.C \
|
||||||
Dialogs.C \
|
Dialogs.C \
|
||||||
FileDialog.C \
|
FileDialog.C \
|
||||||
|
GuiClipboard.h \
|
||||||
|
GuiImplementation.h \
|
||||||
|
GuiWorkArea.h \
|
||||||
LyXKeySymFactory.C \
|
LyXKeySymFactory.C \
|
||||||
LyXScreenFactory.C \
|
|
||||||
QLMenubar.C QLMenubar.h \
|
QLMenubar.C QLMenubar.h \
|
||||||
qtTimeout.C qtTimeout.h \
|
qtTimeout.C qtTimeout.h \
|
||||||
QAbout.C QAbout.h \
|
QAbout.C QAbout.h \
|
||||||
@ -73,7 +75,6 @@ libqt3_la_SOURCES = \
|
|||||||
QWrap.C QWrap.h \
|
QWrap.C QWrap.h \
|
||||||
Qt2BC.C Qt2BC.h \
|
Qt2BC.C Qt2BC.h \
|
||||||
QtLyXView.h \
|
QtLyXView.h \
|
||||||
WorkAreaFactory.C \
|
|
||||||
checkedwidgets.C checkedwidgets.h \
|
checkedwidgets.C checkedwidgets.h \
|
||||||
lyx_gui.C \
|
lyx_gui.C \
|
||||||
lcolorcache.h lcolorcache.C \
|
lcolorcache.h lcolorcache.C \
|
||||||
|
@ -78,6 +78,9 @@ mouse_button::state q_motion_state(Qt::ButtonState state)
|
|||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
// This is a 'heartbeat' generating synthetic mouse move events when the
|
// This is a 'heartbeat' generating synthetic mouse move events when the
|
||||||
// cursor is at the top or bottom edge of the viewport. One scroll per 0.2 s
|
// cursor is at the top or bottom edge of the viewport. One scroll per 0.2 s
|
||||||
SyntheticMouseEvent::SyntheticMouseEvent()
|
SyntheticMouseEvent::SyntheticMouseEvent()
|
||||||
@ -358,3 +361,6 @@ void QContentPane::trackScrollbar(bool track_on)
|
|||||||
{
|
{
|
||||||
track_scrollbar_ = track_on;
|
track_scrollbar_ = track_on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
@ -12,12 +12,14 @@
|
|||||||
#ifndef QCONTENTPANE_H
|
#ifndef QCONTENTPANE_H
|
||||||
#define QCONTENTPANE_H
|
#define QCONTENTPANE_H
|
||||||
|
|
||||||
|
#include "funcrequest.h"
|
||||||
#ifdef emit
|
#ifdef emit
|
||||||
#undef emit
|
#undef emit
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "funcrequest.h"
|
|
||||||
#include "frontends/Timeout.h"
|
#include "frontends/Timeout.h"
|
||||||
|
#define emit
|
||||||
|
#else
|
||||||
|
#include "frontends/Timeout.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <qwidget.h>
|
#include <qwidget.h>
|
||||||
#include <qpixmap.h>
|
#include <qpixmap.h>
|
||||||
@ -31,7 +33,6 @@
|
|||||||
#define USE_INPUT_METHODS 1
|
#define USE_INPUT_METHODS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class QWorkArea;
|
|
||||||
|
|
||||||
/// for emulating triple click
|
/// for emulating triple click
|
||||||
class double_click {
|
class double_click {
|
||||||
@ -55,6 +56,11 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
class QWorkArea;
|
||||||
|
|
||||||
/** Qt only emits mouse events when the mouse is being moved, but
|
/** Qt only emits mouse events when the mouse is being moved, but
|
||||||
* we want to generate 'pseudo' mouse events when the mouse button is
|
* we want to generate 'pseudo' mouse events when the mouse button is
|
||||||
* pressed and the mouse cursor is below the bottom, or above the top
|
* pressed and the mouse cursor is below the bottom, or above the top
|
||||||
@ -139,4 +145,7 @@ private:
|
|||||||
double_click dc_event_;
|
double_click dc_event_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
#endif // QCONTENTPANE_H
|
#endif // QCONTENTPANE_H
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
using std::endl;
|
using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
QLPainter::QLPainter(QWorkArea & qwa)
|
QLPainter::QLPainter(QWorkArea & qwa)
|
||||||
: Painter(), owner_(qwa), paint_check_(0)
|
: Painter(), owner_(qwa), paint_check_(0)
|
||||||
@ -248,3 +250,7 @@ void QLPainter::text(int x, int y, char const * s, size_t ls,
|
|||||||
underline(f, x, y, font_metrics::width(s, ls, f));
|
underline(f, x, y, font_metrics::width(s, ls, f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
@ -12,19 +12,24 @@
|
|||||||
#ifndef QLPAINTER_H
|
#ifndef QLPAINTER_H
|
||||||
#define QLPAINTER_H
|
#define QLPAINTER_H
|
||||||
|
|
||||||
#include "Painter.h"
|
#include "frontends/Painter.h"
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
|
|
||||||
class LyXFont;
|
class LyXFont;
|
||||||
class QWorkArea;
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
class QWorkArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QLPainter - a painter implementation for Xlib
|
* QLPainter - a painter implementation for Xlib
|
||||||
*/
|
*/
|
||||||
class QLPainter : public Painter {
|
class QLPainter : public lyx::frontend::Painter {
|
||||||
public:
|
public:
|
||||||
QLPainter(QWorkArea &);
|
QLPainter(QWorkArea &);
|
||||||
|
|
||||||
@ -133,4 +138,7 @@ private:
|
|||||||
int paint_check_;
|
int paint_check_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
#endif // QLPAINTER_H
|
#endif // QLPAINTER_H
|
||||||
|
@ -38,22 +38,24 @@
|
|||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
#include <support/lstrings.h>
|
#include <support/lstrings.h>
|
||||||
|
|
||||||
using lyx::support::subst;
|
using lyx::support::internalLineEnding;
|
||||||
#endif
|
using lyx::support::externalLineEnding;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
namespace os = lyx::support::os;
|
namespace os = lyx::support::os;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
QWorkArea * wa_ptr = 0;
|
lyx::frontend::QWorkArea * wa_ptr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
QWorkArea::QWorkArea(LyXView & owner, int, int)
|
QWorkArea::QWorkArea(LyXView & owner, int, int)
|
||||||
: WorkArea(), QWidget(qApp->mainWidget()), owner_(owner), painter_(*this)
|
: QWidget(qApp->mainWidget()), owner_(owner), painter_(*this)
|
||||||
{
|
{
|
||||||
scrollbar_ = new QScrollBar(QScrollBar::Vertical, this);
|
scrollbar_ = new QScrollBar(QScrollBar::Vertical, this);
|
||||||
content_ = new QContentPane(this);
|
content_ = new QContentPane(this);
|
||||||
@ -99,6 +101,10 @@ void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
|
|||||||
scrollbar_->setPageStep(height());
|
scrollbar_->setPageStep(height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
bool lyxX11EventFilter(XEvent * xev)
|
bool lyxX11EventFilter(XEvent * xev)
|
||||||
{
|
{
|
||||||
@ -184,7 +190,11 @@ pascal OSErr handleOpenDocuments(const AppleEvent* inEvent,
|
|||||||
}
|
}
|
||||||
#endif // Q_WS_MACX
|
#endif // Q_WS_MACX
|
||||||
|
|
||||||
void QWorkArea::haveSelection(bool own) const
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
void QWorkArea::haveSelection(bool own)
|
||||||
{
|
{
|
||||||
wa_ptr = const_cast<QWorkArea*>(this);
|
wa_ptr = const_cast<QWorkArea*>(this);
|
||||||
|
|
||||||
@ -206,24 +216,14 @@ string const QWorkArea::getClipboard() const
|
|||||||
QString str = QApplication::clipboard()->text();
|
QString str = QApplication::clipboard()->text();
|
||||||
if (str.isNull())
|
if (str.isNull())
|
||||||
return string();
|
return string();
|
||||||
#ifdef Q_OS_MAC
|
return internalLineEnding(fromqstr(str));
|
||||||
// The MAC clipboard uses \r for lineendings, and we use \n
|
|
||||||
return subst(fromqstr(str), '\r', '\n');
|
|
||||||
#else
|
|
||||||
return fromqstr(str);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::putClipboard(string const & str) const
|
void QWorkArea::putClipboard(string const & str)
|
||||||
{
|
{
|
||||||
QApplication::clipboard()->setSelectionMode(true);
|
QApplication::clipboard()->setSelectionMode(true);
|
||||||
#ifdef Q_OS_MAC
|
QApplication::clipboard()->setText(toqstr(externalLineEnding(str)));
|
||||||
// The MAC clipboard uses \r for lineendings, and we use \n
|
|
||||||
QApplication::clipboard()->setText(toqstr(subst(str, '\n', '\r')));
|
|
||||||
#else
|
|
||||||
QApplication::clipboard()->setText(toqstr(str));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -247,3 +247,6 @@ void QWorkArea::dropEvent(QDropEvent * event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#ifndef QWORKAREA_H
|
#ifndef QWORKAREA_H
|
||||||
#define QWORKAREA_H
|
#define QWORKAREA_H
|
||||||
|
|
||||||
#include "WorkArea.h"
|
|
||||||
#include "QLPainter.h"
|
#include "QLPainter.h"
|
||||||
#include "QContentPane.h"
|
#include "QContentPane.h"
|
||||||
|
|
||||||
@ -23,6 +22,9 @@ class LyXView;
|
|||||||
class QPixmap;
|
class QPixmap;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Qt-specific implementation of the work area
|
* Qt-specific implementation of the work area
|
||||||
@ -31,7 +33,7 @@ class QWidget;
|
|||||||
* It consists of a content pane widget, and a scrollbar.
|
* It consists of a content pane widget, and a scrollbar.
|
||||||
* Hopefully soon we can just use QScrollView ...
|
* Hopefully soon we can just use QScrollView ...
|
||||||
*/
|
*/
|
||||||
class QWorkArea : public WorkArea, public QWidget {
|
class QWorkArea : public QWidget {
|
||||||
public:
|
public:
|
||||||
friend class QContentPane;
|
friend class QContentPane;
|
||||||
|
|
||||||
@ -39,7 +41,7 @@ public:
|
|||||||
|
|
||||||
virtual ~QWorkArea();
|
virtual ~QWorkArea();
|
||||||
/// return this widget's painter
|
/// return this widget's painter
|
||||||
virtual Painter & getPainter() { return painter_; }
|
virtual lyx::frontend::Painter & getPainter() { return painter_; }
|
||||||
/// return the width of the content pane
|
/// return the width of the content pane
|
||||||
virtual int workWidth() const { return content_->width(); }
|
virtual int workWidth() const { return content_->width(); }
|
||||||
/// return the height of the content pane
|
/// return the height of the content pane
|
||||||
@ -48,11 +50,11 @@ public:
|
|||||||
virtual void setScrollbarParams(int height, int pos, int line_height);
|
virtual void setScrollbarParams(int height, int pos, int line_height);
|
||||||
|
|
||||||
/// a selection exists
|
/// a selection exists
|
||||||
virtual void haveSelection(bool) const;
|
virtual void haveSelection(bool);
|
||||||
///
|
///
|
||||||
virtual std::string const getClipboard() const;
|
virtual std::string const getClipboard() const;
|
||||||
///
|
///
|
||||||
virtual void putClipboard(std::string const &) const;
|
virtual void putClipboard(std::string const &);
|
||||||
///
|
///
|
||||||
virtual void dragEnterEvent(QDragEnterEvent * event);
|
virtual void dragEnterEvent(QDragEnterEvent * event);
|
||||||
///
|
///
|
||||||
@ -81,4 +83,8 @@ private:
|
|||||||
QLPainter painter_;
|
QLPainter painter_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
#endif // QWORKAREA_H
|
#endif // QWORKAREA_H
|
||||||
|
@ -56,7 +56,7 @@ int const statusbar_timer_value = 3000;
|
|||||||
|
|
||||||
|
|
||||||
QtView::QtView(unsigned int width, unsigned int height)
|
QtView::QtView(unsigned int width, unsigned int height)
|
||||||
: QMainWindow(), LyXView(), commandbuffer_(0)
|
: QMainWindow(), LyXView(), commandbuffer_(0), frontend_(*this)
|
||||||
{
|
{
|
||||||
resize(width, height);
|
resize(width, height);
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "frontends/LyXView.h"
|
#include "frontends/LyXView.h"
|
||||||
|
|
||||||
|
#include "GuiImplementation.h"
|
||||||
|
|
||||||
#include <qmainwindow.h>
|
#include <qmainwindow.h>
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
|
|
||||||
@ -62,6 +64,9 @@ public:
|
|||||||
// returns true if this view has the focus.
|
// returns true if this view has the focus.
|
||||||
virtual bool hasFocus() const;
|
virtual bool hasFocus() const;
|
||||||
|
|
||||||
|
//
|
||||||
|
lyx::frontend::Gui & gui() { return frontend_; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/// idle timeout
|
/// idle timeout
|
||||||
void update_view_state_qt();
|
void update_view_state_qt();
|
||||||
@ -86,6 +91,9 @@ private:
|
|||||||
|
|
||||||
/// command buffer
|
/// command buffer
|
||||||
QCommandBuffer * commandbuffer_;
|
QCommandBuffer * commandbuffer_;
|
||||||
|
|
||||||
|
///
|
||||||
|
GuiImplementation frontend_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file qt3/WorkAreaFactory.C
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author John Levon
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "frontends/WorkAreaFactory.h"
|
|
||||||
#include "QWorkArea.h"
|
|
||||||
|
|
||||||
namespace WorkAreaFactory {
|
|
||||||
|
|
||||||
WorkArea * create(LyXView & owner, int w, int h)
|
|
||||||
{
|
|
||||||
return new QWorkArea(owner, w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace WorkAreaFactory
|
|
@ -30,9 +30,11 @@ void copyInPixmap(QPixmap * p, int dest_y, int src_y, int src_w, int src_h)
|
|||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
QScreen::QScreen(QWorkArea & o)
|
QScreen::QScreen(QWorkArea & o)
|
||||||
: LyXScreen(), owner_(o)
|
: owner_(o)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,12 +44,6 @@ QScreen::~QScreen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WorkArea & QScreen::workarea()
|
|
||||||
{
|
|
||||||
return owner_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void QScreen::repaint()
|
void QScreen::repaint()
|
||||||
{
|
{
|
||||||
QWidget * content = owner_.getContent();
|
QWidget * content = owner_.getContent();
|
||||||
@ -162,3 +158,7 @@ void QScreen::removeCursor()
|
|||||||
owner_.getContent()
|
owner_.getContent()
|
||||||
->update(cursor_x_, cursor_y_, cursor_w_, cursor_h_);
|
->update(cursor_x_, cursor_y_, cursor_w_, cursor_h_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
@ -12,27 +12,27 @@
|
|||||||
#ifndef QSCREEN_H
|
#ifndef QSCREEN_H
|
||||||
#define QSCREEN_H
|
#define QSCREEN_H
|
||||||
|
|
||||||
#include "screen.h"
|
#include "frontends/GuiCursor.h"
|
||||||
|
|
||||||
#include <qcolor.h>
|
#include <qcolor.h>
|
||||||
#include <qpixmap.h>
|
#include <qpixmap.h>
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
class QWorkArea;
|
class QWorkArea;
|
||||||
class WorkArea;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Qt implementation of toolkit-specific parts of LyXScreen.
|
* Qt implementation of toolkit-specific parts of LyXScreen.
|
||||||
*/
|
*/
|
||||||
class QScreen : public LyXScreen {
|
class QScreen {
|
||||||
public:
|
public:
|
||||||
QScreen(QWorkArea &);
|
QScreen(QWorkArea &);
|
||||||
|
|
||||||
virtual ~QScreen();
|
virtual ~QScreen();
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
/// get the work area
|
|
||||||
virtual WorkArea & workarea();
|
|
||||||
|
|
||||||
/// repaint the whole content immediately
|
/// repaint the whole content immediately
|
||||||
void repaint();
|
void repaint();
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ protected:
|
|||||||
virtual void expose(int x, int y, int exp_width, int exp_height);
|
virtual void expose(int x, int y, int exp_width, int exp_height);
|
||||||
|
|
||||||
/// paint the cursor and store the background
|
/// paint the cursor and store the background
|
||||||
virtual void showCursor(int x, int y, int h, Cursor_Shape shape);
|
virtual void showCursor(int x, int y, int h, lyx::frontend::Cursor_Shape shape);
|
||||||
|
|
||||||
/// hide the cursor
|
/// hide the cursor
|
||||||
virtual void removeCursor();
|
virtual void removeCursor();
|
||||||
@ -63,4 +63,7 @@ private:
|
|||||||
QColor cursor_color_;
|
QColor cursor_color_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
#endif // QSCREEN_H
|
#endif // QSCREEN_H
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
// stupid Qt
|
||||||
|
#undef emit
|
||||||
|
|
||||||
|
|
||||||
Timeout::Timeout(unsigned int msec, Type t)
|
Timeout::Timeout(unsigned int msec, Type t)
|
||||||
: pimpl_(new qtTimeout(*this)), type(t), timeout_ms(msec)
|
: pimpl_(new qtTimeout(*this)), type(t), timeout_ms(msec)
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
#ifndef QTTIMEOUT_H
|
#ifndef QTTIMEOUT_H
|
||||||
#define QTTIMEOUT_H
|
#define QTTIMEOUT_H
|
||||||
|
|
||||||
|
#ifdef emit
|
||||||
|
#undef emit
|
||||||
#include "frontends/Timeout.h"
|
#include "frontends/Timeout.h"
|
||||||
|
#define emit
|
||||||
|
#else
|
||||||
|
#include "frontends/Timeout.h"
|
||||||
|
#endif
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
|
|
||||||
// stupid Qt
|
|
||||||
#undef emit
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class executes the callback when the timeout expires
|
* This class executes the callback when the timeout expires
|
||||||
|
44
src/frontends/qt4/GuiClipboard.h
Normal file
44
src/frontends/qt4/GuiClipboard.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file GuiClipboard.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 CLIPBOARD_H
|
||||||
|
#define CLIPBOARD_H
|
||||||
|
|
||||||
|
#include "frontends/Clipboard.h"
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Qt4 version of the Clipboard.
|
||||||
|
*/
|
||||||
|
class GuiClipboard: public Clipboard
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiClipboard() {}
|
||||||
|
|
||||||
|
virtual ~GuiClipboard() {}
|
||||||
|
|
||||||
|
/** ClipBoard overloaded methods
|
||||||
|
*/
|
||||||
|
//@{
|
||||||
|
void haveSelection(bool own);
|
||||||
|
std::string const get() const;
|
||||||
|
void put(std::string const & str);
|
||||||
|
//@}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // CLIPBOARD_H
|
57
src/frontends/qt4/GuiImplementation.C
Normal file
57
src/frontends/qt4/GuiImplementation.C
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file GuiImplementation.C
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author John Levon
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GuiImplementation.h"
|
||||||
|
#include "GuiWorkArea.h"
|
||||||
|
#include "QtView.h"
|
||||||
|
|
||||||
|
using boost::shared_ptr;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
GuiImplementation::GuiImplementation(QtView & owner): owner_(owner), max_id_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Clipboard& GuiImplementation::clipboard()
|
||||||
|
{
|
||||||
|
return clipboard_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int GuiImplementation::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& GuiImplementation::workArea(int id)
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(work_areas_.find(id) != work_areas_.end());
|
||||||
|
|
||||||
|
guiCursor().connect(work_areas_[id].get());
|
||||||
|
|
||||||
|
return *work_areas_[id].get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiImplementation::destroyWorkArea(int id)
|
||||||
|
{
|
||||||
|
work_areas_.erase(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
58
src/frontends/qt4/GuiImplementation.h
Normal file
58
src/frontends/qt4/GuiImplementation.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file GuiImplementation.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author John Levon
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GUI_IMPLEMENTATION_H
|
||||||
|
#define GUI_IMPLEMENTATION_H
|
||||||
|
|
||||||
|
#include "frontends/Gui.h"
|
||||||
|
#include "GuiClipboard.h"
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
class GuiWorkArea;
|
||||||
|
class QtView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The GuiImplementation class is the interface to all Qt4 components.
|
||||||
|
*/
|
||||||
|
class GuiImplementation: public Gui
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiImplementation(QtView & owner);
|
||||||
|
virtual ~GuiImplementation() {}
|
||||||
|
|
||||||
|
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_IMPLEMENTATION_H
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* \file QWorkArea.C
|
* \file GuiWorkArea.C
|
||||||
* This file is part of LyX, the document processor.
|
* This file is part of LyX, the document processor.
|
||||||
* Licence details can be found in the file COPYING.
|
* Licence details can be found in the file COPYING.
|
||||||
*
|
*
|
||||||
@ -13,21 +13,20 @@
|
|||||||
|
|
||||||
#include <boost/current_function.hpp>
|
#include <boost/current_function.hpp>
|
||||||
|
|
||||||
#include "QWorkArea.h"
|
#include "GuiWorkArea.h"
|
||||||
#include "QLPainter.h"
|
#include "QLPainter.h"
|
||||||
#include "QLyXKeySym.h"
|
#include "QLyXKeySym.h"
|
||||||
#include "QtView.h"
|
#include "QtView.h"
|
||||||
|
|
||||||
#include "ColorCache.h"
|
#include "ColorCache.h"
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
|
#include "Application.h"
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
#include "LColor.h"
|
#include "LColor.h"
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QClipboard>
|
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
@ -39,21 +38,10 @@
|
|||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
// Abdel (09/06/2006):
|
||||||
// Specific stuff
|
// I want the drawing to be fast without Keyboard buffering so when working
|
||||||
#ifdef Q_WS_X11
|
// on optimization, please set the following macro to 0:
|
||||||
#include <X11/Xlib.h>
|
#define USE_KEY_BUFFERING 0
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_WS_MACX
|
|
||||||
#include <Carbon/Carbon.h>
|
|
||||||
#include <support/lstrings.h>
|
|
||||||
using lyx::support::subst;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// You can find other qt-immodule, X11 and MACX specific stuff
|
|
||||||
// at the end of this file...
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -62,8 +50,6 @@ namespace os = lyx::support::os;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
QWorkArea * wa_ptr = 0;
|
|
||||||
|
|
||||||
/// return the LyX key state from Qt's
|
/// return the LyX key state from Qt's
|
||||||
key_modifier::state q_key_state(Qt::ButtonState state)
|
key_modifier::state q_key_state(Qt::ButtonState state)
|
||||||
{
|
{
|
||||||
@ -114,6 +100,9 @@ mouse_button::state q_motion_state(Qt::ButtonState state)
|
|||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
// This is a 'heartbeat' generating synthetic mouse move events when the
|
// This is a 'heartbeat' generating synthetic mouse move events when the
|
||||||
// cursor is at the top or bottom edge of the viewport. One scroll per 0.2 s
|
// cursor is at the top or bottom edge of the viewport. One scroll per 0.2 s
|
||||||
SyntheticMouseEvent::SyntheticMouseEvent()
|
SyntheticMouseEvent::SyntheticMouseEvent()
|
||||||
@ -122,13 +111,13 @@ SyntheticMouseEvent::SyntheticMouseEvent()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
QWorkArea::QWorkArea(LyXView & owner, int w, int h)
|
GuiWorkArea::GuiWorkArea(LyXView & owner, int w, int h)
|
||||||
: QAbstractScrollArea(lyx::frontend::QtView::mainWidget()), WorkArea(), view_(owner), painter_(this)
|
: QAbstractScrollArea(QtView::mainWidget()), WorkArea(owner, w, h), view_(owner), painter_(this)
|
||||||
{
|
{
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
|
||||||
lyx::frontend::QtView::mainWidget()->setCentralWidget(this);
|
QtView::mainWidget()->setCentralWidget(this);
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
@ -149,7 +138,7 @@ QWorkArea::QWorkArea(LyXView & owner, int w, int h)
|
|||||||
workHeight_ = h;
|
workHeight_ = h;
|
||||||
|
|
||||||
synthetic_mouse_event_.timeout.timeout.connect(
|
synthetic_mouse_event_.timeout.timeout.connect(
|
||||||
boost::bind(&QWorkArea::generateSyntheticMouseEvent,
|
boost::bind(&GuiWorkArea::generateSyntheticMouseEvent,
|
||||||
this));
|
this));
|
||||||
|
|
||||||
// Initialize the vertical Scroll Bar
|
// Initialize the vertical Scroll Bar
|
||||||
@ -166,18 +155,18 @@ QWorkArea::QWorkArea(LyXView & owner, int w, int h)
|
|||||||
<< "\n viewport height\t" << viewport()->height()
|
<< "\n viewport height\t" << viewport()->height()
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
/*
|
if (USE_KEY_BUFFERING) {
|
||||||
// This is the keyboard buffering stuff...
|
// This is the keyboard buffering stuff...
|
||||||
// I don't see any need for this under windows. The keyboard is reactive
|
// I don't see any need for this under windows. The keyboard is reactive
|
||||||
// enough...
|
// enough...
|
||||||
|
|
||||||
if ( !QObject::connect(&step_timer_, SIGNAL(timeout()),
|
if ( !QObject::connect(&step_timer_, SIGNAL(timeout()),
|
||||||
this, SLOT(keyeventTimeout())) )
|
this, SLOT(keyeventTimeout())) )
|
||||||
lyxerr[Debug::GUI] << "ERROR: keyeventTimeout cannot connect!" << endl;
|
lyxerr[Debug::GUI] << "ERROR: keyeventTimeout cannot connect!" << endl;
|
||||||
|
|
||||||
// Start the timer, one-shot.
|
// Start the timer, one-shot.
|
||||||
step_timer_.start(50, true);
|
step_timer_.start(50, true);
|
||||||
*/
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// Specific stuff goes here...
|
// Specific stuff goes here...
|
||||||
@ -187,24 +176,13 @@ QWorkArea::QWorkArea(LyXView & owner, int w, int h)
|
|||||||
setInputMethodEnabled(true);
|
setInputMethodEnabled(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
|
||||||
// doubleClickInterval() is 400 ms on X11 witch is just too long.
|
|
||||||
// On Windows and Mac OS X, the operating system's value is used.
|
|
||||||
// On Microsoft Windows, calling this function sets the double
|
|
||||||
// click interval for all applications. So we don't!
|
|
||||||
QApplication::setDoubleClickInterval(300);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_WS_MACX
|
|
||||||
wa_ptr = this;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWorkArea::~QWorkArea()
|
GuiWorkArea::~GuiWorkArea()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step)
|
void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step)
|
||||||
{
|
{
|
||||||
// do what cursor movement does (some grey)
|
// do what cursor movement does (some grey)
|
||||||
h += height() / 4;
|
h += height() / 4;
|
||||||
@ -215,7 +193,7 @@ void QWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step)
|
|||||||
verticalScrollBar()->setLineStep(scroll_line_step);
|
verticalScrollBar()->setLineStep(scroll_line_step);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWorkArea::adjustViewWithScrollBar(int action)
|
void GuiWorkArea::adjustViewWithScrollBar(int)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
|
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
|
||||||
@ -231,68 +209,23 @@ void QWorkArea::adjustViewWithScrollBar(int action)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::haveSelection(bool own) const
|
void GuiWorkArea::dragEnterEvent(QDragEnterEvent * event)
|
||||||
{
|
|
||||||
/// \todo ask X11 and MAC devels why this wa_ptr is useful.
|
|
||||||
wa_ptr = const_cast<QWorkArea*>(this);
|
|
||||||
|
|
||||||
if (!QApplication::clipboard()->supportsSelection())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (own) {
|
|
||||||
QApplication::clipboard()->setText(QString(), QClipboard::Selection);
|
|
||||||
}
|
|
||||||
// We don't need to do anything if own = false, as this case is
|
|
||||||
// handled by QT.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
string const QWorkArea::getClipboard() const
|
|
||||||
{
|
|
||||||
QString str = QApplication::clipboard()->text(QClipboard::Selection);
|
|
||||||
lyxerr[Debug::ACTION] << "getClipboard: " << (const char*) str << endl;
|
|
||||||
if (str.isNull())
|
|
||||||
return string();
|
|
||||||
#ifdef Q_WS_MACX
|
|
||||||
// The MAC clipboard uses \r for lineendings, and we use \n
|
|
||||||
return subst(fromqstr(str), '\r', '\n');
|
|
||||||
#else
|
|
||||||
return fromqstr(str);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::putClipboard(string const & str) const
|
|
||||||
{
|
|
||||||
#ifdef Q_WS_MACX
|
|
||||||
// The MAC clipboard uses \r for lineendings, and we use \n
|
|
||||||
QApplication::clipboard()->setText(toqstr(subst(str, '\n', '\r')),
|
|
||||||
QClipboard::Selection);
|
|
||||||
#else
|
|
||||||
QApplication::clipboard()->setText(toqstr(str), QClipboard::Selection);
|
|
||||||
#endif
|
|
||||||
lyxerr[Debug::ACTION] << "putClipboard: " << str << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::dragEnterEvent(QDragEnterEvent * event)
|
|
||||||
{
|
{
|
||||||
if (event->mimeData()->hasUrls())
|
if (event->mimeData()->hasUrls())
|
||||||
event->accept();
|
event->accept();
|
||||||
/// \todo Ask lyx-devel is this is enough:
|
/// \todo Ask lyx-devel is this is enough:
|
||||||
/// if (event->mimeData()->hasFormat("text/plain"))
|
/// if (event->mimeData()->hasFormat("text/plain"))
|
||||||
/// event->acceptProposedAction();
|
/// event->acceptProposedAction();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::dropEvent(QDropEvent* event)
|
void GuiWorkArea::dropEvent(QDropEvent* event)
|
||||||
{
|
{
|
||||||
QList<QUrl> files = event->mimeData()->urls();
|
QList<QUrl> files = event->mimeData()->urls();
|
||||||
if (files.isEmpty())
|
if (files.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lyxerr[Debug::GUI] << "QWorkArea::dropEvent: got URIs!" << endl;
|
lyxerr[Debug::GUI] << "GuiWorkArea::dropEvent: got URIs!" << endl;
|
||||||
for (int i = 0; i!=files.size(); ++i) {
|
for (int i = 0; i!=files.size(); ++i) {
|
||||||
string const file = os::internal_path(fromqstr(files.at(i).toString()));
|
string const file = os::internal_path(fromqstr(files.at(i).toString()));
|
||||||
if (!file.empty())
|
if (!file.empty())
|
||||||
@ -301,7 +234,7 @@ void QWorkArea::dropEvent(QDropEvent* event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::mousePressEvent(QMouseEvent * e)
|
void GuiWorkArea::mousePressEvent(QMouseEvent * e)
|
||||||
{
|
{
|
||||||
if (dc_event_.active && dc_event_ == *e) {
|
if (dc_event_.active && dc_event_ == *e) {
|
||||||
dc_event_.active = false;
|
dc_event_.active = false;
|
||||||
@ -318,7 +251,7 @@ void QWorkArea::mousePressEvent(QMouseEvent * e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::mouseReleaseEvent(QMouseEvent * e)
|
void GuiWorkArea::mouseReleaseEvent(QMouseEvent * e)
|
||||||
{
|
{
|
||||||
if (synthetic_mouse_event_.timeout.running())
|
if (synthetic_mouse_event_.timeout.running())
|
||||||
synthetic_mouse_event_.timeout.stop();
|
synthetic_mouse_event_.timeout.stop();
|
||||||
@ -329,7 +262,7 @@ void QWorkArea::mouseReleaseEvent(QMouseEvent * e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::mouseMoveEvent(QMouseEvent * e)
|
void GuiWorkArea::mouseMoveEvent(QMouseEvent * e)
|
||||||
{
|
{
|
||||||
FuncRequest cmd(LFUN_MOUSE_MOTION, e->x(), e->y(),
|
FuncRequest cmd(LFUN_MOUSE_MOTION, e->x(), e->y(),
|
||||||
q_motion_state(e->state()));
|
q_motion_state(e->state()));
|
||||||
@ -390,18 +323,18 @@ void QWorkArea::mouseMoveEvent(QMouseEvent * e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::wheelEvent(QWheelEvent * e)
|
void GuiWorkArea::wheelEvent(QWheelEvent * e)
|
||||||
{
|
{
|
||||||
// Wheel rotation by one notch results in a delta() of 120 (see
|
// Wheel rotation by one notch results in a delta() of 120 (see
|
||||||
// documentation of QWheelEvent)
|
// documentation of QWheelEvent)
|
||||||
int const lines = QApplication::wheelScrollLines() * e->delta() / 120;
|
int const lines = qApp->wheelScrollLines() * e->delta() / 120;
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->value() -
|
verticalScrollBar()->setValue(verticalScrollBar()->value() -
|
||||||
lines * verticalScrollBar()->lineStep());
|
lines * verticalScrollBar()->lineStep());
|
||||||
adjustViewWithScrollBar();
|
adjustViewWithScrollBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::generateSyntheticMouseEvent()
|
void GuiWorkArea::generateSyntheticMouseEvent()
|
||||||
{
|
{
|
||||||
// Set things off to generate the _next_ 'pseudo' event.
|
// Set things off to generate the _next_ 'pseudo' event.
|
||||||
if (synthetic_mouse_event_.restart_timeout)
|
if (synthetic_mouse_event_.restart_timeout)
|
||||||
@ -419,7 +352,8 @@ void QWorkArea::generateSyntheticMouseEvent()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWorkArea::keyPressEvent(QKeyEvent * e)
|
|
||||||
|
void GuiWorkArea::keyPressEvent(QKeyEvent * e)
|
||||||
{
|
{
|
||||||
lyxerr[Debug::KEY] << BOOST_CURRENT_FUNCTION
|
lyxerr[Debug::KEY] << BOOST_CURRENT_FUNCTION
|
||||||
<< " count=" << e->count()
|
<< " count=" << e->count()
|
||||||
@ -428,16 +362,18 @@ void QWorkArea::keyPressEvent(QKeyEvent * e)
|
|||||||
<< " key=" << e->key()
|
<< " key=" << e->key()
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
// keyeventQueue_.push(boost::shared_ptr<QKeyEvent>(new QKeyEvent(*e)));
|
if (USE_KEY_BUFFERING) {
|
||||||
|
keyeventQueue_.push(boost::shared_ptr<QKeyEvent>(new QKeyEvent(*e)));
|
||||||
boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
|
}
|
||||||
sym->set(e);
|
else {
|
||||||
view_.view()->workAreaKeyPress(sym, q_key_state(e->state()));
|
boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
|
||||||
|
sym->set(e);
|
||||||
|
view_.view()->workAreaKeyPress(sym, q_key_state(e->state()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is not used for now...
|
// This is used only if USE_KEY_BUFFERING is defined...
|
||||||
void QWorkArea::keyeventTimeout()
|
void GuiWorkArea::keyeventTimeout()
|
||||||
{
|
{
|
||||||
bool handle_autos = true;
|
bool handle_autos = true;
|
||||||
|
|
||||||
@ -472,7 +408,7 @@ void QWorkArea::keyeventTimeout()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
|
void GuiWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
|
||||||
{
|
{
|
||||||
dc_event_ = double_click(e);
|
dc_event_ = double_click(e);
|
||||||
|
|
||||||
@ -488,7 +424,7 @@ void QWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::resizeEvent(QResizeEvent * resizeEvent)
|
void GuiWorkArea::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
workWidth_ = viewport()->width();
|
workWidth_ = viewport()->width();
|
||||||
workHeight_ = viewport()->height();
|
workHeight_ = viewport()->height();
|
||||||
@ -513,7 +449,8 @@ void QWorkArea::resizeEvent(QResizeEvent * resizeEvent)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWorkArea::update(int x, int y, int w, int h)
|
|
||||||
|
void GuiWorkArea::update(int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
//screen_device_.fromImage(paint_device_);
|
//screen_device_.fromImage(paint_device_);
|
||||||
//QPainter q(&screen_device_);
|
//QPainter q(&screen_device_);
|
||||||
@ -522,7 +459,8 @@ void QWorkArea::update(int x, int y, int w, int h)
|
|||||||
viewport()->update(x, y, w, h);
|
viewport()->update(x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWorkArea::paintEvent(QPaintEvent * e)
|
|
||||||
|
void GuiWorkArea::paintEvent(QPaintEvent * e)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
|
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
|
||||||
@ -549,29 +487,21 @@ void QWorkArea::paintEvent(QPaintEvent * e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPixmap QWorkArea::copyScreen(int x, int y, int w, int h) const
|
QPixmap GuiWorkArea::copyScreen(int x, int y, int w, int h) const
|
||||||
{
|
{
|
||||||
return paint_device_.copy(x, y, w, h);
|
return paint_device_.copy(x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWorkArea::drawScreen(int x, int y, QPixmap pixmap)
|
|
||||||
|
void GuiWorkArea::drawScreen(int x, int y, QPixmap pixmap)
|
||||||
{
|
{
|
||||||
QPainter q(&paint_device_);
|
QPainter q(&paint_device_);
|
||||||
q.drawPixmap(x, y, pixmap);
|
q.drawPixmap(x, y, pixmap);
|
||||||
viewport()->update(x, y, pixmap.width(), pixmap.height());
|
viewport()->update(x, y, pixmap.width(), pixmap.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
// LyXSreen overloaded methods:
|
|
||||||
|
|
||||||
WorkArea & QWorkArea::workarea()
|
void GuiWorkArea::expose(int x, int y, int w, int h)
|
||||||
{
|
|
||||||
// return static_cast<QWorkArea &> (*this);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::expose(int x, int y, int w, int h)
|
|
||||||
{
|
{
|
||||||
// lyxerr[Debug::GUI] << "expose " << w << 'x' << h
|
// lyxerr[Debug::GUI] << "expose " << w << 'x' << h
|
||||||
// << '+' << x << '+' << y << std::endl;
|
// << '+' << x << '+' << y << std::endl;
|
||||||
@ -580,7 +510,7 @@ void QWorkArea::expose(int x, int y, int w, int h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::showCursor(int x, int y, int h, Cursor_Shape shape)
|
void GuiWorkArea::showCursor(int x, int y, int h, Cursor_Shape shape)
|
||||||
{
|
{
|
||||||
if (!qApp->focusWidget())
|
if (!qApp->focusWidget())
|
||||||
return;
|
return;
|
||||||
@ -640,7 +570,7 @@ void QWorkArea::showCursor(int x, int y, int h, Cursor_Shape shape)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QWorkArea::removeCursor()
|
void GuiWorkArea::removeCursor()
|
||||||
{
|
{
|
||||||
show_vcursor_ = false;
|
show_vcursor_ = false;
|
||||||
show_hcursor_ = false;
|
show_hcursor_ = false;
|
||||||
@ -658,7 +588,7 @@ void QWorkArea::removeCursor()
|
|||||||
#if USE_INPUT_METHODS
|
#if USE_INPUT_METHODS
|
||||||
// to make qt-immodule work
|
// to make qt-immodule work
|
||||||
|
|
||||||
void QWorkArea::inputMethodEvent(QInputMethodEvent * e)
|
void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
|
||||||
{
|
{
|
||||||
QString const text = e->text();
|
QString const text = e->text();
|
||||||
if (!text.isEmpty()) {
|
if (!text.isEmpty()) {
|
||||||
@ -674,97 +604,7 @@ void QWorkArea::inputMethodEvent(QInputMethodEvent * e)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
#include "GuiWorkArea_moc.cpp"
|
||||||
// X11 specific stuff goes here...
|
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
|
||||||
bool lyxX11EventFilter(XEvent * xev)
|
|
||||||
{
|
|
||||||
switch (xev->type) {
|
|
||||||
case SelectionRequest:
|
|
||||||
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
|
||||||
if (wa_ptr)
|
|
||||||
wa_ptr->view().view()->selectionRequested();
|
|
||||||
break;
|
|
||||||
case SelectionClear:
|
|
||||||
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
|
||||||
if (wa_ptr)
|
|
||||||
wa_ptr->view().view()->selectionLost();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// Mac OSX specific stuff goes here...
|
|
||||||
|
|
||||||
#ifdef Q_WS_MACX
|
|
||||||
namespace{
|
|
||||||
OSErr checkAppleEventForMissingParams(const AppleEvent& theAppleEvent)
|
|
||||||
{
|
|
||||||
DescType returnedType;
|
|
||||||
Size actualSize;
|
|
||||||
OSErr err = AEGetAttributePtr(&theAppleEvent, keyMissedKeywordAttr,
|
|
||||||
typeWildCard, &returnedType, nil, 0,
|
|
||||||
&actualSize);
|
|
||||||
switch (err) {
|
|
||||||
case errAEDescNotFound:
|
|
||||||
return noErr;
|
|
||||||
case noErr:
|
|
||||||
return errAEEventNotHandled;
|
|
||||||
default:
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pascal OSErr handleOpenDocuments(const AppleEvent* inEvent,
|
|
||||||
AppleEvent* /*reply*/, long /*refCon*/)
|
|
||||||
{
|
|
||||||
QString s_arg;
|
|
||||||
AEDescList documentList;
|
|
||||||
OSErr err = AEGetParamDesc(inEvent, keyDirectObject, typeAEList,
|
|
||||||
&documentList);
|
|
||||||
if (err != noErr)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
err = checkAppleEventForMissingParams(*inEvent);
|
|
||||||
if (err == noErr) {
|
|
||||||
long documentCount;
|
|
||||||
err = AECountItems(&documentList, &documentCount);
|
|
||||||
for (long documentIndex = 1;
|
|
||||||
err == noErr && documentIndex <= documentCount;
|
|
||||||
documentIndex++) {
|
|
||||||
DescType returnedType;
|
|
||||||
Size actualSize;
|
|
||||||
AEKeyword keyword;
|
|
||||||
FSRef ref;
|
|
||||||
char qstr_buf[1024];
|
|
||||||
err = AESizeOfNthItem(&documentList, documentIndex,
|
|
||||||
&returnedType, &actualSize);
|
|
||||||
if (err == noErr) {
|
|
||||||
err = AEGetNthPtr(&documentList, documentIndex,
|
|
||||||
typeFSRef, &keyword,
|
|
||||||
&returnedType, (Ptr)&ref,
|
|
||||||
sizeof(FSRef), &actualSize);
|
|
||||||
if (err == noErr) {
|
|
||||||
FSRefMakePath(&ref, (UInt8*)qstr_buf,
|
|
||||||
1024);
|
|
||||||
s_arg=QString::fromUtf8(qstr_buf);
|
|
||||||
wa_ptr->view().view()->workAreaDispatch(
|
|
||||||
FuncRequest(LFUN_FILE_OPEN,
|
|
||||||
fromqstr(s_arg)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // for ...
|
|
||||||
}
|
|
||||||
AEDisposeDesc(&documentList);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
#endif // Q_WS_MACX
|
|
||||||
|
|
||||||
#include "QWorkArea_moc.cpp"
|
|
@ -1,6 +1,6 @@
|
|||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
/**
|
/**
|
||||||
* \file QWorkArea.h
|
* \file GuiWorkArea.h
|
||||||
* This file is part of LyX, the document processor.
|
* This file is part of LyX, the document processor.
|
||||||
* Licence details can be found in the file COPYING.
|
* Licence details can be found in the file COPYING.
|
||||||
*
|
*
|
||||||
@ -11,8 +11,8 @@
|
|||||||
* Full author contact details are available in file CREDITS.
|
* Full author contact details are available in file CREDITS.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef QWORKAREA_H
|
#ifndef WORKAREA_H
|
||||||
#define QWORKAREA_H
|
#define WORKAREA_H
|
||||||
|
|
||||||
#if (defined(Q_WS_X11) && QT_VERSION >= 0x030200)
|
#if (defined(Q_WS_X11) && QT_VERSION >= 0x030200)
|
||||||
#define USE_INPUT_METHODS 1
|
#define USE_INPUT_METHODS 1
|
||||||
@ -22,10 +22,10 @@
|
|||||||
#undef emit
|
#undef emit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "WorkArea.h"
|
#include "frontends/LyXView.h"
|
||||||
|
#include "frontends/WorkArea.h"
|
||||||
|
|
||||||
#include "QLPainter.h"
|
#include "QLPainter.h"
|
||||||
#include "LyXView.h"
|
|
||||||
#include "screen.h"
|
|
||||||
|
|
||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
#include "frontends/Timeout.h"
|
#include "frontends/Timeout.h"
|
||||||
@ -49,6 +49,9 @@ class QDragEnterEvent;
|
|||||||
class QDropEvent;
|
class QDropEvent;
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
/// for emulating triple click
|
/// for emulating triple click
|
||||||
class double_click {
|
class double_click {
|
||||||
public:
|
public:
|
||||||
@ -70,7 +73,6 @@ public:
|
|||||||
state(e->button()), active(true) {}
|
state(e->button()), active(true) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Qt only emits mouse events when the mouse is being moved, but
|
/** Qt only emits mouse events when the mouse is being moved, but
|
||||||
* we want to generate 'pseudo' mouse events when the mouse button is
|
* we want to generate 'pseudo' mouse events when the mouse button is
|
||||||
* pressed and the mouse cursor is below the bottom, or above the top
|
* pressed and the mouse cursor is below the bottom, or above the top
|
||||||
@ -96,32 +98,23 @@ public:
|
|||||||
* Qt-specific implementation of the work area
|
* Qt-specific implementation of the work area
|
||||||
* (buffer view GUI)
|
* (buffer view GUI)
|
||||||
*/
|
*/
|
||||||
class QWorkArea : public QAbstractScrollArea, public WorkArea, public LyXScreen {
|
class GuiWorkArea: public QAbstractScrollArea, public WorkArea {
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QWorkArea(LyXView & owner, int w, int h);
|
GuiWorkArea(LyXView & owner, int w, int h);
|
||||||
|
|
||||||
virtual ~QWorkArea();
|
virtual ~GuiWorkArea();
|
||||||
/// return the width of the content pane
|
/// return the width of the content pane
|
||||||
virtual int workWidth() const { return workWidth_; }
|
virtual int width() const { return workWidth_; }
|
||||||
|
|
||||||
/// return the height of the content pane
|
/// return the height of the content pane
|
||||||
virtual int workHeight() const { return workHeight_; }
|
virtual int height() const { return workHeight_; }
|
||||||
///
|
///
|
||||||
virtual void setScrollbarParams(int height, int pos, int line_height);
|
virtual void setScrollbarParams(int height, int pos, int line_height);
|
||||||
|
|
||||||
/// a selection exists
|
|
||||||
virtual void haveSelection(bool) const;
|
|
||||||
|
|
||||||
///
|
|
||||||
virtual std::string const getClipboard() const;
|
|
||||||
|
|
||||||
///
|
|
||||||
virtual void putClipboard(std::string const &) const;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
virtual void dragEnterEvent(QDragEnterEvent * event);
|
virtual void dragEnterEvent(QDragEnterEvent * event);
|
||||||
|
|
||||||
@ -148,11 +141,6 @@ public:
|
|||||||
|
|
||||||
LyXView & view() { return view_; }
|
LyXView & view() { return view_; }
|
||||||
|
|
||||||
// LyXScreen overloaded methods:
|
|
||||||
|
|
||||||
/// get the work area
|
|
||||||
virtual WorkArea & workarea();
|
|
||||||
|
|
||||||
/// copies specified area of pixmap to screen
|
/// copies specified area of pixmap to screen
|
||||||
virtual void expose(int x, int y, int exp_width, int exp_height);
|
virtual void expose(int x, int y, int exp_width, int exp_height);
|
||||||
|
|
||||||
@ -184,7 +172,7 @@ protected:
|
|||||||
#if USE_INPUT_METHODS
|
#if USE_INPUT_METHODS
|
||||||
protected:
|
protected:
|
||||||
/// IM events
|
/// IM events
|
||||||
void QWorkArea::inputMethodEvent(QInputMethodEvent * e)
|
void inputMethodEvent(QInputMethodEvent * e);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -259,4 +247,7 @@ private:
|
|||||||
Cursor_Shape cursor_shape_;
|
Cursor_Shape cursor_shape_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QWORKAREA_H
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // WORKAREA_H
|
@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file qt4/LyXScreenFactory.C
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author John Levon
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "frontends/LyXScreenFactory.h"
|
|
||||||
|
|
||||||
#include "QWorkArea.h"
|
|
||||||
|
|
||||||
namespace LyXScreenFactory {
|
|
||||||
|
|
||||||
LyXScreen * create(WorkArea & owner)
|
|
||||||
{
|
|
||||||
return &(static_cast<QWorkArea &>(owner));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace LyXScreenFactory
|
|
@ -30,17 +30,16 @@ AM_CPPFLAGS += \
|
|||||||
-I$(top_srcdir)/src/frontends/controllers
|
-I$(top_srcdir)/src/frontends/controllers
|
||||||
|
|
||||||
libqt4_la_SOURCES = \
|
libqt4_la_SOURCES = \
|
||||||
QDialogView.C \
|
|
||||||
QDialogView.h \
|
|
||||||
Action.C Action.h \
|
|
||||||
Alert_pimpl.C \
|
Alert_pimpl.C \
|
||||||
|
Application.C Application.h \
|
||||||
ColorCache.h ColorCache.C \
|
ColorCache.h ColorCache.C \
|
||||||
Dialogs.C \
|
Dialogs.C \
|
||||||
FileDialog.C \
|
FileDialog.C \
|
||||||
|
FontLoader.h FontLoader.C \
|
||||||
|
GuiClipboard.h GuiClipboard.C \
|
||||||
|
GuiImplementation.h GuiImplementation.C \
|
||||||
LyXKeySymFactory.C \
|
LyXKeySymFactory.C \
|
||||||
LyXScreenFactory.C \
|
|
||||||
QLMenubar.C QLMenubar.h \
|
QLMenubar.C QLMenubar.h \
|
||||||
qtTimeout.C qtTimeout.h \
|
|
||||||
QAbout.C QAbout.h \
|
QAbout.C QAbout.h \
|
||||||
QBibitem.C QBibitem.h \
|
QBibitem.C QBibitem.h \
|
||||||
QBibtex.C QBibtex.h \
|
QBibtex.C QBibtex.h \
|
||||||
@ -51,6 +50,7 @@ libqt4_la_SOURCES = \
|
|||||||
QCharacter.C QCharacter.h \
|
QCharacter.C QCharacter.h \
|
||||||
QCitation.C QCitation.h \
|
QCitation.C QCitation.h \
|
||||||
QDocument.C QDocument.h \
|
QDocument.C QDocument.h \
|
||||||
|
QDialogView.C QDialogView.h \
|
||||||
QErrorList.C QErrorList.h \
|
QErrorList.C QErrorList.h \
|
||||||
QERT.C QERT.h \
|
QERT.C QERT.h \
|
||||||
QExternal.C QExternal.h \
|
QExternal.C QExternal.h \
|
||||||
@ -80,16 +80,14 @@ libqt4_la_SOURCES = \
|
|||||||
QToc.C QToc.h \
|
QToc.C QToc.h \
|
||||||
QURL.C QURL.h \
|
QURL.C QURL.h \
|
||||||
QVSpace.C QVSpace.h \
|
QVSpace.C QVSpace.h \
|
||||||
QWorkArea.C QWorkArea.h \
|
|
||||||
QWrap.C QWrap.h \
|
QWrap.C QWrap.h \
|
||||||
Qt2BC.C Qt2BC.h \
|
Qt2BC.C Qt2BC.h \
|
||||||
WorkAreaFactory.C \
|
|
||||||
checkedwidgets.C checkedwidgets.h \
|
checkedwidgets.C checkedwidgets.h \
|
||||||
lyx_gui.C \
|
lyx_gui.C \
|
||||||
panelstack.h panelstack.C \
|
panelstack.h panelstack.C \
|
||||||
qfontexample.h qfontexample.C \
|
qfontexample.h qfontexample.C \
|
||||||
FontLoader.h FontLoader.C \
|
|
||||||
qfont_metrics.C \
|
qfont_metrics.C \
|
||||||
qlkey.h \
|
qlkey.h \
|
||||||
qt_helpers.h qt_helpers.C \
|
qt_helpers.h qt_helpers.C \
|
||||||
|
qtTimeout.C qtTimeout.h \
|
||||||
$(MOCFILES)
|
$(MOCFILES)
|
||||||
|
@ -78,6 +78,7 @@ MOCFILES = \
|
|||||||
emptytable.C emptytable.h \
|
emptytable.C emptytable.h \
|
||||||
FileDialog_private.C FileDialog_private.h \
|
FileDialog_private.C FileDialog_private.h \
|
||||||
floatplacement.C floatplacement.h \
|
floatplacement.C floatplacement.h \
|
||||||
|
GuiWorkArea.C GuiWorkArea.h \
|
||||||
iconpalette.C iconpalette.h \
|
iconpalette.C iconpalette.h \
|
||||||
InsertTableWidget.C InsertTableWidget.h \
|
InsertTableWidget.C InsertTableWidget.h \
|
||||||
lengthcombo.C lengthcombo.h \
|
lengthcombo.C lengthcombo.h \
|
||||||
@ -129,7 +130,6 @@ MOCFILES = \
|
|||||||
QtView.C QtView.h \
|
QtView.C QtView.h \
|
||||||
QURLDialog.C QURLDialog.h \
|
QURLDialog.C QURLDialog.h \
|
||||||
QVSpaceDialog.C QVSpaceDialog.h \
|
QVSpaceDialog.C QVSpaceDialog.h \
|
||||||
QWorkArea.C QWorkArea.h \
|
|
||||||
QWrapDialog.C QWrapDialog.h \
|
QWrapDialog.C QWrapDialog.h \
|
||||||
QLToolbar.C QLToolbar.h \
|
QLToolbar.C QLToolbar.h \
|
||||||
socket_callback.C socket_callback.h \
|
socket_callback.C socket_callback.h \
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "QLPainter.h"
|
#include "QLPainter.h"
|
||||||
|
|
||||||
#include "QWorkArea.h"
|
#include "GuiWorkArea.h"
|
||||||
#include "QLImage.h"
|
#include "QLImage.h"
|
||||||
|
|
||||||
#include "ColorCache.h"
|
#include "ColorCache.h"
|
||||||
@ -33,12 +33,14 @@
|
|||||||
using std::endl;
|
using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
QLPainter::~QLPainter()
|
QLPainter::~QLPainter()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QLPainter::QLPainter(QWorkArea * qwa)
|
QLPainter::QLPainter(GuiWorkArea * qwa)
|
||||||
: Painter(), qwa_(qwa)
|
: Painter(), qwa_(qwa)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -234,7 +236,7 @@ void QLPainter::text(int x, int y, char const * s, size_t ls,
|
|||||||
|
|
||||||
QString str;
|
QString str;
|
||||||
str.setLength(ls);
|
str.setLength(ls);
|
||||||
for (int i = 0; i < ls; ++i)
|
for (size_t i = 0; i < ls; ++i)
|
||||||
str[i] = QChar(encoding->ucs(s[i]));
|
str[i] = QChar(encoding->ucs(s[i]));
|
||||||
|
|
||||||
// HACK: QT3 refuses to show single compose characters
|
// HACK: QT3 refuses to show single compose characters
|
||||||
@ -248,7 +250,7 @@ void QLPainter::text(int x, int y, char const * s, size_t ls,
|
|||||||
qp.setFont(fontloader.get(f));
|
qp.setFont(fontloader.get(f));
|
||||||
// We need to draw the text as LTR as we use our own bidi code.
|
// We need to draw the text as LTR as we use our own bidi code.
|
||||||
qp.setLayoutDirection(Qt::LeftToRight);
|
qp.setLayoutDirection(Qt::LeftToRight);
|
||||||
qp.drawText(x, y, str, -1);
|
qp.drawText(x, y, str);
|
||||||
} else {
|
} else {
|
||||||
smallCapsText(x, y, str, f);
|
smallCapsText(x, y, str, f);
|
||||||
}
|
}
|
||||||
@ -270,3 +272,7 @@ void QLPainter::drawImage(int x, int y, QImage const & image)
|
|||||||
QPainter qp(qwa_->paintDevice());
|
QPainter qp(qwa_->paintDevice());
|
||||||
qp.drawImage(x, y, image);
|
qp.drawImage(x, y, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
@ -23,14 +23,18 @@ class QPainter;
|
|||||||
class QString;
|
class QString;
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
class QImage;
|
class QImage;
|
||||||
class QWorkArea;
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
class GuiWorkArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QLPainter - a painter implementation for Qt4
|
* QLPainter - a painter implementation for Qt4
|
||||||
*/
|
*/
|
||||||
class QLPainter : public Painter {
|
class QLPainter : public Painter {
|
||||||
public:
|
public:
|
||||||
QLPainter(QWorkArea *);
|
QLPainter(GuiWorkArea *);
|
||||||
|
|
||||||
~QLPainter();
|
~QLPainter();
|
||||||
|
|
||||||
@ -146,11 +150,14 @@ private:
|
|||||||
boost::scoped_ptr<QPainter> qp_;
|
boost::scoped_ptr<QPainter> qp_;
|
||||||
|
|
||||||
/// the working area
|
/// the working area
|
||||||
QWorkArea * qwa_;
|
GuiWorkArea * qwa_;
|
||||||
|
|
||||||
LColor::color current_color_;
|
LColor::color current_color_;
|
||||||
Painter::line_style current_ls_;
|
Painter::line_style current_ls_;
|
||||||
Painter::line_width current_lw_;
|
Painter::line_width current_lw_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
#endif // QLPAINTER_H
|
#endif // QLPAINTER_H
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* This file is part of LyX, the document processor.
|
* This file is part of LyX, the document processor.
|
||||||
* Licence details can be found in the file COPYING.
|
* Licence details can be found in the file COPYING.
|
||||||
*
|
*
|
||||||
* \author Lars Gullik Bjønnes
|
* \author Lars Gullik Bjønnes
|
||||||
* \author John Levon
|
* \author John Levon
|
||||||
* \author Abdelrazak Younes
|
* \author Abdelrazak Younes
|
||||||
*
|
*
|
||||||
@ -71,7 +71,7 @@ int const statusbar_timer_value = 3000;
|
|||||||
|
|
||||||
|
|
||||||
QtView::QtView(unsigned int width, unsigned int height)
|
QtView::QtView(unsigned int width, unsigned int height)
|
||||||
: QMainWindow(), LyXView(), commandbuffer_(0)
|
: QMainWindow(), LyXView(), commandbuffer_(0), frontend_(*this)
|
||||||
{
|
{
|
||||||
mainWidget_ = this;
|
mainWidget_ = this;
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
// Must be here because of moc.
|
// Must be here because of moc.
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "GuiImplementation.h"
|
||||||
|
|
||||||
#include "frontends/LyXView.h"
|
#include "frontends/LyXView.h"
|
||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
|
|
||||||
@ -72,6 +74,9 @@ public:
|
|||||||
// returns true if this view has the focus.
|
// returns true if this view has the focus.
|
||||||
virtual bool hasFocus() const;
|
virtual bool hasFocus() const;
|
||||||
|
|
||||||
|
//
|
||||||
|
Gui & gui() { return frontend_; }
|
||||||
|
|
||||||
static QMainWindow* mainWidget();
|
static QMainWindow* mainWidget();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -105,6 +110,8 @@ private:
|
|||||||
|
|
||||||
///
|
///
|
||||||
static QMainWindow* mainWidget_;
|
static QMainWindow* mainWidget_;
|
||||||
|
|
||||||
|
GuiImplementation frontend_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file qt4/WorkAreaFactory.C
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author John Levon
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "frontends/WorkAreaFactory.h"
|
|
||||||
#include "QWorkArea.h"
|
|
||||||
|
|
||||||
namespace WorkAreaFactory {
|
|
||||||
|
|
||||||
WorkArea * create(LyXView & owner, int w, int h)
|
|
||||||
{
|
|
||||||
return new QWorkArea(owner, w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace WorkAreaFactory
|
|
@ -5,6 +5,7 @@
|
|||||||
*
|
*
|
||||||
* \author unknown
|
* \author unknown
|
||||||
* \author John Levon
|
* \author John Levon
|
||||||
|
* \author Abdelrazak Younes
|
||||||
*
|
*
|
||||||
* Full author contact details are available in file CREDITS.
|
* Full author contact details are available in file CREDITS.
|
||||||
*/
|
*/
|
||||||
@ -35,10 +36,6 @@
|
|||||||
#include "support/package.h"
|
#include "support/package.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
// Dear Lord, deliver us from Evil, aka the Qt headers
|
|
||||||
// Qt defines a macro 'signals' that clashes with a boost namespace.
|
|
||||||
// All is well if the namespace is visible first.
|
|
||||||
#include <boost/signal.hpp> // FIXME: Is this needed? (Lgb)
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
@ -48,10 +45,7 @@
|
|||||||
#include "QLImage.h"
|
#include "QLImage.h"
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
#include "socket_callback.h"
|
#include "socket_callback.h"
|
||||||
|
#include "Application.h"
|
||||||
#ifdef Q_WS_MACX
|
|
||||||
#include <Carbon/Carbon.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
@ -60,10 +54,13 @@
|
|||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using lyx::support::ltrim;
|
using lyx::support::ltrim;
|
||||||
using lyx::support::package;
|
using lyx::support::package;
|
||||||
|
|
||||||
using lyx::frontend::QtView;
|
using lyx::frontend::QtView;
|
||||||
|
using lyx::frontend::Application;
|
||||||
|
|
||||||
namespace os = lyx::support::os;
|
namespace os = lyx::support::os;
|
||||||
|
|
||||||
@ -77,9 +74,6 @@ using std::map;
|
|||||||
using std::vector;
|
using std::vector;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
|
||||||
extern BufferList bufferlist;
|
|
||||||
|
|
||||||
// FIXME: wrong place !
|
// FIXME: wrong place !
|
||||||
LyXServer * lyxserver;
|
LyXServer * lyxserver;
|
||||||
LyXServerSocket * lyxsocket;
|
LyXServerSocket * lyxsocket;
|
||||||
@ -107,78 +101,45 @@ void cleanup()
|
|||||||
// in QLyXKeySym.C
|
// in QLyXKeySym.C
|
||||||
extern void initEncodings();
|
extern void initEncodings();
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
|
||||||
extern bool lyxX11EventFilter(XEvent * xev);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_WS_MACX
|
|
||||||
extern bool macEventFilter(EventRef event);
|
|
||||||
extern pascal OSErr
|
|
||||||
handleOpenDocuments(const AppleEvent* inEvent, AppleEvent* /*reply*/,
|
|
||||||
long /*refCon*/);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class LQApplication : public QApplication
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LQApplication(int & argc, char ** argv);
|
|
||||||
#ifdef Q_WS_X11
|
|
||||||
bool x11EventFilter (XEvent * ev) { return lyxX11EventFilter(ev); }
|
|
||||||
#endif
|
|
||||||
#ifdef Q_WS_MACX
|
|
||||||
bool macEventFilter(EventRef event);
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
LQApplication::LQApplication(int & argc, char ** argv)
|
|
||||||
: QApplication(argc, argv)
|
|
||||||
{
|
|
||||||
#ifdef Q_WS_MACX
|
|
||||||
AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
|
|
||||||
NewAEEventHandlerUPP(handleOpenDocuments),
|
|
||||||
0, false);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_WS_MACX
|
|
||||||
bool LQApplication::macEventFilter(EventRef event)
|
|
||||||
{
|
|
||||||
if (GetEventClass(event) == kEventClassAppleEvent) {
|
|
||||||
EventRecord eventrec;
|
|
||||||
ConvertEventRefToEventRecord(event, &eventrec);
|
|
||||||
AEProcessAppleEvent(&eventrec);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace lyx_gui {
|
namespace lyx_gui {
|
||||||
|
|
||||||
bool use_gui = true;
|
bool use_gui = true;
|
||||||
|
|
||||||
|
|
||||||
void exec(int & argc, char * argv[])
|
void exec(int & argc, char * argv[])
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
FIXME : Abdel 29/05/2006 (younes.a@free.fr)
|
||||||
|
reorganize this code. In particular make sure that this
|
||||||
|
advice from Qt documentation is respected:
|
||||||
|
|
||||||
|
Since the QApplication object does so much initialization, it
|
||||||
|
must be created before any other objects related to the user
|
||||||
|
interface are created.
|
||||||
|
|
||||||
|
Right now this is not the case, I suspect that a number of global variables
|
||||||
|
contains Qt object that are initialized before the passage through
|
||||||
|
parse_init(). This might also explain the message displayed by Qt
|
||||||
|
that caused the hanging:
|
||||||
|
|
||||||
|
QObject::killTimer: timers cannot be stopped from another thread
|
||||||
|
*/
|
||||||
|
|
||||||
// Force adding of font path _before_ QApplication is initialized
|
// Force adding of font path _before_ QApplication is initialized
|
||||||
FontLoader::initFontPath();
|
FontLoader::initFontPath();
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
static LQApplication app(argc, argv);
|
static Application app(argc, argv);
|
||||||
#else
|
#else
|
||||||
LQApplication app(argc, argv);
|
Application app(argc, argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// install translation file for Qt built-in dialogs
|
// install translation file for Qt built-in dialogs
|
||||||
// These are only installed since Qt 3.2.x
|
// These are only installed since Qt 3.2.x
|
||||||
QTranslator qt_trans;
|
QTranslator qt_trans;
|
||||||
QString language_name = QString("qt_") + QLocale::system().name();
|
QString language_name = QString("qt_") + QLocale::system().name();
|
||||||
language_name.truncate(5);
|
language_name.truncate(5);
|
||||||
if (qt_trans.load(language_name,
|
if (qt_trans.load(language_name,
|
||||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||||
{
|
{
|
||||||
qApp->installTranslator(&qt_trans);
|
qApp->installTranslator(&qt_trans);
|
||||||
|
@ -1,96 +0,0 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
/**
|
|
||||||
* \file screen.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 SCREEN_H
|
|
||||||
#define SCREEN_H
|
|
||||||
|
|
||||||
|
|
||||||
class LyXText;
|
|
||||||
class CursorSlice;
|
|
||||||
class WorkArea;
|
|
||||||
class BufferView;
|
|
||||||
class ViewMetricsInfo;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LyXScreen - document rendering management
|
|
||||||
*
|
|
||||||
* This class is used to manage the on-screen rendering inside the
|
|
||||||
* work area; it is responsible for deciding which LyXText rows
|
|
||||||
* need re-drawing.
|
|
||||||
*
|
|
||||||
* This class will arrange for LyXText to paint onto a pixmap
|
|
||||||
* provided by the WorkArea widget.
|
|
||||||
*
|
|
||||||
* The blinking cursor is also handled here.
|
|
||||||
*/
|
|
||||||
class LyXScreen {
|
|
||||||
public:
|
|
||||||
LyXScreen();
|
|
||||||
|
|
||||||
virtual ~LyXScreen();
|
|
||||||
|
|
||||||
/// redraw the screen, without using existing pixmap
|
|
||||||
virtual void redraw(BufferView & bv, ViewMetricsInfo const & vi);
|
|
||||||
|
|
||||||
/// grey out (no buffer)
|
|
||||||
void greyOut();
|
|
||||||
|
|
||||||
/// hide the visible cursor, if it is visible
|
|
||||||
void hideCursor();
|
|
||||||
|
|
||||||
/// show the cursor if it is not visible
|
|
||||||
void showCursor(BufferView & bv);
|
|
||||||
|
|
||||||
/// toggle the cursor's visibility
|
|
||||||
void toggleCursor(BufferView & bv);
|
|
||||||
|
|
||||||
/// set cursor_visible_ to false in prep for re-display
|
|
||||||
void prepareCursor();
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/// cause the display of the given area of the work area
|
|
||||||
virtual void expose(int x, int y, int w, int h) = 0;
|
|
||||||
|
|
||||||
/// get the work area
|
|
||||||
virtual WorkArea & workarea() = 0;
|
|
||||||
|
|
||||||
/// types of cursor in work area
|
|
||||||
enum Cursor_Shape {
|
|
||||||
/// normal I-beam
|
|
||||||
BAR_SHAPE,
|
|
||||||
/// L-shape for locked insets of a different language
|
|
||||||
L_SHAPE,
|
|
||||||
/// reverse L-shape for RTL text
|
|
||||||
REVERSED_L_SHAPE
|
|
||||||
};
|
|
||||||
|
|
||||||
/// paint the cursor and store the background
|
|
||||||
virtual void showCursor(int x, int y, int h, Cursor_Shape shape) = 0;
|
|
||||||
|
|
||||||
/// hide the cursor
|
|
||||||
virtual void removeCursor() = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
///
|
|
||||||
void checkAndGreyOut();
|
|
||||||
|
|
||||||
///
|
|
||||||
bool greyed_out_;
|
|
||||||
|
|
||||||
/// is the cursor currently displayed
|
|
||||||
bool cursor_visible_;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SCREEN_H
|
|
63
src/frontends/xforms/GuiClipboard.h
Normal file
63
src/frontends/xforms/GuiClipboard.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file xforms/GuiClipboard.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CLIPBOARD_H
|
||||||
|
#define CLIPBOARD_H
|
||||||
|
|
||||||
|
#include "frontends/Clipboard.h"
|
||||||
|
|
||||||
|
#include "XWorkArea.h"
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
typedef XWorkArea FWorkArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The XForms version of the Clipboard.
|
||||||
|
*/
|
||||||
|
class GuiClipboard: public lyx::frontend::Clipboard
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiClipboard(FWorkArea * work_area)
|
||||||
|
: old_work_area_(work_area)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~GuiClipboard() {}
|
||||||
|
|
||||||
|
/** ClipBoard overloaded methods
|
||||||
|
*/
|
||||||
|
//@{
|
||||||
|
void haveSelection(bool own)
|
||||||
|
{
|
||||||
|
old_work_area_->haveSelection(own);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string const get() const
|
||||||
|
{
|
||||||
|
return old_work_area_->getClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void put(std::string const & str)
|
||||||
|
{
|
||||||
|
old_work_area_->putClipboard(str);
|
||||||
|
}
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
FWorkArea * old_work_area_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // CLIPBOARD_H
|
91
src/frontends/xforms/GuiImplementation.h
Normal file
91
src/frontends/xforms/GuiImplementation.h
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file xforms/GuiImplementation.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GUI_IMPLEMENTATION_H
|
||||||
|
#define GUI_IMPLEMENTATION_H
|
||||||
|
|
||||||
|
#include "frontends/Gui.h"
|
||||||
|
#include "frontends/LyXView.h"
|
||||||
|
|
||||||
|
#include "xscreen.h"
|
||||||
|
#include "XWorkArea.h"
|
||||||
|
|
||||||
|
#include "GuiClipboard.h"
|
||||||
|
#include "GuiWorkArea.h"
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
typedef XScreen FScreen;
|
||||||
|
typedef XWorkArea FWorkArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Gui class is the interface to all XForms components.
|
||||||
|
*/
|
||||||
|
class GuiImplementation: public lyx::frontend::Gui
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiImplementation(LyXView & owner): owner_(owner)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~GuiImplementation()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
lyx::frontend::Clipboard& clipboard()
|
||||||
|
{
|
||||||
|
return *clipboard_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newWorkArea(int w, int h)
|
||||||
|
{
|
||||||
|
old_work_area_.reset(new FWorkArea(owner_, w, h));
|
||||||
|
old_screen_.reset(new FScreen(*old_work_area_.get()));
|
||||||
|
work_area_.reset(new GuiWorkArea(owner_, w, h, old_screen_.get(), old_work_area_.get()));
|
||||||
|
clipboard_.reset(new GuiClipboard(old_work_area_.get()));
|
||||||
|
guiCursor().connect(work_area_.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
lyx::frontend::WorkArea& workArea(int id)
|
||||||
|
{
|
||||||
|
return *work_area_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroyWorkArea(int id)
|
||||||
|
{
|
||||||
|
clipboard_.reset();
|
||||||
|
work_area_.reset();
|
||||||
|
old_work_area_.reset();
|
||||||
|
old_screen_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
///
|
||||||
|
boost::shared_ptr<GuiClipboard> clipboard_;
|
||||||
|
///
|
||||||
|
boost::shared_ptr<GuiWorkArea> work_area_;
|
||||||
|
///
|
||||||
|
boost::shared_ptr<FWorkArea> old_work_area_;
|
||||||
|
///
|
||||||
|
boost::shared_ptr<FScreen> old_screen_;
|
||||||
|
///
|
||||||
|
LyXView & owner_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // GUI_IMPLEMENTATION_H
|
98
src/frontends/xforms/GuiWorkArea.h
Normal file
98
src/frontends/xforms/GuiWorkArea.h
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file xforms/WorkArea.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WORKAREA_H
|
||||||
|
#define WORKAREA_H
|
||||||
|
|
||||||
|
#include "frontends/WorkArea.h"
|
||||||
|
|
||||||
|
#include "xscreen.h"
|
||||||
|
#include "XWorkArea.h"
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
typedef XScreen FScreen;
|
||||||
|
typedef XWorkArea FWorkArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary wrapper around XWorkArea and XScreen.
|
||||||
|
* Please refer to the Qt4 implementation for a proper cleanup of the API.
|
||||||
|
*/
|
||||||
|
class GuiWorkArea: public lyx::frontend::WorkArea {
|
||||||
|
public:
|
||||||
|
GuiWorkArea(LyXView & owner, int w, int h,
|
||||||
|
FScreen * screen, FWorkArea * work_area)
|
||||||
|
: lyx::frontend::WorkArea(owner, w, h),
|
||||||
|
old_screen_(screen), old_work_area_(work_area)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~GuiWorkArea() {}
|
||||||
|
|
||||||
|
/// return the painter object for this work area
|
||||||
|
virtual lyx::frontend::Painter & getPainter()
|
||||||
|
{
|
||||||
|
return old_work_area_->getPainter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// return the width of the work area in pixels
|
||||||
|
virtual int width() const
|
||||||
|
{
|
||||||
|
return old_work_area_->workWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// return the height of the work area in pixels
|
||||||
|
virtual int height() const
|
||||||
|
{
|
||||||
|
return old_work_area_->workHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the scrollbar.
|
||||||
|
* @param height the total document height in pixels
|
||||||
|
* @param pos the current position in the document, in pixels
|
||||||
|
* @param line_height the line-scroll amount, in pixels
|
||||||
|
*/
|
||||||
|
virtual void setScrollbarParams(int height, int pos, int line_height)
|
||||||
|
{
|
||||||
|
old_work_area_->setScrollbarParams(height, pos, line_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// paint the cursor and store the background
|
||||||
|
virtual void showCursor(int x, int y, int h, Cursor_Shape shape)
|
||||||
|
{
|
||||||
|
old_screen_->showCursor(x, y, h, shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// hide the cursor
|
||||||
|
virtual void removeCursor()
|
||||||
|
{
|
||||||
|
old_screen_->removeCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// cause the display of the given area of the work area
|
||||||
|
virtual void expose(int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
old_screen_->expose(x, y, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
FScreen * old_screen_;
|
||||||
|
FWorkArea * old_work_area_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // WORKAREA_H
|
@ -1,29 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file xforms/LyXScreenFactory.C
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author John Levon
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "frontends/LyXScreenFactory.h"
|
|
||||||
|
|
||||||
#include "xscreen.h"
|
|
||||||
#include "XWorkArea.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace LyXScreenFactory {
|
|
||||||
|
|
||||||
LyXScreen * create(WorkArea & owner)
|
|
||||||
{
|
|
||||||
using lyx::frontend::XScreen;
|
|
||||||
using lyx::frontend::XWorkArea;
|
|
||||||
|
|
||||||
return new XScreen(static_cast<XWorkArea &>(owner));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -156,10 +156,12 @@ libxforms_la_SOURCES = \
|
|||||||
FormVSpace.h \
|
FormVSpace.h \
|
||||||
FormWrap.C \
|
FormWrap.C \
|
||||||
FormWrap.h \
|
FormWrap.h \
|
||||||
|
GuiClipboard.h \
|
||||||
|
GuiImplementation.h \
|
||||||
|
GuiWorkArea.h \
|
||||||
LayoutEngine.C \
|
LayoutEngine.C \
|
||||||
LayoutEngine.h \
|
LayoutEngine.h \
|
||||||
LyXKeySymFactory.C \
|
LyXKeySymFactory.C \
|
||||||
LyXScreenFactory.C \
|
|
||||||
XFormsMenubar.C \
|
XFormsMenubar.C \
|
||||||
XFormsMenubar.h \
|
XFormsMenubar.h \
|
||||||
RadioButtonGroup.C \
|
RadioButtonGroup.C \
|
||||||
@ -168,7 +170,6 @@ libxforms_la_SOURCES = \
|
|||||||
XFormsToolbar.h \
|
XFormsToolbar.h \
|
||||||
Tooltips.C \
|
Tooltips.C \
|
||||||
Tooltips.h \
|
Tooltips.h \
|
||||||
WorkAreaFactory.C \
|
|
||||||
XFormsView.C \
|
XFormsView.C \
|
||||||
XFormsView.h \
|
XFormsView.h \
|
||||||
XLyXKeySym.C \
|
XLyXKeySym.C \
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file xforms/WorkAreaFactory.C
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author John Levon
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "frontends/WorkAreaFactory.h"
|
|
||||||
#include "XWorkArea.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace WorkAreaFactory {
|
|
||||||
|
|
||||||
WorkArea * create(LyXView & owner, int w, int h)
|
|
||||||
{
|
|
||||||
return new lyx::frontend::XWorkArea(owner, w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -74,7 +74,7 @@ void print_metrics(std::ostream & os, std::string const & name, Box const & box)
|
|||||||
XFormsView::XFormsView(int width, int height)
|
XFormsView::XFormsView(int width, int height)
|
||||||
: LyXView(),
|
: LyXView(),
|
||||||
window_(Box(width, height)),
|
window_(Box(width, height)),
|
||||||
icon_pixmap_(0), icon_mask_(0)
|
icon_pixmap_(0), icon_mask_(0), frontend_(*this)
|
||||||
{
|
{
|
||||||
int const air = 2;
|
int const air = 2;
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#ifndef LyXView_H
|
#ifndef LyXView_H
|
||||||
#define LyXView_H
|
#define LyXView_H
|
||||||
|
|
||||||
|
#include "GuiImplementation.h"
|
||||||
#include "LayoutEngine.h"
|
#include "LayoutEngine.h"
|
||||||
#include "forms_fwd.h"
|
#include "forms_fwd.h"
|
||||||
|
|
||||||
@ -82,6 +83,9 @@ public:
|
|||||||
// returns true if this view has the focus.
|
// returns true if this view has the focus.
|
||||||
virtual bool hasFocus() const;
|
virtual bool hasFocus() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
Gui & gui() { return frontend_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* setWindowTitle - set title of window
|
* setWindowTitle - set title of window
|
||||||
@ -116,6 +120,8 @@ private:
|
|||||||
Pixmap icon_pixmap_;
|
Pixmap icon_pixmap_;
|
||||||
///
|
///
|
||||||
Pixmap icon_mask_;
|
Pixmap icon_mask_;
|
||||||
|
///
|
||||||
|
GuiImplementation frontend_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -613,7 +613,7 @@ int XWorkArea::event_cb(XEvent * xev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XWorkArea::haveSelection(bool yes) const
|
void XWorkArea::haveSelection(bool yes)
|
||||||
{
|
{
|
||||||
Window const owner = yes ? FL_ObjWin(work_area) : None;
|
Window const owner = yes ? FL_ObjWin(work_area) : None;
|
||||||
XSetSelectionOwner(fl_get_display(), XA_PRIMARY, owner, CurrentTime);
|
XSetSelectionOwner(fl_get_display(), XA_PRIMARY, owner, CurrentTime);
|
||||||
@ -642,7 +642,7 @@ string const XWorkArea::getClipboard() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XWorkArea::putClipboard(string const & s) const
|
void XWorkArea::putClipboard(string const & s)
|
||||||
{
|
{
|
||||||
static string hold;
|
static string hold;
|
||||||
hold = s;
|
hold = s;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#define XWORKAREA_H
|
#define XWORKAREA_H
|
||||||
|
|
||||||
#include "frontends/WorkArea.h"
|
#include "frontends/WorkArea.h"
|
||||||
|
#include "frontends/Clipboard.h"
|
||||||
#include "XPainter.h"
|
#include "XPainter.h"
|
||||||
|
|
||||||
#include "LayoutEngine.h"
|
#include "LayoutEngine.h"
|
||||||
@ -25,7 +26,7 @@ class LyXView;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
class XWorkArea : public WorkArea {
|
class XWorkArea {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
XWorkArea(LyXView & owner, int width, int height);
|
XWorkArea(LyXView & owner, int width, int height);
|
||||||
@ -56,11 +57,11 @@ public:
|
|||||||
/// xforms callback from scrollbar
|
/// xforms callback from scrollbar
|
||||||
void scroll_cb();
|
void scroll_cb();
|
||||||
/// a selection exists
|
/// a selection exists
|
||||||
virtual void haveSelection(bool) const;
|
virtual void haveSelection(bool);
|
||||||
///
|
///
|
||||||
virtual std::string const getClipboard() const;
|
virtual std::string const getClipboard() const;
|
||||||
///
|
///
|
||||||
virtual void putClipboard(std::string const &) const;
|
virtual void putClipboard(std::string const &);
|
||||||
|
|
||||||
/// handles SelectionRequest X Event, to fill the clipboard
|
/// handles SelectionRequest X Event, to fill the clipboard
|
||||||
int event_cb(XEvent * xev);
|
int event_cb(XEvent * xev);
|
||||||
|
@ -45,7 +45,7 @@ GC createGC()
|
|||||||
|
|
||||||
|
|
||||||
XScreen::XScreen(XWorkArea & o)
|
XScreen::XScreen(XWorkArea & o)
|
||||||
: LyXScreen(), owner_(o), nocursor_pixmap_(0),
|
: owner_(o), nocursor_pixmap_(0),
|
||||||
cursor_x_(0), cursor_y_(0), cursor_w_(0), cursor_h_(0)
|
cursor_x_(0), cursor_y_(0), cursor_w_(0), cursor_h_(0)
|
||||||
{
|
{
|
||||||
// We need this GC
|
// We need this GC
|
||||||
@ -59,12 +59,6 @@ XScreen::~XScreen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WorkArea & XScreen::workarea()
|
|
||||||
{
|
|
||||||
return owner_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void XScreen::setCursorColor()
|
void XScreen::setCursorColor()
|
||||||
{
|
{
|
||||||
if (!lyxColorHandler.get())
|
if (!lyxColorHandler.get())
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
#ifndef XSCREEN_H
|
#ifndef XSCREEN_H
|
||||||
#define XSCREEN_H
|
#define XSCREEN_H
|
||||||
|
|
||||||
#include "screen.h"
|
#include "frontends/GuiCursor.h"
|
||||||
|
|
||||||
#include <X11/Xlib.h> // for Pixmap, GC
|
#include <X11/Xlib.h> // for Pixmap, GC
|
||||||
|
|
||||||
class WorkArea;
|
class WorkArea;
|
||||||
@ -28,7 +29,7 @@ class XWorkArea;
|
|||||||
date and used to optimize drawing on the screen.
|
date and used to optimize drawing on the screen.
|
||||||
This class also handles the drawing of the cursor and partly the selection.
|
This class also handles the drawing of the cursor and partly the selection.
|
||||||
*/
|
*/
|
||||||
class XScreen : public LyXScreen {
|
class XScreen {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
XScreen(XWorkArea &);
|
XScreen(XWorkArea &);
|
||||||
@ -39,10 +40,6 @@ public:
|
|||||||
/// Sets the cursor color to LColor::cursor.
|
/// Sets the cursor color to LColor::cursor.
|
||||||
virtual void setCursorColor();
|
virtual void setCursorColor();
|
||||||
|
|
||||||
protected:
|
|
||||||
/// get the work area
|
|
||||||
virtual WorkArea & workarea();
|
|
||||||
|
|
||||||
/// Copies specified area of pixmap to screen
|
/// Copies specified area of pixmap to screen
|
||||||
virtual void expose(int x, int y, int w, int h);
|
virtual void expose(int x, int y, int w, int h);
|
||||||
|
|
||||||
|
@ -20,11 +20,17 @@
|
|||||||
#include "box.h"
|
#include "box.h"
|
||||||
#include "lyxfont.h"
|
#include "lyxfont.h"
|
||||||
|
|
||||||
class Painter;
|
|
||||||
class LyXText;
|
class LyXText;
|
||||||
class Paragraph;
|
class Paragraph;
|
||||||
class CursorSlice;
|
class CursorSlice;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
class Painter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** A collapsable text inset
|
/** A collapsable text inset
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "frontends/Painter.h"
|
#include "frontends/Painter.h"
|
||||||
|
|
||||||
|
using lyx::frontend::Painter;
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include "frontends/Painter.h"
|
#include "frontends/Painter.h"
|
||||||
#include "frontends/font_metrics.h"
|
#include "frontends/font_metrics.h"
|
||||||
|
|
||||||
|
using lyx::frontend::Painter;
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
|
||||||
|
@ -53,6 +53,8 @@ using lyx::graphics::PreviewLoader;
|
|||||||
|
|
||||||
using lyx::support::ltrim;
|
using lyx::support::ltrim;
|
||||||
|
|
||||||
|
using lyx::frontend::Painter;
|
||||||
|
|
||||||
using boost::shared_ptr;
|
using boost::shared_ptr;
|
||||||
|
|
||||||
using std::auto_ptr;
|
using std::auto_ptr;
|
||||||
@ -284,7 +286,7 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
|||||||
//lyxerr << "InsetTabular::draw: " << x << " " << y << endl;
|
//lyxerr << "InsetTabular::draw: " << x << " " << y << endl;
|
||||||
BufferView * bv = pi.base.bv;
|
BufferView * bv = pi.base.bv;
|
||||||
|
|
||||||
static NullPainter nop;
|
static lyx::frontend::NullPainter nop;
|
||||||
static PainterInfo nullpi(bv, nop);
|
static PainterInfo nullpi(bv, nop);
|
||||||
|
|
||||||
//resetPos(bv->cursor());
|
//resetPos(bv->cursor());
|
||||||
|
@ -37,13 +37,18 @@
|
|||||||
|
|
||||||
class FuncStatus;
|
class FuncStatus;
|
||||||
class LyXLex;
|
class LyXLex;
|
||||||
class Painter;
|
|
||||||
class BufferView;
|
class BufferView;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class BufferParams;
|
class BufferParams;
|
||||||
class Paragraph;
|
class Paragraph;
|
||||||
class CursorSlice;
|
class CursorSlice;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
class Painter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class InsetTabular : public InsetOld {
|
class InsetTabular : public InsetOld {
|
||||||
public:
|
public:
|
||||||
@ -154,7 +159,7 @@ private:
|
|||||||
virtual std::auto_ptr<InsetBase> doClone() const;
|
virtual std::auto_ptr<InsetBase> doClone() const;
|
||||||
|
|
||||||
///
|
///
|
||||||
void drawCellLines(Painter &, int x, int y, row_type row,
|
void drawCellLines(lyx::frontend::Painter &, int x, int y, row_type row,
|
||||||
idx_type cell, bool erased) const;
|
idx_type cell, bool erased) const;
|
||||||
///
|
///
|
||||||
void setCursorFromCoordinates(LCursor & cur, int x, int y) const;
|
void setCursorFromCoordinates(LCursor & cur, int x, int y) const;
|
||||||
|
@ -334,9 +334,6 @@ public:
|
|||||||
/// delete double space or empty paragraphs around old cursor
|
/// delete double space or empty paragraphs around old cursor
|
||||||
bool deleteEmptyParagraphMechanism(LCursor & cur, LCursor & old);
|
bool deleteEmptyParagraphMechanism(LCursor & cur, LCursor & old);
|
||||||
|
|
||||||
///
|
|
||||||
friend class LyXScreen;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
Dimension dim_;
|
Dimension dim_;
|
||||||
|
@ -229,7 +229,7 @@ void MathNestInset::drawSelection(PainterInfo & pi, int x, int y) const
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: hack to get position cache warm
|
// FIXME: hack to get position cache warm
|
||||||
static NullPainter nop;
|
static lyx::frontend::NullPainter nop;
|
||||||
PainterInfo pinop(pi);
|
PainterInfo pinop(pi);
|
||||||
pinop.pain = nop;
|
pinop.pain = nop;
|
||||||
draw(pinop, x, y);
|
draw(pinop, x, y);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
using lyx::frontend::Painter;
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::max;
|
using std::max;
|
||||||
|
@ -46,7 +46,7 @@ MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
PainterInfo::PainterInfo(BufferView * bv, Painter & painter)
|
PainterInfo::PainterInfo(BufferView * bv, lyx::frontend::Painter & painter)
|
||||||
: pain(painter), ltr_pos(false), erased_(false)
|
: pain(painter), ltr_pos(false), erased_(false)
|
||||||
{
|
{
|
||||||
base.bv = bv;
|
base.bv = bv;
|
||||||
|
@ -17,9 +17,14 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class Painter;
|
|
||||||
class BufferView;
|
class BufferView;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
class Painter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Standard Sizes (mode styles)
|
/// Standard Sizes (mode styles)
|
||||||
enum Styles {
|
enum Styles {
|
||||||
@ -80,7 +85,7 @@ public:
|
|||||||
class PainterInfo {
|
class PainterInfo {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
PainterInfo(BufferView * bv, Painter & pain);
|
PainterInfo(BufferView * bv, lyx::frontend::Painter & pain);
|
||||||
///
|
///
|
||||||
void draw(int x, int y, char c);
|
void draw(int x, int y, char c);
|
||||||
///
|
///
|
||||||
@ -89,7 +94,7 @@ public:
|
|||||||
///
|
///
|
||||||
MetricsBase base;
|
MetricsBase base;
|
||||||
///
|
///
|
||||||
Painter & pain;
|
lyx::frontend::Painter & pain;
|
||||||
/// Whether the text at this point is right-to-left (for InsetNewline)
|
/// Whether the text at this point is right-to-left (for InsetNewline)
|
||||||
bool ltr_pos;
|
bool ltr_pos;
|
||||||
/// Whether the parent is deleted (change tracking)
|
/// Whether the parent is deleted (change tracking)
|
||||||
|
@ -42,6 +42,8 @@
|
|||||||
|
|
||||||
#include <boost/crc.hpp>
|
#include <boost/crc.hpp>
|
||||||
|
|
||||||
|
using lyx::frontend::Painter;
|
||||||
|
using lyx::frontend::NullPainter;
|
||||||
using lyx::char_type;
|
using lyx::char_type;
|
||||||
using lyx::pos_type;
|
using lyx::pos_type;
|
||||||
using lyx::pit_type;
|
using lyx::pit_type;
|
||||||
|
@ -546,6 +546,27 @@ int findToken(char const * const str[], string const & search_token)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string const externalLineEnding(string const & str)
|
||||||
|
{
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
// The MAC clipboard uses \r for lineendings, and we use \n
|
||||||
|
return subst(str, '\n', '\r');
|
||||||
|
#elif defined (_WIN32) || (defined (__CYGWIN__) && defined (X_DISPLAY_MISSING))
|
||||||
|
// Windows clipboard uses \r\n for lineendings, and we use \n
|
||||||
|
return subst(str, "\n", "\r\n");
|
||||||
|
#else
|
||||||
|
return str;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string const internalLineEnding(string const & str)
|
||||||
|
{
|
||||||
|
string s = subst(str, "\r\n", "\n");
|
||||||
|
return subst(s, '\r', '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
|
#ifndef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
|
||||||
#if USE_BOOST_FORMAT
|
#if USE_BOOST_FORMAT
|
||||||
|
|
||||||
|
@ -180,6 +180,12 @@ std::string const getStringFromVector(std::vector<std::string> const & vec,
|
|||||||
/// found, else -1. The last item in \p str must be "".
|
/// found, else -1. The last item in \p str must be "".
|
||||||
int findToken(char const * const str[], std::string const & search_token);
|
int findToken(char const * const str[], std::string const & search_token);
|
||||||
|
|
||||||
|
/// Convert internal line endings to line endings as expected by the OS
|
||||||
|
std::string const externalLineEnding(std::string const & str);
|
||||||
|
|
||||||
|
/// Convert line endings in any formnat to internal line endings
|
||||||
|
std::string const internalLineEnding(std::string const & str);
|
||||||
|
|
||||||
|
|
||||||
#ifdef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
|
#ifdef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user