PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

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