Back to index

im-sdk  12.3.91
Enumerations | Functions
iiimpColor.c File Reference
#include <stdio.h>
#include "iiimpIM.h"
#include "xiiimp.h"
#include "guiIM.h"
#include "iiimpColor.h"

Go to the source code of this file.

Enumerations

enum  IMSetColor { NO_COLOR = 0, FG_COLOR = (1L << 1), BG_COLOR = (1L << 2) }

Functions

Bool SameIMFeedbackList (IMFeedbackList *a, IMFeedbackList *b)
int SetIMColors (XicCommon ic, Display *display, Window win, GC gc, GC rgc, IMFeedbackList *flist, XIMFeedback unused)
void FreeFeedbackList (IMFeedbackList *feedback_list, int len)

Enumeration Type Documentation

enum IMSetColor
Enumerator:
NO_COLOR 
FG_COLOR 
BG_COLOR 

Definition at line 61 of file iiimpColor.c.

             {
  NO_COLOR = 0,
  FG_COLOR = (1L << 1),
  BG_COLOR = (1L << 2)
} IMSetColor;

Function Documentation

void FreeFeedbackList ( IMFeedbackList feedback_list,
int  len 
)

Definition at line 118 of file iiimpColor.c.

                                                         {
  if (feedback_list) {
    IMFeedbackList *p;
    for (p = feedback_list;
        p < &feedback_list[len]; p++) {
      if (p->feedbacks) {
       Xfree(p->feedbacks);
       p->feedbacks = 0;
      }
    }
    Xfree(feedback_list);
  }
}

Here is the caller graph for this function:

Definition at line 50 of file iiimpColor.c.

                                                         {
  int i;
  if (a->count_feedbacks != b->count_feedbacks) return False;
  for (i = 0; i < a->count_feedbacks; i++) {
    if (a->feedbacks[i].type != b->feedbacks[i].type ||
       a->feedbacks[i].value != b->feedbacks[i].value)
      return False;
  }
  return True;
}

Here is the caller graph for this function:

int SetIMColors ( XicCommon  ic,
Display *  display,
Window  win,
GC  gc,
GC  rgc,
IMFeedbackList flist,
XIMFeedback  unused 
)

Definition at line 68 of file iiimpColor.c.

                                                      {
  XColor color;
  Colormap cmap;
  unsigned long r, g, b;
  char colorName[20];              /* enough */
  const char *formater = "#%2.2lX%2.2lX%2.2lX";
  int i;
  IMSetColor flag = NO_COLOR;
  unsigned long fg = 0, bg = 0;

  cmap = DefaultColormap(display, XIC_GUI(ic, screen_number));
  for (i = 0; i < flist->count_feedbacks; i++) {
    r = (flist->feedbacks[i].value & 0x00ff0000) >> 16;
    g = (flist->feedbacks[i].value & 0x0000ff00) >> 8;
    b = flist->feedbacks[i].value & 0x000000ff;
    sprintf(colorName, formater, r, g, b);
    if (XParseColor(display, cmap, colorName, &color)) {
      XAllocColor(display, cmap, &color);

      switch (flist->feedbacks[i].type) {
      case IM_FOREGROUND_RGB_FEEDBACK:
       fg = color.pixel;
       flag |= FG_COLOR;
       break;
      case IM_BACKGROUND_RGB_FEEDBACK:
       bg = color.pixel;
       flag |= BG_COLOR;
       break;
      case IM_UNDERLINE_RGB_FEEDBACK:
       break;
      default:
       break;
      }
    }
  }
  if (((flag & FG_COLOR) && (flag & BG_COLOR)) ||
      !((flag & FG_COLOR) && !(flag & BG_COLOR))) {
    /* if both are set or none are sets */
    if (fg != bg) {
      XSetForeground(display, gc, fg);
      XSetBackground(display, gc, bg);
    }
    return 1;
  }
  return 0;
}

Here is the caller graph for this function: