]> 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         void inputCommit(gchar * str);
86
87         LyXView & view()
88         {
89                 return view_;
90         }
91
92 private:
93         bool onExpose(GdkEventExpose * event);
94         bool onConfigure(GdkEventConfigure * event);
95         void onScroll();
96         bool onScrollWheel(GdkEventScroll * event);
97         bool onButtonPress(GdkEventButton * event);
98         bool onButtonRelease(GdkEventButton * event);
99         bool onMotionNotify(GdkEventMotion * event);
100         bool onKeyPress(GdkEventKey * event);
101         LyXView & view_;
102         Gtk::HBox hbox_;
103         Gtk::DrawingArea workArea_;
104         Gtk::VScrollbar vscrollbar_;
105         /// The pixmap overlay on the workarea
106         Glib::RefPtr<Gdk::Pixmap> workAreaPixmap_;
107         Glib::RefPtr<Gdk::GC> workAreaGC_;
108         GPainter painter_;
109         XftDraw * draw_;
110         ColorHandler colorHandler_;
111         GtkIMContext * imContext_;
112         std::string inputCache_;
113         bool adjusting_;
114 };
115
116 } // namespace frontend
117 } // namespace lyx
118
119 #endif