static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *dp) { #if 0 uiDrawTextFontDescriptor desc; uiDrawTextFont *font; char *s; char *family; // make compiler happy uiDrawTextLayout *layout; uiDrawTextFontMetrics metrics; double ypos; double width; double height; memset(&desc, 0, sizeof (uiDrawTextFontDescriptor)); family = uiEntryText(textFont); desc.Family = family; desc.Size = entryDouble(textSize); desc.Weight = uiComboboxSelected(textWeight); desc.Italic = uiComboboxSelected(textItalic); desc.SmallCaps = uiCheckboxChecked(textSmallCaps); desc.Stretch = uiComboboxSelected(textStretch); desc.Gravity = uiComboboxSelected(textGravity); font = uiDrawLoadClosestFont(&desc); uiFreeText(family); uiDrawTextFontGetMetrics(font, &metrics); width = entryDouble(textWidth); drawGuides(dp->Context, &metrics); s = uiEntryText(textString); layout = uiDrawNewTextLayout(s, font, width); uiFreeText(s); ypos = 10; uiDrawText(dp->Context, 10, ypos, layout); // TODO make these optional? uiDrawTextLayoutExtents(layout, &width, &height); uiDrawFreeTextLayout(layout); layout = uiDrawNewTextLayout("This is a second line", font, -1); if (/*TODO reuse width*/entryDouble(textWidth) < 0) { double ad; ad = metrics.Ascent + metrics.Descent; printf("ad:%g extent:%g\n", ad, height); } ypos += height; if (uiCheckboxChecked(addLeading)) ypos += metrics.Leading; uiDrawText(dp->Context, 10, ypos, layout); uiDrawFreeTextLayout(layout); uiDrawFreeTextFont(font); #endif }
static int l_uiEntryText( lua_State* L ) { char* s = uiEntryText( (uiEntry*) check_object( L, 1, uiEntrySignature ) ); lua_pushstring( L, s ); uiFreeText( s ); return 1; }
// based on the cairo arc sample static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p) { double xc = 128.0; double yc = 128.0; double radius = 100.0; uiDrawBrush source; uiDrawStrokeParams sp; uiDrawPath *path; char *startText; char *sweepText; double factor; source.Type = uiDrawBrushTypeSolid; source.R = 0; source.G = 0; source.B = 0; source.A = 1; sp.Cap = uiDrawLineCapFlat; sp.Join = uiDrawLineJoinMiter; sp.MiterLimit = uiDrawDefaultMiterLimit; sp.Dashes = NULL; sp.NumDashes = 0; sp.DashPhase = 0; startText = uiEntryText(startAngle); sweepText = uiEntryText(sweep); factor = M_PI / 180; if (uiCheckboxChecked(radians)) factor = 1; sp.Thickness = 10.0; path = uiDrawNewPath(uiDrawFillModeWinding); uiDrawPathNewFigure(path, xc, yc); uiDrawPathArcTo(path, xc, yc, radius, atof(startText) * factor, atof(sweepText) * factor, uiCheckboxChecked(negative)); uiDrawPathEnd(path); uiDrawStroke(p->Context, path, &source, &sp); uiDrawFreePath(path); uiFreeText(startText); uiFreeText(sweepText); }
static void entryChanged(uiEntry *e, void *data) { char *text; text = uiEntryText(e); printf("%s entry changed: %s\n", (const char *) data, text); uiFreeText(text); }
static double entryDouble(uiEntry *e) { char *s; double d; s = uiEntryText(e); d = atof(s); uiFreeText(s); return d; }
static Janet janet_ui_entry_text(int32_t argc, Janet *argv) { janet_arity(argc, 1, 2); uiEntry *entry = janet_getuitype(argv, 0, &entry_td); if (argc == 2) { const uint8_t *text = janet_getstring(argv, 1); uiEntrySetText(entry, (const char *)text); return argv[0]; } return janet_cstringv(uiEntryText(entry)); }
static void callback_uiEntryOnChanged( uiEntry* c, void* d ) { lua_State* L = (lua_State*) d; if( L ) { char* str = uiEntryText( c ); lua_pushstring( L, str ); uiFreeText( str ); invoke_callback( L, c, callback_OnChanged, 1 ); } }