diff options
author | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:15 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:15 +0200 |
commit | d3c9975943df58e293359b87905d19ff1fd52061 (patch) | |
tree | e416378879f60e8d538b1b25963904f767d30ff4 /DisplayOptionsListBox.c | |
download | debian_htop-d3c9975943df58e293359b87905d19ff1fd52061.tar.gz debian_htop-d3c9975943df58e293359b87905d19ff1fd52061.tar.bz2 debian_htop-d3c9975943df58e293359b87905d19ff1fd52061.zip |
Imported Upstream version 0.5upstream/0.5
Diffstat (limited to 'DisplayOptionsListBox.c')
-rw-r--r-- | DisplayOptionsListBox.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/DisplayOptionsListBox.c b/DisplayOptionsListBox.c new file mode 100644 index 0000000..e0dff29 --- /dev/null +++ b/DisplayOptionsListBox.c @@ -0,0 +1,73 @@ + +#include "DisplayOptionsListBox.h" + +#include "ListBox.h" +#include "CheckItem.h" +#include "Settings.h" +#include "ScreenManager.h" + +#include "debug.h" +#include <assert.h> + +/*{ + +typedef struct DisplayOptionsListBox_ { + ListBox super; + + Settings* settings; + ScreenManager* scr; +} DisplayOptionsListBox; + +}*/ + +DisplayOptionsListBox* DisplayOptionsListBox_new(Settings* settings, ScreenManager* scr) { + DisplayOptionsListBox* this = (DisplayOptionsListBox*) malloc(sizeof(DisplayOptionsListBox)); + ListBox* super = (ListBox*) this; + ListBox_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true); + ((Object*)this)->delete = DisplayOptionsListBox_delete; + + this->settings = settings; + this->scr = scr; + super->eventHandler = DisplayOptionsListBox_eventHandler; + + ListBox_setHeader(super, RichString_quickString(CRT_colors[PANEL_HEADER_FOCUS], "Display options")); + ListBox_add(super, (Object*) CheckItem_new(String_copy("Tree view"), &(settings->pl->treeView))); + ListBox_add(super, (Object*) CheckItem_new(String_copy("Shadow other users' processes"), &(settings->pl->shadowOtherUsers))); + ListBox_add(super, (Object*) CheckItem_new(String_copy("Hide kernel threads"), &(settings->pl->hideKernelThreads))); + ListBox_add(super, (Object*) CheckItem_new(String_copy("Highlight program \"basename\""), &(settings->pl->highlightBaseName))); + ListBox_add(super, (Object*) CheckItem_new(String_copy("Highlight megabytes in memory counters"), &(settings->pl->highlightMegabytes))); + ListBox_add(super, (Object*) CheckItem_new(String_copy("Leave a margin around header"), &(settings->header->margin))); + return this; +} + +void DisplayOptionsListBox_delete(Object* object) { + ListBox* super = (ListBox*) object; + DisplayOptionsListBox* this = (DisplayOptionsListBox*) object; + ListBox_done(super); + free(this); +} + +HandlerResult DisplayOptionsListBox_eventHandler(ListBox* super, int ch) { + DisplayOptionsListBox* this = (DisplayOptionsListBox*) super; + + HandlerResult result = IGNORED; + CheckItem* selected = (CheckItem*) ListBox_getSelected(super); + + switch(ch) { + case 0x0a: + case 0x0d: + case KEY_ENTER: + case ' ': + *(selected->value) = ! *(selected->value); + result = HANDLED; + } + + if (result == HANDLED) { + Header* header = this->settings->header; + Header_calculateHeight(header); + Header_draw(header); + ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2); + } + return result; +} + |