aboutsummaryrefslogtreecommitdiffstats
path: root/ColorsPanel.c
diff options
context:
space:
mode:
Diffstat (limited to 'ColorsPanel.c')
-rw-r--r--ColorsPanel.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/ColorsPanel.c b/ColorsPanel.c
index 5e58670..4e28d01 100644
--- a/ColorsPanel.c
+++ b/ColorsPanel.c
@@ -1,14 +1,18 @@
+/*
+htop - ColorsPanel.c
+(C) 2004-2011 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
-#include "CRT.h"
#include "ColorsPanel.h"
-#include "Panel.h"
+#include "CRT.h"
#include "CheckItem.h"
-#include "Settings.h"
-#include "ScreenManager.h"
-#include "debug.h"
#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
// TO ADD A NEW SCHEME:
// * Increment the size of bool check in ColorsPanel.h
@@ -17,6 +21,9 @@
// * Add the colors in CRT_setColors
/*{
+#include "Panel.h"
+#include "Settings.h"
+#include "ScreenManager.h"
typedef struct ColorsPanel_ {
Panel super;
@@ -44,7 +51,7 @@ static void ColorsPanel_delete(Object* object) {
free(this);
}
-static HandlerResult ColorsPanel_EventHandler(Panel* super, int ch) {
+static HandlerResult ColorsPanel_eventHandler(Panel* super, int ch) {
ColorsPanel* this = (ColorsPanel*) super;
HandlerResult result = IGNORED;
@@ -67,7 +74,7 @@ static HandlerResult ColorsPanel_EventHandler(Panel* super, int ch) {
this->settings->changed = true;
Header* header = this->settings->header;
CRT_setColors(mark);
- Panel* menu = (Panel*) Vector_get(this->scr->items, 0);
+ Panel* menu = (Panel*) Vector_get(this->scr->panels, 0);
Header_draw(header);
RichString_setAttr(&(super->header), CRT_colors[PANEL_HEADER_FOCUS]);
RichString_setAttr(&(menu->header), CRT_colors[PANEL_HEADER_UNFOCUS]);
@@ -76,19 +83,25 @@ static HandlerResult ColorsPanel_EventHandler(Panel* super, int ch) {
return result;
}
+PanelClass ColorsPanel_class = {
+ .super = {
+ .extends = Class(Panel),
+ .delete = ColorsPanel_delete
+ },
+ .eventHandler = ColorsPanel_eventHandler
+};
+
ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr) {
- ColorsPanel* this = (ColorsPanel*) malloc(sizeof(ColorsPanel));
+ ColorsPanel* this = AllocThis(ColorsPanel);
Panel* super = (Panel*) this;
- Panel_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true);
- ((Object*)this)->delete = ColorsPanel_delete;
+ Panel_init(super, 1, 1, 1, 1, Class(CheckItem), true);
this->settings = settings;
this->scr = scr;
- super->eventHandler = ColorsPanel_EventHandler;
Panel_setHeader(super, "Colors");
for (int i = 0; ColorSchemes[i] != NULL; i++) {
- Panel_add(super, (Object*) CheckItem_new(String_copy(ColorSchemes[i]), NULL, false));
+ Panel_add(super, (Object*) CheckItem_new(strdup(ColorSchemes[i]), NULL, false));
}
CheckItem_set((CheckItem*)Panel_get(super, settings->colorScheme), true);
return this;