diff --git a/src/apps/haiku-depot/Jamfile b/src/apps/haiku-depot/Jamfile index 97499e2689..4a548446b6 100644 --- a/src/apps/haiku-depot/Jamfile +++ b/src/apps/haiku-depot/Jamfile @@ -2,6 +2,16 @@ SubDir HAIKU_TOP src apps haiku-depot ; UsePrivateHeaders interface shared ; +# source directories +local sourceDirs = + textview +; + +local sourceDir ; +for sourceDir in $(sourceDirs) { + SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src apps haiku-depot $(sourceDir) ] ; +} + Application HaikuDepot : App.cpp FilterView.cpp @@ -13,6 +23,10 @@ Application HaikuDepot : PackageListView.cpp PackageManager.cpp support.cpp + + TextLayout.cpp + TextView.cpp + : be translation libcolumnlistview.a libshared.a $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) : HaikuDepot.rdef diff --git a/src/apps/haiku-depot/textview/TextLayout.cpp b/src/apps/haiku-depot/textview/TextLayout.cpp new file mode 100644 index 0000000000..6ce034289d --- /dev/null +++ b/src/apps/haiku-depot/textview/TextLayout.cpp @@ -0,0 +1,499 @@ +/* + * Copyright 2013, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include "TextLayout.h" + +#include + +#include +#include +#include + +#include "List.h" + + +enum { + CHAR_CLASS_DEFAULT, + CHAR_CLASS_WHITESPACE, + CHAR_CLASS_GRAPHICAL, + CHAR_CLASS_QUOTE, + CHAR_CLASS_PUNCTUATION, + CHAR_CLASS_PARENS_OPEN, + CHAR_CLASS_PARENS_CLOSE, + CHAR_CLASS_END_OF_TEXT +}; + + +static uint32 +get_char_classification(uint32 charCode) +{ + // TODO: Should check against a list of characters containing also + // word breakers from other languages. + + switch (charCode) { + case '\0': + return CHAR_CLASS_END_OF_TEXT; + + case ' ': + case '\t': + case '\n': + return CHAR_CLASS_WHITESPACE; + + case '=': + case '+': + case '@': + case '#': + case '$': + case '%': + case '^': + case '&': + case '*': + case '\\': + case '|': + case '<': + case '>': + case '/': + case '~': + return CHAR_CLASS_GRAPHICAL; + + case '\'': + case '"': + return CHAR_CLASS_QUOTE; + + case ',': + case '.': + case '?': + case '!': + case ';': + case ':': + case '-': + return CHAR_CLASS_PUNCTUATION; + + case '(': + case '[': + case '{': + return CHAR_CLASS_PARENS_OPEN; + + case ')': + case ']': + case '}': + return CHAR_CLASS_PARENS_CLOSE; + + default: + return CHAR_CLASS_DEFAULT; + } +} + + +class Style : public BReferenceable { +public: + Style(const BFont& font, float ascent, float descent, float width, + rgb_color fgColor, rgb_color bgColor, bool strikeOut, + rgb_color strikeOutColor, bool underline, + uint32 underlineStyle, rgb_color underlineColor) + : + font(font), + + ascent(ascent), + descent(descent), + width(width), + + fgColor(fgColor), + bgColor(bgColor), + + strikeOut(strikeOut), + strikeOutColor(strikeOutColor), + + underline(underline), + underlineStyle(underlineStyle), + underlineColor(underlineColor) + { + } + +public: + BFont font; + + // The following three values override glyph metrics unless -1 + float ascent; + float descent; + float width; + + rgb_color fgColor; + rgb_color bgColor; + + bool strikeOut; + rgb_color strikeOutColor; + + bool underline; + uint32 underlineStyle; + rgb_color underlineColor; +}; + + +typedef BReference