Back to index

texmacs  1.0.7.15
Defines | Functions | Variables
x_init.cpp File Reference
#include "X11/x_window.hpp"
#include "language.hpp"
#include "font.hpp"
#include "analyze.hpp"
#include "dictionary.hpp"
#include "iterator.hpp"
#include "message.hpp"
#include "sys_utils.hpp"
#include <locale.h>

Go to the source code of this file.

Defines

#define XK_ISO_Left_Tab   0xFE20

Functions

static void reverse (int &r, int &g, int &b)
int x_alloc_color (int r, int g, int b)
void x_init_color_map ()
color rgb_color (int r, int g, int b, int a)
void get_rgb_color (color col, int &r, int &g, int &b, int &a)
static color named_color_bis (string s)
color named_color (string s, int a)
string get_named_color (color c)
color blend (color fg, color bg)
void x_initialize_colors ()
void gui_open (int &argc2, char **argv2)
void gui_start_loop ()
void gui_close ()
void gui_root_extents (SI &width, SI &height)
void gui_maximal_extents (SI &width, SI &height)
void gui_refresh ()

Variables

x_gui_repthe_gui = NULL
hashmap< Window, pointerWindow_to_window
bool true_color = false
bool reverse_colors = false
color black
color white
color red
color green
color blue
color yellow
color magenta
color orange
color brown
color pink
color light_grey
color grey
color dark_grey
static int CSCALES = 4
static int CFACTOR = 5
static int GREYS = 16
static int CTOTAL = (CFACTOR*CFACTOR*CFACTOR+GREYS+1)
static XModifierKeymap * xmodmap
static int mod_n
static KeyCode * mod_k
static array< int > mod_shift
static array< int > mod_ctrl
static array< int > mod_alt

Define Documentation

#define XK_ISO_Left_Tab   0xFE20

Definition at line 292 of file x_init.cpp.


Function Documentation

color blend ( color  fg,
color  bg 
)

