Back to index

im-sdk  12.3.91
SunIMSubr2.c
Go to the documentation of this file.
00001 /*
00002   Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved.
00003 
00004   Permission is hereby granted, free of charge, to any person obtaining a
00005   copy of this software and associated documentation files (the
00006   "Software"), to deal in the Software without restriction, including
00007   without limitation the rights to use, copy, modify, merge, publish,
00008   distribute, sublicense, and/or sell copies of the Software, and to
00009   permit persons to whom the Software is furnished to do so, subject to
00010   the following conditions: The above copyright notice and this
00011   permission notice shall be included in all copies or substantial
00012   portions of the Software.
00013 
00014 
00015   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018   IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
00019   FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00020   CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
00021   THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
00022   ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
00023 
00024 
00025   Except as contained in this notice, the names of The Open Group and/or
00026   Sun Microsystems, Inc. shall not be used in advertising or otherwise to
00027   promote the sale, use or other dealings in this Software without prior
00028   written authorization from The Open Group and/or Sun Microsystems,
00029   Inc., as applicable.
00030 
00031 
00032   X Window System is a trademark of The Open Group
00033 
00034   OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
00035   logo, LBX, X Window System, and Xinerama are trademarks of the Open
00036   Group. All other trademarks and registered trademarks mentioned herein
00037   are the property of their respective owners. No right, title or
00038   interest in or to any trademark, service mark, logo or trade name of
00039   Sun Microsystems, Inc. or its licensors is granted.
00040 
00041 */
00042 #include <stdio.h>
00043 #include <stdlib.h>
00044 #include <string.h>
00045 #include <sys/param.h>
00046 
00047 #include "SunIM.h"
00048 #include "SunIMLock.h"
00049 #include "IMUtil.h"
00050 #ifdef  sun
00051 #include <unistd.h>
00052 #endif
00053 
00054 static void iml_commit (iml_session_t *, UTFCHAR *);
00055 static void iml_forward_keypress (iml_session_t *, IMKeyEventStruct *);
00056 static void iml_conversion_on (iml_session_t *);
00057 static void iml_conversion_off (iml_session_t *);
00058 static void iml_status_start (iml_session_t *);
00059 static void iml_status_end (iml_session_t *);
00060 static void iml_status_draw (iml_session_t *, UTFCHAR *);
00061 static void iml_preedit_start (iml_session_t *);
00062 static void iml_preedit_end (iml_session_t *);
00063 static void iml_preedit_draw (iml_session_t *, UTFCHAR *, int);
00064 static void iml_lookup_start (iml_session_t *, LayoutInfo *);
00065 static void iml_lookup_end (iml_session_t *);
00066 static void iml_lookup_draw (iml_session_t *, int, UTFCHAR **,
00067                           IMFeedbackList **, UTFCHAR **,
00068                           IMFeedbackList **, UTFCHAR *,
00069                           IMFeedbackList *, int, int);
00070 static void iml_aux_start (iml_session_t *, char *);
00071 static void iml_aux_done (iml_session_t *, char *);
00072 static void iml_aux_draw (iml_session_t *, char *, int, int *, int, int *, UTFCHAR **);
00073 
00074 iml_methods_wrapper_t _iml_methods_wrapper = {
00075   iml_commit,
00076   iml_forward_keypress,
00077   iml_conversion_on,
00078   iml_conversion_off,
00079   iml_status_start,
00080   iml_status_end,
00081   iml_status_draw,
00082   iml_preedit_start,
00083   iml_preedit_end,
00084   iml_preedit_draw,
00085   iml_lookup_start,
00086   iml_lookup_end,
00087   iml_lookup_draw,
00088   iml_aux_start,
00089   iml_aux_done,
00090   iml_aux_draw,
00091 };
00092 
00093 Public iml_methods_wrapper_t *
00094 _iml_dup_iml_methods_wrapper ()
00095 {
00096   iml_methods_wrapper_t *m_wrapper = (iml_methods_wrapper_t *) 
00097                                      malloc (sizeof (iml_methods_wrapper_t));
00098   memcpy (m_wrapper, &_iml_methods_wrapper, sizeof (iml_methods_wrapper_t));
00099 
00100   return m_wrapper;
00101 }
00102 
00103 static IMFeedbackList *
00104 create_feedback_list (iml_session_t *s,
00105                     int size)
00106 {
00107   IMFeedbackList *feedback;
00108   int i;
00109 
00110   if (s)
00111     feedback = (IMFeedbackList *) s->If->m->iml_new (s,
00112                                 sizeof (IMFeedbackList) * size);
00113   else
00114     feedback = (IMFeedbackList *) malloc (sizeof (IMFeedbackList) * size);
00115 
00116   memset (feedback, 0, sizeof (IMFeedbackList) * size);
00117 
00118   for (i = 0; i < size; ++i)
00119     {
00120       IMFeedbackList *fbl = feedback + i;
00121 
00122       fbl->count_feedbacks = 1;
00123 
00124       // why 4 here?
00125       if (s)
00126        fbl->feedbacks = (IMFeedback *) s->If->m->iml_new (s,
00127                                      sizeof (IMFeedback) * 4);
00128       else
00129        fbl->feedbacks = (IMFeedback *) malloc (sizeof (IMFeedback) * 4);
00130 
00131       memset (fbl->feedbacks, 0, sizeof (IMFeedback) * 4);
00132     }
00133 
00134   return feedback;
00135 }
00136 
00137 static void
00138 free_feedback_list (iml_session_t *s,
00139                   IMFeedbackList *feedback,
00140                   int size)
00141 {
00142   int i;
00143 
00144   if (!feedback) return;
00145 
00146   for (i = 0; i < size; ++i)
00147     {
00148       IMFeedbackList *fbl = feedback + i;
00149 
00150       if (fbl && !fbl->feedbacks) free (fbl->feedbacks);
00151     }
00152 
00153   free (feedback);
00154 }
00155 
00156 static int
00157 get_nth_feedback (IMFeedbackList *feedback,
00158                 int n)
00159 {
00160   IMFeedback *fb = feedback->feedbacks + n;
00161 
00162   return IM_FEEDBACK_VALUE(fb);
00163 }
00164 
00165 static void
00166 set_nth_feedback (IMFeedbackList *feedback,
00167                 int n,
00168                 int type,
00169                 int value)
00170 {
00171   IMFeedback *fb = feedback->feedbacks + n;
00172 
00173   IM_FEEDBACK_TYPE(fb) = type;
00174   IM_FEEDBACK_VALUE(fb) = value;
00175 }
00176 
00177 static void
00178 set_feedback (IMFeedbackList *feedback,
00179              int normal,
00180              int fg,
00181              int bg,
00182              int underline)
00183 {
00184   int count = 0;
00185 
00186   set_nth_feedback (feedback, count, IM_DECORATION_FEEDBACK, normal);
00187   ++count;
00188 
00189   if (fg != -1)
00190     {
00191       set_nth_feedback (feedback, count, IM_FOREGROUND_RGB_FEEDBACK, fg);
00192       ++count;
00193     }
00194 
00195   if (bg != -1)
00196     {
00197       set_nth_feedback (feedback, count, IM_BACKGROUND_RGB_FEEDBACK, bg);
00198       ++count;
00199     }
00200   
00201   if (underline != -1)
00202     {
00203       set_nth_feedback (feedback, count, IM_UNDERLINE_RGB_FEEDBACK, underline);
00204       ++count;
00205     }
00206 
00207   IM_FEEDBACK_COUNT(feedback) = count;
00208 }
00209 
00210 static IMText *
00211 iml_make_imtext (iml_session_t *s,
00212                UTFCHAR *p,
00213                IMFeedbackList *feedback)
00214 {
00215   IMText *text;
00216   int len = utfchar_length (p);
00217 
00218   if (s)
00219     text = (IMText *) s->If->m->iml_new (s, sizeof (IMText));
00220   else
00221     text = (IMText *) malloc (sizeof (IMText));
00222 
00223   memset (text, 0, sizeof (IMText));
00224 
00225   text->encoding = UTF16_CODESET;
00226 
00227   if (s)
00228     text->text.utf_chars = (UTFCHAR *) s->If->m->iml_new (s,
00229                                          sizeof (UTFCHAR) * (len + 1));
00230   else
00231     text->text.utf_chars = (UTFCHAR *) malloc (sizeof (UTFCHAR) * (len + 1));
00232 
00233   utfchar_copy (text->text.utf_chars, p);
00234   text->char_length = len;
00235 
00236   if (feedback)
00237     text->feedback = feedback;
00238   else
00239     {
00240       int i;
00241 
00242       text->feedback = create_feedback_list (s, len);
00243       for (i = 0; i < len; i++)
00244        set_feedback (text->feedback + i, IMReverse, -1, -1, -1);
00245     }
00246 
00247   return text;
00248 }
00249 
00250 static void
00251 iml_commit (iml_session_t *s, UTFCHAR *commit_str)
00252 {
00253   int len = utfchar_length (commit_str);
00254   iml_inst *lp;
00255   IMText *text;
00256 
00257   if (len) return;
00258 
00259   text = iml_make_imtext (s, commit_str, NULL);
00260   lp = (iml_inst *) s->If->m->iml_make_commit_inst (s, text);
00261   s->If->m->iml_execute (s, &lp);
00262 }
00263 
00264 static void
00265 iml_forward_keypress (iml_session_t *s,
00266                     IMKeyEventStruct *key)
00267 {
00268   iml_inst *lp;
00269 
00270   lp = (iml_inst *) s->If->m->iml_make_keypress_inst (s, key);
00271   s->If->m->iml_execute (s, &lp);
00272 }
00273 
00274 static void
00275 iml_conversion_on (iml_session_t *s)
00276 {
00277   iml_inst *lp;
00278 
00279   lp = (iml_inst *) s->If->m->iml_make_start_conversion_inst (s);
00280   s->If->m->iml_execute (s, &lp);
00281 }
00282 
00283 static void
00284 iml_conversion_off (iml_session_t *s)
00285 {
00286   iml_inst *lp;
00287 
00288   lp = (iml_inst *) s->If->m->iml_make_end_conversion_inst (s);
00289   s->If->m->iml_execute (s, &lp);
00290 }
00291 
00292 static void
00293 iml_status_start (iml_session_t *s)
00294 {
00295   iml_inst *lp;
00296   iml_inst *rrv = NULL;
00297 
00298   lp = (iml_inst *) s->If->m->iml_make_status_start_inst (s);
00299   s->If->m->iml_link_inst_tail (&rrv, lp);
00300 }
00301 
00302 static void
00303 iml_status_end (iml_session_t *s)
00304 {
00305   iml_inst *lp;
00306 
00307   lp = (iml_inst *) s->If->m->iml_make_status_done_inst (s);
00308   s->If->m->iml_execute (s, &lp);
00309 }
00310 
00311 static void
00312 iml_status_draw (iml_session_t *s,
00313                UTFCHAR *status_str)
00314 {
00315   IMText *text;
00316   iml_inst *lp, *rrv = NULL;
00317 
00318   iml_status_start (s);
00319 
00320   text = iml_make_imtext (s, status_str, NULL);
00321   lp = (iml_inst *) s->If->m->iml_make_status_draw_inst (s, text);
00322   s->If->m->iml_link_inst_tail (&rrv, lp);
00323   s->If->m->iml_execute (s, &rrv);
00324 }
00325 
00326 static void
00327 iml_preedit_start (iml_session_t *s)
00328 {
00329   iml_inst *lp, *rrv = NULL;
00330 
00331   lp = (iml_inst *) s->If->m->iml_make_preedit_start_inst (s);
00332   s->If->m->iml_link_inst_tail (&rrv, lp);
00333 }
00334 
00335 static void
00336 iml_preedit_end (iml_session_t *s)
00337 {
00338   iml_inst *lp, *rrv = NULL;
00339 
00340   lp = (iml_inst *) s->If->m->iml_make_preedit_erase_inst (s);
00341   s->If->m->iml_link_inst_tail (&rrv, lp);
00342 
00343   lp = (iml_inst *) s->If->m->iml_make_preedit_done_inst (s);
00344   s->If->m->iml_link_inst_tail (&rrv, lp);
00345 
00346   s->If->m->iml_execute (s, &rrv);
00347 }
00348 
00349 /*
00350  * Caret position is invalid if the `caret_pos` is -1.
00351  */
00352 static void
00353 iml_preedit_draw (iml_session_t *s,
00354                 UTFCHAR *preedit_str,
00355                 int caret_pos)
00356 {
00357   int len = utfchar_length (preedit_str);
00358   iml_inst *lp, *rrv = NULL;
00359   IMText *text;
00360 
00361   iml_preedit_start (s);
00362 
00363   if (!len)
00364     {
00365       lp = (iml_inst *) s->If->m->iml_make_preedit_erase_inst (s);
00366       s->If->m->iml_link_inst_tail (&rrv, lp);
00367       s->If->m->iml_execute (s, &rrv);
00368       
00369       return;
00370     }
00371 
00372   text = iml_make_imtext (s, preedit_str, NULL);
00373   lp = (iml_inst *) s->If->m->iml_make_preedit_draw_inst (s, text);
00374   s->If->m->iml_link_inst_tail (&rrv, lp);
00375 
00376   if (caret_pos != -1)
00377     {
00378       lp = (iml_inst *) s->If->m->iml_make_preedit_caret_inst (s,
00379                                                         caret_pos);
00380       s->If->m->iml_link_inst_tail (&rrv, lp);
00381     }
00382 
00383   s->If->m->iml_execute (s, &rrv);
00384 }
00385 
00386 static void
00387 iml_lookup_start (iml_session_t *s,
00388                 LayoutInfo *layout)
00389 {
00390   iml_inst *lp;
00391   IMLookupStartCallbackStruct *start_cb;
00392   LayoutInfo *tmp_layout;
00393 
00394   if (s)
00395     {
00396       start_cb = (IMLookupStartCallbackStruct *) s->If->m->iml_new (s,
00397                                      sizeof (IMLookupStartCallbackStruct));
00398       tmp_layout = (LayoutInfo *) s->If->m->iml_new (s, sizeof (LayoutInfo));
00399     }
00400   else
00401     {
00402       start_cb = (IMLookupStartCallbackStruct *) malloc (sizeof (IMLookupStartCallbackStruct));
00403       tmp_layout = (LayoutInfo *) malloc (sizeof (LayoutInfo));
00404     }
00405 
00406   memset (start_cb, 0, sizeof (IMLookupStartCallbackStruct));
00407   memset (tmp_layout, 0, sizeof (LayoutInfo));
00408 
00409   start_cb->IMPreference = tmp_layout;
00410 
00411   memcpy (start_cb->IMPreference, layout, sizeof (LayoutInfo));
00412   start_cb->IMPreference->whoOwnsLabel = IMOwnsLabel;
00413 
00414   start_cb->CBPreference = NULL;
00415   start_cb->whoIsMaster = IMIsMaster;
00416 
00417   lp = (iml_inst *) s->If->m->iml_make_lookup_start_inst (s, start_cb);
00418   s->If->m->iml_execute (s, &lp);
00419 }
00420 
00421 static void
00422 iml_lookup_end (iml_session_t *s)
00423 {
00424   iml_inst *lp;
00425 
00426   lp = (iml_inst *) s->If->m->iml_make_lookup_done_inst (s);
00427   s->If->m->iml_execute (s, &lp);
00428 }
00429 
00430 static void
00431 iml_lookup_draw (iml_session_t *s,
00432                int lookup_num,
00433                UTFCHAR **lookup_strs,
00434                IMFeedbackList **lookup_feedbacks,
00435                UTFCHAR **label_strs,
00436                IMFeedbackList **label_feedbacks,
00437                UTFCHAR *title_str,
00438                IMFeedbackList *title_feedbacks,
00439                int cur_cand_id,
00440                int vertical)
00441 {
00442   int i, max_len = 0;
00443   IMLookupStartCallbackStruct *start_cb;
00444   IMLookupDrawCallbackStruct *draw_cb;
00445   IMFeedbackList *feedback;
00446   IMText **cand, **label;
00447   iml_inst *lp;
00448   LayoutInfo *layout;
00449 
00450   if (lookup_num <= 0 || !lookup_strs || !label_strs)
00451     return;
00452 
00453   if (s)
00454     {
00455       start_cb = (IMLookupStartCallbackStruct *) s->If->m->iml_new (s,
00456                                        sizeof (IMLookupStartCallbackStruct));
00457       layout = (LayoutInfo *) s->If->m->iml_new (s, sizeof (LayoutInfo));
00458     }
00459   else
00460     {
00461       start_cb = (IMLookupStartCallbackStruct *) malloc (sizeof (IMLookupStartCallbackStruct));
00462       layout = (LayoutInfo *) malloc (sizeof (LayoutInfo));
00463     }
00464 
00465   start_cb->whoIsMaster = IMIsMaster;
00466 
00467   layout->choice_per_window = lookup_num;
00468   layout->ncolumns = (vertical) ? 1 : lookup_num;
00469   layout->nrows = (vertical) ? lookup_num : 1;
00470   layout->drawUpDirection = vertical;
00471   layout->whoOwnsLabel = IMOwnsLabel;
00472 
00473   start_cb->IMPreference = layout;
00474 
00475   lp = s->If->m->iml_make_lookup_start_inst (s, start_cb);
00476   s->If->m->iml_execute (s, &lp);
00477 
00478   if (s)
00479     cand = (IMText **) s->If->m->iml_new (s, lookup_num * sizeof (IMText *));
00480   else
00481     cand = (IMText **) malloc (lookup_num * sizeof (IMText *));
00482 
00483   if (!cand) return;
00484   memset (cand, 0, lookup_num * sizeof (IMText *));
00485 
00486   for (i = 0; i < lookup_num; ++i)
00487     {
00488       if (lookup_feedbacks) 
00489        feedback = lookup_feedbacks[i];
00490       else
00491        feedback = NULL;
00492 
00493       if (lookup_strs[i])
00494        cand[i] = (IMText *)iml_make_imtext (s, lookup_strs[i], feedback);
00495     }
00496 
00497   if (s)
00498     label = (IMText **) s->If->m->iml_new (s, lookup_num * sizeof (IMText *));
00499   else
00500     label = (IMText **) malloc (lookup_num * sizeof (IMText *));
00501 
00502   if (!label) return;
00503   memset (label, 0, sizeof (lookup_num * sizeof (IMText *)));
00504 
00505   for (i = 0; i < lookup_num; ++i)
00506     {
00507       if (label_feedbacks)
00508        feedback = label_feedbacks[i];
00509       else
00510        feedback = NULL;
00511 
00512       if (label_strs[i])
00513        label[i] = (IMText *)iml_make_imtext (s, label_strs[i], feedback);
00514     }
00515 
00516   if (s)
00517     draw_cb = (IMLookupDrawCallbackStruct *) s->If->m->iml_new (s,
00518                                    sizeof (IMLookupDrawCallbackStruct));
00519   else
00520     draw_cb = (IMLookupDrawCallbackStruct *) malloc (sizeof (IMLookupDrawCallbackStruct));
00521 
00522   if (!draw_cb) return;
00523 
00524   memset (draw_cb, 0, sizeof (IMLookupDrawCallbackStruct));
00525 
00526   if (title_str)
00527     draw_cb->title = (IMText *) iml_make_imtext (s, title_str, title_feedbacks);
00528 
00529   draw_cb->n_choices = lookup_num;
00530   draw_cb->index_of_first_candidate = 0;
00531   draw_cb->index_of_last_candidate = lookup_num - 1;
00532   draw_cb->index_of_current_candidate = cur_cand_id;
00533 
00534   if (s)
00535     draw_cb->choices = (IMChoiceObject *) s->If->m->iml_new (s,
00536                                         lookup_num * sizeof (IMChoiceObject));
00537   else
00538     draw_cb->choices = (IMChoiceObject *) malloc (lookup_num * sizeof (IMChoiceObject));
00539 
00540   if (!draw_cb->choices) return;
00541 
00542   memset (draw_cb->choices, 0, lookup_num * sizeof (IMChoiceObject));
00543 
00544   for (i = 0; i < lookup_num; ++i)
00545     {
00546       IMText *vt; /* for value */
00547       IMText *lt; /* for label */
00548 
00549       vt = draw_cb->choices[i].value = cand[i];
00550       lt = draw_cb->choices[i].label = label[i];
00551 
00552       if (vt && max_len < vt->char_length)
00553        max_len = vt->char_length;
00554     }
00555 
00556   draw_cb->max_len = max_len;
00557 
00558   lp = (iml_inst *) s->If->m->iml_make_lookup_draw_inst (s, draw_cb);
00559   s->If->m->iml_execute (s, &lp);
00560 }
00561 
00562 static void
00563 iml_aux_start (iml_session_t *s,
00564               char *auxname)
00565 {
00566   iml_inst *lp;
00567   IMAuxStartCallbackStruct *start_cb;
00568 
00569   if (s)
00570     start_cb = (IMAuxStartCallbackStruct *) s->If->m->iml_new (s,
00571                                      sizeof (IMAuxStartCallbackStruct));
00572   else
00573     start_cb = (IMAuxStartCallbackStruct *) malloc (sizeof (IMAuxStartCallbackStruct));
00574 
00575   if (!start_cb) return;
00576 
00577   memset (start_cb, 0, sizeof (IMAuxStartCallbackStruct));
00578   start_cb->aux_name = auxname;
00579 
00580   lp = (iml_inst *) s->If->m->iml_make_aux_start_inst (s, start_cb);
00581   s->If->m->iml_execute (s, &lp);
00582 }
00583 
00584 static void
00585 iml_aux_done (iml_session_t *s,
00586              char *auxname)
00587 {
00588   iml_inst *lp;
00589   IMAuxDoneCallbackStruct *done_cb;
00590 
00591   if (s)
00592     done_cb = (IMAuxDoneCallbackStruct *) s->If->m->iml_new (s,
00593                                  sizeof (IMAuxDoneCallbackStruct));
00594   else
00595     done_cb = (IMAuxDoneCallbackStruct *) malloc (sizeof (IMAuxDoneCallbackStruct));
00596 
00597   if (!done_cb) return;
00598 
00599   memset (done_cb, 0, sizeof (IMAuxDoneCallbackStruct));
00600   done_cb->aux_name = auxname;
00601 
00602   lp = (iml_inst *) s->If->m->iml_make_aux_done_inst (s, done_cb);
00603   s->If->m->iml_execute (s, &lp);
00604 }
00605 
00606 static void
00607 iml_aux_draw (iml_session_t *s,
00608              char *auxname,
00609              int num_integers,
00610              int *integers,
00611              int num_strings,
00612              int *string_char_lens,
00613              UTFCHAR **strings)
00614 {
00615   iml_inst *lp;
00616   IMText *text;
00617   IMAuxDrawCallbackStruct *draw_cb;
00618   int i, len;
00619 
00620   if (s)
00621     draw_cb = (IMAuxDrawCallbackStruct *) s->If->m->iml_new (s,
00622                                                sizeof (IMAuxDrawCallbackStruct));
00623   else
00624     draw_cb = (IMAuxDrawCallbackStruct *) malloc (sizeof (IMAuxDrawCallbackStruct));
00625 
00626   if (!draw_cb) return;
00627 
00628   memset (draw_cb, 0, sizeof (IMAuxDrawCallbackStruct));
00629   draw_cb->aux_name = auxname;
00630 
00631   draw_cb->count_integer_values = num_integers;
00632   if (num_integers)
00633     {
00634       draw_cb->integer_values = (int *) s->If->m->iml_new (s,
00635                                        sizeof (int) * num_integers);
00636       memset (draw_cb->integer_values, 0, sizeof (int) * num_integers);
00637       memset (draw_cb->integer_values, 0, sizeof (int) * num_integers);
00638 
00639       for (i = 0; i < num_integers; ++i)
00640        draw_cb->integer_values[i] = integers[i];
00641     }
00642 
00643   draw_cb->count_string_values = num_strings;
00644   if (num_strings)
00645     {
00646       draw_cb->string_values = (IMText *) s->If->m->iml_new (s,
00647                                         sizeof (IMText) * num_strings);
00648       memset (draw_cb->string_values, 0, sizeof (IMText) * num_strings);
00649 
00650       draw_cb->string_values->encoding = UTF16_CODESET;
00651       for (i = 0, text = draw_cb->string_values; i < num_strings; ++i, ++text)
00652        {
00653          len = strings[i] ? utfchar_length (strings[i]) : 0;
00654          text->text.utf_chars = (UTFCHAR *) s->If->m->iml_new (s,
00655                                           sizeof (UTFCHAR) * (len + 1));
00656          memset (text->text.utf_chars, 0, sizeof (UTFCHAR) * (len + 1));
00657          text->char_length = len + 1;
00658          if (strings[i])
00659            memcpy (text->text.utf_chars, strings[i], len * sizeof (UTFCHAR));
00660        }
00661     }
00662 
00663   lp = (iml_inst *) s->If->m->iml_make_aux_draw_inst (s, draw_cb);
00664   s->If->m->iml_execute (s, &lp);
00665 }
00666 
00667 /* Local Variables: */
00668 /* c-file-style: "iiim-project" */
00669 /* End: */