2
#include "CategoriesListBox.h"
3
#include "AvailableMetersListBox.h"
4
#include "MetersListBox.h"
5
#include "DisplayOptionsListBox.h"
14
typedef struct CategoriesListBox_ {
23
/* private property */
24
char* MetersFunctions[10] = {" ", " ", " ", "Type ", "Add L ", "Add R ", "MoveUp", "MoveDn", "Remove", "Done "};
26
/* private property */
27
char* DisplayOptionsFunctions[10] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done "};
29
CategoriesListBox* CategoriesListBox_new(Settings* settings, ScreenManager* scr) {
30
CategoriesListBox* this = (CategoriesListBox*) malloc(sizeof(CategoriesListBox));
31
ListBox* super = (ListBox*) this;
32
ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
33
((Object*)this)->delete = CategoriesListBox_delete;
35
this->settings = settings;
37
super->eventHandler = CategoriesListBox_eventHandler;
38
ListBox_setHeader(super, RichString_quickString(CRT_colors[PANEL_HEADER_FOCUS], "Setup"));
39
ListBox_add(super, (Object*) ListItem_new(String_copy("Meters")));
40
ListBox_add(super, (Object*) ListItem_new(String_copy("Display options")));
44
void CategoriesListBox_delete(Object* object) {
45
ListBox* super = (ListBox*) object;
46
CategoriesListBox* this = (CategoriesListBox*) object;
51
HandlerResult CategoriesListBox_eventHandler(ListBox* super, int ch) {
52
CategoriesListBox* this = (CategoriesListBox*) super;
54
HandlerResult result = IGNORED;
56
int previous = ListBox_getSelectedIndex(super);
65
ListBox_onKey(super, ch);
66
int selected = ListBox_getSelectedIndex(super);
67
if (previous != selected) {
68
int size = ScreenManager_size(this->scr);
69
for (int i = 1; i < size; i++)
70
ScreenManager_remove(this->scr, 1);
73
CategoriesListBox_makeMetersPage(this);
76
CategoriesListBox_makeProcessListPage(this);
87
void CategoriesListBox_makeMetersPage(CategoriesListBox* this) {
88
FunctionBar* fuBar = FunctionBar_new(10, MetersFunctions, NULL, NULL);
89
ListBox* lbLeftMeters = (ListBox*) MetersListBox_new(this->settings, "Left column", this->settings->header->leftMeters, this->scr);
90
ListBox* lbRightMeters = (ListBox*) MetersListBox_new(this->settings, "Right column", this->settings->header->rightMeters, this->scr);
91
ListBox* lbAvailableMeters = (ListBox*) AvailableMetersListBox_new(this->settings, lbLeftMeters, lbRightMeters, this->scr);
92
ScreenManager_add(this->scr, lbLeftMeters, 20);
93
ScreenManager_add(this->scr, lbRightMeters, 20);
94
ScreenManager_add(this->scr, lbAvailableMeters, -1);
95
ScreenManager_setFunctionBar(this->scr, fuBar);
98
void CategoriesListBox_makeProcessListPage(CategoriesListBox* this) {
99
FunctionBar* fuBar = FunctionBar_new(10, DisplayOptionsFunctions, NULL, NULL);
100
ListBox* lbDisplayOptions = (ListBox*) DisplayOptionsListBox_new(this->settings, this->scr);
101
ScreenManager_add(this->scr, lbDisplayOptions, -1);
102
ScreenManager_setFunctionBar(this->scr, fuBar);