openMSX
OSDText.hh
Go to the documentation of this file.
1 #ifndef OSDTEXT_HH
2 #define OSDTEXT_HH
3 
4 #include "OSDImageBasedWidget.hh"
5 #include "TTFFont.hh"
6 #include <memory>
7 
8 namespace openmsx {
9 
10 class OSDText final : public OSDImageBasedWidget
11 {
12 public:
13  OSDText(Display& display, const TclObject& name);
14 
15  std::vector<std::string_view> getProperties() const override;
16  void setProperty(Interpreter& interp,
17  std::string_view name, const TclObject& value) override;
18  void getProperty(std::string_view name, TclObject& result) const override;
19  std::string_view getType() const override;
20 
21 private:
22  void invalidateLocal() override;
23  gl::vec2 getSize(const OutputSurface& output) const override;
24  uint8_t getFadedAlpha() const override;
25  std::unique_ptr<BaseImage> createSDL(OutputSurface& output) override;
26  std::unique_ptr<BaseImage> createGL (OutputSurface& output) override;
27  template <typename IMAGE> std::unique_ptr<BaseImage> create(
28  OutputSurface& output);
29 
30  template<typename FindSplitPointFunc, typename CantSplitFunc>
31  size_t split(const std::string& line, unsigned maxWidth,
32  FindSplitPointFunc findSplitPoint, CantSplitFunc cantSplit,
33  bool removeTrailingSpaces) const;
34  size_t splitAtChar(const std::string& line, unsigned maxWidth) const;
35  size_t splitAtWord(const std::string& line, unsigned maxWidth) const;
36  std::string getCharWrappedText(const std::string& txt, unsigned maxWidth) const;
37  std::string getWordWrappedText(const std::string& txt, unsigned maxWidth) const;
38 
39  gl::vec2 getRenderedSize() const;
40 
41  enum WrapMode { NONE, WORD, CHAR };
42 
43  std::string text;
44  std::string fontfile;
45  TTFFont font;
46  int size;
47  WrapMode wrapMode;
48  float wrapw, wraprelw;
49 
50  friend struct SplitAtChar;
51 };
52 
53 } // namespace openmsx
54 
55 #endif
std::vector< std::string_view > getProperties() const override
Definition: OSDText.cc:37
void setProperty(Interpreter &interp, std::string_view name, const TclObject &value) override
Definition: OSDText.cc:48
Represents the output window/screen of openMSX.
Definition: Display.hh:31
A frame buffer where pixels can be written to.
void getProperty(std::string_view name, TclObject &result) const override
Definition: OSDText.cc:112
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
OSDText(Display &display, const TclObject &name)
Definition: OSDText.cc:29
std::string_view getType() const override
Definition: OSDText.cc:148