Back to index

im-sdk  12.3.91
Classes | Typedefs | Enumerations | Functions
lookup.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _LocalLookupExt

Typedefs

typedef struct _LocalLookupExt LocalLookupExt

Enumerations

enum  LookupWindowState { LOOKUP_UNMAPPED = 0, LOOKUP_MAPPED = 1 }

Functions

void Ximp_Local_Lookup_Create (XicCommon ic)
void Ximp_Local_Lookup_Start (XicCommon ic)
void Ximp_Local_Lookup_Draw (XicCommon ic)
void Ximp_Local_Lookup_Done (XicCommon ic)
void Ximp_Local_Lookup_Destroy (XicCommon ic)
Bool Ximp_Local_Lookup_Button_Filter (XicCommon ic, int index, XEvent *ev)
Bool Ximp_Local_Lookup_Input_Filter (XicCommon ic, char *input, XEvent *ev)
Bool Ximp_Local_Lookup_Action_Filter (XicCommon ic, ActionType action, XEvent *ev)

Class Documentation

struct _LocalLookupExt

Definition at line 50 of file lookup.h.

Collaboration diagram for _LocalLookupExt:
Class Members
int begin_range
int choice_per_window
int crange
int currentindex
int end_range
XPointer LUTable
int LUTableSize
LookupWindowState mapped
int n_choices
int ncolumns
int nrange
int nrows
LuRange * range
int startindex

Typedef Documentation


Enumeration Type Documentation

Enumerator:
LOOKUP_UNMAPPED 
LOOKUP_MAPPED 

Definition at line 45 of file lookup.h.


Function Documentation

Bool Ximp_Local_Lookup_Action_Filter ( XicCommon  ic,
ActionType  action,
XEvent *  ev 
)

