Boost.UI
User Interface Boost library
font.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Kolya Kosenko
2 
3 // Distributed under the Boost Software License, Version 1.0.
4 // See http://www.boost.org/LICENSE_1_0.txt
5 
7 
8 #ifndef BOOST_UI_FONT_HPP
9 #define BOOST_UI_FONT_HPP
10 
11 #include <boost/ui/config.hpp>
12 
13 #ifdef BOOST_HAS_PRAGMA_ONCE
14 #pragma once
15 #endif
16 
17 #include <boost/ui/string.hpp>
18 
19 #include <boost/core/scoped_enum.hpp>
20 
21 namespace boost {
22 namespace ui {
23 
29 
30 class BOOST_UI_DECL font
31 {
32  class impl;
33 
34 public:
36  BOOST_SCOPED_ENUM_DECLARE_BEGIN(family)
37  {
38  other,
39  serif,
40  sans_serif,
41  cursive,
42  fantasy,
43  monospace
44  }
45  BOOST_SCOPED_ENUM_DECLARE_END(family)
46 
47 
48  BOOST_SCOPED_ENUM_DECLARE_BEGIN(slant)
49  {
50  normal,
51  italic,
52  oblique
53  }
54  BOOST_SCOPED_ENUM_DECLARE_END(slant)
55 
56 
57  BOOST_SCOPED_ENUM_DECLARE_BEGIN(weight)
58  {
59  normal,
60  bold
61  }
62  BOOST_SCOPED_ENUM_DECLARE_END(weight)
63 
64  font();
65 #ifndef DOXYGEN
66  font(const font& other);
67  font& operator=(const font& other);
68 #endif
69  ~font();
70 
72  explicit font(double pt, family f,
73  slant s = slant::normal, weight w = weight::normal);
74  explicit font(double pt, const uistring& n,
75  slant s = slant::normal, weight w = weight::normal);
77 
79  font& set_family(family f);
80 
82  family get_family() const;
83 
85  font& set_slant(slant s);
86 
88  slant get_slant() const;
89 
91  font& set_weight(weight w);
92 
94  weight get_weight() const;
95 
98  font& name(const uistring& n);
99 
101  uistring name() const;
102 
105  font& size_pt(double pt);
106 
108  double size_pt() const;
109 
111  bool valid() const BOOST_NOEXCEPT;
112 
114  typedef void* native_handle_type;
115 
117  native_handle_type native_handle() { return m_impl; }
118  const native_handle_type native_handle() const { return m_impl; }
120 
122  static font caption() BOOST_NOEXCEPT;
123 
124 private:
125  impl* m_impl;
126 
127 #ifndef DOXYGEN
128  friend class native_helper;
129 #endif
130 };
131 
132 } // namespace ui
133 } // namespace boost
134 
135 #endif // BOOST_UI_FONT_HPP
boost::ui::uistring
Helper class to convert string between UI and application logic only.
Definition: string.hpp:49
config.hpp
Configuration options.
boost
Boost C++ libraries namespace.
Definition: window.hpp:19
boost::ui::font::slant
slant
Enumaration of font slants.
Definition: font.hpp:48
string.hpp
String class and operations.
boost::ui::font::native_handle
const native_handle_type native_handle() const
Returns the implementation-defined underlying font handle.
Definition: font.hpp:118
boost::ui::font::native_handle_type
void * native_handle_type
Implementation-defined font type.
Definition: font.hpp:114
boost::ui::font
Font class.
Definition: font.hpp:30
boost::ui::font::family
family
Enumaration of font families.
Definition: font.hpp:36
boost::ui::font::weight
weight
Enumaration of font weights.
Definition: font.hpp:57