Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Friends
x_gui_rep Class Reference

#include <x_gui.hpp>

Collaboration diagram for x_gui_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 x_gui_rep (int &argc, char **argv)
 ~x_gui_rep ()
void prepare_color (int sfactor, color fg, color bg)
void initialize_input_method ()
void insert_keysym (array< int > &a, int i, int j)
void get_xmodmap ()
void map (int key, string s)
void Map (int key, string s)
void initialize_keyboard_pointer ()
string look_up_key (XKeyEvent *ev)
string look_up_mouse (XButtonEvent *ev)
unsigned int get_button_mask (XButtonEvent *ev)
void set_shrinking_factor (int sfactor)
void set_default_font (string name)
font default_font_sub (bool tt, bool mini, bool bold)
font default_font (bool tt=false, bool mini=false, bool bold=false)
void get_ps_char (Font fn, int c, metric &ex, glyph &gl)
void load_system_font (string family, int size, int dpi, font_metric &fnm, font_glyphs &fng)
void get_extents (SI &width, SI &height)
void get_max_size (SI &width, SI &height)
void set_button_state (unsigned int state)
void emulate_leave_enter (widget old_widget, widget new_widget)
void obtain_mouse_grab (widget wid)
void release_mouse_grab ()
bool has_mouse_grab (widget w)
void created_window (Window win)
void deleted_window (Window win)
void focussed_window (Window win)
bool get_selection (string key, tree &t, string &s)
bool set_selection (string key, tree t, string s)
void clear_selection (string key)
void show_help_balloon (widget wid, SI x, SI y)
void map_balloon ()
void unmap_balloon ()
void image_auto_gc ()
void image_gc (string name)
void set_mouse_pointer (widget w, string name)
void set_mouse_pointer (widget w, string curs_name, string mask_name)
void show_wait_indicator (widget w, string message, string arg)
void external_event (string s, time_t t)
bool check_event (int type)
void process_event (x_window win, XEvent *ev)
void event_loop ()

Public Attributes

Display * dpy
GC gc
GC pixmap_gc
int scr
Window root
int screen_width
int screen_height
int depth
Colormap cols
colorcmap
bool im_ok
XIM im
list< widgetgrab_ptr
list< widgetgrab_kbd
unsigned int state
list< messagemessages
x_window_repgswindow
int argc
char ** argv
widget balloon_wid
window balloon_win
SI balloon_x
SI balloon_y
time_t balloon_time
bool interrupted
time_t interrupt_time
hashmap< x_character, pointercolor_scale
hashmap< x_character, pointercharacter_bitmap
hashmap< x_character, pointercharacter_pixmap
hashmap< string, int > xpm_bitmap
hashmap< string, int > xpm_pixmap
hashmap< int, stringlower_key
hashmap< int, stringupper_key
list< Window > windows_l
hashmap< string, treeselection_t
hashmap< string, stringselection_s
Window selection_w
Atom XA_CLIPBOARD
Atom XA_TARGETS

Friends

class x_drawable_rep
class x_window_rep
class x_ps_font_rep
class x_tex_font_rep

Detailed Description

Definition at line 91 of file x_gui.hpp.


Constructor & Destructor Documentation

x_gui_rep::x_gui_rep ( int &  argc,
char **  argv 
)

Definition at line 832 of file x_init.cpp.

                                             :
  color_scale ((void*) NULL),
  character_bitmap (NULL), character_pixmap ((pointer) 0),
  xpm_bitmap (0), xpm_pixmap (0),
  lower_key (""), upper_key (""),
  selection_t ("none"), selection_s (""), selection_w ((Window) 0)
{
  the_gui= this;
  ASSERT ((dpy= XOpenDisplay (NULL)) != NULL,
         "failure to connect to Xserver");
  // XSynchronize (dpy, true);

  XGCValues values;
  XVisualInfo visual;

  scr                = DefaultScreen (dpy);
  root               = RootWindow (dpy, scr);
  gc                 = XCreateGC (dpy, root, 0, &values);
  pixmap_gc          = XCreateGC (dpy, root, 0, &values);
  depth              = DefaultDepth (dpy, scr);
  screen_width       = DisplayWidth  (dpy, scr);
  screen_height      = DisplayHeight (dpy, scr);
  cols               = DefaultColormap (dpy, DefaultScreen (dpy));
  state              = 0;
  gswindow           = NULL;
  argc               = argc2;
  argv               = argv2;
  balloon_win        = NULL;
  interrupted        = false;
  interrupt_time     = texmacs_time ();

  XA_CLIPBOARD = XInternAtom (dpy, "CLIPBOARD", false);
  XA_TARGETS = XInternAtom (dpy, "TARGETS", false);

  if (XMatchVisualInfo (dpy, scr, depth, TrueColor, &visual) != 0) {
    if (visual.red_mask   == (255 << 16) &&
       visual.green_mask == (255 << 8) &&
       visual.blue_mask  == 255)
      true_color= true;
  }

  XSetGraphicsExposures (dpy, gc, true);

  int start= 0;
  string xmm= eval_system ("xmodmap");
  for (int i=0; i<=N(xmm); i++)
    if (i == N(xmm) || xmm[i] == '\n') {
      string s= xmm (start, i);
      if (starts (s, "mod") && N(s)>3 && s[3] >= '1' && s[3] <= '5') {
       int nr= ((int) (s[3] - '0'));
       int mask= 4 << nr;
       if (occurs ("Alt_L", s) || occurs ("Alt_R", s)) {
         //cout << "alt_mask= " << mask << "\n";
         alt_mask= mask;
       }
       else if (alt_mask == 0 && occurs ("Mode_switch", s)) {
         //cout << "alt_mask= " << mask << "\n";
         alt_mask= mask;
       }
       else if (occurs ("Meta_L", s) || occurs ("Meta_R", s)) {
         //cout << "meta_mask= " << mask << "\n";
         meta_mask= mask;
       }
       else if (meta_mask == 0 &&
               (occurs ("Super_L", s) || occurs ("Super_R", s))) {
         //cout << "meta_mask= " << mask << "\n";
         meta_mask= mask;
       }
      }
      start= i+1;
    }
  if (alt_mask == 0) alt_mask= 8;
  if (meta_mask == 0) meta_mask= 16;

  //get_xmodmap ();
  x_initialize_colors ();
  initialize_input_method ();
  initialize_keyboard_pointer ();
  set_output_language (get_locale_language ());
  (void) default_font ();
}

Here is the call graph for this function:

Definition at line 914 of file x_init.cpp.

                       {
  if (im_ok) XCloseIM (im);
  clear_selection ("primary");
  XFreeGC (dpy, gc);
  XCloseDisplay (dpy);
  if (!true_color) tm_delete_array (cmap);
}

Here is the call graph for this function:


Member Function Documentation

bool x_gui_rep::check_event ( int  type)

