/* * drawtetra * * generate a tetraedron as a series of move draws */ drawtetra() { move(-0.5, 0.866, -0.5); draw(-0.5, -0.866, -0.5); draw( 1.0, 0.0, -0.5); draw(-0.5, 0.866, -0.5); draw( 0.0, 0.0, 1.5); draw(-0.5, -0.866, -0.5); move( 1.0, 0.0, -0.5); draw( 0.0, 0.0, 1.5); /* * Label the vertices. */ color(WHITE); textsize(0.3, 0.5); /* set the text size */ move(-0.5, 0.866, -0.5); drawchar('a'); move(-0.5, -0.866, -0.5); drawchar('b'); move( 1.0, 0.0, -0.5); drawchar('c'); move( 0.0, 0.0, 1.5); drawchar('d'); }
void CScrollTool::SetText(LPPOINT pos, const TCHAR * fmt, ...) { if (!m_bInitCalled) { ASSERT( 0 ); return; } CString s; va_list marker; va_start( marker, fmt ); s.FormatV(fmt, marker); va_end( marker ); CSize textsize(0); if (m_bRightAligned) { CDC *pDC = GetDC(); textsize = pDC->GetTextExtent(s); ReleaseDC(pDC); } ti.lpszText = s.GetBuffer(); SendMessage(TTM_UPDATETIPTEXT, 0, (LPARAM)(LPTOOLINFO) &ti); SendMessage(TTM_TRACKPOSITION, 0, MAKELONG(pos->x-textsize.cx, pos->y)); s.ReleaseBuffer(); }
gChoice::gChoice(int x, int y, int w, int h, const char *l, bool ang) : Fl_Choice(x, y, w, h, l), angle(ang) { labelsize(11); labelcolor(COLOR_TEXT_0); box(FL_BORDER_BOX); textsize(11); textcolor(COLOR_TEXT_0); color(COLOR_BG_0); }
gInput::gInput(int x, int y, int w, int h, const char *L) : Fl_Input(x, y, w, h, L) { //Fl::set_boxtype(G_BOX, gDrawBox, 1, 1, 2, 2); box(G_BOX); labelsize(11); labelcolor(COLOR_TEXT_0); color(COLOR_BG_DARK); textcolor(COLOR_TEXT_0); cursor_color(COLOR_TEXT_0); selection_color(COLOR_BD_0); textsize(11); }
MenuBase::MenuBase(int X,int Y,int W,int H,const char* l) : Fl_Widget(X,Y,W,H,l) { set_flag(SHORTCUT_LABEL); box(FL_UP_BOX); when(FL_WHEN_RELEASE_ALWAYS); value_ = menu_ = 0; alloc = 0; selection_color(FL_SELECTION_COLOR); textfont(FL_HELVETICA); textsize((uchar)FL_NORMAL_SIZE); textcolor(FL_FOREGROUND_COLOR); down_box(FL_NO_BOX); }
void button::compute_minimum( void ) { script::font_extents fex = _font->extents(); script::text_extents tex = _font->extents( _text ); base::size textsize( tex.x_advance, fex.height ); base::size full( textsize ); full.grow( 12, 6 ); full.ceil(); full.set_height( std::max( full.h(), 21.0 ) ); set_minimum( full ); }
Fineline_File_Metadata_Browser::Fineline_File_Metadata_Browser(int x, int y, int w, int h) : Fl_Browser(x, y, w, h) { //ctor textfont(FL_HELVETICA); textsize(10); textcolor(FL_DARK_BLUE); static int widths[] = { 100, 150, 150, 150, 100, 100, 100, 100, 100, 50, 0 }; // widths for each column column_widths(widths); column_char('\t'); // tabs as column delimiters type(FL_MULTI_BROWSER); //resizable(); }
gModeBox::gModeBox(int x, int y, int w, int h, const char *L) : Fl_Menu_Button(x, y, w, h, L) { box(G_BOX); textsize(11); textcolor(COLOR_TEXT_0); color(COLOR_BG_0); add("Loop . basic", 0, cb_change_chanmode, (void *)LOOP_BASIC); add("Loop . once", 0, cb_change_chanmode, (void *)LOOP_ONCE); add("Loop . repeat", 0, cb_change_chanmode, (void *)LOOP_REPEAT); add("Oneshot . basic", 0, cb_change_chanmode, (void *)SINGLE_BASIC); add("Oneshot . press", 0, cb_change_chanmode, (void *)SINGLE_PRESS); add("Oneshot . retrig", 0, cb_change_chanmode, (void *)SINGLE_RETRIG); id = id_generator++; }
gModeBox::gModeBox(int x, int y, int w, int h, SampleChannel *ch, const char *L) : Fl_Menu_Button(x, y, w, h, L), ch(ch) { box(G_BOX); textsize(11); textcolor(COLOR_TEXT_0); color(COLOR_BG_0); add("Loop . basic", 0, cb_change_chanmode, (void *)LOOP_BASIC); add("Loop . once", 0, cb_change_chanmode, (void *)LOOP_ONCE); add("Loop . once . bar", 0, cb_change_chanmode, (void *)LOOP_ONCE_BAR); add("Loop . repeat", 0, cb_change_chanmode, (void *)LOOP_REPEAT); add("Oneshot . basic", 0, cb_change_chanmode, (void *)SINGLE_BASIC); add("Oneshot . press", 0, cb_change_chanmode, (void *)SINGLE_PRESS); add("Oneshot . retrig", 0, cb_change_chanmode, (void *)SINGLE_RETRIG); add("Oneshot . endless", 0, cb_change_chanmode, (void *)SINGLE_ENDLESS); }
gBrowser::gBrowser(int x, int y, int w, int h, const char *L) : Fl_Hold_Browser(x, y, w, h, L) { box(G_BOX); textsize(11); textcolor(COLOR_TEXT_0); selection_color(COLOR_BG_1); color(COLOR_BG_0); this->scrollbar.color(COLOR_BG_0); this->scrollbar.selection_color(COLOR_BG_1); this->scrollbar.labelcolor(COLOR_BD_1); this->scrollbar.slider(G_BOX); this->hscrollbar.color(COLOR_BG_0); this->hscrollbar.selection_color(COLOR_BG_1); this->hscrollbar.labelcolor(COLOR_BD_1); this->hscrollbar.slider(G_BOX); }
void init_textdragging(F_text *t, int x, int y) { float cw,cw2; int x1, y1; new_t = t; fix_x = cur_x = x; fix_y = cur_y = y; x1 = new_t->base_x; y1 = new_t->base_y; /* adjust fix_x/y so that text will fall on grid if grid is on */ // isometric grid round_coords( &x1, &y1 ); fix_x += new_t->base_x - x1; fix_y += new_t->base_y - y1; x1off = x1-x; /*new_t->base_x - x;*/ y1off = y1-y; /*new_t->base_y - y;*/ if (t->type == T_CENTER_JUSTIFIED || t->type == T_RIGHT_JUSTIFIED) { txsize = textsize(t->fontstruct, strlen(t->cstring), t->cstring); if (t->type == T_CENTER_JUSTIFIED) { cw2 = txsize.length/2.0/display_zoomscale; x1off = round(x1off - cos((double)t->angle)*cw2); y1off = round(y1off + sin((double)t->angle)*cw2); } else { /* T_RIGHT_JUSTIFIED */ cw = 1.0*txsize.length/display_zoomscale; x1off = round(x1off - cos((double)t->angle)*cw); y1off = round(y1off + sin((double)t->angle)*cw); } } canvas_locmove_proc = moving_text; canvas_ref_proc = elastic_movetext; canvas_leftbut_proc = place_text; canvas_middlebut_proc = array_place_text; canvas_rightbut_proc = cancel_text; elastic_movetext(); set_action_on(); }
main() { char dev[20]; int i; fprintf(stderr,"Enter device: "); gets(dev); vinit(dev); color(BLACK); clear(); /* * Set up two viewports (They actually overlap) */ viewport(-1.0, 0.3, -1.0, 0.3); ortho(-2.0, 5.0, -2.0, 5.0, -2.0, 5.0); lookat(0.0, 0.0, 0.0, -3.0, 2.0, -4.0, 0.0); /* * Save it */ pushviewport(); pushmatrix(); viewport(-0.3, 1.0, -0.3, 1.0); ortho(-2.0, 5.0, -2.0, 5.0, -2.0, 5.0); lookat(0.0, 0.0, 0.0, 3.0, 2.0, -4.0, 0.0); textsize(0.4, 0.4); /* * patchcurves provides a number of curves in the t and u * directions. patchprecision gives the minimum number of line * segments making up the curves in the t and u directions. The * actual number of linesegments in t or u is equal to the closest * integer multiple of the number of curves, > nsegs, in t or u, * greater than or equal to the number set by patchprecision in u or * t. eg. curves in t will be made up of 21 line segments so that we * can match up the 7 curves in u; curves in u will have 24 as 4 by 5 * gives 20. */ patchcurves(4, 7); patchprecision(20, 20); for (i = 0; i < 4; i++) { axes(); /* * patchbasis sets the basis matrices for the t and u * functions * */ patchbasis(basis[i], basis[i]); /* * Draw with viewport 2 */ move(0.0, 4.0, 0.0); drawstr(labels[i]); /* * now draw the patches according to the geometry matrices in * x1, y1, and z1, x2, y2, z2. */ drawhull(x1, y1, z1); patch(x1, y1, z1); drawhull(x2, y2, z2); patch(x2, y2, z2); getkey(); /* * Now with viewport 1 */ popviewport(); popmatrix(); axes(); move(0.0, 4.0, 0.0); drawstr(labels[i]); /* * now draw the patches according to the geometry matrices in * x1, y1, and z1, x2, y2, z2. */ drawhull(x1, y1, z1); patch(x1, y1, z1); drawhull(x2, y2, z2); patch(x2, y2, z2); getkey(); /* * Save viewport 1 again and reset to viewport 2 */ pushviewport(); pushmatrix(); viewport(-0.3, 1.0, -0.3, 1.0); ortho(-1.5, 5.0, -1.5, 5.0, -1.5, 5.0); lookat(0.0, 0.0, 0.0, 3.0, 2.0, -4.0, 0.0); color(BLACK); clear(); } vexit(); }
void Fl_ToggleTree::draw_label(char* str, int indent, int x, int y, int w, int h) { const int* i = column_widths(); while (w > 6) { // do each tab-seperated field int w1 = w; // width for this field char* e = 0; // pointer to end of field or null if none if (*i) { // find end of field and temporarily replace with 0 for (e = str; *e && *e != column_char(); e++); if (*e) { *e = 0; w1 = *i++; } else e = 0; } int size = textsize(); Fl_Font font = textfont(); Fl_Color lcol = textcolor(); Fl_Align align = (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP); // check for all the @-lines recognized by XForms: /* while (*str == format_char() && *++str && *str != format_char()) { switch (*str++) { case 'l': case 'L': size = 24; break; case 'm': case 'M': size = 18; break; case 's': size = 11; break; case 'b': font = (Fl_Font)(font|FL_BOLD); break; case 'i': font = (Fl_Font)(font|FL_ITALIC); break; case 'f': case 't': font = FL_COURIER; break; case 'c': align = FL_ALIGN_CENTER; break; case 'r': align = FL_ALIGN_RIGHT; break; case 'B': fl_color((Fl_Color)strtol(str, &str, 10)); fl_rectf(x, y, w1, h); break; case 'C': lcol = (Fl_Color)strtol(str, &str, 10); break; case 'F': font = (Fl_Font)strtol(str, &str, 10); break; case 'N': lcol = FL_INACTIVE_COLOR; break; case 'S': size = strtol(str, &str, 10); break; case '-': fl_color(FL_DARK3); fl_line(x+3, y+h/2, x+w1-3, y+h/2); fl_color(FL_LIGHT3); fl_line(x+3, y+h/2+1, x+w1-3, y+h/2+1); break; case 'u': case '_': fl_color(lcol); fl_line(x+3, y+h-1, x+w1-3, y+h-1); break; case '.': goto BREAK; case '@': str--; goto BREAK; } } BREAK: */ fl_font(font, size); //if (!active_r()) lcol = inactive(lcol); // if (((FL_BLINE*)v)->flags & SELECTED) // lcol = contrast(lcol, selection_color()); fl_color(lcol); fl_draw(str, x + indent, y + 1, w1 - indent, h + 1, align); if (!e) break; // no more fields... *e = column_char(); // put the seperator back x += w1; w -= w1; str = e + 1; indent = 0; } }
static int size_html_txt(graph_t *g, htmltxt_t* ftxt, htmlenv_t* env) { double xsize = 0.0; /* width of text block */ double ysize = 0.0; /* height of text block */ double fsize; double lsize; /* height of current line */ double mxfsize; /* max. font size for the current line */ double curbline = 0; /* dist. of current base line from top */ pointf sz; int i, j, w, width; char *fname; textpara_t lp; for (i = 0; i < ftxt->nparas; i++) { width = w = 0; mxfsize = 0; for (j = 0; j < ftxt->paras[i].nitems; j++) { lp.str = strdup_and_subst_obj (ftxt->paras[i].items[j].str, env->obj); if (ftxt->paras[i].items[j].font) { if (ftxt->paras[i].items[j].font->size > 0) fsize = ftxt->paras[i].items[j].font->size; else fsize = env->finfo.size; if (ftxt->paras[i].items[j].font->name) fname = ftxt->paras[i].items[j].font->name; else fname = env->finfo.name; } else { fsize = env->finfo.size; fname = env->finfo.name; } sz = textsize(g, &lp, fname, fsize); free (ftxt->paras[i].items[j].str); ftxt->paras[i].items[j].str = lp.str; ftxt->paras[i].items[j].size = sz.x; ftxt->paras[i].items[j].xshow = lp.xshow; ftxt->paras[i].items[j].postscript_alias = lp.postscript_alias; ftxt->paras[i].items[j].layout = lp.layout; ftxt->paras[i].items[j].free_layout = lp.free_layout; width += sz.x; mxfsize = MAX(fsize, mxfsize); } lsize = mxfsize * LINESPACING; ftxt->paras[i].size = (double) width; /* ysize - curbline is the distance from the previous * baseline to the bottom of the previous line. * Then, in the current line, we set the baseline to * be 5/6 of the max. font size. Thus, lfsize gives the * distance from the previous baseline to the new one. */ ftxt->paras[i].lfsize = 5*mxfsize/6 + ysize - curbline; curbline += ftxt->paras[i].lfsize; xsize = MAX(width, xsize); ysize += lsize; } ftxt->box.UR.x = xsize; if (ftxt->nparas == 1) ftxt->box.UR.y = (int) (mxfsize); else ftxt->box.UR.y = (int) (ysize); return 0; }
static Boolean replace_text_in_compound(F_compound *com, char *pattern, char *dst) { F_compound *c; F_text *t; PR_SIZE size; Boolean replaced, processed; int pat_len, i, j; char str[300]; pat_len = strlen(pattern); if (pat_len == 0) return False; processed = False; for (c = com->compounds; c != NULL; c = c->next) { if (replace_text_in_compound(c, pattern, dst)) processed = True; } for (t = com->texts; t != NULL; t = t->next) { replaced = False; if (pat_len <= strlen(t->cstring)) { str[0] = '\0'; j = 0; for (i = 0; i <= strlen(t->cstring) - pat_len; i++) { if (compare_string(&t->cstring[i], pattern)) { if (strlen(str) + strlen(dst) < sizeof(str)) { strncat(str, &t->cstring[j], i - j); strcat(str, dst); i += pat_len - 1; j = i + 1; replaced = True; } else { /* string becomes too long; don't replace it */ replaced = False; } } } if (replaced && j < strlen(t->cstring)) { if (strlen(str) + strlen(&t->cstring[j]) < sizeof(str)) { strcat(str, &t->cstring[j]); } else { replaced = False; } } if (replaced) { /* replace the text object */ if (strlen(t->cstring) != strlen(str)) { free(t->cstring); t->cstring = new_string(strlen(str)); } strcpy(t->cstring, str); size = textsize(lookfont(x_fontnum(psfont_text(t), t->font), t->size), strlen(t->cstring), t->cstring); t->ascent = size.ascent; t->descent = size.descent; t->length = size.length; processed = True; } } } if (processed) compound_bound(com, &com->nwcorner.x, &com->nwcorner.y, &com->secorner.x, &com->secorner.y); return processed; }
/* * Shows various combinations of viewing and * projection transformations. */ main() { char device[20]; fprintf(stderr,"Enter device name: "); gets(device); vinit(device); color(BLACK); clear(); /* * we want to draw just within the boundaries of the screen */ viewport(-0.9, 0.9, -0.9, 0.9); ortho2(-5.0, 5.0, -5.0, 5.0); /* set the world size */ color(RED); rect(-5.0, -5.0, 5.0, 5.0); /* draw a boundary frame */ /* * set up a perspective projection with a field of view of * 40.0 degrees, aspect ratio of 1.0, near clipping plane 0.1, * and the far clipping plane at 1000.0. */ perspective(40.0, 1.0, 0.1, 1000.0); /* * we want the drawing to be done with our eye point at (5.0, 8.0, 5.0) * looking towards (0.0, 0.0, 0.0). The last parameter gives a twist * in degrees around the line of sight, in this case zero. */ lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0.0); drawtetra(); move2(-4.5, -4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("perspective/lookat"); getkey(); /* * window can also be used to give a perspective projection. Its * arguments are 6 clipping planes, left, right, bottom, top, near, * and far. */ window(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0); /* * as window replaces the current transformation matrix we must * specify our viewpoint again. */ lookat(5.0, 8.0, 5.0, 0.0, 0.0, 0.0, 0.0); color(BLACK); clear(); color(GREEN); rect(-5.0, -5.0, 5.0, 5.0); drawtetra(); move2(-4.5,-4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("window/lookat"); getkey(); /* * set up our original perspective projection again. */ perspective(40.0, 1.0, 0.1, 1000.0); /* * polarview also specifies our viewpoint, but, unlike lookat, in polar * coordinates. Its arguments are the distance from the world origin, an * azimuthal angle in the x-y plane measured from the y axis, an * incidence angle in the y-z plane measured from the z axis, and a * twist around the line of sight. */ polarview(15.0, 30.0, 30.0, 30.0); color(BLACK); clear(); color(MAGENTA); rect(-5.0, -5.0, 5.0, 5.0); drawtetra(); move2(-4.5,-4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("perspective/polarview"); getkey(); /* * once more with window for comparison */ window(-4.0, 4.0, -4.0, 4.0, -4.0, 4.0); polarview(6.0, 20.0, -30.0, 70.0); color(BLACK); clear(); color(YELLOW); rect(-5.0, -5.0, 5.0, 5.0); drawtetra(); move2(-4.5,-4.5); textsize(0.6, 0.9); /* set the text size */ drawstr("window/polarview"); getkey(); vexit(); }