home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / sun / volume1 / tooltool2.1c / part07 / objects.c
Encoding:
C/C++ Source or Header  |  1989-06-06  |  18.7 KB  |  491 lines

  1. /************************************************************************/
  2. /*    Copyright 1988 by Chuck Musciano and Harris Corporation        */
  3. /*                                    */
  4. /*    Permission to use, copy, modify, and distribute this software    */
  5. /*    and its documentation for any purpose and without fee is    */
  6. /*    hereby granted, provided that the above copyright notice    */
  7. /*    appear in all copies and that both that copyright notice and    */
  8. /*    this permission notice appear in supporting documentation, and    */
  9. /*    that the name of Chuck Musciano and Harris Corporation not be    */
  10. /*    used in advertising or publicity pertaining to distribution    */
  11. /*    of the software without specific, written prior permission.    */
  12. /*    Chuck Musciano and Harris Corporation make no representations    */
  13. /*    about the suitability of this software for any purpose.  It is    */
  14. /*    provided "as is" without express or implied warranty.        */
  15. /*                                    */
  16. /*    The sale of any product based wholely or in part upon the     */
  17. /*    technology provided by tooltool is strictly forbidden without    */
  18. /*    specific, prior written permission from Harris Corporation.    */
  19. /*    Tooltool technology includes, but is not limited to, the source    */
  20. /*    code, executable binary files, specification language, and    */
  21. /*    sample specification files.                    */
  22. /************************************************************************/
  23.  
  24.  
  25. #include    <ctype.h>
  26.  
  27. #include    "tooltool.h"
  28.  
  29. PRIVATE    short    cross_bits[] = {0x4000, 0xe000, 0x4000};
  30. mpr_static(tt_better_button_cross, 3, 3, 1, cross_bits);
  31.  
  32. PRIVATE    short    arrow_bits[] = {0x0400, 0x0600, 0xFD00, 0x0180, 0xFD00, 0x0600, 0x0400};
  33. mpr_static(tt_menu_arrow, 9, 7, 1, arrow_bits);
  34.  
  35. PUBLIC    event_proc(),
  36.     notify_proc();
  37.  
  38. /************************************************************************/
  39. /* This group of routines contructs individual panel gadgets.        */
  40. /************************************************************************/
  41.  
  42. /************************************************************************/
  43. PRIVATE    struct    pixrect    *better_menu_image(text, chars, pixels, font)
  44.  
  45. char    *text;
  46. int    chars;
  47. int    pixels;
  48. struct    pixfont    *font;
  49.  
  50. {    struct    pixrect    *pr;
  51.     struct    pr_prpos    pos;
  52.     int    width, true_width, height;
  53.  
  54.     width = chars * charwidth_of(font) + pixels;
  55.     true_width = text_width(text, font) + 13;
  56.     if (width < true_width)
  57.        width = true_width;
  58.     pr = mem_create(width + 8, height = charheight_of(font) + 6, 1);
  59.     pr_rop(pr, 0, 0, width + 8, height, PIX_SRC | PIX_COLOR(1), NULL, 0, 0);
  60.     pr_rop(pr, 2, 2, width + 4, height - 4, PIX_SRC | PIX_COLOR(0), NULL, 0, 0);
  61.     pr_rop(pr, width - 5, (height - 7) / 2, 9, 7, PIX_SRC, &tt_menu_arrow, 0, 0);
  62.     pos.pr = pr;
  63.     pos.pos.x = 4 + (width - true_width) / 2;
  64.     pos.pos.y = 4 + baseline_of(font);
  65.     pf_ttext(pos, PIX_SRC | PIX_COLOR(1), font, text);
  66.     return(pr);
  67. }
  68.  
  69. /************************************************************************/
  70. PRIVATE    struct    pixrect    *better_button_image(text, chars, pixels, font)
  71.  
  72. char    *text;
  73. int    chars;
  74. int    pixels;
  75. struct    pixfont    *font;
  76.  
  77. {    struct    pixrect    *pr;
  78.     struct    pr_prpos    pos;
  79.     int    width, true_width, height;
  80.  
  81.     width = chars * charwidth_of(font) + pixels;
  82.     true_width = text_width(text, font);
  83.     if (width < true_width)
  84.        width = true_width;
  85.     pr = mem_create(width + 8, height = charheight_of(font) + 6, 1);
  86.     pr_rop(pr, 3, 0, width + 2, 2, PIX_SRC | PIX_COLOR(1), NULL, 0, 0);
  87.     pr_rop(pr, 3, height - 2, width + 2, 2, PIX_SRC | PIX_COLOR(1), NULL, 0, 0);
  88.     pr_rop(pr, 0, 3, 2, height - 6, PIX_SRC | PIX_COLOR(1), NULL, 0, 0);
  89.     pr_rop(pr, width + 6, 3, 2, height - 6, PIX_SRC | PIX_COLOR(1), NULL, 0, 0);
  90.     pr_rop(pr, 1, 1, 3, 3, PIX_SRC | PIX_DST, &tt_better_button_cross, 0, 0);
  91.     pr_rop(pr, width + 4, 1, 3, 3, PIX_SRC | PIX_DST, &tt_better_button_cross, 0, 0);
  92.     pr_rop(pr, width + 4, height - 4, 3, 3, PIX_SRC | PIX_DST, &tt_better_button_cross, 0, 0);
  93.     pr_rop(pr, 1, height - 4, 3, 3, PIX_SRC | PIX_DST, &tt_better_button_cross, 0, 0);
  94.     pos.pr = pr;
  95.     pos.pos.x = 4 + (width - true_width) / 2;
  96.     pos.pos.y = 4 + baseline_of(font);
  97.     pf_ttext(pos, PIX_SRC | PIX_COLOR(1), font, text);
  98.     return(pr);
  99. }
  100.  
  101. /************************************************************************/
  102. PRIVATE    image_box(gadget)
  103.  
  104. g_ptr    gadget;
  105.  
  106. {    int    w, h, mw, mh;
  107.     cv_ptr    cv;
  108.     double    log10();
  109.  
  110.     if (gadget->kind == GADGET_BUTTON) {
  111.        if (gadget->u.but.label[0]->is_icon) {
  112.           gadget->image = gadget->u.but.label[0]->image;
  113.           gadget->width = gadget->image->pr_width;
  114.           gadget->height = gadget->image->pr_height;
  115.           }
  116.        else {
  117.           gadget->width = text_width(gadget->u.but.label[0]->label, gadget->u.but.label[0]->font) + 8;
  118.           gadget->height = charheight_of(gadget->u.but.label[0]->font) + 6;
  119.           }
  120.        }
  121.     else if (gadget->kind == GADGET_MENU) {
  122.        if (gadget->u.men.label->is_icon) {
  123.           gadget->image = gadget->u.men.label->image;
  124.           gadget->width = gadget->image->pr_width;
  125.           gadget->height = gadget->image->pr_height;
  126.           }
  127.        else {
  128.           gadget->width = text_width(gadget->u.men.label->label, gadget->u.men.label->font) + 21;
  129.           gadget->height = charheight_of(gadget->u.men.label->font) + 6;
  130.           }
  131.        }
  132.     else if (gadget->kind == GADGET_LABEL) {
  133.        tt_construct_label(gadget->u.lab.label);
  134.        gadget->image = gadget->u.lab.label->image;
  135.        gadget->width = gadget->image->pr_width;
  136.        gadget->height = gadget->image->pr_height;
  137.        }
  138.     else if (gadget->kind == GADGET_CHOICE) {
  139.        if (gadget->u.cho.label == NULL) {
  140.           gadget->width = -4; /* hack: correct for 4 pixel offset below */
  141.           gadget->height = 0;
  142.           }
  143.        else {
  144.           tt_construct_label(gadget->u.cho.label);
  145.           gadget->image = gadget->u.cho.label->image;
  146.           gadget->width = gadget->u.cho.label->image->pr_width;
  147.           gadget->height = gadget->u.cho.label->image->pr_height;
  148.           }
  149.        tt_construct_label(gadget->u.cho.mark);
  150.        tt_construct_label(gadget->u.cho.nomark);
  151.        mw = max(gadget->u.cho.mark->image->pr_width, gadget->u.cho.nomark->image->pr_width);
  152.        mh = max(gadget->u.cho.mark->image->pr_height, gadget->u.cho.nomark->image->pr_height);
  153.        for (w = h = 0, cv = gadget->u.cho.value; cv; cv = cv->next) {
  154.           tt_construct_label(cv->label);
  155.           switch (gadget->u.cho.mode) {
  156.              case CHOICE_CURRENT    : 
  157.              case CHOICE_CYCLE      : h = max(cv->label->image->pr_height, h);
  158.                           w = max(cv->label->image->pr_width, w);
  159.                           break;
  160.              case CHOICE_VERTICAL   : h += max(cv->label->image->pr_height, mh) + 4;
  161.                           w = max(cv->label->image->pr_width, w);
  162.                           break;
  163.              case CHOICE_HORIZONTAL : h = max(cv->label->image->pr_height, h);
  164.                           w += cv->label->image->pr_width + mw + 8;
  165.                           break;
  166.          }
  167.           }
  168.        switch (gadget->u.cho.mode) {
  169.           case CHOICE_CURRENT    : gadget->width += w + 4;
  170.                              gadget->height = max(gadget->height, h);
  171.                        break;
  172.           case CHOICE_CYCLE      : gadget->width += w + mw + 8;
  173.                              gadget->height = max(gadget->height, h);
  174.                              gadget->height = max(gadget->height, mh);
  175.                        break;
  176.           case CHOICE_VERTICAL   : gadget->width += w + mw + 8;
  177.                              gadget->height = max(gadget->height, h - 4);
  178.                        break;
  179.           case CHOICE_HORIZONTAL : gadget->width += w;
  180.                        gadget->height = max(gadget->height, h);
  181.                        break;
  182.           }
  183.        gadget->u.cho.ch_width = w;
  184.        gadget->u.cho.ch_height = h;
  185.        }
  186.     else if (gadget->kind == GADGET_SLIDER) {
  187.        if (gadget->u.sli.label == NULL) {
  188.           gadget->width = -4; /* hack: correct for 4 pixel offset below */
  189.           gadget->height = 0;
  190.           }
  191.        else {
  192.           tt_construct_label(gadget->u.sli.label);
  193.           gadget->image = gadget->u.sli.label->image;
  194.           gadget->width = gadget->u.sli.label->image->pr_width;
  195.           gadget->height = gadget->u.sli.label->image->pr_height;
  196.           }
  197.        gadget->height = max(gadget->height, charheight_of(gadget->u.sli.font));
  198.        gadget->width += 10 + gadget->u.sli.width;
  199.        w = max(((int) log10(abs(gadget->u.sli.minimum) + 0.1)), ((int) log10(abs(gadget->u.sli.maximum) + 0.1))) + 1;
  200.        if (gadget->u.sli.minimum < 0 || gadget->u.sli.maximum < 0)
  201.           w++;
  202.        if (gadget->u.sli.range)
  203.           gadget->width += (2 * w + 2) * charwidth_of(gadget->u.sli.font);
  204.        if (gadget->u.sli.value)
  205.           gadget->width += (w + 3) * charwidth_of(gadget->u.sli.font);
  206.        }
  207.     else if (gadget->kind == GADGET_TEXT) {
  208.        if (gadget->u.tex.label == NULL) {
  209.           gadget->width = -4; /* hack: correct for 4 pixel offset below */
  210.           gadget->height = 0;
  211.           }
  212.        else {
  213.           tt_construct_label(gadget->u.tex.label);
  214.           gadget->image = gadget->u.tex.label->image;
  215.           gadget->width = gadget->u.tex.label->image->pr_width;
  216.           gadget->height = gadget->u.tex.label->image->pr_height;
  217.           }
  218.        gadget->width += 4 + gadget->u.tex.display_len * charwidth_of(gadget->u.tex.font);
  219.        gadget->height = max(charheight_of(gadget->u.tex.font), gadget->height);
  220.        }
  221. }
  222.  
  223. /************************************************************************/
  224. EXPORT    tt_build_images(d)
  225.  
  226. d_ptr    d;
  227.  
  228. {    int    i, len = 0;
  229.     g_ptr    b;
  230.     char    *p;
  231.  
  232.     for (b = d->gadgets; b; b = b->next) {
  233.        image_box(b);
  234.        if (b->kind == GADGET_BUTTON || b->kind == GADGET_MENU)
  235.           len = (b->width > len)? b->width : len;
  236.        }
  237.     if (d->proportional)
  238.        len = 0;
  239.     for (b = d->gadgets; b; b = b->next) {
  240.        if (b->kind == GADGET_BUTTON) {
  241.           if (b->image == NULL) {
  242.              b->image = better_button_image(b->u.but.label[0]->label, 0, len - 8, b->u.but.label[0]->font);
  243.              b->width = b->image->pr_width;
  244.              b->height = b->image->pr_height;
  245.              }
  246.           b->u.but.menu = menu_create(0);
  247.           for (i = 0; i < MAX_SHIFT_SETS; i++)
  248.              if (b->u.but.label[i])
  249.                 if (b->u.but.label[i]->is_icon) {
  250.                    menu_set(b->u.but.menu,
  251.                               MENU_APPEND_ITEM, menu_create_item(MENU_IMAGE_ITEM, b->u.but.label[i]->image, b->u.but.action[i],
  252.                                                     0),
  253.                            0);
  254.                    }
  255.                 else {
  256.                    p = (char *) safe_malloc(strlen(b->u.but.label[i]->label) + 5);
  257.                    strcpy(p, "    ");
  258.                    strcat(p, b->u.but.label[i]->label);
  259.                    if (i & S_SHIFT)
  260.                       p[0] = 'S';
  261.                    if (i & S_CONTROL)
  262.                       p[1] = 'C';
  263.                    if (i & S_META)
  264.                       p[2] = 'M';
  265.                    menu_set(b->u.but.menu,
  266.                               MENU_APPEND_ITEM, menu_create_item(MENU_STRING_ITEM, p, b->u.but.action[i],
  267.                                                  MENU_FONT, b->u.but.label[i]->font,
  268.                                                  0),
  269.                            0);
  270.                    }
  271.           }
  272.        else if (b->kind == GADGET_MENU) {
  273.           if (b->image == NULL) {
  274.              b->image = better_menu_image(b->u.men.label->label, 0, len - 8, d->g_font);
  275.              b->width = b->image->pr_width;
  276.              b->height = b->image->pr_height;
  277.              }
  278.           }
  279.        else if (b->kind == GADGET_LABEL) {
  280.           /* do nothing, image_box took care of it */
  281.           }
  282.        else if (b->kind == GADGET_TEXT) {
  283.           /* do nothing, image_box took care of it */
  284.           }
  285.        else if (b->kind == GADGET_CHOICE) {
  286.           /* do nothing, image_box took care of it */
  287.           }
  288.        else if (b->kind == GADGET_SLIDER) {
  289.           /* do nothing, image_box took care of it */
  290.           }
  291.        }
  292. }
  293.  
  294. /************************************************************************/
  295. EXPORT    tt_make_gadget(d, gadget, x, y)
  296.  
  297. d_ptr    d;
  298. g_ptr    gadget;
  299. int    x;
  300. int    y;
  301.  
  302. {    char    *s;
  303.     int    i, lx, ly, mx, my, vx, vy, max_h, max_mh, max_mw;
  304.     Panel_item    p;
  305.     cv_ptr    cv;
  306.  
  307.     if (gadget->x != -1) {
  308.        x = gadget->x;
  309.        y = gadget->y;
  310.        }
  311.     if (gadget->kind == GADGET_BUTTON || gadget->kind == GADGET_MENU)
  312.        p = panel_create_item(d->panel, (gadget->kind == GADGET_BUTTON)? PANEL_BUTTON : PANEL_MESSAGE,
  313.                     PANEL_LABEL_IMAGE, gadget->image,
  314.                     PANEL_ITEM_X, x,
  315.                     PANEL_ITEM_Y, y,
  316.                     PANEL_CLIENT_DATA, gadget,
  317.                     PANEL_EVENT_PROC, event_proc,
  318.                     PANEL_NOTIFY_PROC, notify_proc,
  319.                     PANEL_ACCEPT_KEYSTROKE, !d->text_items_exist,
  320.                  0);
  321.     else if (gadget->kind == GADGET_LABEL)
  322.        p = panel_create_item(d->panel, PANEL_MESSAGE,
  323.                     PANEL_LABEL_IMAGE, gadget->image,
  324.                     PANEL_ITEM_X, x,
  325.                     PANEL_ITEM_Y, y,
  326.                     PANEL_CLIENT_DATA, gadget,
  327.                     PANEL_EVENT_PROC, event_proc,
  328.                     PANEL_NOTIFY_PROC, notify_proc,
  329.                     PANEL_ACCEPT_KEYSTROKE, !d->text_items_exist,
  330.                  0);
  331.     else if (gadget->kind == GADGET_SLIDER) {
  332.        if (gadget->u.sli.label == NULL)
  333.           /* do nothing */ ;
  334.        else if (gadget->u.sli.label->image->pr_height > charheight_of(gadget->u.sli.font)) {
  335.           ly = y;
  336.           vy = y + (gadget->u.sli.label->image->pr_height - charheight_of(gadget->u.sli.font)) / 2;
  337.           }
  338.        else {
  339.           ly = y + (charheight_of(gadget->u.sli.font) - gadget->u.sli.label->image->pr_height) / 2;
  340.           vy = y;
  341.           }
  342.        if (gadget->u.sli.label)
  343.           p = panel_create_item(d->panel, PANEL_SLIDER,
  344.                              PANEL_LABEL_IMAGE, gadget->image,
  345.                              PANEL_LABEL_X, x,
  346.                              PANEL_LABEL_Y, ly,
  347.                              PANEL_VALUE_X, x + gadget->image->pr_width + 4,
  348.                              PANEL_VALUE_Y, vy,
  349.                           0);
  350.        else
  351.           p = panel_create_item(d->panel, PANEL_SLIDER,
  352.                              PANEL_VALUE_X, x,
  353.                              PANEL_VALUE_Y, y,
  354.                           0);
  355.        panel_set(p, PANEL_MIN_VALUE, gadget->u.sli.minimum,
  356.                    PANEL_MAX_VALUE, gadget->u.sli.maximum,
  357.                    PANEL_VALUE, gadget->u.sli.initial,
  358.                    PANEL_VALUE_FONT, gadget->u.sli.font,
  359.                    PANEL_SHOW_RANGE, gadget->u.sli.range,
  360.                    PANEL_SHOW_VALUE, gadget->u.sli.value,
  361.                    PANEL_SLIDER_WIDTH, gadget->u.sli.width,
  362.                    PANEL_CLIENT_DATA, gadget,
  363.                 PANEL_EVENT_PROC, event_proc,
  364.                 PANEL_NOTIFY_PROC, notify_proc,
  365.                 PANEL_ACCEPT_KEYSTROKE, !d->text_items_exist,
  366.              0);
  367.        }
  368.     else if (gadget->kind == GADGET_CHOICE) {
  369.        p = panel_create_item(d->panel, PANEL_CHOICE,
  370.                        PANEL_MARK_IMAGES, gadget->u.cho.mark->image, 0,
  371.                              PANEL_NOMARK_IMAGES, gadget->u.cho.nomark->image, 0,
  372.                              PANEL_CLIENT_DATA, gadget,
  373.                              PANEL_EVENT_PROC, event_proc,
  374.                              PANEL_NOTIFY_PROC, notify_proc,
  375.                              PANEL_FEEDBACK, (gadget->u.cho.mode != CHOICE_CURRENT)? PANEL_MARKED : PANEL_NONE,
  376.                           0);
  377.        if (gadget->u.cho.mode == CHOICE_CURRENT || gadget->u.cho.mode == CHOICE_CYCLE)
  378.           panel_set(p, PANEL_DISPLAY_LEVEL, PANEL_CURRENT, 0);
  379.        else
  380.           panel_set(p, PANEL_DISPLAY_LEVEL, PANEL_ALL, 0);
  381.        max_mw = (gadget->u.cho.mode != CHOICE_CURRENT)? max(gadget->u.cho.mark->image->pr_width, gadget->u.cho.nomark->image->pr_width) : -4;
  382.        max_mh = (gadget->u.cho.mode != CHOICE_CURRENT)? max(gadget->u.cho.mark->image->pr_height, gadget->u.cho.nomark->image->pr_height) : 0;
  383.        if (gadget->u.cho.label) {
  384.           lx = x;
  385.           mx = x + gadget->u.cho.label->image->pr_width + 4;
  386.           vx = mx + max_mw + 4;
  387.           if (gadget->u.cho.label->image->pr_height > max_mh)
  388.              if (gadget->u.cho.label->image->pr_height > gadget->u.cho.ch_height)
  389.                 max_h = gadget->u.cho.label->image->pr_height;
  390.              else
  391.                 max_h = gadget->u.cho.ch_height;
  392.           else if (max_mh > gadget->u.cho.ch_height)
  393.              max_h = max_mh;
  394.           else
  395.              max_h = gadget->u.cho.ch_height;
  396.           ly = y + (max_h - gadget->u.cho.label->image->pr_height) / 2;
  397.           my = y + (max_h - max_mh) / 2;
  398.           vy = y + (max_h - gadget->u.cho.ch_height) / 2;
  399.           }
  400.        else {
  401.           mx = x;
  402.           vx = x + max_mw + 4;
  403.           max_h = max(max_mh, gadget->u.cho.ch_height);
  404.           my = y + (max_h - max_mh) / 2;
  405.           vy = y + (max_h - gadget->u.cho.ch_height) / 2;
  406.           }
  407.        if (gadget->u.cho.mode == CHOICE_VERTICAL) {
  408.           ly = y;
  409.           for (i = 0, vy = y, cv = gadget->u.cho.value; cv; i++, cv = cv->next) {
  410.              if (max_mh > cv->label->image->pr_height)
  411.                 panel_set(p, PANEL_CHOICE_IMAGE, i, cv->label->image,
  412.                          PANEL_CHOICE_X, i, vx,
  413.                          PANEL_CHOICE_Y, i, vy + (max_mh - cv->label->image->pr_height) / 2,
  414.                          PANEL_MARK_X, i, mx,
  415.                          PANEL_MARK_Y, i, vy,
  416.                           0);
  417.              else
  418.                 panel_set(p, PANEL_CHOICE_IMAGE, i, cv->label->image,
  419.                          PANEL_CHOICE_X, i, vx,
  420.                          PANEL_CHOICE_Y, i, vy,
  421.                          PANEL_MARK_X, i, mx,
  422.                          PANEL_MARK_Y, i, vy + (cv->label->image->pr_height - max_mh) / 2,
  423.                           0);
  424.              vy += max(max_mh, cv->label->image->pr_height) + 4;
  425.              }
  426.           }
  427.        else {
  428.           for (i = 0, cv = gadget->u.cho.value; cv; cv = cv->next, i++) {
  429.              panel_set(p, PANEL_CHOICE_IMAGE, i, cv->label->image,
  430.                           PANEL_CHOICE_X, i, vx,
  431.                           PANEL_CHOICE_Y, i, vy + (gadget->u.cho.ch_height - cv->label->image->pr_height) / 2,
  432.                        0);
  433.              if (gadget->u.cho.mode != CHOICE_CURRENT)
  434.                 panel_set(p, PANEL_MARK_X, i, mx,
  435.                              PANEL_MARK_Y, i, my,
  436.                           0);
  437.              if (gadget->u.cho.mode == CHOICE_HORIZONTAL) {
  438.                 mx += max_mw + cv->label->image->pr_width + 8;
  439.                 vx += max_mw + cv->label->image->pr_width + 8;
  440.                 }
  441.              }
  442.           }
  443.        if (gadget->u.cho.label)
  444.           panel_set(p, PANEL_LABEL_IMAGE, gadget->u.cho.label->image,
  445.                      PANEL_LABEL_X, lx,
  446.                      PANEL_LABEL_Y, ly,
  447.                   0);
  448.        }
  449.     else if (gadget->kind == GADGET_TEXT) {
  450.        if (gadget->u.tex.label == NULL)
  451.           vy = y;
  452.        else if (gadget->u.tex.label->is_icon)
  453.           if (gadget->u.tex.label->image->pr_height > gadget->u.tex.font->pf_defaultsize.y) {
  454.              ly = y;
  455.              vy = y + (gadget->height - gadget->u.tex.font->pf_defaultsize.y) / 2;
  456.              }
  457.           else {
  458.              ly = y + (gadget->height - gadget->u.tex.label->image->pr_height) / 2;
  459.              vy = y;
  460.              }
  461.        else
  462.           if (gadget->u.tex.label->font->pf_defaultsize.y > gadget->u.tex.font->pf_defaultsize.y) {
  463.              ly = y;
  464.              vy = y + (baseline_of(gadget->u.tex.label->font) - baseline_of(gadget->u.tex.font));
  465.              }
  466.           else {
  467.              ly = y + (baseline_of(gadget->u.tex.font) - baseline_of(gadget->u.tex.label->font));
  468.              vy = y;
  469.              }
  470.        if (gadget->u.tex.label)
  471.           p = panel_create_item(d->panel, PANEL_TEXT,
  472.                              PANEL_LABEL_IMAGE, gadget->image,
  473.                              PANEL_LABEL_X, x,
  474.                                PANEL_LABEL_Y, ly,
  475.                           0);
  476.        else
  477.           p = panel_create_item(d->panel, PANEL_TEXT, 0);
  478.        panel_set(p, PANEL_VALUE_X, gadget->u.tex.label? x + 4 + gadget->image->pr_width : x,
  479.                 PANEL_VALUE_Y, vy,
  480.                 PANEL_VALUE_DISPLAY_LENGTH, gadget->u.tex.display_len,
  481.                 PANEL_VALUE_STORED_LENGTH, gadget->u.tex.retain_len,
  482.                 PANEL_VALUE_FONT, gadget->u.tex.font,
  483.                PANEL_NOTIFY_LEVEL, PANEL_ALL,
  484.                PANEL_CLIENT_DATA, gadget,
  485.                PANEL_EVENT_PROC, event_proc,
  486.                PANEL_NOTIFY_PROC, notify_proc,
  487.                 0);
  488.        }
  489.     gadget->panel_item = p;
  490. }
  491.