diff options
Diffstat (limited to 'AvailableMetersListBox.c')
-rw-r--r-- | AvailableMetersListBox.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/AvailableMetersListBox.c b/AvailableMetersListBox.c index 88011bab..0642ccaa 100644 --- a/AvailableMetersListBox.c +++ b/AvailableMetersListBox.c @@ -1,79 +1,79 @@ -#include "AvailableMetersListBox.h" +#include "AvailableMetersPanel.h" #include "Settings.h" #include "Header.h" #include "ScreenManager.h" -#include "ListBox.h" +#include "Panel.h" #include "debug.h" #include <assert.h> /*{ -typedef struct AvailableMetersListBox_ { - ListBox super; +typedef struct AvailableMetersPanel_ { + Panel super; Settings* settings; - ListBox* leftBox; - ListBox* rightBox; + Panel* leftBox; + Panel* rightBox; ScreenManager* scr; -} AvailableMetersListBox; +} AvailableMetersPanel; }*/ -AvailableMetersListBox* AvailableMetersListBox_new(Settings* settings, ListBox* leftMeters, ListBox* rightMeters, ScreenManager* scr) { - AvailableMetersListBox* this = (AvailableMetersListBox*) malloc(sizeof(AvailableMetersListBox)); - ListBox* super = (ListBox*) this; - ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true); - ((Object*)this)->delete = AvailableMetersListBox_delete; +AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr) { + AvailableMetersPanel* this = (AvailableMetersPanel*) malloc(sizeof(AvailableMetersPanel)); + Panel* super = (Panel*) this; + Panel_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true); + ((Object*)this)->delete = AvailableMetersPanel_delete; this->settings = settings; this->leftBox = leftMeters; this->rightBox = rightMeters; this->scr = scr; - super->eventHandler = AvailableMetersListBox_EventHandler; + super->eventHandler = AvailableMetersPanel_EventHandler; - ListBox_setHeader(super, "Available meters"); + Panel_setHeader(super, "Available meters"); for (int i = 1; Meter_types[i]; i++) { MeterType* type = Meter_types[i]; if (type != &CPUMeter) { - ListBox_add(super, (Object*) ListItem_new(type->uiName, i << 16)); + Panel_add(super, (Object*) ListItem_new(type->uiName, i << 16)); } } MeterType* type = &CPUMeter; int processors = settings->pl->processorCount; if (processors > 1) { - ListBox_add(super, (Object*) ListItem_new("CPU average", 0)); + Panel_add(super, (Object*) ListItem_new("CPU average", 0)); for (int i = 1; i <= processors; i++) { char buffer[50]; sprintf(buffer, "%s %d", type->uiName, i); - ListBox_add(super, (Object*) ListItem_new(buffer, i)); + Panel_add(super, (Object*) ListItem_new(buffer, i)); } } else { - ListBox_add(super, (Object*) ListItem_new("CPU", 1)); + Panel_add(super, (Object*) ListItem_new("CPU", 1)); } return this; } -void AvailableMetersListBox_delete(Object* object) { - ListBox* super = (ListBox*) object; - AvailableMetersListBox* this = (AvailableMetersListBox*) object; - ListBox_done(super); +void AvailableMetersPanel_delete(Object* object) { + Panel* super = (Panel*) object; + AvailableMetersPanel* this = (AvailableMetersPanel*) object; + Panel_done(super); free(this); } /* private */ -inline void AvailableMetersListBox_addHeader(Header* header, ListBox* lb, MeterType* type, int param, HeaderSide side) { +inline void AvailableMetersPanel_addHeader(Header* header, Panel* lb, MeterType* type, int param, HeaderSide side) { Meter* meter = (Meter*) Header_addMeter(header, type, param, side); - ListBox_add(lb, (Object*) Meter_toListItem(meter)); + Panel_add(lb, (Object*) Meter_toListItem(meter)); } -HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch) { - AvailableMetersListBox* this = (AvailableMetersListBox*) super; +HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) { + AvailableMetersPanel* this = (AvailableMetersPanel*) super; Header* header = this->settings->header; - ListItem* selected = (ListItem*) ListBox_getSelected(super); + ListItem* selected = (ListItem*) Panel_getSelected(super); int param = selected->key & 0xff; int type = selected->key >> 16; HandlerResult result = IGNORED; @@ -83,7 +83,7 @@ HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch) { case 'l': case 'L': { - AvailableMetersListBox_addHeader(header, this->leftBox, Meter_types[type], param, LEFT_HEADER); + AvailableMetersPanel_addHeader(header, this->leftBox, Meter_types[type], param, LEFT_HEADER); result = HANDLED; break; } @@ -91,7 +91,7 @@ HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch) { case 'r': case 'R': { - AvailableMetersListBox_addHeader(header, this->rightBox, Meter_types[type], param, RIGHT_HEADER); + AvailableMetersPanel_addHeader(header, this->rightBox, Meter_types[type], param, RIGHT_HEADER); result = HANDLED; break; } |