Loading...
Searching...
No Matches
element.c File Reference
`#include "arc/console/element.h"`
`#include "arc/console/view.h"`
`#include <stdlib.h>`
`#include <ncurses.h>`

Go to the source code of this file.

## Functions

void | ARC_ConsoleElement_Create (ARC_ConsoleElement **element, uint32_t type, uint8_t flags, ARC_String *string, ARC_Point pos, ARC_ConsoleElement_RenderFn renderFn)
void | ARC_ConsoleElement_Destroy (ARC_ConsoleElement *element)
void | ARC_ConsoleElement_DefaultRenderFn (ARC_ConsoleView *view, ARC_ConsoleElement *element)
ARC_Bool | ARC_ConsoleElement_IsSelectable (ARC_ConsoleElement *element)
void | ARC_ConsoleElement_SetSelected (ARC_ConsoleElement *element, ARC_Bool selected)
void | ARC_NCursesElement_ToggleSelected (ARC_ConsoleElement *element)

## Function Documentation

## ARC_ConsoleElement_Create()

void ARC_ConsoleElement_Create | ( | ARC_ConsoleElement ** | element,
|  | uint32_t | type,
|  | uint8_t | flags,
|  | ARC_String * | string,
|  | ARC_Point | pos,
|  | ARC_ConsoleElement_RenderFn | renderFn )

Definition at line 7 of file element.c.

{
*element = (ARC_ConsoleElement *)malloc(sizeof(ARC_ConsoleElement));
(*element)->type = type;
(*element)->flags = flags;
(*element)->string = string;
(*element)->pos = pos;
(*element)->renderFn = renderFn;
}
ARC_ConsoleElement
Definition element.h:27
ARC_ConsoleElement::type
uint32_t type
Definition element.h:28

References ARC_ConsoleElement::type.

## ARC_ConsoleElement_DefaultRenderFn()

void ARC_ConsoleElement_DefaultRenderFn | ( | ARC_ConsoleView * | view,
|  | ARC_ConsoleElement * | element )

Definition at line 21 of file element.c.

{
if(element->flags & ARC_CONSOLE_ELEMENT_FLAG_SELECTED){
ARC_ConsoleView_SetAttribute(view, ARC_CONSOLE_VIEW_ATTRIBUTE_REVERSE);
}
ARC_ConsoleView_RenderStringAt(view, element->string, element->pos);
if(element->flags & ARC_CONSOLE_ELEMENT_FLAG_SELECTED){
ARC_ConsoleView_SetAttribute(view, ARC_CONSOLE_VIEW_ATTRIBUTE_NONE);
}
}
ARC_ConsoleView_RenderStringAt
void ARC_ConsoleView_RenderStringAt(ARC_ConsoleView *view, ARC_String *text, ARC_Point pos)
Definition view.c:109
ARC_CONSOLE_VIEW_ATTRIBUTE_REVERSE
#define ARC_CONSOLE_VIEW_ATTRIBUTE_REVERSE
Definition view.h:253
ARC_CONSOLE_VIEW_ATTRIBUTE_NONE
#define ARC_CONSOLE_VIEW_ATTRIBUTE_NONE
border options
Definition view.h:252
ARC_ConsoleView_SetAttribute
void ARC_ConsoleView_SetAttribute(ARC_ConsoleView *view, uint32_t attribute)
sets a border on the ARC_ConsoleView
Definition view.c:259
ARC_CONSOLE_ELEMENT_FLAG_SELECTED
#define ARC_CONSOLE_ELEMENT_FLAG_SELECTED
Definition element.h:42
ARC_ConsoleElement::string
ARC_String * string
Definition element.h:30
ARC_ConsoleElement::pos
ARC_Point pos
Definition element.h:32
ARC_ConsoleElement::flags
uint8_t flags
Definition element.h:29

References ARC_CONSOLE_ELEMENT_FLAG_SELECTED, ARC_CONSOLE_VIEW_ATTRIBUTE_NONE, ARC_CONSOLE_VIEW_ATTRIBUTE_REVERSE, ARC_ConsoleView_RenderStringAt(), ARC_ConsoleView_SetAttribute(), ARC_ConsoleElement::flags, ARC_ConsoleElement::pos, and ARC_ConsoleElement::string.

## ARC_ConsoleElement_Destroy()

void ARC_ConsoleElement_Destroy | ( | ARC_ConsoleElement * | element | ) |

Definition at line 17 of file element.c.

{
free(element);
}

## ARC_ConsoleElement_IsSelectable()

ARC_Bool ARC_ConsoleElement_IsSelectable | ( | ARC_ConsoleElement * | element | ) |

Parameters

Definition at line 33 of file element.c.

{
if(element->flags & ARC_CONSOLE_ELEMENT_FLAG_SELECTABLE){
return ARC_True;
}
return ARC_False;
}
ARC_False
#define ARC_False
Definition bool.h:12
ARC_True
#define ARC_True
Definition bool.h:11
ARC_CONSOLE_ELEMENT_FLAG_SELECTABLE
#define ARC_CONSOLE_ELEMENT_FLAG_SELECTABLE
Definition element.h:41

References ARC_CONSOLE_ELEMENT_FLAG_SELECTABLE, ARC_False, ARC_True, and ARC_ConsoleElement::flags.

## ARC_ConsoleElement_SetSelected()

void ARC_ConsoleElement_SetSelected | ( | ARC_ConsoleElement * | element,
|  | ARC_Bool | selected )

Parameters

Definition at line 41 of file element.c.

{
if(selected){
element->flags |= ARC_CONSOLE_ELEMENT_FLAG_SELECTED;
return;
}
element->flags &= ~ARC_CONSOLE_ELEMENT_FLAG_SELECTED;
}

References ARC_CONSOLE_ELEMENT_FLAG_SELECTED, and ARC_ConsoleElement::flags.

## ARC_NCursesElement_ToggleSelected()

void ARC_NCursesElement_ToggleSelected | ( | ARC_ConsoleElement * | element | ) |

Definition at line 50 of file element.c.

{
element->flags ^= ARC_CONSOLE_ELEMENT_FLAG_SELECTED;
}

References ARC_CONSOLE_ELEMENT_FLAG_SELECTED, and ARC_ConsoleElement::flags.