/TeXmacs-1.0.7.11-src/src/Plugins/X11/x_gui.hpp
C++ Header | 203 lines | 148 code | 29 blank | 26 comment | 2 complexity | 0b1f3b68d9ecf0d73b5e7f2881a1f1f4 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, MPL-2.0-no-copyleft-exception
1
2/******************************************************************************
3* MODULE : x_gui.hpp
4* DESCRIPTION: Graphical user interface for X11
5* COPYRIGHT : (C) 1999 Joris van der Hoeven
6*******************************************************************************
7* This software falls under the GNU general public license version 3 or later.
8* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10******************************************************************************/
11
12#ifndef X_GUI_H
13#define X_GUI_H
14#include "timer.hpp"
15#include "gui.hpp"
16#include "widget.hpp"
17#include "array.hpp"
18#include "hashmap.hpp"
19
20class x_gui_rep;
21class x_drawable_rep;
22class x_window_rep;
23typedef x_gui_rep* x_gui;
24typedef x_window_rep* x_window;
25extern x_gui the_gui;
26
27#define XK_CYRILLIC
28
29#include <X11/Xlib.h>
30#include <X11/X.h>
31#include <X11/Xutil.h>
32#include <X11/Xos.h>
33#include <X11/Xatom.h>
34#include <X11/keysym.h>
35#include <X11/Sunkeysym.h>
36
37extern bool true_color;
38#define CONVERT(c) (true_color? (c & 0xffffff): gui->cmap [c & 0xffffff])
39color blend (color fg, color bg);
40
41/******************************************************************************
42* For anti aliasing of TeX fonts
43******************************************************************************/
44
45struct x_character_rep: concrete_struct {
46 int c;
47 font_glyphs fng;
48 int sf;
49 color fg;
50 color bg;
51 x_character_rep (int c, font_glyphs fng, int sf, color fg, color bg);
52 friend class x_character;
53};
54
55class x_character {
56 CONCRETE(x_character);
57 x_character (int c=0, font_glyphs fng= font_glyphs (),
58 int sf=1, color fg= 0, color bg= 1);
59 operator tree ();
60};
61CONCRETE_CODE(x_character);
62
63bool operator == (x_character xc1, x_character xc2);
64bool operator != (x_character xc1, x_character xc2);
65int hash (x_character xc);
66
67/******************************************************************************
68* Delayed messages
69******************************************************************************/
70
71struct message_rep: concrete_struct {
72 widget wid;
73 string s;
74 time_t t;
75 message_rep (widget wid, string s, time_t t);
76 friend class message;
77};
78
79class message {
80 CONCRETE(message);
81 message (widget wid, string s, time_t t);
82};
83CONCRETE_CODE(message);
84
85tm_ostream& operator << (tm_ostream& out, message m);
86
87/******************************************************************************
88* The x_gui class
89******************************************************************************/
90
91class x_gui_rep {
92public:
93 Display* dpy;
94 GC gc;
95 GC pixmap_gc;
96 int scr;
97 Window root;
98 int screen_width;
99 int screen_height;
100 int depth;
101 Colormap cols;
102 color* cmap;
103 bool im_ok;
104 XIM im;
105 list<widget> grab_ptr;
106 list<widget> grab_kbd;
107 unsigned int state;
108 list<message> messages;
109 x_window_rep* gswindow;
110 int argc;
111 char** argv;
112 widget balloon_wid;
113 window balloon_win;
114 SI balloon_x;
115 SI balloon_y;
116 time_t balloon_time;
117 bool interrupted;
118 time_t interrupt_time;
119
120 hashmap<x_character,pointer> color_scale; // for anti-aliasing
121 hashmap<x_character,pointer> character_bitmap; // bitmaps of all characters
122 hashmap<x_character,pointer> character_pixmap; // pixmaps of all characters
123 hashmap<string,int> xpm_bitmap; // bitmaps of all xpms
124 hashmap<string,int> xpm_pixmap; // pixmaps of all xpms
125 hashmap<int,string> lower_key;
126 hashmap<int,string> upper_key;
127
128 list<Window> windows_l;
129 hashmap<string,tree> selection_t;
130 hashmap<string,string> selection_s;
131 Window selection_w;
132
133 Atom XA_CLIPBOARD;
134 Atom XA_TARGETS;
135
136public:
137 x_gui_rep (int& argc, char** argv);
138 ~x_gui_rep ();
139
140 /******************************* Colors ************************************/
141 void prepare_color (int sfactor, color fg, color bg);
142
143 /****************************** Keyboard ***********************************/
144 void initialize_input_method ();
145 void insert_keysym (array<int>& a, int i, int j);
146 void get_xmodmap ();
147 void map (int key, string s);
148 void Map (int key, string s);
149 void initialize_keyboard_pointer ();
150 string look_up_key (XKeyEvent* ev);
151 string look_up_mouse (XButtonEvent* ev);
152 unsigned int get_button_mask (XButtonEvent* ev);
153
154 /******************************** Fonts ************************************/
155 void set_shrinking_factor (int sfactor);
156 void set_default_font (string name);
157 font default_font_sub (bool tt, bool mini);
158 font default_font (bool tt= false, bool mini= false);
159 void get_ps_char (Font fn, int c, metric& ex, glyph& gl);
160 void load_system_font (string family, int size, int dpi,
161 font_metric& fnm, font_glyphs& fng);
162
163 /********************* extents, grabbing, selections ***********************/
164 void get_extents (SI& width, SI& height);
165 void get_max_size (SI& width, SI& height);
166 void set_button_state (unsigned int state);
167 void emulate_leave_enter (widget old_widget, widget new_widget);
168 void obtain_mouse_grab (widget wid);
169 void release_mouse_grab ();
170 bool has_mouse_grab (widget w);
171
172 /*********************** interclient communication *************************/
173 void created_window (Window win);
174 void deleted_window (Window win);
175 void focussed_window (Window win);
176 bool get_selection (string key, tree& t, string& s);
177 bool set_selection (string key, tree t, string s);
178 void clear_selection (string key);
179
180 /**************************** miscellaneous ********************************/
181 void show_help_balloon (widget wid, SI x, SI y);
182 void map_balloon ();
183 void unmap_balloon ();
184 void image_auto_gc ();
185 void image_gc (string name);
186 void set_mouse_pointer (widget w, string name);
187 void set_mouse_pointer (widget w, string curs_name, string mask_name);
188 void show_wait_indicator (widget w, string message, string arg);
189 void external_event (string s, time_t t);
190 bool check_event (int type);
191
192 /************************** Event processing *******************************/
193 void process_event (x_window win, XEvent* ev);
194 void event_loop ();
195
196 /*************************** And our friends *******************************/
197 friend class x_drawable_rep;
198 friend class x_window_rep;
199 friend class x_ps_font_rep;
200 friend class x_tex_font_rep;
201};
202
203#endif // defined X_GUI_H