//============================================================================= // eButton::Update //----------------------------------------------------------------------------- void eButton::Update() { bool change_focus = focused != last_focused; eInherited::Update(); if(changed) { changed = false; eRect sr = ScreenBound(); DrawRect(sr, focused ? COLOR_FOCUSED : background); ePoint cen = sr.Beg() + ePoint(sr.Width() / 2, sr.Height() / 2); ePoint t_half((strlen(text) * FontSize().x / 2), FontSize().y / 2); eRect r(cen.x - t_half.x, cen.y - t_half.y, cen.x + t_half.x, cen.y + t_half.y); DrawText(r, text); } if(pushed != last_pushed) { last_pushed = pushed; if(triggered && highlight) DrawRect(ScreenBound(), focused ? COLOR_PUSHED_FOCUSED : COLOR_PUSHED, COLOR_WHITE); else DrawRect(ScreenBound(), focused ? COLOR_FOCUSED : background, COLOR_WHITE); Notify(pushed ? N_PUSH : N_POP); } if(change_focus && triggered && highlight) { DrawRect(ScreenBound(), focused ? COLOR_PUSHED_FOCUSED : COLOR_PUSHED, COLOR_WHITE); } }
void PDF_DefineGraphicNames(OBJECT x) { assert( type(x) == GRAPHIC, "PrintGraphic: type(x) != GRAPHIC!" ); debug1(DPF, D, "DefineGraphicNames( %s )", EchoObject(x)); debug1(DPF, DD, " style = %s", EchoStyle(&save_style(x))); /* if font is different to previous word then print change */ if( font(save_style(x)) != currentfont ) { currentfont = font(save_style(x)); if( currentfont > 0 ) { currentxheight2 = FontHalfXHeight(currentfont); PDFFont_Set(out_fp, FontSize(currentfont, x), FontName(currentfont)); } } /* if colour is different to previous word then print change */ if( colour(save_style(x)) != currentcolour ) { currentcolour = colour(save_style(x)); if( currentcolour > 0 ) { char str[256]; sprintf(str, "%s ", ColourCommand(currentcolour)); PDFPage_Write(out_fp, str); } } PDFPage_SetVars(size(x, COLM), size(x, ROWM), back(x, COLM), fwd(x, ROWM), currentfont <= 0 ? 12*PT : FontSize(currentfont, x), width(line_gap(save_style(x))), width(space_gap(save_style(x)))); debug0(DPF, D, "PDF_DefineGraphicNames returning."); } /* end PDF_DefineGraphicNames */
static void PsFonts(void) { fprintf(outfp, "/HE%d /Helvetica findfont %d scalefont def\n", TITLE_FONT, FontSize(TITLE_FONT)); fprintf(outfp, "/HE%d /Helvetica findfont %d scalefont def\n", SCALE_FONT, FontSize(SCALE_FONT)); fprintf(outfp, "/HE%d /Helvetica findfont %d scalefont def\n", KEY_FONT, FontSize(KEY_FONT)); fprintf(outfp, "/HE%d /Helvetica findfont %d scalefont def\n", SMALLKEY_FONT, FontSize(SMALLKEY_FONT)); }
void DataView::FrameResized(float width, float height) { if (fFitFontSize) { // adapt the font size to fit in the view's bounds float oldSize = FontSize(); BFont font = be_fixed_font; float steps = 0.5f; float size; for (size = 1.f; size < 100; size += steps) { font.SetSize(size); float charWidth = font.StringWidth("w"); if (charWidth * (kBlockSize * 4 + fPositionLength + 6) + 2 * kHorizontalSpace > width) break; if (size > 6) steps = 1.0f; } size -= steps; font.SetSize(size); if (oldSize != size) { SetFont(&font); Invalidate(); } } UpdateScroller(); }
void DataView::FrameResized(float width, float height) { if (fFitFontSize) { // adapt the font size to fit in the view's bounds float oldSize = FontSize(); float steps = 0.5f; float size; for (size = 1.f; size < 100; size += steps) { int32 preferredWidth = WidthForFontSize(size); if (preferredWidth > width) break; if (size > 6) steps = 1.0f; } size -= steps; if (oldSize != size) { BFont font = be_fixed_font; font.SetSize(size); SetFont(&font); Invalidate(); } } UpdateScroller(); }
void StermFrameClass::OnSmallerPress(wxCommandEvent &event) { if (Points > 6) { FontSize (--Points); //Fit (); } }
/* ** Change the font size on the given style by the delta-amount given */ static void ScaleFont(HtmlStyle *pStyle, int delta){ int size = FontSize(pStyle->font) + delta; if( size<0 ){ delta -= size; }else if( size>6 ){ delta -= size-6; } pStyle->font += delta; }
void eProfiler::Init() { background = COLOR_BACKGROUND; int cnt = 0; for(xProfiler::eSection* s = xProfiler::eSection::First(); s; s = s->Next()) { ++cnt; } ePoint margin(6, 6); ePoint size(200, cnt*FontSize().y); sections = new eList; Insert(sections); eRect r_sec(size); r_sec.Move(margin); sections->Bound() = r_sec; eRect r_dlg(ePoint(size.x + margin.x*2, size.y + margin.y*2)); r_dlg.Move(ePoint(10, 10)); Bound() = r_dlg; frames = 0; SectionsUpdate(); }
//============================================================================= // eList::Update //----------------------------------------------------------------------------- void eList::Update() { eRect sr = ScreenBound(); if(changed) { DrawRect(sr, background); eRect r(sr.left, sr.top, sr.right, sr.top + FontSize().y); int i = page_begin; for(; items[i]; ++i) { if(r.bottom > sr.bottom) break; DrawText(r, items[i]); r.Move(ePoint(0, FontSize().y)); } page_size = i - page_begin; } if((changed || (selected != last_selected)) && page_size) { eRect cursor(sr.left, 0, sr.right, 0); cursor.top = sr.top + (last_selected - page_begin) * FontSize().y; cursor.bottom = cursor.top + FontSize().y; DrawRect(cursor, background, 0x08ffffff); last_selected = selected; if(selected < page_begin) { page_begin = selected; changed = true; return; } if(selected >= page_begin + page_size) { page_begin = selected - page_size + 1; changed = true; return; } cursor.top = sr.top + (selected - page_begin) * FontSize().y; cursor.bottom = cursor.top + FontSize().y; DrawRect(cursor, CURSOR_COLOR, 0x08ffffff); } changed = false; }
bool Font::fromString(string const & data, bool & toggle) { istringstream is(data); Lexer lex; lex.setStream(is); int nset = 0; while (lex.isOK()) { string token; if (lex.next()) token = lex.getString(); if (token.empty() || !lex.next()) break; if (token == "family") { int const next = lex.getInteger(); bits_.setFamily(FontFamily(next)); } else if (token == "series") { int const next = lex.getInteger(); bits_.setSeries(FontSeries(next)); } else if (token == "shape") { int const next = lex.getInteger(); bits_.setShape(FontShape(next)); } else if (token == "size") { int const next = lex.getInteger(); bits_.setSize(FontSize(next)); } else if (token == "emph" || token == "underbar" || token == "noun" || token == "number" || token == "uuline" || token == "uwave" || token == "strikeout") { int const next = lex.getInteger(); FontState const misc = FontState(next); if (token == "emph") bits_.setEmph(misc); else if (token == "underbar") bits_.setUnderbar(misc); else if (token == "strikeout") bits_.setStrikeout(misc); else if (token == "uuline") bits_.setUuline(misc); else if (token == "uwave") bits_.setUwave(misc); else if (token == "noun") bits_.setNoun(misc); else if (token == "number") bits_.setNumber(misc); } else if (token == "color") { int const next = lex.getInteger(); bits_.setColor(ColorCode(next)); /** } else if (token == "background") { int const next = lex.getInteger(); bits_.setBackground(ColorCode(next)); */ } else if (token == "language") { string const next = lex.getString(); setLanguage(languages.getLanguage(next)); } else if (token == "toggleall") { toggle = lex.getBool(); } else { // Unrecognised token break; } ++nset; } return (nset > 0); }
static void PDF_PrintWord(OBJECT x, int hpos, int vpos) { FULL_CHAR *p, *q, *a, *b, *lig, *unacc; int ksize; char *command; MAPPING m; unsigned short *composite; COMPOSITE *cmp; /* currently unused - JeffK */ static int last_hpos; /* does not need to be initialised */ static int next_hpos = -1; #if 0 struct metrics *fnt; #endif debug6(DPF, DD, "PrintWord( %s, %d, %d ) font %d colour %d%s", string(x), hpos, vpos, word_font(x), word_colour(x), word_outline(x) ? " outline" : ""); TotalWordCount++; /* if font is different to previous word then print change */ if( word_font(x) != currentfont ) { currentfont = word_font(x); currentxheight2 = FontHalfXHeight(currentfont); PDFFont_Set(out_fp, FontSize(currentfont, x), FontName(currentfont)); } /* if colour is different to previous word then print change */ if( word_colour(x) != currentcolour ) { currentcolour = word_colour(x); if( currentcolour > 0 ) { char str[256]; sprintf(str, "%s ", ColourCommand(currentcolour)); PDFPage_Write(out_fp, str); } } /* move to coordinate of x */ debug1(DPF, DDD, " currentxheight2 = %d", currentxheight2); vpos = vpos - currentxheight2; if( cpexists && (currenty == vpos) && PDFHasValidTextMatrix() ) { /* printnum(hpos, out_fp); */ command = "s"; /* Note: I calculate the width of the space char here in case the font has changed. This prevents subtle spacing errors. */ #if 0 fnt = finfo[currentfont].size_table; if( (next_hpos + fnt[' '].right /* width of space char */ ) == hpos ) command = " "; #endif } else { currenty = vpos; /* printnum(hpos, out_fp); fputs(" ", out_fp); printnum(currenty, out_fp); */ command = "m"; cpexists = TRUE; } /* convert ligature sequences into ligature characters */ lig = finfo[word_font(x)].lig_table; p = q = string(x); do { /* check for missing glyph (lig[] == 1) or ligatures (lig[] > 1) */ if( lig[*q++ = *p++] ) { if( lig[*(q-1)] == 1 ) continue; else { a = &lig[ lig[*(p-1)] + MAX_CHARS ]; while( *a++ == *(p-1) ) { b = p; while( *a == *b && *(a+1) != '\0' && *b != '\0' ) a++, b++; if( *(a+1) == '\0' ) { *(q-1) = *a; p = b; break; } else { while( *++a ); a++; } } } } } while( *p ); *q = '\0'; switch (command[0]) { case 'm': PDFText_OpenXY(out_fp, hpos, vpos); last_hpos = hpos; next_hpos = hpos + fwd(x, COLM); /* fwd(x, COLM) = width of wd */ break; case 's': #if 0 PDFText_Open(out_fp); PDFText_Kern(out_fp, hpos - next_hpos); #else PDFText_OpenX(out_fp, hpos - last_hpos); #endif last_hpos = hpos; next_hpos = hpos + fwd(x, COLM); /* fwd(x, COLM) = width of wd */ break; #if 0 case ' ': PDFText_Open(out_fp); #if 1 /* try kerning to get correct position */ PDFText_Kern(out_fp, fnt[' '].right); #else PDFPage_Write(out_fp, EightBitToPrintForm[' ']); #endif next_hpos += fwd(x, COLM) + fnt[' '].right; /* width of space ch */ break; #endif } p = string(x); PDFPage_Write(out_fp, EightBitToPrintForm[*p]); m = font_mapping(finfo[word_font(x)].font_table); unacc = MapTable[m]->map[MAP_UNACCENTED]; /* acc = MapTable[m]->map[MAP_ACCENT]; */ for( p++; *p; p++ ) { /* *** this seems right but is actually wrong for PDF, which according to Uwe uses original units for kerning KernLength(word_font(x), unacc, *(p-1), *p, ksize); *** */ KernLength(font_num(finfo[word_font(x)].original_face), unacc, *(p-1), *p, ksize); if ( ksize != 0 ) { PDFText_Kern(out_fp, ksize); } PDFPage_Write(out_fp, EightBitToPrintForm[*p]); } PDFText_Close(out_fp); debug0(DPF, DDD, "PDF_PrintWord returning"); } /* end PDF_PrintWord */
void StermFrameClass::OnBiggerPress(wxCommandEvent &event) { FontSize (++Points); //Fit (); }
/* ** This routine adds information to the input texts that doesn't change ** when the display is resized or when new fonts are selected, etc. ** Mostly this means adding style attributes. But other constant ** information (such as numbering on <li> and images used for <IMG>) ** is also obtained. The key is that this routine is only called ** once, where the sizer and layout routines can be called many times. ** ** This routine is called whenever the list of elements grows. The ** style stack is stored as part of the HTML widget so that we can ** always continue where we left off the last time. ** ** In addition to adding style, this routine will invoke callbacks ** needed to acquire information about a markup. The htmlPtr->zIsVisitied ** callback is called for each <a> and the htmlPtr->zGetImage is called ** for each <IMG> or for each <LI> that has a SRC= field. ** ** This routine may invoke a callback procedure which could delete ** the HTML widget. ** ** When a markup is inserted or deleted from the token list, the ** style routine must be completely rerun from the beginning. So ** what we said above, that this routine is only run once, is not ** strictly true. */ void HtmlAddStyle(HtmlWidget *htmlPtr, HtmlElement *p){ HtmlStyle style; /* Current style */ int size; /* A new font size */ int i; /* Loop counter */ int paraAlign; /* Current paragraph alignment */ int rowAlign; /* Current table row alignment */ int anchorFlags; /* Flags associated with <a> tag */ int inDt; /* True if within <dt>..</dt> */ HtmlStyle nextStyle; /* Style for next token if useNextStyle==1 */ int useNextStyle = 0; /* True if nextStyle is valid */ char *z; /* A tag parameter's value */ /* The size of header fonts relative to the current font size */ static int header_sizes[] = {+2, +1, 1, 1, -1, -1}; /* Don't allow recursion */ if( htmlPtr->flags & STYLER_RUNNING ){ TestPoint(0); return; } htmlPtr->flags |= STYLER_RUNNING; /* Load the style state out of the htmlPtr structure and into local ** variables. This is purely a matter of convenience... */ style = GetCurrentStyle(htmlPtr); paraAlign = htmlPtr->paraAlignment; rowAlign = htmlPtr->rowAlignment; anchorFlags = htmlPtr->anchorFlags; inDt = htmlPtr->inDt; /* Loop over tokens */ while( p ){ switch( p->base.type ){ case Html_A: if( htmlPtr->anchorStart ){ style = HtmlPopStyleStack(htmlPtr, Html_EndA); htmlPtr->anchorStart = 0; anchorFlags = 0; } z = HtmlMarkupArg(p,"href",0); if( z ){ HtmlLock(htmlPtr); style.color = GetLinkColor(htmlPtr, z); if( htmlPtr->underlineLinks ){ style.flags |= STY_Underline; } if( HtmlUnlock(htmlPtr) ) return; anchorFlags |= STY_Anchor; PushStyleStack(htmlPtr, Html_EndA, style); htmlPtr->anchorStart = p; } break; case Html_EndA: if( htmlPtr->anchorStart ){ p->ref.pOther = htmlPtr->anchorStart; style = HtmlPopStyleStack(htmlPtr, Html_EndA); htmlPtr->anchorStart = 0; anchorFlags = 0; } break; case Html_ADDRESS: case Html_EndADDRESS: case Html_BLOCKQUOTE: case Html_EndBLOCKQUOTE: paraAlign = ALIGN_None; TestPoint(0); break; case Html_APPLET: if( htmlPtr->zAppletCommand && *htmlPtr->zAppletCommand ){ nextStyle = style; nextStyle.flags |= STY_Invisible; PushStyleStack(htmlPtr, Html_EndAPPLET, nextStyle); useNextStyle = 1; }else{ PushStyleStack(htmlPtr, Html_EndAPPLET, style); } TestPoint(0); break; case Html_B: style.font = BoldFont( FontSize(style.font) ); PushStyleStack(htmlPtr, Html_EndB, style); TestPoint(0); break; case Html_EndAPPLET: case Html_EndB: case Html_EndBIG: case Html_EndCENTER: case Html_EndCITE: case Html_EndCODE: case Html_EndCOMMENT: case Html_EndEM: case Html_EndFONT: case Html_EndI: case Html_EndKBD: case Html_EndMARQUEE: case Html_EndNOBR: case Html_EndNOFRAME: case Html_EndNOSCRIPT: case Html_EndS: case Html_EndSAMP: case Html_EndSMALL: case Html_EndSTRIKE: case Html_EndSTRONG: case Html_EndSUB: case Html_EndSUP: case Html_EndTITLE: case Html_EndTT: case Html_EndU: case Html_EndVAR: style = HtmlPopStyleStack(htmlPtr, p->base.type); TestPoint(0); break; case Html_BASE: z = HtmlMarkupArg(p,"href",0); if( z ){ HtmlLock(htmlPtr); z = HtmlResolveUri(htmlPtr, z); if( HtmlUnlock(htmlPtr) ) return; if( z!=0 ){ if( htmlPtr->zBaseHref ){ HtmlFree(htmlPtr->zBaseHref); } htmlPtr->zBaseHref = z; } } break; case Html_EndDIV: paraAlign = ALIGN_None; style = HtmlPopStyleStack(htmlPtr, p->base.type); TestPoint(0); break; case Html_EndBASEFONT: style = HtmlPopStyleStack(htmlPtr, Html_EndBASEFONT); style.font = FontFamily(style.font) + 2; TestPoint(0); break; case Html_BIG: ScaleFont(&style,1); PushStyleStack(htmlPtr, Html_EndBIG, style); TestPoint(0); break; case Html_CAPTION: paraAlign = GetAlignment(p, paraAlign); TestPoint(0); break; case Html_EndCAPTION: paraAlign = ALIGN_None; TestPoint(0); break; case Html_CENTER: paraAlign = ALIGN_None; style.align = ALIGN_Center; PushStyleStack(htmlPtr, Html_EndCENTER, style); TestPoint(0); break; case Html_CITE: PushStyleStack(htmlPtr, Html_EndCITE, style); TestPoint(0); break; case Html_CODE: style.font = CWFont( FontSize(style.font) ); PushStyleStack(htmlPtr, Html_EndCODE, style); TestPoint(0); break; case Html_COMMENT: style.flags |= STY_Invisible; PushStyleStack(htmlPtr, Html_EndCOMMENT, style); TestPoint(0); break; case Html_DD: if( htmlPtr->innerList && htmlPtr->innerList->base.type==Html_DL ){ p->ref.pOther = htmlPtr->innerList; TestPoint(0); }else{ p->ref.pOther = 0; TestPoint(0); } inDt = 0; break; case Html_DIR: case Html_MENU: case Html_UL: p->list.pPrev = htmlPtr->innerList; p->list.cnt = 0; htmlPtr->innerList = p; if( p->list.pPrev==0 ){ p->list.type = LI_TYPE_Bullet1; p->list.compact = HtmlMarkupArg(p,"compact",0)!=0; TestPoint(0); }else if( p->list.pPrev->list.pPrev==0 ){ p->list.type = LI_TYPE_Bullet2; p->list.compact = 1; TestPoint(0); }else{ p->list.type = LI_TYPE_Bullet3; p->list.compact = 1; TestPoint(0); } p->list.type = GetUnorderedListType(p,p->list.type); break; case Html_EndDL: inDt = 0; TestPoint(0); /* Fall thru into the next case */ case Html_EndDIR: case Html_EndMENU: case Html_EndOL: case Html_EndUL: p->ref.pOther = htmlPtr->innerList; if( htmlPtr->innerList ){ htmlPtr->innerList = htmlPtr->innerList->list.pPrev; TestPoint(0); }else{ TestPoint(0); } break; case Html_DIV: paraAlign = ALIGN_None; style.align = GetAlignment(p, style.align); PushStyleStack(htmlPtr, Html_EndDIV, style); TestPoint(0); break; case Html_DT: if( htmlPtr->innerList && htmlPtr->innerList->base.type==Html_DL ){ p->ref.pOther = htmlPtr->innerList; TestPoint(0); }else{ p->ref.pOther = 0; TestPoint(0); } inDt = STY_DT; break; case Html_EndDD: case Html_EndDT: inDt = 0; TestPoint(0); break; case Html_DL: p->list.pPrev = htmlPtr->innerList; p->list.cnt = 0; htmlPtr->innerList = p; p->list.compact = HtmlMarkupArg(p,"compact",0)!=0; inDt = 0; TestPoint(0); break; case Html_EM: style.font = ItalicFont( FontSize(style.font) ); PushStyleStack(htmlPtr, Html_EndEM, style); TestPoint(0); break; case Html_EMBED: break; case Html_BASEFONT: case Html_FONT: z = HtmlMarkupArg(p,"size",0); if( z ){ if( *z=='-' ){ size = FontSize(style.font) - atoi(&z[1]); }else if( *z=='+' ){ size = FontSize(style.font) + atoi(&z[1]); }else{ size = atoi(z); } if( size <= 0 ){ size = 1; } if( size >= N_FONT_SIZE ){ size = N_FONT_SIZE - 1; } style.font = FontFamily(style.font) + size - 1; } z = HtmlMarkupArg(p,"color",0); if( z ){ style.color = HtmlGetColorByName(htmlPtr, z); } PushStyleStack(htmlPtr, p->base.type==Html_FONT ? Html_EndFONT : Html_EndBASEFONT, style); break; case Html_FORM: { char *zUrl; char *zMethod; Tcl_DString cmd; /* -formcommand callback */ int result; char zToken[50]; htmlPtr->formStart = 0; p->form.id = 0; if( htmlPtr->zFormCommand==0 || htmlPtr->zFormCommand[0]==0 ){ TestPoint(0); break; } zUrl = HtmlMarkupArg(p,"action",0); if( zUrl==0 ){ TestPoint(0); break; } HtmlLock(htmlPtr); zUrl = HtmlResolveUri(htmlPtr, zUrl); if( HtmlUnlock(htmlPtr) ) return; if( zUrl==0 ) break; zMethod = HtmlMarkupArg(p,"method","GET"); sprintf(zToken," %d form ", ++htmlPtr->nForm); Tcl_DStringInit(&cmd); Tcl_DStringAppend(&cmd, htmlPtr->zFormCommand, -1); Tcl_DStringAppend(&cmd, zToken, -1); Tcl_DStringAppendElement(&cmd, zUrl); HtmlFree(zUrl); Tcl_DStringAppendElement(&cmd, zMethod); Tcl_DStringStartSublist(&cmd); HtmlAppendArglist(&cmd, p); Tcl_DStringEndSublist(&cmd); HtmlLock(htmlPtr); result = Tcl_GlobalEval(htmlPtr->interp, Tcl_DStringValue(&cmd)); Tcl_DStringFree(&cmd); if( HtmlUnlock(htmlPtr) ) return; if( result==TCL_OK ){ htmlPtr->formStart = p; p->form.id = htmlPtr->nForm; } Tcl_ResetResult(htmlPtr->interp); break; } case Html_EndFORM: p->ref.pOther = htmlPtr->formStart; htmlPtr->formStart = 0; TestPoint(0); break; case Html_H1: case Html_H2: case Html_H3: case Html_H4: case Html_H5: case Html_H6: paraAlign = ALIGN_None; i = (p->base.type - Html_H1)/2 + 1; if( i>=1 && i<=6 ){ ScaleFont(&style,header_sizes[i-1]); } style.font = BoldFont( FontSize(style.font) ); style.align = GetAlignment(p, style.align); PushStyleStack(htmlPtr, Html_EndH1, style); break; case Html_EndH1: case Html_EndH2: case Html_EndH3: case Html_EndH4: case Html_EndH5: case Html_EndH6: paraAlign = ALIGN_None; style = HtmlPopStyleStack(htmlPtr, Html_EndH1); TestPoint(0); break; case Html_HR: nextStyle = style; style.align = GetAlignment(p, ALIGN_None); useNextStyle = 1; break; case Html_I: style.font = ItalicFont( FontSize(style.font) ); PushStyleStack(htmlPtr, Html_EndI, style); TestPoint(0); break; case Html_IMG: HtmlLock(htmlPtr); p->image.pImage = HtmlGetImage(htmlPtr, p); if( HtmlUnlock(htmlPtr) ) return; TestPoint(0); break; case Html_INPUT: p->input.pForm = htmlPtr->formStart; TestPoint(0); break; case Html_KBD: style.font = CWFont( FontSize(style.font) ); PushStyleStack(htmlPtr, Html_EndKBD, style); TestPoint(0); break; case Html_LI: if( htmlPtr->innerList ){ p->li.type = htmlPtr->innerList->list.type; if( htmlPtr->innerList->base.type==Html_OL ){ z = HtmlMarkupArg(p, "value", 0); if( z ){ int n = atoi(z); if( n>0 ){ p->li.cnt = n; htmlPtr->innerList->list.cnt = n+1; TestPoint(0); }else{ TestPoint(0); } }else{ p->li.cnt = htmlPtr->innerList->list.cnt++; TestPoint(0); } p->li.type = GetOrderedListType(p,p->li.type); }else{ p->li.type = GetUnorderedListType(p,p->li.type); TestPoint(0); } }else{ p->base.flags &= ~HTML_Visible; TestPoint(0); } break; case Html_MARQUEE: style.flags |= STY_Invisible; PushStyleStack(htmlPtr, Html_EndMARQUEE, style); TestPoint(0); break; case Html_NOBR: style.flags |= STY_NoBreak; PushStyleStack(htmlPtr, Html_EndNOBR, style); TestPoint(0); break; case Html_NOFRAME: if( htmlPtr->zFrameCommand && *htmlPtr->zFrameCommand ){ nextStyle = style; nextStyle.flags |= STY_Invisible; PushStyleStack(htmlPtr, Html_EndNOFRAME, nextStyle); useNextStyle = 1; }else{ PushStyleStack(htmlPtr, Html_EndNOFRAME, style); } TestPoint(0); break; case Html_NOSCRIPT: if( htmlPtr->zScriptCommand && *htmlPtr->zScriptCommand ){ nextStyle = style; nextStyle.flags |= STY_Invisible; PushStyleStack(htmlPtr, Html_EndNOSCRIPT, nextStyle); useNextStyle = 1; }else{ PushStyleStack(htmlPtr, Html_EndNOSCRIPT, style); } TestPoint(0); break; case Html_OL: p->list.pPrev = htmlPtr->innerList; p->list.type = GetOrderedListType(p,LI_TYPE_Enum_1); p->list.cnt = 1; z = HtmlMarkupArg(p,"start",0); if( z ){ int n = atoi(z); if( n>0 ){ p->list.cnt = n; TestPoint(0); }else{ TestPoint(0); } }else{ TestPoint(0); } p->list.compact = htmlPtr->innerList!=0 || HtmlMarkupArg(p,"compact",0)!=0; htmlPtr->innerList = p; break; case Html_P: paraAlign = GetAlignment(p, ALIGN_None); TestPoint(0); break; case Html_EndP: paraAlign = ALIGN_None; TestPoint(0); break; case Html_PRE: case Html_LISTING: case Html_XMP: case Html_PLAINTEXT: paraAlign = ALIGN_None; style.font = CWFont( FontSize(style.font) ); style.flags |= STY_Preformatted; PushStyleStack(htmlPtr, Html_EndPRE, style); TestPoint(0); break; case Html_EndPRE: case Html_EndLISTING: case Html_EndXMP: style = HtmlPopStyleStack(htmlPtr, Html_EndPRE); TestPoint(0); break; case Html_S: style.flags |= STY_StrikeThru; PushStyleStack(htmlPtr, Html_EndS, style); TestPoint(0); break; case Html_SCRIPT: if( htmlPtr->zScriptCommand && *htmlPtr->zScriptCommand ){ Tcl_DString cmd; int result; Tcl_DStringInit(&cmd); Tcl_DStringAppend(&cmd, htmlPtr->zScriptCommand, -1); Tcl_DStringStartSublist(&cmd); HtmlAppendArglist(&cmd, p); Tcl_DStringEndSublist(&cmd); Tcl_DStringStartSublist(&cmd); Tcl_DStringAppend(&cmd, p->script.zScript, p->script.nScript); Tcl_DStringEndSublist(&cmd); HtmlLock(htmlPtr); result = Tcl_GlobalEval(htmlPtr->interp, Tcl_DStringValue(&cmd)); Tcl_DStringFree(&cmd); if( HtmlUnlock(htmlPtr) ) return; Tcl_ResetResult(htmlPtr->interp); } nextStyle = style; style.flags |= STY_Invisible; useNextStyle = 1; break; case Html_SELECT: p->input.pForm = htmlPtr->formStart; nextStyle.flags |= STY_Invisible; useNextStyle = 1; PushStyleStack(htmlPtr, Html_EndSELECT, style); htmlPtr->formElemStart = p; break; case Html_EndSELECT: style = HtmlPopStyleStack(htmlPtr, Html_EndSELECT); if( htmlPtr->formElemStart && htmlPtr->formElemStart->base.type==Html_SELECT ){ p->ref.pOther = htmlPtr->formElemStart; MakeInvisible(p->ref.pOther, p); }else{ p->ref.pOther = 0; } htmlPtr->formElemStart = 0; break; case Html_STRIKE: style.flags |= STY_StrikeThru; PushStyleStack(htmlPtr, Html_EndSTRIKE, style); TestPoint(0); break; case Html_STYLE: /* Ignore style sheets */ break; case Html_SAMP: style.font = CWFont( FontSize(style.font) ); PushStyleStack(htmlPtr, Html_EndSAMP, style); TestPoint(0); break; case Html_SMALL: ScaleFont(&style,-1); PushStyleStack(htmlPtr, Html_EndSMALL, style); TestPoint(0); break; case Html_STRONG: style.font = BoldFont( FontSize(style.font) ); PushStyleStack(htmlPtr, Html_EndSTRONG, style); TestPoint(0); break; case Html_SUB: ScaleFont(&style,-1); if( style.subscript > -6 ){ style.subscript--; TestPoint(0); }else{ TestPoint(0); } PushStyleStack(htmlPtr, Html_EndSUB, style); break; case Html_SUP: ScaleFont(&style,-1); if( style.subscript < 6 ){ style.subscript++; TestPoint(0); }else{ TestPoint(0); } PushStyleStack(htmlPtr, Html_EndSUP, style); break; case Html_TABLE: paraAlign = ALIGN_None; nextStyle = style; nextStyle.align = ALIGN_Left; z = HtmlMarkupArg(p, "bgcolor", 0); if( z ){ nextStyle.bgcolor = HtmlGetColorByName(htmlPtr, z); style.bgcolor = nextStyle.bgcolor; /* }else{ nextStyle.bgcolor = COLOR_Background; */ } PushStyleStack(htmlPtr, Html_EndTABLE, nextStyle); useNextStyle = 1; htmlPtr->inTd = 0; htmlPtr->inTr = 0; TestPoint(0); break; case Html_EndTABLE: paraAlign = ALIGN_None; if( htmlPtr->inTd ){ style = HtmlPopStyleStack(htmlPtr, Html_EndTD); htmlPtr->inTd = 0; } if( htmlPtr->inTr ){ style = HtmlPopStyleStack(htmlPtr, Html_EndTR); htmlPtr->inTr = 0; } style = HtmlPopStyleStack(htmlPtr, p->base.type); TestPoint(0); break; case Html_TD: if( htmlPtr->inTd ){ style = HtmlPopStyleStack(htmlPtr, Html_EndTD); } htmlPtr->inTd = 1; paraAlign = GetAlignment(p, rowAlign); if( (z = HtmlMarkupArg(p, "bgcolor", 0))!=0 ){ style.bgcolor = HtmlGetColorByName(htmlPtr, z); } PushStyleStack(htmlPtr, Html_EndTD, style); TestPoint(0); break; case Html_TEXTAREA: p->input.pForm = htmlPtr->formStart; nextStyle = style; nextStyle.flags |= STY_Invisible; PushStyleStack(htmlPtr, Html_EndTEXTAREA, nextStyle); htmlPtr->formElemStart = p; useNextStyle = 1; TestPoint(0); break; case Html_EndTEXTAREA: style = HtmlPopStyleStack(htmlPtr, Html_EndTEXTAREA); if( htmlPtr->formElemStart && htmlPtr->formElemStart->base.type==Html_TEXTAREA ){ p->ref.pOther = htmlPtr->formElemStart; }else{ p->ref.pOther = 0; } htmlPtr->formElemStart = 0; break; case Html_TH: /* paraAlign = GetAlignment(p, rowAlign); */ if( htmlPtr->inTd ){ style = HtmlPopStyleStack(htmlPtr, Html_EndTD); } paraAlign = GetAlignment(p, ALIGN_Center); style.font = BoldFont( FontSize(style.font) ); if( (z = HtmlMarkupArg(p, "bgcolor", 0))!=0 ){ style.bgcolor = HtmlGetColorByName(htmlPtr, z); } PushStyleStack(htmlPtr, Html_EndTD, style); htmlPtr->inTd = 1; TestPoint(0); break; case Html_TR: if( htmlPtr->inTd ){ style = HtmlPopStyleStack(htmlPtr, Html_EndTD); htmlPtr->inTd = 0; } if( htmlPtr->inTr ){ style = HtmlPopStyleStack(htmlPtr, Html_EndTR); } rowAlign = GetAlignment(p, ALIGN_None); if( (z = HtmlMarkupArg(p, "bgcolor", 0))!=0 ){ style.bgcolor = HtmlGetColorByName(htmlPtr, z); } PushStyleStack(htmlPtr, Html_EndTR, style); htmlPtr->inTr = 1; TestPoint(0); break; case Html_EndTR: if( htmlPtr->inTd ){ style = HtmlPopStyleStack(htmlPtr, Html_EndTD); htmlPtr->inTd = 0; } style = HtmlPopStyleStack(htmlPtr, Html_EndTR); htmlPtr->inTr = 0; paraAlign = ALIGN_None; rowAlign = ALIGN_None; TestPoint(0); break; case Html_EndTD: case Html_EndTH: style = HtmlPopStyleStack(htmlPtr, Html_EndTD); htmlPtr->inTd = 0; paraAlign = ALIGN_None; rowAlign = ALIGN_None; TestPoint(0); break; case Html_TITLE: style.flags |= STY_Invisible; PushStyleStack(htmlPtr, Html_EndTITLE, style); TestPoint(0); break; case Html_TT: style.font = CWFont( FontSize(style.font) ); PushStyleStack(htmlPtr, Html_EndTT, style); TestPoint(0); break; case Html_U: style.flags |= STY_Underline; PushStyleStack(htmlPtr, Html_EndU, style); break; case Html_VAR: style.font = ItalicFont( FontSize(style.font) ); PushStyleStack(htmlPtr, Html_EndVAR, style); TestPoint(0); break; default: TestPoint(0); break; } p->base.style = style; p->base.style.flags |= anchorFlags | inDt; if( paraAlign!=ALIGN_None ){ p->base.style.align = paraAlign; } if( useNextStyle ){ style = nextStyle; useNextStyle = 0; } TRACE(HtmlTrace_Style, ("Style of 0x%08x font=%02d color=%02d bg=%02d " "align=%d flags=0x%04x token=%s\n", (int)p, p->base.style.font, p->base.style.color, p->base.style.bgcolor, p->base.style.align, p->base.style.flags, HtmlTokenName(p))); p = p->pNext; } /* Copy state information back into the htmlPtr structure for ** safe keeping. */ htmlPtr->paraAlignment = paraAlign; htmlPtr->rowAlignment = rowAlign; htmlPtr->anchorFlags = anchorFlags; htmlPtr->inDt = inDt; htmlPtr->flags &= ~STYLER_RUNNING; }
void FontDemoView::_DrawView(BView* view) { if (!view) return; view->SetDrawingMode(B_OP_COPY); BRect rect = view->Bounds(); view->SetHighColor(255, 255, 255); view->FillRect(rect); if (!fString) return; view->SetFont(&fFont, B_FONT_ALL); const size_t size = strlen(fString); BRect boundBoxes[size]; if (OutLineLevel()) fFont.GetGlyphShapes(fString, size, fShapes); else fFont.GetBoundingBoxesAsGlyphs(fString, size, B_SCREEN_METRIC, boundBoxes); float escapementArray[size]; //struct escapement_delta escapeDeltas[size]; struct edge_info edgeInfo[size]; /* for (size_t j = 0; j < size; j++) { escapeDeltas[j].nonspace = 0.0f; escapeDeltas[j].space = 0.0f; } */ fFont.GetEdges(fString, size, edgeInfo); fFont.GetEscapements(fString, size, /*escapeDeltas,*/ escapementArray); font_height fh; fFont.GetHeight(&fh); float xCoordArray[size]; float yCoordArray[size]; float yCoord = (rect.Height() + fh.ascent - fh.descent) / 2; float xCoord = -rect.Width() / 2; const float xCenter = xCoord * -1; const float r = Rotation() * (M_PI / 180.0); const float cosinus = cos(r); const float sinus = -sin(r); // When the bounding boxes workes properly we will invalidate only the // region area instead of the whole view. fBoxRegion.MakeEmpty(); for (size_t i = 0; i < size; i++) { xCoordArray[i] = 0.0f; yCoordArray[i] = 0.0f; yCoordArray[i] = sinus * (xCoord - xCoordArray[i]); xCoordArray[i] = cosinus * xCoord; xCoordArray[i] += xCenter; yCoordArray[i] += yCoord; boundBoxes[i].OffsetBy(xCoordArray[i], yCoordArray[i]); if (OutLineLevel()) { view->MovePenTo(xCoordArray[i], yCoordArray[i]); view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->FillShape(fShapes[i]); view->SetPenSize(OutLineLevel()); view->SetHighColor(0, 0, 0); view->StrokeShape(fShapes[i]); } else { view->SetHighColor(0, 0, 0); view->SetDrawingMode(fDrawingMode); view->DrawChar(fString[i], BPoint(xCoordArray[i], yCoordArray[i])); } if (BoundingBoxes() && !OutLineLevel()) { if (i % 2) view->SetHighColor(0, 255, 0); else view->SetHighColor(255, 0, 0); view->SetDrawingMode(B_OP_COPY); view->StrokeRect(boundBoxes[i]); } // add the bounding to the region. fBoxRegion.Include(boundBoxes[i]); xCoord += (escapementArray[i] /*+ escapeDeltas[i].nonspace + escapeDeltas[i].space*/) * FontSize() + Spacing(); //printf("xCoord %f\n", xCoord); } }
TreeNode* Parser::Statement() { kdDebug(0)<<"Parser::Statement()"<<endl; while (currentToken.type == tokEOL) getToken(); // statements can allways start on newlines switch (currentToken.type) { case tokLearn : return Learn(); break; case tokIf : return If(); break; case tokFor : return For(); break; case tokForEach : return ForEach(); break; case tokWhile : return While(); break; case tokRun : return ExternalRun(); break; case tokReturn : return Return(); break; case tokBreak : return Break(); break; case tokUnknown : return Other(); break; //assignment or function call case tokClear : return Clear(); break; case tokGo : return Go(); break; case tokGoX : return GoX(); break; case tokGoY : return GoY(); break; case tokForward : return Forward(); break; case tokBackward : return Backward(); break; case tokDirection : return Direction(); break; case tokTurnLeft : return TurnLeft(); break; case tokTurnRight : return TurnRight(); break; case tokCenter : return Center(); break; case tokSetPenWidth : return SetPenWidth(); break; case tokPenUp : return PenUp(); break; case tokPenDown : return PenDown(); break; case tokSetFgColor : return SetFgColor(); break; case tokSetBgColor : return SetBgColor(); break; case tokResizeCanvas : return ResizeCanvas(); break; case tokSpriteShow : return SpriteShow(); break; case tokSpriteHide : return SpriteHide(); break; case tokSpritePress : return SpritePress(); break; case tokSpriteChange : return SpriteChange(); break; case tokPrint : return Print(); break; case tokInputWindow : return InputWindow(); break; case tokMessage : return Message(); break; case tokFontType : return FontType(); break; case tokFontSize : return FontSize(); break; case tokRepeat : return Repeat(); break; case tokRandom : return Random(); break; case tokWait : return Wait(); break; case tokWrapOn : return WrapOn(); break; case tokWrapOff : return WrapOff(); break; case tokReset : return Reset(); break; case tokEOF : return EndOfFile(); break; case tokEnd : Error(currentToken, i18n("Cannot understand ']'"), 1050); getToken(); return new TreeNode(currentToken, Unknown); break; case tokBegin : Error(currentToken, i18n("Cannot understand '['"), 1050); getToken(); return new TreeNode(currentToken, Unknown); break; default : break; } if (currentToken.type != tokEnd) { Error(currentToken, i18n("Cannot understand '%1'").arg(currentToken.look), 1060); } getToken(); return new TreeNode(currentToken, Unknown); // fall-though for unknowns }
QFont SongInfoTextView::Font() { QFont font; font.setPointSizeF(FontSize()); return font; }