Definition at line 410 of file lookup.c.

                                        {
  LocalLookupExt *hook = (LocalLookupExt*)(ic->local_icpart->lookup_ext);
  int startindex, endindex;

  if (!hook) return False;
  switch (action) {
  case TopPage:
    /* top page */
    startindex = hook->begin_range;
    if (hook->startindex == startindex) {
      /* already at top */
      return False;
    }
    hook->startindex = startindex;
    Ximp_Local_Lookup_Draw(ic);
    break;
  case LastPage:
    /* last page */
    endindex = hook->end_range == -1 ? 0xffff : hook->end_range;
    if (hook->startindex + hook->choice_per_window - 1 == endindex) {
      /* already at last */
      return False;
    }
    startindex = endindex - hook->choice_per_window + 1;
    hook->startindex = startindex;
    Ximp_Local_Lookup_Draw(ic);
    break;
  case NextPage:
    /* next page */
    endindex = hook->end_range == -1 ? 0xffff : hook->end_range;
    if (hook->startindex + hook->choice_per_window - 1 == endindex) {
      /* already at last */
      return False;
    }
    startindex = hook->startindex + hook->choice_per_window;
    if (startindex + hook->choice_per_window > endindex) {
      startindex = endindex - hook->choice_per_window + 1;
    }
    hook->startindex = startindex;
    Ximp_Local_Lookup_Draw(ic);
    break;
  case PrevPage:
    /* prev page */
    startindex = hook->begin_range;
    if (hook->startindex == startindex) {
      /* already at top */
      return False;
    }
    startindex = hook->startindex - hook->choice_per_window;
    if (startindex < hook->begin_range) {
      startindex = hook->begin_range;
    }
    hook->startindex = startindex;
    Ximp_Local_Lookup_Draw(ic);
    break;
  case NextCand:
    /* move focus to next cand */
    if (hook->currentindex == hook->choice_per_window - 1) {
      /* move to top */
      hook->currentindex = 0;
    } else {
      hook->currentindex++;
    }
    Ximp_Local_Lookup_Draw(ic);
    break;
  case PrevCand:
    /* move focus to prev cand */
    if (hook->currentindex == 0) {
      /* move to last */
      hook->currentindex = hook->choice_per_window - 1;
    } else {
      hook->currentindex--;
    }
    Ximp_Local_Lookup_Draw(ic);
    break;
  case UpCand:
    /* move focus to up cand */
    hook->currentindex -= hook->ncolumns;
    if (hook->currentindex < 0) {
      hook->currentindex += hook->choice_per_window;
    }
    Ximp_Local_Lookup_Draw(ic);
    break;
  case DownCand:
    /* move focus to down cand */
    hook->currentindex += hook->ncolumns;
    if (hook->currentindex >= hook->choice_per_window) {
      hook->currentindex -= hook->choice_per_window;
    }
    Ximp_Local_Lookup_Draw(ic);
    break;
  case SelectCand:
    {
      /* select cand at currentindex */
      XIMText *p;
      XIMChoiceObject2 *LUTable;
      LUTable = (XIMChoiceObject2*)hook->LUTable;
      p = &LUTable->value[hook->currentindex];
      lookup_commit(ic, p->string.multi_byte, ev);
    }
    break;
  default:
    break;
  }
  return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool Ximp_Local_Lookup_Button_Filter ( XicCommon  ic,
int  index,
XEvent *  ev 
)

Definition at line 376 of file lookup.c.

                                                   {
  LocalLookupExt *hook = (LocalLookupExt*)(ic->local_icpart->lookup_ext);
  XIMChoiceObject2 *LUTable;
  XIMText *p;

  if (!hook) return False;
  LUTable = (XIMChoiceObject2*)hook->LUTable;
  p = &LUTable->value[index];
  lookup_commit(ic, p->string.multi_byte, ev);
  return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 192 of file lookup.c.

                                       {
  setup_local_lookup_ext(ic);
  return;
}

Here is the call graph for this function:

Definition at line 519 of file lookup.c.

                                        {
  LocalLookupExt *hook = (LocalLookupExt *)(ic->local_icpart->lookup_ext);

  if (!hook) return;

  if (hook->LUTable) {
    DefillLookup(hook, hook->startindex, hook->n_choices);
    Xfree(hook->LUTable);
  }
  Xfree(hook);
  ic->local_icpart->lookup_ext = 0;
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 307 of file lookup.c.

                                     {
  LocalLookupExt *hook = (LocalLookupExt*)(ic->local_icpart->lookup_ext);
  if (!hook) return;
  DefillLookup(hook, hook->startindex, hook->n_choices);
  XIC_GUI(ic, change_lookup)((XIC)ic, LOOKUP_DONE, NULL);
  hook->mapped = LOOKUP_UNMAPPED;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 232 of file lookup.c.

                                     {
  LocalLookupExt *hook = (LocalLookupExt*)(ic->local_icpart->lookup_ext);
  XIMLookupDrawCallbackStruct2 cbdata;
  XIMText title_text;
  char stitle[80];
  size_t tlen;
  int startindex, endindex;

  if (!hook) {
    Ximp_Local_Lookup_Start(ic);
    hook = (LocalLookupExt *)(ic->local_icpart->lookup_ext);
    if (!hook) return;
  }
  DefillLookup(hook, hook->startindex, hook->n_choices);

  startindex = hook->startindex;

  endindex = startindex + ((hook->end_range == -1) ? 
                        hook->choice_per_window : hook->end_range);

  if (endindex < startindex) return;

  if (0xffff0000 & endindex) {
    endindex = 0x0000ffff;
  }

  memset(&cbdata, 0, sizeof(XIMLookupDrawCallbackStruct2));
  cbdata.n_choices =
    ((endindex - startindex) + 1 > hook->choice_per_window) ?
    hook->choice_per_window : (endindex - startindex) + 1;
  hook->n_choices = cbdata.n_choices;
  cbdata.first_index = 0;
  cbdata.current_index = hook->currentindex;
  cbdata.last_index = cbdata.n_choices - 1;

  if (!FillLookup(ic, hook, startindex, cbdata.n_choices)) return;

  cbdata.choices = (XIMChoiceObject2*)hook->LUTable;

  if (hook->crange != -1) {
    sprintf(stitle, "%s:  0x%04x to 0x%04x",
           hook->range[hook->crange].RangeName+3, startindex, 
           (startindex + (cbdata.n_choices - 1)));
  } else {
    sprintf(stitle, "UNICODE Lookup:  0x%04x to 0x%04x",
           startindex, (startindex +(cbdata.n_choices - 1)));
  }
  tlen = strlen(stitle);

  cbdata.title = &title_text;
  memset((char *)cbdata.title, 0, sizeof(XIMText));
  cbdata.title->length = tlen;
  cbdata.title->feedback = (XIMFeedback*)Xmalloc(sizeof(XIMFeedback) * tlen);
  if (cbdata.title->feedback) {
    XIMFeedback *p;
    for (p = cbdata.title->feedback; p < &cbdata.title->feedback[tlen]; p++) {
      *p = 0;
    }
  } else {
    return;
  }

  cbdata.title->encoding_is_wchar = False;
  cbdata.title->string.multi_byte = stitle;

  XIC_GUI(ic, change_lookup)((XIC)ic, LOOKUP_DRAW, (XPointer)&cbdata);
  hook->mapped = LOOKUP_MAPPED;

  if (cbdata.title->feedback) {
    Xfree(cbdata.title->feedback);
  }
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool Ximp_Local_Lookup_Input_Filter ( XicCommon  ic,
char *  input,
XEvent *  ev 
)

Definition at line 390 of file lookup.c.

                                                                      {
  LocalLookupExt *hook = (LocalLookupExt *)(ic->local_icpart->lookup_ext);
  int i;
  XIMChoiceObject2 *LUTable;
  XIMText *p;
  LUTable = (XIMChoiceObject2*)hook->LUTable;
  if (!LUTable) return False;
  p = LUTable->label;
  if (!p) return False;
  /* if given input matches to a label, commit it */
  for (i = 0; p < &LUTable->label[hook->n_choices]; p++, i++) {
    if (!strcmp(p->string.multi_byte, input)) {
      Ximp_Local_Lookup_Button_Filter(ic, i, ev);
      return True;          /* filtered */
    }
  }
  return False;                    /* not filtered */
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 198 of file lookup.c.

                                      {
  LocalLookupExt *hook = (LocalLookupExt*)(ic->local_icpart->lookup_ext);
  LocalIMState *state = (LocalIMState *)(ic->local_icpart->imstate);
  XIMLookupStartCallbackStruct2 cbdata;

  if (!hook) {
    if (!setup_local_lookup_ext(ic))
      return;
    hook = (LocalLookupExt*)(ic->local_icpart->lookup_ext);
    if (!hook) return;
  }

  memset(&cbdata, 0, sizeof(XIMLookupStartCallbackStruct2));
  cbdata.which_is_master = XIMIsMaster;
  if (state->attr && state->type == LookupState) {
    cbdata.nrows = state->attr->_attr_u.LUstruct.num_of_rows;
    cbdata.ncolumns = state->attr->_attr_u.LUstruct.num_of_cols;
    cbdata.choice_per_window = state->attr->_attr_u.LUstruct.num_of_cands;
  } else {
    cbdata.nrows = 6;
    cbdata.ncolumns = 16;
    cbdata.choice_per_window = 80;
  }
  hook->choice_per_window = cbdata.choice_per_window; /* for drawing */
  hook->nrows = cbdata.nrows; /* for drawing */
  hook->ncolumns = cbdata.ncolumns; /* for drawing */
  cbdata.who_owns_label = XIMOwnsLabel;

  XIC_GUI(ic, change_lookup)((XIC)ic, LOOKUP_START,
                          (XPointer)&cbdata);
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function: