#include "v_view.h"
#include MUT_H
#include MPH_H
#include "mbk_extern.h"
#include "g_visu.h"
#include "g_extern.c"
#include "v_extern.h"
#include "v_menu.h"

void put_str(pt, drawable)
X_RECT *pt;
Drawable drawable;
{
int i, j;
char *buffer;
LAMBDA xstr, ystr;

	/* font choice */
	XSetFont(display, V_gcCao[GC_FGND], V_vr[0]);
	for (i = 1, j = 0; j < 5; j++, i += 3)
		if (scale >= i && scale < i + 3) {
			XSetFont(display, V_gcCao[GC_FGND], V_vr[j]);
			break;
		}
	XSetForeground(display, V_gcCao[GC_FGND], V_colors[COLOR_FGND]);
	/* going thru strings */
	string_coord(pt, &xstr, &ystr);
	switch (pt->TYPE & MASK) {
		case INSCON:
		case FIGCON:
			if (((C_Config_List.C_VISIBLE >> (GC_DEFAULT + 1)) & 1) == 1)
				if (((phcon_list *)pt->PTMBK)->NAME) {
					buffer = nameindex(((phcon_list *) pt->PTMBK)->NAME,
											((phcon_list *)pt->PTMBK)->INDEX);
					XDrawString(display, drawable, V_gcCao[GC_FGND],
									(int)((xstr - xscreen) * scale),
									YMENU - 1 +
									(int)((yscreen - ystr + dyscreen) * scale),
									buffer, strlen(buffer));
				}
			break;
		case REF:
			if (((C_Config_List.C_VISIBLE >> (GC_DEFAULT + 3)) & 1) == 1)
				if (((phref_list *)pt->PTMBK)->NAME)
					XDrawString(display, drawable, V_gcCao[GC_FGND],
									(int)((xstr - xscreen) * scale),
									YMENU - 1 
									+ (int)((yscreen - ystr + dyscreen) * scale),
									((phref_list *)pt->PTMBK)->NAME,
									strlen(((phref_list *)pt->PTMBK)->NAME));
			break;
		case SEG:
			if (((C_Config_List.C_VISIBLE >> (GC_DEFAULT + 2)) & 1) == 1)
				if (((phseg_list *)pt->PTMBK)->NAME)
					XDrawString(display, drawable, V_gcCao[GC_FGND],
									(int)((xstr - xscreen) * scale),
									YMENU - 1 
									+ (int)((yscreen - ystr + dyscreen) * scale),
									((phseg_list *)pt->PTMBK)->NAME,
									strlen(((phseg_list *)pt->PTMBK)->NAME));
			break;
		case INS:
			if (((C_Config_List.C_VISIBLE >> (GC_DEFAULT + 0)) & 1) == 1) {
				if (scale == 2) {
					XSetFont(display, V_gcCao[GC_FGND], V_vr[0]);
					XDrawString(display, drawable, V_gcCao[GC_FGND],
									(int)((xstr - xscreen) * scale),
									YMENU - 1 +
									(int)((yscreen - ystr + dyscreen) * scale),
									((phins_list *) pt->PTMBK)->INSNAME,
									strlen(((phins_list *) pt->PTMBK)->INSNAME));
					XSetFont(display, V_gcCao[GC_FGND], V_vr[j]);
				} else if (j < 4) {
					if (j)
						XSetFont(display, V_gcCao[GC_FGND], V_vr[j + 1]);
					XDrawString(display, drawable, V_gcCao[GC_FGND],
									(int)((xstr - xscreen) * scale),
									YMENU - 1 + (int)((yscreen - ystr + dyscreen) * scale),
									((phins_list *) pt->PTMBK)->INSNAME,
									strlen(((phins_list *)pt->PTMBK)->INSNAME));
					XSetFont(display, V_gcCao[GC_FGND], V_vr[j]);
				} else
					XDrawString(display, drawable, V_gcCao[GC_FGND],
							(int)((xstr - xscreen) * scale),
							YMENU - 1 + (int)((yscreen - ystr + dyscreen) * scale),
							((phins_list *) pt->PTMBK)->INSNAME,
							strlen(((phins_list *) pt->PTMBK)->INSNAME));
			}
	}
}
