summaryrefslogtreecommitdiffstats
path: root/AvailableColumnsListBox.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2006-03-04 18:16:49 +0000
committerHisham Muhammad <hisham@gobolinux.org>2006-03-04 18:16:49 +0000
commitd6231bab89d634da5564491196b7c478db038505 (patch)
treebfc0bf00b138763eb41132fd27a8f389a78bf3a4 /AvailableColumnsListBox.c
Initial import.
Diffstat (limited to 'AvailableColumnsListBox.c')
-rw-r--r--AvailableColumnsListBox.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/AvailableColumnsListBox.c b/AvailableColumnsListBox.c
new file mode 100644
index 00000000..f4f91372
--- /dev/null
+++ b/AvailableColumnsListBox.c
@@ -0,0 +1,72 @@
+
+#include "AvailableColumnsListBox.h"
+#include "Settings.h"
+#include "Header.h"
+#include "ScreenManager.h"
+#include "ColumnsListBox.h"
+
+#include "ListBox.h"
+
+#include "debug.h"
+#include <assert.h>
+
+/*{
+
+typedef struct AvailableColumnsListBox_ {
+ ListBox super;
+ ListBox* columns;
+
+ Settings* settings;
+ ScreenManager* scr;
+} AvailableColumnsListBox;
+
+}*/
+
+AvailableColumnsListBox* AvailableColumnsListBox_new(Settings* settings, ListBox* columns, ScreenManager* scr) {
+ AvailableColumnsListBox* this = (AvailableColumnsListBox*) malloc(sizeof(AvailableColumnsListBox));
+ ListBox* super = (ListBox*) this;
+ ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
+ ((Object*)this)->delete = AvailableColumnsListBox_delete;
+
+ this->settings = settings;
+ this->scr = scr;
+ super->eventHandler = AvailableColumnsListBox_eventHandler;
+
+ ListBox_setHeader(super, "Available Columns");
+
+ for (int i = 1; i < LAST_PROCESSFIELD; i++) {
+ if (i != COMM)
+ ListBox_add(super, (Object*) ListItem_new(Process_fieldNames[i], 0));
+ }
+ this->columns = columns;
+ return this;
+}
+
+void AvailableColumnsListBox_delete(Object* object) {
+ ListBox* super = (ListBox*) object;
+ AvailableColumnsListBox* this = (AvailableColumnsListBox*) object;
+ ListBox_done(super);
+ free(this);
+}
+
+HandlerResult AvailableColumnsListBox_eventHandler(ListBox* super, int ch) {
+ AvailableColumnsListBox* this = (AvailableColumnsListBox*) super;
+ char* text = ((ListItem*) ListBox_getSelected(super))->value;
+ HandlerResult result = IGNORED;
+
+ switch(ch) {
+ case 13:
+ case KEY_ENTER:
+ case KEY_F(5):
+ {
+ int at = ListBox_getSelectedIndex(this->columns) + 1;
+ if (at == ListBox_getSize(this->columns))
+ at--;
+ ListBox_insert(this->columns, at, (Object*) ListItem_new(text, 0));
+ ColumnsListBox_update(this->columns);
+ result = HANDLED;
+ break;
+ }
+ }
+ return result;
+}