]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GWorkArea.h
header file reorder
[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 "frontends/WorkArea.h"
18
19 #include <gtkmm.h>
20 #include <gtk/gtk.h>
21
22 #include <X11/Xft/Xft.h>
23
24 class LColor_color;
25 class LyXView;
26
27 namespace lyx {
28 namespace frontend {
29
30 class ColorCache {
31 public:
32         typedef std::map<LColor_color, Gdk::Color *> Map;
33         typedef Map::iterator MapIt;
34         typedef std::map<LColor_color, XftColor *> Map2;
35         typedef Map2::iterator MapIt2;
36         ~ColorCache();
37         Gdk::Color * getColor(LColor_color);
38         XftColor * getXftColor(LColor_color);
39         void cacheColor(LColor_color, Gdk::Color *);
40         void cacheXftColor(LColor_color, XftColor *);
41         void clear();
42 private:
43         Map cache_;
44         Map2 cache2_;
45 };
46
47 extern ColorCache colorCache;
48
49 class ColorHandler {
50 public:
51         ColorHandler(GWorkArea & owner) : owner_(owner) {}
52         XftColor * getXftColor(LColor_color clr);
53         Gdk::Color * getGdkColor(LColor_color clr);
54 private:
55         GWorkArea & owner_;
56 };
57
58
59 class GWorkArea : public WorkArea, public sigc::trackable {
60 public:
61         GWorkArea(LyXView & owner, int width, int height);
62         ~GWorkArea();
63
64         virtual Painter & getPainter();
65         ///
66         virtual int workWidth() const;
67         ///
68         virtual int workHeight() const;
69         /// return x position of window
70         int xpos() const;
71         /// return y position of window
72         int ypos() const;
73         ///
74         Glib::RefPtr<Gdk::Window> getWindow();
75         Display * getDisplay() const;
76         Glib::RefPtr<Gdk::Pixmap> getPixmap();
77         Glib::RefPtr<Gdk::GC> getGC();
78         Glib::RefPtr<Gdk::Colormap> getColormap();
79         XftDraw * getXftDraw();
80         ColorHandler & getColorHandler();
81
82         virtual void setScrollbarParams(int height, int pos, int line_height);
83         /// a selection exists
84         virtual void haveSelection(bool) const;
85         ///
86         virtual std::string const getClipboard() const;
87         ///
88         virtual void putClipboard(std::string const &) const;
89         void inputCommit(gchar * str);
90 private:
91         bool onExpose(GdkEventExpose * event);
92         bool onConfigure(GdkEventConfigure * event);
93         void onScroll();
94         bool onScrollWheel(GdkEventScroll * event);
95         bool onButtonPress(GdkEventButton * event);
96         bool onButtonRelease(GdkEventButton * event);
97         bool onMotionNotify(GdkEventMotion * event);
98         bool onKeyPress(GdkEventKey * event);
99         void onClipboardGet(Gtk::SelectionData & selection_data, guint info);
100         void onClipboardClear();
101         Gtk::HBox hbox_;
102         Gtk::DrawingArea workArea_;
103         Gtk::VScrollbar vscrollbar_;
104         /// The pixmap overlay on the workarea
105         Glib::RefPtr<Gdk::Pixmap> workAreaPixmap_;
106         Glib::RefPtr<Gdk::GC> workAreaGC_;
107         /// the xforms-specific painter
108         GPainter painter_;
109         XftDraw * draw_;
110         ColorHandler colorHandler_;
111         GtkIMContext * imContext_;
112         std::string inputCache_;
113 };
114
115 } // namespace frontend
116 } // namespace lyx
117
118 #endif