Array<int32> FontData::getXAdvances(const String& codePoints) { if (!render(codePoints)) { return Array<int32>(); } Array<int32> xAdvabces; for (const auto codePoint : codePoints) { if (codePoint == U'\t') { xAdvabces.push_back(m_tabWidth); } else if (IsControl(codePoint)) { xAdvabces.push_back(0); } else { const auto& glyphInfo = m_glyphs[m_glyphIndexTable[codePoint]]; xAdvabces.push_back(glyphInfo.xAdvance); } } return xAdvabces; }
void wxToolBarTool::SetSize(const wxSize& size) { if ( IsControl() ) { GetControl()->SetSize( size ) ; } }
// --------------------------------------------------------- // TCodParser::EndOfLine() // --------------------------------------------------------- // void TCodParser::EndOfLine() { while ( iCurP < iEndP ) { if ( *iCurP == KCodLineFeed ) { // LF found -> done. This is the lookahead. break; } else if ( *iCurP == KCodCarriageRet ) { // CR found -> may be CR LF (that's OK) or CR alone (error). if ( iCurP + 1 < iEndP && *(iCurP + 1) == KCodLineFeed ) { // CR LF found-> done. Lookahead is the LF. iCurP ++; break; } // CR without LF is unexpected. Error( KErrCodInvalidDescriptor ); } if ( IsValueChar() || IsControl() ) { // Valuechar or CTL unexpected. Error( KErrCodInvalidDescriptor ); } iCurP++; } }
sf::Vector2f GUI_Element::GetGlobalPosition() const{ sf::Vector2f position = GetPosition(); if (m_owner == nullptr || m_owner == this){ return position; } position += m_owner->GetGlobalPosition(); if (IsControl()){ return position; } position.x -= m_owner->m_scrollHorizontal; position.y -= m_owner->m_scrollVertical; return position; }
wxToolBarToolBase::~wxToolBarToolBase() { #if wxUSE_MENUS delete m_dropdownMenu; #endif if ( IsControl() ) GetControl()->Destroy(); }
RectF FontData::getRegion(const String& codePoints, const double lineSpacingScale) { if (!render(codePoints)) { return RectF(0); } Vec2 penPos(0, 0); Vec2 minPos(DBL_MAX, DBL_MAX); Vec2 maxPos(DBL_MIN, DBL_MIN); int32 lineCount = 0; for (const auto codePoint : codePoints) { if (codePoint == U'\n') { penPos.x = 0; penPos.y += m_lineSpacing * lineSpacingScale; ++lineCount; } else if (codePoint == U'\t') { minPos.x = std::min(minPos.x, penPos.x); minPos.y = std::min(minPos.y, penPos.y + m_ascender); maxPos.x = std::max(maxPos.x, penPos.x + m_tabWidth); maxPos.y = std::max(maxPos.y, penPos.y); penPos.x += m_tabWidth; } else if (!IsControl(codePoint)) { if (lineCount == 0) { ++lineCount; } const auto& glyphInfo = m_glyphs[m_glyphIndexTable[codePoint]]; const RectF region(penPos + glyphInfo.offset, glyphInfo.bitmapRect.size); const int32 characterWidth = glyphInfo.xAdvance; minPos.x = std::min(minPos.x, region.x); minPos.y = std::min(minPos.y, region.y); maxPos.x = std::max(maxPos.x, penPos.x + characterWidth); maxPos.y = std::max(maxPos.y, region.y + region.h); penPos.x += glyphInfo.xAdvance; } } if (minPos == Vec2(DBL_MAX, DBL_MAX)) { return RectF(0); } return RectF(0, 0, maxPos.x, lineCount * m_lineSpacing * lineSpacingScale); }
void wxToolBarTool::SetPosition(const wxPoint& position) { m_x = position.x; m_y = position.y; int x , y ; x = y = 0 ; int mac_x = position.x ; int mac_y = position.y ; if ( ! GetToolBar()->MacGetTopLevelWindow()->MacUsesCompositing() ) { GetToolBar()->MacWindowToRootWindow( &x , &y ) ; mac_x += x; mac_y += y; } if ( IsButton() ) { Rect contrlRect ; GetControlBounds( m_controlHandle , &contrlRect ) ; int former_mac_x = contrlRect.left ; int former_mac_y = contrlRect.top ; GetToolBar()->GetToolSize() ; if ( mac_x != former_mac_x || mac_y != former_mac_y ) { UMAMoveControl( m_controlHandle , mac_x , mac_y ) ; } } else if ( IsControl() ) { GetControl()->Move( position ) ; } else { // separator #ifdef __WXMAC_OSX__ Rect contrlRect ; GetControlBounds( m_controlHandle , &contrlRect ) ; int former_mac_x = contrlRect.left ; int former_mac_y = contrlRect.top ; if ( mac_x != former_mac_x || mac_y != former_mac_y ) { UMAMoveControl( m_controlHandle , mac_x , mac_y ) ; } #endif } }
RectF FontData::draw(const String& codePoints, const Vec2& pos, const ColorF& color, double lineSpacingScale) { if (!render(codePoints)) { return RectF(pos, 0); } Vec2 penPos(pos); double maxPosX = DBL_MIN; int32 lineCount = 0; for (const auto codePoint : codePoints) { if (codePoint == U'\n') { penPos.x = pos.x; penPos.y += m_lineSpacing * lineSpacingScale; ++lineCount; continue; } else if (codePoint == U'\t') { maxPosX = std::max(maxPosX, penPos.x + m_tabWidth); penPos.x += m_tabWidth; continue; } else if (!IsControl(codePoint)) { if (lineCount == 0) { ++lineCount; } const auto& glyphInfo = m_glyphs[m_glyphIndexTable[codePoint]]; const RectF region = m_texture(glyphInfo.bitmapRect).draw(penPos + glyphInfo.offset, color); const int32 characterWidth = glyphInfo.xAdvance; maxPosX = std::max(maxPosX, region.x + characterWidth); penPos.x += glyphInfo.xAdvance; } } if (!lineCount) { return RectF(pos, 0); } return RectF(pos, maxPosX - pos.x, lineCount * m_lineSpacing * lineSpacingScale); }
const char* GetO65OptionText (const O65Option* O) /* Return the data of the given option as a readable text. The function returns * a pointer to a static buffer that is reused on the next call, so if in doubt, * make a copy (and no, the function is not thread safe). */ { static char Buf[256]; unsigned I, J; /* Get the length of the text */ unsigned Len = 0; while (Len < O->Len && O->Data[Len] != '\0') { ++Len; } /* Copy into the buffer converting non readable characters */ I = J = 0; while (I < sizeof (Buf) - 1 && J < Len) { if (!IsControl (O->Data[J])) { Buf[I++] = O->Data[J]; } else { Buf[I++] = '\\'; if (I >= sizeof (Buf) - 4) { --I; break; } switch (O->Data[J]) { case '\t': Buf[I++] = 't'; break; case '\b': Buf[I++] = 'b'; break; case '\n': Buf[I++] = 'n'; break; case '\r': Buf[I++] = 'r'; break; case '\v': Buf[I++] = 'v'; break; default: sprintf (Buf + I, "x%02X", O->Data[J]); I += 3; break; } } ++J; } /* Terminate the string and return it */ Buf[I] = '\0'; return Buf; }
Array<Glyph> FontData::getGlyphs(const String& codePoints) { if (!render(codePoints)) { return Array<Glyph>(codePoints.size()); } Array<Glyph> glyphs; int32 index = 0; for (const auto codePoint : codePoints) { Glyph glyph; glyph.codePoint = codePoint; glyph.index = index; if (codePoint == U'\n') { } else if (codePoint == U'\t') { glyph.xAdvance = m_tabWidth; } else if (IsControl(codePoint)) { } else { const auto& glyphInfo = m_glyphs[m_glyphIndexTable[codePoint]]; glyph.texture = m_texture(glyphInfo.bitmapRect); glyph.offset = glyphInfo.offset; glyph.bearingY = glyphInfo.bearingY; glyph.xAdvance = glyphInfo.xAdvance; } glyphs.push_back(glyph); ++index; } return glyphs; }
void CParser::ParseExpression() { Clear(); SkipSpaces(); ProceedUnary(); while (pos < sz) { SkipSpaces(); char curChar = src[pos]; if (IsControl(curChar)) { break; } else if (IsDigit(curChar)) { ParseNumber(); } else if (curChar == '(') { ops.push_front(0); // 0 instead '(' ++pos; ProceedUnary(); } else if (curChar == ')') { while (!ops.empty() && ops.front()!=0) { Simplify(); } ops.pop_front(); ++pos; } else if (OpPriority(curChar) >= 0) { ProceedOperator(); } else { ParseName(); } } // !while (pos < lim) while(st.size() > 1 || !ops.empty()) { Simplify(); } // if (st.size() != 1 || !ops.empty()) { Clear(); throw AST::ASTException("Miss parameters"); } _pProgram->AddExpression(st.front()); st.pop_front(); }
wxSize GetSize() const { if ( IsControl() ) { return GetControl()->GetSize() ; } else if ( IsButton() ) { return GetToolBar()->GetToolSize() ; } else { // separator size wxSize sz = GetToolBar()->GetToolSize() ; if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL ) sz.y /= 4 ; else sz.x /= 4 ; return sz ; } }
bool wxToolBarTool::DoEnable(bool enable) { if ( IsControl() ) { GetControl()->Enable( enable ) ; } else if ( IsButton() ) { #if TARGET_API_MAC_OSX if ( enable ) EnableControl( m_controlHandle ) ; else DisableControl( m_controlHandle ) ; #else if ( enable ) ActivateControl( m_controlHandle ) ; else DeactivateControl( m_controlHandle ) ; #endif } return true ; }
wxToolBarToolBase::~wxToolBarToolBase() { delete m_dropdownMenu; if ( IsControl() ) GetControl()->Destroy(); }
void GUI_Element::ApplyStyle(){ ApplyTextStyle(); ApplyBgStyle(); ApplyGlyphStyle(); if (m_owner != this && !IsControl()){ m_owner->AdjustContentSize(this); } }
void InfoNextTok (void) /* Read the next token from the input stream */ { unsigned I; char DecodeBuf [2]; Again: /* Skip whitespace */ SkipBlanks (0); /* Remember the current position */ InfoErrorLine = InputLine; InfoErrorCol = InputCol; /* Identifier? */ if (C == '_' || IsAlpha (C)) { /* Read the identifier */ I = 0; while (C == '_' || IsAlNum (C)) { if (I < CFG_MAX_IDENT_LEN) { InfoSVal [I++] = C; } NextChar (); } InfoSVal [I] = '\0'; InfoTok = INFOTOK_IDENT; return; } /* Hex number? */ if (C == '$') { NextChar (); if (!IsXDigit (C)) { InfoError ("Hex digit expected"); } InfoIVal = 0; while (IsXDigit (C)) { InfoIVal = InfoIVal * 16 + DigitVal (C); NextChar (); } InfoTok = INFOTOK_INTCON; return; } /* Decimal number? */ if (IsDigit (C)) { InfoIVal = GetDecimalToken (); InfoTok = INFOTOK_INTCON; return; } /* Other characters */ switch (C) { case '{': NextChar (); InfoTok = INFOTOK_LCURLY; break; case '}': NextChar (); InfoTok = INFOTOK_RCURLY; break; case ';': NextChar (); InfoTok = INFOTOK_SEMI; break; case '.': NextChar (); InfoTok = INFOTOK_DOT; break; case ',': NextChar (); InfoTok = INFOTOK_COMMA; break; case '=': NextChar (); InfoTok = INFOTOK_EQ; break; case ':': NextChar (); InfoTok = INFOTOK_COLON; break; case '\"': NextChar (); I = 0; InfoSVal[0] = '\0'; while (C != EOF && C != '\"') { if (GetEncodedChar (InfoSVal, &I, sizeof InfoSVal) < 0) { if (C == EOF) { InfoError ("Unterminated string"); } else { InfoError ("Invalid escape char: %c", C); } } } if (C != '\"') { InfoError ("Unterminated string"); } NextChar (); InfoTok = INFOTOK_STRCON; break; case '\'': NextChar (); if (C == EOF || IsControl (C) || C == '\'') { InfoError ("Invalid character constant"); } if (GetEncodedChar (DecodeBuf, &I, sizeof DecodeBuf) < 0 || I != 1) { InfoError ("Invalid character constant"); } InfoIVal = DecodeBuf [0]; if (C != '\'') { InfoError ("Unterminated character constant"); } NextChar (); InfoTok = INFOTOK_CHARCON; break; case '#': /* # lineno "sourcefile" or # comment */ if (SyncLines && InputCol == 1) { LineMarkerOrComment (); } else { do { NextChar (); } while (C != EOF && C != '\n'); NextChar (); } if (C != EOF) { goto Again; } InfoTok = INFOTOK_EOF; break; case '/': /* C++ style comment */ NextChar (); if (C != '/') { InfoError ("Invalid token '/'"); } do { NextChar (); } while (C != '\n' && C != EOF); if (C != EOF) { goto Again; } InfoTok = INFOTOK_EOF; break; case EOF: InfoTok = INFOTOK_EOF; break; default: InfoError ("Invalid character '%c'", C); } }
void NextRawTok (void) /* Read the next raw token from the input stream */ { Macro* M; /* If we've a forced end of assembly, don't read further */ if (ForcedEnd) { CurTok.Tok = TOK_EOF; return; } Restart: /* Check if we have tokens from another input source */ if (InputFromStack ()) { if (CurTok.Tok == TOK_IDENT && (M = FindDefine (&CurTok.SVal)) != 0) { /* This is a define style macro - expand it */ MacExpandStart (M); goto Restart; } return; } Again: /* Skip whitespace, remember if we had some */ if ((CurTok.WS = IsBlank (C)) != 0) { do { NextChar (); } while (IsBlank (C)); } /* Mark the file position of the next token */ Source->Func->MarkStart (Source); /* Clear the string attribute */ SB_Clear (&CurTok.SVal); /* Generate line info for the current token */ NewAsmLine (); /* Hex number or PC symbol? */ if (C == '$') { NextChar (); /* Hex digit must follow or DollarIsPC must be enabled */ if (!IsXDigit (C)) { if (DollarIsPC) { CurTok.Tok = TOK_PC; return; } else { Error ("Hexadecimal digit expected"); } } /* Read the number */ CurTok.IVal = 0; while (1) { if (UnderlineInNumbers && C == '_') { while (C == '_') { NextChar (); } if (!IsXDigit (C)) { Error ("Number may not end with underline"); } } if (IsXDigit (C)) { if (CurTok.IVal & 0xF0000000) { Error ("Overflow in hexadecimal number"); CurTok.IVal = 0; } CurTok.IVal = (CurTok.IVal << 4) + DigitVal (C); NextChar (); } else { break; } } /* This is an integer constant */ CurTok.Tok = TOK_INTCON; return; } /* Binary number? */ if (C == '%') { NextChar (); /* 0 or 1 must follow */ if (!IsBDigit (C)) { Error ("Binary digit expected"); } /* Read the number */ CurTok.IVal = 0; while (1) { if (UnderlineInNumbers && C == '_') { while (C == '_') { NextChar (); } if (!IsBDigit (C)) { Error ("Number may not end with underline"); } } if (IsBDigit (C)) { if (CurTok.IVal & 0x80000000) { Error ("Overflow in binary number"); CurTok.IVal = 0; } CurTok.IVal = (CurTok.IVal << 1) + DigitVal (C); NextChar (); } else { break; } } /* This is an integer constant */ CurTok.Tok = TOK_INTCON; return; } /* Number? */ if (IsDigit (C)) { char Buf[16]; unsigned Digits; unsigned Base; unsigned I; long Max; unsigned DVal; /* Ignore leading zeros */ while (C == '0') { NextChar (); } /* Read the number into Buf counting the digits */ Digits = 0; while (1) { if (UnderlineInNumbers && C == '_') { while (C == '_') { NextChar (); } if (!IsXDigit (C)) { Error ("Number may not end with underline"); } } if (IsXDigit (C)) { /* Buf is big enough to allow any decimal and hex number to ** overflow, so ignore excess digits here, they will be detected ** when we convert the value. */ if (Digits < sizeof (Buf)) { Buf[Digits++] = C; } NextChar (); } else { break; } } /* Allow zilog/intel style hex numbers with a 'h' suffix */ if (C == 'h' || C == 'H') { NextChar (); Base = 16; Max = 0xFFFFFFFFUL / 16; } else { Base = 10; Max = 0xFFFFFFFFUL / 10; } /* Convert the number using the given base */ CurTok.IVal = 0; for (I = 0; I < Digits; ++I) { if (CurTok.IVal > Max) { Error ("Number out of range"); CurTok.IVal = 0; break; } DVal = DigitVal (Buf[I]); if (DVal >= Base) { Error ("Invalid digits in number"); CurTok.IVal = 0; break; } CurTok.IVal = (CurTok.IVal * Base) + DVal; } /* This is an integer constant */ CurTok.Tok = TOK_INTCON; return; } /* Control command? */ if (C == '.') { /* Remember and skip the dot */ NextChar (); /* Check if it's just a dot */ if (!IsIdStart (C)) { /* Just a dot */ CurTok.Tok = TOK_DOT; } else { /* Read the remainder of the identifier */ SB_AppendChar (&CurTok.SVal, '.'); ReadIdent (); /* Dot keyword, search for it */ CurTok.Tok = FindDotKeyword (); if (CurTok.Tok == TOK_NONE) { /* Not found */ if (!LeadingDotInIdents) { /* Invalid pseudo instruction */ Error ("'%m%p' is not a recognized control command", &CurTok.SVal); goto Again; } /* An identifier with a dot. Check if it's a define style ** macro. */ if ((M = FindDefine (&CurTok.SVal)) != 0) { /* This is a define style macro - expand it */ MacExpandStart (M); goto Restart; } /* Just an identifier with a dot */ CurTok.Tok = TOK_IDENT; } } return; } /* Indirect op for sweet16 cpu. Must check this before checking for local ** symbols, because these may also use the '@' symbol. */ if (CPU == CPU_SWEET16 && C == '@') { NextChar (); CurTok.Tok = TOK_AT; return; } /* Local symbol? */ if (C == LocalStart) { /* Read the identifier. */ ReadIdent (); /* Start character alone is not enough */ if (SB_GetLen (&CurTok.SVal) == 1) { Error ("Invalid cheap local symbol"); goto Again; } /* A local identifier */ CurTok.Tok = TOK_LOCAL_IDENT; return; } /* Identifier or keyword? */ if (IsIdStart (C)) { /* Read the identifier */ ReadIdent (); /* Check for special names. Bail out if we have identified the type of ** the token. Go on if the token is an identifier. */ switch (SB_GetLen (&CurTok.SVal)) { case 1: switch (toupper (SB_AtUnchecked (&CurTok.SVal, 0))) { case 'A': if (C == ':') { NextChar (); CurTok.Tok = TOK_OVERRIDE_ABS; } else { CurTok.Tok = TOK_A; } return; case 'F': if (C == ':') { NextChar (); CurTok.Tok = TOK_OVERRIDE_FAR; return; } break; case 'S': if ((CPU == CPU_4510) || (CPU == CPU_65816)) { CurTok.Tok = TOK_S; return; } break; case 'X': CurTok.Tok = TOK_X; return; case 'Y': CurTok.Tok = TOK_Y; return; case 'Z': if (C == ':') { NextChar (); CurTok.Tok = TOK_OVERRIDE_ZP; return; } else { if (CPU == CPU_4510) { CurTok.Tok = TOK_Z; return; } } break; default: break; } break; case 2: if ((CPU == CPU_4510) && (toupper (SB_AtUnchecked (&CurTok.SVal, 0)) == 'S') && (toupper (SB_AtUnchecked (&CurTok.SVal, 1)) == 'P')) { CurTok.Tok = TOK_S; return; } /* FALL THROUGH */ default: if (CPU == CPU_SWEET16 && (CurTok.IVal = Sweet16Reg (&CurTok.SVal)) >= 0) { /* A sweet16 register number in sweet16 mode */ CurTok.Tok = TOK_REG; return; } } /* Check for define style macro */ if ((M = FindDefine (&CurTok.SVal)) != 0) { /* Macro - expand it */ MacExpandStart (M); goto Restart; } else { /* An identifier */ CurTok.Tok = TOK_IDENT; } return; } /* Ok, let's do the switch */ CharAgain: switch (C) { case '+': NextChar (); CurTok.Tok = TOK_PLUS; return; case '-': NextChar (); CurTok.Tok = TOK_MINUS; return; case '/': NextChar (); if (C != '*') { CurTok.Tok = TOK_DIV; } else if (CComments) { /* Remember the position, then skip the '*' */ Collection LineInfos = STATIC_COLLECTION_INITIALIZER; GetFullLineInfo (&LineInfos); NextChar (); do { while (C != '*') { if (C == EOF) { LIError (&LineInfos, "Unterminated comment"); ReleaseFullLineInfo (&LineInfos); DoneCollection (&LineInfos); goto CharAgain; } NextChar (); } NextChar (); } while (C != '/'); NextChar (); ReleaseFullLineInfo (&LineInfos); DoneCollection (&LineInfos); goto Again; } return; case '*': NextChar (); CurTok.Tok = TOK_MUL; return; case '^': NextChar (); CurTok.Tok = TOK_XOR; return; case '&': NextChar (); if (C == '&') { NextChar (); CurTok.Tok = TOK_BOOLAND; } else { CurTok.Tok = TOK_AND; } return; case '|': NextChar (); if (C == '|') { NextChar (); CurTok.Tok = TOK_BOOLOR; } else { CurTok.Tok = TOK_OR; } return; case ':': NextChar (); switch (C) { case ':': NextChar (); CurTok.Tok = TOK_NAMESPACE; break; case '-': CurTok.IVal = 0; do { --CurTok.IVal; NextChar (); } while (C == '-'); CurTok.Tok = TOK_ULABEL; break; case '+': CurTok.IVal = 0; do { ++CurTok.IVal; NextChar (); } while (C == '+'); CurTok.Tok = TOK_ULABEL; break; case '=': NextChar (); CurTok.Tok = TOK_ASSIGN; break; default: CurTok.Tok = TOK_COLON; break; } return; case ',': NextChar (); CurTok.Tok = TOK_COMMA; return; case ';': NextChar (); while (C != '\n' && C != EOF) { NextChar (); } goto CharAgain; case '#': NextChar (); CurTok.Tok = TOK_HASH; return; case '(': NextChar (); CurTok.Tok = TOK_LPAREN; return; case ')': NextChar (); CurTok.Tok = TOK_RPAREN; return; case '[': NextChar (); CurTok.Tok = TOK_LBRACK; return; case ']': NextChar (); CurTok.Tok = TOK_RBRACK; return; case '{': NextChar (); CurTok.Tok = TOK_LCURLY; return; case '}': NextChar (); CurTok.Tok = TOK_RCURLY; return; case '<': NextChar (); if (C == '=') { NextChar (); CurTok.Tok = TOK_LE; } else if (C == '<') { NextChar (); CurTok.Tok = TOK_SHL; } else if (C == '>') { NextChar (); CurTok.Tok = TOK_NE; } else { CurTok.Tok = TOK_LT; } return; case '=': NextChar (); CurTok.Tok = TOK_EQ; return; case '!': NextChar (); CurTok.Tok = TOK_BOOLNOT; return; case '>': NextChar (); if (C == '=') { NextChar (); CurTok.Tok = TOK_GE; } else if (C == '>') { NextChar (); CurTok.Tok = TOK_SHR; } else { CurTok.Tok = TOK_GT; } return; case '~': NextChar (); CurTok.Tok = TOK_NOT; return; case '\'': /* Hack: If we allow ' as terminating character for strings, read ** the following stuff as a string, and check for a one character ** string later. */ if (LooseStringTerm) { ReadStringConst ('\''); if (SB_GetLen (&CurTok.SVal) == 1) { CurTok.IVal = SB_AtUnchecked (&CurTok.SVal, 0); CurTok.Tok = TOK_CHARCON; } else { CurTok.Tok = TOK_STRCON; } } else { /* Always a character constant */ NextChar (); if (C == EOF || IsControl (C)) { Error ("Illegal character constant"); goto CharAgain; } CurTok.IVal = C; CurTok.Tok = TOK_CHARCON; NextChar (); if (C != '\'') { if (!MissingCharTerm) { Error ("Illegal character constant"); } } else { NextChar (); } } return; case '\"': ReadStringConst ('\"'); CurTok.Tok = TOK_STRCON; return; case '\\': /* Line continuation? */ if (LineCont) { NextChar (); /* Next char should be a LF, if not, will result in an error later */ if (C == '\n') { /* Ignore the '\n' */ NextChar (); goto Again; } else { /* Make it clear what the problem is: */ Error ("EOL expected."); } } break; case '\n': NextChar (); CurTok.Tok = TOK_SEP; return; case EOF: CheckInputStack (); /* In case of the main file, do not close it, but return EOF. */ if (Source && Source->Next) { DoneCharSource (); goto Again; } else { CurTok.Tok = TOK_EOF; } return; } /* If we go here, we could not identify the current character. Skip it ** and try again. */ Error ("Invalid input character: 0x%02X", C & 0xFF); NextChar (); goto Again; }
bool IsPrintable(const char &ch) { return !IsControl(ch); }
bool FontData::draw(const String& codePoints, const RectF& area, const ColorF& color, const double lineSpacingScale) { if (!render(codePoints)) { return false; } const double width = area.w; const double height = area.h; std::u32string adjustedText; bool needDots = false; if (m_lineSpacing > height) { return false; } { Vec2 penPos(0, 0); for (const auto& codePoint : codePoints) { if (codePoint == U'\n') { penPos.y += m_lineSpacing * lineSpacingScale; if (penPos.y + m_lineSpacing <= height) { penPos.x = 0; adjustedText.push_back(U'\n'); continue; } else { needDots = true; break; } } else if (codePoint == U'\t') { const int32 characterWidth = m_tabWidth; if (penPos.x + characterWidth <= width) { penPos.x += characterWidth; adjustedText.push_back(codePoint); continue; } else { penPos.y += m_lineSpacing * lineSpacingScale; if (penPos.y + m_lineSpacing <= height) { if (characterWidth > width) { return false; } penPos.x = characterWidth; adjustedText.push_back(U'\n'); adjustedText.push_back(codePoint); continue; } else { needDots = true; break; } } } else if (IsControl(codePoint)) { continue; } const auto& glyphInfo = m_glyphs[m_glyphIndexTable[codePoint]]; const int32 characterWidth = glyphInfo.offset.x + glyphInfo.bitmapRect.w; if (penPos.x + characterWidth <= width) { penPos.x += glyphInfo.xAdvance; adjustedText.push_back(codePoint); continue; } else { penPos.y += m_lineSpacing * lineSpacingScale; if (penPos.y + m_lineSpacing <= height) { if (glyphInfo.xAdvance > width) { return false; } penPos.x = glyphInfo.xAdvance; adjustedText.push_back(U'\n'); adjustedText.push_back(codePoint); continue; } else { needDots = true; break; } } } if (needDots) { if (!render(String(1, U'.'))) { return false; } const auto& dotGlyph = m_glyphs[m_glyphIndexTable[U'.']]; const int32 dotWidth = dotGlyph.offset.x + dotGlyph.bitmapRect.w; const int32 dotsWidth = dotGlyph.xAdvance * 2 + dotWidth; while (!adjustedText.empty()) { const char32 codePoint = adjustedText.back(); if (codePoint == U'\n') { break; } if (width - penPos.x >= dotsWidth) { break; } const auto& glyphInfo = m_glyphs[m_glyphIndexTable[codePoint]]; penPos.x -= glyphInfo.xAdvance; adjustedText.pop_back(); } if (width - penPos.x >= dotsWidth) { adjustedText.append(U"..."); } } } { Vec2 penPos(area.pos); int32 lineCount = 0; for (const auto& codePoint : adjustedText) { if (codePoint == U'\n') { penPos.x = area.x; penPos.y += m_lineSpacing * lineSpacingScale; ++lineCount; continue; } else if (codePoint == U'\t') { penPos.x += m_tabWidth; continue; } else if (IsControl(codePoint)) { continue; } if (lineCount == 0) { ++lineCount; } const auto& glyphInfo = m_glyphs[m_glyphIndexTable[codePoint]]; m_texture(glyphInfo.bitmapRect).draw(penPos + glyphInfo.offset, color); penPos.x += glyphInfo.xAdvance; } } return !needDots; }
TCodParser::TCodAttr TCodParser::AttrName() { TCodAttr attr( ECodUnknownAttr ); const TText* start = iCurP; while ( iCurP < iEndP && !IsControl() && !IsSeparator() && *iCurP != KCodCarriageRet && *iCurP != KCodLineFeed ) { iCurP++; } TPtrC token( start, iCurP - start ); if ( !token.Length() ) { Error( KErrCodInvalidDescriptor ); } else if ( !token.Compare( KCodName ) ) { attr = ECodName; } else if ( !token.Compare( KCodVendor ) ) { attr = ECodVendor; } else if ( !token.Compare( KCodDescription ) ) { attr = ECodDescription; } else if ( !token.Compare( KCodUrl ) ) { attr = ECodUrl; } else if ( !token.Compare( KCodSize ) ) { attr = ECodSize; } else if ( !token.Compare( KCodType ) ) { attr = ECodType; } else if ( !token.Compare( KCodInstallNotify ) ) { attr = ECodInstallNotify; } else if ( !token.Compare( KCodNextUrl ) ) { attr = ECodNextUrl; } else if ( !token.Compare( KCodNextUrlAtError ) ) { attr = ECodNextUrlAtError; } else if ( !token.Compare( KCodInfoUrl ) ) { attr = ECodInfoUrl; } else if ( !token.Compare( KCodPrice ) ) { attr = ECodPrice; } else if ( !token.Compare( KCodIcon ) ) { attr = ECodIcon; } CLOG(( EParse, 4, _L("TCodParser::AttrName token<%S> attr(%d)"), \ &token, attr )); return attr; }
// --------------------------------------------------------- // TCodParser::IsValueChar() // --------------------------------------------------------- // TBool TCodParser::IsValueChar() const { __ASSERT_DEBUG( iCurP < iEndP, CodPanic( ECodBufferOverread ) ); return ( !(IsControl() || IsWhiteSpace()) ); }