2003-09-02 10:29:05 +00:00
|
|
|
/**
|
|
|
|
* \file GScreen.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Huang Ying
|
|
|
|
*
|
2003-09-02 17:02:32 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-09-02 10:29:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2004-11-16 23:18:46 +00:00
|
|
|
// Too hard to make concept checks work with this file
|
|
|
|
#ifdef _GLIBCPP_CONCEPT_CHECKS
|
|
|
|
#undef _GLIBCPP_CONCEPT_CHECKS
|
|
|
|
#endif
|
|
|
|
|
2003-09-15 15:20:22 +00:00
|
|
|
#include "GScreen.h"
|
2003-09-02 10:29:05 +00:00
|
|
|
|
|
|
|
#include "GWorkArea.h"
|
2003-09-15 15:20:22 +00:00
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
#include "buffer.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "debug.h"
|
2003-09-15 15:20:22 +00:00
|
|
|
#include "language.h"
|
|
|
|
#include "LColor.h"
|
|
|
|
#include "lyxtext.h"
|
|
|
|
#include "lyxrow.h"
|
|
|
|
|
|
|
|
#include "frontends/screen.h"
|
|
|
|
#include "frontends/font_metrics.h"
|
|
|
|
#include "frontends/Painter.h"
|
|
|
|
#include "frontends/WorkArea.h"
|
|
|
|
|
|
|
|
#include "insets/insettext.h"
|
|
|
|
|
|
|
|
#include <algorithm>
|
2003-09-02 10:29:05 +00:00
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2003-09-02 10:29:05 +00:00
|
|
|
|
|
|
|
GScreen::GScreen(GWorkArea & o)
|
|
|
|
: LyXScreen(), owner_(o)
|
|
|
|
{
|
|
|
|
// the cursor isnt yet visible
|
|
|
|
cursorX_ = 0;
|
|
|
|
cursorY_ = 0;
|
|
|
|
cursorW_ = 0;
|
|
|
|
cursorH_ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GScreen::~GScreen()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-16 07:53:02 +00:00
|
|
|
WorkArea & GScreen::workarea() const
|
|
|
|
{
|
|
|
|
return owner_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
void GScreen::setCursorColor(Glib::RefPtr<Gdk::GC> gc)
|
|
|
|
{
|
|
|
|
Gdk::Color * clr = owner_.getColorHandler().
|
|
|
|
getGdkColor(LColor::cursor);
|
|
|
|
gc->set_foreground(*clr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
void GScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
|
2003-09-02 10:29:05 +00:00
|
|
|
{
|
|
|
|
// Update the cursor color.
|
|
|
|
setCursorColor(owner_.getGC());
|
|
|
|
|
|
|
|
cursorX_ = x;
|
|
|
|
cursorY_ = y;
|
|
|
|
cursorH_ = h;
|
|
|
|
|
|
|
|
switch (shape) {
|
|
|
|
case BAR_SHAPE:
|
|
|
|
cursorW_ = 1;
|
|
|
|
break;
|
|
|
|
case L_SHAPE:
|
|
|
|
cursorW_ = cursorH_ / 3;
|
|
|
|
break;
|
|
|
|
case REVERSED_L_SHAPE:
|
|
|
|
cursorW_ = cursorH_ / 3;
|
|
|
|
cursorX_ = x - cursorW_ + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int fx, fy, fwidth, fheight, fdepth;
|
|
|
|
owner_.getWindow()->get_geometry(fx, fy, fwidth, fheight, fdepth);
|
|
|
|
cursorPixmap_ = Gdk::Pixmap::create(owner_.getWindow(),
|
|
|
|
cursorW_,
|
|
|
|
cursorH_,
|
|
|
|
fdepth);
|
|
|
|
cursorPixmap_->draw_drawable(owner_.getGC(),
|
|
|
|
owner_.getWindow(),
|
|
|
|
owner_.xpos() + cursorX_,
|
|
|
|
owner_.ypos() + cursorY_,
|
|
|
|
0, 0,
|
|
|
|
cursorW_,
|
|
|
|
cursorH_);
|
|
|
|
owner_.getWindow()->draw_line(owner_.getGC(),
|
|
|
|
x + owner_.xpos(),
|
|
|
|
y + owner_.ypos(),
|
|
|
|
x + owner_.xpos(),
|
|
|
|
y + h - 1 + owner_.ypos());
|
|
|
|
switch (shape) {
|
|
|
|
case BAR_SHAPE:
|
|
|
|
break;
|
|
|
|
case L_SHAPE:
|
|
|
|
case REVERSED_L_SHAPE:
|
|
|
|
owner_.getWindow()->draw_line(owner_.getGC(),
|
|
|
|
owner_.xpos() + cursorX_,
|
|
|
|
owner_.ypos() + y + h - 1,
|
|
|
|
owner_.xpos() + cursorX_ + cursorW_ - 1,
|
|
|
|
owner_.xpos() + y + h - 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GScreen::removeCursor()
|
|
|
|
{
|
|
|
|
if (cursorPixmap_) {
|
|
|
|
owner_.getWindow()->draw_drawable(owner_.getGC(),
|
|
|
|
cursorPixmap_,
|
|
|
|
0, 0,
|
|
|
|
cursorX_ + owner_.xpos(),
|
|
|
|
cursorY_ + owner_.ypos(),
|
|
|
|
cursorW_, cursorH_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GScreen::expose(int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
lyxerr[Debug::GUI] << "expose " << w << 'x' << h
|
|
|
|
<< '+' << x << '+' << y << std::endl;
|
|
|
|
owner_.getWindow()->draw_drawable(owner_.getGC(),
|
|
|
|
owner_.getPixmap(),
|
|
|
|
x, y,
|
|
|
|
x + owner_.xpos(),
|
|
|
|
y + owner_.ypos(),
|
|
|
|
w, h);
|
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|