2003-09-02 10:29:05 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file GWorkArea.h
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GWORKAREA_H
|
|
|
|
#define GWORKAREA_H
|
|
|
|
|
|
|
|
#include "GPainter.h"
|
2003-09-16 07:53:02 +00:00
|
|
|
#include <gdk/gdkx.h>
|
2003-09-02 10:29:05 +00:00
|
|
|
#include <gtk/gtk.h>
|
2003-09-16 07:53:02 +00:00
|
|
|
|
|
|
|
#include "frontends/WorkArea.h"
|
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
#include <X11/Xft/Xft.h>
|
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
class LColor_color;
|
2004-04-28 11:33:27 +00:00
|
|
|
class LyXView;
|
2003-09-15 15:20:22 +00:00
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
class ColorCache
|
|
|
|
{
|
2003-09-18 11:48:11 +00:00
|
|
|
typedef std::map<LColor_color, Gdk::Color *> Map;
|
2003-09-02 10:29:05 +00:00
|
|
|
typedef Map::iterator MapIt;
|
2003-09-18 11:48:11 +00:00
|
|
|
typedef std::map<LColor_color, XftColor *> Map2;
|
2003-09-02 10:29:05 +00:00
|
|
|
typedef Map2::iterator MapIt2;
|
|
|
|
public:
|
2003-09-16 07:53:02 +00:00
|
|
|
~ColorCache();
|
2003-09-18 11:48:11 +00:00
|
|
|
Gdk::Color * getColor(LColor_color);
|
|
|
|
XftColor * getXftColor(LColor_color);
|
|
|
|
void cacheColor(LColor_color, Gdk::Color *);
|
|
|
|
void cacheXftColor(LColor_color, XftColor *);
|
2003-09-02 10:29:05 +00:00
|
|
|
void clear();
|
|
|
|
private:
|
|
|
|
Map cache_;
|
|
|
|
Map2 cache2_;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern ColorCache colorCache;
|
|
|
|
|
|
|
|
class ColorHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ColorHandler(GWorkArea& owner) : owner_(owner) {}
|
2003-09-18 11:48:11 +00:00
|
|
|
XftColor * getXftColor(LColor_color clr);
|
|
|
|
Gdk::Color * getGdkColor(LColor_color clr);
|
2003-09-02 10:29:05 +00:00
|
|
|
private:
|
|
|
|
GWorkArea & owner_;
|
|
|
|
};
|
|
|
|
|
2003-09-16 07:53:02 +00:00
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
class GWorkArea : public WorkArea, public SigC::Object
|
|
|
|
{
|
|
|
|
public:
|
2004-04-28 11:33:27 +00:00
|
|
|
GWorkArea(LyXView & owner, int width, int height);
|
2003-09-02 10:29:05 +00:00
|
|
|
~GWorkArea();
|
|
|
|
|
2003-09-16 07:53:02 +00:00
|
|
|
virtual Painter & getPainter();
|
2003-09-02 10:29:05 +00:00
|
|
|
///
|
2003-09-16 07:53:02 +00:00
|
|
|
virtual int workWidth() const;
|
2003-09-02 10:29:05 +00:00
|
|
|
///
|
2003-09-16 07:53:02 +00:00
|
|
|
virtual int workHeight() const;
|
2003-09-02 10:29:05 +00:00
|
|
|
/// return x position of window
|
2003-09-16 07:53:02 +00:00
|
|
|
int xpos() const;
|
2003-09-02 10:29:05 +00:00
|
|
|
/// return y position of window
|
2003-09-16 07:53:02 +00:00
|
|
|
int ypos() const;
|
2003-09-02 10:29:05 +00:00
|
|
|
///
|
2003-09-16 07:53:02 +00:00
|
|
|
Glib::RefPtr<Gdk::Window> getWindow();
|
|
|
|
Display * getDisplay() const;
|
|
|
|
Glib::RefPtr<Gdk::Pixmap> getPixmap();
|
|
|
|
Glib::RefPtr<Gdk::GC> getGC();
|
|
|
|
Glib::RefPtr<Gdk::Colormap> getColormap();
|
|
|
|
XftDraw * getXftDraw();
|
|
|
|
ColorHandler & getColorHandler();
|
2003-09-02 10:29:05 +00:00
|
|
|
|
|
|
|
virtual void setScrollbarParams(int height, int pos, int line_height);
|
|
|
|
/// a selection exists
|
|
|
|
virtual void haveSelection(bool) const;
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
virtual std::string const getClipboard() const;
|
2003-09-02 10:29:05 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
virtual void putClipboard(std::string const &) const;
|
2003-09-02 10:29:05 +00:00
|
|
|
void inputCommit(gchar * str);
|
|
|
|
private:
|
|
|
|
bool onExpose(GdkEventExpose * event);
|
|
|
|
bool onConfigure(GdkEventConfigure * event);
|
|
|
|
void onScroll();
|
|
|
|
bool onButtonPress(GdkEventButton * event);
|
|
|
|
bool onButtonRelease(GdkEventButton * event);
|
|
|
|
bool onMotionNotify(GdkEventMotion * event);
|
|
|
|
bool onKeyPress(GdkEventKey * event);
|
|
|
|
void onClipboardGet(Gtk::SelectionData& selection_data, guint info);
|
|
|
|
void onClipboardClear();
|
|
|
|
Gtk::HBox hbox_;
|
|
|
|
Gtk::DrawingArea workArea_;
|
|
|
|
Gtk::VScrollbar vscrollbar_;
|
|
|
|
/// The pixmap overlay on the workarea
|
|
|
|
Glib::RefPtr<Gdk::Pixmap> workAreaPixmap_;
|
|
|
|
Glib::RefPtr<Gdk::GC> workAreaGC_;
|
|
|
|
/// the xforms-specific painter
|
|
|
|
GPainter painter_;
|
|
|
|
XftDraw * draw_;
|
|
|
|
ColorHandler colorHandler_;
|
|
|
|
GtkIMContext * imContext_;
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string inputCache_;
|
2003-09-02 10:29:05 +00:00
|
|
|
};
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
#endif
|