Index: trunk/src/stub_draw.c =================================================================== --- trunk/src/stub_draw.c (revision 23127) +++ trunk/src/stub_draw.c (revision 23128) @@ -88,6 +88,6 @@ static pcb_text_t *dummy_fontsel_text = NULL; -void (*pcb_stub_draw_fontsel)(pcb_hid_gc_t gc, const pcb_hid_expose_ctx_t *e) = dummy_draw_fontsel; -pcb_bool (*pcb_stub_draw_fontsel_mouse_ev)(pcb_hid_mouse_ev_t kind, pcb_coord_t x, pcb_coord_t y) = dummy_mouse; -pcb_text_t **pcb_stub_draw_fontsel_text_obj = &dummy_fontsel_text; +void (*pcb_stub_draw_fontsel)(pcb_hid_gc_t gc, const pcb_hid_expose_ctx_t *e, pcb_text_t *txt) = dummy_draw_fontsel; +pcb_bool (*pcb_stub_draw_fontsel_mouse_ev)(pcb_hid_mouse_ev_t kind, pcb_coord_t x, pcb_coord_t y, pcb_text_t *txt) = dummy_mouse; + Index: trunk/src/stub_draw.h =================================================================== --- trunk/src/stub_draw.h (revision 23127) +++ trunk/src/stub_draw.h (revision 23128) @@ -45,8 +45,7 @@ extern pcb_bool (*pcb_stub_draw_csect_mouse_ev)(pcb_hid_mouse_ev_t kind, pcb_coord_t x, pcb_coord_t y); /* fontsel */ -extern void (*pcb_stub_draw_fontsel)(pcb_hid_gc_t gc, const pcb_hid_expose_ctx_t *e); -extern pcb_bool (*pcb_stub_draw_fontsel_mouse_ev)(pcb_hid_mouse_ev_t kind, pcb_coord_t x, pcb_coord_t y); -extern pcb_text_t **pcb_stub_draw_fontsel_text_obj; +extern void (*pcb_stub_draw_fontsel)(pcb_hid_gc_t gc, const pcb_hid_expose_ctx_t *e, pcb_text_t *txt); +extern pcb_bool (*pcb_stub_draw_fontsel_mouse_ev)(pcb_hid_mouse_ev_t kind, pcb_coord_t x, pcb_coord_t y, pcb_text_t *txt); #endif Index: trunk/src_plugins/dialogs/dlg_fontsel.c =================================================================== --- trunk/src_plugins/dialogs/dlg_fontsel.c (revision 23127) +++ trunk/src_plugins/dialogs/dlg_fontsel.c (revision 23128) @@ -33,7 +33,7 @@ int wprev; int active; - pcb_text_t *old_txt; + pcb_text_t *txt_obj; } fontsel_ctx_t; fontsel_ctx_t fontsel_ctx; @@ -43,8 +43,6 @@ { fontsel_ctx_t *ctx = caller_data; - *pcb_stub_draw_fontsel_text_obj = ctx->old_txt; - PCB_DAD_FREE(ctx->dlg); memset(ctx, 0, sizeof(fontsel_ctx_t)); } @@ -51,12 +49,14 @@ void fontsel_expose_cb(pcb_hid_attribute_t *attrib, pcb_hid_preview_t *prv, pcb_hid_gc_t gc, const pcb_hid_expose_ctx_t *e) { - pcb_stub_draw_fontsel(gc, e); + fontsel_ctx_t *ctx = prv->user_ctx; + pcb_stub_draw_fontsel(gc, e, ctx->txt_obj); } pcb_bool fontsel_mouse_cb(pcb_hid_attribute_t *attrib, pcb_hid_preview_t *prv, pcb_hid_mouse_ev_t kind, pcb_coord_t x, pcb_coord_t y) { - return pcb_stub_draw_fontsel_mouse_ev(kind, x, y); + fontsel_ctx_t *ctx = prv->user_ctx; + return pcb_stub_draw_fontsel_mouse_ev(kind, x, y, ctx->txt_obj); } void fontsel_free_cb(pcb_hid_attribute_t *attrib, void *user_ctx, void *hid_ctx) @@ -101,7 +101,7 @@ } -static void pcb_dlg_fontsel(pcb_board_t *pcb, int modal) +static void pcb_dlg_fontsel(pcb_board_t *pcb, int modal, pcb_text_t *txt_obj) { pcb_box_t vbox = {0, 0, PCB_MM_TO_COORD(55), PCB_MM_TO_COORD(55)}; pcb_hid_dad_buttons_t clbtn[] = {{"Close", 0}, {NULL, 0}}; @@ -109,6 +109,7 @@ return; /* do not open another */ fontsel_ctx.pcb = pcb; + fontsel_ctx.txt_obj = txt_obj; PCB_DAD_BEGIN_VBOX(fontsel_ctx.dlg); PCB_DAD_COMPFLAG(fontsel_ctx.dlg, PCB_HATF_EXPFILL); PCB_DAD_PREVIEW(fontsel_ctx.dlg, fontsel_expose_cb, fontsel_mouse_cb, fontsel_free_cb, &vbox, 200, 200, &fontsel_ctx); @@ -138,14 +139,13 @@ { const char *op = NULL; int modal = 0; + pcb_text_t *txt_obj = NULL; + if (argc > 2) PCB_ACT_FAIL(Fontsel); PCB_ACT_MAY_CONVARG(1, FGW_STR, Fontsel, op = argv[1].val.str); - fontsel_ctx.old_txt = *pcb_stub_draw_fontsel_text_obj; - *pcb_stub_draw_fontsel_text_obj = NULL; - if (op != NULL) { if (pcb_strcasecmp(op, "Object") == 0) { pcb_coord_t x, y; @@ -153,7 +153,7 @@ void *ptr1, *ptr2, *ptr3; pcb_hid_get_coords("Select an Object", &x, &y, 0); if ((type = pcb_search_screen(x, y, PCB_CHANGENAME_TYPES, &ptr1, &ptr2, &ptr3)) != PCB_OBJ_VOID) { - *pcb_stub_draw_fontsel_text_obj = ptr2; + txt_obj = ptr2; modal = 1; } } @@ -160,7 +160,7 @@ else PCB_ACT_FAIL(Fontsel); } - pcb_dlg_fontsel(PCB, modal); + pcb_dlg_fontsel(PCB, modal, txt_obj); return 0; } Index: trunk/src_plugins/draw_fontsel/draw_fontsel.c =================================================================== --- trunk/src_plugins/draw_fontsel/draw_fontsel.c (revision 23127) +++ trunk/src_plugins/draw_fontsel/draw_fontsel.c (revision 23128) @@ -99,23 +99,21 @@ font_coord_t font_coord[MAX_FONT]; int font_coords; -pcb_text_t *fontsel_txt = NULL; - -static void pcb_draw_font(pcb_hid_gc_t gc, pcb_font_t *f, int x, int *y) +static void pcb_draw_font(pcb_hid_gc_t gc, pcb_font_t *f, int x, int *y, pcb_text_t *txt) { - char txt[256]; + char buf[256]; pcb_text_t *t; const char *nm; int y_old = *y; - pcb_font_id_t target_fid = (fontsel_txt == NULL) ? conf_core.design.text_font_id : fontsel_txt->fid; + pcb_font_id_t target_fid = (txt == NULL) ? conf_core.design.text_font_id : txt->fid; nm = (f->name == NULL) ? "" : f->name; - pcb_snprintf(txt, sizeof(txt), "#%d [abc ABC 123] %s", f->id, nm); + pcb_snprintf(buf, sizeof(buf), "#%d [abc ABC 123] %s", f->id, nm); dchkbox(gc, x-4, *y, (f->id == target_fid)); pcb_gui->set_color(gc, pcb_color_black); - t = dtext(x, *y, 200, f->id, txt); + t = dtext(x, *y, 200, f->id, buf); pcb_text_bbox(pcb_font(PCB, f->id, 1), t); *y += pcb_round(PCB_COORD_TO_MM(t->BoundingBox.Y2 - t->BoundingBox.Y1) + 0.5); @@ -129,17 +127,17 @@ } -static void pcb_draw_fontsel(pcb_hid_gc_t gc, const pcb_hid_expose_ctx_t *e) +static void pcb_draw_fontsel(pcb_hid_gc_t gc, const pcb_hid_expose_ctx_t *e, pcb_text_t *txt) { int y = 0; font_coords = 0; - pcb_draw_font(gc, &PCB->fontkit.dflt, 0, &y); + pcb_draw_font(gc, &PCB->fontkit.dflt, 0, &y, txt); if (PCB->fontkit.hash_inited) { htip_entry_t *e; for (e = htip_first(&PCB->fontkit.fonts); e; e = htip_next(&PCB->fontkit.fonts, e)) - pcb_draw_font(gc, e->value, 0, &y); + pcb_draw_font(gc, e->value, 0, &y, txt); } } @@ -153,7 +151,7 @@ return -1; } -static pcb_bool pcb_mouse_fontsel(pcb_hid_mouse_ev_t kind, pcb_coord_t x, pcb_coord_t y) +static pcb_bool pcb_mouse_fontsel(pcb_hid_mouse_ev_t kind, pcb_coord_t x, pcb_coord_t y, pcb_text_t *txt) { pcb_font_id_t fid; int ymm; @@ -163,15 +161,15 @@ ymm = PCB_COORD_TO_MM(y); fid = lookup_fid_for_coord(ymm); if (fid >= 0) { - if (fontsel_txt == NULL) { + if (txt == NULL) { char sval[128]; sprintf(sval, "%ld", fid); conf_set(CFR_DESIGN, "design/text_font_id", 0, sval, POL_OVERWRITE); } else { - switch(fontsel_txt->type) { + switch(txt->type) { case PCB_OBJ_TEXT: - pcb_text_set_font(fontsel_txt, fid); + pcb_text_set_font(txt, fid); break; default: break; @@ -197,6 +195,5 @@ PCB_API_CHK_VER; pcb_stub_draw_fontsel = pcb_draw_fontsel; pcb_stub_draw_fontsel_mouse_ev = pcb_mouse_fontsel; - pcb_stub_draw_fontsel_text_obj = &fontsel_txt; return 0; }