MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / drawTextBox

Function drawTextBox

src/ui/theme.cpp:77–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77void drawTextBox(Graphics* g, Widget* widget,
78 int* w, int* h, gfx::Color bg, gfx::Color fg)
79{
80 View* view = View::getView(widget);
81 char* text = const_cast<char*>(widget->text().c_str());
82 char* beg, *end;
83 int x1, y1, x2, y2;
84 int x, y, chr, len;
85 gfx::Point scroll;
86 int viewport_w, viewport_h;
87 int textheight = widget->textHeight();
88 auto font = widget->font();
89 char *beg_end, *old_end;
90 int width;
91
92 if (view) {
93 gfx::Rect vp = view->viewportBounds()
94 .offset(-view->viewport()->bounds().origin());
95
96 x1 = vp.x;
97 y1 = vp.y;
98 viewport_w = vp.w;
99 viewport_h = vp.h;
100 scroll = view->viewScroll();
101 }
102 else {
103 x1 = widget->clientBounds().x + widget->border().left();
104 y1 = widget->clientBounds().y + widget->border().top();
105 viewport_w = widget->clientBounds().w - widget->border().width();
106 viewport_h = widget->clientBounds().h - widget->border().height();
107 }
108 x2 = x1 + viewport_w;
109 y2 = y1 + viewport_h;
110
111 chr = 0;
112
113 // Without word-wrap
114 if (!(widget->align() & WORDWRAP)) {
115 width = widget->clientBounds().w;
116 }
117 // With word-wrap
118 else {
119 if (w) {
120 width = *w;
121 *w = 0;
122 }
123 else {
124 /* TODO modificable option? I don't think so, this is very internal stuff */
125#if 0
126 /* shows more information in x-scroll 0 */
127 width = viewport_w;
128#else
129 /* make good use of the complete text-box */
130 if (view) {
131 gfx::Size maxSize = view->getScrollableSize();
132 width = MAX(viewport_w, maxSize.w);
133 }
134 else {

Callers 2

paintTextBoxMethod · 0.85
onSizeHintMethod · 0.85

Calls 15

PointClass · 0.85
textHeightMethod · 0.80
viewportBoundsMethod · 0.80
viewportMethod · 0.80
clientBoundsMethod · 0.80
drawUIStringMethod · 0.80
fillAreaBetweenRectsMethod · 0.80
fontMethod · 0.45
offsetMethod · 0.45
originMethod · 0.45
boundsMethod · 0.45
viewScrollMethod · 0.45

Tested by

no test coverage detected