2006-03-04 18:16:49 +00:00
|
|
|
|
2006-05-30 13:47:28 +00:00
|
|
|
#include "AvailableColumnsPanel.h"
|
2006-03-04 18:16:49 +00:00
|
|
|
#include "Settings.h"
|
|
|
|
#include "Header.h"
|
|
|
|
#include "ScreenManager.h"
|
2006-05-30 13:47:28 +00:00
|
|
|
#include "ColumnsPanel.h"
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2006-05-30 13:47:28 +00:00
|
|
|
#include "Panel.h"
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
/*{
|
|
|
|
|
2006-05-30 13:47:28 +00:00
|
|
|
typedef struct AvailableColumnsPanel_ {
|
|
|
|
Panel super;
|
|
|
|
Panel* columns;
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
Settings* settings;
|
|
|
|
ScreenManager* scr;
|
2006-05-30 13:47:28 +00:00
|
|
|
} AvailableColumnsPanel;
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
}*/
|
|
|
|
|
2006-05-30 13:47:28 +00:00
|
|
|
AvailableColumnsPanel* AvailableColumnsPanel_new(Settings* settings, Panel* columns, ScreenManager* scr) {
|
|
|
|
AvailableColumnsPanel* this = (AvailableColumnsPanel*) malloc(sizeof(AvailableColumnsPanel));
|
|
|
|
Panel* super = (Panel*) this;
|
|
|
|
Panel_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
|
|
|
|
((Object*)this)->delete = AvailableColumnsPanel_delete;
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
this->settings = settings;
|
|
|
|
this->scr = scr;
|
2006-05-30 13:47:28 +00:00
|
|
|
super->eventHandler = AvailableColumnsPanel_eventHandler;
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2006-05-30 13:47:28 +00:00
|
|
|
Panel_setHeader(super, "Available Columns");
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < LAST_PROCESSFIELD; i++) {
|
|
|
|
if (i != COMM)
|
2006-05-30 13:47:28 +00:00
|
|
|
Panel_add(super, (Object*) ListItem_new(Process_fieldNames[i], 0));
|
2006-03-04 18:16:49 +00:00
|
|
|
}
|
|
|
|
this->columns = columns;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2006-05-30 13:47:28 +00:00
|
|
|
void AvailableColumnsPanel_delete(Object* object) {
|
|
|
|
Panel* super = (Panel*) object;
|
|
|
|
AvailableColumnsPanel* this = (AvailableColumnsPanel*) object;
|
|
|
|
Panel_done(super);
|
2006-03-04 18:16:49 +00:00
|
|
|
free(this);
|
|
|
|
}
|
|
|
|
|
2006-05-30 13:47:28 +00:00
|
|
|
HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) {
|
|
|
|
AvailableColumnsPanel* this = (AvailableColumnsPanel*) super;
|
|
|
|
char* text = ((ListItem*) Panel_getSelected(super))->value;
|
2006-03-04 18:16:49 +00:00
|
|
|
HandlerResult result = IGNORED;
|
|
|
|
|
|
|
|
switch(ch) {
|
|
|
|
case 13:
|
|
|
|
case KEY_ENTER:
|
|
|
|
case KEY_F(5):
|
|
|
|
{
|
2006-05-30 13:47:28 +00:00
|
|
|
int at = Panel_getSelectedIndex(this->columns) + 1;
|
|
|
|
if (at == Panel_getSize(this->columns))
|
2006-03-04 18:16:49 +00:00
|
|
|
at--;
|
2006-05-30 13:47:28 +00:00
|
|
|
Panel_insert(this->columns, at, (Object*) ListItem_new(text, 0));
|
|
|
|
ColumnsPanel_update(this->columns);
|
2006-03-04 18:16:49 +00:00
|
|
|
result = HANDLED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|