]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GWorkArea.h
make it compile again
[lyx.git] / src / frontends / gtk / GWorkArea.h
1 // -*- C++ -*-
2 /**
3  * \file GWorkArea.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Huang Ying
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GWORKAREA_H
13 #define GWORKAREA_H
14
15 #include "GPainter.h"
16
17 #include <boost/shared_ptr.hpp>
18
19 #include <gtkmm.h>
20 #include <gtk/gtk.h>
21
22 #include <X11/Xft/Xft.h>
23
24 // FIXME: defined in X.h, spuriously pulled in by some gui headers
25 #undef CursorShape
26
27 class LColor_color;
28 class LyXView;
29
30 namespace lyx {
31 namespace frontend {
32
33 class ColorCache {
34 public:
35         typedef std::map<LColor_color, boost::shared_ptr<Gdk::Color> > Map;
36         typedef Map::iterator MapIt;
37         typedef std::map<LColor_color, boost::shared_ptr<XftColor> > Map2;
38         typedef Map2::iterator MapIt2;
39         Gdk::Color * getColor(LColor_color);
40         XftColor * getXftColor(LColor_color);
41         void cacheColor(LColor_color, Gdk::Color *);
42         void cacheXftColor(LColor_color, XftColor *);
43         void clear();
44 private:
45         Map cache_;
46         Map2 cache2_;
47 };
48
49 extern ColorCache colorCache;
50
51 class ColorHandler {
52 public:
53         ColorHandler(GWorkArea & owner) : owner_(owner) {}
54         XftColor * getXftColor(LColor_color clr);
55         Gdk::Color * getGdkColor(LColor_color clr);
56 private:
57         GWorkArea & owner_;
58 };
59
60
61 class GWorkArea : public sigc::trackable {
62 public:
63         GWorkArea(LyXView & owner, int width, int height);
64         virtual ~GWorkArea();
65
66         virtual Painter & getPainter();
67         ///
68         virtual int workWidth() const;
69         ///
70         virtual int workHeight() const;
71         /// return x position of window
72         int xpos() const;
73         /// return y position of window
74         int ypos() const;
75         ///
76         Glib::RefPtr<Gdk::Window> getWindow();
77         Display * getDisplay() const;
78         Glib::RefPtr<Gdk::Pixmap> getPixmap();
79         Glib::RefPtr<Gdk::GC> getGC();
80         Glib::RefPtr<Gdk::Colormap> getColormap();
81         XftDraw * getXftDraw();
82         ColorHandler & getColorHandler();
83
84         virtual void setScrollbarParams(int height, int pos, int line_height);
85         /// a selection exists
86         virtual void haveSelection(bool);
87         void inputCommit(gchar * str);
88
89         LyXView & view()
90         {
91                 return view_;
92         }
93
94 private:
95         bool onExpose(GdkEventExpose * event);
96         bool onConfigure(GdkEventConfigure * event);
97         void onScroll();
98         bool onScrollWheel(GdkEventScroll * event);
99         bool onButtonPress(GdkEventButton * event);
100         bool onButtonRelease(GdkEventButton * event);
101         bool onMotionNotify(GdkEventMotion * event);
102         bool onKeyPress(GdkEventKey * event);
103         void onClipboardGet(Gtk::SelectionData & selection_data, guint info);
104         void onClipboardClear();
105         LyXView & view_;
106         Gtk::HBox hbox_;
107         Gtk::DrawingArea workArea_;
108         Gtk::VScrollbar vscrollbar_;
109         /// The pixmap overlay on the workarea
110         Glib::RefPtr<Gdk::Pixmap> workAreaPixmap_;
111         Glib::RefPtr<Gdk::GC> workAreaGC_;
112         GPainter painter_;
113         XftDraw * draw_;
114         ColorHandler colorHandler_;
115         GtkIMContext * imContext_;
116         std::string inputCache_;
117         bool adjusting_;
118 };
119
120 } // namespace frontend
121 } // namespace lyx
122
123 #endif