home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* Copyright 1988, 1989 by Chuck Musciano and Harris Corporation */
- /* */
- /* Permission to use, copy, modify, and distribute this software */
- /* and its documentation for any purpose and without fee is */
- /* hereby granted, provided that the above copyright notice */
- /* appear in all copies and that both that copyright notice and */
- /* this permission notice appear in supporting documentation, and */
- /* that the name of Chuck Musciano and Harris Corporation not be */
- /* used in advertising or publicity pertaining to distribution */
- /* of the software without specific, written prior permission. */
- /* Chuck Musciano and Harris Corporation make no representations */
- /* about the suitability of this software for any purpose. It is */
- /* provided "as is" without express or implied warranty. This */
- /* software may not be sold without the prior explicit permission */
- /* of Harris Corporation. */
- /************************************************************************/
-
- #include <stdio.h>
-
- #include <suntool/sunview.h>
- #include <suntool/panel.h>
-
- #include "contool.h"
-
- /************************************************************************/
- PRIVATE text_width(text, font)
-
- char *text;
- struct pixfont *font;
-
- { int width;
-
- for (width = 0; *text; text++)
- width += font->pf_char[*text].pc_adv.x;
- return(width);
- }
-
- /************************************************************************/
- EXPORT struct pixrect *better_button_image(panel, text, chars, pixels, font)
-
- Panel panel;
- char *text;
- int chars;
- int pixels;
- struct pixfont *font;
-
- { struct pixrect *pr;
- struct pr_prpos pos;
- int width, true_width, height;
-
- if (font == NULL)
- font = (struct pixfont *) window_get(panel, WIN_FONT);
- width = chars * font->pf_char['0'].pc_adv.x + pixels;
- true_width = text_width(text, font);
- if (width < true_width)
- width = true_width;
- pr = mem_create(width + 8, height = font->pf_defaultsize.y + 6, 1);
- pr_rop(pr, 3, 0, width + 2, 2, PIX_SRC | PIX_COLOR(1), NULL, 0, 0);
- pr_rop(pr, 3, height - 2, width + 2, 2, PIX_SRC | PIX_COLOR(1), NULL, 0, 0);
- pr_rop(pr, 0, 3, 2, height - 6, PIX_SRC | PIX_COLOR(1), NULL, 0, 0);
- pr_rop(pr, width + 6, 3, 2, height - 6, PIX_SRC | PIX_COLOR(1), NULL, 0, 0);
- pr_rop(pr, 1, 1, 3, 3, PIX_SRC | PIX_DST, &better_button_cross, 0, 0);
- pr_rop(pr, width + 4, 1, 3, 3, PIX_SRC | PIX_DST, &better_button_cross, 0, 0);
- pr_rop(pr, width + 4, height - 4, 3, 3, PIX_SRC | PIX_DST, &better_button_cross, 0, 0);
- pr_rop(pr, 1, height - 4, 3, 3, PIX_SRC | PIX_DST, &better_button_cross, 0, 0);
- pos.pr = pr;
- pos.pos.x = 4 + (width - true_width) / 2;
- pos.pos.y = 4 - font->pf_char['T'].pc_home.y;
- pf_ttext(pos, PIX_SRC | PIX_COLOR(1), font, text);
- return(pr);
- }
-