mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Use override specifier for text layout classes.
This commit is contained in:
parent
d95c7083ea
commit
fbc4cef180
|
@ -134,12 +134,12 @@ public:
|
||||||
public:
|
public:
|
||||||
ICUVisualRun(const icu::ParagraphLayout::VisualRun *vr) : vr(vr) { }
|
ICUVisualRun(const icu::ParagraphLayout::VisualRun *vr) : vr(vr) { }
|
||||||
|
|
||||||
const Font *GetFont() const { return (const Font*)vr->getFont(); }
|
const Font *GetFont() const override { return (const Font*)vr->getFont(); }
|
||||||
int GetGlyphCount() const { return vr->getGlyphCount(); }
|
int GetGlyphCount() const override { return vr->getGlyphCount(); }
|
||||||
const GlyphID *GetGlyphs() const { return vr->getGlyphs(); }
|
const GlyphID *GetGlyphs() const override { return vr->getGlyphs(); }
|
||||||
const float *GetPositions() const { return vr->getPositions(); }
|
const float *GetPositions() const override { return vr->getPositions(); }
|
||||||
int GetLeading() const { return vr->getLeading(); }
|
int GetLeading() const override { return vr->getLeading(); }
|
||||||
const int *GetGlyphToCharMap() const { return vr->getGlyphToCharMap(); }
|
const int *GetGlyphToCharMap() const override { return vr->getGlyphToCharMap(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A single line worth of VisualRuns. */
|
/** A single line worth of VisualRuns. */
|
||||||
|
@ -153,14 +153,14 @@ public:
|
||||||
this->push_back(new ICUVisualRun(l->getVisualRun(i)));
|
this->push_back(new ICUVisualRun(l->getVisualRun(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~ICULine() { delete l; }
|
~ICULine() override { delete l; }
|
||||||
|
|
||||||
int GetLeading() const { return l->getLeading(); }
|
int GetLeading() const override { return l->getLeading(); }
|
||||||
int GetWidth() const { return l->getWidth(); }
|
int GetWidth() const override { return l->getWidth(); }
|
||||||
int CountRuns() const { return l->countRuns(); }
|
int CountRuns() const override { return l->countRuns(); }
|
||||||
const ParagraphLayouter::VisualRun *GetVisualRun(int run) const { return this->at(run); }
|
const ParagraphLayouter::VisualRun *GetVisualRun(int run) const override { return this->at(run); }
|
||||||
|
|
||||||
int GetInternalCharLength(WChar c) const
|
int GetInternalCharLength(WChar c) const override
|
||||||
{
|
{
|
||||||
/* ICU uses UTF-16 internally which means we need to account for surrogate pairs. */
|
/* ICU uses UTF-16 internally which means we need to account for surrogate pairs. */
|
||||||
return Utf8CharLen(c) < 4 ? 1 : 2;
|
return Utf8CharLen(c) < 4 ? 1 : 2;
|
||||||
|
@ -168,10 +168,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
ICUParagraphLayout(icu::ParagraphLayout *p) : p(p) { }
|
ICUParagraphLayout(icu::ParagraphLayout *p) : p(p) { }
|
||||||
~ICUParagraphLayout() { delete p; }
|
~ICUParagraphLayout() override { delete p; }
|
||||||
void Reflow() { p->reflow(); }
|
void Reflow() override { p->reflow(); }
|
||||||
|
|
||||||
ParagraphLayouter::Line *NextLine(int max_width)
|
ParagraphLayouter::Line *NextLine(int max_width) override
|
||||||
{
|
{
|
||||||
icu::ParagraphLayout::Line *l = p->nextLine(max_width);
|
icu::ParagraphLayout::Line *l = p->nextLine(max_width);
|
||||||
return l == NULL ? NULL : new ICULine(l);
|
return l == NULL ? NULL : new ICULine(l);
|
||||||
|
@ -259,24 +259,24 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FallbackVisualRun(Font *font, const WChar *chars, int glyph_count, int x);
|
FallbackVisualRun(Font *font, const WChar *chars, int glyph_count, int x);
|
||||||
~FallbackVisualRun();
|
~FallbackVisualRun() override;
|
||||||
const Font *GetFont() const;
|
const Font *GetFont() const override;
|
||||||
int GetGlyphCount() const;
|
int GetGlyphCount() const override;
|
||||||
const GlyphID *GetGlyphs() const;
|
const GlyphID *GetGlyphs() const override;
|
||||||
const float *GetPositions() const;
|
const float *GetPositions() const override;
|
||||||
int GetLeading() const;
|
int GetLeading() const override;
|
||||||
const int *GetGlyphToCharMap() const;
|
const int *GetGlyphToCharMap() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A single line worth of VisualRuns. */
|
/** A single line worth of VisualRuns. */
|
||||||
class FallbackLine : public AutoDeleteSmallVector<FallbackVisualRun *>, public ParagraphLayouter::Line {
|
class FallbackLine : public AutoDeleteSmallVector<FallbackVisualRun *>, public ParagraphLayouter::Line {
|
||||||
public:
|
public:
|
||||||
int GetLeading() const;
|
int GetLeading() const override;
|
||||||
int GetWidth() const;
|
int GetWidth() const override;
|
||||||
int CountRuns() const;
|
int CountRuns() const override;
|
||||||
const ParagraphLayouter::VisualRun *GetVisualRun(int run) const;
|
const ParagraphLayouter::VisualRun *GetVisualRun(int run) const override;
|
||||||
|
|
||||||
int GetInternalCharLength(WChar c) const { return 1; }
|
int GetInternalCharLength(WChar c) const override { return 1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
const WChar *buffer_begin; ///< Begin of the buffer.
|
const WChar *buffer_begin; ///< Begin of the buffer.
|
||||||
|
@ -284,8 +284,8 @@ public:
|
||||||
FontMap &runs; ///< The fonts we have to use for this paragraph.
|
FontMap &runs; ///< The fonts we have to use for this paragraph.
|
||||||
|
|
||||||
FallbackParagraphLayout(WChar *buffer, int length, FontMap &runs);
|
FallbackParagraphLayout(WChar *buffer, int length, FontMap &runs);
|
||||||
void Reflow();
|
void Reflow() override;
|
||||||
const ParagraphLayouter::Line *NextLine(int max_width);
|
const ParagraphLayouter::Line *NextLine(int max_width) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,13 +54,13 @@ public:
|
||||||
public:
|
public:
|
||||||
CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff);
|
CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff);
|
||||||
|
|
||||||
virtual const GlyphID *GetGlyphs() const { return &this->glyphs[0]; }
|
const GlyphID *GetGlyphs() const override { return &this->glyphs[0]; }
|
||||||
virtual const float *GetPositions() const { return &this->positions[0]; }
|
const float *GetPositions() const override { return &this->positions[0]; }
|
||||||
virtual const int *GetGlyphToCharMap() const { return &this->glyph_to_char[0]; }
|
const int *GetGlyphToCharMap() const override { return &this->glyph_to_char[0]; }
|
||||||
|
|
||||||
virtual const Font *GetFont() const { return this->font; }
|
const Font *GetFont() const override { return this->font; }
|
||||||
virtual int GetLeading() const { return this->font->fc->GetHeight(); }
|
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
||||||
virtual int GetGlyphCount() const { return (int)this->glyphs.size(); }
|
int GetGlyphCount() const override { return (int)this->glyphs.size(); }
|
||||||
int GetAdvance() const { return this->total_advance; }
|
int GetAdvance() const { return this->total_advance; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,12 +83,12 @@ public:
|
||||||
CFRelease(line);
|
CFRelease(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int GetLeading() const;
|
int GetLeading() const override;
|
||||||
virtual int GetWidth() const;
|
int GetWidth() const override;
|
||||||
virtual int CountRuns() const { return this->size(); }
|
int CountRuns() const override { return this->size(); }
|
||||||
virtual const VisualRun *GetVisualRun(int run) const { return this->at(run); }
|
const VisualRun *GetVisualRun(int run) const override { return this->at(run); }
|
||||||
|
|
||||||
int GetInternalCharLength(WChar c) const
|
int GetInternalCharLength(WChar c) const override
|
||||||
{
|
{
|
||||||
/* CoreText uses UTF-16 internally which means we need to account for surrogate pairs. */
|
/* CoreText uses UTF-16 internally which means we need to account for surrogate pairs. */
|
||||||
return c >= 0x010000U ? 2 : 1;
|
return c >= 0x010000U ? 2 : 1;
|
||||||
|
@ -100,17 +100,17 @@ public:
|
||||||
this->Reflow();
|
this->Reflow();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~CoreTextParagraphLayout()
|
~CoreTextParagraphLayout() override
|
||||||
{
|
{
|
||||||
CFRelease(this->typesetter);
|
CFRelease(this->typesetter);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Reflow()
|
void Reflow() override
|
||||||
{
|
{
|
||||||
this->cur_offset = 0;
|
this->cur_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const Line *NextLine(int max_width);
|
const Line *NextLine(int max_width) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,10 @@ class OSXStringIterator : public StringIterator {
|
||||||
size_t cur_pos; ///< Current iteration position.
|
size_t cur_pos; ///< Current iteration position.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void SetString(const char *s);
|
void SetString(const char *s) override;
|
||||||
virtual size_t SetCurPosition(size_t pos);
|
size_t SetCurPosition(size_t pos) override;
|
||||||
virtual size_t Next(IterType what);
|
size_t Next(IterType what) override;
|
||||||
virtual size_t Prev(IterType what);
|
size_t Prev(IterType what) override;
|
||||||
|
|
||||||
static StringIterator *Create();
|
static StringIterator *Create();
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,30 +90,30 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UniscribeVisualRun(const UniscribeRun &range, int x);
|
UniscribeVisualRun(const UniscribeRun &range, int x);
|
||||||
virtual ~UniscribeVisualRun()
|
~UniscribeVisualRun() override
|
||||||
{
|
{
|
||||||
free(this->glyph_to_char);
|
free(this->glyph_to_char);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const GlyphID *GetGlyphs() const { return &this->glyphs[0]; }
|
const GlyphID *GetGlyphs() const override { return &this->glyphs[0]; }
|
||||||
virtual const float *GetPositions() const { return &this->positions[0]; }
|
const float *GetPositions() const override { return &this->positions[0]; }
|
||||||
virtual const int *GetGlyphToCharMap() const;
|
const int *GetGlyphToCharMap() const override;
|
||||||
|
|
||||||
virtual const Font *GetFont() const { return this->font; }
|
const Font *GetFont() const override { return this->font; }
|
||||||
virtual int GetLeading() const { return this->font->fc->GetHeight(); }
|
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
||||||
virtual int GetGlyphCount() const { return this->num_glyphs; }
|
int GetGlyphCount() const override { return this->num_glyphs; }
|
||||||
int GetAdvance() const { return this->total_advance; }
|
int GetAdvance() const { return this->total_advance; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A single line worth of VisualRuns. */
|
/** A single line worth of VisualRuns. */
|
||||||
class UniscribeLine : public AutoDeleteSmallVector<UniscribeVisualRun *>, public ParagraphLayouter::Line {
|
class UniscribeLine : public AutoDeleteSmallVector<UniscribeVisualRun *>, public ParagraphLayouter::Line {
|
||||||
public:
|
public:
|
||||||
virtual int GetLeading() const;
|
int GetLeading() const override;
|
||||||
virtual int GetWidth() const;
|
int GetWidth() const override;
|
||||||
virtual int CountRuns() const { return (uint)this->size(); }
|
int CountRuns() const override { return (uint)this->size(); }
|
||||||
virtual const VisualRun *GetVisualRun(int run) const { return this->at(run); }
|
const VisualRun *GetVisualRun(int run) const override { return this->at(run); }
|
||||||
|
|
||||||
int GetInternalCharLength(WChar c) const
|
int GetInternalCharLength(WChar c) const override
|
||||||
{
|
{
|
||||||
/* Uniscribe uses UTF-16 internally which means we need to account for surrogate pairs. */
|
/* Uniscribe uses UTF-16 internally which means we need to account for surrogate pairs. */
|
||||||
return c >= 0x010000U ? 2 : 1;
|
return c >= 0x010000U ? 2 : 1;
|
||||||
|
@ -125,15 +125,15 @@ public:
|
||||||
this->Reflow();
|
this->Reflow();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~UniscribeParagraphLayout() {}
|
~UniscribeParagraphLayout() override {}
|
||||||
|
|
||||||
virtual void Reflow()
|
void Reflow() override
|
||||||
{
|
{
|
||||||
this->cur_range = this->ranges.begin();
|
this->cur_range = this->ranges.begin();
|
||||||
this->cur_range_offset = 0;
|
this->cur_range_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const Line *NextLine(int max_width);
|
const Line *NextLine(int max_width) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
void UniscribeResetScriptCache(FontSize size)
|
void UniscribeResetScriptCache(FontSize size)
|
||||||
|
|
|
@ -81,10 +81,10 @@ class UniscribeStringIterator : public StringIterator {
|
||||||
size_t cur_pos; ///< Current iteration position.
|
size_t cur_pos; ///< Current iteration position.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void SetString(const char *s);
|
void SetString(const char *s) override;
|
||||||
virtual size_t SetCurPosition(size_t pos);
|
size_t SetCurPosition(size_t pos) override;
|
||||||
virtual size_t Next(IterType what);
|
size_t Next(IterType what) override;
|
||||||
virtual size_t Prev(IterType what);
|
size_t Prev(IterType what) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(WITH_UNISCRIBE) */
|
#endif /* defined(WITH_UNISCRIBE) */
|
||||||
|
|
|
@ -638,13 +638,13 @@ public:
|
||||||
this->utf16_to_utf8.push_back(0);
|
this->utf16_to_utf8.push_back(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~IcuStringIterator()
|
~IcuStringIterator() override
|
||||||
{
|
{
|
||||||
delete this->char_itr;
|
delete this->char_itr;
|
||||||
delete this->word_itr;
|
delete this->word_itr;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SetString(const char *s)
|
void SetString(const char *s) override
|
||||||
{
|
{
|
||||||
const char *string_base = s;
|
const char *string_base = s;
|
||||||
|
|
||||||
|
@ -681,7 +681,7 @@ public:
|
||||||
this->word_itr->first();
|
this->word_itr->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_t SetCurPosition(size_t pos)
|
size_t SetCurPosition(size_t pos) override
|
||||||
{
|
{
|
||||||
/* Convert incoming position to an UTF-16 string index. */
|
/* Convert incoming position to an UTF-16 string index. */
|
||||||
uint utf16_pos = 0;
|
uint utf16_pos = 0;
|
||||||
|
@ -699,7 +699,7 @@ public:
|
||||||
return this->utf16_to_utf8[this->char_itr->current()];
|
return this->utf16_to_utf8[this->char_itr->current()];
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_t Next(IterType what)
|
size_t Next(IterType what) override
|
||||||
{
|
{
|
||||||
int32_t pos;
|
int32_t pos;
|
||||||
switch (what) {
|
switch (what) {
|
||||||
|
@ -731,7 +731,7 @@ public:
|
||||||
return pos == icu::BreakIterator::DONE ? END : this->utf16_to_utf8[pos];
|
return pos == icu::BreakIterator::DONE ? END : this->utf16_to_utf8[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_t Prev(IterType what)
|
size_t Prev(IterType what) override
|
||||||
{
|
{
|
||||||
int32_t pos;
|
int32_t pos;
|
||||||
switch (what) {
|
switch (what) {
|
||||||
|
|
Loading…
Reference in New Issue