Definition at line 229 of file x_init.cpp.

                           {
  if (((fg >> 24) & 255) == 255) return fg;
  int fR, fG, fB, fA, bR, bG, bB, bA;
  get_rgb_color (fg, fR, fG, fB, fA);
  get_rgb_color (bg, bR, bG, bB, bA);
  fR= (bR * (255 - fA) + fR * fA) / 255;
  fG= (bG * (255 - fA) + fG * fA) / 255;
  fB= (bB * (255 - fA) + fB * fA) / 255;
  return rgb_color (fR, fG, fB);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 219 of file x_init.cpp.

                          {
  int r, g, b, a;
  get_rgb_color (c, r, g, b, a);
  return "#" *
    as_hexadecimal (r, 2) *
    as_hexadecimal (g, 2) *
    as_hexadecimal (b, 2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void get_rgb_color ( color  col,
int &  r,
int &  g,
int &  b,
int &  a 
)

Definition at line 132 of file x_init.cpp.

                                                          {
  if (true_color) {
    a= (col >> 24) & 255;
    r= (col >> 16) & 255;
    g= (col >> 8 ) & 255;
    b=  col        & 255;
    if (reverse_colors) reverse (r, g, b);
  }
  else {
    a= (col >> 24) & 255;
    col= col & 0xffffff;
    if (col <= ((color) GREYS)) {
      r= (col*255)/GREYS;
      g= (col*255)/GREYS;
      b= (col*255)/GREYS;
    }
    else {
      int rr, gg, bb;
      col-= (GREYS+1);
      bb  = col % CFACTOR;
      gg  = (col/CFACTOR) % CFACTOR;
      rr  = (col/(CFACTOR*CFACTOR)) % CFACTOR;
      r   = (rr*255)/CSCALES;
      g   = (gg*255)/CSCALES;
      b   = (bb*255)/CSCALES;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gui_close ( )

Definition at line 934 of file x_init.cpp.

             {
  ASSERT (the_gui != NULL, "gui not yet open");
  tm_delete (the_gui);
  the_gui= NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gui_maximal_extents ( SI width,
SI height 
)

Definition at line 946 of file x_init.cpp.

                                            {
  the_gui->get_max_size (width, height);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gui_open ( int &  argc2,
char **  argv2 
)

Definition at line 923 of file x_init.cpp.

                                    {
  ASSERT (the_gui == NULL, "gui already open");
  the_gui= tm_new<x_gui_rep> (argc2, argv2);
}

Here is the caller graph for this function:

void gui_refresh ( )

Definition at line 951 of file x_init.cpp.

               {
  iterator<Window> it= iterate (Window_to_window);
  while (it->busy()) {
    x_window win= (x_window) Window_to_window [it->next()];
    if (get_x_window (win->w) != NULL)
      send_update (win->w);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gui_root_extents ( SI width,
SI height 
)

Definition at line 941 of file x_init.cpp.

                                         {
  the_gui->get_extents (width, height);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gui_start_loop ( )

Definition at line 929 of file x_init.cpp.

                  {
  the_gui->event_loop ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

color named_color ( string  s,
int  a 
)

Definition at line 213 of file x_init.cpp.

                              {
  color c= named_color_bis (s);
  return (a << 24) + (c & 0xffffff);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static color named_color_bis ( string  s) [static]

Definition at line 162 of file x_init.cpp.

                           {
  if ((N(s) == 4) && (s[0]=='#')) {
    int r= 17 * from_hexadecimal (s (1, 2));
    int g= 17 * from_hexadecimal (s (2, 3));
    int b= 17 * from_hexadecimal (s (3, 4));
    return rgb_color (r, g, b);
  }
  if ((N(s) == 7) && (s[0]=='#')) {
    int r= from_hexadecimal (s (1, 3));
    int g= from_hexadecimal (s (3, 5));
    int b= from_hexadecimal (s (5, 7));
    return rgb_color (r, g, b);
  }
  int pastel= (the_gui->depth>=16? 223: 191);
  if (s == "black")          return black;
  if (s == "white")          return white;
  if (s == "grey")           return grey;
  if (s == "red")            return red;
  if (s == "blue")           return blue;
  if (s == "yellow")         return yellow;
  if (s == "green")          return green;
  if (s == "magenta")        return magenta;
  if (s == "cyan")           return rgb_color (0, 255, 255);
  if (s == "orange")         return orange;
  if (s == "brown")          return brown;
  if (s == "pink")           return pink;
  if (s == "broken white")   return rgb_color (255, 255, pastel);
  if (s == "light grey")     return light_grey;
  if (s == "darker grey")    return rgb_color (64, 64, 64);
  if (s == "dark grey")      return dark_grey;
  if (s == "dark red")       return rgb_color (128, 0, 0);
  if (s == "dark blue")      return rgb_color (0, 0, 128);
  if (s == "dark yellow")    return rgb_color (128, 128, 0);
  if (s == "dark green")     return rgb_color (0, 128, 0);
  if (s == "dark magenta")   return rgb_color (128, 0, 128);
  if (s == "dark cyan")      return rgb_color (0, 128, 128);
  if (s == "dark orange")    return rgb_color (128, 64, 0);
  if (s == "dark brown")     return rgb_color (64, 16, 0);
  if (s == "pastel grey")    return rgb_color (pastel, pastel, pastel);
  if (s == "pastel red")     return rgb_color (255, pastel, pastel);
  if (s == "pastel blue")    return rgb_color (pastel, pastel, 255);
  if (s == "pastel yellow")  return rgb_color (255, 255, pastel);
  if (s == "pastel green")   return rgb_color (pastel, 255, pastel);
  if (s == "pastel magenta") return rgb_color (255, pastel, 255);
  if (s == "pastel cyan")    return rgb_color (pastel, 255, 255);
  if (s == "pastel orange")  return rgb_color (255, pastel, 2*pastel-255);
  if (s == "pastel brown")   return rgb_color (pastel, 2*pastel-255, 2*pastel-255);
  return black;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void reverse ( int &  r,
int &  g,
int &  b 
) [static]

Definition at line 42 of file x_init.cpp.

                                 {
  int m= min (r, min (g, b));
  int M= max (r, max (g, b));
  int t= (r + g + b) / 3;
  int tt= 255 - t;
  double mu= 1.0;
  // tt= 6 * tt / 7;
  if (M != m) {
    double lambda1= max (((double) (t - m)) / t,
                      ((double) (M - t)) / (255 - t));
    double lambda2= max (((double) (t - m)) / tt,
                      ((double) (M - t)) / (255 - tt));
    mu= lambda1 / lambda2;
  }
  r= (int) (tt + mu * (r - t) + 0.5);
  g= (int) (tt + mu * (g - t) + 0.5);
  b= (int) (tt + mu * (b - t) + 0.5);
}
color rgb_color ( int  r,
int  g,
int  b,
int  a 
)

Definition at line 116 of file x_init.cpp.

                                       {
  if (true_color) {
    if (reverse_colors) reverse (r, g, b);
    return (a << 24) + (r << 16) + (g << 8) + b;
  }
  else if ((r==g) && (g==b))
    return (a << 24) + ((r*GREYS+ 128)/255);
  else {
    r= (r*CSCALES+ 128)/255;
    g= (g*CSCALES+ 128)/255;
    b= (b*CSCALES+ 128)/255;
    return (a << 24) + r*CFACTOR*CFACTOR + g*CFACTOR + b + GREYS + 1;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int x_alloc_color ( int  r,
int  g,
int  b 
)

Definition at line 62 of file x_init.cpp.

                                    {
  if (true_color)
    return ((r >> 8) << 16) + ((g >> 8) << 8) + (b >> 8);

  if (reverse_colors) {
    int m= min (r, min (g, b));
    int M= max (r, max (g, b));
    int t= (r + g + b) / 3;
    int tt= 65535 - t;
    double mu= 1.0;
    tt= 6 * tt / 7;
    if (M != m) {
      double lambda1= max (((double) (t - m)) / t,
                        ((double) (M - t)) / (65535 - t));
      double lambda2= max (((double) (t - m)) / tt,
                        ((double) (M - t)) / (65535 - tt));
      mu= lambda1 / lambda2;
    }
    r= (int) (tt + mu * (r - t) + 0.5);
    g= (int) (tt + mu * (g - t) + 0.5);
    b= (int) (tt + mu * (b - t) + 0.5);
  }

  XColor col;
  col.red  = r;
  col.green= g;
  col.blue = b;
  if (!XAllocColor (the_gui->dpy, the_gui->cols, &col))
    cerr << "Warning: can't allocate color\n";
  return col.pixel;
}

Here is the caller graph for this function:

void x_init_color_map ( )

Definition at line 95 of file x_init.cpp.

                    {
  if (true_color) return;

  int i, r, g, b;
  the_gui->cmap= tm_new_array<color> (CTOTAL);

  for (i=0; i<=GREYS; i++)
    the_gui->cmap[i]=
      x_alloc_color ((i*65535)/GREYS, (i*65535)/GREYS, (i*65535)/GREYS);

  for (r=0; r<=CSCALES; r++)
    for (g=0; g<=CSCALES; g++)
      for (b=0; b<=CSCALES; b++) {
       i= r*CFACTOR*CFACTOR+ g*CFACTOR+ b+ GREYS+ 1;
       the_gui->cmap[i]= x_alloc_color ((r*65535)/CSCALES,
                                    (g*65535)/CSCALES,
                                    (b*65535)/CSCALES);
      }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 241 of file x_init.cpp.

                       {
  if (the_gui->depth >= 16) {
    CSCALES= 8;
    CFACTOR= 9;
    GREYS  = 256;
    CTOTAL = (CFACTOR*CFACTOR*CFACTOR+GREYS+1);
  }

  x_init_color_map ();

  black   = rgb_color (0, 0, 0);
  white   = rgb_color (255, 255, 255);
  red     = rgb_color (255, 0, 0);
  blue    = rgb_color (0, 0, 255);
  yellow  = rgb_color (255, 255, 0);
  green   = rgb_color (0, 255, 0);
  magenta = rgb_color (255, 0, 255);
  orange  = rgb_color (255, 128, 0);
  brown   = rgb_color (128, 32, 0);
  pink    = rgb_color (255, 128, 128);

  light_grey = rgb_color (208, 208, 208);
  grey       = rgb_color (184, 184, 184);
  dark_grey  = rgb_color (112, 112, 112);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 32 of file x_init.cpp.

Definition at line 32 of file x_init.cpp.

Definition at line 33 of file x_init.cpp.

int CFACTOR = 5 [static]

Definition at line 37 of file x_init.cpp.

int CSCALES = 4 [static]

Definition at line 36 of file x_init.cpp.

int CTOTAL = (CFACTOR*CFACTOR*CFACTOR+GREYS+1) [static]

Definition at line 39 of file x_init.cpp.

Definition at line 34 of file x_init.cpp.

Definition at line 32 of file x_init.cpp.

Definition at line 34 of file x_init.cpp.

int GREYS = 16 [static]

Definition at line 38 of file x_init.cpp.

Definition at line 34 of file x_init.cpp.

Definition at line 33 of file x_init.cpp.

array<int> mod_alt [static]

Definition at line 300 of file x_init.cpp.

array<int> mod_ctrl [static]

Definition at line 299 of file x_init.cpp.

KeyCode* mod_k [static]

Definition at line 297 of file x_init.cpp.

int mod_n [static]

Definition at line 296 of file x_init.cpp.

array<int> mod_shift [static]

Definition at line 298 of file x_init.cpp.

Definition at line 33 of file x_init.cpp.

Definition at line 33 of file x_init.cpp.

Definition at line 32 of file x_init.cpp.

bool reverse_colors = false

Definition at line 30 of file x_init.cpp.

x_gui_rep* the_gui = NULL

Definition at line 22 of file x_init.cpp.

bool true_color = false

Definition at line 29 of file x_init.cpp.

Definition at line 32 of file x_init.cpp.

XModifierKeymap* xmodmap [static]

Definition at line 295 of file x_init.cpp.

Definition at line 33 of file x_init.cpp.