OpenPine C++ API
C++ wrapper for the OpenPine Pine Script VM
Loading...
Searching...
No Matches
box.hpp
Go to the documentation of this file.
1#pragma once
2
7
8#if (defined(_MSVC_LANG) ? _MSVC_LANG : __cplusplus) < 201703L
9#error \
10 "OpenPine C++ wrapper headers require C++17 (std::optional, std::string_view)."
11#endif
12
13#include <cstdint>
14#include <optional>
15#include <string_view>
16
17#include "../ffi.hpp"
18#include "../string_ref.hpp"
19#include "../types.hpp"
20
21namespace openpine {
22namespace graph {
23
27class Box {
28 private:
29 const ffi::Box* p_;
30
31 public:
32 Box(const ffi::Box* p) : p_(p) {}
33
37 int64_t left() const { return ffi::boxLeft(p_); }
38
42 double top() const { return ffi::boxTop(p_); }
43
47 int64_t right() const { return ffi::boxRight(p_); }
48
52 double bottom() const { return ffi::boxBottom(p_); }
53
57 std::optional<uint32_t> borderColor() const {
58 uint32_t v;
59 if (ffi::boxBorderColor(p_, &v)) {
60 return v;
61 } else {
62 return std::nullopt;
63 }
64 }
65
69 int32_t borderWidth() const { return ffi::boxBorderWidth(p_); }
70
74 LineStyle borderStyle() const { return ffi::boxBorderStyle(p_); }
75
79 Extend extend() const { return ffi::boxExtend(p_); }
80
84 XLocation xloc() const { return ffi::boxXloc(p_); }
85
89 std::optional<uint32_t> backgroundColor() const {
90 uint32_t v;
91 if (ffi::boxBackgroundColor(p_, &v)) {
92 return v;
93 } else {
94 return std::nullopt;
95 }
96 }
97
101 std::string_view text() const {
102 ffi::PineStringRef ref;
103 ffi::boxText(p_, &ref);
104 return detail::refToView(ref);
105 }
106
110 uint32_t textSize() const { return ffi::boxTextSize(p_); }
111
115 std::optional<uint32_t> textColor() const {
116 uint32_t v;
117 if (ffi::boxTextColor(p_, &v)) {
118 return v;
119 } else {
120 return std::nullopt;
121 }
122 }
123
127 HorizontalAlign textHalign() const { return ffi::boxTextHalign(p_); }
128
132 VerticalAlign textValign() const { return ffi::boxTextValign(p_); }
133
137 TextWrap textWrap() const { return ffi::boxTextWrap(p_); }
138
142 FontFamily textFontFamily() const { return ffi::boxTextFontFamily(p_); }
143
147 TextFormatting textFormatting() const { return ffi::boxTextFormatting(p_); }
148
152 bool forceOverlay() const { return ffi::boxForceOverlay(p_); }
153};
154
155} // namespace graph
156} // namespace openpine
TextWrap textWrap() const
Gets the text wrapping mode.
Definition box.hpp:137
std::optional< uint32_t > borderColor() const
Gets the optional border color.
Definition box.hpp:57
VerticalAlign textValign() const
Gets the text vertical alignment.
Definition box.hpp:132
bool forceOverlay() const
Gets whether the box is forced to render as overlay.
Definition box.hpp:152
Box(const ffi::Box *p)
Definition box.hpp:32
int32_t borderWidth() const
Gets the border width.
Definition box.hpp:69
uint32_t textSize() const
Gets the text size.
Definition box.hpp:110
std::optional< uint32_t > textColor() const
Gets the optional text color.
Definition box.hpp:115
int64_t left() const
Gets the left x-coordinate.
Definition box.hpp:37
int64_t right() const
Gets the right x-coordinate.
Definition box.hpp:47
std::string_view text() const
Gets the text inside the box.
Definition box.hpp:101
XLocation xloc() const
Gets the X-axis coordinate system used by left()/right().
Definition box.hpp:84
HorizontalAlign textHalign() const
Gets the text horizontal alignment.
Definition box.hpp:127
std::optional< uint32_t > backgroundColor() const
Gets the optional background fill color.
Definition box.hpp:89
Extend extend() const
Gets the extend mode.
Definition box.hpp:79
double bottom() const
Gets the bottom y-coordinate.
Definition box.hpp:52
TextFormatting textFormatting() const
Gets the text formatting (bold/italic).
Definition box.hpp:147
FontFamily textFontFamily() const
Gets the font family.
Definition box.hpp:142
LineStyle borderStyle() const
Gets the border style.
Definition box.hpp:74
double top() const
Gets the top y-coordinate.
Definition box.hpp:42
std::string_view refToView(const ffi::PineStringRef &ref)
Shared helpers for converting C ABI string refs to std::string_view.
Re-exports FFI types into the openpine namespace.