MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DrawText

Method DrawText

ui/UIEdit.cpp:288–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288void UIEdit::DrawText() {
289 char buffer[EDIT_BUFLEN_MAX];
290 int str_w, i, cursor_w;
291
292 if (m_FontHandle > -1)
293 ui_DrawSetFont(m_FontHandle);
294
295 // I need an extra character.
296 ASSERT(strlen(m_TextBuf) < sizeof(buffer));
297
298 if (m_Flags & UIED_PASSWORD) {
299 memset(buffer, '*', strlen(m_TextBuf));
300 buffer[strlen(m_TextBuf)] = 0;
301 } else {
302 strcpy(buffer, m_TextBuf);
303 }
304
305 if (m_Active || HasFocus())
306 ui_SetCharAlpha(255);
307 else
308 ui_SetCharAlpha(164);
309
310 if (IsDisabled())
311 ui_SetCharAlpha(96);
312
313 // we must set StartPos if StartPos is -1
314 if (m_StartPos < 0) {
315 m_StartPos = 0;
316 cursor_w = ui_GetTextWidth("_");
317 str_w = ui_GetTextWidth(&buffer[m_StartPos]);
318 while ((m_X1b + str_w) > (m_X2b - cursor_w)) {
319 m_StartPos++;
320 str_w = ui_GetTextWidth(&buffer[m_StartPos]);
321 }
322 }
323
324 // determine how much of string to draw at one time.
325 i = 0;
326
327 cursor_w = ui_GetTextWidth("_") * 2;
328 str_w = ui_GetTextWidth(&buffer[m_StartPos]);
329 while ((m_X1b + str_w) > (m_X2b - cursor_w) && ((int)strlen(buffer) > m_StartPos)) {
330 buffer[strlen(buffer) - 1] = 0;
331 str_w = ui_GetTextWidth(&buffer[m_StartPos]);
332 i++;
333 }
334
335 // if i is > 0, then the string displayed overlaps the boundaries of the listbox
336 m_ScrollThresh = i ? (strlen(buffer)) : 0;
337
338 if (m_ScrollThresh && m_UpdateCount) {
339 m_StartPos++;
340 m_UpdateCount = false;
341 }
342
343 // if cursor position is outside viewing region, we must adjust the viewing region.
344 // i = strlen(buffer);
345 // while (m_CurPos > i)

Callers 3

DrawItemMethod · 0.80
DrawItemMethod · 0.80
DrawCaptionMethod · 0.80

Calls 7

ui_DrawSetFontFunction · 0.85
ui_SetCharAlphaFunction · 0.85
ui_GetTextWidthFunction · 0.85
ui_DrawSetTextTypeFunction · 0.85
ui_DrawStringFunction · 0.85
ui_GetFontHeightFunction · 0.85
UI_TIMEFunction · 0.85

Tested by

no test coverage detected