2
#include "DisplayOptionsPanel.h"
7
#include "ScreenManager.h"
14
typedef struct DisplayOptionsPanel_ {
19
} DisplayOptionsPanel;
23
DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr) {
24
DisplayOptionsPanel* this = (DisplayOptionsPanel*) malloc(sizeof(DisplayOptionsPanel));
25
Panel* super = (Panel*) this;
26
Panel_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true);
27
((Object*)this)->delete = DisplayOptionsPanel_delete;
29
this->settings = settings;
31
super->eventHandler = DisplayOptionsPanel_EventHandler;
33
Panel_setHeader(super, "Display options");
34
Panel_add(super, (Object*) CheckItem_new(String_copy("Tree view"), &(settings->pl->treeView)));
35
Panel_add(super, (Object*) CheckItem_new(String_copy("Shadow other users' processes"), &(settings->pl->shadowOtherUsers)));
36
Panel_add(super, (Object*) CheckItem_new(String_copy("Hide kernel threads"), &(settings->pl->hideKernelThreads)));
37
Panel_add(super, (Object*) CheckItem_new(String_copy("Hide userland threads"), &(settings->pl->hideUserlandThreads)));
38
Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight program \"basename\""), &(settings->pl->highlightBaseName)));
39
Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight megabytes in memory counters"), &(settings->pl->highlightMegabytes)));
40
Panel_add(super, (Object*) CheckItem_new(String_copy("Leave a margin around header"), &(settings->header->margin)));
44
void DisplayOptionsPanel_delete(Object* object) {
45
Panel* super = (Panel*) object;
46
DisplayOptionsPanel* this = (DisplayOptionsPanel*) object;
51
HandlerResult DisplayOptionsPanel_EventHandler(Panel* super, int ch) {
52
DisplayOptionsPanel* this = (DisplayOptionsPanel*) super;
54
HandlerResult result = IGNORED;
55
CheckItem* selected = (CheckItem*) Panel_getSelected(super);
62
*(selected->value) = ! *(selected->value);
66
if (result == HANDLED) {
67
this->settings->changed = true;
68
Header* header = this->settings->header;
69
Header_calculateHeight(header);
71
ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);