Definition at line 572 of file x_gui.cpp.

                                {
  bool status;
  XEvent ev;
  switch (type) {
  case INTERRUPT_EVENT:
    if (interrupted) return true;
    else {
      time_t now= texmacs_time ();
      if (now - interrupt_time < 0) return false;
      else interrupt_time= now + (100 / (XPending (dpy) + 1));
      interrupted= XCheckMaskEvent (dpy, KeyPressMask|ButtonPressMask, &ev);
      if (interrupted) XPutBackEvent (dpy, &ev);
      return interrupted;
    }
  case INTERRUPTED_EVENT:
    return interrupted;
  case ANY_EVENT:
    return (XPending (dpy)>0);
  case MOTION_EVENT:
    status= XCheckMaskEvent (dpy, PointerMotionMask, &ev);
    if (status) XPutBackEvent (dpy, &ev);
    return status;
  case DRAG_EVENT:
    status= XCheckMaskEvent (dpy, ButtonMotionMask, &ev);
    if (status) XPutBackEvent (dpy, &ev);
    return status;
  case MENU_EVENT:
    status= XCheckMaskEvent (dpy, ButtonMotionMask|ButtonReleaseMask, &ev);
    if (status) XPutBackEvent (dpy, &ev);
    return status;
  }
  return interrupted;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 289 of file x_gui.cpp.

                                      {
  selection_t->reset (key);
  selection_s->reset (key);
}

Here is the caller graph for this function:

void x_gui_rep::created_window ( Window  win)

Definition at line 202 of file x_gui.cpp.

                                     {
  windows_l << win;
}

Here is the caller graph for this function:

font x_gui_rep::default_font ( bool  tt = false,
bool  mini = false,
bool  bold = false 
)

Definition at line 193 of file x_font.cpp.

                                                      {
  font fn= default_font_sub (tt, mini, bold);
  if (!tt && !mini) the_default_wait_font= fn;
  return fn;
}

Here is the call graph for this function:

Here is the caller graph for this function:

font x_gui_rep::default_font_sub ( bool  tt,
bool  mini,
bool  bold 
)

Definition at line 139 of file x_font.cpp.

                                                          {
  string s= the_default_font;
  string series= (bold? string ("bold"): string ("medium"));
  if (s == "") s= "ecrm11@300";
  int i, j, n= N(s);
  for (j=0; j<n; j++) if ((s[j] >= '0') && (s[j] <= '9')) break;
  string fam= s (0, j);
  if (mini && fam == "ecrm") fam= "ecss";
  if (bold && fam == "ecrm") fam= "ecbx";
  if (bold && fam == "ecss") fam= "ecsx";
  for (i=j; j<n; j++) if (s[j] == '@') break;
  int sz= (j<n? as_int (s (i, j)): 10);
  if (j<n) j++;
  int dpi= (j<n? as_int (s (j, n)): 300);
  if (mini) { sz= (int) (0.6 * sz); dpi= (int) (1.3333333 * dpi); }
  if (use_macos_fonts ()) {
    tree lucida_fn= tuple ("apple-lucida", "ss", series, "right");
    lucida_fn << as_string (sz) << as_string ((int) (0.95 * dpi));
    return find_font (lucida_fn);
  }
  if (N(fam) >= 2) {
    string ff= fam (0, 2);
    string out_lan= get_output_language ();
    if (((out_lan == "bulgarian") || (out_lan == "russian") ||
        (out_lan == "ukrainian")) &&
       ((ff == "cm") || (ff == "ec"))) {
      fam= "la" * fam (2, N(fam)); ff= "la"; if (sz<100) sz *= 100; }
    if (out_lan == "japanese" || out_lan == "korean") {
      tree modern_fn= tuple ("modern", "ss", series, "right");
      modern_fn << as_string (sz) << as_string (dpi);
      return find_font (modern_fn);
    }
    if (out_lan == "chinese" || out_lan == "taiwanese")
      return unicode_font ("fireflysung", sz, dpi);
    //if (out_lan == "japanese")
    //return unicode_font ("ipagui", sz, dpi);
    //if (out_lan == "korean")
    //return unicode_font ("UnDotum", sz, dpi);
    if (ff == "ec")
      return tex_ec_font (tt? ff * "tt": fam, sz, dpi);
    if (ff == "la")
      return tex_la_font (tt? ff * "tt": fam, sz, dpi, 1000);
    if (ff == "pu") tt= false;
    if ((ff == "cm") || (ff == "pn") || (ff == "pu"))
      return tex_cm_font (tt? ff * "tt": fam, sz, dpi);
  }
  return tex_font (fam, sz, dpi);
  // if (out_lan == "german") return tex_font ("ygoth", 14, 300, 0);
  // return tex_font ("rpagk", 10, 300, 0);
  // return tex_font ("rphvr", 10, 300, 0);
  // return ps_font ("b&h-lucidabright-medium-r-normal", 11, 300);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_gui_rep::deleted_window ( Window  win)

Definition at line 207 of file x_gui.cpp.

                                     {
  windows_l= remove (windows_l, win);
}

Here is the caller graph for this function:

void x_gui_rep::emulate_leave_enter ( widget  old_widget,
widget  new_widget 
)

Definition at line 100 of file x_gui.cpp.

                                                                    {
  Window root, child;
  SI root_x, root_y, x, y;
  unsigned int mask;

  XQueryPointer (dpy, get_Window (old_widget),
               &root, &child, &root_x, &root_y, &x, &y, &mask);
  set_button_state (mask);
  x= (x * PIXEL);
  y= ((-y) * PIXEL);
  // cout << "\nLeave " << old_widget << "\n";
  send_mouse (old_widget, "leave", x, y, state, 0);
  // cout << "Leave OK\n";

  XQueryPointer (dpy, get_Window (new_widget),
               &root, &child, &root_x, &root_y, &x, &y, &mask);
  set_button_state (mask);
  x= (x * PIXEL);
  y= ((-y) * PIXEL);
  // cout << "Enter " << new_widget << "\n";
  send_mouse (new_widget, "enter", x, y, state, 0);
  // cout << "Enter OK\n\n";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 346 of file x_loop.cpp.

                       {
  bool wait  = true;
  int count  = 0;
  int delay  = MIN_DELAY;

  while (nr_windows>0 || number_of_servers () != 0) {
    request_partial_redraw= false;

    // Get events
    XEvent report;
    if (XPending (dpy) > 0) {
      XNextEvent (dpy, &report);
      if (XFilterEvent (&report, (Window) NULL) == True) continue;
      //if (string (event_name[report.type]) != "No expose")
      //cout << "Event: " << event_name[report.type] << "\n";
      x_window win= (x_window) Window_to_window[report.xany.window];
      if (win!=NULL) process_event (win, &report);
      count= 0;
      delay= MIN_DELAY;
      wait = false;
    }
    if (nr_windows == 0) continue;

    // Don't typeset when resizing window
    if (XPending (dpy) > 0)
      if (report.type == ConfigureNotify ||
         report.type == Expose ||
         report.type == NoExpose) continue;

    // Wait for events on all channels and interpose
    //time_t t1= texmacs_time ();
    if (wait) {
      struct timeval tv;
      tv.tv_sec  = delay/1000;
      tv.tv_usec = 1000 * (delay%1000);
      select (0, NULL, NULL, NULL, &tv);
      count += delay;
      if (count >= SLEEP_AFTER) delay= MAX_DELAY;
    }
    else wait= true;
    if (the_interpose_handler != NULL) the_interpose_handler ();
    if (nr_windows == 0) continue;
    //time_t t2= texmacs_time ();
    //if (t2 - t1 >= 10) cout << "interpose took " << t2-t1 << "ms\n";

    // Popup help balloons
    if (!is_nil (balloon_wid))
      if (texmacs_time () - balloon_time >= 666)
       if (balloon_win == NULL)
         map_balloon ();

    // Redraw invalid windows
    //time_t t3= texmacs_time ();
    if (XPending (dpy) == 0 || request_partial_redraw) {
      interrupted= false;
      interrupt_time= texmacs_time () + (100 / (XPending (dpy) + 1));
      iterator<Window> it= iterate (Window_to_window);
      while (it->busy()) { // first the window which has the focus
       x_window win= (x_window) Window_to_window[it->next()];
       if (win->has_focus) win->repaint_invalid_regions();
      }
      it= iterate (Window_to_window);
      while (it->busy()) { // and then the other windows
       x_window win= (x_window) Window_to_window[it->next()];
       if (!win->has_focus) win->repaint_invalid_regions();
      }
    }
    //time_t t4= texmacs_time ();
    //if (t4 - t3 >= 10) cout << "redraw took " << t4-t3 << "ms\n";

    // Handle alarm messages
    if (!is_nil (messages)) {
      list<message> not_ready;
      while (!is_nil (messages)) {
       time_t ct= texmacs_time ();
       message m= messages->item;
       if ((m->t - ct) <= 0) send_delayed_message (m->wid, m->s, m->t);
       else not_ready= list<message> (m, not_ready);
       messages= messages->next;
      }
      messages= not_ready;
    }
    
#if defined(X11TEXMACS) && defined (MACOSX_EXTENSIONS)
    process_mac_events ();
#endif
    
    
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 562 of file x_gui.cpp.

                                                {
  (void) t;
  if (!is_nil (windows_l)) {
    Window win= windows_l->item;
    x_window x_win= (x_window) Window_to_window[win];
    x_win->key_event (type);
  }
}

Here is the call graph for this function:

void x_gui_rep::focussed_window ( Window  win)

Definition at line 212 of file x_gui.cpp.

                                      {
  windows_l= list<Window> (win, remove (windows_l, win));
}

Here is the caller graph for this function:

unsigned int x_gui_rep::get_button_mask ( XButtonEvent *  ev)

Definition at line 114 of file x_loop.cpp.

                                            {
  switch (ev->button) {
  case Button1: return Button1Mask;
  case Button2: return Button2Mask;
  case Button3: return Button3Mask;
  case Button4: return Button4Mask;
  case Button5: return Button5Mask;
  default: return 0;
  }
}

Here is the caller graph for this function:

void x_gui_rep::get_extents ( SI width,
SI height 
)

Definition at line 817 of file x_init.cpp.

Here is the caller graph for this function:

void x_gui_rep::get_max_size ( SI width,
SI height 
)

Definition at line 823 of file x_init.cpp.

                                              {
  width = 8000 * PIXEL;
  height= 6000 * PIXEL;
}

Here is the caller graph for this function:

void x_gui_rep::get_ps_char ( Font  fn,
int  c,
metric ex,
glyph gl 
)

Definition at line 214 of file x_font.cpp.

                                                             {
  XCharStruct xcs;
  int i1, i2, i3;
  char temp[1]; temp[0]= (char) c;

  XQueryTextExtents (dpy, fn, temp, 1, &i1, &i2, &i3, &xcs);
  ex->x1= 0;
  ex->y1= (-1-xcs.descent) * PIXEL;
  ex->x2= xcs.width * PIXEL;
  ex->y2= (-1+xcs.ascent) * PIXEL;
  ex->x3= xcs.lbearing * PIXEL;
  ex->y3= (-1-xcs.descent) * PIXEL;
  ex->x4= xcs.rbearing * PIXEL;
  ex->y4= (-1+xcs.ascent) * PIXEL;

  int w   = xcs.rbearing- xcs.lbearing;
  int h   = xcs.ascent+ xcs.descent;
  int xoff=  -xcs.lbearing;
  int yoff= h-xcs.descent ;
  if ((w == 0) || (h == 0)) return;

  Pixmap pm= XCreatePixmap (dpy, root, w, h, depth);
  XSetForeground (dpy, pixmap_gc, white);
  XFillRectangle (dpy, pm, pixmap_gc, 0, 0, w, h);
  XSetForeground (dpy, pixmap_gc, black);
  XSetFont (dpy, pixmap_gc, fn);
  XDrawString (dpy, pm, pixmap_gc, xoff, yoff, temp, 1);
  XImage* im= XGetImage (dpy, pm, 0, 0, w, h, 0xffffffff, ZPixmap);

  int i, j;
  gl= glyph (w, h, xoff, yoff);
  for (j=0; j<h; j++)
    for (i=0; i<w; i++) {
      int c = im->f.get_pixel (im, i, j);
      int on= (((color) c) == black? 1: 0);
      gl->set_x (i, j, on);
    }
  gl->lwidth= xcs.width;

  im->f.destroy_image (im);
  XFreePixmap (dpy, pm);
}

Here is the caller graph for this function:

bool x_gui_rep::get_selection ( string  key,
tree t,
string s 
)

Definition at line 217 of file x_gui.cpp.

                                                        {
  t= "none";
  s= "";
  bool res=false;

  if (selection_t->contains (key)) {
    t= copy (selection_t [key]);
    s= copy (selection_s [key]);
    return true;
  }
  
  Atom xsel;
  if (key == "primary") xsel = XA_CLIPBOARD;
  else if (key == "mouse") xsel = XA_PRIMARY;
  else return res;

  Window selown = XGetSelectionOwner(dpy, xsel);
  if (selown == None ||
      is_nil (windows_l) ||
      contains (windows_l, selown)) return res;

  Window win= windows_l->item;
  x_window x_win= (x_window) Window_to_window[win];
  Atom prop= XInternAtom (dpy, "MY_STRING_SELECTION", false);
  XConvertSelection (dpy, xsel, XA_STRING, prop, win, CurrentTime);

  int i;
  XEvent ev;
  for (i=0; i<1000000; i++)
    if (XCheckIfEvent (dpy, &ev, my_selnotify_predicate, (XPointer) x_win))
      break;
  if (i==1000000) return res;
  XSelectionEvent& sel= ev.xselection;

  if (sel.property==prop) {
    long offset=0;
    Atom type;
    int fm;
    unsigned long n, remains;
    unsigned char* ret;
    
    do {
      XGetWindowProperty (dpy, win, sel.property,
                       offset, 1024, true, AnyPropertyType,
                       &type, &fm, &n, &remains, &ret);
      s << string ((char*) ret, n);
      offset += (n >> 2);
      XFree (ret);
    } while (remains>0);
    t= tuple ("extern", s);
    return true;
  }
  else return res;
}

Here is the call graph for this function:

Definition at line 309 of file x_init.cpp.

                        {
  int i;
  xmodmap= XGetModifierMapping (dpy);
  mod_n= xmodmap->max_keypermod;
  mod_k= xmodmap->modifiermap;
  for (i=0; i<mod_n; i++) {
    insert_keysym (mod_shift, 0, i);
    insert_keysym (mod_shift, 1, i);
    insert_keysym (mod_ctrl, 2, i);
    insert_keysym (mod_alt, 3, i);
  }
  XFreeModifiermap (xmodmap);
}

Here is the call graph for this function:

Definition at line 187 of file x_gui.cpp.

                                   {
  return (!is_nil (grab_ptr)) && (grab_ptr->item == w);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 450 of file x_drawable.cpp.

                          {
  time_t time= texmacs_time ();
  if (time-cache_image_last_gc <= 300000) return;
  cache_image_last_gc= time;
  if (DEBUG_AUTO)
    cout << "TeXmacs] Launching garbage collection for unused pictures\n";

  iterator<tree> it= iterate (cache_image);
  while (it->busy()) {
    tree lookup= it->next();
    int diff= time- cache_image_time [lookup];
    int fact= cache_image_nr [lookup];
    fact= fact * fact * fact;
    if (cache_image_w [lookup] * cache_image_h [lookup] < 400) fact= fact * 5;
    if (cache_image_w [lookup] * cache_image_h [lookup] < 6400) fact= fact * 5;
    if (diff/fact > 60000) {
      Pixmap pm= (Pixmap) cache_image [lookup];
      XFreePixmap (dpy, pm);
      cache_image->reset (lookup);
      cache_image_w->reset (lookup);
      cache_image_h->reset (lookup);
      cache_image_time->reset (lookup);
      ps_bbox->reset (lookup[0]);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_gui_rep::image_gc ( string  name)

Definition at line 478 of file x_drawable.cpp.

                                {
  (void) name;
  cache_image_last_gc= texmacs_time ();
  iterator<tree> it= iterate (cache_image);
  while (it->busy()) {
    tree lookup= it->next();
    if (!is_ramdisc (as_url (lookup[0]))) {
      Pixmap pm= (Pixmap) cache_image [lookup];
      XFreePixmap (dpy, pm);
      cache_image->reset (lookup);
      cache_image_w->reset (lookup);
      cache_image_h->reset (lookup);
      cache_image_time->reset (lookup);
      cache_image_nr->reset (lookup);
      ps_bbox->reset (lookup[0]);
    }
  }
}

Here is the call graph for this function:

Definition at line 272 of file x_init.cpp.

                                    {
  im_ok= false;
  if (setlocale (LC_CTYPE, "") == NULL)
    cerr << "TeXmacs] Warning: locale could not be set\n";
  else {
    if (!XSetLocaleModifiers (""))
      cerr << "TeXmacs] Warning: could not set locale modifiers\n";
    if (XSupportsLocale () == False)
      cerr << "TeXmacs] Warning: locale is not supported\n";
    else if ((im = XOpenIM (dpy, NULL, NULL, NULL)) == NULL)
      cout << "TeXmacs] Warning: could not open input method\n";
    else im_ok= true;
  }
}

Here is the caller graph for this function:

Definition at line 340 of file x_init.cpp.

                                        {
  // Latin characters
  Map (XK_a, "a");
  Map (XK_b, "b");
  Map (XK_c, "c");
  Map (XK_d, "d");
  Map (XK_e, "e");
  Map (XK_f, "f");
  Map (XK_g, "g");
  Map (XK_h, "h");
  Map (XK_i, "i");
  Map (XK_j, "j");
  Map (XK_k, "k");
  Map (XK_l, "l");
  Map (XK_m, "m");
  Map (XK_n, "n");
  Map (XK_o, "o");
  Map (XK_p, "p");
  Map (XK_q, "q");
  Map (XK_r, "r");
  Map (XK_s, "s");
  Map (XK_t, "t");
  Map (XK_u, "u");
  Map (XK_v, "v");
  Map (XK_w, "w");
  Map (XK_x, "x");
  Map (XK_y, "y");
  Map (XK_z, "z");
  Map (XK_A, "A");
  Map (XK_B, "B");
  Map (XK_C, "C");
  Map (XK_D, "D");
  Map (XK_E, "E");
  Map (XK_F, "F");
  Map (XK_G, "G");
  Map (XK_H, "H");
  Map (XK_I, "I");
  Map (XK_J, "J");
  Map (XK_K, "K");
  Map (XK_L, "L");
  Map (XK_M, "M");
  Map (XK_N, "N");
  Map (XK_O, "O");
  Map (XK_P, "P");
  Map (XK_Q, "Q");
  Map (XK_R, "R");
  Map (XK_S, "S");
  Map (XK_T, "T");
  Map (XK_U, "U");
  Map (XK_V, "V");
  Map (XK_W, "W");
  Map (XK_X, "X");
  Map (XK_Y, "Y");
  Map (XK_Z, "Z");
  Map (XK_0, "0");
  Map (XK_1, "1");
  Map (XK_2, "2");
  Map (XK_3, "3");
  Map (XK_4, "4");
  Map (XK_5, "5");
  Map (XK_6, "6");
  Map (XK_7, "7");
  Map (XK_8, "8");
  Map (XK_9, "9");

  // Cyrillic letters
  Map (XK_Cyrillic_a,   "\xe0");
  Map (XK_Cyrillic_be,  "\xe1");
  Map (XK_Cyrillic_ve,  "\xe2");
  Map (XK_Cyrillic_ghe, "\xe3");
  Map (XK_Cyrillic_de,  "\xe4");
  Map (XK_Cyrillic_ie,  "\xe5");
  Map (XK_Cyrillic_io,  "\xbc");
  Map (XK_Cyrillic_zhe, "\xe6");
  Map (XK_Cyrillic_ze,  "\xe7");
  Map (XK_Cyrillic_i,   "\xe8");
  Map (XK_Cyrillic_shorti,   "\xe9");
  Map (XK_Cyrillic_ka,  "\xea");
  Map (XK_Cyrillic_el,  "\xeb");
  Map (XK_Cyrillic_em,  "\xec");
  Map (XK_Cyrillic_en,  "\xed");
  Map (XK_Cyrillic_o,   "\xee");
  Map (XK_Cyrillic_pe,  "\xef");
  Map (XK_Cyrillic_er,  "\xf0");
  Map (XK_Cyrillic_es,  "\xf1");
  Map (XK_Cyrillic_te,  "\xf2");
  Map (XK_Cyrillic_u,   "\xf3");
  Map (XK_Cyrillic_ef,  "\xf4");
  Map (XK_Cyrillic_ha,  "\xf5");
  Map (XK_Cyrillic_tse, "\xf6");
  Map (XK_Cyrillic_che, "\xf7");
  Map (XK_Cyrillic_sha, "\xf8");
  Map (XK_Cyrillic_shcha,    "\xf9");
  Map (XK_Cyrillic_hardsign, "\xfa");
  Map (XK_Cyrillic_yeru,     "\xfb");
  Map (XK_Cyrillic_softsign, "\xfc");
  Map (XK_Cyrillic_e,   "\xfd");
  Map (XK_Cyrillic_yu,  "\xfe");
  Map (XK_Cyrillic_ya,  "\xff");
  Map (XK_Cyrillic_A,   "\xc0");
  Map (XK_Cyrillic_BE,  "\xc1");
  Map (XK_Cyrillic_VE,  "\xc2");
  Map (XK_Cyrillic_GHE, "\xc3");
  Map (XK_Cyrillic_DE,  "\xc4");
  Map (XK_Cyrillic_IE,  "\xc5");
  Map (XK_Cyrillic_IO,  "\x9c");
  Map (XK_Cyrillic_ZHE, "\xc6");
  Map (XK_Cyrillic_ZE,  "\xc7");
  Map (XK_Cyrillic_I,   "\xc8");
  Map (XK_Cyrillic_SHORTI,   "\xc9");
  Map (XK_Cyrillic_KA,  "\xca");
  Map (XK_Cyrillic_EL,  "\xcb");
  Map (XK_Cyrillic_EM,  "\xcc");
  Map (XK_Cyrillic_EN,  "\xcd");
  Map (XK_Cyrillic_O,   "\xce");
  Map (XK_Cyrillic_PE,  "\xcf");
  Map (XK_Cyrillic_ER,  "\xd0");
  Map (XK_Cyrillic_ES,  "\xd1");
  Map (XK_Cyrillic_TE,  "\xd2");
  Map (XK_Cyrillic_U,   "\xd3");
  Map (XK_Cyrillic_EF,  "\xd4");
  Map (XK_Cyrillic_HA,  "\xd5");
  Map (XK_Cyrillic_TSE, "\xd6");
  Map (XK_Cyrillic_CHE, "\xd7");
  Map (XK_Cyrillic_SHA, "\xd8");
  Map (XK_Cyrillic_SHCHA,    "\xd9");
  Map (XK_Cyrillic_HARDSIGN, "\xda");
  Map (XK_Cyrillic_YERU,     "\xdb");
  Map (XK_Cyrillic_SOFTSIGN, "\xdc");
  Map (XK_Cyrillic_E,   "\xdd");
  Map (XK_Cyrillic_YU,  "\xde");
  Map (XK_Cyrillic_YA,  "\xdf");

  //Ukrainian letters in T2A encoding
  Map (XK_Ukrainian_i,   "i"); // Fall back!
  Map (XK_Ukrainian_I,   "I"); // Fall back!
  Map (XK_Ukrainian_yi,   "\xa8");
  Map (XK_Ukrainian_YI,   "\x88");
  Map (XK_Ukrainian_ie,   "\xb9");
  Map (XK_Ukrainian_IE,   "\x99");
  // Map (XK_Ukrainian_ghe_with_upturn,   "\xa0");
  // Map (XK_Ukrainian_GHE_WITH_UPTURN,   "\x80");
  Map (0x6ad,   "\xa0");
  Map (0x6bd,   "\x80");

  // Standard ASCII Symbols
  Map (XK_exclam, "!");
  Map (XK_quotedbl, "\x22");
  Map (XK_numbersign, "#");
  Map (XK_dollar, "$");
  Map (XK_percent, "%");
  Map (XK_ampersand, "&");
  Map (XK_apostrophe, "'");
  Map (XK_quoteright, "'");
  Map (XK_parenleft, "(");
  Map (XK_parenright, ")");
  Map (XK_asterisk, "*");
  Map (XK_plus, "+");
  Map (XK_comma, ",");
  Map (XK_minus, "-");
  Map (XK_period, ".");
  Map (XK_slash, "/");
  Map (XK_colon, ":");
  Map (XK_semicolon, ";");
  Map (XK_less, "<");
  Map (XK_equal, "=");
  Map (XK_greater, ">");
  Map (XK_question, "?");
  Map (XK_at, "@");
  Map (XK_bracketleft, "[");
  Map (XK_backslash, "\\");
  Map (XK_bracketright, "]");
  Map (XK_asciicircum, "^");
  Map (XK_underscore, "_");
  Map (XK_grave, "`");
  Map (XK_quoteleft, "`");
  Map (XK_braceleft, "{");
  Map (XK_bar, "|");
  Map (XK_braceright, "}");
  Map (XK_asciitilde, "~");

  // dead keys
  Map (0xFE50, "grave");
  Map (0xFE51, "acute");
  Map (0xFE52, "hat");
  Map (0xFE53, "tilde");
  Map (0xFE54, "macron");
  Map (0xFE55, "breve");
  Map (0xFE56, "abovedot");
  Map (0XFE57, "umlaut");
  Map (0xFE58, "abovering");
  Map (0xFE59, "doubleacute");
  Map (0xFE5A, "check");
  Map (0xFE5B, "cedilla");
  Map (0xFE5C, "ogonek");
  Map (0xFE5D, "iota");
  Map (0xFE5E, "voicedsound");
  Map (0xFE5F, "semivoicedsound");
  Map (0xFE60, "belowdot");

  // Extended symbols and accented characters
  Map (XK_nobreakspace, "varspace");
  Map (XK_exclamdown, "exclamdown");
  Map (XK_cent, "cent");
  Map (XK_sterling, "sterling");
  Map (XK_currency, "currency");
  Map (XK_yen, "yen");
  Map (XK_brokenbar, "brokenbar");
  Map (XK_section, "section");
  Map (XK_diaeresis, "umlaut");
  Map (XK_copyright, "copyright");
  Map (XK_ordfeminine, "ordfeminine");
  Map (XK_guillemotleft, "guillemotleft");
  Map (XK_notsign, "notsign");
  Map (XK_hyphen, "hyphen");
  Map (XK_registered, "registered");
  Map (XK_macron, "macron");
  Map (XK_degree, "degree");
  Map (XK_plusminus, "plusminus");
  Map (XK_twosuperior, "twosuperior");
  Map (XK_threesuperior, "threesuperior");
  Map (XK_acute, "acute");
  Map (XK_mu, "mu");
  Map (XK_paragraph, "paragraph");
  Map (XK_periodcentered, "periodcentered");
  Map (XK_cedilla, "cedilla");
  Map (XK_onesuperior, "onesuperior");
  Map (XK_masculine, "masculine");
  Map (XK_guillemotright, "guillemotright");
  Map (XK_onequarter, "onequarter");
  Map (XK_onehalf, "onehalf");
  Map (XK_threequarters, "threequarters");
  Map (XK_questiondown, "questiondown");
  Map (XK_multiply, "times");
  Map (XK_division, "div");

  Map (XK_Agrave, "\xc0");
  Map (XK_Aacute, "\xc1");
  Map (XK_Acircumflex, "\xc2");
  Map (XK_Atilde, "\xc3");
  Map (XK_Adiaeresis, "\xc4");
  Map (XK_Aring, "\xc5");
  Map (XK_AE, "\xc6");
  Map (XK_Ccedilla, "\xc7");
  Map (XK_Egrave, "\xc8");
  Map (XK_Eacute, "\xc9");
  Map (XK_Ecircumflex, "\xca");
  Map (XK_Ediaeresis, "\xcb");
  Map (XK_Igrave, "\xcc");
  Map (XK_Iacute, "\xcd");
  Map (XK_Icircumflex, "\xce");
  Map (XK_Idiaeresis, "\xcf");
  Map (XK_ETH, "\xd0");
  Map (XK_Eth, "\xd0");
  Map (XK_Ntilde, "\xd1");
  Map (XK_Ograve, "\xd2");
  Map (XK_Oacute, "\xd3");
  Map (XK_Ocircumflex, "\xd4");
  Map (XK_Otilde, "\xd5");
  Map (XK_Odiaeresis, "\xd6");
  Map (XK_OE, "\xd7");
  Map (XK_Ooblique, "\xd8");
  Map (XK_Ugrave, "\xd9");
  Map (XK_Uacute, "\xda");
  Map (XK_Ucircumflex, "\xdb");
  Map (XK_Udiaeresis, "\xdc");
  Map (XK_Yacute, "\xdd");
  Map (XK_THORN, "\xde");
  Map (XK_Thorn, "\xde");
  Map (XK_ssharp, "sz");
  Map (XK_agrave, "\xe0");
  Map (XK_aacute, "\xe1");
  Map (XK_acircumflex, "\xe2");
  Map (XK_atilde, "\xe3");
  Map (XK_adiaeresis, "\xe4");
  Map (XK_aring, "\xe5");
  Map (XK_ae, "\xe6");
  Map (XK_ccedilla, "\xe7");
  Map (XK_egrave, "\xe8");
  Map (XK_eacute, "\xe9");
  Map (XK_ecircumflex, "\xea");
  Map (XK_ediaeresis, "\xeb");
  Map (XK_igrave, "\xec");
  Map (XK_iacute, "\xed");
  Map (XK_icircumflex, "\xee");
  Map (XK_idiaeresis, "\xef");
  Map (XK_eth, "\xf0");
  Map (XK_ntilde, "\xf1");
  Map (XK_ograve, "\xf2");
  Map (XK_oacute, "\xf3");
  Map (XK_ocircumflex, "\xf4");
  Map (XK_otilde, "\xf5");
  Map (XK_odiaeresis, "\xf6");
  Map (XK_oe, "\xf7");
  Map (XK_oslash, "\xf8");
  Map (XK_ugrave, "\xf9");
  Map (XK_uacute, "\xfa");
  Map (XK_ucircumflex, "\xfb");
  Map (XK_udiaeresis, "\xfc");
  Map (XK_yacute, "\xfd");
  Map (XK_thorn, "\xfe");
  Map (XK_ydiaeresis, "\xff");

  // Symbols from iso-latin-2
  Map (XK_Aogonek, "\x81");
  Map (XK_breve, "breve");
  Map (XK_Lstroke, "\x8a");
  Map (XK_Lcaron, "\x89");
  Map (XK_Sacute, "\x91");
  Map (XK_Scaron, "\x92");
  Map (XK_Scedilla, "\x93");
  Map (XK_Tcaron, "\x94");
  Map (XK_Zacute, "\x99");
  Map (XK_Zcaron, "\x9a");
  Map (XK_Zabovedot, "\x9b");
  Map (XK_aogonek, "\xa1");
  Map (XK_ogonek, "ogonek");
  Map (XK_lstroke, "\xaa");
  Map (XK_lcaron, "\xa9");
  Map (XK_sacute, "\xb1");
  Map (XK_caron, "caron");
  Map (XK_scaron, "\xb2");
  Map (XK_scedilla, "\xb3");
  Map (XK_tcaron, "\xb4");
  Map (XK_zacute, "\xb9");
  Map (XK_doubleacute, "doubleacute");
  Map (XK_zcaron, "\xba");
  Map (XK_zabovedot, "\xbb");
  Map (XK_Racute, "\x8f");
  Map (XK_Abreve, "\x80");
  Map (XK_Lacute, "\x88");
  Map (XK_Cacute, "\x82");
  Map (XK_Ccaron, "\x83");
  Map (XK_Eogonek, "\x86");
  Map (XK_Ecaron, "\x85");
  Map (XK_Dcaron, "\x84");
  Map (XK_Dstroke, "\xd0");
  Map (XK_Nacute, "\x8b");
  Map (XK_Ncaron, "\x8c");
  Map (XK_Odoubleacute, "\x8e");
  Map (XK_Rcaron, "\x90");
  Map (XK_Uring, "\x97");
  Map (XK_Udoubleacute, "\x96");
  Map (XK_Tcedilla, "\x95");
  Map (XK_racute, "\xaf");
  Map (XK_abreve, "\xa0");
  Map (XK_lacute, "\xa8");
  Map (XK_cacute, "\xa2");
  Map (XK_ccaron, "\xa3");
  Map (XK_eogonek, "\xa6");
  Map (XK_ecaron, "\xa5");
  Map (XK_dcaron, "\xa4");
  Map (XK_dstroke, "\x9e");
  Map (XK_nacute, "\xab");
  Map (XK_ncaron, "\xac");
  Map (XK_odoubleacute, "\xae");
  Map (XK_udoubleacute, "\xb6");
  Map (XK_rcaron, "\xb0");
  Map (XK_uring, "\xb7");
  Map (XK_tcedilla, "\xb5");
  Map (XK_abovedot, "abovedot");

  // Special control keys
  Map (XK_Prior, "pageup");
  Map (XK_Next, "pagedown");
  Map (XK_Undo, "undo");
  Map (XK_Redo, "redo");
  Map (XK_Cancel, "cancel");

  // Control keys
  map (XK_space, "space");
  map (XK_Return, "return");
  map (XK_BackSpace, "backspace");
  map (XK_Delete, "delete");
  map (XK_Insert, "insert");
  map (XK_Tab, "tab");
  map (XK_ISO_Left_Tab, "tab");
  map (XK_Escape, "escape");
  map (XK_Left, "left");
  map (XK_Right, "right");
  map (XK_Up, "up");
  map (XK_Down, "down");
  map (XK_Page_Up, "pageup");
  map (XK_Page_Down, "pagedown");
  map (XK_Home, "home");
  map (XK_End, "end");
  map (XK_F1, "F1");
  map (XK_F2, "F2");
  map (XK_F3, "F3");
  map (XK_F4, "F4");
  map (XK_F5, "F5");
  map (XK_F6, "F6");
  map (XK_F7, "F7");
  map (XK_F8, "F8");
  map (XK_F9, "F9");
  map (XK_F10, "F10");
  map (XK_F11, "F11");
  map (XK_F12, "F12");
  map (XK_F13, "F13");
  map (XK_F14, "F14");
  map (XK_F15, "F15");
  map (XK_F16, "F16");
  map (XK_F17, "F17");
  map (XK_F18, "F18");
  map (XK_F19, "F19");
  map (XK_F20, "F20");
  // map (XK_Mode_switch, "modeswitch");

  // Keypad keys
  Map (XK_KP_Space, "K-space");
  Map (XK_KP_Enter, "K-return");
  Map (XK_KP_Delete, "K-delete");
  Map (XK_KP_Insert, "K-insert");
  Map (XK_KP_Tab, "K-tab");
  Map (XK_KP_Left, "K-left");
  Map (XK_KP_Right, "K-right");
  Map (XK_KP_Up, "K-up");
  Map (XK_KP_Down, "K-down");
  Map (XK_KP_Page_Up, "K-pageup");
  Map (XK_KP_Page_Down, "K-pagedown");
  Map (XK_KP_Home, "K-home");
  Map (XK_KP_Begin, "K-begin");
  Map (XK_KP_End, "K-end");
  Map (XK_KP_F1, "K-F1");
  Map (XK_KP_F2, "K-F2");
  Map (XK_KP_F3, "K-F3");
  Map (XK_KP_F4, "K-F4");
  Map (XK_KP_Equal, "K-=");
  Map (XK_KP_Multiply, "K-*");
  Map (XK_KP_Add, "K-+");
  Map (XK_KP_Subtract, "K--");
  Map (XK_KP_Decimal, "K-.");
  Map (XK_KP_Separator, "K-,");
  Map (XK_KP_Divide, "K-/");
  Map (XK_KP_0, "K-0");
  Map (XK_KP_1, "K-1");
  Map (XK_KP_2, "K-2");
  Map (XK_KP_3, "K-3");
  Map (XK_KP_4, "K-4");
  Map (XK_KP_5, "K-5");
  Map (XK_KP_6, "K-6");
  Map (XK_KP_7, "K-7");
  Map (XK_KP_8, "K-8");
  Map (XK_KP_9, "K-9");

  // For Sun keyboards
  Map (SunXK_FA_Grave, "grave");
  Map (SunXK_FA_Circum, "hat");
  Map (SunXK_FA_Tilde, "tilde");
  Map (SunXK_FA_Acute, "acute");
  Map (SunXK_FA_Diaeresis, "umlaut");
  Map (SunXK_FA_Cedilla, "cedilla");
  Map (SunXK_F36, "F11");
  Map (SunXK_F37, "F12");
  Map (SunXK_Copy, "copy");
  Map (SunXK_Paste, "paste");
  Map (SunXK_Cut, "cut");
  // Map (XK_L1, "stop");   On Sun, but conflicts with F11
  // Map (XK_L2, "again");  On Sun, but conflicts with F12
  Map (XK_L3, "props");
  Map (XK_L4, "undo");
  Map (XK_L5, "front");
  Map (XK_L6, "copy");
  Map (XK_L7, "open");
  Map (XK_L8, "paste");
  Map (XK_L9, "find");
  Map (XK_L10, "cut");

  // Miscellaneous
  Map (0x20ac, "euro");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_gui_rep::insert_keysym ( array< int > &  a,
int  i,
int  j 
)

Definition at line 303 of file x_init.cpp.

                                                     {
  int ks= XKeycodeToKeysym (dpy, mod_k[i*mod_n+j], 0);
  if (ks!=0) a << ks;
}

Here is the caller graph for this function:

void x_gui_rep::load_system_font ( string  family,
int  size,
int  dpi,
font_metric fnm,
font_glyphs &  fng 
)

Definition at line 258 of file x_font.cpp.

{
  string fn_name= "ps:" * family * as_string (size) * "@" * as_string (dpi);
  if (font_metric::instances -> contains (fn_name)) {
    fnm= font_metric (fn_name);
    fng= font_glyphs (fn_name);
  }

  string name= "-" * family;
  string sz1= as_string ((size*dpi)/72);
  string sz2= as_string (10*((size*dpi)/72));
  name << "-*-" * sz1 * "-" * sz2 * "-*-*-*-*-*-*";
  if (size == 0) name= family;

  if (DEBUG_VERBOSE) cout << "TeXmacs] Loading ps font " << name << "\n";
  char* temp= as_charp (name);
  XFontStruct *xfs = XLoadQueryFont (dpy, temp);
  tm_delete_array (temp);
  if (xfs == NULL) {
    if (DEBUG_VERBOSE) cout << "TeXmacs] Font " << name << " not found\n";
    if (DEBUG_VERBOSE) cout << "TeXmacs] Using default font instead\n";
    xfs = XLoadQueryFont (dpy, "*");
    ASSERT (xfs != NULL, "could not load default X font");
  }
  Font fn = xfs->fid;
  int i;
  metric* texs= tm_new_array<metric> (256);
  glyph * gls = tm_new_array<glyph> (256);
  for (i=0; i<=255; i++)
    get_ps_char (fn, i, texs[i], gls[i]);
  fnm= std_font_metric (fn_name, texs, 0, 255);
  fng= std_font_glyphs (fn_name, gls , 0, 255);

  XFreeFont(dpy, xfs);
}

Here is the call graph for this function:

string x_gui_rep::look_up_key ( XKeyEvent *  ev)

Definition at line 74 of file x_loop.cpp.

                                     {
  KeySym key= 0;
  //cout << ev->state << ", " << ev->keycode << LF;

  if (im_ok) {
    x_window win= (x_window) Window_to_window[ev->window];
    char str[256];
    Status status;
    int count = Xutf8LookupString (win->ic, (XKeyPressedEvent*) ev,
                               str, 256, &key, &status);
    string r (str, count);
    r= utf8_to_cork (r);
    if (contains_unicode_char (r)) return r;
  }
  else XLookupString (ev, NULL, 0, &key, NULL);
  string s= ((ev->state&1)? upper_key [key]: lower_key [key]);
  if ((N(s)>=2) && (s[0]=='K') && (s[1]=='-')) s= s (2, N(s));

  /* other keyboard modifiers */
  if (N(s)==0) return s;
  if (ev->state & 4) s= "C-" * s;
  if (ev->state & alt_mask) s= "A-" * s;
  if (ev->state & meta_mask) s= "M-" * s;
  // cout << "key press: " << s << LF;
  return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string x_gui_rep::look_up_mouse ( XButtonEvent *  ev)

Definition at line 102 of file x_loop.cpp.

                                          {
  switch (ev->button) {
  case Button1: return "left";
  case Button2: return "middle";
  case Button3: return "right";
  case Button4: return "up";
  case Button5: return "down";
  default: return "unknown";
  }
}

Here is the caller graph for this function:

void x_gui_rep::map ( int  key,
string  s 
)

Definition at line 328 of file x_init.cpp.

                                 {
  lower_key (key)= s;
  upper_key (key)= "S-" * s;
}

Here is the caller graph for this function:

void x_gui_rep::Map ( int  key,
string  s 
)

Definition at line 334 of file x_init.cpp.

                                 {
  lower_key (key)= s;
  upper_key (key)= s;
}

Here is the caller graph for this function:

Definition at line 517 of file x_gui.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 147 of file x_gui.cpp.

                                        {
  Window win= get_Window (wid);
  if ((!is_nil (grab_ptr)) && (wid==grab_ptr->item)) return;
  widget old_widget; if (!is_nil (grab_ptr)) old_widget= grab_ptr->item;
  grab_ptr= list<widget> (wid, grab_ptr);
  widget new_widget= grab_ptr->item;
  notify_mouse_grab (new_widget, true);
  XGrabPointer (dpy, win, false,
              PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
              GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
  // cout << "\n---> In grab " << pritty ((tree) wid) << "\n\n";
  if (!is_nil (old_widget)) {
    notify_mouse_grab (old_widget, false);
    emulate_leave_enter (old_widget, new_widget);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_gui_rep::prepare_color ( int  sfactor,
color  fg,
color  bg 
)

Definition at line 53 of file x_gui.cpp.

                                                    {
  int nr_cols= sf*sf;
  if (nr_cols >= 64) nr_cols= 64;
  x_character col_entry (0, font_glyphs (), sf, fg, bg);
  color* cols= (color*) color_scale [col_entry];
  if (cols == NULL) {
    int fR, fG, fB, fA, bR, bG, bB, bA, j;
    get_rgb_color (fg, fR, fG, fB, fA);
    get_rgb_color (bg, bR, bG, bB, bA);
    if (fA != 255) {
      fR= (bR * (255 - fA) + fR * fA) / 255;
      fG= (bG * (255 - fA) + fG * fA) / 255;
      fB= (bB * (255 - fA) + fB * fA) / 255;
    }
    cols= tm_new_array<color> (nr_cols+1);
    for (j=0; j<=nr_cols; j++)
      cols [nr_cols-j]= rgb_color ((bR*j + fR*(nr_cols-j)) / nr_cols,
                               (bG*j + fG*(nr_cols-j)) / nr_cols,
                               (bB*j + fB*(nr_cols-j)) / nr_cols);
    color_scale (col_entry)= (void*) cols;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_gui_rep::process_event ( x_window  win,
XEvent *  ev 
)

Definition at line 169 of file x_loop.cpp.

                                                  {
  //if (ev->type != NoExpose)
  //cout << "Event: " << event_name[ev->type] << "\n";
  switch (ev->type) {
  case Expose:
    {
      XExposeEvent& ee= ev->xexpose;
      /*
      cout << "Expose: " << ee.x << "," << ee.y << ","
           << ee.x+ee.width << "," << ee.y+ee.height << "\n";
      */
      win->invalidate_event (ee.x, ee.y, ee.x+ee.width, ee.y+ee.height);
      break;
    }
  case GraphicsExpose:
    {
      XGraphicsExposeEvent& ee= ev->xgraphicsexpose;
      /*
      cout << "Expose: " << ee.x << "," << ee.y << ","
          << ee.x+ee.width << "," << ee.y+ee.height << "\n";
          */
      win->invalidate_event (ee.x, ee.y, ee.x+ee.width, ee.y+ee.height);
      break;
    }
  case NoExpose:
    // cout << "No expose\n";
    break;
  case ConfigureNotify:
    /*
    cout << "Configure move  : " << ev->xconfigure.x << ","
        << ev->xconfigure.y << "\n";
    cout << "Configure resize: " << ev->xconfigure.width << ","
        << ev->xconfigure.height << "\n";
        */
    /*
    if ((ev->xconfigure.x!=0) || (ev->xconfigure.y!=0) ||
       ((ev->xconfigure.width == win->win_w) &&
        (ev->xconfigure.height == win->win_h)))
    */
    win->move_event (ev->xconfigure.x, ev->xconfigure.y);
    win->resize_event (ev->xconfigure.width, ev->xconfigure.height);
    break;
  case CreateNotify:
    break;
  case DestroyNotify:
    // cout << "Destroy\n";
    // win->destroy_event ();
    // event_loop ();
    // exit (0);
    break;
  case UnmapNotify:
    // cout << "Unmap\n";
    break;
  case ButtonPress:
    unmap_balloon ();
    set_button_state (ev->xbutton.state ^ get_button_mask (&ev->xbutton));
    win->mouse_event ("press-" * look_up_mouse (&ev->xbutton),
                    ev->xbutton.x, ev->xbutton.y, ev->xbutton.time);
    break;
  case ButtonRelease:
    unmap_balloon ();
    set_button_state (ev->xbutton.state ^ get_button_mask (&ev->xbutton));
    win->mouse_event ("release-" * look_up_mouse (&ev->xbutton),
                    ev->xbutton.x, ev->xbutton.y, ev->xbutton.time);
    break;
  case EnterNotify:
    unmap_balloon ();
    if (ev->xcrossing.mode == NotifyNormal) {
      // cout << "Enter at (" <<ev->xcrossing.x<<","<<ev->xcrossing.y << ")\n";
      set_button_state (ev->xcrossing.state);
      win->mouse_event ("enter", ev->xcrossing.x, ev->xcrossing.y,
                     ev->xcrossing.time);
    }
    break;
  case LeaveNotify:
    unmap_balloon ();
    if (ev->xcrossing.mode == NotifyNormal) {
      // cout << "Leave at (" <<ev->xcrossing.x<<","<<ev->xcrossing.y << ")\n";
      set_button_state (ev->xcrossing.state);
      win->mouse_event ("leave", ev->xcrossing.x, ev->xcrossing.y,
                     ev->xcrossing.time);
    }
    break;
  case FocusIn:
    win->focus_in_event ();
    break;
  case FocusOut:
    win->focus_out_event ();
    break;
  case MotionNotify:
    // cout << "Move to (" << ev->xmotion.x << "," << ev->xmotion.y << ")\n";
    unmap_balloon ();
    set_button_state (ev->xmotion.state);
    win->mouse_event ("move", ev->xmotion.x, ev->xmotion.y, ev->xmotion.time);
    break;
  case KeyPress:
    unmap_balloon ();
    {
      string key= look_up_key (&ev->xkey);
      //cout << "Press " << key << " at " << (time_t) ev->xkey.time
      //<< " (" << texmacs_time() << ")\n";
      kbd_count++;
      synchronize_time (ev->xkey.time);
      if (texmacs_time () - remote_time (ev->xkey.time) < 100 ||
         (kbd_count & 15) == 0)
       request_partial_redraw= true;
      //cout << "key   : " << key << "\n";
      //cout << "redraw: " << request_partial_redraw << "\n";
      if (N(key)>0) win->key_event (key);
      break;
    }
  case SelectionRequest: {
      XSelectionRequestEvent& req= ev->xselectionrequest;
      XSelectionEvent sel;
      sel.type      = SelectionNotify;
      sel.requestor = req.requestor;
      sel.selection = req.selection;
      sel.target    = req.target;
      sel.time      = req.time;
      string key = "none";
      if (req.selection == XA_PRIMARY) key = "mouse";
      else if (req.selection == XA_CLIPBOARD) key = "primary";
      if (!selection_s->contains (key)) sel.property= None;
      else if (req.target==XA_TARGETS) {
        Atom targets[2];
        targets[0] = XA_TARGETS;
        targets[1] = XA_STRING;
        XChangeProperty (dpy, req.requestor, req.property, XA_ATOM,
                         32, PropModeReplace,
                         (unsigned char*)&targets[0],2);
        sel.property  = req.property;
      }
      else if ((req.target==AnyPropertyType) || (req.target==XA_STRING)) {
        char *txt = as_charp (selection_s(key));
        XChangeProperty (dpy, req.requestor, req.property, XA_STRING,
                         8, PropModeReplace,
                         (unsigned char*) txt,
                         strlen (txt));
        tm_delete_array (txt);
        sel.property  = req.property;
      }
      else sel.property = None;
      XSendEvent (dpy, sel.requestor, false, 0, (XEvent*) &sel);
    }
    break;
  case SelectionClear:
    {
      XSelectionClearEvent& req= ev->xselectionclear;
      if (selection_w == req.window) selection_w= (Window) 0;
      else if (req.selection == XA_PRIMARY) clear_selection ("mouse");
      else if (req.selection == XA_CLIPBOARD) clear_selection ("primary");
    }
    break;
  case ClientMessage:
    {
      Atom wm_protocols     = XInternAtom (win->dpy, "WM_PROTOCOLS",     1);
      Atom wm_delete_window = XInternAtom (win->dpy, "WM_DELETE_WINDOW", 1);
      if ((ev->xclient.message_type == wm_protocols) &&
         ((Atom)ev->xclient.data.l[0] == wm_delete_window))
       win->destroy_event();
      break;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 165 of file x_gui.cpp.

                               {
  if (is_nil (grab_ptr)) return;
  widget old_widget= grab_ptr->item;
  grab_ptr= grab_ptr->next;
  widget new_widget; if (!is_nil (grab_ptr)) new_widget= grab_ptr->item;
  if (is_nil (grab_ptr)) {
    XUngrabPointer (dpy, CurrentTime);
    // cout << "\n---> No grab\n\n";
  }
  else {
    x_window grab_win= get_x_window (new_widget);
    notify_mouse_grab (new_widget, true);    
    XGrabPointer (dpy, grab_win->win, false,
                PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
                GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
    // cout << "\n---> In grab " << new_widget << "\n";
    notify_mouse_grab (old_widget, false);
    emulate_leave_enter (old_widget, new_widget);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_gui_rep::set_button_state ( unsigned int  state)

Definition at line 81 of file x_gui.cpp.

                                               {
  int i= 0;
  if ((state & Button1Mask) != 0) i += 1;
  if ((state & Button2Mask) != 0) i += 2;
  if ((state & Button3Mask) != 0) i += 4;
  if ((state & Button4Mask) != 0) i += 8;
  if ((state & Button5Mask) != 0) i += 16;
  if ((state & ShiftMask)   != 0) i += 256;
  if ((state & ControlMask) != 0) i += 512;
  if ((state & LockMask)    != 0) i += 1024;
  if ((state & Mod1Mask)    != 0) i += 2048;
  if ((state & Mod2Mask)    != 0) i += 4096;
  if ((state & Mod3Mask)    != 0) i += 8192;
  if ((state & Mod4Mask)    != 0) i += 16384;
  if ((state & Mod5Mask)    != 0) i += 32768;
  x_gui_rep::state= i;
}

Here is the caller graph for this function:

Definition at line 134 of file x_font.cpp.

                                        {
  the_default_font= name;
}
void x_gui_rep::set_mouse_pointer ( widget  w,
string  name 
)

Definition at line 444 of file x_gui.cpp.

                                                   {
  int no= fetch_X11_cursor_no (name);
  if (no==-1) return;
  Cursor cursor=XCreateFontCursor(dpy, no);
  x_window win= get_x_window (w);
  if (win != NULL) XDefineCursor(dpy, win->win, cursor);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_gui_rep::set_mouse_pointer ( widget  w,
string  curs_name,
string  mask_name 
)

Definition at line 453 of file x_gui.cpp.

                                                                     {
  static hashmap<string,tree> xpm_cache ("");
  if (mask_name=="") mask_name= name;
  x_drawable_rep* dra= tm_new<x_drawable_rep> (this, 1, 1);
  dra->xpm_initialize (name);
  if (mask_name!=name) dra->xpm_initialize (mask_name);
  tm_delete (dra);
  Pixmap curs= (Pixmap) xpm_bitmap [name];
  Pixmap mask= (Pixmap) xpm_bitmap [mask_name];

  if (!xpm_cache->contains (name))
    xpm_cache (name)= xpm_load (name);

  if (!xpm_cache->contains (mask_name))
    xpm_cache (mask_name)= xpm_load (mask_name);

  array<string> cnames_curs= xpm_colors (xpm_cache[name]);
  array<SI> hotspot= xpm_hotspot (xpm_cache[name]);
  ASSERT (N(hotspot) != 0, "missing hotspot");
  array<string> cnames_mask= xpm_colors (xpm_cache[mask_name]);
  char* bgcolor= as_charp (N(cnames_mask)>1 ? cnames_mask[1] :
                                         string ("white"));
  char* fgcolor= as_charp (N(cnames_curs)>1 ? cnames_curs[1] :
                                         string ("black"));
  if (!strcmp (bgcolor, "none")) bgcolor= as_charp (string ("white"));
  if (!strcmp (fgcolor, "none")) fgcolor= as_charp (string ("white"));

  XColor *bg= NULL, *fg= NULL;
  XColor exact1, closest1;
  XLookupColor(dpy, cols, fgcolor, &exact1, &closest1);
  if (XAllocColor (dpy, cols, &exact1)) fg= &exact1;
  else if (XAllocColor (dpy, cols, &closest1)) fg= &closest1;
  else FAILED ("unable to allocate fgcolor");

  XColor exact2, closest2;
  XLookupColor(dpy, cols, bgcolor, &exact2, &closest2);
  if (XAllocColor (dpy, cols, &exact2)) bg= &exact2;
  else if (XAllocColor (dpy, cols, &closest2)) bg= &closest2;
  else FAILED ("unable to allocate bgcolor");

  tm_delete_array (bgcolor);
  tm_delete_array (fgcolor);

  SI x= hotspot[0], y= hotspot[1];
  Cursor cursor=XCreatePixmapCursor (dpy, curs, mask, fg, bg, x, y);
  x_window win= get_x_window (w);
  if (win != NULL) XDefineCursor(dpy, win->win, cursor);
}

Here is the call graph for this function:

bool x_gui_rep::set_selection ( string  key,
tree  t,
string  s 
)

Definition at line 273 of file x_gui.cpp.

                                                      {
  selection_t (key)= copy (t);
  selection_s (key)= copy (s);
  Atom xsel;
  if(key == "primary") xsel = XA_CLIPBOARD;
  else if (key == "mouse") xsel = XA_PRIMARY;
  else return true;
  if (is_nil (windows_l)) return false;
  Window win= windows_l->item;
  selection_w= win;
  XSetSelectionOwner (dpy, xsel, win, CurrentTime);
  if (XGetSelectionOwner (dpy, xsel) == None) return false;
  return true;
}

Here is the call graph for this function:

void x_gui_rep::set_shrinking_factor ( int  sfactor)
void x_gui_rep::show_help_balloon ( widget  wid,
SI  x,
SI  y 
)

Definition at line 507 of file x_gui.cpp.

Here is the call graph for this function:

void x_gui_rep::show_wait_indicator ( widget  w,
string  message,
string  arg 
)

Definition at line 537 of file x_gui.cpp.

                                                                    {
  // NOTE: the wait indicator is directly displayed inside the window
  // corresponding to w. We explicitly shortcut the main event loop
  // by invalidating the wait widget and requesting a redraw.
  // Using a popup window does not work, because it would be necessary
  // to return to the main loop to map and redraw it.
  x_window ww= get_x_window (w);
  if (ww == NULL || message == "") return;
  if (arg != "") message= message * " " * arg * "...";
  SI width= 400*PIXEL, height= 160*PIXEL;
  widget wait_wid= wait_widget (width, height, message);
  SI mid_x= (ww->win_w>>1)*PIXEL, mid_y= -(ww->win_h>>1)*PIXEL + height;
  SI x= mid_x- width/2, y= mid_y- height/2;
  widget old_wid= ww->w;
  ww->w= wait_wid;
  set_position (wait_wid, x, y);
  set_identifier (wait_wid, (int) ww->win);
  send_invalidate_all (wait_wid);
  ww->repaint_invalid_regions ();
  ww->w= old_wid;
  XFlush (dpy);
  send_invalidate_all (old_wid);
}

Here is the call graph for this function:

Definition at line 525 of file x_gui.cpp.

                          {
  if (!is_nil (balloon_wid)) {
    if (balloon_win != NULL) {
      balloon_win->set_visibility (false);
      tm_delete (balloon_win);
      balloon_win= NULL;
    }
    balloon_wid= widget ();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class x_drawable_rep [friend]

Definition at line 197 of file x_gui.hpp.

friend class x_ps_font_rep [friend]

Definition at line 199 of file x_gui.hpp.

friend class x_tex_font_rep [friend]

Definition at line 200 of file x_gui.hpp.

friend class x_window_rep [friend]

Definition at line 198 of file x_gui.hpp.


Member Data Documentation

Definition at line 110 of file x_gui.hpp.

Definition at line 111 of file x_gui.hpp.

Definition at line 116 of file x_gui.hpp.

Definition at line 112 of file x_gui.hpp.

Definition at line 113 of file x_gui.hpp.

Definition at line 114 of file x_gui.hpp.

Definition at line 115 of file x_gui.hpp.

Definition at line 121 of file x_gui.hpp.

Definition at line 122 of file x_gui.hpp.

Definition at line 102 of file x_gui.hpp.

Definition at line 120 of file x_gui.hpp.

Colormap x_gui_rep::cols

Definition at line 101 of file x_gui.hpp.

Definition at line 100 of file x_gui.hpp.

Display* x_gui_rep::dpy

Definition at line 93 of file x_gui.hpp.

Definition at line 94 of file x_gui.hpp.

Definition at line 106 of file x_gui.hpp.

Definition at line 105 of file x_gui.hpp.

Definition at line 109 of file x_gui.hpp.

Definition at line 104 of file x_gui.hpp.

Definition at line 103 of file x_gui.hpp.

Definition at line 118 of file x_gui.hpp.

Definition at line 117 of file x_gui.hpp.

Definition at line 125 of file x_gui.hpp.

Definition at line 108 of file x_gui.hpp.

Definition at line 95 of file x_gui.hpp.

Definition at line 97 of file x_gui.hpp.

Definition at line 96 of file x_gui.hpp.

Definition at line 99 of file x_gui.hpp.

Definition at line 98 of file x_gui.hpp.

Definition at line 130 of file x_gui.hpp.

Definition at line 129 of file x_gui.hpp.

Definition at line 131 of file x_gui.hpp.

unsigned int x_gui_rep::state

Definition at line 107 of file x_gui.hpp.

Definition at line 126 of file x_gui.hpp.

Definition at line 128 of file x_gui.hpp.

Definition at line 133 of file x_gui.hpp.

Definition at line 134 of file x_gui.hpp.

Definition at line 123 of file x_gui.hpp.

Definition at line 124 of file x_gui.hpp.


The documentation for this class was generated from the following files: