~ubuntu-branches/ubuntu/quantal/texmacs/quantal

« back to all changes in this revision

Viewing changes to src/Plugins/X11/x_gui.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Atsuhito KOHDA, Kamaraju Kusumanchi, kohda
  • Date: 2008-04-06 15:11:41 UTC
  • mfrom: (1.1.7 upstream) (4.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080406151141-w0sg20jnv86mlt6f
Tags: 1:1.0.6.14-1
[Kamaraju Kusumanchi <kamaraju@gmail.com>]
* New upstream release
* 01_american.dpatch is updated
* Since thread support in guile-1.8 is now disabled, the segmentation faults
  should not arise anymore. More info at #439923. (Closes: #450499, #458685)
[kohda]
* This version fixed menu problem.  (Closes: #447083)
* Reverted orig.tar.gz to the upstream tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 and comes WITHOUT
 
8
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
 
9
* If you don't have this file, write to the Free Software Foundation, Inc.,
 
10
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
11
******************************************************************************/
 
12
 
 
13
#ifndef X_GUI_H
 
14
#define X_GUI_H
 
15
#include "timer.hpp"
 
16
#include "gui.hpp"
 
17
#include "widget.hpp"
 
18
#include "array.hpp"
 
19
#include "hashmap.hpp"
 
20
 
 
21
class x_gui_rep;
 
22
class x_drawable_rep;
 
23
class x_window_rep;
 
24
typedef x_gui_rep* x_gui;
 
25
typedef x_window_rep* x_window;
 
26
extern x_gui the_gui;
 
27
 
 
28
#define XK_CYRILLIC
 
29
 
 
30
#include <X11/Xlib.h>
 
31
#include <X11/X.h>
 
32
#include <X11/Xutil.h>
 
33
#include <X11/Xos.h>
 
34
#include <X11/Xatom.h>
 
35
#include <X11/keysym.h>
 
36
#include <X11/Sunkeysym.h>
 
37
 
 
38
extern bool true_color;
 
39
#define CONVERT(c) (true_color? c: gui->cmap[c])
 
40
 
 
41
/******************************************************************************
 
42
* For anti aliasing of TeX fonts
 
43
******************************************************************************/
 
44
 
 
45
struct 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
 
 
55
class 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
};
 
61
CONCRETE_CODE(x_character);
 
62
 
 
63
bool operator == (x_character xc1, x_character xc2);
 
64
bool operator != (x_character xc1, x_character xc2);
 
65
int hash (x_character xc);
 
66
 
 
67
/******************************************************************************
 
68
* Delayed messages
 
69
******************************************************************************/
 
70
 
 
71
struct 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
 
 
79
class message {
 
80
  CONCRETE(message);
 
81
  message (widget wid, string s, time_t t);
 
82
};
 
83
CONCRETE_CODE(message);
 
84
 
 
85
ostream& operator << (ostream& out, message m);
 
86
 
 
87
/******************************************************************************
 
88
* The x_gui class
 
89
******************************************************************************/
 
90
 
 
91
class x_gui_rep {
 
92
public:
 
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
  char*                        selection;
 
130
  hashmap<string,tree>         selection_t;
 
131
  hashmap<string,string>       selection_s;
 
132
 
 
133
public:
 
134
  x_gui_rep (int argc, char** argv);
 
135
  ~x_gui_rep ();
 
136
 
 
137
  /******************************* Colors ************************************/
 
138
  void prepare_color (int sfactor, color fg, color bg);
 
139
 
 
140
  /****************************** Keyboard ***********************************/
 
141
  void initialize_input_method ();
 
142
  void insert_keysym (array<int>& a, int i, int j);
 
143
  void get_xmodmap ();
 
144
  void map (int key, string s);
 
145
  void Map (int key, string s);
 
146
  void initialize_keyboard_pointer ();
 
147
  string look_up_key (XKeyEvent* ev);
 
148
  string look_up_mouse (XButtonEvent* ev);
 
149
  unsigned int get_button_mask (XButtonEvent* ev);
 
150
 
 
151
  /******************************** Fonts ************************************/
 
152
  void set_shrinking_factor (int sfactor);
 
153
  void set_default_font (string name);
 
154
  font default_font_sub (bool tt);
 
155
  font default_font (bool tt= false);
 
156
  void get_ps_char (Font fn, int c, metric& ex, glyph& gl);
 
157
  void load_system_font (string family, int size, int dpi,
 
158
                         font_metric& fnm, font_glyphs& fng);
 
159
 
 
160
  /********************* extents, grabbing, selections ***********************/
 
161
  void   get_extents (SI& width, SI& height);
 
162
  void   get_max_size (SI& width, SI& height);
 
163
  void   set_button_state (unsigned int state);
 
164
  void   emulate_leave_enter (widget old_widget, widget new_widget);
 
165
  void   obtain_mouse_grab (widget wid);
 
166
  void   release_mouse_grab ();
 
167
  bool   has_mouse_grab (widget w);
 
168
 
 
169
  /*********************** interclient communication *************************/
 
170
  void   created_window (Window win);
 
171
  void   deleted_window (Window win);
 
172
  void   focussed_window (Window win);
 
173
  bool   get_selection (string key, tree& t, string& s);
 
174
  bool   set_selection (string key, tree t, string s);
 
175
  void   clear_selection (string key);
 
176
 
 
177
  /**************************** miscellaneous ********************************/
 
178
  void   show_help_balloon (widget wid, SI x, SI y);
 
179
  void   map_balloon ();
 
180
  void   unmap_balloon ();
 
181
  void   image_auto_gc ();
 
182
  void   image_gc (string name);
 
183
  void   set_mouse_pointer (widget w, string name);
 
184
  void   set_mouse_pointer (widget w, string curs_name, string mask_name);
 
185
  void   show_wait_indicator (widget w, string message, string arg);
 
186
  bool   check_event (int type);
 
187
 
 
188
  /************************** Event processing *******************************/
 
189
  void process_event (x_window win, XEvent* ev);
 
190
  void event_loop ();
 
191
 
 
192
  /*************************** And our friends *******************************/
 
193
  friend class x_drawable_rep;
 
194
  friend class x_window_rep;
 
195
  friend class x_ps_font_rep;
 
196
  friend class x_tex_font_rep;
 
197
};
 
198
 
 
199
#endif // defined X_GUI_H